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

Commit 10a5831c authored by mike dooley's avatar mike dooley
Browse files

Checking that the connection service can be resolved when setting

new connection manager.

This is to fix an edge case where downgrading could cause an invalid
connection manager to be set, resulting in all calls failing.

Also filtering out unresolveable phone accounts (which prevents the UI
from showing invalid choices).

Bug: 18225329
Change-Id: If46dea2937af42b81d3d7062c385f98370015cbe
parent 64883a94
Loading
Loading
Loading
Loading
+1 −2
Original line number Diff line number Diff line
@@ -223,8 +223,7 @@ final class CreateConnectionProcessor {
            CallAttemptRecord record = new CallAttemptRecord(
                    mPhoneAccountRegistrar.getSimCallManager(),
                    mAttemptRecords.get(0).targetPhoneAccount);
            Log.v(this, "setConnectionManager, changing %s -> %s",
                    mAttemptRecords.get(0).targetPhoneAccount, record);
            Log.v(this, "setConnectionManager, changing %s -> %s", mAttemptRecords.get(0), record);
            mAttemptRecords.set(0, record);
        } else {
            Log.v(this, "setConnectionManager, not changing");
+14 −8
Original line number Diff line number Diff line
@@ -250,7 +250,8 @@ public final class PhoneAccountRegistrar {
            // Return the registered sim call manager iff it still exists (we keep a sticky
            // setting to survive account deletion and re-addition)
            for (int i = 0; i < mState.accounts.size(); i++) {
                if (mState.accounts.get(i).getAccountHandle().equals(mState.simCallManager)) {
                if (mState.accounts.get(i).getAccountHandle().equals(mState.simCallManager)
                        && !resolveComponent(mState.simCallManager.getComponentName()).isEmpty()) {
                    return mState.simCallManager;
                }
            }
@@ -260,14 +261,9 @@ public final class PhoneAccountRegistrar {
        String defaultConnectionMgr =
                mContext.getResources().getString(R.string.default_connection_manager_component);
        if (!TextUtils.isEmpty(defaultConnectionMgr)) {
            PackageManager pm = mContext.getPackageManager();

            ComponentName componentName = ComponentName.unflattenFromString(defaultConnectionMgr);
            Intent intent = new Intent(ConnectionService.SERVICE_INTERFACE);
            intent.setComponent(componentName);

            // Make sure that the component can be resolved.
            List<ResolveInfo> resolveInfos = pm.queryIntentServices(intent, 0);
            List<ResolveInfo> resolveInfos = resolveComponent(componentName);
            if (!resolveInfos.isEmpty()) {
                // See if there is registered PhoneAccount by this component.
                List<PhoneAccountHandle> handles = getAllPhoneAccountHandles();
@@ -287,6 +283,13 @@ public final class PhoneAccountRegistrar {
        return null;
    }

    private List<ResolveInfo> resolveComponent(ComponentName componentName) {
        PackageManager pm = mContext.getPackageManager();
        Intent intent = new Intent(ConnectionService.SERVICE_INTERFACE);
        intent.setComponent(componentName);
        return pm.queryIntentServices(intent, 0);
    }

    /**
     * Retrieves a list of all {@link PhoneAccountHandle}s registered.
     *
@@ -520,9 +523,12 @@ public final class PhoneAccountRegistrar {
        List<PhoneAccountHandle> accountHandles = new ArrayList<>();
        for (PhoneAccount m : mState.accounts) {
            if (m.hasCapabilities(flags) && (uriScheme == null || m.supportsUriScheme(uriScheme))) {
                // Also filter out unresolveable accounts
                if (!resolveComponent(m.getAccountHandle().getComponentName()).isEmpty()) {
                    accountHandles.add(m.getAccountHandle());
                }
            }
        }
        return accountHandles;
    }