Merge "Add logging for activity finishActivity to be blocked as part of go/activity-security"

This commit is contained in:
Hani Kazmi
2022-11-11 10:53:09 +00:00
committed by Android (Google) Code Review
2 changed files with 47 additions and 1 deletions

View File

@@ -86,6 +86,7 @@ import android.window.TransitionInfo;
import com.android.internal.app.AssistUtils;
import com.android.internal.policy.IKeyguardDismissCallback;
import com.android.internal.protolog.common.ProtoLog;
import com.android.internal.util.FrameworkStatsLog;
import com.android.server.LocalServices;
import com.android.server.Watchdog;
import com.android.server.pm.KnownPackages;
@@ -454,6 +455,39 @@ class ActivityClientController extends IActivityClientController.Stub {
finishTask == Activity.FINISH_TASK_WITH_ROOT_ACTIVITY;
if (finishTask == Activity.FINISH_TASK_WITH_ACTIVITY
|| (finishWithRootActivity && r == rootR)) {
ActivityRecord topActivity =
r.getTask().getTopNonFinishingActivity();
boolean passesAsmChecks = topActivity != null
&& topActivity.getUid() == r.getUid();
if (!passesAsmChecks) {
Slog.i(TAG, "Finishing task from background. r: " + r);
FrameworkStatsLog.write(FrameworkStatsLog.ACTIVITY_ACTION_BLOCKED,
/* caller_uid */
r.getUid(),
/* caller_activity_class_name */
r.info.name,
/* target_task_top_activity_uid */
topActivity == null ? -1 : topActivity.getUid(),
/* target_task_top_activity_class_name */
topActivity == null ? null : topActivity.info.name,
/* target_task_is_different */
false,
/* target_activity_uid */
-1,
/* target_activity_class_name */
null,
/* target_intent_action */
null,
/* target_intent_flags */
0,
/* action */
FrameworkStatsLog.ACTIVITY_ACTION_BLOCKED__ACTION__FINISH_TASK,
/* version */
1,
/* multi_window */
false
);
}
// If requested, remove the task that is associated to this activity only if it
// was the root activity in the task. The result code and data is ignored
// because we don't support returning them across task boundaries. Also, to

View File

@@ -1857,6 +1857,11 @@ class ActivityStarter {
+ " from background: " + mSourceRecord
+ ". New task: " + newTask);
boolean newOrEmptyTask = newTask || (targetTopActivity == null);
int action = newTask
? FrameworkStatsLog.ACTIVITY_ACTION_BLOCKED__ACTION__ACTIVITY_START_NEW_TASK
: (mSourceRecord.getTask().equals(targetTask)
? FrameworkStatsLog.ACTIVITY_ACTION_BLOCKED__ACTION__ACTIVITY_START_SAME_TASK
: FrameworkStatsLog.ACTIVITY_ACTION_BLOCKED__ACTION__ACTIVITY_START_DIFFERENT_TASK);
FrameworkStatsLog.write(FrameworkStatsLog.ACTIVITY_ACTION_BLOCKED,
/* caller_uid */
callerUid,
@@ -1875,7 +1880,14 @@ class ActivityStarter {
/* target_intent_action */
r.intent.getAction(),
/* target_intent_flags */
r.intent.getFlags()
r.intent.getFlags(),
/* action */
action,
/* version */
1,
/* multi_window */
targetTask != null && !targetTask.equals(mSourceRecord.getTask())
&& targetTask.isVisible()
);
}
}