summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Pengquan Meng <mpq@google.com> 2018-09-06 10:27:01 -0700
committer Pengquan Meng <mpq@google.com> 2018-09-11 15:07:56 -0700
commit97c29e04fa37bcf572cc5109fd975ff510f55fa5 (patch)
tree35129f5f84818d683bd9ceea47be0103fa24d941
parent98cd65e17f02c649bef6d7bc34fdbbf47a1cf139 (diff)
Add New TelephonyManager APIs
Bug:111453847 Test: build test Merged-In: I83a5f4149f92ce495cd066f7158e7ff37a66894f Change-Id: I83a5f4149f92ce495cd066f7158e7ff37a66894f
-rw-r--r--telephony/java/android/telephony/TelephonyManager.java119
-rw-r--r--telephony/java/com/android/internal/telephony/ITelephony.aidl33
2 files changed, 152 insertions, 0 deletions
diff --git a/telephony/java/android/telephony/TelephonyManager.java b/telephony/java/android/telephony/TelephonyManager.java
index e3c0b308a3d9..eee173101f40 100644
--- a/telephony/java/android/telephony/TelephonyManager.java
+++ b/telephony/java/android/telephony/TelephonyManager.java
@@ -134,6 +134,22 @@ public class TelephonyManager {
static final int NEVER_USE = 2;
}
+ /** @hide */
+ @Retention(RetentionPolicy.SOURCE)
+ @IntDef(prefix = {"NETWORK_SELECTION_MODE_"},
+ value = {
+ NETWORK_SELECTION_MODE_UNKNOWN,
+ NETWORK_SELECTION_MODE_AUTO,
+ NETWORK_SELECTION_MODE_MANUAL})
+ public @interface NetworkSelectionMode {}
+
+ /** @hide */
+ public static final int NETWORK_SELECTION_MODE_UNKNOWN = 0;
+ /** @hide */
+ public static final int NETWORK_SELECTION_MODE_AUTO = 1;
+ /** @hide */
+ public static final int NETWORK_SELECTION_MODE_MANUAL = 2;
+
/** The otaspMode passed to PhoneStateListener#onOtaspChanged */
/** @hide */
static public final int OTASP_UNINITIALIZED = 0;
@@ -5818,6 +5834,31 @@ public class TelephonyManager {
return false;
}
+ /**
+ * Get the network selection mode.
+ *
+ * <p>If this object has been created with {@link #createForSubscriptionId}, applies to the
+ * given subId. Otherwise, applies to {@link SubscriptionManager#getDefaultDataSubscriptionId()}
+
+ * @return the network selection mode.
+ *
+ * @hide
+ */
+ @NetworkSelectionMode
+ @RequiresPermission(android.Manifest.permission.READ_PHONE_STATE)
+ public int getNetworkSelectionMode() {
+ int mode = NETWORK_SELECTION_MODE_UNKNOWN;
+ try {
+ ITelephony telephony = getITelephony();
+ if (telephony != null) {
+ mode = telephony.getNetworkSelectionMode(getSubId());
+ }
+ } catch (RemoteException ex) {
+ Rlog.e(TAG, "getNetworkSelectionMode RemoteException", ex);
+ }
+ return mode;
+ }
+
/**
* Set the preferred network type.
* Used for device configuration by some CDMA operators.
@@ -6732,6 +6773,84 @@ public class TelephonyManager {
}
/**
+ * Gets the roaming mode for CDMA phone.
+ *
+ * <p>If this object has been created with {@link #createForSubscriptionId}, applies to the
+ * given subId. Otherwise, applies to {@link SubscriptionManager#getDefaultDataSubscriptionId()}
+ *
+ * @return one of {@link #CDMA_ROAMING_MODE_RADIO_DEFAULT}, {@link #CDMA_ROAMING_MODE_HOME},
+ * {@link #CDMA_ROAMING_MODE_AFFILIATED}, {@link #CDMA_ROAMING_MODE_ANY}.
+ *
+ * @hide
+ */
+ @RequiresPermission(android.Manifest.permission.READ_PHONE_STATE)
+ public int getCdmaRoamingMode() {
+ int mode = CDMA_ROAMING_MODE_RADIO_DEFAULT;
+ try {
+ ITelephony telephony = getITelephony();
+ if (telephony != null) {
+ mode = telephony.getCdmaRoamingMode(getSubId());
+ }
+ } catch (RemoteException ex) {
+ Log.e(TAG, "Error calling ITelephony#getCdmaRoamingMode", ex);
+ }
+ return mode;
+ }
+
+ /**
+ * Sets the roaming mode for CDMA phone to the given mode {@code mode}.
+ *
+ * <p>If this object has been created with {@link #createForSubscriptionId}, applies to the
+ * given subId. Otherwise, applies to {@link SubscriptionManager#getDefaultDataSubscriptionId()}
+ *
+ * @param mode should be one of {@link #CDMA_ROAMING_MODE_RADIO_DEFAULT},
+ * {@link #CDMA_ROAMING_MODE_HOME}, {@link #CDMA_ROAMING_MODE_AFFILIATED},
+ * {@link #CDMA_ROAMING_MODE_ANY}.
+ *
+ * @return {@code true} if successed.
+ *
+ * @hide
+ */
+ @RequiresPermission(android.Manifest.permission.MODIFY_PHONE_STATE)
+ public boolean setCdmaRoamingMode(int mode) {
+ try {
+ ITelephony telephony = getITelephony();
+ if (telephony != null) {
+ return telephony.setCdmaRoamingMode(getSubId(), mode);
+ }
+ } catch (RemoteException ex) {
+ Log.e(TAG, "Error calling ITelephony#setCdmaRoamingMode", ex);
+ }
+ return false;
+ }
+
+ /**
+ * Sets the subscription mode for CDMA phone to the given mode {@code mode}.
+ *
+ * @param mode CDMA subscription mode
+ *
+ * @return {@code true} if successed.
+ *
+ * @see Phone#CDMA_SUBSCRIPTION_UNKNOWN
+ * @see Phone#CDMA_SUBSCRIPTION_RUIM_SIM
+ * @see Phone#CDMA_SUBSCRIPTION_NV
+ *
+ * @hide
+ */
+ @RequiresPermission(android.Manifest.permission.MODIFY_PHONE_STATE)
+ public boolean setCdmaSubscriptionMode(int mode) {
+ try {
+ ITelephony telephony = getITelephony();
+ if (telephony != null) {
+ return telephony.setCdmaSubscriptionMode(getSubId(), mode);
+ }
+ } catch (RemoteException ex) {
+ Log.e(TAG, "Error calling ITelephony#setCdmaSubscriptionMode", ex);
+ }
+ return false;
+ }
+
+ /**
* Enables/Disables the data roaming on the subscription.
*
* <p>If this object has been created with {@link #createForSubscriptionId}, applies to the
diff --git a/telephony/java/com/android/internal/telephony/ITelephony.aidl b/telephony/java/com/android/internal/telephony/ITelephony.aidl
index b4f3487a5f63..066db1fca140 100644
--- a/telephony/java/com/android/internal/telephony/ITelephony.aidl
+++ b/telephony/java/com/android/internal/telephony/ITelephony.aidl
@@ -1536,6 +1536,34 @@ interface ITelephony {
void setDataRoamingEnabled(int subId, boolean isEnabled);
/**
+ * Gets the roaming mode for the CDMA phone with the subscription id {@code subId}.
+ *
+ * @param the subscription id.
+ * @return the roaming mode for CDMA phone.
+ */
+ int getCdmaRoamingMode(int subId);
+
+ /**
+ * Sets the roaming mode on the CDMA phone with the subscription {@code subId} to the given
+ * roaming mode {@code mode}.
+ *
+ * @param subId the subscription id.
+ * @param mode the roaming mode should be set.
+ * @return {@code true} if successed.
+ */
+ boolean setCdmaRoamingMode(int subId, int mode);
+
+ /**
+ * Sets the subscription mode for CDMA phone with the subscription {@code subId} to the given
+ * subscription mode {@code mode}.
+ *
+ * @param subId the subscription id.
+ * @param mode the subscription mode should be set.
+ * @return {@code true} if successed.
+ */
+ boolean setCdmaSubscriptionMode(int subId, int mode);
+
+ /**
* A test API to override carrier information including mccmnc, imsi, iccid, gid1, gid2,
* plmn and spn. This would be handy for, eg, forcing a particular carrier id, carrier's config
* (also any country or carrier overlays) to be loaded when using a test SIM with a call box.
@@ -1559,4 +1587,9 @@ interface ITelephony {
* @hide
*/
int getNumberOfModemsWithSimultaneousDataConnections(int subId, String callingPackage);
+
+ /**
+ * Return the network selection mode on the subscription with id {@code subId}.
+ */
+ int getNetworkSelectionMode(int subId);
}