diff --git a/api/system-current.txt b/api/system-current.txt index c60110b1b5c6c..5a8a7d4852128 100755 --- a/api/system-current.txt +++ b/api/system-current.txt @@ -11925,6 +11925,7 @@ package android.telephony { method @RequiresPermission(android.Manifest.permission.MODIFY_PHONE_STATE) public void setDataRoamingEnabled(boolean); method @RequiresPermission(android.Manifest.permission.MODIFY_PHONE_STATE) public int setIccLockEnabled(boolean, @NonNull String); method @RequiresPermission(android.Manifest.permission.MODIFY_PHONE_STATE) public void setMultiSimCarrierRestriction(boolean); + method @RequiresPermission(android.Manifest.permission.MODIFY_PHONE_STATE) public boolean setNetworkSelectionModeManual(@NonNull String, int, boolean); method @RequiresPermission(android.Manifest.permission.MODIFY_PHONE_STATE) public boolean setOpportunisticNetworkState(boolean); method @RequiresPermission(android.Manifest.permission.MODIFY_PHONE_STATE) public void setPolicyDataEnabled(boolean); method @RequiresPermission(android.Manifest.permission.MODIFY_PHONE_STATE) public boolean setPreferredNetworkTypeBitmask(long); diff --git a/telephony/java/android/telephony/TelephonyManager.java b/telephony/java/android/telephony/TelephonyManager.java index 075b56b72c19c..163bc74062839 100644 --- a/telephony/java/android/telephony/TelephonyManager.java +++ b/telephony/java/android/telephony/TelephonyManager.java @@ -7929,6 +7929,36 @@ public class TelephonyManager { persistSelection); } + /** + * Ask the radio to connect to the input network and change selection mode to manual. + * + *
If this object has been created with {@link #createForSubscriptionId}, applies to the + * given subId. Otherwise, applies to {@link SubscriptionManager#getDefaultSubscriptionId()} + * + *
Requires Permission:
+ * {@link android.Manifest.permission#MODIFY_PHONE_STATE MODIFY_PHONE_STATE} or that the calling
+ * app has carrier privileges (see {@link #hasCarrierPrivileges}).
+ *
+ * @param operatorNumeric the PLMN ID of the network to select.
+ * @param ran the initial suggested radio access network type.
+ * If registration fails, the RAN is not available after, the RAN is not within the
+ * network types specified by {@link #setPreferredNetworkTypeBitmask}, or the value is
+ * {@link AccessNetworkConstants.AccessNetworkType#UNKNOWN}, modem will select
+ * the next best RAN for network registration.
+ * @param persistSelection whether the selection will persist until reboot.
+ * If true, only allows attaching to the selected PLMN until reboot; otherwise,
+ * attach to the chosen PLMN and resume normal network selection next time.
+ * @return {@code true} on success; {@code false} on any failure.
+ * @hide
+ */
+ @RequiresPermission(android.Manifest.permission.MODIFY_PHONE_STATE)
+ @SystemApi
+ public boolean setNetworkSelectionModeManual(@NonNull String operatorNumeric,
+ @AccessNetworkConstants.RadioAccessNetworkType int ran, boolean persistSelection) {
+ return setNetworkSelectionModeManual(new OperatorInfo("" /* operatorAlphaLong */,
+ "" /* operatorAlphaShort */, operatorNumeric, ran), persistSelection);
+ }
+
/**
* Ask the radio to connect to the input network and change selection mode to manual.
*
diff --git a/telephony/java/com/android/internal/telephony/OperatorInfo.java b/telephony/java/com/android/internal/telephony/OperatorInfo.java
index 64d7863910219..2ca459811e04f 100644
--- a/telephony/java/com/android/internal/telephony/OperatorInfo.java
+++ b/telephony/java/com/android/internal/telephony/OperatorInfo.java
@@ -20,6 +20,7 @@ import android.compat.annotation.UnsupportedAppUsage;
import android.os.Build;
import android.os.Parcel;
import android.os.Parcelable;
+import android.telephony.AccessNetworkConstants.AccessNetworkType;
/**
* @hide
@@ -43,6 +44,7 @@ public class OperatorInfo implements Parcelable {
@UnsupportedAppUsage
private State mState = State.UNKNOWN;
+ private int mRan = AccessNetworkType.UNKNOWN;
@UnsupportedAppUsage
@@ -69,6 +71,10 @@ public class OperatorInfo implements Parcelable {
return mState;
}
+ public int getRan() {
+ return mRan;
+ }
+
@UnsupportedAppUsage
OperatorInfo(String operatorAlphaLong,
String operatorAlphaShort,
@@ -82,6 +88,14 @@ public class OperatorInfo implements Parcelable {
mState = state;
}
+ OperatorInfo(String operatorAlphaLong,
+ String operatorAlphaShort,
+ String operatorNumeric,
+ State state,
+ int ran) {
+ this (operatorAlphaLong, operatorAlphaShort, operatorNumeric, state);
+ mRan = ran;
+ }
@UnsupportedAppUsage
public OperatorInfo(String operatorAlphaLong,
@@ -92,6 +106,14 @@ public class OperatorInfo implements Parcelable {
operatorNumeric, rilStateToState(stateString));
}
+ public OperatorInfo(String operatorAlphaLong,
+ String operatorAlphaShort,
+ String operatorNumeric,
+ int ran) {
+ this (operatorAlphaLong, operatorAlphaShort, operatorNumeric);
+ mRan = ran;
+ }
+
@UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.P, trackingBug = 115609023)
public OperatorInfo(String operatorAlphaLong,
String operatorAlphaShort,
@@ -124,7 +146,8 @@ public class OperatorInfo implements Parcelable {
return "OperatorInfo " + mOperatorAlphaLong
+ "/" + mOperatorAlphaShort
+ "/" + mOperatorNumeric
- + "/" + mState;
+ + "/" + mState
+ + "/" + mRan;
}
/**
@@ -150,6 +173,7 @@ public class OperatorInfo implements Parcelable {
dest.writeString(mOperatorAlphaShort);
dest.writeString(mOperatorNumeric);
dest.writeSerializable(mState);
+ dest.writeInt(mRan);
}
/**
@@ -158,20 +182,21 @@ public class OperatorInfo implements Parcelable {
*/
@UnsupportedAppUsage
public static final Creator