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

Commit caf0bfe8 authored by Android Build Coastguard Worker's avatar Android Build Coastguard Worker
Browse files

Merge cherrypicks of [14947012, 14947430, 14947171, 14947470, 14947471,...

Merge cherrypicks of [14947012, 14947430, 14947171, 14947470, 14947471, 14947013, 14947490] into security-aosp-pi-release

Change-Id: If066b134489d5be3c9febd7b95a923dede7202e3
parents f461dcce 377a988e
Loading
Loading
Loading
Loading
+18 −6
Original line number Original line Diff line number Diff line
@@ -41,6 +41,7 @@ import android.telephony.UiccAccessRule;
import android.telephony.euicc.EuiccManager;
import android.telephony.euicc.EuiccManager;
import android.text.TextUtils;
import android.text.TextUtils;
import android.text.format.Time;
import android.text.format.Time;
import android.util.EventLog;
import android.util.Log;
import android.util.Log;


import com.android.internal.annotations.VisibleForTesting;
import com.android.internal.annotations.VisibleForTesting;
@@ -238,6 +239,11 @@ public class SubscriptionController extends ISub.Stub {
                android.Manifest.permission.MODIFY_PHONE_STATE, message);
                android.Manifest.permission.MODIFY_PHONE_STATE, message);
    }
    }


    private void enforceReadPrivilegedPhoneState(String message) {
        mContext.enforceCallingOrSelfPermission(
                Manifest.permission.READ_PRIVILEGED_PHONE_STATE, message);
    }

    /**
    /**
     * Broadcast when SubscriptionInfo has changed
     * Broadcast when SubscriptionInfo has changed
     * FIXME: Hopefully removed if the API council accepts SubscriptionInfoListener
     * FIXME: Hopefully removed if the API council accepts SubscriptionInfoListener
@@ -736,12 +742,18 @@ public class SubscriptionController extends ISub.Stub {


    @Override
    @Override
    public List<SubscriptionInfo> getAvailableSubscriptionInfoList(String callingPackage) {
    public List<SubscriptionInfo> getAvailableSubscriptionInfoList(String callingPackage) {
        // This API isn't public, so no need to provide a valid subscription ID - we're not worried
        try {
        // about carrier-privileged callers not having access.
            enforceReadPrivilegedPhoneState("getAvailableSubscriptionInfoList");
        if (!TelephonyPermissions.checkCallingOrSelfReadPhoneState(
        } catch (SecurityException e) {
                mContext, SubscriptionManager.INVALID_SUBSCRIPTION_ID, callingPackage,
            try {
                "getAvailableSubscriptionInfoList")) {
                mContext.enforceCallingOrSelfPermission(Manifest.permission.READ_PHONE_STATE, null);
            throw new SecurityException("Need READ_PHONE_STATE to call "
                // If caller doesn't have READ_PRIVILEGED_PHONE_STATE permission but only
                // has READ_PHONE_STATE permission, log this event.
                EventLog.writeEvent(0x534e4554, "185235454", Binder.getCallingUid());
            } catch (SecurityException ex) {
                // Ignore
            }
            throw new SecurityException("Need READ_PRIVILEGED_PHONE_STATE to call "
                    + " getAvailableSubscriptionInfoList");
                    + " getAvailableSubscriptionInfoList");
        }
        }