blob: 522a8c09506a0f231742ef33026c7d9e736695d8 [file] [log] [blame]
Steven Moreland23646142017-04-07 10:46:25 -07001/*
2 * Copyright (C) 2017 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#define LOG_TAG "schedulerservicehidl"
17
18#include "SchedulingPolicyService.h"
19
20#include <private/android_filesystem_config.h> // for AID_CAMERASERVER
21
22#include <log/log.h>
23#include <hwbinder/IPCThreadState.h>
24#include <mediautils/SchedulingPolicyService.h>
25
26namespace android {
27namespace frameworks {
28namespace schedulerservice {
29namespace V1_0 {
30namespace implementation {
31
32Return<bool> SchedulingPolicyService::requestPriority(int32_t pid, int32_t tid, int32_t priority) {
33 using ::android::hardware::IPCThreadState;
34
35 if (priority < static_cast<int32_t>(Priority::MIN) ||
36 priority > static_cast<int32_t>(Priority::MAX)) {
37 return false;
38 }
39
40 if (IPCThreadState::self()->getCallingUid() != AID_CAMERASERVER) {
41 return false;
42 }
43
44 // this should always be allowed since we are in system_server.
45 int value = ::android::requestPriority(pid, tid, priority, false /* isForApp */);
46 return value == 0 /* success */;
47}
48
49} // namespace implementation
50} // namespace V1_0
51} // namespace schedulerservice
52} // namespace frameworks
53} // namespace android