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

Commit 81b2b453 authored by Nazanin Bakhshi's avatar Nazanin Bakhshi Committed by Android (Google) Code Review
Browse files

Merge "add certs to carrier configs and store them as UiccAccessRules" into qt-qpr1-dev-plus-aosp

parents 347e96dd 600a9fee
Loading
Loading
Loading
Loading
+8 −0
Original line number Original line Diff line number Diff line
@@ -3139,6 +3139,13 @@ public class CarrierConfigManager {
    public static final String KEY_SUPPORT_WPS_OVER_IMS_BOOL =
    public static final String KEY_SUPPORT_WPS_OVER_IMS_BOOL =
            "support_wps_over_ims_bool";
            "support_wps_over_ims_bool";


    /**
     * Holds the list of carrier certificate hashes. Note that each carrier has its own certificates
     * @hide
     */
    public static final String KEY_CARRIER_CERTIFICATE_STRING_ARRAY =
            "carrier_certificate_string_array";

    /** The default value for every variable. */
    /** The default value for every variable. */
    private final static PersistableBundle sDefaults;
    private final static PersistableBundle sDefaults;


@@ -3560,6 +3567,7 @@ public class CarrierConfigManager {
                });
                });
        sDefaults.putBoolean(KEY_SUPPORT_WPS_OVER_IMS_BOOL, true);
        sDefaults.putBoolean(KEY_SUPPORT_WPS_OVER_IMS_BOOL, true);
        sDefaults.putAll(Ims.getDefaults());
        sDefaults.putAll(Ims.getDefaults());
        sDefaults.putStringArray(KEY_CARRIER_CERTIFICATE_STRING_ARRAY, null);
    }
    }


    /**
    /**
+62 −26
Original line number Original line Diff line number Diff line
@@ -38,6 +38,7 @@ import android.text.TextUtils;
import android.util.DisplayMetrics;
import android.util.DisplayMetrics;
import android.util.Log;
import android.util.Log;


import java.util.ArrayList;
import java.util.Arrays;
import java.util.Arrays;
import java.util.Collections;
import java.util.Collections;
import java.util.List;
import java.util.List;
@@ -147,7 +148,14 @@ public class SubscriptionInfo implements Parcelable {
     * The access rules for this subscription, if it is embedded and defines any.
     * The access rules for this subscription, if it is embedded and defines any.
     */
     */
    @Nullable
    @Nullable
    private UiccAccessRule[] mAccessRules;
    private UiccAccessRule[] mNativeAccessRules;

    /**
     * The carrier certificates for this subscription that are saved in carrier configs.
     * The other carrier certificates are embedded on Uicc and stored as part of mNativeAccessRules.
     */
    @Nullable
    private UiccAccessRule[] mCarrierConfigAccessRules;


    /**
    /**
     * The string ID of the SIM card. It is the ICCID of the active profile for a UICC card and the
     * The string ID of the SIM card. It is the ICCID of the active profile for a UICC card and the
@@ -206,12 +214,12 @@ public class SubscriptionInfo implements Parcelable {
    public SubscriptionInfo(int id, String iccId, int simSlotIndex, CharSequence displayName,
    public SubscriptionInfo(int id, String iccId, int simSlotIndex, CharSequence displayName,
            CharSequence carrierName, int nameSource, int iconTint, String number, int roaming,
            CharSequence carrierName, int nameSource, int iconTint, String number, int roaming,
            Bitmap icon, String mcc, String mnc, String countryIso, boolean isEmbedded,
            Bitmap icon, String mcc, String mnc, String countryIso, boolean isEmbedded,
            @Nullable UiccAccessRule[] accessRules, String cardString) {
            @Nullable UiccAccessRule[] nativeAccessRules, String cardString) {
        this(id, iccId, simSlotIndex, displayName, carrierName, nameSource, iconTint, number,
        this(id, iccId, simSlotIndex, displayName, carrierName, nameSource, iconTint, number,
                roaming, icon, mcc, mnc, countryIso, isEmbedded, accessRules, cardString, -1,
                roaming, icon, mcc, mnc, countryIso, isEmbedded, nativeAccessRules, cardString, -1,
                false, null, false, TelephonyManager.UNKNOWN_CARRIER_ID,
                false, null, false, TelephonyManager.UNKNOWN_CARRIER_ID,
                SubscriptionManager.PROFILE_CLASS_DEFAULT,
                SubscriptionManager.PROFILE_CLASS_DEFAULT,
                SubscriptionManager.SUBSCRIPTION_TYPE_LOCAL_SIM, null);
                SubscriptionManager.SUBSCRIPTION_TYPE_LOCAL_SIM, null, null);
    }
    }


    /**
    /**
@@ -220,12 +228,12 @@ public class SubscriptionInfo implements Parcelable {
    public SubscriptionInfo(int id, String iccId, int simSlotIndex, CharSequence displayName,
    public SubscriptionInfo(int id, String iccId, int simSlotIndex, CharSequence displayName,
            CharSequence carrierName, int nameSource, int iconTint, String number, int roaming,
            CharSequence carrierName, int nameSource, int iconTint, String number, int roaming,
            Bitmap icon, String mcc, String mnc, String countryIso, boolean isEmbedded,
            Bitmap icon, String mcc, String mnc, String countryIso, boolean isEmbedded,
            @Nullable UiccAccessRule[] accessRules, String cardString, boolean isOpportunistic,
            @Nullable UiccAccessRule[] nativeAccessRules, String cardString,
            @Nullable String groupUUID, int carrierId, int profileClass) {
            boolean isOpportunistic, @Nullable String groupUUID, int carrierId, int profileClass) {
        this(id, iccId, simSlotIndex, displayName, carrierName, nameSource, iconTint, number,
        this(id, iccId, simSlotIndex, displayName, carrierName, nameSource, iconTint, number,
                roaming, icon, mcc, mnc, countryIso, isEmbedded, accessRules, cardString, -1,
                roaming, icon, mcc, mnc, countryIso, isEmbedded, nativeAccessRules, cardString, -1,
                isOpportunistic, groupUUID, false, carrierId, profileClass,
                isOpportunistic, groupUUID, false, carrierId, profileClass,
                SubscriptionManager.SUBSCRIPTION_TYPE_LOCAL_SIM, null);
                SubscriptionManager.SUBSCRIPTION_TYPE_LOCAL_SIM, null, null);
    }
    }


    /**
    /**
@@ -234,9 +242,10 @@ public class SubscriptionInfo implements Parcelable {
    public SubscriptionInfo(int id, String iccId, int simSlotIndex, CharSequence displayName,
    public SubscriptionInfo(int id, String iccId, int simSlotIndex, CharSequence displayName,
            CharSequence carrierName, int nameSource, int iconTint, String number, int roaming,
            CharSequence carrierName, int nameSource, int iconTint, String number, int roaming,
            Bitmap icon, String mcc, String mnc, String countryIso, boolean isEmbedded,
            Bitmap icon, String mcc, String mnc, String countryIso, boolean isEmbedded,
            @Nullable UiccAccessRule[] accessRules, String cardString, int cardId,
            @Nullable UiccAccessRule[] nativeAccessRules, String cardString, int cardId,
            boolean isOpportunistic, @Nullable String groupUUID, boolean isGroupDisabled,
            boolean isOpportunistic, @Nullable String groupUUID, boolean isGroupDisabled,
            int carrierId, int profileClass, int subType, @Nullable String groupOwner) {
            int carrierId, int profileClass, int subType, @Nullable String groupOwner,
            @Nullable UiccAccessRule[] carrierConfigAccessRules) {
        this.mId = id;
        this.mId = id;
        this.mIccId = iccId;
        this.mIccId = iccId;
        this.mSimSlotIndex = simSlotIndex;
        this.mSimSlotIndex = simSlotIndex;
@@ -251,7 +260,7 @@ public class SubscriptionInfo implements Parcelable {
        this.mMnc = mnc;
        this.mMnc = mnc;
        this.mCountryIso = countryIso;
        this.mCountryIso = countryIso;
        this.mIsEmbedded = isEmbedded;
        this.mIsEmbedded = isEmbedded;
        this.mAccessRules = accessRules;
        this.mNativeAccessRules = nativeAccessRules;
        this.mCardString = cardString;
        this.mCardString = cardString;
        this.mCardId = cardId;
        this.mCardId = cardId;
        this.mIsOpportunistic = isOpportunistic;
        this.mIsOpportunistic = isOpportunistic;
@@ -261,6 +270,7 @@ public class SubscriptionInfo implements Parcelable {
        this.mProfileClass = profileClass;
        this.mProfileClass = profileClass;
        this.mSubscriptionType = subType;
        this.mSubscriptionType = subType;
        this.mGroupOwner = groupOwner;
        this.mGroupOwner = groupOwner;
        this.mCarrierConfigAccessRules = carrierConfigAccessRules;
    }
    }


    /**
    /**
@@ -566,7 +576,8 @@ public class SubscriptionInfo implements Parcelable {
        if (!isEmbedded()) {
        if (!isEmbedded()) {
            throw new UnsupportedOperationException("Not an embedded subscription");
            throw new UnsupportedOperationException("Not an embedded subscription");
        }
        }
        if (mAccessRules == null) {
        List<UiccAccessRule> allAccessRules = getAllAccessRules();
        if (allAccessRules == null) {
            return false;
            return false;
        }
        }
        PackageManager packageManager = context.getPackageManager();
        PackageManager packageManager = context.getPackageManager();
@@ -576,7 +587,7 @@ public class SubscriptionInfo implements Parcelable {
        } catch (PackageManager.NameNotFoundException e) {
        } catch (PackageManager.NameNotFoundException e) {
            throw new IllegalArgumentException("Unknown package: " + packageName, e);
            throw new IllegalArgumentException("Unknown package: " + packageName, e);
        }
        }
        for (UiccAccessRule rule : mAccessRules) {
        for (UiccAccessRule rule : allAccessRules) {
            if (rule.getCarrierPrivilegeStatus(packageInfo)
            if (rule.getCarrierPrivilegeStatus(packageInfo)
                    == TelephonyManager.CARRIER_PRIVILEGE_STATUS_HAS_ACCESS) {
                    == TelephonyManager.CARRIER_PRIVILEGE_STATUS_HAS_ACCESS) {
                return true;
                return true;
@@ -586,7 +597,10 @@ public class SubscriptionInfo implements Parcelable {
    }
    }


    /**
    /**
     * @return the {@link UiccAccessRule}s dictating who is authorized to manage this subscription.
     * @return the {@link UiccAccessRule}s that are stored in Uicc, dictating who
     * is authorized to manage this subscription.
     * TODO and fix it properly in R / master: either deprecate this and have 3 APIs
     *  native + carrier + all, or have this return all by default.
     * @throws UnsupportedOperationException if this subscription is not embedded.
     * @throws UnsupportedOperationException if this subscription is not embedded.
     * @hide
     * @hide
     */
     */
