diff options
8 files changed, 86 insertions, 68 deletions
diff --git a/core/java/android/app/AppOpsManager.java b/core/java/android/app/AppOpsManager.java index 3347e045886a..0a6827cde3d3 100644 --- a/core/java/android/app/AppOpsManager.java +++ b/core/java/android/app/AppOpsManager.java @@ -7370,15 +7370,17 @@ public class AppOpsManager { try { collectNoteOpCallsForValidation(op); int collectionMode = getNotedOpCollectionMode(uid, packageName, op); + boolean shouldCollectMessage = Process.myUid() == Process.SYSTEM_UID ? true : false; if (collectionMode == COLLECT_ASYNC) { if (message == null) { // Set stack trace as default message message = getFormattedStackTrace(); + shouldCollectMessage = true; } } int mode = mService.noteOperation(op, uid, packageName, attributionTag, - collectionMode == COLLECT_ASYNC, message); + collectionMode == COLLECT_ASYNC, message, shouldCollectMessage); if (mode == MODE_ALLOWED) { if (collectionMode == COLLECT_SELF) { @@ -7531,16 +7533,19 @@ public class AppOpsManager { try { collectNoteOpCallsForValidation(op); int collectionMode = getNotedOpCollectionMode(proxiedUid, proxiedPackageName, op); + boolean shouldCollectMessage = myUid == Process.SYSTEM_UID ? true : false; if (collectionMode == COLLECT_ASYNC) { if (message == null) { // Set stack trace as default message message = getFormattedStackTrace(); + shouldCollectMessage = true; } } int mode = mService.noteProxyOperation(op, proxiedUid, proxiedPackageName, proxiedAttributionTag, myUid, mContext.getOpPackageName(), - mContext.getAttributionTag(), collectionMode == COLLECT_ASYNC, message); + mContext.getAttributionTag(), collectionMode == COLLECT_ASYNC, message, + shouldCollectMessage); if (mode == MODE_ALLOWED) { if (collectionMode == COLLECT_SELF) { @@ -7855,15 +7860,18 @@ public class AppOpsManager { try { collectNoteOpCallsForValidation(op); int collectionMode = getNotedOpCollectionMode(uid, packageName, op); + boolean shouldCollectMessage = Process.myUid() == Process.SYSTEM_UID ? true : false; if (collectionMode == COLLECT_ASYNC) { if (message == null) { // Set stack trace as default message message = getFormattedStackTrace(); + shouldCollectMessage = true; } } int mode = mService.startOperation(getClientId(), op, uid, packageName, - attributionTag, startIfModeDefault, collectionMode == COLLECT_ASYNC, message); + attributionTag, startIfModeDefault, collectionMode == COLLECT_ASYNC, message, + shouldCollectMessage); if (mode == MODE_ALLOWED) { if (collectionMode == COLLECT_SELF) { diff --git a/core/java/android/app/AppOpsManagerInternal.java b/core/java/android/app/AppOpsManagerInternal.java index 309e91f1e4ff..5e032f00a3a0 100644 --- a/core/java/android/app/AppOpsManagerInternal.java +++ b/core/java/android/app/AppOpsManagerInternal.java @@ -22,7 +22,7 @@ import android.util.SparseArray; import android.util.SparseIntArray; import com.android.internal.app.IAppOpsCallback; -import com.android.internal.util.function.HexFunction; +import com.android.internal.util.function.HeptFunction; import com.android.internal.util.function.QuadFunction; /** @@ -73,9 +73,9 @@ public abstract class AppOpsManagerInternal { */ int noteOperation(int code, int uid, @Nullable String packageName, @Nullable String featureId, boolean shouldCollectAsyncNotedOp, - @Nullable String message, - @NonNull HexFunction<Integer, Integer, String, String, Boolean, String, Integer> - superImpl); + @Nullable String message, boolean shouldCollectMessage, + @NonNull HeptFunction<Integer, Integer, String, String, Boolean, String, Boolean, + Integer> superImpl); } /** diff --git a/core/java/com/android/internal/app/IAppOpsService.aidl b/core/java/com/android/internal/app/IAppOpsService.aidl index e614a0eb996b..51e56b7fca43 100644 --- a/core/java/com/android/internal/app/IAppOpsService.aidl +++ b/core/java/com/android/internal/app/IAppOpsService.aidl @@ -36,10 +36,10 @@ interface IAppOpsService { // and not be reordered int checkOperation(int code, int uid, String packageName); int noteOperation(int code, int uid, String packageName, @nullable String attributionTag, - boolean shouldCollectAsyncNotedOp, String message); + boolean shouldCollectAsyncNotedOp, String message, boolean shouldCollectMessage); int startOperation(IBinder clientId, int code, int uid, String packageName, @nullable String attributionTag, boolean startIfModeDefault, - boolean shouldCollectAsyncNotedOp, String message); + boolean shouldCollectAsyncNotedOp, String message, boolean shouldCollectMessage); @UnsupportedAppUsage void finishOperation(IBinder clientId, int code, int uid, String packageName, @nullable String attributionTag); @@ -54,7 +54,8 @@ interface IAppOpsService { int noteProxyOperation(int code, int proxiedUid, String proxiedPackageName, String proxiedAttributionTag, int proxyUid, String proxyPackageName, - String proxyAttributionTag, boolean shouldCollectAsyncNotedOp, String message); + String proxyAttributionTag, boolean shouldCollectAsyncNotedOp, String message, + boolean shouldCollectMessage); // Remaining methods are only used in Java. int checkPackage(int uid, String packageName); diff --git a/services/core/java/com/android/server/am/ActiveServices.java b/services/core/java/com/android/server/am/ActiveServices.java index a7bf98280af8..56953708e383 100644 --- a/services/core/java/com/android/server/am/ActiveServices.java +++ b/services/core/java/com/android/server/am/ActiveServices.java @@ -622,7 +622,7 @@ public final class ActiveServices { } mAm.mAppOpsService.startOperation(AppOpsManager.getToken(mAm.mAppOpsService), AppOpsManager.OP_START_FOREGROUND, r.appInfo.uid, r.packageName, null, - true, false, null); + true, false, null, false); } final ServiceMap smap = getServiceMapLocked(r.userId); @@ -1464,7 +1464,7 @@ public final class ActiveServices { mAm.mAppOpsService.startOperation( AppOpsManager.getToken(mAm.mAppOpsService), AppOpsManager.OP_START_FOREGROUND, r.appInfo.uid, r.packageName, - null, true, false, ""); + null, true, false, "", false); FrameworkStatsLog.write(FrameworkStatsLog.FOREGROUND_SERVICE_STATE_CHANGED, r.appInfo.uid, r.shortInstanceName, FrameworkStatsLog.FOREGROUND_SERVICE_STATE_CHANGED__STATE__ENTER, diff --git a/services/core/java/com/android/server/am/ActivityManagerService.java b/services/core/java/com/android/server/am/ActivityManagerService.java index 3e6a17325f5c..157feb30c24d 100644 --- a/services/core/java/com/android/server/am/ActivityManagerService.java +++ b/services/core/java/com/android/server/am/ActivityManagerService.java @@ -335,7 +335,7 @@ import com.android.internal.util.FastPrintWriter; import com.android.internal.util.FrameworkStatsLog; import com.android.internal.util.MemInfoReader; import com.android.internal.util.Preconditions; -import com.android.internal.util.function.HexFunction; +import com.android.internal.util.function.HeptFunction; import com.android.internal.util.function.QuadFunction; import com.android.internal.util.function.TriFunction; import com.android.server.AlarmManagerInternal; @@ -405,9 +405,7 @@ import java.util.Locale; import java.util.Map; import java.util.Objects; import java.util.Set; -import java.util.concurrent.CompletableFuture; import java.util.concurrent.CountDownLatch; -import java.util.concurrent.ExecutionException; import java.util.concurrent.Executor; import java.util.concurrent.atomic.AtomicBoolean; import java.util.concurrent.atomic.AtomicInteger; @@ -3272,7 +3270,7 @@ public class ActivityManagerService extends IActivityManager.Stub private boolean hasUsageStatsPermission(String callingPackage) { final int mode = mAppOpsService.noteOperation(AppOpsManager.OP_GET_USAGE_STATS, - Binder.getCallingUid(), callingPackage, null, false, ""); + Binder.getCallingUid(), callingPackage, null, false, "", false); if (mode == AppOpsManager.MODE_DEFAULT) { return checkCallingPermission(Manifest.permission.PACKAGE_USAGE_STATS) == PackageManager.PERMISSION_GRANTED; @@ -6100,7 +6098,7 @@ public class ActivityManagerService extends IActivityManager.Stub // TODO moltmann: Allow to specify featureId return mActivityManagerService.mAppOpsService .noteOperation(AppOpsManager.strOpToOp(op), uid, packageName, null, - false, ""); + false, "", false); } @Override @@ -20143,8 +20141,8 @@ public class ActivityManagerService extends IActivityManager.Stub private final int mTargetUid; private @Nullable String[] mPermissions; - ShellDelegate(String targetPacakgeName, int targetUid, @Nullable String[] permissions) { - mTargetPackageName = targetPacakgeName; + ShellDelegate(String targetPackageName, int targetUid, @Nullable String[] permissions) { + mTargetPackageName = targetPackageName; mTargetUid = targetUid; mPermissions = permissions; } @@ -20191,20 +20189,20 @@ public class ActivityManagerService extends IActivityManager.Stub @Override public int noteOperation(int code, int uid, @Nullable String packageName, @Nullable String featureId, boolean shouldCollectAsyncNotedOp, - @Nullable String message, - @NonNull HexFunction<Integer, Integer, String, String, Boolean, String, Integer> - superImpl) { + @Nullable String message, boolean shouldCollectMessage, + @NonNull HeptFunction<Integer, Integer, String, String, Boolean, String, Boolean, + Integer> superImpl) { if (uid == mTargetUid && isTargetOp(code)) { final long identity = Binder.clearCallingIdentity(); try { return superImpl.apply(code, Process.SHELL_UID, "com.android.shell", featureId, - shouldCollectAsyncNotedOp, message); + shouldCollectAsyncNotedOp, message, shouldCollectMessage); } finally { Binder.restoreCallingIdentity(identity); } } return superImpl.apply(code, uid, packageName, featureId, shouldCollectAsyncNotedOp, - message); + message, shouldCollectMessage); } @Override diff --git a/services/core/java/com/android/server/appop/AppOpsService.java b/services/core/java/com/android/server/appop/AppOpsService.java index 73c98da6aa56..7e172a21de43 100644 --- a/services/core/java/com/android/server/appop/AppOpsService.java +++ b/services/core/java/com/android/server/appop/AppOpsService.java @@ -1724,12 +1724,12 @@ public class AppOpsService extends IAppOpsService.Stub { return Zygote.MOUNT_EXTERNAL_NONE; } if (noteOperation(AppOpsManager.OP_READ_EXTERNAL_STORAGE, uid, - packageName, null, true, "External storage policy") + packageName, null, true, "External storage policy", true) != AppOpsManager.MODE_ALLOWED) { return Zygote.MOUNT_EXTERNAL_NONE; } if (noteOperation(AppOpsManager.OP_WRITE_EXTERNAL_STORAGE, uid, - packageName, null, true, "External storage policy") + packageName, null, true, "External storage policy", true) != AppOpsManager.MODE_ALLOWED) { return Zygote.MOUNT_EXTERNAL_READ; } @@ -2955,7 +2955,8 @@ public class AppOpsService extends IAppOpsService.Stub { @Override public int noteProxyOperation(int code, int proxiedUid, String proxiedPackageName, String proxiedAttributionTag, int proxyUid, String proxyPackageName, - String proxyAttributionTag, boolean shouldCollectAsyncNotedOp, String message) { + String proxyAttributionTag, boolean shouldCollectAsyncNotedOp, String message, + boolean shouldCollectMessage) { verifyIncomingUid(proxyUid); verifyIncomingOp(code); @@ -2972,7 +2973,7 @@ public class AppOpsService extends IAppOpsService.Stub { : AppOpsManager.OP_FLAG_UNTRUSTED_PROXY; final int proxyMode = noteOperationUnchecked(code, proxyUid, resolveProxyPackageName, proxyAttributionTag, Process.INVALID_UID, null, null, proxyFlags, - !isProxyTrusted, "proxy " + message); + !isProxyTrusted, "proxy " + message, shouldCollectMessage); if (proxyMode != AppOpsManager.MODE_ALLOWED || Binder.getCallingUid() == proxiedUid) { return proxyMode; } @@ -2985,27 +2986,28 @@ public class AppOpsService extends IAppOpsService.Stub { : AppOpsManager.OP_FLAG_UNTRUSTED_PROXIED; return noteOperationUnchecked(code, proxiedUid, resolveProxiedPackageName, proxiedAttributionTag, proxyUid, resolveProxyPackageName, proxyAttributionTag, - proxiedFlags, shouldCollectAsyncNotedOp, message); + proxiedFlags, shouldCollectAsyncNotedOp, message, shouldCollectMessage); } @Override public int noteOperation(int code, int uid, String packageName, String attributionTag, - boolean shouldCollectAsyncNotedOp, String message) { + boolean shouldCollectAsyncNotedOp, String message, boolean shouldCollectMessage) { final CheckOpsDelegate delegate; synchronized (this) { delegate = mCheckOpsDelegate; } if (delegate == null) { return noteOperationImpl(code, uid, packageName, attributionTag, - shouldCollectAsyncNotedOp, message); + shouldCollectAsyncNotedOp, message, shouldCollectMessage); } return delegate.noteOperation(code, uid, packageName, attributionTag, - shouldCollectAsyncNotedOp, message, AppOpsService.this::noteOperationImpl); + shouldCollectAsyncNotedOp, message, shouldCollectMessage, + AppOpsService.this::noteOperationImpl); } private int noteOperationImpl(int code, int uid, @Nullable String packageName, @Nullable String attributionTag, boolean shouldCollectAsyncNotedOp, - @Nullable String message) { + @Nullable String message, boolean shouldCollectMessage) { verifyIncomingUid(uid); verifyIncomingOp(code); String resolvedPackageName = resolvePackageName(uid, packageName); @@ -3014,13 +3016,14 @@ public class AppOpsService extends IAppOpsService.Stub { } return noteOperationUnchecked(code, uid, resolvedPackageName, attributionTag, Process.INVALID_UID, null, null, AppOpsManager.OP_FLAG_SELF, - shouldCollectAsyncNotedOp, message); + shouldCollectAsyncNotedOp, message, shouldCollectMessage); } private int noteOperationUnchecked(int code, int uid, @NonNull String packageName, @Nullable String attributionTag, int proxyUid, String proxyPackageName, @Nullable String proxyAttributionTag, @OpFlags int flags, - boolean shouldCollectAsyncNotedOp, @Nullable String message) { + boolean shouldCollectAsyncNotedOp, @Nullable String message, + boolean shouldCollectMessage) { RestrictionBypass bypass; try { bypass = verifyAndGetBypass(uid, packageName, attributionTag); @@ -3090,7 +3093,8 @@ public class AppOpsService extends IAppOpsService.Stub { flags); if (shouldCollectAsyncNotedOp) { - collectAsyncNotedOp(uid, packageName, code, attributionTag, message); + collectAsyncNotedOp(uid, packageName, code, attributionTag, flags, message, + shouldCollectMessage); } return AppOpsManager.MODE_ALLOWED; @@ -3247,7 +3251,8 @@ public class AppOpsService extends IAppOpsService.Stub { * @param message The message for the op noting */ private void collectAsyncNotedOp(int uid, @NonNull String packageName, int opCode, - @Nullable String attributionTag, @NonNull String message) { + @Nullable String attributionTag, @OpFlags int flags, @NonNull String message, + boolean shouldCollectMessage) { Objects.requireNonNull(message); int callingUid = Binder.getCallingUid(); @@ -3262,8 +3267,11 @@ public class AppOpsService extends IAppOpsService.Stub { attributionTag, message, System.currentTimeMillis()); final boolean[] wasNoteForwarded = {false}; - reportRuntimeAppOpAccessMessageAsyncLocked(uid, packageName, opCode, attributionTag, - message); + if ((flags & (OP_FLAG_SELF | OP_FLAG_TRUSTED_PROXIED)) != 0 + && shouldCollectMessage) { + reportRuntimeAppOpAccessMessageAsyncLocked(uid, packageName, opCode, + attributionTag, message); + } if (callbacks != null) { callbacks.broadcast((cb) -> { @@ -3376,7 +3384,7 @@ public class AppOpsService extends IAppOpsService.Stub { @Override public int startOperation(IBinder clientId, int code, int uid, String packageName, String attributionTag, boolean startIfModeDefault, boolean shouldCollectAsyncNotedOp, - String message) { + String message, boolean shouldCollectMessage) { verifyIncomingUid(uid); verifyIncomingOp(code); String resolvedPackageName = resolvePackageName(uid, packageName); @@ -3447,7 +3455,8 @@ public class AppOpsService extends IAppOpsService.Stub { } if (shouldCollectAsyncNotedOp) { - collectAsyncNotedOp(uid, packageName, code, attributionTag, message); + collectAsyncNotedOp(uid, packageName, code, attributionTag, AppOpsManager.OP_FLAG_SELF, + message, shouldCollectMessage); } return AppOpsManager.MODE_ALLOWED; @@ -4910,7 +4919,7 @@ public class AppOpsService extends IAppOpsService.Stub { if (shell.packageName != null) { shell.mInterface.startOperation(shell.mToken, shell.op, shell.packageUid, shell.packageName, shell.attributionTag, true, true, - "appops start shell command"); + "appops start shell command", true); } else { return -1; } diff --git a/services/tests/mockingservicestests/src/com/android/server/appop/AppOpsServiceTest.java b/services/tests/mockingservicestests/src/com/android/server/appop/AppOpsServiceTest.java index de6f55ba1053..0a61c443e0bd 100644 --- a/services/tests/mockingservicestests/src/com/android/server/appop/AppOpsServiceTest.java +++ b/services/tests/mockingservicestests/src/com/android/server/appop/AppOpsServiceTest.java @@ -169,12 +169,13 @@ public class AppOpsServiceTest { mAppOpsService.setMode(OP_WRITE_SMS, mMyUid, sMyPackageName, MODE_ERRORED); // Note an op that's allowed. - mAppOpsService.noteOperation(OP_READ_SMS, mMyUid, sMyPackageName, null, false, null); + mAppOpsService.noteOperation(OP_READ_SMS, mMyUid, sMyPackageName, null, false, null, false); List<PackageOps> loggedOps = getLoggedOps(); assertContainsOp(loggedOps, OP_READ_SMS, mTestStartMillis, -1, MODE_ALLOWED); // Note another op that's not allowed. - mAppOpsService.noteOperation(OP_WRITE_SMS, mMyUid, sMyPackageName, null, false, null); + mAppOpsService.noteOperation(OP_WRITE_SMS, mMyUid, sMyPackageName, null, false, null, + false); loggedOps = getLoggedOps(); assertContainsOp(loggedOps, OP_READ_SMS, mTestStartMillis, -1, MODE_ALLOWED); assertContainsOp(loggedOps, OP_WRITE_SMS, -1, mTestStartMillis, MODE_ERRORED); @@ -191,7 +192,7 @@ public class AppOpsServiceTest { mAppOpsService.setMode(OP_COARSE_LOCATION, mMyUid, sMyPackageName, MODE_ALLOWED); assertThat(mAppOpsService.noteOperation(OP_WIFI_SCAN, mMyUid, sMyPackageName, null, false, - null)).isEqualTo(MODE_ALLOWED); + null, false)).isEqualTo(MODE_ALLOWED); assertContainsOp(getLoggedOps(), OP_WIFI_SCAN, mTestStartMillis, -1, MODE_ALLOWED /* default for WIFI_SCAN; this is not changed or used in this test */); @@ -199,7 +200,7 @@ public class AppOpsServiceTest { // Now set COARSE_LOCATION to ERRORED -> this will make WIFI_SCAN disabled as well. mAppOpsService.setMode(OP_COARSE_LOCATION, mMyUid, sMyPackageName, MODE_ERRORED); assertThat(mAppOpsService.noteOperation(OP_WIFI_SCAN, mMyUid, sMyPackageName, null, false, - null)).isEqualTo(MODE_ERRORED); + null, false)).isEqualTo(MODE_ERRORED); assertContainsOp(getLoggedOps(), OP_WIFI_SCAN, mTestStartMillis, mTestStartMillis, MODE_ALLOWED /* default for WIFI_SCAN; this is not changed or used in this test */); @@ -210,8 +211,9 @@ public class AppOpsServiceTest { public void testStatePersistence() { mAppOpsService.setMode(OP_READ_SMS, mMyUid, sMyPackageName, MODE_ALLOWED); mAppOpsService.setMode(OP_WRITE_SMS, mMyUid, sMyPackageName, MODE_ERRORED); - mAppOpsService.noteOperation(OP_READ_SMS, mMyUid, sMyPackageName, null, false, null); - mAppOpsService.noteOperation(OP_WRITE_SMS, mMyUid, sMyPackageName, null, false, null); + mAppOpsService.noteOperation(OP_READ_SMS, mMyUid, sMyPackageName, null, false, null, false); + mAppOpsService.noteOperation(OP_WRITE_SMS, mMyUid, sMyPackageName, null, false, null, + false); mAppOpsService.writeState(); // Create a new app ops service, and initialize its state from XML. @@ -228,7 +230,7 @@ public class AppOpsServiceTest { @Test public void testShutdown() { mAppOpsService.setMode(OP_READ_SMS, mMyUid, sMyPackageName, MODE_ALLOWED); - mAppOpsService.noteOperation(OP_READ_SMS, mMyUid, sMyPackageName, null, false, null); + mAppOpsService.noteOperation(OP_READ_SMS, mMyUid, sMyPackageName, null, false, null, false); mAppOpsService.shutdown(); // Create a new app ops service, and initialize its state from XML. @@ -243,7 +245,7 @@ public class AppOpsServiceTest { @Test public void testGetOpsForPackage() { mAppOpsService.setMode(OP_READ_SMS, mMyUid, sMyPackageName, MODE_ALLOWED); - mAppOpsService.noteOperation(OP_READ_SMS, mMyUid, sMyPackageName, null, false, null); + mAppOpsService.noteOperation(OP_READ_SMS, mMyUid, sMyPackageName, null, false, null, false); // Query all ops List<PackageOps> loggedOps = mAppOpsService.getOpsForPackage( @@ -272,7 +274,7 @@ public class AppOpsServiceTest { @Test public void testPackageRemoved() { mAppOpsService.setMode(OP_READ_SMS, mMyUid, sMyPackageName, MODE_ALLOWED); - mAppOpsService.noteOperation(OP_READ_SMS, mMyUid, sMyPackageName, null, false, null); + mAppOpsService.noteOperation(OP_READ_SMS, mMyUid, sMyPackageName, null, false, null, false); List<PackageOps> loggedOps = getLoggedOps(); assertContainsOp(loggedOps, OP_READ_SMS, mTestStartMillis, -1, MODE_ALLOWED); @@ -287,7 +289,7 @@ public class AppOpsServiceTest { @Test public void testPackageRemovedHistoricalOps() throws InterruptedException { mAppOpsService.setMode(OP_READ_SMS, mMyUid, sMyPackageName, MODE_ALLOWED); - mAppOpsService.noteOperation(OP_READ_SMS, mMyUid, sMyPackageName, null, false, null); + mAppOpsService.noteOperation(OP_READ_SMS, mMyUid, sMyPackageName, null, false, null, false); AppOpsManager.HistoricalOps historicalOps = new AppOpsManager.HistoricalOps(0, 15000); historicalOps.increaseAccessCount(OP_READ_SMS, mMyUid, sMyPackageName, null, @@ -327,7 +329,7 @@ public class AppOpsServiceTest { @Test public void testUidRemoved() { mAppOpsService.setMode(OP_READ_SMS, mMyUid, sMyPackageName, MODE_ALLOWED); - mAppOpsService.noteOperation(OP_READ_SMS, mMyUid, sMyPackageName, null, false, null); + mAppOpsService.noteOperation(OP_READ_SMS, mMyUid, sMyPackageName, null, false, null, false); List<PackageOps> loggedOps = getLoggedOps(); assertContainsOp(loggedOps, OP_READ_SMS, mTestStartMillis, -1, MODE_ALLOWED); @@ -351,12 +353,12 @@ public class AppOpsServiceTest { mAppOpsService.updateUidProcState(mMyUid, ActivityManager.PROCESS_STATE_CACHED_EMPTY, ActivityManager.PROCESS_CAPABILITY_NONE); assertThat(mAppOpsService.noteOperation(OP_COARSE_LOCATION, mMyUid, sMyPackageName, null, - false, null)).isNotEqualTo(MODE_ALLOWED); + false, null, false)).isNotEqualTo(MODE_ALLOWED); mAppOpsService.updateUidProcState(mMyUid, ActivityManager.PROCESS_STATE_TOP, ActivityManager.PROCESS_CAPABILITY_FOREGROUND_LOCATION); assertThat(mAppOpsService.noteOperation(OP_COARSE_LOCATION, mMyUid, sMyPackageName, null, - false, null)).isEqualTo(MODE_ALLOWED); + false, null, false)).isEqualTo(MODE_ALLOWED); mAppOpsService.updateUidProcState(mMyUid, ActivityManager.PROCESS_STATE_CACHED_EMPTY, ActivityManager.PROCESS_CAPABILITY_NONE); @@ -365,7 +367,7 @@ public class AppOpsServiceTest { mAppOpsService.updateUidProcState(mMyUid, ActivityManager.PROCESS_STATE_CACHED_EMPTY, ActivityManager.PROCESS_CAPABILITY_NONE); assertThat(mAppOpsService.noteOperation(OP_COARSE_LOCATION, mMyUid, sMyPackageName, null, - false, null)).isNotEqualTo(MODE_ALLOWED); + false, null, false)).isNotEqualTo(MODE_ALLOWED); } @Test @@ -374,12 +376,12 @@ public class AppOpsServiceTest { mAppOpsService.updateUidProcState(mMyUid, ActivityManager.PROCESS_STATE_CACHED_EMPTY, ActivityManager.PROCESS_CAPABILITY_NONE); assertThat(mAppOpsService.noteOperation(OP_COARSE_LOCATION, mMyUid, sMyPackageName, null, - false, null)).isNotEqualTo(MODE_ALLOWED); + false, null, false)).isNotEqualTo(MODE_ALLOWED); mAppOpsService.updateUidProcState(mMyUid, PROCESS_STATE_FOREGROUND_SERVICE, ActivityManager.PROCESS_CAPABILITY_NONE); assertThat(mAppOpsService.noteOperation(OP_COARSE_LOCATION, mMyUid, sMyPackageName, null, - false, null)).isNotEqualTo(MODE_ALLOWED); + false, null, false)).isNotEqualTo(MODE_ALLOWED); } @Test @@ -389,12 +391,12 @@ public class AppOpsServiceTest { mAppOpsService.updateUidProcState(mMyUid, ActivityManager.PROCESS_STATE_CACHED_EMPTY, ActivityManager.PROCESS_CAPABILITY_NONE); assertThat(mAppOpsService.noteOperation(OP_COARSE_LOCATION, mMyUid, sMyPackageName, null, - false, null)).isNotEqualTo(MODE_ALLOWED); + false, null, false)).isNotEqualTo(MODE_ALLOWED); mAppOpsService.updateUidProcState(mMyUid, PROCESS_STATE_FOREGROUND_SERVICE, ActivityManager.PROCESS_CAPABILITY_FOREGROUND_LOCATION); assertThat(mAppOpsService.noteOperation(OP_COARSE_LOCATION, mMyUid, sMyPackageName, null, - false, null)).isEqualTo(MODE_ALLOWED); + false, null, false)).isEqualTo(MODE_ALLOWED); } @Test @@ -404,12 +406,12 @@ public class AppOpsServiceTest { mAppOpsService.updateUidProcState(mMyUid, ActivityManager.PROCESS_STATE_CACHED_EMPTY, ActivityManager.PROCESS_CAPABILITY_NONE); assertThat(mAppOpsService.noteOperation(OP_COARSE_LOCATION, mMyUid, sMyPackageName, null, - false, null)).isNotEqualTo(MODE_ALLOWED); + false, null, false)).isNotEqualTo(MODE_ALLOWED); mAppOpsService.updateUidProcState(mMyUid, ActivityManager.PROCESS_STATE_TOP, ActivityManager.PROCESS_CAPABILITY_FOREGROUND_LOCATION); assertThat(mAppOpsService.noteOperation(OP_COARSE_LOCATION, mMyUid, sMyPackageName, null, - false, null)).isEqualTo(MODE_ALLOWED); + false, null, false)).isEqualTo(MODE_ALLOWED); mAppOpsService.updateUidProcState(mMyUid, PROCESS_STATE_FOREGROUND_SERVICE, ActivityManager.PROCESS_CAPABILITY_NONE); @@ -418,7 +420,7 @@ public class AppOpsServiceTest { mAppOpsService.updateUidProcState(mMyUid, PROCESS_STATE_FOREGROUND_SERVICE, ActivityManager.PROCESS_CAPABILITY_NONE); assertThat(mAppOpsService.noteOperation(OP_COARSE_LOCATION, mMyUid, sMyPackageName, null, - false, null)).isNotEqualTo(MODE_ALLOWED); + false, null, false)).isNotEqualTo(MODE_ALLOWED); } @Test @@ -428,12 +430,12 @@ public class AppOpsServiceTest { mAppOpsService.updateUidProcState(mMyUid, ActivityManager.PROCESS_STATE_CACHED_EMPTY, ActivityManager.PROCESS_CAPABILITY_NONE); assertThat(mAppOpsService.noteOperation(OP_COARSE_LOCATION, mMyUid, sMyPackageName, null, - false, null)).isNotEqualTo(MODE_ALLOWED); + false, null, false)).isNotEqualTo(MODE_ALLOWED); mAppOpsService.updateUidProcState(mMyUid, ActivityManager.PROCESS_STATE_TOP, ActivityManager.PROCESS_CAPABILITY_FOREGROUND_LOCATION); assertThat(mAppOpsService.noteOperation(OP_COARSE_LOCATION, mMyUid, sMyPackageName, null, - false, null)).isEqualTo(MODE_ALLOWED); + false, null, false)).isEqualTo(MODE_ALLOWED); mAppOpsService.updateUidProcState(mMyUid, PROCESS_STATE_FOREGROUND_SERVICE, ActivityManager.PROCESS_CAPABILITY_FOREGROUND_LOCATION); @@ -442,7 +444,7 @@ public class AppOpsServiceTest { mAppOpsService.updateUidProcState(mMyUid, PROCESS_STATE_FOREGROUND_SERVICE, ActivityManager.PROCESS_CAPABILITY_FOREGROUND_LOCATION); assertThat(mAppOpsService.noteOperation(OP_COARSE_LOCATION, mMyUid, sMyPackageName, null, - false, null)).isEqualTo(MODE_ALLOWED); + false, null, false)).isEqualTo(MODE_ALLOWED); mAppOpsService.updateUidProcState(mMyUid, PROCESS_STATE_FOREGROUND_SERVICE, ActivityManager.PROCESS_CAPABILITY_NONE); @@ -451,7 +453,7 @@ public class AppOpsServiceTest { mAppOpsService.updateUidProcState(mMyUid, PROCESS_STATE_FOREGROUND_SERVICE, ActivityManager.PROCESS_CAPABILITY_NONE); assertThat(mAppOpsService.noteOperation(OP_COARSE_LOCATION, mMyUid, sMyPackageName, null, - false, null)).isNotEqualTo(MODE_ALLOWED); + false, null, false)).isNotEqualTo(MODE_ALLOWED); } private List<PackageOps> getLoggedOps() { diff --git a/services/tests/servicestests/src/com/android/server/am/ActivityManagerServiceTest.java b/services/tests/servicestests/src/com/android/server/am/ActivityManagerServiceTest.java index 6fe259e7fc85..6a797f31fa55 100644 --- a/services/tests/servicestests/src/com/android/server/am/ActivityManagerServiceTest.java +++ b/services/tests/servicestests/src/com/android/server/am/ActivityManagerServiceTest.java @@ -506,7 +506,7 @@ public class ActivityManagerServiceTest { @Test public void testDispatchUids_dispatchNeededChanges() throws RemoteException { when(mAppOpsService.noteOperation(AppOpsManager.OP_GET_USAGE_STATS, Process.myUid(), null, - null, false, null)).thenReturn(AppOpsManager.MODE_ALLOWED); + null, false, null, false)).thenReturn(AppOpsManager.MODE_ALLOWED); final int[] changesToObserve = { ActivityManager.UID_OBSERVER_PROCSTATE, |