Loading core/java/android/app/AppOpsManager.java +29 −0 Original line number Diff line number Diff line Loading @@ -182,6 +182,8 @@ public class AppOpsManager { @EnabledAfter(targetSdkVersion = Build.VERSION_CODES.Q) public static final long CALL_BACK_ON_CHANGED_LISTENER_WITH_SWITCHED_OP_CHANGE = 148180766L; private static final int MAX_UNFORWARDED_OPS = 10; final Context mContext; @UnsupportedAppUsage Loading Loading @@ -216,6 +218,17 @@ public class AppOpsManager { @GuardedBy("sLock") private static @Nullable OnOpNotedCallback sOnOpNotedCallback; /** * Sync note-ops collected from {@link #readAndLogNotedAppops(Parcel)} that have not been * delivered to a callback yet. * * Similar to {@link com.android.server.appop.AppOpsService#mUnforwardedAsyncNotedOps} for * {@link COLLECT_ASYNC}. Used in situation when AppOpsManager asks to collect stacktrace with * {@link #sMessageCollector}, which forces {@link COLLECT_SYNC} mode. */ @GuardedBy("sLock") private static ArrayList<SyncNotedAppOp> sUnforwardedOps = new ArrayList<>(); /** * Additional collector that collect accesses and forwards a few of them them via * {@link IAppOpsService#reportRuntimeAppOpAccessMessageAndGetConfig}. Loading Loading @@ -8163,6 +8176,11 @@ public class AppOpsManager { code = notedAppOps.nextSetBit(code + 1)) { if (sOnOpNotedCallback != null) { sOnOpNotedCallback.onNoted(new SyncNotedAppOp(code, attributionTag)); } else { sUnforwardedOps.add(new SyncNotedAppOp(code, attributionTag)); if (sUnforwardedOps.size() > MAX_UNFORWARDED_OPS) { sUnforwardedOps.remove(0); } } } } Loading Loading @@ -8229,6 +8247,17 @@ public class AppOpsManager { } } } synchronized (this) { int numMissedSyncOps = sUnforwardedOps.size(); for (int i = 0; i < numMissedSyncOps; i++) { final SyncNotedAppOp syncNotedAppOp = sUnforwardedOps.get(i); if (sOnOpNotedCallback != null) { sOnOpNotedCallback.getAsyncNotedExecutor().execute( () -> sOnOpNotedCallback.onNoted(syncNotedAppOp)); } } sUnforwardedOps.clear(); } } } } Loading services/core/java/com/android/server/appop/AppOpsService.java +2 −2 Original line number Diff line number Diff line Loading @@ -249,7 +249,7 @@ public class AppOpsService extends IAppOpsService.Stub { OP_CAMERA, }; private static final int MAX_UNFORWARED_OPS = 10; 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 @@ -3371,7 +3371,7 @@ public class AppOpsService extends IAppOpsService.Stub { } unforwardedOps.add(asyncNotedOp); if (unforwardedOps.size() > MAX_UNFORWARED_OPS) { if (unforwardedOps.size() > MAX_UNFORWARDED_OPS) { unforwardedOps.remove(0); } } Loading Loading
core/java/android/app/AppOpsManager.java +29 −0 Original line number Diff line number Diff line Loading @@ -182,6 +182,8 @@ public class AppOpsManager { @EnabledAfter(targetSdkVersion = Build.VERSION_CODES.Q) public static final long CALL_BACK_ON_CHANGED_LISTENER_WITH_SWITCHED_OP_CHANGE = 148180766L; private static final int MAX_UNFORWARDED_OPS = 10; final Context mContext; @UnsupportedAppUsage Loading Loading @@ -216,6 +218,17 @@ public class AppOpsManager { @GuardedBy("sLock") private static @Nullable OnOpNotedCallback sOnOpNotedCallback; /** * Sync note-ops collected from {@link #readAndLogNotedAppops(Parcel)} that have not been * delivered to a callback yet. * * Similar to {@link com.android.server.appop.AppOpsService#mUnforwardedAsyncNotedOps} for * {@link COLLECT_ASYNC}. Used in situation when AppOpsManager asks to collect stacktrace with * {@link #sMessageCollector}, which forces {@link COLLECT_SYNC} mode. */ @GuardedBy("sLock") private static ArrayList<SyncNotedAppOp> sUnforwardedOps = new ArrayList<>(); /** * Additional collector that collect accesses and forwards a few of them them via * {@link IAppOpsService#reportRuntimeAppOpAccessMessageAndGetConfig}. Loading Loading @@ -8163,6 +8176,11 @@ public class AppOpsManager { code = notedAppOps.nextSetBit(code + 1)) { if (sOnOpNotedCallback != null) { sOnOpNotedCallback.onNoted(new SyncNotedAppOp(code, attributionTag)); } else { sUnforwardedOps.add(new SyncNotedAppOp(code, attributionTag)); if (sUnforwardedOps.size() > MAX_UNFORWARDED_OPS) { sUnforwardedOps.remove(0); } } } } Loading Loading @@ -8229,6 +8247,17 @@ public class AppOpsManager { } } } synchronized (this) { int numMissedSyncOps = sUnforwardedOps.size(); for (int i = 0; i < numMissedSyncOps; i++) { final SyncNotedAppOp syncNotedAppOp = sUnforwardedOps.get(i); if (sOnOpNotedCallback != null) { sOnOpNotedCallback.getAsyncNotedExecutor().execute( () -> sOnOpNotedCallback.onNoted(syncNotedAppOp)); } } sUnforwardedOps.clear(); } } } } Loading
services/core/java/com/android/server/appop/AppOpsService.java +2 −2 Original line number Diff line number Diff line Loading @@ -249,7 +249,7 @@ public class AppOpsService extends IAppOpsService.Stub { OP_CAMERA, }; private static final int MAX_UNFORWARED_OPS = 10; 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 @@ -3371,7 +3371,7 @@ public class AppOpsService extends IAppOpsService.Stub { } unforwardedOps.add(asyncNotedOp); if (unforwardedOps.size() > MAX_UNFORWARED_OPS) { if (unforwardedOps.size() > MAX_UNFORWARDED_OPS) { unforwardedOps.remove(0); } } Loading