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

Commit 6f2c1ebb authored by mike dooley's avatar mike dooley Committed by Android (Google) Code Review
Browse files

Merge "Checking that the connection service can be resolved when setting new...

Merge "Checking that the connection service can be resolved when setting new connection manager." into lmp-mr1-dev
parents 9644c426 10a5831c
Loading
Loading
Loading
Loading
+1 −2
Original line number Diff line number Diff line
@@ -228,8 +228,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;
    }