Loading core/java/android/app/AppOpInfo.java +17 −2 Original line number Diff line number Diff line Loading @@ -26,6 +26,7 @@ import java.util.Objects; * Information about a particular app op. */ class AppOpInfo { /** * A unique constant identifying this app op. */ Loading Loading @@ -91,6 +92,11 @@ class AppOpInfo { */ public final boolean restrictRead; /** * Whether to collect noteOp instances, and send them to callbacks. */ public final boolean forceCollectNotes; AppOpInfo(int code, int switchCode, @NonNull String name, Loading @@ -100,7 +106,8 @@ class AppOpInfo { AppOpsManager.RestrictionBypass allowSystemRestrictionBypass, int defaultMode, boolean disableReset, boolean restrictRead) { boolean restrictRead, boolean forceCollectNotes) { if (code < OP_NONE) throw new IllegalArgumentException(); if (switchCode < OP_NONE) throw new IllegalArgumentException(); Objects.requireNonNull(name); Loading @@ -115,6 +122,7 @@ class AppOpInfo { this.defaultMode = defaultMode; this.disableReset = disableReset; this.restrictRead = restrictRead; this.forceCollectNotes = forceCollectNotes; } static class Builder { Loading @@ -128,6 +136,7 @@ class AppOpInfo { private int mDefaultMode = AppOpsManager.MODE_DEFAULT; private boolean mDisableReset = false; private boolean mRestrictRead = false; private boolean mForceCollectNotes = false; Builder(int code, @NonNull String name, @NonNull String simpleName) { if (code < OP_NONE) throw new IllegalArgumentException(); Loading Loading @@ -190,9 +199,15 @@ class AppOpInfo { return this; } public Builder setForceCollectNotes(boolean value) { this.mForceCollectNotes = value; return this; } public AppOpInfo build() { return new AppOpInfo(mCode, mSwitchCode, mName, mSimpleName, mPermission, mRestriction, mAllowSystemRestrictionBypass, mDefaultMode, mDisableReset, mRestrictRead); mAllowSystemRestrictionBypass, mDefaultMode, mDisableReset, mRestrictRead, mForceCollectNotes); } } } core/java/android/app/AppOpsManager.java +13 −4 Original line number Diff line number Diff line Loading @@ -1831,6 +1831,9 @@ public class AppOpsManager { }) private @interface ShouldCollectNoteOp {} /** Whether noting for an appop should be collected */ private static final @ShouldCollectNoteOp byte[] sAppOpsToNote = new byte[_NUM_OP]; private static final int[] RUNTIME_AND_APPOP_PERMISSIONS_OPS = { // RUNTIME PERMISSIONS // Contacts Loading Loading @@ -2281,9 +2284,18 @@ public class AppOpsManager { "ACCESS_RESTRICTED_SETTINGS").setDefaultMode(AppOpsManager.MODE_ALLOWED) .setDisableReset(true).setRestrictRead(true).build(), new AppOpInfo.Builder(OP_RECEIVE_AMBIENT_TRIGGER_AUDIO, OPSTR_RECEIVE_AMBIENT_TRIGGER_AUDIO, "RECEIVE_SOUNDTRIGGER_AUDIO").setDefaultMode(AppOpsManager.MODE_ALLOWED).build() "RECEIVE_SOUNDTRIGGER_AUDIO").setDefaultMode(AppOpsManager.MODE_ALLOWED) .setForceCollectNotes(true).build() }; /** * @hide */ public static boolean shouldForceCollectNoteForOp(int op) { Preconditions.checkArgumentInRange(op, 0, _NUM_OP - 1, "opCode"); return sAppOpInfos[op].forceCollectNotes; } /** * Mapping from an app op name to the app op code. */ Loading Loading @@ -2313,9 +2325,6 @@ public class AppOpsManager { private static final ThreadLocal<ArrayMap<String, long[]>> sAppOpsNotedInThisBinderTransaction = new ThreadLocal<>(); /** Whether noting for an appop should be collected */ private static final @ShouldCollectNoteOp byte[] sAppOpsToNote = new byte[_NUM_OP]; static { if (sAppOpInfos.length != _NUM_OP) { throw new IllegalStateException("mAppOpInfos length " + sAppOpInfos.length Loading services/core/java/com/android/server/appop/AppOpsService.java +1 −5 Original line number Diff line number Diff line Loading @@ -267,10 +267,6 @@ public class AppOpsService extends IAppOpsService.Stub implements PersistenceSch OP_CAMERA, }; private static final int[] WATCHABLE_NON_PERMISSION_OPS = { OP_RECEIVE_AMBIENT_TRIGGER_AUDIO, }; private static final int MAX_UNFORWARDED_OPS = 10; private static final int MAX_UNUSED_POOLED_OBJECTS = 3; private static final int RARELY_USED_PACKAGES_INITIALIZATION_DELAY_MILLIS = 300000; Loading Loading @@ -4252,7 +4248,7 @@ public class AppOpsService extends IAppOpsService.Stub implements PersistenceSch public boolean shouldCollectNotes(int opCode) { Preconditions.checkArgumentInRange(opCode, 0, _NUM_OP - 1, "opCode"); if (ArrayUtils.contains(WATCHABLE_NON_PERMISSION_OPS, opCode)) { if (AppOpsManager.shouldForceCollectNoteForOp(opCode)) { return true; } Loading Loading
core/java/android/app/AppOpInfo.java +17 −2 Original line number Diff line number Diff line Loading @@ -26,6 +26,7 @@ import java.util.Objects; * Information about a particular app op. */ class AppOpInfo { /** * A unique constant identifying this app op. */ Loading Loading @@ -91,6 +92,11 @@ class AppOpInfo { */ public final boolean restrictRead; /** * Whether to collect noteOp instances, and send them to callbacks. */ public final boolean forceCollectNotes; AppOpInfo(int code, int switchCode, @NonNull String name, Loading @@ -100,7 +106,8 @@ class AppOpInfo { AppOpsManager.RestrictionBypass allowSystemRestrictionBypass, int defaultMode, boolean disableReset, boolean restrictRead) { boolean restrictRead, boolean forceCollectNotes) { if (code < OP_NONE) throw new IllegalArgumentException(); if (switchCode < OP_NONE) throw new IllegalArgumentException(); Objects.requireNonNull(name); Loading @@ -115,6 +122,7 @@ class AppOpInfo { this.defaultMode = defaultMode; this.disableReset = disableReset; this.restrictRead = restrictRead; this.forceCollectNotes = forceCollectNotes; } static class Builder { Loading @@ -128,6 +136,7 @@ class AppOpInfo { private int mDefaultMode = AppOpsManager.MODE_DEFAULT; private boolean mDisableReset = false; private boolean mRestrictRead = false; private boolean mForceCollectNotes = false; Builder(int code, @NonNull String name, @NonNull String simpleName) { if (code < OP_NONE) throw new IllegalArgumentException(); Loading Loading @@ -190,9 +199,15 @@ class AppOpInfo { return this; } public Builder setForceCollectNotes(boolean value) { this.mForceCollectNotes = value; return this; } public AppOpInfo build() { return new AppOpInfo(mCode, mSwitchCode, mName, mSimpleName, mPermission, mRestriction, mAllowSystemRestrictionBypass, mDefaultMode, mDisableReset, mRestrictRead); mAllowSystemRestrictionBypass, mDefaultMode, mDisableReset, mRestrictRead, mForceCollectNotes); } } }
core/java/android/app/AppOpsManager.java +13 −4 Original line number Diff line number Diff line Loading @@ -1831,6 +1831,9 @@ public class AppOpsManager { }) private @interface ShouldCollectNoteOp {} /** Whether noting for an appop should be collected */ private static final @ShouldCollectNoteOp byte[] sAppOpsToNote = new byte[_NUM_OP]; private static final int[] RUNTIME_AND_APPOP_PERMISSIONS_OPS = { // RUNTIME PERMISSIONS // Contacts Loading Loading @@ -2281,9 +2284,18 @@ public class AppOpsManager { "ACCESS_RESTRICTED_SETTINGS").setDefaultMode(AppOpsManager.MODE_ALLOWED) .setDisableReset(true).setRestrictRead(true).build(), new AppOpInfo.Builder(OP_RECEIVE_AMBIENT_TRIGGER_AUDIO, OPSTR_RECEIVE_AMBIENT_TRIGGER_AUDIO, "RECEIVE_SOUNDTRIGGER_AUDIO").setDefaultMode(AppOpsManager.MODE_ALLOWED).build() "RECEIVE_SOUNDTRIGGER_AUDIO").setDefaultMode(AppOpsManager.MODE_ALLOWED) .setForceCollectNotes(true).build() }; /** * @hide */ public static boolean shouldForceCollectNoteForOp(int op) { Preconditions.checkArgumentInRange(op, 0, _NUM_OP - 1, "opCode"); return sAppOpInfos[op].forceCollectNotes; } /** * Mapping from an app op name to the app op code. */ Loading Loading @@ -2313,9 +2325,6 @@ public class AppOpsManager { private static final ThreadLocal<ArrayMap<String, long[]>> sAppOpsNotedInThisBinderTransaction = new ThreadLocal<>(); /** Whether noting for an appop should be collected */ private static final @ShouldCollectNoteOp byte[] sAppOpsToNote = new byte[_NUM_OP]; static { if (sAppOpInfos.length != _NUM_OP) { throw new IllegalStateException("mAppOpInfos length " + sAppOpInfos.length Loading
services/core/java/com/android/server/appop/AppOpsService.java +1 −5 Original line number Diff line number Diff line Loading @@ -267,10 +267,6 @@ public class AppOpsService extends IAppOpsService.Stub implements PersistenceSch OP_CAMERA, }; private static final int[] WATCHABLE_NON_PERMISSION_OPS = { OP_RECEIVE_AMBIENT_TRIGGER_AUDIO, }; private static final int MAX_UNFORWARDED_OPS = 10; private static final int MAX_UNUSED_POOLED_OBJECTS = 3; private static final int RARELY_USED_PACKAGES_INITIALIZATION_DELAY_MILLIS = 300000; Loading Loading @@ -4252,7 +4248,7 @@ public class AppOpsService extends IAppOpsService.Stub implements PersistenceSch public boolean shouldCollectNotes(int opCode) { Preconditions.checkArgumentInRange(opCode, 0, _NUM_OP - 1, "opCode"); if (ArrayUtils.contains(WATCHABLE_NON_PERMISSION_OPS, opCode)) { if (AppOpsManager.shouldForceCollectNoteForOp(opCode)) { return true; } Loading