Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 88631c7b authored by Hani Kazmi's avatar Hani Kazmi
Browse files

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
parent 8d3cabe5
Loading
Loading
Loading
Loading
+13 −10
Original line number Diff line number Diff line
@@ -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
                    + " as source: "
                    + (mSourceRecord != null ? mSourceRecord : r.launchedFromPackage)
                    + " is in background. New task: " + newTask
                    + ". Top activity: " + targetTopActivity);
                    + ". Top activity: " + targetTopActivity
                    + ". BAL Code: " + mBalCode);

            return false;
        }
+4 −2
Original line number Diff line number Diff line
@@ -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
                );
            }
        }