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 virtual void startWatchingModeWithFlags(int32_t op, const String16& packageName, 56 int32_t flags, const sp<IAppOpsCallback>& callback) = 0; 57 58 enum { 59 CHECK_OPERATION_TRANSACTION = IBinder::FIRST_CALL_TRANSACTION, 60 NOTE_OPERATION_TRANSACTION = IBinder::FIRST_CALL_TRANSACTION+1, 61 START_OPERATION_TRANSACTION = IBinder::FIRST_CALL_TRANSACTION+2, 62 FINISH_OPERATION_TRANSACTION = IBinder::FIRST_CALL_TRANSACTION+3, 63 START_WATCHING_MODE_TRANSACTION = IBinder::FIRST_CALL_TRANSACTION+4, 64 STOP_WATCHING_MODE_TRANSACTION = IBinder::FIRST_CALL_TRANSACTION+5, 65 PERMISSION_TO_OP_CODE_TRANSACTION = IBinder::FIRST_CALL_TRANSACTION+6, 66 CHECK_AUDIO_OPERATION_TRANSACTION = IBinder::FIRST_CALL_TRANSACTION+7, 67 SHOULD_COLLECT_NOTES_TRANSACTION = IBinder::FIRST_CALL_TRANSACTION+8, 68 SET_CAMERA_AUDIO_RESTRICTION_TRANSACTION = IBinder::FIRST_CALL_TRANSACTION+9, 69 START_WATCHING_MODE_WITH_FLAGS_TRANSACTION = IBinder::FIRST_CALL_TRANSACTION+10, 70 }; 71 72 enum { 73 MODE_ALLOWED = 0, 74 MODE_IGNORED = 1, 75 MODE_ERRORED = 2 76 }; 77 }; 78 79 // ---------------------------------------------------------------------- 80 81 class BnAppOpsService : public BnInterface<IAppOpsService> 82 { 83 public: 84 // NOLINTNEXTLINE(google-default-arguments) 85 virtual status_t onTransact( uint32_t code, 86 const Parcel& data, 87 Parcel* reply, 88 uint32_t flags = 0); 89 }; 90 91 // ---------------------------------------------------------------------- 92 93 } // namespace android 94