blob: ea2e32c013f43e120a92631baf396531abb69aa3 [file] [log] [blame]
Steven Moreland11a732a2017-03-07 17:44:17 -08001/*
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 Moreland11a732a2017-03-07 17:44:17 -080017#include <hidl/HidlBinderSupport.h>
18
19namespace android {
20namespace hardware {
21
22void configureRpcThreadpool(size_t maxThreads, bool callerWillJoin) {
23 // TODO(b/32756130) this should be transport-dependent
24 configureBinderRpcThreadpool(maxThreads, callerWillJoin);
25}
26void joinRpcThreadpool() {
27 // TODO(b/32756130) this should be transport-dependent
28 joinBinderRpcThreadpool();
29}
30
Martijn Coenen81ef4da2017-04-21 16:21:31 -070031bool setMinSchedulerPolicy(const sp<::android::hidl::base::V1_0::IBase>& service,
32 int policy, int priority) {
33 if (service->isRemote()) {
34 ALOGE("Can't set scheduler policy on remote service.");
35 return false;
36 }
37
38 if (policy != SCHED_NORMAL && policy != SCHED_FIFO && policy != SCHED_RR) {
39 ALOGE("Invalid scheduler policy %d", policy);
40 return false;
41 }
42
43 if (policy == SCHED_NORMAL && (priority < -20 || priority > 19)) {
44 ALOGE("Invalid priority for SCHED_NORMAL: %d", priority);
45 return false;
46 } else if (priority < 1 || priority > 99) {
47 ALOGE("Invalid priority for real-time policy: %d", priority);
48 return false;
49 }
50
51 details::gServicePrioMap.set(service, { policy, priority });
52
53 return true;
Steven Moreland11a732a2017-03-07 17:44:17 -080054}
Martijn Coenen81ef4da2017-04-21 16:21:31 -070055
56}
57}