Home | History | Annotate | Download | only in schedulerservice
      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 
     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 
     30 bool SchedulingPolicyService::isAllowed() {
     31     // TODO(b/37291237)
     32     return true;
     33 }
     34 
     35 Return<bool> SchedulingPolicyService::requestPriority(int32_t pid, int32_t tid, int32_t priority) {
     36     if (priority < static_cast<int32_t>(Priority::MIN) ||
     37             priority > static_cast<int32_t>(Priority::MAX)) {
     38         return false;
     39     }
     40 
     41     if (!isAllowed()) {
     42         return false;
     43     }
     44 
     45     // TODO(b/37226359): decouple from and remove AIDL service
     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 
     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 
     60 }  // namespace implementation
     61 }  // namespace V1_0
     62 }  // namespace schedulerservice
     63 }  // namespace frameworks
     64 }  // namespace android
     65