blob: f5bfe20a56798ffc4b0b42789f75f561281424e7 [file] [log] [blame]
Glenn Kasten1dc28b72012-04-24 10:01:03 -07001/*
2 * Copyright (C) 2012 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
Eric Laurentf59a4b32013-07-02 11:15:41 -070017#define LOG_TAG "ISchedulingPolicyService"
Glenn Kasten1dc28b72012-04-24 10:01:03 -070018//#define LOG_NDEBUG 0
19
20#include <binder/Parcel.h>
21#include "ISchedulingPolicyService.h"
22
23namespace android {
24
25// Keep in sync with frameworks/base/core/java/android/os/ISchedulingPolicyService.aidl
26enum {
27 REQUEST_PRIORITY_TRANSACTION = IBinder::FIRST_CALL_TRANSACTION,
28};
29
30// ----------------------------------------------------------------------
31
32class BpSchedulingPolicyService : public BpInterface<ISchedulingPolicyService>
33{
34public:
Chih-Hung Hsieh090ef602016-04-27 10:39:54 -070035 explicit BpSchedulingPolicyService(const sp<IBinder>& impl)
Glenn Kasten1dc28b72012-04-24 10:01:03 -070036 : BpInterface<ISchedulingPolicyService>(impl)
37 {
38 }
39
Glenn Kastenf8197a62013-04-23 12:39:37 -070040 virtual int requestPriority(int32_t pid, int32_t tid, int32_t prio, bool asynchronous)
Glenn Kasten1dc28b72012-04-24 10:01:03 -070041 {
42 Parcel data, reply;
43 data.writeInterfaceToken(ISchedulingPolicyService::getInterfaceDescriptor());
44 data.writeInt32(pid);
45 data.writeInt32(tid);
46 data.writeInt32(prio);
Glenn Kastenf8197a62013-04-23 12:39:37 -070047 uint32_t flags = asynchronous ? IBinder::FLAG_ONEWAY : 0;
Eric Laurentf59a4b32013-07-02 11:15:41 -070048 status_t status = remote()->transact(REQUEST_PRIORITY_TRANSACTION, data, &reply, flags);
49 if (status != NO_ERROR) {
50 return status;
51 }
52 if (asynchronous) {
53 return NO_ERROR;
54 }
55 // fail on exception: force binder reconnection
56 if (reply.readExceptionCode() != 0) {
57 return DEAD_OBJECT;
58 }
Glenn Kasten1dc28b72012-04-24 10:01:03 -070059 return reply.readInt32();
60 }
61};
62
63IMPLEMENT_META_INTERFACE(SchedulingPolicyService, "android.os.ISchedulingPolicyService");
64
65// ----------------------------------------------------------------------
66
67status_t BnSchedulingPolicyService::onTransact(
68 uint32_t code, const Parcel& data, Parcel* reply, uint32_t flags)
69{
70 switch (code) {
71 case REQUEST_PRIORITY_TRANSACTION:
72 // Not reached
73 return NO_ERROR;
74 break;
75 default:
76 return BBinder::onTransact(code, data, reply, flags);
77 }
78}
79
80} // namespace android