From 2af47ea5c79b9653c673455267f8baac991fb9f0 Mon Sep 17 00:00:00 2001 From: Mark Renouf Date: Fri, 3 May 2024 11:18:46 -0400 Subject: Dismiss if restarting after private space is locked Share sheet only dismisses when it is moved to the background. When private space is set to lock automatically, the private space profile tab may remain visible, leading to disclosure risk. When restarting ChooserActivity, if the private tab was visible but the private profile has since become locked, the activity will be finished instead. Bug: 338125945 Flag: com.android.intentresolver.fix_private_space_locked_on_restart Test: manual; see description, screencast in bug Change-Id: I294bf62f0a73f6c1b73f598109814701215cdeb5 --- java/src/com/android/intentresolver/ChooserActivity.java | 9 +++++++++ java/src/com/android/intentresolver/ProfileAvailability.kt | 2 +- 2 files changed, 10 insertions(+), 1 deletion(-) (limited to 'java') diff --git a/java/src/com/android/intentresolver/ChooserActivity.java b/java/src/com/android/intentresolver/ChooserActivity.java index 1922c05c..f01fd77c 100644 --- a/java/src/com/android/intentresolver/ChooserActivity.java +++ b/java/src/com/android/intentresolver/ChooserActivity.java @@ -416,6 +416,15 @@ public class ChooserActivity extends Hilt_ChooserActivity implements @Override protected final void onRestart() { super.onRestart(); + if (mFeatureFlags.fixPrivateSpaceLockedOnRestart()) { + if (mChooserMultiProfilePagerAdapter.hasPageForProfile(Profile.Type.PRIVATE.ordinal()) + && !mProfileAvailability.isAvailable(mProfiles.getPrivateProfile())) { + Log.d(TAG, "Exiting due to unavailable profile"); + finish(); + return; + } + } + if (!mRegistered) { mPersonalPackageMonitor.register( this, diff --git a/java/src/com/android/intentresolver/ProfileAvailability.kt b/java/src/com/android/intentresolver/ProfileAvailability.kt index c8e78552..43982727 100644 --- a/java/src/com/android/intentresolver/ProfileAvailability.kt +++ b/java/src/com/android/intentresolver/ProfileAvailability.kt @@ -47,7 +47,7 @@ class ProfileAvailability( /** Query current profile availability. An unavailable profile is one which is not active. */ @MainThread - fun isAvailable(profile: Profile): Boolean { + fun isAvailable(profile: Profile?): Boolean { return runBlocking(background) { userInteractor.availability.map { it[profile] == true }.first() } -- cgit v1.2.3-59-g8ed1b