Merge "Remove debug code before beta release." into rvc-dev
This commit is contained in:
committed by
Android (Google) Code Review
commit
c81dddfda6
@@ -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);
|
||||
|
||||
@@ -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);
|
||||
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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) {
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
|
||||
|
||||
@@ -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> {
|
||||
|
||||
Reference in New Issue
Block a user