Add PhoneAccounts on boot completed
The accounts aren't ready earlier Bug: 265466098 Test: atest FrameworksServicesTests:com.android.server.companion.datatransfer.contextsync Change-Id: I9049c9af05b3f7d585c79b6a8a09b5e6c24f028f
This commit is contained in:
@@ -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();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -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));
|
||||
|
||||
Reference in New Issue
Block a user