From 63da8c35f7032912de22975882d4bf22c193d52a Mon Sep 17 00:00:00 2001 From: Himanshu Gupta Date: Wed, 1 May 2024 16:25:25 +0100 Subject: [PATCH] Do not move to ALL_APPS when default Launcher is not system. Currently we fire ALL_APP intent for System Launchers at the end of PS setup flow, even when the system launcher (NexusLauncher) was not the default Launcher. In such cases, the user is moved to NexusLauncher, but they cannot unlock PS (only default launcher can do it), leading to crashes. To fix this, we do not fire the intent in case non system Launcher has the HOME role. Bug: 331722929 Test: Manual build and flash Flag: NA Change-Id: I77353474cc74028d72508c433c89b6116b4148bd --- .../privatespace/SetupSuccessFragment.java | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/src/com/android/settings/privatespace/SetupSuccessFragment.java b/src/com/android/settings/privatespace/SetupSuccessFragment.java index 647bc62087d..bfd9e961837 100644 --- a/src/com/android/settings/privatespace/SetupSuccessFragment.java +++ b/src/com/android/settings/privatespace/SetupSuccessFragment.java @@ -18,6 +18,7 @@ package com.android.settings.privatespace; import android.app.Activity; import android.app.ActivityManager; +import android.app.role.RoleManager; import android.app.settings.SettingsEnums; import android.content.Intent; import android.content.pm.PackageManager; @@ -103,12 +104,19 @@ public class SetupSuccessFragment extends InstrumentedFragment { PackageManager.MATCH_SYSTEM_ONLY, activity.getUserId()); if (resolveInfo != null) { - allAppsIntent.setPackage(resolveInfo.activityInfo.packageName); - allAppsIntent.setComponent(resolveInfo.activityInfo.getComponentName()); + RoleManager mRoleManager = getContext().getSystemService(RoleManager.class); + final List packageNames = mRoleManager + .getRoleHolders(RoleManager.ROLE_HOME); + if (packageNames.contains(resolveInfo.activityInfo.packageName)) { + allAppsIntent.setPackage(resolveInfo.activityInfo.packageName); + allAppsIntent.setComponent(resolveInfo.activityInfo.getComponentName()); + } } activity.setTheme(R.style.Theme_SubSettings); - accessPrivateSpaceToast(); - startActivity(allAppsIntent); + if (allAppsIntent.getPackage() != null) { + accessPrivateSpaceToast(); + startActivity(allAppsIntent); + } Log.i(TAG, "Private space setup complete"); deleteAllTaskAndFinish(activity); }