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

Commit d5cfe6cd authored by Polina Bondarenko's avatar Polina Bondarenko
Browse files

Make TelephonyManager#get/setAllowedCarriers system api

Make TelephonyManager#get/setAllowedCarriers system api under
PackageManager#FEATURE_TELEPHONY_CARRIERLOCK feature flag.

Bug: 33480084
Test: cts

Merged-In: I1ce77a9e3801bd4003b52887d0a36866e5a5b81a

Change-Id: I1ce77a9e3801bd4003b52887d0a36866e5a5b81a
parent 1aa24246
Loading
Loading
Loading
Loading
+3 −0
Original line number Diff line number Diff line
@@ -10252,6 +10252,7 @@ package android.content.pm {
    field public static final java.lang.String FEATURE_SIP = "android.software.sip";
    field public static final java.lang.String FEATURE_SIP_VOIP = "android.software.sip.voip";
    field public static final java.lang.String FEATURE_TELEPHONY = "android.hardware.telephony";
    field public static final java.lang.String FEATURE_TELEPHONY_CARRIERLOCK = "android.hardware.telephony.carrierlock";
    field public static final java.lang.String FEATURE_TELEPHONY_CDMA = "android.hardware.telephony.cdma";
    field public static final java.lang.String FEATURE_TELEPHONY_GSM = "android.hardware.telephony.gsm";
    field public static final deprecated java.lang.String FEATURE_TELEVISION = "android.hardware.type.television";
@@ -40751,6 +40752,7 @@ package android.telephony {
    method public void enableVideoCalling(boolean);
    method public boolean endCall();
    method public java.util.List<android.telephony.CellInfo> getAllCellInfo();
    method public java.util.List<android.service.carrier.CarrierIdentifier> getAllowedCarriers(int);
    method public int getCallState();
    method public android.os.PersistableBundle getCarrierConfig();
    method public java.util.List<java.lang.String> getCarrierPackageNamesForIntent(android.content.Intent);
@@ -40824,6 +40826,7 @@ package android.telephony {
    method public void listen(android.telephony.PhoneStateListener, int);
    method public boolean needsOtaServiceProvisioning();
    method public java.lang.String sendEnvelopeWithStatus(java.lang.String);
    method public int setAllowedCarriers(int, java.util.List<android.service.carrier.CarrierIdentifier>);
    method public void setDataEnabled(boolean);
    method public void setDataEnabled(int, boolean);
    method public boolean setLine1NumberForDisplay(java.lang.String, java.lang.String);
+14 −0
Original line number Diff line number Diff line
@@ -1809,6 +1809,20 @@ public abstract class PackageManager {
    @SdkConstant(SdkConstantType.FEATURE)
    public static final String FEATURE_TELEPHONY_GSM = "android.hardware.telephony.gsm";

    /**
     * Feature for {@link #getSystemAvailableFeatures} and {@link #hasSystemFeature}:
     * The device supports telephony carrier restriction mechanism.
     *
     * <p>Devices declaring this feature must have an implementation of the
     * {@link android.telephony.TelephonyManager#getAllowedCarriers} and
     * {@link android.telephony.TelephonyManager#setAllowedCarriers}.
     * @hide
     */
    @SystemApi
    @SdkConstant(SdkConstantType.FEATURE)
    public static final String FEATURE_TELEPHONY_CARRIERLOCK =
            "android.hardware.telephony.carrierlock";

    /**
     * Feature for {@link #getSystemAvailableFeatures} and
     * {@link #hasSystemFeature}: The device supports connecting to USB devices
+18 −0
Original line number Diff line number Diff line
@@ -5682,10 +5682,17 @@ public class TelephonyManager {
     * Set the allowed carrier list for slotId
     * Require system privileges. In the future we may add this to carrier APIs.
     *
     * <p>Requires Permission:
     *   {@link android.Manifest.permission#MODIFY_PHONE_STATE}
     *
     * <p>This method works only on devices with {@link
     * android.content.pm.PackageManager#FEATURE_TELEPHONY_CARRIERLOCK} enabled.
     *
     * @return The number of carriers set successfully. Should be length of
     * carrierList on success; -1 on error.
     * @hide
     */
    @SystemApi
    public int setAllowedCarriers(int slotId, List<CarrierIdentifier> carriers) {
        try {
            ITelephony service = getITelephony();
@@ -5694,6 +5701,8 @@ public class TelephonyManager {
            }
        } catch (RemoteException e) {
            Log.e(TAG, "Error calling ITelephony#setAllowedCarriers", e);
        } catch (NullPointerException e) {
            Log.e(TAG, "Error calling ITelephony#setAllowedCarriers", e);
        }
        return -1;
    }
@@ -5702,10 +5711,17 @@ public class TelephonyManager {
     * Get the allowed carrier list for slotId.
     * Require system privileges. In the future we may add this to carrier APIs.
     *
     * <p>Requires Permission:
     *   {@link android.Manifest.permission#READ_PRIVILEGED_PHONE_STATE}
     *
     * <p>This method returns valid data on devices with {@link
     * android.content.pm.PackageManager#FEATURE_TELEPHONY_CARRIERLOCK} enabled.
     *
     * @return List of {@link android.telephony.CarrierIdentifier}; empty list
     * means all carriers are allowed.
     * @hide
     */
    @SystemApi
    public List<CarrierIdentifier> getAllowedCarriers(int slotId) {
        try {
            ITelephony service = getITelephony();
@@ -5714,6 +5730,8 @@ public class TelephonyManager {
            }
        } catch (RemoteException e) {
            Log.e(TAG, "Error calling ITelephony#getAllowedCarriers", e);
        } catch (NullPointerException e) {
            Log.e(TAG, "Error calling ITelephony#setAllowedCarriers", e);
        }
        return new ArrayList<CarrierIdentifier>(0);
    }