Loading core/java/android/app/AppOpsManagerInternal.java +24 −0 Original line number Diff line number Diff line Loading @@ -26,6 +26,7 @@ import android.util.SparseIntArray; import com.android.internal.app.IAppOpsCallback; import com.android.internal.util.function.HeptFunction; import com.android.internal.util.function.HexFunction; import com.android.internal.util.function.NonaFunction; import com.android.internal.util.function.OctFunction; import com.android.internal.util.function.QuadFunction; import com.android.internal.util.function.TriFunction; Loading Loading @@ -100,9 +101,32 @@ public abstract class AppOpsManagerInternal { @NonNull HexFunction<Integer, AttributionSource, Boolean, String, Boolean, Boolean, SyncNotedAppOp> superImpl); /** * Allows overriding start operation behavior. * * @param token The client state. * @param code The op code to start. * @param uid The UID for which to note. * @param packageName The package for which to note. {@code null} for system package. * @param attributionTag the attribution tag. * @param startIfModeDefault Whether to start the op of the mode is default. * @param shouldCollectAsyncNotedOp If an {@link AsyncNotedAppOp} should be collected * @param message The message in the async noted op * @param shouldCollectMessage whether to collect messages * @param superImpl The super implementation. * @return The app op note result. */ SyncNotedAppOp startOperation(IBinder token, int code, int uid, @Nullable String packageName, @Nullable String attributionTag, boolean startIfModeDefault, boolean shouldCollectAsyncNotedOp, @Nullable String message, boolean shouldCollectMessage, @NonNull NonaFunction< IBinder, Integer, Integer, String, String, Boolean, Boolean, String, Boolean, SyncNotedAppOp> superImpl); /** * Allows overriding start proxy operation behavior. * * @param token The client state. * @param code The op code to start. * @param attributionSource The permission identity of the caller. * @param startIfModeDefault Whether to start the op of the mode is default. Loading data/etc/privapp-permissions-platform.xml +1 −0 Original line number Diff line number Diff line Loading @@ -344,6 +344,7 @@ applications that come with the platform <permission name="android.permission.ACTIVITY_EMBEDDING"/> <permission name="android.permission.FORCE_STOP_PACKAGES"/> <permission name="android.permission.GET_APP_OPS_STATS"/> <permission name="android.permission.WATCH_APPOPS"/> <permission name="android.permission.INSTALL_DYNAMIC_SYSTEM"/> <permission name="android.permission.INSTALL_LOCATION_PROVIDER"/> <permission name="android.permission.INSTALL_PACKAGES"/> Loading packages/Shell/AndroidManifest.xml +1 −0 Original line number Diff line number Diff line Loading @@ -300,6 +300,7 @@ <uses-permission android:name="android.permission.COMPANION_APPROVE_WIFI_CONNECTIONS" /> <uses-permission android:name="android.permission.MANAGE_APPOPS" /> <uses-permission android:name="android.permission.WATCH_APPOPS" /> <!-- Permission required for IncrementalLogCollectionTest --> <uses-permission android:name="android.permission.LOADER_USAGE_STATS" /> Loading services/core/java/com/android/server/am/ActivityManagerService.java +24 −0 Original line number Diff line number Diff line Loading @@ -346,6 +346,7 @@ import com.android.internal.util.MemInfoReader; import com.android.internal.util.Preconditions; import com.android.internal.util.function.HeptFunction; import com.android.internal.util.function.HexFunction; import com.android.internal.util.function.NonaFunction; import com.android.internal.util.function.OctFunction; import com.android.internal.util.function.QuadFunction; import com.android.internal.util.function.TriFunction; Loading Loading @@ -16730,6 +16731,29 @@ public class ActivityManagerService extends IActivityManager.Stub message, shouldCollectMessage, skiProxyOperation); } @Override public SyncNotedAppOp startOperation(IBinder token, int code, int uid, @Nullable String packageName, @Nullable String attributionTag, boolean startIfModeDefault, boolean shouldCollectAsyncNotedOp, @Nullable String message, boolean shouldCollectMessage, @NonNull NonaFunction<IBinder, Integer, Integer, String, String, Boolean, Boolean, String, Boolean, SyncNotedAppOp> superImpl) { if (uid == mTargetUid && isTargetOp(code)) { final int shellUid = UserHandle.getUid(UserHandle.getUserId(uid), Process.SHELL_UID); final long identity = Binder.clearCallingIdentity(); try { return superImpl.apply(token, code, shellUid, "com.android.shell", attributionTag, startIfModeDefault, shouldCollectAsyncNotedOp, message, shouldCollectMessage); } finally { Binder.restoreCallingIdentity(identity); } } return superImpl.apply(token, code, uid, packageName, attributionTag, startIfModeDefault, shouldCollectAsyncNotedOp, message, shouldCollectMessage); } @Override public SyncNotedAppOp startProxyOperation(IBinder token, int code, @NonNull AttributionSource attributionSource, boolean startIfModeDefault, services/core/java/com/android/server/appop/AppOpsService.java +46 −5 Original line number Diff line number Diff line Loading @@ -3509,9 +3509,19 @@ public class AppOpsService extends IAppOpsService.Stub { } @Override public SyncNotedAppOp startOperation(IBinder clientId, int code, int uid, String packageName, String attributionTag, boolean startIfModeDefault, boolean shouldCollectAsyncNotedOp, public SyncNotedAppOp startOperation(IBinder token, int code, int uid, @Nullable String packageName, @Nullable String attributionTag, boolean startIfModeDefault, boolean shouldCollectAsyncNotedOp, String message, boolean shouldCollectMessage) { return mCheckOpsDelegateDispatcher.startOperation(token, code, uid, packageName, attributionTag, startIfModeDefault, shouldCollectAsyncNotedOp, message, shouldCollectMessage); } private SyncNotedAppOp startOperationImpl(@NonNull IBinder clientId, int code, int uid, @Nullable String packageName, @Nullable String attributionTag, boolean startIfModeDefault, boolean shouldCollectAsyncNotedOp, @NonNull String message, boolean shouldCollectMessage) { verifyIncomingUid(uid); verifyIncomingOp(code); verifyIncomingPackage(packageName, UserHandle.getUserId(uid)); Loading @@ -3535,7 +3545,6 @@ public class AppOpsService extends IAppOpsService.Stub { return startOperationUnchecked(clientId, code, uid, packageName, attributionTag, Process.INVALID_UID, null, null, OP_FLAG_SELF, startIfModeDefault, shouldCollectAsyncNotedOp, message, shouldCollectMessage, false); } @Override Loading Loading @@ -6973,8 +6982,8 @@ public class AppOpsService extends IAppOpsService.Stub { } public SyncNotedAppOp noteProxyOperation(int code, AttributionSource attributionSource, boolean shouldCollectAsyncNotedOp, String message, boolean shouldCollectMessage, boolean skipProxyOperation) { boolean shouldCollectAsyncNotedOp, @Nullable String message, boolean shouldCollectMessage, boolean skipProxyOperation) { if (mPolicy != null) { if (mCheckOpsDelegate != null) { return mPolicy.noteProxyOperation(code, attributionSource, Loading Loading @@ -7003,6 +7012,38 @@ public class AppOpsService extends IAppOpsService.Stub { AppOpsService.this::noteProxyOperationImpl); } public SyncNotedAppOp startOperation(IBinder token, int code, int uid, @Nullable String packageName, @NonNull String attributionTag, boolean startIfModeDefault, boolean shouldCollectAsyncNotedOp, @Nullable String message, boolean shouldCollectMessage) { if (mPolicy != null) { if (mCheckOpsDelegate != null) { return mPolicy.startOperation(token, code, uid, packageName, attributionTag, startIfModeDefault, shouldCollectAsyncNotedOp, message, shouldCollectMessage, this::startDelegateOperationImpl); } else { return mPolicy.startOperation(token, code, uid, packageName, attributionTag, startIfModeDefault, shouldCollectAsyncNotedOp, message, shouldCollectMessage, AppOpsService.this::startOperationImpl); } } else if (mCheckOpsDelegate != null) { return startDelegateOperationImpl(token, code, uid, packageName, attributionTag, startIfModeDefault, shouldCollectAsyncNotedOp, message, shouldCollectMessage); } return startOperationImpl(token, code, uid, packageName, attributionTag, startIfModeDefault, shouldCollectAsyncNotedOp, message, shouldCollectMessage); } private SyncNotedAppOp startDelegateOperationImpl(IBinder token, int code, int uid, @Nullable String packageName, @Nullable String attributionTag, boolean startIfModeDefault, boolean shouldCollectAsyncNotedOp, String message, boolean shouldCollectMessage) { return mCheckOpsDelegate.startOperation(token, code, uid, packageName, attributionTag, startIfModeDefault, shouldCollectAsyncNotedOp, message, shouldCollectMessage, AppOpsService.this::startOperationImpl); } public SyncNotedAppOp startProxyOperation(IBinder clientId, int code, @NonNull AttributionSource attributionSource, boolean startIfModeDefault, boolean shouldCollectAsyncNotedOp, String message, boolean shouldCollectMessage, Loading Loading
core/java/android/app/AppOpsManagerInternal.java +24 −0 Original line number Diff line number Diff line Loading @@ -26,6 +26,7 @@ import android.util.SparseIntArray; import com.android.internal.app.IAppOpsCallback; import com.android.internal.util.function.HeptFunction; import com.android.internal.util.function.HexFunction; import com.android.internal.util.function.NonaFunction; import com.android.internal.util.function.OctFunction; import com.android.internal.util.function.QuadFunction; import com.android.internal.util.function.TriFunction; Loading Loading @@ -100,9 +101,32 @@ public abstract class AppOpsManagerInternal { @NonNull HexFunction<Integer, AttributionSource, Boolean, String, Boolean, Boolean, SyncNotedAppOp> superImpl); /** * Allows overriding start operation behavior. * * @param token The client state. * @param code The op code to start. * @param uid The UID for which to note. * @param packageName The package for which to note. {@code null} for system package. * @param attributionTag the attribution tag. * @param startIfModeDefault Whether to start the op of the mode is default. * @param shouldCollectAsyncNotedOp If an {@link AsyncNotedAppOp} should be collected * @param message The message in the async noted op * @param shouldCollectMessage whether to collect messages * @param superImpl The super implementation. * @return The app op note result. */ SyncNotedAppOp startOperation(IBinder token, int code, int uid, @Nullable String packageName, @Nullable String attributionTag, boolean startIfModeDefault, boolean shouldCollectAsyncNotedOp, @Nullable String message, boolean shouldCollectMessage, @NonNull NonaFunction< IBinder, Integer, Integer, String, String, Boolean, Boolean, String, Boolean, SyncNotedAppOp> superImpl); /** * Allows overriding start proxy operation behavior. * * @param token The client state. * @param code The op code to start. * @param attributionSource The permission identity of the caller. * @param startIfModeDefault Whether to start the op of the mode is default. Loading
data/etc/privapp-permissions-platform.xml +1 −0 Original line number Diff line number Diff line Loading @@ -344,6 +344,7 @@ applications that come with the platform <permission name="android.permission.ACTIVITY_EMBEDDING"/> <permission name="android.permission.FORCE_STOP_PACKAGES"/> <permission name="android.permission.GET_APP_OPS_STATS"/> <permission name="android.permission.WATCH_APPOPS"/> <permission name="android.permission.INSTALL_DYNAMIC_SYSTEM"/> <permission name="android.permission.INSTALL_LOCATION_PROVIDER"/> <permission name="android.permission.INSTALL_PACKAGES"/> Loading
packages/Shell/AndroidManifest.xml +1 −0 Original line number Diff line number Diff line Loading @@ -300,6 +300,7 @@ <uses-permission android:name="android.permission.COMPANION_APPROVE_WIFI_CONNECTIONS" /> <uses-permission android:name="android.permission.MANAGE_APPOPS" /> <uses-permission android:name="android.permission.WATCH_APPOPS" /> <!-- Permission required for IncrementalLogCollectionTest --> <uses-permission android:name="android.permission.LOADER_USAGE_STATS" /> Loading
services/core/java/com/android/server/am/ActivityManagerService.java +24 −0 Original line number Diff line number Diff line Loading @@ -346,6 +346,7 @@ import com.android.internal.util.MemInfoReader; import com.android.internal.util.Preconditions; import com.android.internal.util.function.HeptFunction; import com.android.internal.util.function.HexFunction; import com.android.internal.util.function.NonaFunction; import com.android.internal.util.function.OctFunction; import com.android.internal.util.function.QuadFunction; import com.android.internal.util.function.TriFunction; Loading Loading @@ -16730,6 +16731,29 @@ public class ActivityManagerService extends IActivityManager.Stub message, shouldCollectMessage, skiProxyOperation); } @Override public SyncNotedAppOp startOperation(IBinder token, int code, int uid, @Nullable String packageName, @Nullable String attributionTag, boolean startIfModeDefault, boolean shouldCollectAsyncNotedOp, @Nullable String message, boolean shouldCollectMessage, @NonNull NonaFunction<IBinder, Integer, Integer, String, String, Boolean, Boolean, String, Boolean, SyncNotedAppOp> superImpl) { if (uid == mTargetUid && isTargetOp(code)) { final int shellUid = UserHandle.getUid(UserHandle.getUserId(uid), Process.SHELL_UID); final long identity = Binder.clearCallingIdentity(); try { return superImpl.apply(token, code, shellUid, "com.android.shell", attributionTag, startIfModeDefault, shouldCollectAsyncNotedOp, message, shouldCollectMessage); } finally { Binder.restoreCallingIdentity(identity); } } return superImpl.apply(token, code, uid, packageName, attributionTag, startIfModeDefault, shouldCollectAsyncNotedOp, message, shouldCollectMessage); } @Override public SyncNotedAppOp startProxyOperation(IBinder token, int code, @NonNull AttributionSource attributionSource, boolean startIfModeDefault,
services/core/java/com/android/server/appop/AppOpsService.java +46 −5 Original line number Diff line number Diff line Loading @@ -3509,9 +3509,19 @@ public class AppOpsService extends IAppOpsService.Stub { } @Override public SyncNotedAppOp startOperation(IBinder clientId, int code, int uid, String packageName, String attributionTag, boolean startIfModeDefault, boolean shouldCollectAsyncNotedOp, public SyncNotedAppOp startOperation(IBinder token, int code, int uid, @Nullable String packageName, @Nullable String attributionTag, boolean startIfModeDefault, boolean shouldCollectAsyncNotedOp, String message, boolean shouldCollectMessage) { return mCheckOpsDelegateDispatcher.startOperation(token, code, uid, packageName, attributionTag, startIfModeDefault, shouldCollectAsyncNotedOp, message, shouldCollectMessage); } private SyncNotedAppOp startOperationImpl(@NonNull IBinder clientId, int code, int uid, @Nullable String packageName, @Nullable String attributionTag, boolean startIfModeDefault, boolean shouldCollectAsyncNotedOp, @NonNull String message, boolean shouldCollectMessage) { verifyIncomingUid(uid); verifyIncomingOp(code); verifyIncomingPackage(packageName, UserHandle.getUserId(uid)); Loading @@ -3535,7 +3545,6 @@ public class AppOpsService extends IAppOpsService.Stub { return startOperationUnchecked(clientId, code, uid, packageName, attributionTag, Process.INVALID_UID, null, null, OP_FLAG_SELF, startIfModeDefault, shouldCollectAsyncNotedOp, message, shouldCollectMessage, false); } @Override Loading Loading @@ -6973,8 +6982,8 @@ public class AppOpsService extends IAppOpsService.Stub { } public SyncNotedAppOp noteProxyOperation(int code, AttributionSource attributionSource, boolean shouldCollectAsyncNotedOp, String message, boolean shouldCollectMessage, boolean skipProxyOperation) { boolean shouldCollectAsyncNotedOp, @Nullable String message, boolean shouldCollectMessage, boolean skipProxyOperation) { if (mPolicy != null) { if (mCheckOpsDelegate != null) { return mPolicy.noteProxyOperation(code, attributionSource, Loading Loading @@ -7003,6 +7012,38 @@ public class AppOpsService extends IAppOpsService.Stub { AppOpsService.this::noteProxyOperationImpl); } public SyncNotedAppOp startOperation(IBinder token, int code, int uid, @Nullable String packageName, @NonNull String attributionTag, boolean startIfModeDefault, boolean shouldCollectAsyncNotedOp, @Nullable String message, boolean shouldCollectMessage) { if (mPolicy != null) { if (mCheckOpsDelegate != null) { return mPolicy.startOperation(token, code, uid, packageName, attributionTag, startIfModeDefault, shouldCollectAsyncNotedOp, message, shouldCollectMessage, this::startDelegateOperationImpl); } else { return mPolicy.startOperation(token, code, uid, packageName, attributionTag, startIfModeDefault, shouldCollectAsyncNotedOp, message, shouldCollectMessage, AppOpsService.this::startOperationImpl); } } else if (mCheckOpsDelegate != null) { return startDelegateOperationImpl(token, code, uid, packageName, attributionTag, startIfModeDefault, shouldCollectAsyncNotedOp, message, shouldCollectMessage); } return startOperationImpl(token, code, uid, packageName, attributionTag, startIfModeDefault, shouldCollectAsyncNotedOp, message, shouldCollectMessage); } private SyncNotedAppOp startDelegateOperationImpl(IBinder token, int code, int uid, @Nullable String packageName, @Nullable String attributionTag, boolean startIfModeDefault, boolean shouldCollectAsyncNotedOp, String message, boolean shouldCollectMessage) { return mCheckOpsDelegate.startOperation(token, code, uid, packageName, attributionTag, startIfModeDefault, shouldCollectAsyncNotedOp, message, shouldCollectMessage, AppOpsService.this::startOperationImpl); } public SyncNotedAppOp startProxyOperation(IBinder clientId, int code, @NonNull AttributionSource attributionSource, boolean startIfModeDefault, boolean shouldCollectAsyncNotedOp, String message, boolean shouldCollectMessage, Loading