| 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 | // |
| 18 | #ifndef ANDROID_IAPP_OPS_SERVICE_H |
| 19 | #define ANDROID_IAPP_OPS_SERVICE_H |
| 20 | |
| Jiyong Park | 47f876b | 2018-04-17 13:56:46 +0900 | [diff] [blame] | 21 | #ifndef __ANDROID_VNDK__ |
| 22 | |
| Dianne Hackborn | 5da5ca5 | 2013-02-12 15:12:21 -0800 | [diff] [blame] | 23 | #include <binder/IAppOpsCallback.h> |
| 24 | #include <binder/IInterface.h> |
| 25 | |
| 26 | namespace android { |
| 27 | |
| 28 | // ---------------------------------------------------------------------- |
| 29 | |
| 30 | class IAppOpsService : public IInterface |
| 31 | { |
| 32 | public: |
| Colin Cross | 17576de | 2016-09-26 13:07:06 -0700 | [diff] [blame] | 33 | DECLARE_META_INTERFACE(AppOpsService) |
| Dianne Hackborn | 5da5ca5 | 2013-02-12 15:12:21 -0800 | [diff] [blame] | 34 | |
| 35 | virtual int32_t checkOperation(int32_t code, int32_t uid, const String16& packageName) = 0; |
| 36 | virtual int32_t noteOperation(int32_t code, int32_t uid, const String16& packageName) = 0; |
| Dianne Hackborn | 913b63d | 2013-07-17 17:26:15 -0700 | [diff] [blame] | 37 | virtual int32_t startOperation(const sp<IBinder>& token, int32_t code, int32_t uid, |
| Svet Ganov | 616554c | 2018-02-26 13:27:26 -0800 | [diff] [blame] | 38 | const String16& packageName, bool startIfModeDefault) = 0; |
| Dianne Hackborn | 913b63d | 2013-07-17 17:26:15 -0700 | [diff] [blame] | 39 | virtual void finishOperation(const sp<IBinder>& token, int32_t code, int32_t uid, |
| 40 | const String16& packageName) = 0; |
| Dianne Hackborn | 5da5ca5 | 2013-02-12 15:12:21 -0800 | [diff] [blame] | 41 | virtual void startWatchingMode(int32_t op, const String16& packageName, |
| 42 | const sp<IAppOpsCallback>& callback) = 0; |
| 43 | virtual void stopWatchingMode(const sp<IAppOpsCallback>& callback) = 0; |
| Dianne Hackborn | 913b63d | 2013-07-17 17:26:15 -0700 | [diff] [blame] | 44 | virtual sp<IBinder> getToken(const sp<IBinder>& clientToken) = 0; |
| Svetoslav | b412f6e | 2015-04-29 16:50:41 -0700 | [diff] [blame] | 45 | virtual int32_t permissionToOpCode(const String16& permission) = 0; |
| Jean-Michel Trivi | 94a566d | 2019-02-25 12:16:02 -0800 | [diff] [blame] | 46 | virtual int32_t checkAudioOperation(int32_t code, int32_t usage,int32_t uid, |
| 47 | const String16& packageName) = 0; |
| Dianne Hackborn | 5da5ca5 | 2013-02-12 15:12:21 -0800 | [diff] [blame] | 48 | |
| 49 | enum { |
| 50 | CHECK_OPERATION_TRANSACTION = IBinder::FIRST_CALL_TRANSACTION, |
| 51 | NOTE_OPERATION_TRANSACTION = IBinder::FIRST_CALL_TRANSACTION+1, |
| 52 | START_OPERATION_TRANSACTION = IBinder::FIRST_CALL_TRANSACTION+2, |
| 53 | FINISH_OPERATION_TRANSACTION = IBinder::FIRST_CALL_TRANSACTION+3, |
| 54 | START_WATCHING_MODE_TRANSACTION = IBinder::FIRST_CALL_TRANSACTION+4, |
| Dianne Hackborn | 913b63d | 2013-07-17 17:26:15 -0700 | [diff] [blame] | 55 | STOP_WATCHING_MODE_TRANSACTION = IBinder::FIRST_CALL_TRANSACTION+5, |
| 56 | GET_TOKEN_TRANSACTION = IBinder::FIRST_CALL_TRANSACTION+6, |
| Svetoslav | b412f6e | 2015-04-29 16:50:41 -0700 | [diff] [blame] | 57 | PERMISSION_TO_OP_CODE_TRANSACTION = IBinder::FIRST_CALL_TRANSACTION+7, |
| Jean-Michel Trivi | 94a566d | 2019-02-25 12:16:02 -0800 | [diff] [blame] | 58 | CHECK_AUDIO_OPERATION_TRANSACTION = IBinder::FIRST_CALL_TRANSACTION+8, |
| Dianne Hackborn | 5da5ca5 | 2013-02-12 15:12:21 -0800 | [diff] [blame] | 59 | }; |
| Eino-Ville Talvala | e88a85e | 2013-02-19 12:54:57 -0800 | [diff] [blame] | 60 | |
| 61 | enum { |
| 62 | MODE_ALLOWED = 0, |
| 63 | MODE_IGNORED = 1, |
| 64 | MODE_ERRORED = 2 |
| 65 | }; |
| Dianne Hackborn | 5da5ca5 | 2013-02-12 15:12:21 -0800 | [diff] [blame] | 66 | }; |
| 67 | |
| 68 | // ---------------------------------------------------------------------- |
| 69 | |
| 70 | class BnAppOpsService : public BnInterface<IAppOpsService> |
| 71 | { |
| 72 | public: |
| Jiyong Park | b86c866 | 2018-10-29 23:01:57 +0900 | [diff] [blame] | 73 | // NOLINTNEXTLINE(google-default-arguments) |
| Dianne Hackborn | 5da5ca5 | 2013-02-12 15:12:21 -0800 | [diff] [blame] | 74 | virtual status_t onTransact( uint32_t code, |
| 75 | const Parcel& data, |
| 76 | Parcel* reply, |
| 77 | uint32_t flags = 0); |
| 78 | }; |
| 79 | |
| 80 | // ---------------------------------------------------------------------- |
| 81 | |
| 82 | }; // namespace android |
| 83 | |
| Jiyong Park | 47f876b | 2018-04-17 13:56:46 +0900 | [diff] [blame] | 84 | #else // __ANDROID_VNDK__ |
| 85 | #error "This header is not visible to vendors" |
| 86 | #endif // __ANDROID_VNDK__ |
| 87 | |
| Dianne Hackborn | 5da5ca5 | 2013-02-12 15:12:21 -0800 | [diff] [blame] | 88 | #endif // ANDROID_IAPP_OPS_SERVICE_H |