From 0cecdf70dba754b3fc4a508589f41c44b08a1fb4 Mon Sep 17 00:00:00 2001 From: Pengquan Meng Date: Thu, 20 Sep 2018 13:47:43 -0700 Subject: [PATCH] Update network selection API Change the manual network selection api in TelephonyManager to support the OperatorInfo. Bug: 115401728 Test: manual test Merged-In: I43dee55ce117873b699cb98c6eb6d41f5dee24ea Change-Id: I43dee55ce117873b699cb98c6eb6d41f5dee24ea --- .../android/telephony/TelephonyManager.java | 34 ++++++++++++++++--- .../internal/telephony/ITelephony.aidl | 11 +++--- .../internal/telephony/OperatorInfo.java | 2 +- 3 files changed, 37 insertions(+), 10 deletions(-) diff --git a/telephony/java/android/telephony/TelephonyManager.java b/telephony/java/android/telephony/TelephonyManager.java index 7236571205932..7f27009205c4e 100644 --- a/telephony/java/android/telephony/TelephonyManager.java +++ b/telephony/java/android/telephony/TelephonyManager.java @@ -67,6 +67,7 @@ import com.android.internal.telephony.CellNetworkScanResult; import com.android.internal.telephony.IPhoneSubInfo; import com.android.internal.telephony.ITelephony; import com.android.internal.telephony.ITelephonyRegistry; +import com.android.internal.telephony.OperatorInfo; import com.android.internal.telephony.PhoneConstants; import com.android.internal.telephony.RILConstants; import com.android.internal.telephony.TelephonyProperties; @@ -5833,21 +5834,46 @@ public class TelephonyManager { * @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 true on success; false on any failure. + * @return {@code true} on success; {@code false} on any failure. */ @SuppressAutoDoc // Blocked by b/72967236 - no support for carrier privileges @RequiresPermission(android.Manifest.permission.MODIFY_PHONE_STATE) public boolean setNetworkSelectionModeManual(String operatorNumeric, boolean persistSelection) { + return setNetworkSelectionModeManual( + new OperatorInfo( + "" /* operatorAlphaLong */, "" /* operatorAlphaShort */, operatorNumeric), + 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#getDefaultDataSubscriptionId()} + * + *

Requires Permission: + * {@link android.Manifest.permission#MODIFY_PHONE_STATE MODIFY_PHONE_STATE} or that the calling + * app has carrier privileges (see {@link #hasCarrierPrivileges}). + * + * @param operatorInfo included the PLMN id, long name, short name of the operator to attach to. + * @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 true} on any failure. + * + * @hide + */ + @RequiresPermission(android.Manifest.permission.MODIFY_PHONE_STATE) + public boolean setNetworkSelectionModeManual( + OperatorInfo operatorInfo, boolean persistSelection) { try { ITelephony telephony = getITelephony(); if (telephony != null) { return telephony.setNetworkSelectionModeManual( - getSubId(), operatorNumeric, persistSelection); + getSubId(), operatorInfo, persistSelection); } } catch (RemoteException ex) { Rlog.e(TAG, "setNetworkSelectionModeManual RemoteException", ex); - } catch (NullPointerException ex) { - Rlog.e(TAG, "setNetworkSelectionModeManual NPE", ex); } return false; } diff --git a/telephony/java/com/android/internal/telephony/ITelephony.aidl b/telephony/java/com/android/internal/telephony/ITelephony.aidl index 066db1fca1407..df3944018e3c2 100644 --- a/telephony/java/com/android/internal/telephony/ITelephony.aidl +++ b/telephony/java/com/android/internal/telephony/ITelephony.aidl @@ -871,14 +871,15 @@ interface ITelephony { * Ask the radio to connect to the input network and change selection mode to manual. * * @param subId the id of the subscription. - * @param operatorNumeric the PLMN of the operator to attach to. - * @param persistSelection Whether the selection will persist until reboot. If true, only allows + * @param operatorInfo the operator inforamtion, included the PLMN, long name and short name of + * the operator to attach to. + * @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 true if the request suceeded. + * @return {@code true} on success; {@code true} on any failure. */ - boolean setNetworkSelectionModeManual(int subId, in String operatorNumeric, - boolean persistSelection); + boolean setNetworkSelectionModeManual( + int subId, in OperatorInfo operatorInfo, boolean persisSelection); /** * Set the preferred network type. diff --git a/telephony/java/com/android/internal/telephony/OperatorInfo.java b/telephony/java/com/android/internal/telephony/OperatorInfo.java index d0245a0a07b40..a47e2b0260218 100644 --- a/telephony/java/com/android/internal/telephony/OperatorInfo.java +++ b/telephony/java/com/android/internal/telephony/OperatorInfo.java @@ -21,7 +21,7 @@ import android.os.Parcel; import android.os.Parcelable; /** - * {@hide} + * @hide */ public class OperatorInfo implements Parcelable { public enum State {