Commit f5992d58 authored by Roshan Pius's avatar Roshan Pius
Browse files

Purge invalid SIP phone accounts at startup.

Adding changes to verify all the SIP phone accounts registered with
telecom and delete any invalid SIP accounts detected. SipAccountRegistry
will re-register phoneAccounts corresponding to the SIP profiles
present in the device.
This will also fix the recent change in SIP phone accounts to use
the SIP username as account handle ID instead of SIP URI. So, any
devices upgrading from L or lower releases will have new SIP
accounts automatically recreated with the new account Handle ID.

BUG: 23028921
Change-Id: I560569b4746605b1f0e7698f29178e18abf7019b
parent c4f11557
......@@ -113,9 +113,30 @@ public final class SipAccountRegistry {
}
void setup(Context context) {
verifyAndPurgeInvalidPhoneAccounts(context);
startSipProfilesAsync(context, (String) null, false);
}
/**
* Checks the existing SIP phone {@link PhoneAccount}s registered with telecom and deletes any
* invalid accounts.
*
* @param context The context.
*/
void verifyAndPurgeInvalidPhoneAccounts(Context context) {
TelecomManager telecomManager = TelecomManager.from(context);
SipProfileDb profileDb = new SipProfileDb(context);
List<PhoneAccountHandle> accountHandles = telecomManager.getPhoneAccountsSupportingScheme(
PhoneAccount.SCHEME_SIP);
// TODO: remove orphaned SIP Accounts
for (PhoneAccountHandle accountHandle : accountHandles) {
String profileName = SipUtil.getSipProfileNameFromPhoneAccount(accountHandle);
SipProfile profile = profileDb.retrieveSipProfileFromName(profileName);
if (profile == null) {
log("verifyAndPurgeInvalidPhoneAccounts, deleting account: " + accountHandle);
telecomManager.unregisterPhoneAccount(accountHandle);
}
}
}
/**
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment