blob: 1f6ed5791359ef4676e9c1404030957336197368 [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
Steven Moreland23646142017-04-07 10:46:25 -070020#include <log/log.h>
21#include <hwbinder/IPCThreadState.h>
22#include <mediautils/SchedulingPolicyService.h>
23
24namespace android {
25namespace frameworks {
26namespace schedulerservice {
27namespace V1_0 {
28namespace implementation {
29
Steven Moreland3ac75762017-04-10 22:09:03 -070030bool SchedulingPolicyService::isAllowed() {
Peng Xu76dc5952017-04-10 22:16:48 -070031 // TODO(b/37291237)
32 return true;
Steven Moreland3ac75762017-04-10 22:09:03 -070033}
34
35Return<bool> SchedulingPolicyService::requestPriority(int32_t pid, int32_t tid, int32_t priority) {
Steven Moreland23646142017-04-07 10:46:25 -070036 if (priority < static_cast<int32_t>(Priority::MIN) ||
37 priority > static_cast<int32_t>(Priority::MAX)) {
38 return false;
39 }
40
Steven Moreland3ac75762017-04-10 22:09:03 -070041 if (!isAllowed()) {
Steven Moreland23646142017-04-07 10:46:25 -070042 return false;
43 }
44
Steven Moreland3ac75762017-04-10 22:09:03 -070045 // TODO(b/37226359): decouple from and remove AIDL service
Steven Moreland23646142017-04-07 10:46:25 -070046 // this should always be allowed since we are in system_server.
47 int value = ::android::requestPriority(pid, tid, priority, false /* isForApp */);
48 return value == 0 /* success */;
49}
50
Steven Moreland3ac75762017-04-10 22:09:03 -070051Return<int32_t> SchedulingPolicyService::getMaxAllowedPriority() {
52 if (!isAllowed()) {
53 return 0;
54 }
55
56 // TODO(b/37226359): decouple from and remove AIDL service
57 return 3;
58}
59
Steven Moreland23646142017-04-07 10:46:25 -070060} // namespace implementation
61} // namespace V1_0
62} // namespace schedulerservice
63} // namespace frameworks
64} // namespace android