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

Commit af03cf4a authored by Xin Li's avatar Xin Li
Browse files

Merge Android 12 QPR 3

Bug: 236045730
Merged-In: I070e4ef71b381cf1253f50362810c5270f97e9a9
Change-Id: I1b9d120b33b85a55a5c2b122cc92566c1e142404
parents ce6bef58 56fc40f2
Loading
Loading
Loading
Loading
+10 −0
Original line number Diff line number Diff line
@@ -947,6 +947,15 @@ public class InCallController extends CallsManagerListenerBase implements
        }
    };

    private final BroadcastReceiver mUserAddedReceiver = new BroadcastReceiver() {
        @Override
        public void onReceive(Context context, Intent intent) {
            if (Intent.ACTION_USER_ADDED.equals(intent.getAction())) {
                restrictPhoneCallOps();
            }
        }
    };

    private final SystemStateListener mSystemStateListener = new SystemStateListener() {
        @Override
        public void onCarModeChanged(int priority, String packageName, boolean isCarMode) {
@@ -1055,6 +1064,7 @@ public class InCallController extends CallsManagerListenerBase implements
        mSystemStateHelper.addListener(mSystemStateListener);
        mClockProxy = clockProxy;
        restrictPhoneCallOps();
        mContext.registerReceiver(mUserAddedReceiver, new IntentFilter(Intent.ACTION_USER_ADDED));
    }

    private void restrictPhoneCallOps() {
+21 −2
Original line number Diff line number Diff line
@@ -134,6 +134,7 @@ public class PhoneAccountRegistrar {
    public static final String FILE_NAME = "phone-account-registrar-state.xml";
    @VisibleForTesting
    public static final int EXPECTED_STATE_VERSION = 9;
    public static final int MAX_PHONE_ACCOUNT_REGISTRATIONS = 10;

    /** Keep in sync with the same in SipSettings.java */
    private static final String SIP_SHARED_PREFERENCES = "SIP_PREFERENCES";
@@ -766,8 +767,13 @@ public class PhoneAccountRegistrar {
        return account.isSelfManaged();
    }

    // TODO: Should we implement an artificial limit for # of accounts associated with a single
    // ComponentName?
    /**
     * Performs checks before calling addOrReplacePhoneAccount(PhoneAccount)
     *
     * @param account The {@code PhoneAccount} to add or replace.
     * @throws SecurityException if package does not have BIND_TELECOM_CONNECTION_SERVICE permission
     * @throws IllegalArgumentException if MAX_PHONE_ACCOUNT_REGISTRATIONS are reached
     */
    public void registerPhoneAccount(PhoneAccount account) {
        // Enforce the requirement that a connection service for a phone account has the correct
        // permission.
@@ -778,6 +784,19 @@ public class PhoneAccountRegistrar {
            throw new SecurityException("PhoneAccount connection service requires "
                    + "BIND_TELECOM_CONNECTION_SERVICE permission.");
        }
        //Enforce an upper bound on the number of PhoneAccount's a package can register.
        // Most apps should only require 1-2.
        if (getPhoneAccountsForPackage(
                account.getAccountHandle().getComponentName().getPackageName(),
                account.getAccountHandle().getUserHandle()).size()
                >= MAX_PHONE_ACCOUNT_REGISTRATIONS) {
            Log.w(this, "Phone account %s reached max registration limit for package",
                    account.getAccountHandle());
            throw new IllegalArgumentException(
                    "Error, cannot register phone account " + account.getAccountHandle()
                            + " because the limit, " + MAX_PHONE_ACCOUNT_REGISTRATIONS
                            + ", has been reached");
        }

        addOrReplacePhoneAccount(account);
    }