diff --git a/api/system-current.txt b/api/system-current.txt
index b1fa0bad9102e..2f7dd202732d9 100755
--- a/api/system-current.txt
+++ b/api/system-current.txt
@@ -7181,6 +7181,7 @@ package android.provider {
public static final class Telephony.SimInfo {
field public static final String ACCESS_RULES = "access_rules";
field public static final String ACCESS_RULES_FROM_CARRIER_CONFIGS = "access_rules_from_carrier_configs";
+ field public static final String ALLOWED_NETWORK_TYPES = "allowed_network_types";
field public static final String CARD_ID = "card_id";
field public static final String CARRIER_ID = "carrier_id";
field public static final String CARRIER_NAME = "carrier_name";
@@ -9449,6 +9450,7 @@ package android.telephony {
method @Deprecated @RequiresPermission(android.Manifest.permission.MODIFY_PHONE_STATE) public void enableVideoCalling(boolean);
method @Nullable @RequiresPermission(android.Manifest.permission.READ_PRIVILEGED_PHONE_STATE) public String getAidForAppType(int);
method @Deprecated @RequiresPermission(android.Manifest.permission.READ_PRIVILEGED_PHONE_STATE) public java.util.List
Requires Permission: + * {@link android.Manifest.permission#READ_PRIVILEGED_PHONE_STATE READ_PRIVILEGED_PHONE_STATE} + * or that the calling app has carrier privileges (see {@link #hasCarrierPrivileges}). + * + * @return the allowed network type bitmask + * @hide + */ + @RequiresPermission(android.Manifest.permission.READ_PRIVILEGED_PHONE_STATE) + @SystemApi + public @NetworkTypeBitMask long getAllowedNetworkTypes() { + try { + ITelephony telephony = getITelephony(); + if (telephony != null) { + return telephony.getAllowedNetworkTypes(getSubId()); + } + } catch (RemoteException ex) { + Rlog.e(TAG, "getAllowedNetworkTypes RemoteException", ex); + } + return -1; + } + /** * Sets the network selection mode to automatic. * @@ -7609,7 +7635,9 @@ public class TelephonyManager { * @param networkType the preferred network type * @return true on success; false on any failure. * @hide + * @deprecated Use {@link #setPreferredNetworkTypeBitmask} instead. */ + @Deprecated @UnsupportedAppUsage public boolean setPreferredNetworkType(int subId, @PrefNetworkMode int networkType) { try { @@ -7624,7 +7652,8 @@ public class TelephonyManager { } /** - * Set the preferred network type bitmask. + * Set the preferred network type bitmask but if {@link #setAllowedNetworkTypes} has been set, + * only the allowed network type will set to the modem. * *
If this object has been created with {@link #createForSubscriptionId}, applies to the * given subId. Otherwise, applies to {@link SubscriptionManager#getDefaultSubscriptionId()} @@ -7653,6 +7682,29 @@ public class TelephonyManager { return false; } + /** + * Set the allowed network types of the device. This is for carrier or privileged apps to + * enable/disable certain network types on the device. The user preferred network types should + * be set through {@link #setPreferredNetworkTypeBitmask}. + * + * @param allowedNetworkTypes The bitmask of allowed network types. + * @return true on success; false on any failure. + * @hide + */ + @RequiresPermission(android.Manifest.permission.MODIFY_PHONE_STATE) + @SystemApi + public boolean setAllowedNetworkTypes(@NetworkTypeBitMask long allowedNetworkTypes) { + try { + ITelephony telephony = getITelephony(); + if (telephony != null) { + return telephony.setAllowedNetworkTypes(getSubId(), allowedNetworkTypes); + } + } catch (RemoteException ex) { + Rlog.e(TAG, "setAllowedNetworkTypes RemoteException", ex); + } + return false; + } + /** * Set the preferred network type to global mode which includes LTE, CDMA, EvDo and GSM/WCDMA. * diff --git a/telephony/java/com/android/internal/telephony/ITelephony.aidl b/telephony/java/com/android/internal/telephony/ITelephony.aidl index 625f5252026c3..dfb4ee50f7cc1 100644 --- a/telephony/java/com/android/internal/telephony/ITelephony.aidl +++ b/telephony/java/com/android/internal/telephony/ITelephony.aidl @@ -926,6 +926,23 @@ interface ITelephony { boolean setNetworkSelectionModeManual( int subId, in OperatorInfo operatorInfo, boolean persisSelection); + /** + * Get the allowed network types that store in the telephony provider. + * + * @param subId the id of the subscription. + * @return allowedNetworkTypes the allowed network types. + */ + long getAllowedNetworkTypes(int subId); + + /** + * Set the allowed network types. + * + * @param subId the id of the subscription. + * @param allowedNetworkTypes the allowed network types. + * @return true on success; false on any failure. + */ + boolean setAllowedNetworkTypes(int subId, long allowedNetworkTypes); + /** * Set the preferred network type. * Used for device configuration by some CDMA operators.