summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author TreeHugger Robot <treehugger-gerrit@google.com> 2020-06-09 20:08:04 +0000
committer Android (Google) Code Review <android-gerrit@google.com> 2020-06-09 20:08:04 +0000
commitc81dddfda6dadce737fab6ad263c2f526b288af9 (patch)
treecda5da11fffdfa6acc50dd9f02d0bd52457b7800
parent692e990f0603120c4b0a028265a966f1780161c8 (diff)
parentcdfb1d6c3040fd5c32e281f3021e810e9b4a66c1 (diff)
Merge "Remove debug code before beta release." into rvc-dev
-rw-r--r--core/java/android/app/ActivityManager.java36
-rw-r--r--core/java/android/app/ActivityManagerInternal.java7
-rw-r--r--services/core/java/com/android/server/am/ActiveServices.java46
-rw-r--r--services/core/java/com/android/server/am/ActivityManagerService.java9
-rw-r--r--services/core/java/com/android/server/am/OomAdjuster.java29
-rw-r--r--services/core/java/com/android/server/am/PendingStartActivityUids.java4
-rw-r--r--services/core/java/com/android/server/am/ServiceRecord.java5
-rw-r--r--services/core/java/com/android/server/appop/AppOpsService.java70
8 files changed, 8 insertions, 198 deletions
diff --git a/core/java/android/app/ActivityManager.java b/core/java/android/app/ActivityManager.java
index 97b704ccc1c9..b608a343fc7d 100644
--- a/core/java/android/app/ActivityManager.java
+++ b/core/java/android/app/ActivityManager.java
@@ -601,20 +601,6 @@ public class ActivityManager {
@TestApi
public static final int PROCESS_CAPABILITY_FOREGROUND_MICROPHONE = 1 << 2;
- // TODO: remove this when development is done.
- // These are debug flags used between OomAdjuster and AppOpsService to detect and report absence
- // of the real flags.
- /** @hide */
- public static final int DEBUG_PROCESS_CAPABILITY_FOREGROUND_MICROPHONE_Q = 1 << 27;
- /** @hide */
- public static final int DEBUG_PROCESS_CAPABILITY_FOREGROUND_CAMERA_Q = 1 << 28;
- /** @hide */
- public static final int DEBUG_PROCESS_CAPABILITY_FOREGROUND_MICROPHONE = 1 << 29;
- /** @hide */
- public static final int DEBUG_PROCESS_CAPABILITY_FOREGROUND_CAMERA = 1 << 30;
- /** @hide */
- public static final int DEBUG_PROCESS_CAPABILITY_FOREGROUND_LOCATION = 1 << 31;
-
/** @hide all capabilities, the ORing of all flags in {@link ProcessCapability}*/
@TestApi
public static final int PROCESS_CAPABILITY_ALL = PROCESS_CAPABILITY_FOREGROUND_LOCATION
@@ -653,29 +639,9 @@ public class ActivityManager {
*/
public static void printCapabilitiesFull(PrintWriter pw, @ProcessCapability int caps) {
printCapabilitiesSummary(pw, caps);
- if ((caps & DEBUG_PROCESS_CAPABILITY_FOREGROUND_LOCATION) != 0) {
- pw.print(" !L");
- }
- if ((caps & DEBUG_PROCESS_CAPABILITY_FOREGROUND_CAMERA) != 0) {
- pw.print(" !C");
- }
- if ((caps & DEBUG_PROCESS_CAPABILITY_FOREGROUND_CAMERA_Q) != 0) {
- pw.print(" !Cq");
- }
- if ((caps & DEBUG_PROCESS_CAPABILITY_FOREGROUND_MICROPHONE) != 0) {
- pw.print(" !M");
- }
- if ((caps & DEBUG_PROCESS_CAPABILITY_FOREGROUND_MICROPHONE_Q) != 0) {
- pw.print(" !Mq");
- }
final int remain = caps & ~(PROCESS_CAPABILITY_FOREGROUND_LOCATION
| PROCESS_CAPABILITY_FOREGROUND_CAMERA
- | PROCESS_CAPABILITY_FOREGROUND_MICROPHONE
- | DEBUG_PROCESS_CAPABILITY_FOREGROUND_LOCATION
- | DEBUG_PROCESS_CAPABILITY_FOREGROUND_CAMERA
- | DEBUG_PROCESS_CAPABILITY_FOREGROUND_CAMERA_Q
- | DEBUG_PROCESS_CAPABILITY_FOREGROUND_MICROPHONE
- | DEBUG_PROCESS_CAPABILITY_FOREGROUND_MICROPHONE_Q);
+ | PROCESS_CAPABILITY_FOREGROUND_MICROPHONE);
if (remain != 0) {
pw.print('+');
pw.print(remain);
diff --git a/core/java/android/app/ActivityManagerInternal.java b/core/java/android/app/ActivityManagerInternal.java
index 2ce55219506f..a5965bc7f85f 100644
--- a/core/java/android/app/ActivityManagerInternal.java
+++ b/core/java/android/app/ActivityManagerInternal.java
@@ -398,13 +398,6 @@ public abstract class ActivityManagerInternal {
*/
public abstract boolean isUidCurrentlyInstrumented(int uid);
- /**
- * Show a debug toast, asking user to file a bugreport.
- */
- // TODO: remove this toast after feature development is done
- public abstract void showWhileInUseDebugToast(int uid, int op, int mode);
-
-
/** Is this a device owner app? */
public abstract boolean isDeviceOwner(int uid);
diff --git a/services/core/java/com/android/server/am/ActiveServices.java b/services/core/java/com/android/server/am/ActiveServices.java
index c5c3cafa8813..a7bf98280af8 100644
--- a/services/core/java/com/android/server/am/ActiveServices.java
+++ b/services/core/java/com/android/server/am/ActiveServices.java
@@ -4918,52 +4918,6 @@ public final class ActiveServices {
if (isDeviceOwner) {
return true;
}
-
- r.mInfoDenyWhileInUsePermissionInFgs =
- "Background FGS start while-in-use permission restriction [callingPackage: "
- + callingPackage
- + "; callingUid: " + callingUid
- + "; intent: " + intent
- + "]";
return false;
}
-
- // TODO: remove this toast after feature development is done
- void showWhileInUseDebugToastLocked(int uid, int op, int mode) {
- final UidRecord uidRec = mAm.mProcessList.getUidRecordLocked(uid);
- if (uidRec == null) {
- return;
- }
-
- for (int i = uidRec.procRecords.size() - 1; i >= 0; i--) {
- ProcessRecord pr = uidRec.procRecords.valueAt(i);
- if (pr.uid != uid) {
- continue;
- }
- for (int j = pr.numberOfRunningServices() - 1; j >= 0; j--) {
- ServiceRecord r = pr.getRunningServiceAt(j);
- if (!r.isForeground) {
- continue;
- }
- if (mode == DEBUG_FGS_ALLOW_WHILE_IN_USE) {
- if (!r.mAllowWhileInUsePermissionInFgs
- && r.mInfoDenyWhileInUsePermissionInFgs != null) {
- final String msg = r.mInfoDenyWhileInUsePermissionInFgs
- + " affected while-in-use permission:"
- + AppOpsManager.opToPublicName(op);
- Slog.wtf(TAG, msg);
- }
- } else if (mode == DEBUG_FGS_ENFORCE_TYPE) {
- final String msg =
- "FGS Missing foregroundServiceType in manifest file [callingPackage: "
- + r.mRecentCallingPackage
- + "; intent:" + r.intent.getIntent()
- + "] affected while-in-use permission:"
- + AppOpsManager.opToPublicName(op)
- + "; targetSdkVersion:" + r.appInfo.targetSdkVersion;
- Slog.wtf(TAG, msg);
- }
- }
- }
- }
}
diff --git a/services/core/java/com/android/server/am/ActivityManagerService.java b/services/core/java/com/android/server/am/ActivityManagerService.java
index 933dc99a43f0..026f147e955c 100644
--- a/services/core/java/com/android/server/am/ActivityManagerService.java
+++ b/services/core/java/com/android/server/am/ActivityManagerService.java
@@ -19671,15 +19671,6 @@ public class ActivityManagerService extends IActivityManager.Stub
return false;
}
- // TODO: remove this toast after feature development is done
- @Override
- public void showWhileInUseDebugToast(int uid, int op, int mode) {
- synchronized (ActivityManagerService.this) {
- ActivityManagerService.this.mServices.showWhileInUseDebugToastLocked(
- uid, op, mode);
- }
- }
-
@Override
public void setDeviceOwnerUid(int uid) {
synchronized (ActivityManagerService.this) {
diff --git a/services/core/java/com/android/server/am/OomAdjuster.java b/services/core/java/com/android/server/am/OomAdjuster.java
index 03ff3d0e0978..da5f48962130 100644
--- a/services/core/java/com/android/server/am/OomAdjuster.java
+++ b/services/core/java/com/android/server/am/OomAdjuster.java
@@ -1508,16 +1508,7 @@ public final class OomAdjuster {
capabilityFromFGS |=
(fgsType & FOREGROUND_SERVICE_TYPE_LOCATION)
!= 0 ? PROCESS_CAPABILITY_FOREGROUND_LOCATION : 0;
- } else {
- //The FGS has the location capability, but due to FGS BG start restriction it
- //lost the capability, use temp location capability to mark this case.
- //TODO: remove this block when development is done.
- capabilityFromFGS |=
- (fgsType & FOREGROUND_SERVICE_TYPE_LOCATION) != 0
- ? ActivityManager.DEBUG_PROCESS_CAPABILITY_FOREGROUND_LOCATION
- : 0;
- }
- if (s.mAllowWhileInUsePermissionInFgs) {
+
boolean enabled = false;
try {
enabled = mPlatformCompat.isChangeEnabled(
@@ -1527,23 +1518,13 @@ public final class OomAdjuster {
if (enabled) {
capabilityFromFGS |=
(fgsType & FOREGROUND_SERVICE_TYPE_CAMERA)
- != 0 ? PROCESS_CAPABILITY_FOREGROUND_CAMERA
- : ActivityManager.DEBUG_PROCESS_CAPABILITY_FOREGROUND_CAMERA;
+ != 0 ? PROCESS_CAPABILITY_FOREGROUND_CAMERA : 0;
capabilityFromFGS |=
(fgsType & FOREGROUND_SERVICE_TYPE_MICROPHONE)
- != 0 ? PROCESS_CAPABILITY_FOREGROUND_MICROPHONE
- : ActivityManager.DEBUG_PROCESS_CAPABILITY_FOREGROUND_MICROPHONE;
+ != 0 ? PROCESS_CAPABILITY_FOREGROUND_MICROPHONE : 0;
} else {
- // Remove fgsType check and assign PROCESS_CAPABILITY_FOREGROUND_CAMERA
- // and MICROPHONE when finish debugging.
- capabilityFromFGS |=
- (fgsType & FOREGROUND_SERVICE_TYPE_CAMERA)
- != 0 ? PROCESS_CAPABILITY_FOREGROUND_CAMERA
- : ActivityManager.DEBUG_PROCESS_CAPABILITY_FOREGROUND_CAMERA_Q;
- capabilityFromFGS |=
- (fgsType & FOREGROUND_SERVICE_TYPE_MICROPHONE)
- != 0 ? PROCESS_CAPABILITY_FOREGROUND_MICROPHONE
- : ActivityManager.DEBUG_PROCESS_CAPABILITY_FOREGROUND_MICROPHONE_Q;
+ capabilityFromFGS |= PROCESS_CAPABILITY_FOREGROUND_CAMERA
+ | PROCESS_CAPABILITY_FOREGROUND_MICROPHONE;
}
}
}
diff --git a/services/core/java/com/android/server/am/PendingStartActivityUids.java b/services/core/java/com/android/server/am/PendingStartActivityUids.java
index 0ed99fedf23d..6bf9d4e5c3f0 100644
--- a/services/core/java/com/android/server/am/PendingStartActivityUids.java
+++ b/services/core/java/com/android/server/am/PendingStartActivityUids.java
@@ -18,7 +18,6 @@ package com.android.server.am;
import android.content.Context;
import android.os.SystemClock;
-import android.provider.Settings;
import android.util.Pair;
import android.util.Slog;
import android.util.SparseArray;
@@ -58,8 +57,7 @@ final class PendingStartActivityUids {
if (delay >= 1000 /*ms*/) {
Slog.i(TAG,
"PendingStartActivityUids startActivity to updateOomAdj delay:"
- + delay + "ms," + " uid:" + uid + " packageName:"
- + Settings.getPackageNameForUid(mContext, uid));
+ + delay + "ms," + " uid:" + uid);
}
mPendingUids.delete(uid);
}
diff --git a/services/core/java/com/android/server/am/ServiceRecord.java b/services/core/java/com/android/server/am/ServiceRecord.java
index 4670d58ca63b..9c96e6e02566 100644
--- a/services/core/java/com/android/server/am/ServiceRecord.java
+++ b/services/core/java/com/android/server/am/ServiceRecord.java
@@ -138,10 +138,7 @@ final class ServiceRecord extends Binder implements ComponentName.WithComponentN
// allow while-in-use permissions in foreground service or not.
// while-in-use permissions in FGS started from background might be restricted.
boolean mAllowWhileInUsePermissionInFgs;
- // information string what/why service is denied while-in-use permissions when
- // foreground service is started from background.
- // TODO: remove this field after feature development is done
- String mInfoDenyWhileInUsePermissionInFgs;
+
// the most recent package that start/bind this service.
String mRecentCallingPackage;
diff --git a/services/core/java/com/android/server/appop/AppOpsService.java b/services/core/java/com/android/server/appop/AppOpsService.java
index 435e82535baf..73c98da6aa56 100644
--- a/services/core/java/com/android/server/appop/AppOpsService.java
+++ b/services/core/java/com/android/server/appop/AppOpsService.java
@@ -16,11 +16,6 @@
package com.android.server.appop;
-import static android.app.ActivityManager.DEBUG_PROCESS_CAPABILITY_FOREGROUND_CAMERA;
-import static android.app.ActivityManager.DEBUG_PROCESS_CAPABILITY_FOREGROUND_CAMERA_Q;
-import static android.app.ActivityManager.DEBUG_PROCESS_CAPABILITY_FOREGROUND_LOCATION;
-import static android.app.ActivityManager.DEBUG_PROCESS_CAPABILITY_FOREGROUND_MICROPHONE;
-import static android.app.ActivityManager.DEBUG_PROCESS_CAPABILITY_FOREGROUND_MICROPHONE_Q;
import static android.app.ActivityManager.PROCESS_CAPABILITY_FOREGROUND_CAMERA;
import static android.app.ActivityManager.PROCESS_CAPABILITY_FOREGROUND_LOCATION;
import static android.app.ActivityManager.PROCESS_CAPABILITY_FOREGROUND_MICROPHONE;
@@ -520,8 +515,6 @@ public class AppOpsService extends IAppOpsService.Stub {
public SparseBooleanArray foregroundOps;
public boolean hasForegroundWatchers;
- public long lastTimeShowDebugToast;
-
public UidState(int uid) {
this.uid = uid;
}
@@ -557,44 +550,19 @@ public class AppOpsService extends IAppOpsService.Stub {
case AppOpsManager.OP_MONITOR_HIGH_POWER_LOCATION:
if ((capability & PROCESS_CAPABILITY_FOREGROUND_LOCATION) != 0) {
return MODE_ALLOWED;
- } else if ((capability
- & DEBUG_PROCESS_CAPABILITY_FOREGROUND_LOCATION) != 0) {
- // The FGS has the location capability, but due to FGS BG start
- // restriction it lost the capability, use temp location capability
- // to mark this case.
- maybeShowWhileInUseDebugToast(op, DEBUG_FGS_ALLOW_WHILE_IN_USE);
- return MODE_IGNORED;
} else {
return MODE_IGNORED;
}
case OP_CAMERA:
if ((capability & PROCESS_CAPABILITY_FOREGROUND_CAMERA) != 0) {
return MODE_ALLOWED;
- } else if ((capability & DEBUG_PROCESS_CAPABILITY_FOREGROUND_CAMERA_Q)
- != 0) {
- maybeShowWhileInUseDebugToast(op, DEBUG_FGS_ENFORCE_TYPE);
- return MODE_ALLOWED;
- } else if ((capability & DEBUG_PROCESS_CAPABILITY_FOREGROUND_CAMERA)
- != 0) {
- maybeShowWhileInUseDebugToast(op, DEBUG_FGS_ENFORCE_TYPE);
- return MODE_IGNORED;
} else {
- maybeShowWhileInUseDebugToast(op, DEBUG_FGS_ALLOW_WHILE_IN_USE);
return MODE_IGNORED;
}
case OP_RECORD_AUDIO:
if ((capability & PROCESS_CAPABILITY_FOREGROUND_MICROPHONE) != 0) {
return MODE_ALLOWED;
- } else if ((capability
- & DEBUG_PROCESS_CAPABILITY_FOREGROUND_MICROPHONE_Q) != 0) {
- maybeShowWhileInUseDebugToast(op, DEBUG_FGS_ENFORCE_TYPE);
- return MODE_ALLOWED;
- } else if ((capability
- & DEBUG_PROCESS_CAPABILITY_FOREGROUND_MICROPHONE) != 0) {
- maybeShowWhileInUseDebugToast(op, DEBUG_FGS_ENFORCE_TYPE);
- return MODE_IGNORED;
} else {
- maybeShowWhileInUseDebugToast(op, DEBUG_FGS_ALLOW_WHILE_IN_USE);
return MODE_IGNORED;
}
default:
@@ -612,15 +580,7 @@ public class AppOpsService extends IAppOpsService.Stub {
return MODE_ALLOWED;
} else if ((capability & PROCESS_CAPABILITY_FOREGROUND_CAMERA) != 0) {
return MODE_ALLOWED;
- } else if ((capability
- & DEBUG_PROCESS_CAPABILITY_FOREGROUND_CAMERA_Q) != 0) {
- maybeShowWhileInUseDebugToast(op, DEBUG_FGS_ENFORCE_TYPE);
- return MODE_ALLOWED;
- } else if ((capability & DEBUG_PROCESS_CAPABILITY_FOREGROUND_CAMERA) != 0) {
- maybeShowWhileInUseDebugToast(op, DEBUG_FGS_ENFORCE_TYPE);
- return MODE_IGNORED;
} else {
- maybeShowWhileInUseDebugToast(op, DEBUG_FGS_ALLOW_WHILE_IN_USE);
return MODE_IGNORED;
}
case OP_RECORD_AUDIO:
@@ -629,16 +589,7 @@ public class AppOpsService extends IAppOpsService.Stub {
return MODE_ALLOWED;
} else if ((capability & PROCESS_CAPABILITY_FOREGROUND_MICROPHONE) != 0) {
return MODE_ALLOWED;
- } else if ((capability & DEBUG_PROCESS_CAPABILITY_FOREGROUND_MICROPHONE_Q)
- != 0) {
- maybeShowWhileInUseDebugToast(op, DEBUG_FGS_ENFORCE_TYPE);
- return MODE_ALLOWED;
- } else if ((capability & DEBUG_PROCESS_CAPABILITY_FOREGROUND_MICROPHONE)
- != 0) {
- maybeShowWhileInUseDebugToast(op, DEBUG_FGS_ENFORCE_TYPE);
- return MODE_IGNORED;
} else {
- maybeShowWhileInUseDebugToast(op, DEBUG_FGS_ALLOW_WHILE_IN_USE);
return MODE_IGNORED;
}
default:
@@ -692,27 +643,6 @@ public class AppOpsService extends IAppOpsService.Stub {
}
foregroundOps = which;
}
-
- // TODO: remove this toast after feature development is done
- // For DEBUG_FGS_ALLOW_WHILE_IN_USE, if the procstate is foreground service and while-in-use
- // permission is denied, show a toast message and generate a WTF log so we know
- // how many apps are impacted by the new background started foreground service while-in-use
- // permission restriction.
- // For DEBUG_FGS_ENFORCE_TYPE, The process has a foreground service that does not have
- // camera/microphone foregroundServiceType in manifest file, and the process is asking
- // AppOps for camera/microphone ops, show a toast message and generate a WTF log.
- void maybeShowWhileInUseDebugToast(int op, int mode) {
- if (mode == DEBUG_FGS_ALLOW_WHILE_IN_USE && state != UID_STATE_FOREGROUND_SERVICE) {
- return;
- }
- final long now = SystemClock.elapsedRealtime();
- if (lastTimeShowDebugToast == 0 || now - lastTimeShowDebugToast > 600000) {
- lastTimeShowDebugToast = now;
- mHandler.sendMessage(PooledLambda.obtainMessage(
- ActivityManagerInternal::showWhileInUseDebugToast,
- mActivityManagerInternal, uid, op, mode));
- }
- }
}
final static class Ops extends SparseArray<Op> {