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

Commit 0ae51392 authored by Rambo Wang's avatar Rambo Wang Committed by Android (Google) Code Review
Browse files

Merge changes from topic "Blueberry-getUiccCardsInfo" into main

* changes:
  Introduce utility methods to redact sensitive info in UiccCard/PortInfo
  Allow caller with READ_BASIC_PHONE_STATE to retrieve basic UiccCardInfo
parents a20c1765 0b09de78
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -47800,7 +47800,7 @@ package android.telephony {
    method @RequiresPermission("android.permission.READ_PRIVILEGED_PHONE_STATE") public long getSupportedRadioAccessFamily();
    method @Nullable public String getTypeAllocationCode();
    method @Nullable public String getTypeAllocationCode(int);
    method @NonNull @RequiresPermission("android.permission.READ_PRIVILEGED_PHONE_STATE") public java.util.List<android.telephony.UiccCardInfo> getUiccCardsInfo();
    method @FlaggedApi("com.android.internal.telephony.flags.macro_based_opportunistic_networks") @NonNull @RequiresPermission(anyOf={android.Manifest.permission.READ_BASIC_PHONE_STATE, "android.permission.READ_PRIVILEGED_PHONE_STATE", "carrier privileges"}) public java.util.List<android.telephony.UiccCardInfo> getUiccCardsInfo();
    method @Nullable @RequiresPermission(android.Manifest.permission.READ_PHONE_STATE) public String getVisualVoicemailPackageName();
    method @RequiresPermission(android.Manifest.permission.READ_PHONE_STATE) public String getVoiceMailAlphaTag();
    method @RequiresPermission(android.Manifest.permission.READ_PHONE_STATE) public String getVoiceMailNumber();
+36 −18
Original line number Diff line number Diff line
@@ -4428,29 +4428,47 @@ public class TelephonyManager {
    }
    /**
     * Gets information about currently inserted UICCs and eUICCs.
     * Gets information about currently inserted UICCs (Universal Integrated Circuit Cards)
     * and eUICCs (embedded UICCs).
     * <p>
     * Requires that the calling app has carrier privileges (see {@link #hasCarrierPrivileges}).
     * <p>
     * If the caller has carrier priviliges on any active subscription, then they have permission to
     * get simple information like the card ID ({@link UiccCardInfo#getCardId()}), whether the card
     * is an eUICC ({@link UiccCardInfo#isEuicc()}), and the physical slot index where the card is
     * inserted ({@link UiccCardInfo#getPhysicalSlotIndex()}.
     * <p>
     * To get private information such as the EID ({@link UiccCardInfo#getEid()}) or ICCID
     * ({@link UiccCardInfo#getIccId()}), the caller must have carrier priviliges on that specific
     * UICC or eUICC card.
     * The details returned for each {@link android.telephony.UiccCardInfo UiccCardInfo} object
     * depend on the permissions held by the calling application.
     * The specific fields populated within each {@code UiccCardInfo} are determined as follows:
     * <ul>
     * <li>With {@link android.Manifest.permission#READ_BASIC_PHONE_STATE READ_BASIC_PHONE_STATE}:
     * The {@code UiccCardInfo} will include whether the card is an eUICC
     * ({@link android.telephony.UiccCardInfo#isEuicc()}) and its
     * {@link android.telephony.UiccCardInfo#getPhysicalSlotIndex() physical slot index}.</li>
     * <li>With carrier privileges on any active subscription (see
     * {@link TelephonyManager#hasCarrierPrivileges()}):
     * The {@code UiccCardInfo} will include the card ID
     * ({@link android.telephony.UiccCardInfo#getCardId()}), whether it's an
     * eUICC ({@link android.telephony.UiccCardInfo#isEuicc()}), and its
     * {@link android.telephony.UiccCardInfo#getPhysicalSlotIndex() physical slot index}.</li>
     * <li>With carrier privileges on the specific UICC or eUICC card:
     * Sensitive identifiers like the EID ({@link android.telephony.UiccCardInfo#getEid()}) and
     * ICCID ({@link android.telephony.UiccCardInfo#getIccId()}) for that particular card
     * can be accessed.</li>
     * </ul>
     * If an application lacks the necessary permissions for certain details of a card (e.g.,the EID
     * due to missing specific carrier privileges for that card), those fields will not be populated
     * in the {@code UiccCardInfo} object for that card.
     * <p>
     * See {@link UiccCardInfo} for more details on the kind of information available.
     * See {@link android.telephony.UiccCardInfo} for a comprehensive description of all possible
     * card attributes and their individual data protection considerations.
     *
     * @return a list of UiccCardInfo objects, representing information on the currently inserted
     * UICCs and eUICCs. Each UiccCardInfo in the list will have private information filtered out if
     * the caller does not have adequate permissions for that card.
     * @return A list of {@code UiccCardInfo} objects, representing the currently inserted
     * UICCs and eUICCs. Each object contains information filtered according to the
     * caller's permissions for that specific card. Returns an empty list if no
     * cards are present or accessible.
     *
     * @throws UnsupportedOperationException If the device does not have
     *          {@link PackageManager#FEATURE_TELEPHONY_SUBSCRIPTION}.
     * @throws UnsupportedOperationException If the device does not declare the
     * {@link PackageManager#FEATURE_TELEPHONY_SUBSCRIPTION} feature.
     */
    @RequiresPermission(android.Manifest.permission.READ_PRIVILEGED_PHONE_STATE)
    @FlaggedApi(Flags.FLAG_MACRO_BASED_OPPORTUNISTIC_NETWORKS)
    @RequiresPermission(anyOf = {android.Manifest.permission.READ_BASIC_PHONE_STATE,
            android.Manifest.permission.READ_PRIVILEGED_PHONE_STATE,
            "carrier privileges"})
    @RequiresFeature(PackageManager.FEATURE_TELEPHONY_SUBSCRIPTION)
    @NonNull
    public List<UiccCardInfo> getUiccCardsInfo() {
+32 −0
Original line number Diff line number Diff line
@@ -231,6 +231,38 @@ public final class UiccCardInfo implements Parcelable {
        this.mIccIdAccessRestricted = iccIdAccessRestricted;
    }

    /**
     * Return a copy of the current UiccCardInfo but with sensitive info redacted.
     *
     * @hide
     */
    public UiccCardInfo createSensitiveInfoSanitizedCopy(boolean hasCarrierPrivileges) {
        if (hasCarrierPrivileges) {
            List<UiccPortInfo> portInfos = new  ArrayList<>();
            for (UiccPortInfo portInfo : this.getPorts()) {
                portInfos.add(portInfo.createSensitiveInfoSanitizedCopy());
            }
            return new UiccCardInfo(
                    this.isEuicc(),
                    this.getCardId(),
                    null,
                    this.getPhysicalSlotIndex(),
                    this.isRemovable(),
                    this.isMultipleEnabledProfilesSupported(),
                    portInfos);
        } else {
            // Without carrier privileges, treat it as READ_BASIC_PHONE_STATE, copy minimum info
            return new UiccCardInfo(
                    this.isEuicc(),
                    TelephonyManager.UNINITIALIZED_CARD_ID,
                    null,
                    this.getPhysicalSlotIndex(),
                    this.isRemovable(),
                    this.isMultipleEnabledProfilesSupported(),
                    List.of());
        }
    }

    @Override
    public boolean equals(Object obj) {
        if (this == obj) {
+13 −0
Original line number Diff line number Diff line
@@ -138,6 +138,19 @@ public final class UiccPortInfo implements Parcelable{
        return mLogicalSlotIndex;
    }

    /**
     * Return a copy of the current UiccPortInfo but with sensitive info (ICCID) redacted.
     *
     * @hide
     */
    public UiccPortInfo createSensitiveInfoSanitizedCopy() {
        return new UiccPortInfo(
                UiccPortInfo.ICCID_REDACTED,
                this.getPortIndex(),
                this.getLogicalSlotIndex(),
                this.isActive());
    }

    @Override
    public boolean equals(@Nullable Object obj) {
        if (this == obj) {