blob: c13030b1eddbefedb375d4a1e0e8314f0bf6c973 [file] [log] [blame]
Jayant Chowdharyad9fe272019-03-07 22:36:06 -08001/*
2 * Copyright 2019 The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17#include <binder/IPCThreadState.h>
Steven Moreland2b3f3cd2020-01-31 14:56:45 -080018#include <binderthreadstate/CallerUtils.h>
Jayant Chowdharyad9fe272019-03-07 22:36:06 -080019#include <hwbinder/IPCThreadState.h>
20#include <private/gui/BufferQueueThreadState.h>
21#include <unistd.h>
22
23namespace android {
24
25uid_t BufferQueueThreadState::getCallingUid() {
Steven Moreland2b3f3cd2020-01-31 14:56:45 -080026 if (getCurrentServingCall() == BinderCallType::HWBINDER) {
Jayant Chowdharyad9fe272019-03-07 22:36:06 -080027 return hardware::IPCThreadState::self()->getCallingUid();
28 }
29 return IPCThreadState::self()->getCallingUid();
30}
31
32pid_t BufferQueueThreadState::getCallingPid() {
Steven Moreland2b3f3cd2020-01-31 14:56:45 -080033 if (getCurrentServingCall() == BinderCallType::HWBINDER) {
Jayant Chowdharyad9fe272019-03-07 22:36:06 -080034 return hardware::IPCThreadState::self()->getCallingPid();
35 }
36 return IPCThreadState::self()->getCallingPid();
37}
38
39} // namespace android