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 package com.android.internal.app; 18 19 import android.app.AppOpsManager; 20 import android.app.AsyncNotedAppOp; 21 import android.app.SyncNotedAppOp; 22 import android.app.RuntimeAppOpAccessMessage; 23 import android.content.AttributionSource; 24 import android.content.AttributionSourceState; 25 import android.content.pm.ParceledListSlice; 26 import android.os.Bundle; 27 import android.os.PackageTagsList; 28 import android.os.RemoteCallback; 29 import com.android.internal.app.IAppOpsCallback; 30 import com.android.internal.app.IAppOpsActiveCallback; 31 import com.android.internal.app.IAppOpsAsyncNotedCallback; 32 import com.android.internal.app.IAppOpsNotedCallback; 33 import com.android.internal.app.IAppOpsStartedCallback; 34 import com.android.internal.app.MessageSamplingConfig; 35 36 // AppOpsService AIDL interface. 37 // PLEASE READ BEFORE MODIFYING THIS FILE. 38 // Some methods in this interface or their transaction codes are mentioned in 39 // frameworks/base/boot/hiddenapi/hiddenapi-unsupported.txt, meaning that we cannot change their 40 // signature or ordering as they may be used by 3p apps. 41 // Also, some methods are mentioned in native code, meaning that the numbering in 42 // frameworks/native/libs/permission/include/binder/IAppOpsService.h must match the order here. 43 // Please be careful to respect both these issues when modifying this file. 44 interface IAppOpsService { 45 // These methods are also called by native code, so please be careful that the number in 46 // frameworks/native/libs/permission/include/binder/IAppOpsService.h matches the ordering here. checkOperation(int code, int uid, String packageName)47 int checkOperation(int code, int uid, String packageName); noteOperation(int code, int uid, String packageName, @nullable String attributionTag, boolean shouldCollectAsyncNotedOp, String message, boolean shouldCollectMessage)48 SyncNotedAppOp noteOperation(int code, int uid, String packageName, @nullable String attributionTag, 49 boolean shouldCollectAsyncNotedOp, String message, boolean shouldCollectMessage); startOperation(IBinder clientId, int code, int uid, String packageName, @nullable String attributionTag, boolean startIfModeDefault, boolean shouldCollectAsyncNotedOp, String message, boolean shouldCollectMessage, int attributionFlags, int attributionChainId)50 SyncNotedAppOp startOperation(IBinder clientId, int code, int uid, String packageName, 51 @nullable String attributionTag, boolean startIfModeDefault, 52 boolean shouldCollectAsyncNotedOp, String message, boolean shouldCollectMessage, 53 int attributionFlags, int attributionChainId); 54 @UnsupportedAppUsage finishOperation(IBinder clientId, int code, int uid, String packageName, @nullable String attributionTag)55 void finishOperation(IBinder clientId, int code, int uid, String packageName, 56 @nullable String attributionTag); startWatchingMode(int op, String packageName, IAppOpsCallback callback)57 void startWatchingMode(int op, String packageName, IAppOpsCallback callback); stopWatchingMode(IAppOpsCallback callback)58 void stopWatchingMode(IAppOpsCallback callback); permissionToOpCode(String permission)59 int permissionToOpCode(String permission); checkAudioOperation(int code, int usage, int uid, String packageName)60 int checkAudioOperation(int code, int usage, int uid, String packageName); shouldCollectNotes(int opCode)61 boolean shouldCollectNotes(int opCode); setCameraAudioRestriction(int mode)62 void setCameraAudioRestriction(int mode); startWatchingModeWithFlags(int op, String packageName, int flags, IAppOpsCallback callback)63 void startWatchingModeWithFlags(int op, String packageName, int flags, 64 IAppOpsCallback callback); 65 // End of methods also called by native code (there may be more blocks like this of native 66 // methods later in this file). 67 // Deprecated, use noteProxyOperationWithState instead. noteProxyOperation(int code, in AttributionSource attributionSource, boolean shouldCollectAsyncNotedOp, String message, boolean shouldCollectMessage, boolean skipProxyOperation)68 SyncNotedAppOp noteProxyOperation(int code, in AttributionSource attributionSource, 69 boolean shouldCollectAsyncNotedOp, String message, boolean shouldCollectMessage, 70 boolean skipProxyOperation); 71 // Deprecated, use startProxyOperationWithState instead. startProxyOperation(IBinder clientId, int code, in AttributionSource attributionSource, boolean startIfModeDefault, boolean shouldCollectAsyncNotedOp, String message, boolean shouldCollectMessage, boolean skipProxyOperation, int proxyAttributionFlags, int proxiedAttributionFlags, int attributionChainId)72 SyncNotedAppOp startProxyOperation(IBinder clientId, int code, 73 in AttributionSource attributionSource, boolean startIfModeDefault, 74 boolean shouldCollectAsyncNotedOp, String message, boolean shouldCollectMessage, 75 boolean skipProxyOperation, int proxyAttributionFlags, int proxiedAttributionFlags, 76 int attributionChainId); 77 // Deprecated, use finishProxyOperationWithState instead. finishProxyOperation(IBinder clientId, int code, in AttributionSource attributionSource, boolean skipProxyOperation)78 void finishProxyOperation(IBinder clientId, int code, in AttributionSource attributionSource, 79 boolean skipProxyOperation); checkPackage(int uid, String packageName)80 int checkPackage(int uid, String packageName); collectRuntimeAppOpAccessMessage()81 RuntimeAppOpAccessMessage collectRuntimeAppOpAccessMessage(); reportRuntimeAppOpAccessMessageAndGetConfig(String packageName, in SyncNotedAppOp appOp, String message)82 MessageSamplingConfig reportRuntimeAppOpAccessMessageAndGetConfig(String packageName, 83 in SyncNotedAppOp appOp, String message); 84 @UnsupportedAppUsage getPackagesForOps(in int[] ops)85 List<AppOpsManager.PackageOps> getPackagesForOps(in int[] ops); 86 @UnsupportedAppUsage getOpsForPackage(int uid, String packageName, in int[] ops)87 List<AppOpsManager.PackageOps> getOpsForPackage(int uid, String packageName, in int[] ops); getHistoricalOps(int uid, String packageName, String attributionTag, in List<String> ops, int historyFlags, int filter, long beginTimeMillis, long endTimeMillis, int flags, in RemoteCallback callback)88 void getHistoricalOps(int uid, String packageName, String attributionTag, in List<String> ops, 89 int historyFlags, int filter, long beginTimeMillis, long endTimeMillis, int flags, 90 in RemoteCallback callback); getHistoricalOpsFromDiskRaw(int uid, String packageName, String attributionTag, in List<String> ops, int historyFlags, int filter, long beginTimeMillis, long endTimeMillis, int flags, in RemoteCallback callback)91 void getHistoricalOpsFromDiskRaw(int uid, String packageName, String attributionTag, 92 in List<String> ops, int historyFlags, int filter, long beginTimeMillis, 93 long endTimeMillis, int flags, in RemoteCallback callback); 94 @EnforcePermission("MANAGE_APPOPS") offsetHistory(long duration)95 void offsetHistory(long duration); 96 @EnforcePermission("MANAGE_APPOPS") setHistoryParameters(int mode, long baseSnapshotInterval, int compressionStep)97 void setHistoryParameters(int mode, long baseSnapshotInterval, int compressionStep); 98 @EnforcePermission("MANAGE_APPOPS") addHistoricalOps(in AppOpsManager.HistoricalOps ops)99 void addHistoricalOps(in AppOpsManager.HistoricalOps ops); 100 @EnforcePermission("MANAGE_APPOPS") resetHistoryParameters()101 void resetHistoryParameters(); 102 @EnforcePermission("MANAGE_APPOPS") resetPackageOpsNoHistory(String packageName)103 void resetPackageOpsNoHistory(String packageName); 104 @EnforcePermission("MANAGE_APPOPS") clearHistory()105 void clearHistory(); 106 @EnforcePermission("MANAGE_APPOPS") rebootHistory(long offlineDurationMillis)107 void rebootHistory(long offlineDurationMillis); getUidOps(int uid, in int[] ops)108 List<AppOpsManager.PackageOps> getUidOps(int uid, in int[] ops); setUidMode(int code, int uid, int mode)109 void setUidMode(int code, int uid, int mode); 110 @UnsupportedAppUsage setMode(int code, int uid, String packageName, int mode)111 void setMode(int code, int uid, String packageName, int mode); 112 @UnsupportedAppUsage(maxTargetSdk = 30, trackingBug = 170729553) resetAllModes(int reqUserId, String reqPackageName)113 void resetAllModes(int reqUserId, String reqPackageName); setAudioRestriction(int code, int usage, int uid, int mode, in String[] exceptionPackages)114 void setAudioRestriction(int code, int usage, int uid, int mode, in String[] exceptionPackages); 115 setUserRestrictions(in Bundle restrictions, IBinder token, int userHandle)116 void setUserRestrictions(in Bundle restrictions, IBinder token, int userHandle); setUserRestriction(int code, boolean restricted, IBinder token, int userHandle, in PackageTagsList excludedPackageTags)117 void setUserRestriction(int code, boolean restricted, IBinder token, int userHandle, in PackageTagsList excludedPackageTags); 118 removeUser(int userHandle)119 void removeUser(int userHandle); 120 startWatchingActive(in int[] ops, IAppOpsActiveCallback callback)121 void startWatchingActive(in int[] ops, IAppOpsActiveCallback callback); stopWatchingActive(IAppOpsActiveCallback callback)122 void stopWatchingActive(IAppOpsActiveCallback callback); isOperationActive(int code, int uid, String packageName)123 boolean isOperationActive(int code, int uid, String packageName); isProxying(int op, String proxyPackageName, String proxyAttributionTag, int proxiedUid, String proxiedPackageName)124 boolean isProxying(int op, String proxyPackageName, String proxyAttributionTag, int proxiedUid, 125 String proxiedPackageName); 126 startWatchingStarted(in int[] ops, IAppOpsStartedCallback callback)127 void startWatchingStarted(in int[] ops, IAppOpsStartedCallback callback); stopWatchingStarted(IAppOpsStartedCallback callback)128 void stopWatchingStarted(IAppOpsStartedCallback callback); 129 startWatchingNoted(in int[] ops, IAppOpsNotedCallback callback)130 void startWatchingNoted(in int[] ops, IAppOpsNotedCallback callback); stopWatchingNoted(IAppOpsNotedCallback callback)131 void stopWatchingNoted(IAppOpsNotedCallback callback); 132 startWatchingAsyncNoted(String packageName, IAppOpsAsyncNotedCallback callback)133 void startWatchingAsyncNoted(String packageName, IAppOpsAsyncNotedCallback callback); stopWatchingAsyncNoted(String packageName, IAppOpsAsyncNotedCallback callback)134 void stopWatchingAsyncNoted(String packageName, IAppOpsAsyncNotedCallback callback); extractAsyncOps(String packageName)135 List<AsyncNotedAppOp> extractAsyncOps(String packageName); 136 checkOperationRaw(int code, int uid, String packageName, @nullable String attributionTag)137 int checkOperationRaw(int code, int uid, String packageName, @nullable String attributionTag); reloadNonHistoricalState()138 void reloadNonHistoricalState(); 139 collectNoteOpCallsForValidation(String stackTrace, int op, String packageName, long version)140 void collectNoteOpCallsForValidation(String stackTrace, int op, String packageName, long version); 141 noteProxyOperationWithState(int code, in AttributionSourceState attributionSourceStateState, boolean shouldCollectAsyncNotedOp, String message, boolean shouldCollectMessage, boolean skipProxyOperation)142 SyncNotedAppOp noteProxyOperationWithState(int code, 143 in AttributionSourceState attributionSourceStateState, 144 boolean shouldCollectAsyncNotedOp, String message, boolean shouldCollectMessage, 145 boolean skipProxyOperation); startProxyOperationWithState(IBinder clientId, int code, in AttributionSourceState attributionSourceStateState, boolean startIfModeDefault, boolean shouldCollectAsyncNotedOp, String message, boolean shouldCollectMessage, boolean skipProxyOperation, int proxyAttributionFlags, int proxiedAttributionFlags, int attributionChainId)146 SyncNotedAppOp startProxyOperationWithState(IBinder clientId, int code, 147 in AttributionSourceState attributionSourceStateState, boolean startIfModeDefault, 148 boolean shouldCollectAsyncNotedOp, String message, boolean shouldCollectMessage, 149 boolean skipProxyOperation, int proxyAttributionFlags, int proxiedAttributionFlags, 150 int attributionChainId); finishProxyOperationWithState(IBinder clientId, int code, in AttributionSourceState attributionSourceStateState, boolean skipProxyOperation)151 void finishProxyOperationWithState(IBinder clientId, int code, 152 in AttributionSourceState attributionSourceStateState, boolean skipProxyOperation); checkOperationRawForDevice(int code, int uid, String packageName, @nullable String attributionTag, int virtualDeviceId)153 int checkOperationRawForDevice(int code, int uid, String packageName, 154 @nullable String attributionTag, int virtualDeviceId); checkOperationForDevice(int code, int uid, String packageName, int virtualDeviceId)155 int checkOperationForDevice(int code, int uid, String packageName, int virtualDeviceId); noteOperationForDevice(int code, int uid, String packageName, @nullable String attributionTag, int virtualDeviceId, boolean shouldCollectAsyncNotedOp, String message, boolean shouldCollectMessage)156 SyncNotedAppOp noteOperationForDevice(int code, int uid, String packageName, 157 @nullable String attributionTag, int virtualDeviceId, 158 boolean shouldCollectAsyncNotedOp, String message, boolean shouldCollectMessage); startOperationForDevice(IBinder clientId, int code, int uid, String packageName, @nullable String attributionTag, int virtualDeviceId, boolean startIfModeDefault, boolean shouldCollectAsyncNotedOp, String message, boolean shouldCollectMessage, int attributionFlags, int attributionChainId)159 SyncNotedAppOp startOperationForDevice(IBinder clientId, int code, int uid, String packageName, 160 @nullable String attributionTag, int virtualDeviceId, boolean startIfModeDefault, 161 boolean shouldCollectAsyncNotedOp, String message, boolean shouldCollectMessage, 162 int attributionFlags, int attributionChainId); finishOperationForDevice(IBinder clientId, int code, int uid, String packageName, @nullable String attributionTag, int virtualDeviceId)163 void finishOperationForDevice(IBinder clientId, int code, int uid, String packageName, 164 @nullable String attributionTag, int virtualDeviceId); getPackagesForOpsForDevice(in int[] ops, String persistentDeviceId)165 List<AppOpsManager.PackageOps> getPackagesForOpsForDevice(in int[] ops, String persistentDeviceId); 166 } 167