Steven Moreland | 11a732a | 2017-03-07 17:44:17 -0800 | [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 | #include <hidl/HidlTransportSupport.h> |
Steven Moreland | 11a732a | 2017-03-07 17:44:17 -0800 | [diff] [blame] | 17 | #include <hidl/HidlBinderSupport.h> |
| 18 | |
Yifan Hong | a8b6eab | 2017-11-22 22:15:39 -0800 | [diff] [blame] | 19 | #include <android/hidl/manager/1.0/IServiceManager.h> |
| 20 | |
Steven Moreland | 11a732a | 2017-03-07 17:44:17 -0800 | [diff] [blame] | 21 | namespace android { |
| 22 | namespace hardware { |
| 23 | |
| 24 | void configureRpcThreadpool(size_t maxThreads, bool callerWillJoin) { |
| 25 | // TODO(b/32756130) this should be transport-dependent |
| 26 | configureBinderRpcThreadpool(maxThreads, callerWillJoin); |
| 27 | } |
| 28 | void joinRpcThreadpool() { |
| 29 | // TODO(b/32756130) this should be transport-dependent |
| 30 | joinBinderRpcThreadpool(); |
| 31 | } |
| 32 | |
Martijn Coenen | 3f5ac4c | 2017-11-27 15:09:28 -0800 | [diff] [blame^] | 33 | int setupTransportPolling() { |
| 34 | return setupBinderPolling(); |
| 35 | } |
| 36 | |
| 37 | status_t handleTransportPoll(int /*fd*/) { |
| 38 | return handleBinderPoll(); |
| 39 | } |
| 40 | |
Martijn Coenen | 81ef4da | 2017-04-21 16:21:31 -0700 | [diff] [blame] | 41 | bool setMinSchedulerPolicy(const sp<::android::hidl::base::V1_0::IBase>& service, |
| 42 | int policy, int priority) { |
| 43 | if (service->isRemote()) { |
| 44 | ALOGE("Can't set scheduler policy on remote service."); |
| 45 | return false; |
| 46 | } |
| 47 | |
| 48 | if (policy != SCHED_NORMAL && policy != SCHED_FIFO && policy != SCHED_RR) { |
| 49 | ALOGE("Invalid scheduler policy %d", policy); |
| 50 | return false; |
| 51 | } |
| 52 | |
| 53 | if (policy == SCHED_NORMAL && (priority < -20 || priority > 19)) { |
| 54 | ALOGE("Invalid priority for SCHED_NORMAL: %d", priority); |
| 55 | return false; |
| 56 | } else if (priority < 1 || priority > 99) { |
| 57 | ALOGE("Invalid priority for real-time policy: %d", priority); |
| 58 | return false; |
| 59 | } |
| 60 | |
| 61 | details::gServicePrioMap.set(service, { policy, priority }); |
| 62 | |
| 63 | return true; |
Steven Moreland | 11a732a | 2017-03-07 17:44:17 -0800 | [diff] [blame] | 64 | } |
Martijn Coenen | 81ef4da | 2017-04-21 16:21:31 -0700 | [diff] [blame] | 65 | |
Yifan Hong | 7a4b756 | 2017-11-20 11:36:51 -0800 | [diff] [blame] | 66 | namespace details { |
| 67 | int32_t getPidIfSharable() { |
| 68 | #if LIBHIDL_TARGET_DEBUGGABLE |
| 69 | return getpid(); |
| 70 | #else |
| 71 | using android::hidl::manager::V1_0::IServiceManager; |
Yifan Hong | a8b6eab | 2017-11-22 22:15:39 -0800 | [diff] [blame] | 72 | return static_cast<int32_t>(IServiceManager::PidConstant::NO_PID); |
Yifan Hong | 7a4b756 | 2017-11-20 11:36:51 -0800 | [diff] [blame] | 73 | #endif |
| 74 | } |
| 75 | } // namespace details |
| 76 | |
Steven Moreland | a15479f | 2017-10-06 16:06:26 -0700 | [diff] [blame] | 77 | } // namespace hardware |
| 78 | } // namespace android |