diff options
| author | 2024-05-28 16:55:47 +0000 | |
|---|---|---|
| committer | 2024-06-11 14:01:45 +0000 | |
| commit | be0e7f20c47180a2f05d852007b68d745a4e78ef (patch) | |
| tree | 835536410eb508f8d22a5caaecd3193297ed6203 | |
| parent | 9046efe028f70a47275cf912af8533902a52315f (diff) | |
Show AppSelectorActivity for all users
Fix an issue where app selector could only be opened on primary user
Fix: 339789605
Bug: 298975543
Flag: NONE unnecesary
Test: PSS screen recording from system on a secondary user while opening a new app
Test: PSS screen recording from system on a secondary user while opening a recent app
Test: PSS screen recording from 3P app on a secondary user while opening a new app
Test: PSS screen recording from 3P app on a secondary user while opening a recent app
Test: PSS screen sharing on a secondary user while opening a new app
Test: PSS screen sharing on a secondary user while opening a recent app
Change-Id: I698a12f12ba2cfade23b6f10824815614c79db88
3 files changed, 8 insertions, 6 deletions
diff --git a/packages/SystemUI/AndroidManifest.xml b/packages/SystemUI/AndroidManifest.xml index a9c4399d81ab..bd6efe5242b2 100644 --- a/packages/SystemUI/AndroidManifest.xml +++ b/packages/SystemUI/AndroidManifest.xml @@ -650,6 +650,7 @@ <!-- started from MediaProjectionManager --> <activity android:name=".mediaprojection.permission.MediaProjectionPermissionActivity" + android:showForAllUsers="true" android:exported="true" android:theme="@style/Theme.SystemUI.MediaProjectionAlertDialog" android:finishOnCloseSystemDialogs="true" @@ -660,6 +661,7 @@ <activity android:name=".mediaprojection.appselector.MediaProjectionAppSelectorActivity" android:theme="@style/Theme.SystemUI.MediaProjectionAppSelector" + android:showForAllUsers="true" android:finishOnCloseSystemDialogs="true" android:excludeFromRecents="true" android:documentLaunchMode="never" diff --git a/packages/SystemUI/src/com/android/systemui/mediaprojection/appselector/data/RecentTaskListProvider.kt b/packages/SystemUI/src/com/android/systemui/mediaprojection/appselector/data/RecentTaskListProvider.kt index 03adf1b68095..01b1be9d02b7 100644 --- a/packages/SystemUI/src/com/android/systemui/mediaprojection/appselector/data/RecentTaskListProvider.kt +++ b/packages/SystemUI/src/com/android/systemui/mediaprojection/appselector/data/RecentTaskListProvider.kt @@ -58,7 +58,7 @@ constructor( // opening the app selector in split screen mode, the foreground task will be the second // task in index 0. val foregroundGroup = - if (groupedTasks.first().splitBounds != null) groupedTasks.first() + if (groupedTasks.firstOrNull()?.splitBounds != null) groupedTasks.first() else groupedTasks.elementAtOrNull(1) val foregroundTaskId1 = foregroundGroup?.taskInfo1?.taskId val foregroundTaskId2 = foregroundGroup?.taskInfo2?.taskId diff --git a/packages/SystemUI/src/com/android/systemui/mediaprojection/permission/MediaProjectionPermissionActivity.java b/packages/SystemUI/src/com/android/systemui/mediaprojection/permission/MediaProjectionPermissionActivity.java index e861ddf69aa6..f004c3a8916f 100644 --- a/packages/SystemUI/src/com/android/systemui/mediaprojection/permission/MediaProjectionPermissionActivity.java +++ b/packages/SystemUI/src/com/android/systemui/mediaprojection/permission/MediaProjectionPermissionActivity.java @@ -23,6 +23,7 @@ import static android.media.projection.IMediaProjectionManager.EXTRA_USER_REVIEW import static android.media.projection.MediaProjectionManager.OVERRIDE_DISABLE_MEDIA_PROJECTION_SINGLE_APP_OPTION; import static android.media.projection.ReviewGrantedConsentResult.RECORD_CANCEL; import static android.media.projection.ReviewGrantedConsentResult.RECORD_CONTENT_DISPLAY; +import static android.os.UserHandle.USER_SYSTEM; import static android.view.WindowManager.LayoutParams.SYSTEM_FLAG_HIDE_NON_SYSTEM_OVERLAY_WINDOWS; import static com.android.systemui.mediaprojection.permission.ScreenShareOptionKt.ENTIRE_SCREEN; @@ -31,7 +32,6 @@ import static com.android.systemui.mediaprojection.permission.ScreenShareOptionK import android.annotation.Nullable; import android.annotation.RequiresPermission; import android.app.Activity; -import android.app.ActivityManager; import android.app.ActivityOptions.LaunchCookie; import android.app.AlertDialog; import android.app.StatusBarManager; @@ -366,11 +366,11 @@ public class MediaProjectionPermissionActivity extends Activity intent.putExtra(EXTRA_USER_REVIEW_GRANTED_CONSENT, mReviewGrantedConsentRequired); intent.setFlags(Intent.FLAG_ACTIVITY_FORWARD_RESULT); - // Start activity from the current foreground user to avoid creating a separate - // SystemUI process without access to recent tasks because it won't have - // WM Shell running inside. + // Start activity as system user and manually show app selector to all users to + // avoid creating a separate SystemUI process without access to recent tasks + // because it won't have WM Shell running inside. mUserSelectingTask = true; - startActivityAsUser(intent, UserHandle.of(ActivityManager.getCurrentUser())); + startActivityAsUser(intent, UserHandle.of(USER_SYSTEM)); // close shade if it's open mStatusBarManager.collapsePanels(); } |