From 78ee160c20eeb41bb7eccfde9af772a9b1a958d6 Mon Sep 17 00:00:00 2001 From: Chris Antol Date: Thu, 29 Aug 2024 19:50:55 +0000 Subject: [PATCH] Only check INTERACT_ACROSS_USERS_FULL when user handle is not current Bug: 326057017 Change-Id: I83ab4461f28e7f40c676099213c840a1a7dc932a Test: atest; open app info pages from both primary and secondary profile -> verify they open as expected Flag: EXEMPT bug fix --- .../settings/applications/AppInfoBase.java | 16 ++++++++-------- .../applications/AppInfoWithHeaderTest.java | 4 ++-- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/src/com/android/settings/applications/AppInfoBase.java b/src/com/android/settings/applications/AppInfoBase.java index c056add7ef3..1d774826c2d 100644 --- a/src/com/android/settings/applications/AppInfoBase.java +++ b/src/com/android/settings/applications/AppInfoBase.java @@ -136,14 +136,14 @@ public abstract class AppInfoBase extends SettingsPreferenceFragment mPackageName = intent.getData().getSchemeSpecificPart(); } } - if (!hasInteractAcrossUsersPermission()) { - Log.w(TAG, "Intent not valid."); - finish(); - return ""; - } if (intent != null && intent.hasExtra(Intent.EXTRA_USER_HANDLE)) { - mUserId = ((UserHandle) intent.getParcelableExtra( - Intent.EXTRA_USER_HANDLE)).getIdentifier(); + mUserId = ((UserHandle) intent.getParcelableExtra(Intent.EXTRA_USER_HANDLE)) + .getIdentifier(); + if (mUserId != UserHandle.myUserId() && !hasInteractAcrossUsersFullPermission()) { + Log.w(TAG, "Intent not valid."); + finish(); + return ""; + } } else { mUserId = UserHandle.myUserId(); } @@ -171,7 +171,7 @@ public abstract class AppInfoBase extends SettingsPreferenceFragment } @VisibleForTesting - protected boolean hasInteractAcrossUsersPermission() { + protected boolean hasInteractAcrossUsersFullPermission() { Activity activity = getActivity(); if (!(activity instanceof SettingsActivity)) { return false; diff --git a/tests/robotests/src/com/android/settings/applications/AppInfoWithHeaderTest.java b/tests/robotests/src/com/android/settings/applications/AppInfoWithHeaderTest.java index cb121ea3c05..0ed56c0fec6 100644 --- a/tests/robotests/src/com/android/settings/applications/AppInfoWithHeaderTest.java +++ b/tests/robotests/src/com/android/settings/applications/AppInfoWithHeaderTest.java @@ -250,7 +250,7 @@ public class AppInfoWithHeaderTest { } @Override - protected boolean hasInteractAcrossUsersPermission() { + protected boolean hasInteractAcrossUsersFullPermission() { return true; } @@ -267,7 +267,7 @@ public class AppInfoWithHeaderTest { private static final class TestFragmentWithoutPermission extends TestFragment { @Override - protected boolean hasInteractAcrossUsersPermission() { + protected boolean hasInteractAcrossUsersFullPermission() { return false; } }