diff options
author | Shishir Agrawal <shishir@google.com> | 2015-06-22 18:19:52 +0000 |
---|---|---|
committer | Android (Google) Code Review <android-gerrit@google.com> | 2015-06-22 18:19:58 +0000 |
commit | c242d9d2aeececeda4c980dfa119b3414d818424 (patch) | |
tree | 34a143179ab314be15e2482cfe0e124293b192ee /telephony | |
parent | de4aecd8310f61d7fe9f06a5a1f684247f88d437 (diff) | |
parent | d4f2bcdab5a43e6439babfd5eefeaff908b73870 (diff) | |
download | frameworks_base-c242d9d2aeececeda4c980dfa119b3414d818424.zip frameworks_base-c242d9d2aeececeda4c980dfa119b3414d818424.tar.gz frameworks_base-c242d9d2aeececeda4c980dfa119b3414d818424.tar.bz2 |
Merge "Adding hidden TM calls to scan/select cell networks." into mnc-dev
Diffstat (limited to 'telephony')
5 files changed, 374 insertions, 1 deletions
diff --git a/telephony/java/android/telephony/TelephonyManager.java b/telephony/java/android/telephony/TelephonyManager.java index f77d268..b7ca749 100644 --- a/telephony/java/android/telephony/TelephonyManager.java +++ b/telephony/java/android/telephony/TelephonyManager.java @@ -33,9 +33,11 @@ import android.telecom.PhoneAccount; import android.util.Log; import com.android.internal.telecom.ITelecomService; +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; @@ -3433,6 +3435,55 @@ public class TelephonyManager { } /** + * Perform a radio scan and return the list of avialble networks. + * + * The return value is a list of the OperatorInfo of the networks found. Note that this + * scan can take a long time (sometimes minutes) to happen. + * + * <p> + * Requires Permission: + * {@link android.Manifest.permission#MODIFY_PHONE_STATE MODIFY_PHONE_STATE} + * Or the calling app has carrier privileges. @see #hasCarrierPrivileges + * + * @hide + */ + public CellNetworkScanResult getCellNetworkScanResults(int subId) { + try { + ITelephony telephony = getITelephony(); + if (telephony != null) + return telephony.getCellNetworkScanResults(subId); + } catch (RemoteException ex) { + Rlog.e(TAG, "getCellNetworkScanResults RemoteException", ex); + } catch (NullPointerException ex) { + Rlog.e(TAG, "getCellNetworkScanResults NPE", ex); + } + return null; + } + + /** + * Ask the radio to connect to the input network and change selection mode to manual. + * + * <p> + * Requires Permission: + * {@link android.Manifest.permission#MODIFY_PHONE_STATE MODIFY_PHONE_STATE} + * Or the calling app has carrier privileges. @see #hasCarrierPrivileges + * + * @hide + */ + public boolean setNetworkSelectionModeManual(int subId, OperatorInfo operator) { + try { + ITelephony telephony = getITelephony(); + if (telephony != null) + return telephony.setNetworkSelectionModeManual(subId, operator); + } catch (RemoteException ex) { + Rlog.e(TAG, "setNetworkSelectionModeManual RemoteException", ex); + } catch (NullPointerException ex) { + Rlog.e(TAG, "setNetworkSelectionModeManual NPE", ex); + } + return false; + } + + /** * Set the preferred network type. * Used for device configuration by some CDMA operators. * <p> diff --git a/telephony/java/com/android/internal/telephony/CellNetworkScanResult.aidl b/telephony/java/com/android/internal/telephony/CellNetworkScanResult.aidl new file mode 100644 index 0000000..7917a81 --- /dev/null +++ b/telephony/java/com/android/internal/telephony/CellNetworkScanResult.aidl @@ -0,0 +1,19 @@ +/* +** Copyright 2015, The Android Open Source Project +** +** Licensed under the Apache License, Version 2.0 (the "License"); +** you may not use this file except in compliance with the License. +** You may obtain a copy of the License at +** +** http://www.apache.org/licenses/LICENSE-2.0 +** +** Unless required by applicable law or agreed to in writing, software +** distributed under the License is distributed on an "AS IS" BASIS, +** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +** See the License for the specific language governing permissions and +** limitations under the License. +*/ + +package com.android.internal.telephony; + +parcelable CellNetworkScanResult; diff --git a/telephony/java/com/android/internal/telephony/CellNetworkScanResult.java b/telephony/java/com/android/internal/telephony/CellNetworkScanResult.java new file mode 100644 index 0000000..c708c14 --- /dev/null +++ b/telephony/java/com/android/internal/telephony/CellNetworkScanResult.java @@ -0,0 +1,125 @@ +/* +** Copyright 2015, The Android Open Source Project +** +** Licensed under the Apache License, Version 2.0 (the "License"); +** you may not use this file except in compliance with the License. +** You may obtain a copy of the License at +** +** http://www.apache.org/licenses/LICENSE-2.0 +** +** Unless required by applicable law or agreed to in writing, software +** distributed under the License is distributed on an "AS IS" BASIS, +** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +** See the License for the specific language governing permissions and +** limitations under the License. +*/ + +package com.android.internal.telephony; + +import android.os.Parcel; +import android.os.Parcelable; +import java.util.ArrayList; +import java.util.List; + +/** + * Response for querying available cellular networks. + * + * @hide + */ +public class CellNetworkScanResult implements Parcelable { + + /** + * Possible status values. + */ + public static final int STATUS_SUCCESS = 1; + public static final int STATUS_RADIO_NOT_AVAILABLE = 2; + public static final int STATUS_RADIO_GENERIC_FAILURE = 3; + public static final int STATUS_UNKNOWN_ERROR = 4; + + private final int mStatus; + private final List<OperatorInfo> mOperators; + + /** + * Constructor. + * + * @hide + */ + public CellNetworkScanResult(int status, List<OperatorInfo> operators) { + mStatus = status; + mOperators = operators; + } + + /** + * Construct a CellNetworkScanResult from a given parcel. + */ + private CellNetworkScanResult(Parcel in) { + mStatus = in.readInt(); + int len = in.readInt(); + if (len > 0) { + mOperators = new ArrayList(); + for (int i = 0; i < len; ++i) { + mOperators.add(OperatorInfo.CREATOR.createFromParcel(in)); + } + } else { + mOperators = null; + } + } + + /** + * @return the status of the command. + */ + public int getStatus() { + return mStatus; + } + + /** + * @return the operators. + */ + public List<OperatorInfo> getOperators() { + return mOperators; + } + + @Override + public int describeContents() { + return 0; + } + + @Override + public void writeToParcel(Parcel out, int flags) { + out.writeInt(mStatus); + if (mOperators != null && mOperators.size() > 0) { + for (OperatorInfo network : mOperators) { + network.writeToParcel(out, flags); + } + } else { + out.writeInt(0); + } + } + + @Override + public String toString() { + StringBuffer sb = new StringBuffer(); + sb.append("CellNetworkScanResult: {"); + sb.append(" status:").append(mStatus); + if (mOperators != null) { + for (OperatorInfo network : mOperators) { + sb.append(" network:").append(network); + } + } + sb.append("}"); + return sb.toString(); + } + + public static final Parcelable.Creator<CellNetworkScanResult> CREATOR + = new Parcelable.Creator<CellNetworkScanResult>() { + + @Override + public CellNetworkScanResult createFromParcel(Parcel in) { + return new CellNetworkScanResult(in); + } + + public CellNetworkScanResult[] newArray(int size) { + return new CellNetworkScanResult[size]; + } + }; +} diff --git a/telephony/java/com/android/internal/telephony/ITelephony.aidl b/telephony/java/com/android/internal/telephony/ITelephony.aidl index 44754ab..7dc71ed 100644 --- a/telephony/java/com/android/internal/telephony/ITelephony.aidl +++ b/telephony/java/com/android/internal/telephony/ITelephony.aidl @@ -24,6 +24,8 @@ import android.telephony.IccOpenLogicalChannelResponse; import android.telephony.NeighboringCellInfo; import android.telephony.RadioAccessFamily; import android.telephony.ModemActivityInfo; +import com.android.internal.telephony.CellNetworkScanResult; +import com.android.internal.telephony.OperatorInfo; import java.util.List; @@ -679,6 +681,23 @@ interface ITelephony { void setNetworkSelectionModeAutomatic(int subId); /** + * Perform a radio scan and return the list of avialble networks. + * + * @param subId the id of the subscription. + * @return CellNetworkScanResult containing status of scan and networks. + */ + CellNetworkScanResult getCellNetworkScanResults(int subId); + + /** + * Ask the radio to connect to the input network and change selection mode to manual. + * + * @param subId the id of the subscription. + * @param operatorInfo the operator to attach to. + * @return true if the request suceeded. + */ + boolean setNetworkSelectionModeManual(int subId, in OperatorInfo operator); + + /** * Set the preferred network type. * Used for device configuration by some CDMA operators. * @@ -917,7 +936,6 @@ interface ITelephony { * @return {@code true} if the device supports hearing aid compatibility. */ boolean isHearingAidCompatibilitySupported(); - /** * Get IMS Registration Status */ diff --git a/telephony/java/com/android/internal/telephony/OperatorInfo.java b/telephony/java/com/android/internal/telephony/OperatorInfo.java new file mode 100644 index 0000000..a29d7c1 --- /dev/null +++ b/telephony/java/com/android/internal/telephony/OperatorInfo.java @@ -0,0 +1,160 @@ +/* + * Copyright (C) 2006 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.android.internal.telephony; + +import android.os.Parcel; +import android.os.Parcelable; + +/** + * {@hide} + */ +public class OperatorInfo implements Parcelable { + public enum State { + UNKNOWN, + AVAILABLE, + CURRENT, + FORBIDDEN; + } + + private String mOperatorAlphaLong; + private String mOperatorAlphaShort; + private String mOperatorNumeric; + + private State mState = State.UNKNOWN; + + + public String + getOperatorAlphaLong() { + return mOperatorAlphaLong; + } + + public String + getOperatorAlphaShort() { + return mOperatorAlphaShort; + } + + public String + getOperatorNumeric() { + return mOperatorNumeric; + } + + public State + getState() { + return mState; + } + + OperatorInfo(String operatorAlphaLong, + String operatorAlphaShort, + String operatorNumeric, + State state) { + + mOperatorAlphaLong = operatorAlphaLong; + mOperatorAlphaShort = operatorAlphaShort; + mOperatorNumeric = operatorNumeric; + + mState = state; + } + + + public OperatorInfo(String operatorAlphaLong, + String operatorAlphaShort, + String operatorNumeric, + String stateString) { + this (operatorAlphaLong, operatorAlphaShort, + operatorNumeric, rilStateToState(stateString)); + } + + public OperatorInfo(String operatorAlphaLong, + String operatorAlphaShort, + String operatorNumeric) { + this(operatorAlphaLong, operatorAlphaShort, operatorNumeric, State.UNKNOWN); + } + + /** + * See state strings defined in ril.h RIL_REQUEST_QUERY_AVAILABLE_NETWORKS + */ + private static State rilStateToState(String s) { + if (s.equals("unknown")) { + return State.UNKNOWN; + } else if (s.equals("available")) { + return State.AVAILABLE; + } else if (s.equals("current")) { + return State.CURRENT; + } else if (s.equals("forbidden")) { + return State.FORBIDDEN; + } else { + throw new RuntimeException( + "RIL impl error: Invalid network state '" + s + "'"); + } + } + + + @Override + public String toString() { + return "OperatorInfo " + mOperatorAlphaLong + + "/" + mOperatorAlphaShort + + "/" + mOperatorNumeric + + "/" + mState; + } + + /** + * Parcelable interface implemented below. + * This is a simple effort to make OperatorInfo parcelable rather than + * trying to make the conventional containing object (AsyncResult), + * implement parcelable. This functionality is needed for the + * NetworkQueryService to fix 1128695. + */ + + @Override + public int describeContents() { + return 0; + } + + /** + * Implement the Parcelable interface. + * Method to serialize a OperatorInfo object. + */ + @Override + public void writeToParcel(Parcel dest, int flags) { + dest.writeString(mOperatorAlphaLong); + dest.writeString(mOperatorAlphaShort); + dest.writeString(mOperatorNumeric); + dest.writeSerializable(mState); + } + + /** + * Implement the Parcelable interface + * Method to deserialize a OperatorInfo object, or an array thereof. + */ + public static final Creator<OperatorInfo> CREATOR = + new Creator<OperatorInfo>() { + @Override + public OperatorInfo createFromParcel(Parcel in) { + OperatorInfo opInfo = new OperatorInfo( + in.readString(), /*operatorAlphaLong*/ + in.readString(), /*operatorAlphaShort*/ + in.readString(), /*operatorNumeric*/ + (State) in.readSerializable()); /*state*/ + return opInfo; + } + + @Override + public OperatorInfo[] newArray(int size) { + return new OperatorInfo[size]; + } + }; +} |