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

Commit 948be1a7 authored by Hall Liu's avatar Hall Liu
Browse files

Convert PhoneAccount sort order to integers

Since it's only used to carry slot IDs, use integers instead of strings
for better clarity.

Bug: 169153499
Test: atest TelecomUnitTests:PhoneAccountRegistrarTest
Change-Id: I55f87cd9d29c8fbbd4986cc9b04d7f025df4fa33
Merged-In: I55f87cd9d29c8fbbd4986cc9b04d7f025df4fa33
parent fc4647b8
Loading
Loading
Loading
Loading
+5 −5
Original line number Diff line number Diff line
@@ -1266,11 +1266,11 @@ public class PhoneAccountRegistrar {
            // Comparator which places PhoneAccounts with a specified sort order first, followed by
            // those with no sort order.
            Comparator<PhoneAccount> bySortOrder = (p1, p2) -> {
                String sort1 = p1.getExtras() == null ? null :
                        p1.getExtras().getString(PhoneAccount.EXTRA_SORT_ORDER, null);
                String sort2 = p2.getExtras() == null ? null :
                        p2.getExtras().getString(PhoneAccount.EXTRA_SORT_ORDER, null);
                return nullSafeStringComparator.compare(sort1, sort2);
                int sort1 = p1.getExtras() == null ? Integer.MAX_VALUE:
                        p1.getExtras().getInt(PhoneAccount.EXTRA_SORT_ORDER, Integer.MAX_VALUE);
                int sort2 = p2.getExtras() == null ? Integer.MAX_VALUE:
                        p2.getExtras().getInt(PhoneAccount.EXTRA_SORT_ORDER, Integer.MAX_VALUE);
                return Integer.compare(sort1, sort2);
            };

            // Comparator which sorts PhoneAccounts by label.
+13 −4
Original line number Diff line number Diff line
@@ -725,16 +725,20 @@ public class PhoneAccountRegistrarTest extends TelecomTestCase {
        mComponentContextFixture.addConnectionService(componentC,
                Mockito.mock(IConnectionService.class));

        Bundle account1Extras = new Bundle();
        account1Extras.putInt(PhoneAccount.EXTRA_SORT_ORDER, 1);
        PhoneAccount account1 = new PhoneAccount.Builder(
                makeQuickAccountHandle(componentA, "c"), "c")
                .setCapabilities(PhoneAccount.CAPABILITY_CALL_PROVIDER)
                .setExtras(Bundle.forPair(PhoneAccount.EXTRA_SORT_ORDER, "A"))
                .setExtras(account1Extras)
                .build();

        Bundle account2Extras = new Bundle();
        account2Extras.putInt(PhoneAccount.EXTRA_SORT_ORDER, 2);
        PhoneAccount account2 = new PhoneAccount.Builder(
                makeQuickAccountHandle(componentB, "b"), "b")
                .setCapabilities(PhoneAccount.CAPABILITY_CALL_PROVIDER)
                .setExtras(Bundle.forPair(PhoneAccount.EXTRA_SORT_ORDER, "B"))
                .setExtras(account2Extras)
                .build();

        PhoneAccount account3 = new PhoneAccount.Builder(
@@ -814,18 +818,23 @@ public class PhoneAccountRegistrarTest extends TelecomTestCase {
                Mockito.mock(IConnectionService.class));
        mComponentContextFixture.addConnectionService(componentZ,
                Mockito.mock(IConnectionService.class));

        Bundle account1Extras = new Bundle();
        account1Extras.putInt(PhoneAccount.EXTRA_SORT_ORDER, 2);
        PhoneAccount account1 = new PhoneAccount.Builder(makeQuickAccountHandle(
                makeQuickConnectionServiceComponentName(), "y"), "y")
                .setCapabilities(PhoneAccount.CAPABILITY_CALL_PROVIDER |
                        PhoneAccount.CAPABILITY_SIM_SUBSCRIPTION)
                .setExtras(Bundle.forPair(PhoneAccount.EXTRA_SORT_ORDER, "2"))
                .setExtras(account1Extras)
                .build();

        Bundle account2Extras = new Bundle();
        account2Extras.putInt(PhoneAccount.EXTRA_SORT_ORDER, 1);
        PhoneAccount account2 = new PhoneAccount.Builder(makeQuickAccountHandle(
                makeQuickConnectionServiceComponentName(), "z"), "z")
                .setCapabilities(PhoneAccount.CAPABILITY_CALL_PROVIDER |
                        PhoneAccount.CAPABILITY_SIM_SUBSCRIPTION)
                .setExtras(Bundle.forPair(PhoneAccount.EXTRA_SORT_ORDER, "1"))
                .setExtras(account2Extras)
                .build();

        PhoneAccount account3 = new PhoneAccount.Builder(makeQuickAccountHandle(