summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Sooraj Sasindran <sasindran@google.com> 2020-07-09 22:52:36 +0000
committer Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com> 2020-07-09 22:52:36 +0000
commit39877c432174f7fd3ed072eff242afab1e35bb46 (patch)
tree98b90a38c6ed5d290b149e05af6538fa23e075fa
parent4aa8851cc4d9f5a08526a8f55ff2b77d1c2ea2a4 (diff)
parentdc52bd51d8549dd22ac2bb7d3b8ba40f4184183a (diff)
Merge "Add hidden API to support allowed networks reason" am: dc52bd51d8
Original change: https://android-review.googlesource.com/c/platform/frameworks/base/+/1358929 Change-Id: I4debe07aef416e7e1bf6c35bce879c07aaea1d68
-rw-r--r--telephony/java/android/telephony/TelephonyManager.java134
-rw-r--r--telephony/java/com/android/internal/telephony/ITelephony.aidl29
2 files changed, 163 insertions, 0 deletions
diff --git a/telephony/java/android/telephony/TelephonyManager.java b/telephony/java/android/telephony/TelephonyManager.java
index 6fa94d39dbc7..686adab53bf1 100644
--- a/telephony/java/android/telephony/TelephonyManager.java
+++ b/telephony/java/android/telephony/TelephonyManager.java
@@ -8057,6 +8057,140 @@ public class TelephonyManager {
return false;
}
+ /** @hide */
+ @IntDef({
+ ALLOWED_NETWORK_TYPES_REASON_POWER
+ })
+ @Retention(RetentionPolicy.SOURCE)
+ public @interface AllowedNetworkTypesReason{}
+
+ /**
+ * To indicate allowed network type change is requested by power manager.
+ * Power Manger configuration won't affect the settings configured through
+ * {@link setAllowedNetworkTypes} and will result in allowing network types that are in both
+ * configurations (i.e intersection of both sets).
+ * @hide
+ */
+ public static final int ALLOWED_NETWORK_TYPES_REASON_POWER = 0;
+
+ /**
+ * Set the allowed network types of the device and
+ * provide the reason triggering the allowed network change.
+ * This can be called for following reasons
+ * <ol>
+ * <li>Allowed network types control by power manager
+ * {@link #ALLOWED_NETWORK_TYPES_REASON_POWER}
+ * </ol>
+ * This API will result in allowing an intersection of allowed network types for all reasons,
+ * including the configuration done through {@link setAllowedNetworkTypes}.
+ * While this API and {@link setAllowedNetworkTypes} is controlling allowed network types
+ * on device, user preference will still be set through {@link #setPreferredNetworkTypeBitmask}.
+ * Thus resultant network type configured on modem will be an intersection of the network types
+ * from setAllowedNetworkTypesForReason, {@link setAllowedNetworkTypes}
+ * and {@link #setPreferredNetworkTypeBitmask}.
+ *
+ * @param reason the reason the allowed network type change is taking place
+ * @param allowedNetworkTypes The bitmask of allowed network types.
+ * @throws IllegalStateException if the Telephony process is not currently available.
+ * @throws IllegalArgumentException if invalid AllowedNetworkTypesReason is passed.
+ * @hide
+ */
+ @RequiresPermission(android.Manifest.permission.MODIFY_PHONE_STATE)
+ public void setAllowedNetworkTypesForReason(@AllowedNetworkTypesReason int reason,
+ @NetworkTypeBitMask long allowedNetworkTypes) {
+ if (reason != ALLOWED_NETWORK_TYPES_REASON_POWER) {
+ throw new IllegalArgumentException("invalid AllowedNetworkTypesReason.");
+ }
+ try {
+ ITelephony telephony = getITelephony();
+ if (telephony != null) {
+ telephony.setAllowedNetworkTypesForReason(getSubId(), reason,
+ allowedNetworkTypes);
+ } else {
+ throw new IllegalStateException("telephony service is null.");
+ }
+ } catch (RemoteException ex) {
+ Rlog.e(TAG, "setAllowedNetworkTypesForReason RemoteException", ex);
+ ex.rethrowFromSystemServer();
+ }
+ }
+
+ /**
+ * Get the allowed network types for certain reason.
+ *
+ * {@link #getAllowedNetworkTypesForReason} returns allowed network type for a
+ * specific reason. For effective allowed network types configured on device,
+ * query {@link getEffectiveAllowedNetworkTypes}
+ *
+ * <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}).
+ *s
+ * @param reason the reason the allowed network type change is taking place
+ * @return the allowed network type bitmask
+ * @throws IllegalStateException if the Telephony process is not currently available.
+ * @throws IllegalArgumentException if invalid AllowedNetworkTypesReason is passed.
+ * @hide
+ */
+ @RequiresPermission(android.Manifest.permission.READ_PRIVILEGED_PHONE_STATE)
+ public @NetworkTypeBitMask long getAllowedNetworkTypesForReason(
+ @AllowedNetworkTypesReason int reason) {
+ if (reason != ALLOWED_NETWORK_TYPES_REASON_POWER) {
+ throw new IllegalArgumentException("invalid AllowedNetworkTypesReason.");
+ }
+ try {
+ ITelephony telephony = getITelephony();
+ if (telephony != null) {
+ return telephony.getAllowedNetworkTypesForReason(getSubId(), reason);
+ } else {
+ throw new IllegalStateException("telephony service is null.");
+ }
+ } catch (RemoteException ex) {
+ Rlog.e(TAG, "getAllowedNetworkTypesForReason RemoteException", ex);
+ ex.rethrowFromSystemServer();
+ }
+ return -1;
+ }
+
+ /**
+ * Get bit mask of all network types.
+ *
+ * @return bit mask of all network types
+ * @hide
+ */
+ public static @NetworkTypeBitMask long getAllNetworkTypesBitmask() {
+ return NETWORK_STANDARDS_FAMILY_BITMASK_3GPP | NETWORK_STANDARDS_FAMILY_BITMASK_3GPP2;
+ }
+
+ /**
+ * Get the allowed network types configured on the device.
+ * This API will return an intersection of allowed network types for all reasons,
+ * including the configuration done through setAllowedNetworkTypes
+ *
+ * <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
+ * @throws IllegalStateException if the Telephony process is not currently available.
+ * @hide
+ */
+ @RequiresPermission(android.Manifest.permission.READ_PRIVILEGED_PHONE_STATE)
+ public @NetworkTypeBitMask long getEffectiveAllowedNetworkTypes() {
+ try {
+ ITelephony telephony = getITelephony();
+ if (telephony != null) {
+ return telephony.getEffectiveAllowedNetworkTypes(getSubId());
+ } else {
+ throw new IllegalStateException("telephony service is null.");
+ }
+ } catch (RemoteException ex) {
+ Rlog.e(TAG, "getEffectiveAllowedNetworkTypes RemoteException", ex);
+ ex.rethrowFromSystemServer();
+ }
+ return -1;
+ }
+
/**
* 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 9b64ff17cc1e..bf81ddcb0c15 100644
--- a/telephony/java/com/android/internal/telephony/ITelephony.aidl
+++ b/telephony/java/com/android/internal/telephony/ITelephony.aidl
@@ -943,6 +943,35 @@ interface ITelephony {
boolean setAllowedNetworkTypes(int subId, long allowedNetworkTypes);
/**
+ * Get the allowed network types for certain reason.
+ *
+ * @param subId the id of the subscription.
+ * @param reason the reason the allowed network type change is taking place
+ * @return allowedNetworkTypes the allowed network types.
+ */
+ long getAllowedNetworkTypesForReason(int subId, int reason);
+
+ /**
+ * Get the effective allowed network types on the device. This API will
+ * return an intersection of allowed network types for all reasons,
+ * including the configuration done through setAllowedNetworkTypes
+ *
+ * @param subId the id of the subscription.
+ * @return allowedNetworkTypes the allowed network types.
+ */
+ long getEffectiveAllowedNetworkTypes(int subId);
+
+ /**
+ * Set the allowed network types and provide the reason triggering the allowed network change.
+ *
+ * @param subId the id of the subscription.
+ * @param reason the reason the allowed network type change is taking place
+ * @param allowedNetworkTypes the allowed network types.
+ * @return true on success; false on any failure.
+ */
+ boolean setAllowedNetworkTypesForReason(int subId, int reason, long allowedNetworkTypes);
+
+ /**
* Set the preferred network type.
* Used for device configuration by some CDMA operators.
*