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

Commit b22697f1 authored by Christine Franks's avatar Christine Franks
Browse files

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
parent 2e423533
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -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();
        }
    }

+29 −0
Original line number Diff line number Diff line
@@ -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));