@@ -595,8 +609,25 @@ public class SubscriptionInfo implements Parcelable {
        if (!isEmbedded()) {
        if (!isEmbedded()) {
            throw new UnsupportedOperationException("Not an embedded subscription");
            throw new UnsupportedOperationException("Not an embedded subscription");
        }
        }
        if (mAccessRules == null) return null;
        if (mNativeAccessRules == null) return null;
        return Arrays.asList(mAccessRules);
        return Arrays.asList(mNativeAccessRules);
    }

    /**
     * @return the {@link UiccAccessRule}s that are both stored on Uicc and in carrierConfigs
     * dictating who is authorized to manage this subscription.
     * @hide
     */
    public @Nullable List<UiccAccessRule> getAllAccessRules() {
        if (!isEmbedded()) {
            throw new UnsupportedOperationException("Not an embedded subscription");
        }
        List<UiccAccessRule> merged = new ArrayList<>();
        if (mNativeAccessRules != null) merged.addAll(getAccessRules());
        if (mCarrierConfigAccessRules != null) {
            merged.addAll(Arrays.asList(mCarrierConfigAccessRules));
        }
        return merged.isEmpty() ? null : merged;
    }
    }


    /**
    /**
@@ -651,7 +682,7 @@ public class SubscriptionInfo implements Parcelable {
            String countryIso = source.readString();
            String countryIso = source.readString();
            Bitmap iconBitmap = source.readParcelable(Bitmap.class.getClassLoader());
            Bitmap iconBitmap = source.readParcelable(Bitmap.class.getClassLoader());
            boolean isEmbedded = source.readBoolean();
            boolean isEmbedded = source.readBoolean();
            UiccAccessRule[] accessRules = source.createTypedArray(UiccAccessRule.CREATOR);
            UiccAccessRule[] nativeAccessRules = source.createTypedArray(UiccAccessRule.CREATOR);
            String cardString = source.readString();
            String cardString = source.readString();
            int cardId = source.readInt();
            int cardId = source.readInt();
            boolean isOpportunistic = source.readBoolean();
            boolean isOpportunistic = source.readBoolean();
@@ -663,11 +694,14 @@ public class SubscriptionInfo implements Parcelable {
            String[] ehplmns = source.readStringArray();
            String[] ehplmns = source.readStringArray();
            String[] hplmns = source.readStringArray();
            String[] hplmns = source.readStringArray();
            String groupOwner = source.readString();
            String groupOwner = source.readString();
            UiccAccessRule[] carrierConfigAccessRules = source.createTypedArray(
                UiccAccessRule.CREATOR);


            SubscriptionInfo info = new SubscriptionInfo(id, iccId, simSlotIndex, displayName,
            SubscriptionInfo info = new SubscriptionInfo(id, iccId, simSlotIndex, displayName,
                    carrierName, nameSource, iconTint, number, dataRoaming, iconBitmap, mcc, mnc,
                    carrierName, nameSource, iconTint, number, dataRoaming, iconBitmap, mcc, mnc,
                    countryIso, isEmbedded, accessRules, cardString, cardId, isOpportunistic,
                    countryIso, isEmbedded, nativeAccessRules, cardString, cardId, isOpportunistic,
                    groupUUID, isGroupDisabled, carrierid, profileClass, subType, groupOwner);
                    groupUUID, isGroupDisabled, carrierid, profileClass, subType, groupOwner,
                    carrierConfigAccessRules);
            info.setAssociatedPlmns(ehplmns, hplmns);
            info.setAssociatedPlmns(ehplmns, hplmns);
            return info;
            return info;
        }
        }
@@ -694,7 +728,7 @@ public class SubscriptionInfo implements Parcelable {
        dest.writeString(mCountryIso);
        dest.writeString(mCountryIso);
        dest.writeParcelable(mIconBitmap, flags);
        dest.writeParcelable(mIconBitmap, flags);
        dest.writeBoolean(mIsEmbedded);
        dest.writeBoolean(mIsEmbedded);
        dest.writeTypedArray(mAccessRules, flags);
        dest.writeTypedArray(mNativeAccessRules, flags);
        dest.writeString(mCardString);
        dest.writeString(mCardString);
        dest.writeInt(mCardId);
        dest.writeInt(mCardId);
        dest.writeBoolean(mIsOpportunistic);
        dest.writeBoolean(mIsOpportunistic);
@@ -706,6 +740,7 @@ public class SubscriptionInfo implements Parcelable {
        dest.writeStringArray(mEhplmns);
        dest.writeStringArray(mEhplmns);
        dest.writeStringArray(mHplmns);
        dest.writeStringArray(mHplmns);
        dest.writeString(mGroupOwner);
        dest.writeString(mGroupOwner);
        dest.writeTypedArray(mCarrierConfigAccessRules, flags);
    }
    }


    @Override
    @Override
@@ -736,9 +771,9 @@ public class SubscriptionInfo implements Parcelable {
                + " carrierId=" + mCarrierId + " displayName=" + mDisplayName
                + " carrierId=" + mCarrierId + " displayName=" + mDisplayName
                + " carrierName=" + mCarrierName + " nameSource=" + mNameSource
                + " carrierName=" + mCarrierName + " nameSource=" + mNameSource
                + " iconTint=" + mIconTint + " mNumber=" + Rlog.pii(Build.IS_DEBUGGABLE, mNumber)
                + " iconTint=" + mIconTint + " mNumber=" + Rlog.pii(Build.IS_DEBUGGABLE, mNumber)
                + " dataRoaming=" + mDataRoaming + " iconBitmap=" + mIconBitmap + " mcc=" + mMcc
                + " dataRoaming=" + mDataRoaming + " iconBitmap=" + mIconBitmap + " mcc " + mMcc
                + " mnc=" + mMnc + " mCountryIso=" + mCountryIso + " isEmbedded=" + mIsEmbedded
                + " mnc " + mMnc + "mCountryIso=" + mCountryIso + " isEmbedded " + mIsEmbedded
                + " accessRules=" + Arrays.toString(mAccessRules)
                + " nativeAccessRules " + Arrays.toString(mNativeAccessRules)
                + " cardString=" + cardStringToPrint + " cardId=" + mCardId
                + " cardString=" + cardStringToPrint + " cardId=" + mCardId
                + " isOpportunistic=" + mIsOpportunistic + " mGroupUUID=" + mGroupUUID
                + " isOpportunistic=" + mIsOpportunistic + " mGroupUUID=" + mGroupUUID
                + " mIsGroupDisabled=" + mIsGroupDisabled
                + " mIsGroupDisabled=" + mIsGroupDisabled
@@ -746,14 +781,15 @@ public class SubscriptionInfo implements Parcelable {
                + " ehplmns=" + Arrays.toString(mEhplmns)
                + " ehplmns=" + Arrays.toString(mEhplmns)
                + " hplmns=" + Arrays.toString(mHplmns)
                + " hplmns=" + Arrays.toString(mHplmns)
                + " subscriptionType=" + mSubscriptionType
                + " subscriptionType=" + mSubscriptionType
                + " mGroupOwner=" + mGroupOwner + "}";
                + " mGroupOwner=" + mGroupOwner
                + " carrierConfigAccessRules=" + mCarrierConfigAccessRules + "}";
    }
    }


    @Override
    @Override
    public int hashCode() {
    public int hashCode() {
        return Objects.hash(mId, mSimSlotIndex, mNameSource, mIconTint, mDataRoaming, mIsEmbedded,
        return Objects.hash(mId, mSimSlotIndex, mNameSource, mIconTint, mDataRoaming, mIsEmbedded,
                mIsOpportunistic, mGroupUUID, mIccId, mNumber, mMcc, mMnc,
                mIsOpportunistic, mGroupUUID, mIccId, mNumber, mMcc, mMnc,
                mCountryIso, mCardString, mCardId, mDisplayName, mCarrierName, mAccessRules,
                mCountryIso, mCardString, mCardId, mDisplayName, mCarrierName, mNativeAccessRules,
                mIsGroupDisabled, mCarrierId, mProfileClass, mGroupOwner);
                mIsGroupDisabled, mCarrierId, mProfileClass, mGroupOwner);
    }
    }


@@ -789,7 +825,7 @@ public class SubscriptionInfo implements Parcelable {
                && Objects.equals(mGroupOwner, toCompare.mGroupOwner)
                && Objects.equals(mGroupOwner, toCompare.mGroupOwner)
                && TextUtils.equals(mDisplayName, toCompare.mDisplayName)
                && TextUtils.equals(mDisplayName, toCompare.mDisplayName)
                && TextUtils.equals(mCarrierName, toCompare.mCarrierName)
                && TextUtils.equals(mCarrierName, toCompare.mCarrierName)
                && Arrays.equals(mAccessRules, toCompare.mAccessRules)
                && Arrays.equals(mNativeAccessRules, toCompare.mNativeAccessRules)
                && mProfileClass == toCompare.mProfileClass
                && mProfileClass == toCompare.mProfileClass
                && Arrays.equals(mEhplmns, toCompare.mEhplmns)
                && Arrays.equals(mEhplmns, toCompare.mEhplmns)
                && Arrays.equals(mHplmns, toCompare.mHplmns);
                && Arrays.equals(mHplmns, toCompare.mHplmns);
+12 −2
Original line number Original line Diff line number Diff line
@@ -570,6 +570,16 @@ public class SubscriptionManager {
     */
     */
    public static final String ACCESS_RULES = "access_rules";
    public static final String ACCESS_RULES = "access_rules";


    /**
     * TelephonyProvider column name for the encoded {@link UiccAccessRule}s from
     * {@link UiccAccessRule#encodeRules} but for the rules that come from CarrierConfigs.
     * Only present if there are access rules in CarrierConfigs
     * <p>TYPE: BLOB
     * @hide
     */
    public static final String ACCESS_RULES_FROM_CARRIER_CONFIGS =
            "access_rules_from_carrier_configs";

    /**
    /**
     * TelephonyProvider column name identifying whether an embedded subscription is on a removable
     * TelephonyProvider column name identifying whether an embedded subscription is on a removable
     * card. Such subscriptions are marked inaccessible as soon as the current card is removed.
     * card. Such subscriptions are marked inaccessible as soon as the current card is removed.
@@ -2601,7 +2611,7 @@ public class SubscriptionManager {
        if (!info.isEmbedded()) {
        if (!info.isEmbedded()) {
            throw new IllegalArgumentException("Not an embedded subscription");
            throw new IllegalArgumentException("Not an embedded subscription");
        }
        }
        if (info.getAccessRules() == null) {
        if (info.getAllAccessRules() == null) {
            return false;
            return false;
        }
        }
        PackageManager packageManager = mContext.getPackageManager();
        PackageManager packageManager = mContext.getPackageManager();
@@ -2611,7 +2621,7 @@ public class SubscriptionManager {
        } catch (PackageManager.NameNotFoundException e) {
        } catch (PackageManager.NameNotFoundException e) {
            throw new IllegalArgumentException("Unknown package: " + packageName, e);
            throw new IllegalArgumentException("Unknown package: " + packageName, e);
        }
        }
        for (UiccAccessRule rule : info.getAccessRules()) {
        for (UiccAccessRule rule : info.getAllAccessRules()) {
            if (rule.getCarrierPrivilegeStatus(packageInfo)
            if (rule.getCarrierPrivilegeStatus(packageInfo)
                    == TelephonyManager.CARRIER_PRIVILEGE_STATUS_HAS_ACCESS) {
                    == TelephonyManager.CARRIER_PRIVILEGE_STATUS_HAS_ACCESS) {
                return true;
                return true;