Loading src/com/android/packageinstaller/PackageInstallerApplication.java +5 −4 Original line number Diff line number Diff line Loading @@ -38,23 +38,24 @@ public class PackageInstallerApplication extends Application { private void updateSpecialAppAccessListActivityEnabledState() { ArrayMap<String, Role> roles = Roles.get(this); boolean hasSpecialAppAccess = false; boolean hasVisibleSpecialAppAccess = false; int rolesSize = roles.size(); for (int i = 0; i < rolesSize; i++) { Role role = roles.valueAt(i); if (!role.isAvailable(this)) { if (!role.isAvailable(this) || !role.isVisible(this)) { continue; } if (!role.isExclusive()) { hasSpecialAppAccess = true; hasVisibleSpecialAppAccess = true; break; } } PackageManager packageManager = getPackageManager(); ComponentName componentName = new ComponentName(this, SpecialAppAccessListActivity.class); int enabledState = hasSpecialAppAccess ? PackageManager.COMPONENT_ENABLED_STATE_DEFAULT int enabledState = hasVisibleSpecialAppAccess ? PackageManager.COMPONENT_ENABLED_STATE_DEFAULT : PackageManager.COMPONENT_ENABLED_STATE_DISABLED; packageManager.setComponentEnabledSetting(componentName, enabledState, PackageManager.DONT_KILL_APP); Loading src/com/android/packageinstaller/role/model/Role.java +11 −0 Original line number Diff line number Diff line Loading @@ -261,6 +261,17 @@ public class Role { return true; } /** * Check whether this role should be visible to user, for current user. * * @param context the {@code Context} to retrieve system services * * @return whether this role should be visible to user. */ public boolean isVisible(@NonNull Context context) { return isVisibleAsUser(Process.myUserHandle(), context); } /** * Get the {@link Intent} to manage this role, or {@code null} to use the default UI. * Loading src/com/android/packageinstaller/role/service/RoleSearchIndexablesProvider.java +4 −0 Original line number Diff line number Diff line Loading @@ -50,6 +50,10 @@ public class RoleSearchIndexablesProvider extends BaseSearchIndexablesProvider { for (int i = 0; i < rolesSize; i++) { Role role = roles.valueAt(i); if (!role.isAvailable(context) || !role.isVisible(context)) { continue; } String label = context.getString(role.getLabelResource()); boolean isExclusive = role.isExclusive(); cursor.newRow() Loading src/com/android/packageinstaller/role/ui/RequestRoleActivity.java +6 −0 Original line number Diff line number Diff line Loading @@ -83,6 +83,12 @@ public class RequestRoleActivity extends FragmentActivity { return; } if (!role.isVisible(this)) { Log.e(LOG_TAG, "Role is invisible: " + mRoleName); finish(); return; } if (PackageUtils.getApplicationInfo(mPackageName, this) == null) { Log.w(LOG_TAG, "Unknown application: " + mPackageName); finish(); Loading Loading
src/com/android/packageinstaller/PackageInstallerApplication.java +5 −4 Original line number Diff line number Diff line Loading @@ -38,23 +38,24 @@ public class PackageInstallerApplication extends Application { private void updateSpecialAppAccessListActivityEnabledState() { ArrayMap<String, Role> roles = Roles.get(this); boolean hasSpecialAppAccess = false; boolean hasVisibleSpecialAppAccess = false; int rolesSize = roles.size(); for (int i = 0; i < rolesSize; i++) { Role role = roles.valueAt(i); if (!role.isAvailable(this)) { if (!role.isAvailable(this) || !role.isVisible(this)) { continue; } if (!role.isExclusive()) { hasSpecialAppAccess = true; hasVisibleSpecialAppAccess = true; break; } } PackageManager packageManager = getPackageManager(); ComponentName componentName = new ComponentName(this, SpecialAppAccessListActivity.class); int enabledState = hasSpecialAppAccess ? PackageManager.COMPONENT_ENABLED_STATE_DEFAULT int enabledState = hasVisibleSpecialAppAccess ? PackageManager.COMPONENT_ENABLED_STATE_DEFAULT : PackageManager.COMPONENT_ENABLED_STATE_DISABLED; packageManager.setComponentEnabledSetting(componentName, enabledState, PackageManager.DONT_KILL_APP); Loading
src/com/android/packageinstaller/role/model/Role.java +11 −0 Original line number Diff line number Diff line Loading @@ -261,6 +261,17 @@ public class Role { return true; } /** * Check whether this role should be visible to user, for current user. * * @param context the {@code Context} to retrieve system services * * @return whether this role should be visible to user. */ public boolean isVisible(@NonNull Context context) { return isVisibleAsUser(Process.myUserHandle(), context); } /** * Get the {@link Intent} to manage this role, or {@code null} to use the default UI. * Loading
src/com/android/packageinstaller/role/service/RoleSearchIndexablesProvider.java +4 −0 Original line number Diff line number Diff line Loading @@ -50,6 +50,10 @@ public class RoleSearchIndexablesProvider extends BaseSearchIndexablesProvider { for (int i = 0; i < rolesSize; i++) { Role role = roles.valueAt(i); if (!role.isAvailable(context) || !role.isVisible(context)) { continue; } String label = context.getString(role.getLabelResource()); boolean isExclusive = role.isExclusive(); cursor.newRow() Loading
src/com/android/packageinstaller/role/ui/RequestRoleActivity.java +6 −0 Original line number Diff line number Diff line Loading @@ -83,6 +83,12 @@ public class RequestRoleActivity extends FragmentActivity { return; } if (!role.isVisible(this)) { Log.e(LOG_TAG, "Role is invisible: " + mRoleName); finish(); return; } if (PackageUtils.getApplicationInfo(mPackageName, this) == null) { Log.w(LOG_TAG, "Unknown application: " + mPackageName); finish(); Loading