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
diff --git a/src/com/android/server/telecom/PhoneAccountRegistrar.java b/src/com/android/server/telecom/PhoneAccountRegistrar.java
index d500eda..a18fcc0 100644
--- a/src/com/android/server/telecom/PhoneAccountRegistrar.java
+++ b/src/com/android/server/telecom/PhoneAccountRegistrar.java
@@ -121,7 +121,7 @@
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 @@
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)