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 21 #ifndef __ANDROID_VNDK__ 22 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: 33 DECLARE_META_INTERFACE(AppOpsService) 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; 37 virtual int32_t startOperation(const sp<IBinder>& token, int32_t code, int32_t uid, 38 const String16& packageName, bool startIfModeDefault) = 0; 39 virtual void finishOperation(const sp<IBinder>& token, int32_t code, int32_t uid, 40 const String16& packageName) = 0; 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; 44 virtual sp<IBinder> getToken(const sp<IBinder>& clientToken) = 0; 45 virtual int32_t permissionToOpCode(const String16& permission) = 0; 46 virtual int32_t checkAudioOperation(int32_t code, int32_t usage,int32_t uid, 47 const String16& packageName) = 0; 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, 55 STOP_WATCHING_MODE_TRANSACTION = IBinder::FIRST_CALL_TRANSACTION+5, 56 GET_TOKEN_TRANSACTION = IBinder::FIRST_CALL_TRANSACTION+6, 57 PERMISSION_TO_OP_CODE_TRANSACTION = IBinder::FIRST_CALL_TRANSACTION+7, 58 CHECK_AUDIO_OPERATION_TRANSACTION = IBinder::FIRST_CALL_TRANSACTION+8, 59 }; 60 61 enum { 62 MODE_ALLOWED = 0, 63 MODE_IGNORED = 1, 64 MODE_ERRORED = 2 65 }; 66 }; 67 68 // ---------------------------------------------------------------------- 69 70 class BnAppOpsService : public BnInterface<IAppOpsService> 71 { 72 public: 73 // NOLINTNEXTLINE(google-default-arguments) 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 84 #else // __ANDROID_VNDK__ 85 #error "This header is not visible to vendors" 86 #endif // __ANDROID_VNDK__ 87 88 #endif // ANDROID_IAPP_OPS_SERVICE_H 89