| 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 |  | 
|  | 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 |  | 
|  | 26 | namespace android { | 
|  | 27 | namespace frameworks { | 
|  | 28 | namespace schedulerservice { | 
|  | 29 | namespace V1_0 { | 
|  | 30 | namespace implementation { | 
|  | 31 |  | 
|  | 32 | Return<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 |