Update asm logging for non-activity sources

This update improves the previous logging to provide more data where an
activity start is blocked for a non-activity source - these would
previously have provided no details due to a null source record.

1. Log the callingUid to map to a package name.if sourceRecord is
   unavailble.
2. Provide the BAL code.

We also now show the launching package in the toast

Bug: 258792202
Test: TH passes
Change-Id: I963af999f45f4809c510b521dca53da2a5940131
This commit is contained in:
Hani Kazmi
2023-02-01 16:24:25 +00:00
parent 8d3cabe561
commit 88631c7bf2
2 changed files with 17 additions and 12 deletions

View File

@@ -1944,7 +1944,7 @@ class ActivityStarter {
FrameworkStatsLog.write(FrameworkStatsLog.ACTIVITY_ACTION_BLOCKED,
/* caller_uid */
mSourceRecord != null ? mSourceRecord.getUid() : -1,
mSourceRecord != null ? mSourceRecord.getUid() : mCallingUid,
/* caller_activity_class_name */
mSourceRecord != null ? mSourceRecord.info.name : null,
/* target_task_top_activity_uid */
@@ -1965,10 +1965,12 @@ class ActivityStarter {
/* action */
action,
/* version */
2,
3,
/* multi_window - we have our source not in the target task, but both are visible */
targetTask != null && mSourceRecord != null
&& !targetTask.equals(mSourceRecord.getTask()) && targetTask.isVisible()
&& !targetTask.equals(mSourceRecord.getTask()) && targetTask.isVisible(),
/* bal_code */
mBalCode
);
boolean shouldBlockActivityStart =
@@ -1976,19 +1978,20 @@ class ActivityStarter {
if (ActivitySecurityModelFeatureFlags.shouldShowToast(mCallingUid)) {
UiThread.getHandler().post(() -> Toast.makeText(mService.mContext,
(shouldBlockActivityStart
? "Activity start blocked by "
: "Activity start would be blocked by ")
+ ActivitySecurityModelFeatureFlags.DOC_LINK,
"Activity start from " + r.launchedFromPackage
+ (shouldBlockActivityStart ? " " : " would be ")
+ "blocked by " + ActivitySecurityModelFeatureFlags.DOC_LINK,
Toast.LENGTH_SHORT).show());
}
if (shouldBlockActivityStart) {
Slog.e(TAG, "Abort Launching r: " + r
+ " as source: " + mSourceRecord
+ "is in background. New task: " + newTask
+ ". Top activity: " + targetTopActivity);
+ " as source: "
+ (mSourceRecord != null ? mSourceRecord : r.launchedFromPackage)
+ " is in background. New task: " + newTask
+ ". Top activity: " + targetTopActivity
+ ". BAL Code: " + mBalCode);
return false;
}

View File

@@ -1662,9 +1662,11 @@ public class ActivityTaskSupervisor implements RecentTasks.Callbacks {
/* action */
FrameworkStatsLog.ACTIVITY_ACTION_BLOCKED__ACTION__FINISH_TASK,
/* version */
1,
3,
/* multi_window */
false
false,
/* bal_code */
-1
);
}
}