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

Commit e8ca5932 authored by Jack Yu's avatar Jack Yu
Browse files

Fixed display name not persisted

The display number was incorrectly replacing
the display name.

Fix: 266228825
Test: Manual + atest SubscriptionManagerServiceTest
Change-Id: I05ad5e129edcb9e7c426a1ea1f096d2447939e61
parent 502bb1c2
Loading
Loading
Loading
Loading
+27 −4
Original line number Diff line number Diff line
@@ -1933,6 +1933,7 @@ public class SubscriptionManagerService extends ISub.Stub {
            @SimDisplayNameSource int nameSource) {
        enforcePermissions("setDisplayNameUsingSrc", Manifest.permission.MODIFY_PHONE_STATE);

        String callingPackage = getCallingPackage();
        final long identity = Binder.clearCallingIdentity();
        try {
            Objects.requireNonNull(displayName, "setDisplayNameUsingSrc");
@@ -1980,6 +1981,9 @@ public class SubscriptionManagerService extends ISub.Stub {
                nameToSet = displayName;
            }

            logl("setDisplayNameUsingSrc: subId=" + subId + ", name=" + nameToSet
                    + ", nameSource=" + SubscriptionManager.displayNameSourceToString(nameSource)
                    + ", calling package=" + callingPackage);
            mSubscriptionDatabaseManager.setDisplayName(subId, nameToSet);
            mSubscriptionDatabaseManager.setDisplayNameSource(subId, nameSource);

@@ -2017,11 +2021,12 @@ public class SubscriptionManagerService extends ISub.Stub {
    @RequiresPermission(Manifest.permission.MODIFY_PHONE_STATE)
    public int setDisplayNumber(@NonNull String number, int subId) {
        enforcePermissions("setDisplayNumber", Manifest.permission.MODIFY_PHONE_STATE);

        logl("setDisplayNumber: subId=" + subId + ", number=" + number
                + ", calling package=" + getCallingPackage());
        // Now that all security checks passes, perform the operation as ourselves.
        final long identity = Binder.clearCallingIdentity();
        try {
            mSubscriptionDatabaseManager.setDisplayName(subId, number);
            mSubscriptionDatabaseManager.setNumber(subId, number);
            return 1;
        } finally {
            Binder.restoreCallingIdentity(identity);
@@ -3056,8 +3061,15 @@ public class SubscriptionManagerService extends ISub.Stub {
    public int setUiccApplicationsEnabled(boolean enabled, int subId) {
        enforcePermissions("setUiccApplicationsEnabled",
                Manifest.permission.MODIFY_PHONE_STATE);
        logl("setUiccApplicationsEnabled: subId=" + subId + ", enabled=" + enabled);
        logl("setUiccApplicationsEnabled: subId=" + subId + ", enabled=" + enabled
                + ", calling package=" + getCallingPackage());

        final long identity = Binder.clearCallingIdentity();
        try {
            mSubscriptionDatabaseManager.setUiccApplicationsEnabled(subId, enabled);
        } finally {
            Binder.restoreCallingIdentity(identity);
        }
        return 1;
    }

@@ -3638,6 +3650,17 @@ public class SubscriptionManagerService extends ISub.Stub {
        });
    }

    /**
     * Get the calling package(s).
     *
     * @return The calling package(s).
     */
    @NonNull
    private String getCallingPackage() {
        return Arrays.toString(mContext.getPackageManager().getPackagesForUid(
                Binder.getCallingUid()));
    }

    /**
     * Log debug messages.
     *
+1 −1
Original line number Diff line number Diff line
@@ -1041,7 +1041,7 @@ public class SubscriptionManagerServiceTest extends TelephonyTest {
        SubscriptionInfoInternal subInfo = mSubscriptionManagerServiceUT
                .getSubscriptionInfoInternal(1);
        assertThat(subInfo).isNotNull();
        assertThat(subInfo.getDisplayName()).isEqualTo(FAKE_PHONE_NUMBER2);
        assertThat(subInfo.getNumber()).isEqualTo(FAKE_PHONE_NUMBER2);
    }

    @Test