Dianne Hackborn | 5da5ca5 | 2013-02-12 15:12:21 -0800 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2013 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 "AppOpsCallback" |
| 18 | |
| 19 | #include <binder/IAppOpsCallback.h> |
| 20 | |
Dianne Hackborn | 5da5ca5 | 2013-02-12 15:12:21 -0800 | [diff] [blame] | 21 | #include <utils/Log.h> |
| 22 | #include <binder/Parcel.h> |
| 23 | #include <utils/String8.h> |
| 24 | |
| 25 | #include <private/binder/Static.h> |
| 26 | |
| 27 | namespace android { |
| 28 | |
| 29 | // ---------------------------------------------------------------------- |
| 30 | |
| 31 | class BpAppOpsCallback : public BpInterface<IAppOpsCallback> |
| 32 | { |
| 33 | public: |
Chih-Hung Hsieh | e2347b7 | 2016-04-25 15:41:05 -0700 | [diff] [blame] | 34 | explicit BpAppOpsCallback(const sp<IBinder>& impl) |
Dianne Hackborn | 5da5ca5 | 2013-02-12 15:12:21 -0800 | [diff] [blame] | 35 | : BpInterface<IAppOpsCallback>(impl) |
| 36 | { |
| 37 | } |
| 38 | |
| 39 | virtual void opChanged(int32_t op, const String16& packageName) { |
| 40 | Parcel data, reply; |
| 41 | data.writeInterfaceToken(IAppOpsCallback::getInterfaceDescriptor()); |
| 42 | data.writeInt32(op); |
| 43 | data.writeString16(packageName); |
| 44 | remote()->transact(OP_CHANGED_TRANSACTION, data, &reply); |
| 45 | } |
| 46 | }; |
| 47 | |
| 48 | IMPLEMENT_META_INTERFACE(AppOpsCallback, "com.android.internal.app.IAppOpsCallback"); |
| 49 | |
| 50 | // ---------------------------------------------------------------------- |
| 51 | |
Jiyong Park | b86c866 | 2018-10-29 23:01:57 +0900 | [diff] [blame] | 52 | // NOLINTNEXTLINE(google-default-arguments) |
Dianne Hackborn | 5da5ca5 | 2013-02-12 15:12:21 -0800 | [diff] [blame] | 53 | status_t BnAppOpsCallback::onTransact( |
| 54 | uint32_t code, const Parcel& data, Parcel* reply, uint32_t flags) |
| 55 | { |
| 56 | switch(code) { |
| 57 | case OP_CHANGED_TRANSACTION: { |
| 58 | CHECK_INTERFACE(IAppOpsCallback, data, reply); |
| 59 | int32_t op = data.readInt32(); |
Mikhail Naganov | 29fef7d | 2019-04-23 10:19:51 -0700 | [diff] [blame^] | 60 | String16 packageName; |
| 61 | (void)data.readString16(&packageName); |
Dianne Hackborn | 5da5ca5 | 2013-02-12 15:12:21 -0800 | [diff] [blame] | 62 | opChanged(op, packageName); |
| 63 | reply->writeNoException(); |
| 64 | return NO_ERROR; |
| 65 | } break; |
| 66 | default: |
| 67 | return BBinder::onTransact(code, data, reply, flags); |
| 68 | } |
| 69 | } |
| 70 | |
| 71 | }; // namespace android |