1/* 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 17#define LOG_TAG "SchedulingPolicyService" 18//#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: 35 BpSchedulingPolicyService(const sp<IBinder>& impl) 36 : BpInterface<ISchedulingPolicyService>(impl) 37 { 38 } 39 40 virtual int requestPriority(int32_t pid, int32_t tid, int32_t prio) 41 { 42 Parcel data, reply; 43 data.writeInterfaceToken(ISchedulingPolicyService::getInterfaceDescriptor()); 44 data.writeInt32(pid); 45 data.writeInt32(tid); 46 data.writeInt32(prio); 47 remote()->transact(REQUEST_PRIORITY_TRANSACTION, data, &reply); 48 // fail on exception 49 if (reply.readExceptionCode() != 0) return -1; 50 return reply.readInt32(); 51 } 52}; 53 54IMPLEMENT_META_INTERFACE(SchedulingPolicyService, "android.os.ISchedulingPolicyService"); 55 56// ---------------------------------------------------------------------- 57 58status_t BnSchedulingPolicyService::onTransact( 59 uint32_t code, const Parcel& data, Parcel* reply, uint32_t flags) 60{ 61 switch (code) { 62 case REQUEST_PRIORITY_TRANSACTION: 63 // Not reached 64 return NO_ERROR; 65 break; 66 default: 67 return BBinder::onTransact(code, data, reply, flags); 68 } 69} 70 71} // namespace android 72