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