Merge "Update network selection API"

This commit is contained in:
Pengquan Meng
2018-09-21 21:20:57 +00:00
committed by Gerrit Code Review
3 changed files with 37 additions and 10 deletions

View File

@@ -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.
*
* <p>If this object has been created with {@link #createForSubscriptionId}, applies to the
* given subId. Otherwise, applies to {@link SubscriptionManager#getDefaultDataSubscriptionId()}
*
* <p>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;
}

View File

@@ -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.

View File

@@ -21,7 +21,7 @@ import android.os.Parcel;
import android.os.Parcelable;
/**
* {@hide}
* @hide
*/
public class OperatorInfo implements Parcelable {
public enum State {