11dc28b794587be22c90a97070d928f94586db638Glenn Kasten/*
21dc28b794587be22c90a97070d928f94586db638Glenn Kasten * Copyright (C) 2012 The Android Open Source Project
31dc28b794587be22c90a97070d928f94586db638Glenn Kasten *
41dc28b794587be22c90a97070d928f94586db638Glenn Kasten * Licensed under the Apache License, Version 2.0 (the "License");
51dc28b794587be22c90a97070d928f94586db638Glenn Kasten * you may not use this file except in compliance with the License.
61dc28b794587be22c90a97070d928f94586db638Glenn Kasten * You may obtain a copy of the License at
71dc28b794587be22c90a97070d928f94586db638Glenn Kasten *
81dc28b794587be22c90a97070d928f94586db638Glenn Kasten *      http://www.apache.org/licenses/LICENSE-2.0
91dc28b794587be22c90a97070d928f94586db638Glenn Kasten *
101dc28b794587be22c90a97070d928f94586db638Glenn Kasten * Unless required by applicable law or agreed to in writing, software
111dc28b794587be22c90a97070d928f94586db638Glenn Kasten * distributed under the License is distributed on an "AS IS" BASIS,
121dc28b794587be22c90a97070d928f94586db638Glenn Kasten * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
131dc28b794587be22c90a97070d928f94586db638Glenn Kasten * See the License for the specific language governing permissions and
141dc28b794587be22c90a97070d928f94586db638Glenn Kasten * limitations under the License.
151dc28b794587be22c90a97070d928f94586db638Glenn Kasten */
161dc28b794587be22c90a97070d928f94586db638Glenn Kasten
171dc28b794587be22c90a97070d928f94586db638Glenn Kasten#define LOG_TAG "SchedulingPolicyService"
181dc28b794587be22c90a97070d928f94586db638Glenn Kasten//#define LOG_NDEBUG 0
191dc28b794587be22c90a97070d928f94586db638Glenn Kasten
201dc28b794587be22c90a97070d928f94586db638Glenn Kasten#include <binder/Parcel.h>
211dc28b794587be22c90a97070d928f94586db638Glenn Kasten#include "ISchedulingPolicyService.h"
221dc28b794587be22c90a97070d928f94586db638Glenn Kasten
231dc28b794587be22c90a97070d928f94586db638Glenn Kastennamespace android {
241dc28b794587be22c90a97070d928f94586db638Glenn Kasten
251dc28b794587be22c90a97070d928f94586db638Glenn Kasten// Keep in sync with frameworks/base/core/java/android/os/ISchedulingPolicyService.aidl
261dc28b794587be22c90a97070d928f94586db638Glenn Kastenenum {
271dc28b794587be22c90a97070d928f94586db638Glenn Kasten    REQUEST_PRIORITY_TRANSACTION = IBinder::FIRST_CALL_TRANSACTION,
281dc28b794587be22c90a97070d928f94586db638Glenn Kasten};
291dc28b794587be22c90a97070d928f94586db638Glenn Kasten
301dc28b794587be22c90a97070d928f94586db638Glenn Kasten// ----------------------------------------------------------------------
311dc28b794587be22c90a97070d928f94586db638Glenn Kasten
321dc28b794587be22c90a97070d928f94586db638Glenn Kastenclass BpSchedulingPolicyService : public BpInterface<ISchedulingPolicyService>
331dc28b794587be22c90a97070d928f94586db638Glenn Kasten{
341dc28b794587be22c90a97070d928f94586db638Glenn Kastenpublic:
351dc28b794587be22c90a97070d928f94586db638Glenn Kasten    BpSchedulingPolicyService(const sp<IBinder>& impl)
361dc28b794587be22c90a97070d928f94586db638Glenn Kasten        : BpInterface<ISchedulingPolicyService>(impl)
371dc28b794587be22c90a97070d928f94586db638Glenn Kasten    {
381dc28b794587be22c90a97070d928f94586db638Glenn Kasten    }
391dc28b794587be22c90a97070d928f94586db638Glenn Kasten
401dc28b794587be22c90a97070d928f94586db638Glenn Kasten    virtual int requestPriority(int32_t pid, int32_t tid, int32_t prio)
411dc28b794587be22c90a97070d928f94586db638Glenn Kasten    {
421dc28b794587be22c90a97070d928f94586db638Glenn Kasten        Parcel data, reply;
431dc28b794587be22c90a97070d928f94586db638Glenn Kasten        data.writeInterfaceToken(ISchedulingPolicyService::getInterfaceDescriptor());
441dc28b794587be22c90a97070d928f94586db638Glenn Kasten        data.writeInt32(pid);
451dc28b794587be22c90a97070d928f94586db638Glenn Kasten        data.writeInt32(tid);
461dc28b794587be22c90a97070d928f94586db638Glenn Kasten        data.writeInt32(prio);
471dc28b794587be22c90a97070d928f94586db638Glenn Kasten        remote()->transact(REQUEST_PRIORITY_TRANSACTION, data, &reply);
481dc28b794587be22c90a97070d928f94586db638Glenn Kasten        // fail on exception
491dc28b794587be22c90a97070d928f94586db638Glenn Kasten        if (reply.readExceptionCode() != 0) return -1;
501dc28b794587be22c90a97070d928f94586db638Glenn Kasten        return reply.readInt32();
511dc28b794587be22c90a97070d928f94586db638Glenn Kasten    }
521dc28b794587be22c90a97070d928f94586db638Glenn Kasten};
531dc28b794587be22c90a97070d928f94586db638Glenn Kasten
541dc28b794587be22c90a97070d928f94586db638Glenn KastenIMPLEMENT_META_INTERFACE(SchedulingPolicyService, "android.os.ISchedulingPolicyService");
551dc28b794587be22c90a97070d928f94586db638Glenn Kasten
561dc28b794587be22c90a97070d928f94586db638Glenn Kasten// ----------------------------------------------------------------------
571dc28b794587be22c90a97070d928f94586db638Glenn Kasten
581dc28b794587be22c90a97070d928f94586db638Glenn Kastenstatus_t BnSchedulingPolicyService::onTransact(
591dc28b794587be22c90a97070d928f94586db638Glenn Kasten    uint32_t code, const Parcel& data, Parcel* reply, uint32_t flags)
601dc28b794587be22c90a97070d928f94586db638Glenn Kasten{
611dc28b794587be22c90a97070d928f94586db638Glenn Kasten    switch (code) {
621dc28b794587be22c90a97070d928f94586db638Glenn Kasten    case REQUEST_PRIORITY_TRANSACTION:
631dc28b794587be22c90a97070d928f94586db638Glenn Kasten        // Not reached
641dc28b794587be22c90a97070d928f94586db638Glenn Kasten        return NO_ERROR;
651dc28b794587be22c90a97070d928f94586db638Glenn Kasten        break;
661dc28b794587be22c90a97070d928f94586db638Glenn Kasten    default:
671dc28b794587be22c90a97070d928f94586db638Glenn Kasten        return BBinder::onTransact(code, data, reply, flags);
681dc28b794587be22c90a97070d928f94586db638Glenn Kasten    }
691dc28b794587be22c90a97070d928f94586db638Glenn Kasten}
701dc28b794587be22c90a97070d928f94586db638Glenn Kasten
711dc28b794587be22c90a97070d928f94586db638Glenn Kasten}   // namespace android
72