Update ASM logging for U release
1. Add an error message for launches which would be blocked in the future. 2. Include task stack. Bug: 269253404 Test: Manually checked logs Change-Id: I9184c3f4a1261a1b632028439d6977888b7bcb56
This commit is contained in:
@@ -2028,6 +2028,13 @@ class ActivityStarter {
|
||||
}
|
||||
}
|
||||
|
||||
// ASM rules have failed. Log why
|
||||
return logAsmFailureAndCheckFeatureEnabled(r, newTask, targetTask, shouldBlockActivityStart,
|
||||
taskToFront);
|
||||
}
|
||||
|
||||
private boolean logAsmFailureAndCheckFeatureEnabled(ActivityRecord r, boolean newTask,
|
||||
Task targetTask, boolean shouldBlockActivityStart, boolean taskToFront) {
|
||||
// ASM rules have failed. Log why
|
||||
ActivityRecord targetTopActivity = targetTask == null ? null
|
||||
: targetTask.getActivity(ar -> !ar.finishing && !ar.isAlwaysOnTop());
|
||||
@@ -2038,6 +2045,13 @@ class ActivityStarter {
|
||||
? FrameworkStatsLog.ACTIVITY_ACTION_BLOCKED__ACTION__ACTIVITY_START_SAME_TASK
|
||||
: FrameworkStatsLog.ACTIVITY_ACTION_BLOCKED__ACTION__ACTIVITY_START_DIFFERENT_TASK);
|
||||
|
||||
boolean blockActivityStartAndFeatureEnabled = ActivitySecurityModelFeatureFlags
|
||||
.shouldRestrictActivitySwitch(mCallingUid)
|
||||
&& shouldBlockActivityStart;
|
||||
|
||||
String asmDebugInfo = getDebugInfoForActivitySecurity("Launch", r, targetTask,
|
||||
targetTopActivity, blockActivityStartAndFeatureEnabled, /*taskToFront*/taskToFront);
|
||||
|
||||
FrameworkStatsLog.write(FrameworkStatsLog.ACTIVITY_ACTION_BLOCKED,
|
||||
/* caller_uid */
|
||||
mSourceRecord != null ? mSourceRecord.getUid() : mCallingUid,
|
||||
@@ -2066,24 +2080,21 @@ class ActivityStarter {
|
||||
targetTask != null && mSourceRecord != null
|
||||
&& !targetTask.equals(mSourceRecord.getTask()) && targetTask.isVisible(),
|
||||
/* bal_code */
|
||||
mBalCode
|
||||
mBalCode,
|
||||
/* task_stack */
|
||||
asmDebugInfo
|
||||
);
|
||||
|
||||
boolean blockActivityStartAndFeatureEnabled = ActivitySecurityModelFeatureFlags
|
||||
.shouldRestrictActivitySwitch(mCallingUid)
|
||||
&& shouldBlockActivityStart;
|
||||
|
||||
String launchedFromPackageName = r.launchedFromPackage;
|
||||
if (ActivitySecurityModelFeatureFlags.shouldShowToast(mCallingUid)) {
|
||||
String toastText = ActivitySecurityModelFeatureFlags.DOC_LINK
|
||||
+ (blockActivityStartAndFeatureEnabled ? " blocked " : " would block ")
|
||||
+ getApplicationLabel(mService.mContext.getPackageManager(),
|
||||
launchedFromPackageName);
|
||||
launchedFromPackageName);
|
||||
UiThread.getHandler().post(() -> Toast.makeText(mService.mContext,
|
||||
toastText, Toast.LENGTH_LONG).show());
|
||||
|
||||
logDebugInfoForActivitySecurity("Launch", r, targetTask, targetTopActivity,
|
||||
blockActivityStartAndFeatureEnabled, /* taskToFront */ taskToFront);
|
||||
Slog.i(TAG, asmDebugInfo);
|
||||
}
|
||||
|
||||
if (blockActivityStartAndFeatureEnabled) {
|
||||
@@ -2101,7 +2112,7 @@ class ActivityStarter {
|
||||
}
|
||||
|
||||
/** Only called when an activity launch may be blocked, which should happen very rarely */
|
||||
private void logDebugInfoForActivitySecurity(String action, ActivityRecord r, Task targetTask,
|
||||
private String getDebugInfoForActivitySecurity(String action, ActivityRecord r, Task targetTask,
|
||||
ActivityRecord targetTopActivity, boolean blockActivityStartAndFeatureEnabled,
|
||||
boolean taskToFront) {
|
||||
final String prefix = "[ASM] ";
|
||||
@@ -2162,7 +2173,7 @@ class ActivityStarter {
|
||||
joiner.add(prefix + "BalCode: " + balCodeToString(mBalCode));
|
||||
|
||||
joiner.add(prefix + "------ Activity Security " + action + " Debug Logging End ------");
|
||||
Slog.i(TAG, joiner.toString());
|
||||
return joiner.toString();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -2336,7 +2347,7 @@ class ActivityStarter {
|
||||
+ ActivitySecurityModelFeatureFlags.DOC_LINK,
|
||||
Toast.LENGTH_LONG).show());
|
||||
|
||||
logDebugInfoForActivitySecurity("Clear Top", mStartActivity, targetTask, targetTaskTop,
|
||||
getDebugInfoForActivitySecurity("Clear Top", mStartActivity, targetTask, targetTaskTop,
|
||||
shouldBlockActivityStart, /* taskToFront */ true);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1752,7 +1752,9 @@ public class ActivityTaskSupervisor implements RecentTasks.Callbacks {
|
||||
/* multi_window */
|
||||
false,
|
||||
/* bal_code */
|
||||
-1
|
||||
-1,
|
||||
/* task_stack */
|
||||
null
|
||||
);
|
||||
|
||||
boolean restrictActivitySwitch = ActivitySecurityModelFeatureFlags
|
||||
|
||||
Reference in New Issue
Block a user