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 #pragma once 18 19 #include <binder/IAppOpsCallback.h> 20 #include <binder/IInterface.h> 21 22 #include <optional> 23 24 #ifdef __ANDROID_VNDK__ 25 #error "This header is not visible to vendors" 26 #endif 27 28 namespace android { 29 30 // ---------------------------------------------------------------------- 31 32 class IAppOpsService : public IInterface 33 { 34 public: 35 DECLARE_META_INTERFACE(AppOpsService) 36 37 virtual int32_t checkOperation(int32_t code, int32_t uid, const String16& packageName) = 0; 38 virtual int32_t noteOperation(int32_t code, int32_t uid, const String16& packageName, 39 const std::optional<String16>& attributionTag, bool shouldCollectAsyncNotedOp, 40 const String16& message, bool shouldCollectMessage) = 0; 41 virtual int32_t startOperation(const sp<IBinder>& token, int32_t code, int32_t uid, 42 const String16& packageName, const std::optional<String16>& attributionTag, 43 bool startIfModeDefault, bool shouldCollectAsyncNotedOp, const String16& message, 44 bool shouldCollectMessage) = 0; 45 virtual void finishOperation(const sp<IBinder>& token, int32_t code, int32_t uid, 46 const String16& packageName, const std::optional<String16>& attributionTag) = 0; 47 virtual void startWatchingMode(int32_t op, const String16& packageName, 48 const sp<IAppOpsCallback>& callback) = 0; 49 virtual void stopWatchingMode(const sp<IAppOpsCallback>& callback) = 0; 50 virtual int32_t permissionToOpCode(const String16& permission) = 0; 51 virtual int32_t checkAudioOperation(int32_t code, int32_t usage,int32_t uid, 52 const String16& packageName) = 0; 53 virtual void setCameraAudioRestriction(int32_t mode) = 0; 54 virtual bool shouldCollectNotes(int32_t opCode) = 0; 55 56 enum { 57 CHECK_OPERATION_TRANSACTION = IBinder::FIRST_CALL_TRANSACTION, 58 NOTE_OPERATION_TRANSACTION = IBinder::FIRST_CALL_TRANSACTION+1, 59 START_OPERATION_TRANSACTION = IBinder::FIRST_CALL_TRANSACTION+2, 60 FINISH_OPERATION_TRANSACTION = IBinder::FIRST_CALL_TRANSACTION+3, 61 START_WATCHING_MODE_TRANSACTION = IBinder::FIRST_CALL_TRANSACTION+4, 62 STOP_WATCHING_MODE_TRANSACTION = IBinder::FIRST_CALL_TRANSACTION+5, 63 PERMISSION_TO_OP_CODE_TRANSACTION = IBinder::FIRST_CALL_TRANSACTION+6, 64 CHECK_AUDIO_OPERATION_TRANSACTION = IBinder::FIRST_CALL_TRANSACTION+7, 65 SHOULD_COLLECT_NOTES_TRANSACTION = IBinder::FIRST_CALL_TRANSACTION+8, 66 SET_CAMERA_AUDIO_RESTRICTION_TRANSACTION = IBinder::FIRST_CALL_TRANSACTION+9, 67 }; 68 69 enum { 70 MODE_ALLOWED = 0, 71 MODE_IGNORED = 1, 72 MODE_ERRORED = 2 73 }; 74 }; 75 76 // ---------------------------------------------------------------------- 77 78 class BnAppOpsService : public BnInterface<IAppOpsService> 79 { 80 public: 81 // NOLINTNEXTLINE(google-default-arguments) 82 virtual status_t onTransact( uint32_t code, 83 const Parcel& data, 84 Parcel* reply, 85 uint32_t flags = 0); 86 }; 87 88 // ---------------------------------------------------------------------- 89 90 } // namespace android 91