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

Commit 6f752c88 authored by Roshan Pius's avatar Roshan Pius
Browse files

Migrate existing SIP PhoneAccount IDs to username.

We've changed the SIP phone accounts to use the SIP username as
account handle ID in M (ag/685031). So, need to migrate all existing
SIP phone accounts when upgrading from L or lower releases to use the
new account handle ID.
Adding a new version of the phone-account-registrar-state.xml file to
detect the need to migrate and replace the SIP URI's on the accounts
with only the username.

BUG: 23028921
Change-Id: I8cc6f099ec9cafb71c5cf6d040245ddb6a3b00ea
parent 1a373830
Loading
Loading
Loading
Loading
+13 −1
Original line number Diff line number Diff line
@@ -121,7 +121,7 @@ public final class PhoneAccountRegistrar {

    private static final String FILE_NAME = "phone-account-registrar-state.xml";
    @VisibleForTesting
    public static final int EXPECTED_STATE_VERSION = 7;
    public static final int EXPECTED_STATE_VERSION = 8;

    /** Keep in sync with the same in SipSettings.java */
    private static final String SIP_SHARED_PREFERENCES = "SIP_PREFERENCES";
@@ -1259,6 +1259,18 @@ public final class PhoneAccountRegistrar {
                        enabled = true;
                    }
                }
                if (version < 8) {
                    // Migrate the SIP account handle ids to use SIP username instead of SIP URI.
                    if (accountHandle.getComponentName().equals(sipComponentName)) {
                        Uri accountUri = Uri.parse(accountHandle.getId());
                        if (accountUri.getScheme() != null &&
                            accountUri.getScheme().equals(PhoneAccount.SCHEME_SIP)) {
                            accountHandle = new PhoneAccountHandle(accountHandle.getComponentName(),
                                    accountUri.getSchemeSpecificPart(),
                                    accountHandle.getUserHandle());
                        }
                    }
                }

                PhoneAccount.Builder builder = PhoneAccount.builder(accountHandle, label)
                        .setAddress(address)