Merge "Add PhoneAccounts on boot completed" into udc-dev

This commit is contained in:
Christine Franks
2023-05-11 21:04:45 +00:00
committed by Android (Google) Code Review
2 changed files with 30 additions and 0 deletions

View File

@@ -306,6 +306,7 @@ public class CompanionDeviceManagerService extends SystemService {
} else if (phase == PHASE_BOOT_COMPLETED) {
// Run the Inactive Association Removal job service daily.
InactiveAssociationsRemovalService.schedule(getContext());
mCrossDeviceSyncController.onBootCompleted();
}
}

View File

@@ -146,6 +146,31 @@ public class CrossDeviceSyncController {
mPhoneAccountManager = new PhoneAccountManager(mContext);
}
/** Invoke set-up tasks that happen when boot is completed. */
public void onBootCompleted() {
if (!CompanionDeviceConfig.isEnabled(CompanionDeviceConfig.ENABLE_CONTEXT_SYNC_TELECOM)) {
return;
}
mPhoneAccountManager.onBootCompleted();
final TelecomManager telecomManager = mContext.getSystemService(TelecomManager.class);
if (telecomManager.getCallCapablePhoneAccounts().size() != 0) {
final PhoneAccountHandle defaultOutgoingTelAccountHandle =
telecomManager.getDefaultOutgoingPhoneAccount(PhoneAccount.SCHEME_TEL);
if (defaultOutgoingTelAccountHandle != null) {
final PhoneAccount defaultOutgoingTelAccount = telecomManager.getPhoneAccount(
defaultOutgoingTelAccountHandle);
if (defaultOutgoingTelAccount != null) {
mCallFacilitators.add(
new CallMetadataSyncData.CallFacilitator(
defaultOutgoingTelAccount.getLabel().toString(),
FACILITATOR_ID_SYSTEM));
}
}
}
}
private void processCallCreateRequests(int associationId,
CallMetadataSyncData callMetadataSyncData) {
final Iterator<CallMetadataSyncData.CallCreateRequest> iterator =
@@ -546,6 +571,10 @@ public class CrossDeviceSyncController {
CallMetadataSyncConnectionService.class);
}
void onBootCompleted() {
mTelecomManager.clearPhoneAccounts();
}
PhoneAccountHandle getPhoneAccountHandle(int associationId, String appIdentifier) {
return mPhoneAccountHandles.get(
new PhoneAccountHandleIdentifier(associationId, appIdentifier));