diff options
author | Hai Zhang <zhanghai@google.com> | 2019-08-26 13:11:44 -0700 |
---|---|---|
committer | Hai Zhang <zhanghai@google.com> | 2019-08-26 22:51:28 +0000 |
commit | 1719c99a5f31621c270ad10068e90eec48c61812 (patch) | |
tree | 215fb4bcc15ea02adabc4c0b8f7d5e9344054ae4 | |
parent | 0e7ae6d3b060ab5a17d028f27401ec3716dfd0f7 (diff) | |
download | android_packages_apps_PackageInstaller-1719c99a5f31621c270ad10068e90eec48c61812.tar.gz android_packages_apps_PackageInstaller-1719c99a5f31621c270ad10068e90eec48c61812.tar.bz2 android_packages_apps_PackageInstaller-1719c99a5f31621c270ad10068e90eec48c61812.zip |
Don't show Settings as a home app anywhere in UI.
FallbackHome inside Settings should not be explicitly set as the home
activity by user, which will prevent the device from getting a real
home app running. It is already hidden in Default apps settings, but
it needs to be hidden in the request role dialog as well.
Fixes: 139919985
Test: Manually confirm Setting doesn't appear in request role dialog
Test: or Default apps settings.
Change-Id: I6f8e935ebc6ff3aed6a54c595a2e5492321432a8
4 files changed, 37 insertions, 3 deletions
diff --git a/src/com/android/packageinstaller/role/model/HomeRoleBehavior.java b/src/com/android/packageinstaller/role/model/HomeRoleBehavior.java index c59575de..eb808acb 100644 --- a/src/com/android/packageinstaller/role/model/HomeRoleBehavior.java +++ b/src/com/android/packageinstaller/role/model/HomeRoleBehavior.java @@ -126,12 +126,17 @@ public class HomeRoleBehavior implements RoleBehavior { } @Override + public boolean isApplicationVisibleAsUser(@NonNull Role role, + @NonNull ApplicationInfo applicationInfo, @NonNull UserHandle user, + @NonNull Context context) { + // Home is not available for work profile, so we can just use the current user. + return !isSettingsApplication(applicationInfo, context); + } + + @Override public void prepareApplicationPreferenceAsUser(@NonNull Role role, @NonNull Preference preference, @NonNull ApplicationInfo applicationInfo, @NonNull UserHandle user, @NonNull Context context) { - // Home is not available for work profile, so we can just use the current user. - boolean isSettingsApplication = isSettingsApplication(applicationInfo, context); - preference.setVisible(!isSettingsApplication); boolean missingWorkProfileSupport = isMissingWorkProfileSupport(applicationInfo, context); preference.setEnabled(!missingWorkProfileSupport); preference.setSummary(missingWorkProfileSupport ? context.getString( diff --git a/src/com/android/packageinstaller/role/model/Role.java b/src/com/android/packageinstaller/role/model/Role.java index 58cbf622..e3332db0 100644 --- a/src/com/android/packageinstaller/role/model/Role.java +++ b/src/com/android/packageinstaller/role/model/Role.java @@ -369,6 +369,23 @@ public class Role { } /** + * Check whether a qualifying application should be visible to user. + * + * @param applicationInfo the {@link ApplicationInfo} for the application + * @param user the user for the application + * @param context the {@code Context} to retrieve system services + * + * @return whether the qualifying application should be visible to user + */ + public boolean isApplicationVisibleAsUser(@NonNull ApplicationInfo applicationInfo, + @NonNull UserHandle user, @NonNull Context context) { + if (mBehavior != null) { + return mBehavior.isApplicationVisibleAsUser(this, applicationInfo, user, context); + } + return true; + } + + /** * Prepare a {@link Preference} for an application. * * @param preference the {@link Preference} for the application diff --git a/src/com/android/packageinstaller/role/model/RoleBehavior.java b/src/com/android/packageinstaller/role/model/RoleBehavior.java index 4a30d00c..41ffb455 100644 --- a/src/com/android/packageinstaller/role/model/RoleBehavior.java +++ b/src/com/android/packageinstaller/role/model/RoleBehavior.java @@ -84,6 +84,15 @@ public interface RoleBehavior { @NonNull Context context) {} /** + * @see Role#isApplicationVisibleAsUser(ApplicationInfo, UserHandle, Context) + */ + default boolean isApplicationVisibleAsUser(@NonNull Role role, + @NonNull ApplicationInfo applicationInfo, @NonNull UserHandle user, + @NonNull Context context) { + return true; + } + + /** * @see Role#prepareApplicationPreferenceAsUser(Preference, ApplicationInfo, UserHandle, * Context) */ diff --git a/src/com/android/packageinstaller/role/ui/RoleLiveData.java b/src/com/android/packageinstaller/role/ui/RoleLiveData.java index 4b932b6f..5a7b138b 100644 --- a/src/com/android/packageinstaller/role/ui/RoleLiveData.java +++ b/src/com/android/packageinstaller/role/ui/RoleLiveData.java @@ -94,6 +94,9 @@ public class RoleLiveData extends AsyncTaskLiveData<List<Pair<ApplicationInfo, B + qualifyingPackageName); continue; } + if (!mRole.isApplicationVisibleAsUser(qualifyingApplicationInfo, mUser, mContext)) { + continue; + } boolean isHolderApplication = holderPackageNames.contains(qualifyingPackageName); qualifyingApplications.add(new Pair<>(qualifyingApplicationInfo, isHolderApplication)); } |