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

Commit 4e9606bd authored by Hall Liu's avatar Hall Liu Committed by Automerger Merge Worker
Browse files

Convert PhoneAccount sort order to integers am: 948be1a7 am: 51c83300 am: 3edf3b19

Original change: https://android-review.googlesource.com/c/platform/packages/services/Telecomm/+/1471169

Change-Id: Ife85084aea2379d88c776430320bb15c1c1e9b4c
parents 8481905a 3edf3b19
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(