Merge "Update ASM logging for U release" into udc-qpr-dev am: 53e91c63af am: 9ccc2d55ee

Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/23874531

Change-Id: I65ac5100c88b848c59120b19ea2c42af31b091ae
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
This commit is contained in:
Hani Kazmi
2023-07-24 19:14:14 +00:00
committed by Automerger Merge Worker
2 changed files with 25 additions and 12 deletions

View File

@@ -2041,6 +2041,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());
@@ -2051,6 +2058,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,
@@ -2079,24 +2093,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) {
@@ -2114,7 +2125,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] ";
@@ -2175,7 +2186,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();
}
/**
@@ -2349,7 +2360,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);
}
}

View File

@@ -1752,7 +1752,9 @@ public class ActivityTaskSupervisor implements RecentTasks.Callbacks {
/* multi_window */
false,
/* bal_code */
-1
-1,
/* task_stack */
null
);
boolean restrictActivitySwitch = ActivitySecurityModelFeatureFlags