Merge "Add logging for BAL" into rvc-dev
This commit is contained in:
committed by
Android (Google) Code Review
commit
a1951e195b
@@ -61,6 +61,7 @@ import static com.android.server.wm.ActivityStackSupervisor.DEFER_RESUME;
|
|||||||
import static com.android.server.wm.ActivityStackSupervisor.ON_TOP;
|
import static com.android.server.wm.ActivityStackSupervisor.ON_TOP;
|
||||||
import static com.android.server.wm.ActivityStackSupervisor.PRESERVE_WINDOWS;
|
import static com.android.server.wm.ActivityStackSupervisor.PRESERVE_WINDOWS;
|
||||||
import static com.android.server.wm.ActivityStackSupervisor.TAG_TASKS;
|
import static com.android.server.wm.ActivityStackSupervisor.TAG_TASKS;
|
||||||
|
import static com.android.server.wm.ActivityTaskManagerDebugConfig.DEBUG_ACTIVITY_STARTS;
|
||||||
import static com.android.server.wm.ActivityTaskManagerDebugConfig.DEBUG_CONFIGURATION;
|
import static com.android.server.wm.ActivityTaskManagerDebugConfig.DEBUG_CONFIGURATION;
|
||||||
import static com.android.server.wm.ActivityTaskManagerDebugConfig.DEBUG_PERMISSIONS_REVIEW;
|
import static com.android.server.wm.ActivityTaskManagerDebugConfig.DEBUG_PERMISSIONS_REVIEW;
|
||||||
import static com.android.server.wm.ActivityTaskManagerDebugConfig.DEBUG_RESULTS;
|
import static com.android.server.wm.ActivityTaskManagerDebugConfig.DEBUG_RESULTS;
|
||||||
@@ -108,6 +109,7 @@ import android.os.UserManager;
|
|||||||
import android.service.voice.IVoiceInteractionSession;
|
import android.service.voice.IVoiceInteractionSession;
|
||||||
import android.text.TextUtils;
|
import android.text.TextUtils;
|
||||||
import android.util.ArraySet;
|
import android.util.ArraySet;
|
||||||
|
import android.util.DebugUtils;
|
||||||
import android.util.Pools.SynchronizedPool;
|
import android.util.Pools.SynchronizedPool;
|
||||||
import android.util.Slog;
|
import android.util.Slog;
|
||||||
|
|
||||||
@@ -1195,6 +1197,9 @@ class ActivityStarter {
|
|||||||
final int callingAppId = UserHandle.getAppId(callingUid);
|
final int callingAppId = UserHandle.getAppId(callingUid);
|
||||||
if (callingUid == Process.ROOT_UID || callingAppId == Process.SYSTEM_UID
|
if (callingUid == Process.ROOT_UID || callingAppId == Process.SYSTEM_UID
|
||||||
|| callingAppId == Process.NFC_UID) {
|
|| callingAppId == Process.NFC_UID) {
|
||||||
|
if (DEBUG_ACTIVITY_STARTS) {
|
||||||
|
Slog.d(TAG, "Activity start allowed for important callingUid (" + callingUid + ")");
|
||||||
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1208,6 +1213,11 @@ class ActivityStarter {
|
|||||||
final boolean isCallingUidPersistentSystemProcess =
|
final boolean isCallingUidPersistentSystemProcess =
|
||||||
callingUidProcState <= ActivityManager.PROCESS_STATE_PERSISTENT_UI;
|
callingUidProcState <= ActivityManager.PROCESS_STATE_PERSISTENT_UI;
|
||||||
if (callingUidHasAnyVisibleWindow || isCallingUidPersistentSystemProcess) {
|
if (callingUidHasAnyVisibleWindow || isCallingUidPersistentSystemProcess) {
|
||||||
|
if (DEBUG_ACTIVITY_STARTS) {
|
||||||
|
Slog.d(TAG, "Activity start allowed: callingUidHasAnyVisibleWindow = " + callingUid
|
||||||
|
+ ", isCallingUidPersistentSystemProcess = "
|
||||||
|
+ isCallingUidPersistentSystemProcess);
|
||||||
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
// take realCallingUid into consideration
|
// take realCallingUid into consideration
|
||||||
@@ -1229,35 +1239,66 @@ class ActivityStarter {
|
|||||||
if (realCallingUid != callingUid) {
|
if (realCallingUid != callingUid) {
|
||||||
// don't abort if the realCallingUid has a visible window
|
// don't abort if the realCallingUid has a visible window
|
||||||
if (realCallingUidHasAnyVisibleWindow) {
|
if (realCallingUidHasAnyVisibleWindow) {
|
||||||
|
if (DEBUG_ACTIVITY_STARTS) {
|
||||||
|
Slog.d(TAG, "Activity start allowed: realCallingUid (" + realCallingUid
|
||||||
|
+ ") has visible (non-toast) window");
|
||||||
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
// if the realCallingUid is a persistent system process, abort if the IntentSender
|
// if the realCallingUid is a persistent system process, abort if the IntentSender
|
||||||
// wasn't whitelisted to start an activity
|
// wasn't whitelisted to start an activity
|
||||||
if (isRealCallingUidPersistentSystemProcess && allowBackgroundActivityStart) {
|
if (isRealCallingUidPersistentSystemProcess && allowBackgroundActivityStart) {
|
||||||
|
if (DEBUG_ACTIVITY_STARTS) {
|
||||||
|
Slog.d(TAG, "Activity start allowed: realCallingUid (" + realCallingUid
|
||||||
|
+ ") is persistent system process AND intent sender whitelisted "
|
||||||
|
+ "(allowBackgroundActivityStart = true)");
|
||||||
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
// don't abort if the realCallingUid is an associated companion app
|
// don't abort if the realCallingUid is an associated companion app
|
||||||
if (mService.isAssociatedCompanionApp(UserHandle.getUserId(realCallingUid),
|
if (mService.isAssociatedCompanionApp(UserHandle.getUserId(realCallingUid),
|
||||||
realCallingUid)) {
|
realCallingUid)) {
|
||||||
|
if (DEBUG_ACTIVITY_STARTS) {
|
||||||
|
Slog.d(TAG, "Activity start allowed: realCallingUid (" + realCallingUid
|
||||||
|
+ ") is companion app");
|
||||||
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// don't abort if the callingUid has START_ACTIVITIES_FROM_BACKGROUND permission
|
// don't abort if the callingUid has START_ACTIVITIES_FROM_BACKGROUND permission
|
||||||
if (mService.checkPermission(START_ACTIVITIES_FROM_BACKGROUND, callingPid, callingUid)
|
if (mService.checkPermission(START_ACTIVITIES_FROM_BACKGROUND, callingPid, callingUid)
|
||||||
== PERMISSION_GRANTED) {
|
== PERMISSION_GRANTED) {
|
||||||
|
if (DEBUG_ACTIVITY_STARTS) {
|
||||||
|
Slog.d(TAG,
|
||||||
|
"Background activity start allowed: START_ACTIVITIES_FROM_BACKGROUND "
|
||||||
|
+ "permission granted for uid "
|
||||||
|
+ callingUid);
|
||||||
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
// don't abort if the caller has the same uid as the recents component
|
// don't abort if the caller has the same uid as the recents component
|
||||||
if (mSupervisor.mRecentTasks.isCallerRecents(callingUid)) {
|
if (mSupervisor.mRecentTasks.isCallerRecents(callingUid)) {
|
||||||
|
if (DEBUG_ACTIVITY_STARTS) {
|
||||||
|
Slog.d(TAG, "Background activity start allowed: callingUid (" + callingUid
|
||||||
|
+ ") is recents");
|
||||||
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
// don't abort if the callingUid is the device owner
|
// don't abort if the callingUid is the device owner
|
||||||
if (mService.isDeviceOwner(callingUid)) {
|
if (mService.isDeviceOwner(callingUid)) {
|
||||||
|
if (DEBUG_ACTIVITY_STARTS) {
|
||||||
|
Slog.d(TAG, "Background activity start allowed: callingUid (" + callingUid
|
||||||
|
+ ") is device owner");
|
||||||
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
// don't abort if the callingUid has companion device
|
// don't abort if the callingUid has companion device
|
||||||
final int callingUserId = UserHandle.getUserId(callingUid);
|
final int callingUserId = UserHandle.getUserId(callingUid);
|
||||||
if (mService.isAssociatedCompanionApp(callingUserId, callingUid)) {
|
if (mService.isAssociatedCompanionApp(callingUserId, callingUid)) {
|
||||||
|
if (DEBUG_ACTIVITY_STARTS) {
|
||||||
|
Slog.d(TAG, "Background activity start allowed: callingUid (" + callingUid
|
||||||
|
+ ") is companion app");
|
||||||
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
// If we don't have callerApp at this point, no caller was provided to startActivity().
|
// If we don't have callerApp at this point, no caller was provided to startActivity().
|
||||||
@@ -1273,6 +1314,10 @@ class ActivityStarter {
|
|||||||
if (callerApp != null) {
|
if (callerApp != null) {
|
||||||
// first check the original calling process
|
// first check the original calling process
|
||||||
if (callerApp.areBackgroundActivityStartsAllowed()) {
|
if (callerApp.areBackgroundActivityStartsAllowed()) {
|
||||||
|
if (DEBUG_ACTIVITY_STARTS) {
|
||||||
|
Slog.d(TAG, "Background activity start allowed: callerApp process (pid = "
|
||||||
|
+ callerApp.getPid() + ", uid = " + callerAppUid + ") is whitelisted");
|
||||||
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
// only if that one wasn't whitelisted, check the other ones
|
// only if that one wasn't whitelisted, check the other ones
|
||||||
@@ -1282,6 +1327,11 @@ class ActivityStarter {
|
|||||||
for (int i = uidProcesses.size() - 1; i >= 0; i--) {
|
for (int i = uidProcesses.size() - 1; i >= 0; i--) {
|
||||||
final WindowProcessController proc = uidProcesses.valueAt(i);
|
final WindowProcessController proc = uidProcesses.valueAt(i);
|
||||||
if (proc != callerApp && proc.areBackgroundActivityStartsAllowed()) {
|
if (proc != callerApp && proc.areBackgroundActivityStartsAllowed()) {
|
||||||
|
if (DEBUG_ACTIVITY_STARTS) {
|
||||||
|
Slog.d(TAG,
|
||||||
|
"Background activity start allowed: process " + proc.getPid()
|
||||||
|
+ " from uid " + callerAppUid + " is whitelisted");
|
||||||
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1297,9 +1347,15 @@ class ActivityStarter {
|
|||||||
Slog.w(TAG, "Background activity start [callingPackage: " + callingPackage
|
Slog.w(TAG, "Background activity start [callingPackage: " + callingPackage
|
||||||
+ "; callingUid: " + callingUid
|
+ "; callingUid: " + callingUid
|
||||||
+ "; isCallingUidForeground: " + isCallingUidForeground
|
+ "; isCallingUidForeground: " + isCallingUidForeground
|
||||||
|
+ "; callingUidHasAnyVisibleWindow: " + callingUidHasAnyVisibleWindow
|
||||||
|
+ "; callingUidProcState: " + DebugUtils.valueToString(ActivityManager.class,
|
||||||
|
"PROCESS_STATE_", callingUidProcState)
|
||||||
+ "; isCallingUidPersistentSystemProcess: " + isCallingUidPersistentSystemProcess
|
+ "; isCallingUidPersistentSystemProcess: " + isCallingUidPersistentSystemProcess
|
||||||
+ "; realCallingUid: " + realCallingUid
|
+ "; realCallingUid: " + realCallingUid
|
||||||
+ "; isRealCallingUidForeground: " + isRealCallingUidForeground
|
+ "; isRealCallingUidForeground: " + isRealCallingUidForeground
|
||||||
|
+ "; realCallingUidHasAnyVisibleWindow: " + realCallingUidHasAnyVisibleWindow
|
||||||
|
+ "; realCallingUidProcState: " + DebugUtils.valueToString(ActivityManager.class,
|
||||||
|
"PROCESS_STATE_", realCallingUidProcState)
|
||||||
+ "; isRealCallingUidPersistentSystemProcess: "
|
+ "; isRealCallingUidPersistentSystemProcess: "
|
||||||
+ isRealCallingUidPersistentSystemProcess
|
+ isRealCallingUidPersistentSystemProcess
|
||||||
+ "; originatingPendingIntent: " + originatingPendingIntent
|
+ "; originatingPendingIntent: " + originatingPendingIntent
|
||||||
|
|||||||
@@ -65,6 +65,7 @@ public class ActivityTaskManagerDebugConfig {
|
|||||||
static final boolean DEBUG_USER_LEAVING = DEBUG_ALL || false;
|
static final boolean DEBUG_USER_LEAVING = DEBUG_ALL || false;
|
||||||
static final boolean DEBUG_PERMISSIONS_REVIEW = DEBUG_ALL || false;
|
static final boolean DEBUG_PERMISSIONS_REVIEW = DEBUG_ALL || false;
|
||||||
static final boolean DEBUG_RESULTS = DEBUG_ALL || false;
|
static final boolean DEBUG_RESULTS = DEBUG_ALL || false;
|
||||||
|
static final boolean DEBUG_ACTIVITY_STARTS = DEBUG_ALL || false;
|
||||||
public static final boolean DEBUG_CLEANUP = DEBUG_ALL || false;
|
public static final boolean DEBUG_CLEANUP = DEBUG_ALL || false;
|
||||||
public static final boolean DEBUG_METRICS = DEBUG_ALL || false;
|
public static final boolean DEBUG_METRICS = DEBUG_ALL || false;
|
||||||
|
|
||||||
|
|||||||
@@ -29,6 +29,7 @@ import static com.android.server.wm.ActivityStack.ActivityState.PAUSING;
|
|||||||
import static com.android.server.wm.ActivityStack.ActivityState.RESUMED;
|
import static com.android.server.wm.ActivityStack.ActivityState.RESUMED;
|
||||||
import static com.android.server.wm.ActivityStack.ActivityState.STARTED;
|
import static com.android.server.wm.ActivityStack.ActivityState.STARTED;
|
||||||
import static com.android.server.wm.ActivityStack.ActivityState.STOPPING;
|
import static com.android.server.wm.ActivityStack.ActivityState.STOPPING;
|
||||||
|
import static com.android.server.wm.ActivityTaskManagerDebugConfig.DEBUG_ACTIVITY_STARTS;
|
||||||
import static com.android.server.wm.ActivityTaskManagerDebugConfig.DEBUG_CONFIGURATION;
|
import static com.android.server.wm.ActivityTaskManagerDebugConfig.DEBUG_CONFIGURATION;
|
||||||
import static com.android.server.wm.ActivityTaskManagerDebugConfig.DEBUG_RELEASE;
|
import static com.android.server.wm.ActivityTaskManagerDebugConfig.DEBUG_RELEASE;
|
||||||
import static com.android.server.wm.ActivityTaskManagerDebugConfig.POSTFIX_CONFIGURATION;
|
import static com.android.server.wm.ActivityTaskManagerDebugConfig.POSTFIX_CONFIGURATION;
|
||||||
@@ -430,6 +431,11 @@ public class WindowProcessController extends ConfigurationContainer<Configuratio
|
|||||||
|
|
||||||
void setLastActivityLaunchTime(long launchTime) {
|
void setLastActivityLaunchTime(long launchTime) {
|
||||||
if (launchTime <= mLastActivityLaunchTime) {
|
if (launchTime <= mLastActivityLaunchTime) {
|
||||||
|
if (launchTime < mLastActivityLaunchTime) {
|
||||||
|
Slog.w(TAG,
|
||||||
|
"Tried to set launchTime (" + launchTime + ") < mLastActivityLaunchTime ("
|
||||||
|
+ mLastActivityLaunchTime + ")");
|
||||||
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
mLastActivityLaunchTime = launchTime;
|
mLastActivityLaunchTime = launchTime;
|
||||||
@@ -449,6 +455,10 @@ public class WindowProcessController extends ConfigurationContainer<Configuratio
|
|||||||
boolean areBackgroundActivityStartsAllowed() {
|
boolean areBackgroundActivityStartsAllowed() {
|
||||||
// allow if the whitelisting flag was explicitly set
|
// allow if the whitelisting flag was explicitly set
|
||||||
if (mAllowBackgroundActivityStarts) {
|
if (mAllowBackgroundActivityStarts) {
|
||||||
|
if (DEBUG_ACTIVITY_STARTS) {
|
||||||
|
Slog.d(TAG, "[WindowProcessController(" + mPid
|
||||||
|
+ ")] Activity start allowed: mAllowBackgroundActivityStarts = true");
|
||||||
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
// allow if any activity in the caller has either started or finished very recently, and
|
// allow if any activity in the caller has either started or finished very recently, and
|
||||||
@@ -460,19 +470,43 @@ public class WindowProcessController extends ConfigurationContainer<Configuratio
|
|||||||
// let app to be able to start background activity even it's in grace period.
|
// let app to be able to start background activity even it's in grace period.
|
||||||
if (mLastActivityLaunchTime > mAtm.getLastStopAppSwitchesTime()
|
if (mLastActivityLaunchTime > mAtm.getLastStopAppSwitchesTime()
|
||||||
|| mLastActivityFinishTime > mAtm.getLastStopAppSwitchesTime()) {
|
|| mLastActivityFinishTime > mAtm.getLastStopAppSwitchesTime()) {
|
||||||
|
if (DEBUG_ACTIVITY_STARTS) {
|
||||||
|
Slog.d(TAG, "[WindowProcessController(" + mPid
|
||||||
|
+ ")] Activity start allowed: within "
|
||||||
|
+ ACTIVITY_BG_START_GRACE_PERIOD_MS + "ms grace period");
|
||||||
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
if (DEBUG_ACTIVITY_STARTS) {
|
||||||
|
Slog.d(TAG, "[WindowProcessController(" + mPid + ")] Activity start within "
|
||||||
|
+ ACTIVITY_BG_START_GRACE_PERIOD_MS
|
||||||
|
+ "ms grace period but also within stop app switch window");
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
// allow if the proc is instrumenting with background activity starts privs
|
// allow if the proc is instrumenting with background activity starts privs
|
||||||
if (mInstrumentingWithBackgroundActivityStartPrivileges) {
|
if (mInstrumentingWithBackgroundActivityStartPrivileges) {
|
||||||
|
if (DEBUG_ACTIVITY_STARTS) {
|
||||||
|
Slog.d(TAG, "[WindowProcessController(" + mPid
|
||||||
|
+ ")] Activity start allowed: process instrumenting with background "
|
||||||
|
+ "activity starts privileges");
|
||||||
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
// allow if the caller has an activity in any foreground task
|
// allow if the caller has an activity in any foreground task
|
||||||
if (hasActivityInVisibleTask()) {
|
if (hasActivityInVisibleTask()) {
|
||||||
|
if (DEBUG_ACTIVITY_STARTS) {
|
||||||
|
Slog.d(TAG, "[WindowProcessController(" + mPid
|
||||||
|
+ ")] Activity start allowed: process has activity in foreground task");
|
||||||
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
// allow if the caller is bound by a UID that's currently foreground
|
// allow if the caller is bound by a UID that's currently foreground
|
||||||
if (isBoundByForegroundUid()) {
|
if (isBoundByForegroundUid()) {
|
||||||
|
if (DEBUG_ACTIVITY_STARTS) {
|
||||||
|
Slog.d(TAG, "[WindowProcessController(" + mPid
|
||||||
|
+ ")] Activity start allowed: process bound by foreground uid");
|
||||||
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
|
|||||||
Reference in New Issue
Block a user