Steven Moreland | 2364614 | 2017-04-07 10:46:25 -0700 | [diff] [blame] | 1 | /* |
| 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 Moreland | 2364614 | 2017-04-07 10:46:25 -0700 | [diff] [blame] | 20 | #include <log/log.h> |
| 21 | #include <hwbinder/IPCThreadState.h> |
| 22 | #include <mediautils/SchedulingPolicyService.h> |
| 23 | |
| 24 | namespace android { |
| 25 | namespace frameworks { |
| 26 | namespace schedulerservice { |
| 27 | namespace V1_0 { |
| 28 | namespace implementation { |
| 29 | |
Steven Moreland | 3ac7576 | 2017-04-10 22:09:03 -0700 | [diff] [blame] | 30 | bool SchedulingPolicyService::isAllowed() { |
Peng Xu | 76dc595 | 2017-04-10 22:16:48 -0700 | [diff] [blame] | 31 | // TODO(b/37291237) |
| 32 | return true; |
Steven Moreland | 3ac7576 | 2017-04-10 22:09:03 -0700 | [diff] [blame] | 33 | } |
| 34 | |
| 35 | Return<bool> SchedulingPolicyService::requestPriority(int32_t pid, int32_t tid, int32_t priority) { |
Steven Moreland | 2364614 | 2017-04-07 10:46:25 -0700 | [diff] [blame] | 36 | if (priority < static_cast<int32_t>(Priority::MIN) || |
| 37 | priority > static_cast<int32_t>(Priority::MAX)) { |
| 38 | return false; |
| 39 | } |
| 40 | |
Steven Moreland | 3ac7576 | 2017-04-10 22:09:03 -0700 | [diff] [blame] | 41 | if (!isAllowed()) { |
Steven Moreland | 2364614 | 2017-04-07 10:46:25 -0700 | [diff] [blame] | 42 | return false; |
| 43 | } |
| 44 | |
Steven Moreland | 3ac7576 | 2017-04-10 22:09:03 -0700 | [diff] [blame] | 45 | // TODO(b/37226359): decouple from and remove AIDL service |
Steven Moreland | 2364614 | 2017-04-07 10:46:25 -0700 | [diff] [blame] | 46 | // 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 Moreland | 3ac7576 | 2017-04-10 22:09:03 -0700 | [diff] [blame] | 51 | Return<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 Moreland | 2364614 | 2017-04-07 10:46:25 -0700 | [diff] [blame] | 60 | } // namespace implementation |
| 61 | } // namespace V1_0 |
| 62 | } // namespace schedulerservice |
| 63 | } // namespace frameworks |
| 64 | } // namespace android |