Loading telephony/java/android/telephony/TelephonyManager.java +51 −0 Original line number Diff line number Diff line Loading @@ -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; Loading Loading @@ -3432,6 +3434,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. Loading telephony/java/com/android/internal/telephony/CellNetworkScanResult.aidl 0 → 100644 +19 −0 Original line number Diff line number Diff line /* ** 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; telephony/java/com/android/internal/telephony/CellNetworkScanResult.java 0 → 100644 +125 −0 Original line number Diff line number Diff line /* ** 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]; } }; } telephony/java/com/android/internal/telephony/ITelephony.aidl +19 −1 Original line number Diff line number Diff line Loading @@ -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; Loading Loading @@ -678,6 +680,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. Loading Loading @@ -917,7 +936,6 @@ interface ITelephony { * @return {@code true} if the device supports hearing aid compatibility. */ boolean isHearingAidCompatibilitySupported(); /** * Get IMS Registration Status */ Loading telephony/java/com/android/internal/telephony/OperatorInfo.java 0 → 100644 +160 −0 Original line number Diff line number Diff line /* * 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]; } }; } Loading
telephony/java/android/telephony/TelephonyManager.java +51 −0 Original line number Diff line number Diff line Loading @@ -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; Loading Loading @@ -3432,6 +3434,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. Loading
telephony/java/com/android/internal/telephony/CellNetworkScanResult.aidl 0 → 100644 +19 −0 Original line number Diff line number Diff line /* ** 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;
telephony/java/com/android/internal/telephony/CellNetworkScanResult.java 0 → 100644 +125 −0 Original line number Diff line number Diff line /* ** 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]; } }; }
telephony/java/com/android/internal/telephony/ITelephony.aidl +19 −1 Original line number Diff line number Diff line Loading @@ -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; Loading Loading @@ -678,6 +680,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. Loading Loading @@ -917,7 +936,6 @@ interface ITelephony { * @return {@code true} if the device supports hearing aid compatibility. */ boolean isHearingAidCompatibilitySupported(); /** * Get IMS Registration Status */ Loading
telephony/java/com/android/internal/telephony/OperatorInfo.java 0 → 100644 +160 −0 Original line number Diff line number Diff line /* * 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]; } }; }