Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 7876adb6 authored by Hai Zhang's avatar Hai Zhang
Browse files

Add config_defaultRoleHolders for specifying default role holders.

This config string array will be an array of roles and package names
of their default holders, with each item in the format of "ROLE_NAME:
PACKAGE_NAME_1, PACKAGE_NAME_2". This config will be read by
PermissionController to initialize the roles. This change also fixed
an issue preventing role controller to set default holders correctly.

Bug: 110557011
Bug: 122730135
Test: build
Change-Id: I90ffd156d26098235c821e7937950c0b420e0e7f
parent 94ae766a
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -195,6 +195,7 @@ package android {
  }
  public static final class R.array {
    field public static final int config_defaultRoleHolders = 17235974; // 0x1070006
    field public static final int config_keySystemUuidMapping = 17235973; // 0x1070005
  }
+8 −0
Original line number Diff line number Diff line
@@ -1855,6 +1855,8 @@
               cell broadcasting sms, and MMS. -->
    <bool name="config_sms_capable">true</bool>

    <!-- TODO: STOPSHIP(b/110557011): Remove this from framework and overlays as we use
         config_defaultRoleHolders now. -->
    <!-- Default SMS Application. This will be the default SMS application when
         the phone first boots. The user can then change the default app to one
         of their choosing.
@@ -1873,6 +1875,12 @@
         the behavior will be as though no app was named as an explicit default. -->
    <string name="default_browser" translatable="false"></string>

    <!-- Default role holders. This will be an array of roles and package names of their default
         holders, with each item in the format of "ROLE_NAME: PACKAGE_NAME_1, PACKAGE_NAME_2". -->
    <string-array name="config_defaultRoleHolders" translatable="false">
        <item>android.app.role.SMS: com.android.messaging</item>
    </string-array>

    <!-- Enable/disable default bluetooth profiles:
        HSP_AG, ObexObjectPush, Audio, NAP -->
    <bool name="config_bluetooth_default_profiles">true</bool>
+5 −0
Original line number Diff line number Diff line
@@ -2985,6 +2985,11 @@
        <public name="system_notification_accent_color" />
    </public-group>

    <public-group type="array" first-id="0x01070006">
      <!-- @hide @SystemApi -->
      <public name="config_defaultRoleHolders" />
    </public-group>

  <!-- ===============================================================
       DO NOT ADD UN-GROUPED ITEMS HERE

+2 −0
Original line number Diff line number Diff line
@@ -62,6 +62,8 @@ public class LegacyRoleResolutionPolicy implements RoleManagerService.RoleHolder
                        mContext.getContentResolver(),
                        Settings.Secure.SMS_DEFAULT_APPLICATION, userId);

                // TODO: STOPSHIP: Remove the following code once we remove default_sms_application
                // and use the new config_defaultRoleHolders.
                if (result == null) {
                    Collection<SmsApplication.SmsApplicationData> applications =
                            SmsApplication.getApplicationCollectionAsUser(mContext, userId);
+4 −1
Original line number Diff line number Diff line
@@ -229,9 +229,12 @@ public class RoleManagerService extends SystemService implements RoleUserState.C
        // Any role for which we have a record are already migrated
        RoleUserState userState = getOrCreateUserState(userId);
        if (!userState.isRoleAvailable(role)) {
            userState.addRoleName(role);
            List<String> roleHolders = mLegacyRoleResolver.getRoleHolders(role, userId);
            if (roleHolders.isEmpty()) {
                return;
            }
            Slog.i(LOG_TAG, "Migrating " + role + ", legacy holders: " + roleHolders);
            userState.addRoleName(role);
            int size = roleHolders.size();
            for (int i = 0; i < size; i++) {
                userState.addRoleHolder(role, roleHolders.get(i));