diff options
| author | 2020-01-20 08:00:05 +0000 | |
|---|---|---|
| committer | 2020-01-20 08:00:05 +0000 | |
| commit | 2ffecdb9fd4583ede5c36bc8f49f9559f012856f (patch) | |
| tree | 3a0e50f9ba21362e7b63ab15d559cebcdb2dc6d1 | |
| parent | 79150a0ad160d1844363e258d5af32fbf07698f7 (diff) | |
| parent | d11c1218d59c33750fadb8d3025fe3197306460e (diff) | |
Merge "Redesign the setPreferredNetworkType"
| -rwxr-xr-x | api/system-current.txt | 3 | ||||
| -rw-r--r-- | core/java/android/provider/Telephony.java | 6 | ||||
| -rw-r--r-- | telephony/java/android/telephony/SubscriptionManager.java | 29 | ||||
| -rw-r--r-- | telephony/java/android/telephony/TelephonyManager.java | 54 | ||||
| -rw-r--r-- | telephony/java/com/android/internal/telephony/ITelephony.aidl | 17 | 
5 files changed, 107 insertions, 2 deletions
diff --git a/api/system-current.txt b/api/system-current.txt index 1549f9ef2721..69319193b535 100755 --- a/api/system-current.txt +++ b/api/system-current.txt @@ -8408,6 +8408,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"; @@ -10749,6 +10750,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<android.service.carrier.CarrierIdentifier> getAllowedCarriers(int); +    method @RequiresPermission(android.Manifest.permission.READ_PRIVILEGED_PHONE_STATE) public long getAllowedNetworkTypes();      method @Nullable @RequiresPermission(android.Manifest.permission.READ_PRIVILEGED_PHONE_STATE) public android.telephony.ImsiEncryptionInfo getCarrierInfoForImsiEncryption(int);      method public java.util.List<java.lang.String> getCarrierPackageNamesForIntent(android.content.Intent);      method public java.util.List<java.lang.String> getCarrierPackageNamesForIntentAndPhone(android.content.Intent, int); @@ -10834,6 +10836,7 @@ package android.telephony {      method @RequiresPermission(android.Manifest.permission.MODIFY_PHONE_STATE) public boolean resetRadioConfig();      method @RequiresPermission(android.Manifest.permission.CONNECTIVITY_INTERNAL) public void resetSettings();      method @Deprecated @RequiresPermission(android.Manifest.permission.MODIFY_PHONE_STATE) public int setAllowedCarriers(int, java.util.List<android.service.carrier.CarrierIdentifier>); +    method @RequiresPermission(android.Manifest.permission.MODIFY_PHONE_STATE) public boolean setAllowedNetworkTypes(long);      method @RequiresPermission(android.Manifest.permission.MODIFY_PHONE_STATE) public boolean setAlwaysAllowMmsData(boolean);      method @RequiresPermission(android.Manifest.permission.MODIFY_PHONE_STATE) public void setCarrierDataEnabled(boolean);      method @RequiresPermission(android.Manifest.permission.MODIFY_PHONE_STATE) public int setCarrierRestrictionRules(@NonNull android.telephony.CarrierRestrictionRules); diff --git a/core/java/android/provider/Telephony.java b/core/java/android/provider/Telephony.java index f3690648f35b..453728137d9a 100644 --- a/core/java/android/provider/Telephony.java +++ b/core/java/android/provider/Telephony.java @@ -5374,5 +5374,11 @@ public final class Telephony {          /** Whether uicc applications is set to be enabled or disabled. By default it's enabled. */          public static final String UICC_APPLICATIONS_ENABLED = "uicc_applications_enabled"; + +        /** +         * TelephonyProvider column name for allowed network types. Indicate which network types +         * are allowed. Default is -1. +         */ +        public static final String ALLOWED_NETWORK_TYPES = "allowed_network_types";      }  } diff --git a/telephony/java/android/telephony/SubscriptionManager.java b/telephony/java/android/telephony/SubscriptionManager.java index b42ce35aa79c..8de5b8541f56 100644 --- a/telephony/java/android/telephony/SubscriptionManager.java +++ b/telephony/java/android/telephony/SubscriptionManager.java @@ -782,6 +782,12 @@ public class SubscriptionManager {      public static final String UICC_APPLICATIONS_ENABLED = SimInfo.UICC_APPLICATIONS_ENABLED;      /** +     * Indicate which network type is allowed. By default it's enabled. +     * @hide +     */ +    public static final String ALLOWED_NETWORK_TYPES = SimInfo.ALLOWED_NETWORK_TYPES; + +    /**       * Broadcast Action: The user has changed one of the default subs related to       * data, phone calls, or sms</p>       * @@ -2434,7 +2440,28 @@ public class SubscriptionManager {              try {                  return Integer.parseInt(result);              } catch (NumberFormatException err) { -                logd("getBooleanSubscriptionProperty NumberFormat exception"); +                logd("getIntegerSubscriptionProperty NumberFormat exception"); +            } +        } +        return defValue; +    } + +    /** +     * Returns long value corresponding to query result. +     * @param subId Subscription Id of Subscription +     * @param propKey Column name in SubscriptionInfo database +     * @param defValue Default long value to be returned +     * @return long result value to be returned +     * @hide +     */ +    public static long getLongSubscriptionProperty(int subId, String propKey, long defValue, +                                                     Context context) { +        String result = getSubscriptionProperty(subId, propKey, context); +        if (result != null) { +            try { +                return Long.parseLong(result); +            } catch (NumberFormatException err) { +                logd("getLongSubscriptionProperty NumberFormat exception");              }          }          return defValue; diff --git a/telephony/java/android/telephony/TelephonyManager.java b/telephony/java/android/telephony/TelephonyManager.java index 7e493aee20ff..c9d5006946aa 100644 --- a/telephony/java/android/telephony/TelephonyManager.java +++ b/telephony/java/android/telephony/TelephonyManager.java @@ -7687,7 +7687,9 @@ public class TelephonyManager {       *       * @return the preferred network type.       * @hide +     * @deprecated Use {@link #getPreferredNetworkTypeBitmask} instead.       */ +    @Deprecated      @RequiresPermission((android.Manifest.permission.READ_PRIVILEGED_PHONE_STATE))      @UnsupportedAppUsage      public @PrefNetworkMode int getPreferredNetworkType(int subId) { @@ -7732,6 +7734,30 @@ public class TelephonyManager {      }      /** +     * Get the allowed network types. +     * +     * <p>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.       *       * <p>If this object has been created with {@link #createForSubscriptionId}, applies to the @@ -7982,7 +8008,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 { @@ -7997,7 +8025,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.       *       * <p>If this object has been created with {@link #createForSubscriptionId}, applies to the       * given subId. Otherwise, applies to {@link SubscriptionManager#getDefaultSubscriptionId()} @@ -8027,6 +8056,29 @@ public class TelephonyManager {      }      /** +     * 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.       *       * <p>Requires that the calling app has carrier privileges (see {@link #hasCarrierPrivileges}). diff --git a/telephony/java/com/android/internal/telephony/ITelephony.aidl b/telephony/java/com/android/internal/telephony/ITelephony.aidl index a2dc0d5e1b7a..7add741e84fa 100644 --- a/telephony/java/com/android/internal/telephony/ITelephony.aidl +++ b/telephony/java/com/android/internal/telephony/ITelephony.aidl @@ -922,6 +922,23 @@ interface ITelephony {              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.       *  |