diff options
Diffstat (limited to 'telephony/java/android')
11 files changed, 397 insertions, 43 deletions
diff --git a/telephony/java/android/telephony/CellInfo.java b/telephony/java/android/telephony/CellInfo.java index bfa0942..b5e4eef 100644 --- a/telephony/java/android/telephony/CellInfo.java +++ b/telephony/java/android/telephony/CellInfo.java @@ -76,7 +76,7 @@ public abstract class CellInfo implements Parcelable { return mRegistered; } /** @hide */ - public void setRegisterd(boolean registered) { + public void setRegistered(boolean registered) { mRegistered = registered; } diff --git a/telephony/java/android/telephony/CellLocation.java b/telephony/java/android/telephony/CellLocation.java index 42c2aff..f9a222f 100644 --- a/telephony/java/android/telephony/CellLocation.java +++ b/telephony/java/android/telephony/CellLocation.java @@ -19,9 +19,6 @@ package android.telephony; import android.os.Bundle; import android.os.RemoteException; import android.os.ServiceManager; -import android.os.SystemProperties; -import android.provider.Settings; - import android.telephony.cdma.CdmaCellLocation; import android.telephony.gsm.GsmCellLocation; diff --git a/telephony/java/android/telephony/CellSignalStrength.java b/telephony/java/android/telephony/CellSignalStrength.java index 3b470fc..9c23f78 100644 --- a/telephony/java/android/telephony/CellSignalStrength.java +++ b/telephony/java/android/telephony/CellSignalStrength.java @@ -16,9 +16,6 @@ package android.telephony; -import android.os.Parcel; -import android.os.Parcelable; - /** * Abstract base class for cell phone signal strength related information. */ diff --git a/telephony/java/android/telephony/CellSignalStrengthCdma.java b/telephony/java/android/telephony/CellSignalStrengthCdma.java index 46d09f6..be13acc 100644 --- a/telephony/java/android/telephony/CellSignalStrengthCdma.java +++ b/telephony/java/android/telephony/CellSignalStrengthCdma.java @@ -137,7 +137,6 @@ public final class CellSignalStrengthCdma extends CellSignalStrength implements /** * Get the signal level as an asu value between 0..97, 99 is unknown - * Asu is calculated based on 3GPP RSRP. Refer to 3GPP 27.007 (Ver 10.3.0) Sec 8.69 */ @Override public int getAsuLevel() { @@ -342,7 +341,7 @@ public final class CellSignalStrengthCdma extends CellSignalStrength implements /** * Construct a SignalStrength object from the given parcel - * where the TYPE_LTE token is already been processed. + * where the TYPE_CDMA token is already been processed. */ private CellSignalStrengthCdma(Parcel in) { // CdmaDbm, CdmaEcio, EvdoDbm and EvdoEcio are written into diff --git a/telephony/java/android/telephony/DataConnectionRealTimeInfo.aidl b/telephony/java/android/telephony/DataConnectionRealTimeInfo.aidl new file mode 100644 index 0000000..70fbb11 --- /dev/null +++ b/telephony/java/android/telephony/DataConnectionRealTimeInfo.aidl @@ -0,0 +1,20 @@ +/* +** +** Copyright 2007, 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 android.telephony; + +parcelable DataConnectionRealTimeInfo; diff --git a/telephony/java/android/telephony/DataConnectionRealTimeInfo.java b/telephony/java/android/telephony/DataConnectionRealTimeInfo.java new file mode 100644 index 0000000..4a9ae39 --- /dev/null +++ b/telephony/java/android/telephony/DataConnectionRealTimeInfo.java @@ -0,0 +1,138 @@ +/* + * Copyright (C) 2014 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 android.telephony; + +import android.os.Parcel; +import android.os.Parcelable; + +/** + * Data connection real time information + * + * TODO: How to handle multiple subscriptions? + */ +public class DataConnectionRealTimeInfo implements Parcelable { + private long mTime; // Time the info was collected since boot in nanos; + + public static int DC_POWER_STATE_LOW = 1; + public static int DC_POWER_STATE_MEDIUM = 2; + public static int DC_POWER_STATE_HIGH = 3; + public static int DC_POWER_STATE_UNKNOWN = Integer.MAX_VALUE; + + private int mDcPowerState; // DC_POWER_STATE_[LOW | MEDIUM | HIGH | UNKNOWN] + + /** + * Constructor + * + * @hide + */ + public DataConnectionRealTimeInfo(long time, int dcPowerState) { + mTime = time; + mDcPowerState = dcPowerState; + } + + /** + * Constructor + * + * @hide + */ + public DataConnectionRealTimeInfo() { + mTime = Long.MAX_VALUE; + mDcPowerState = DC_POWER_STATE_UNKNOWN; + } + + /** + * Construct a PreciseCallState object from the given parcel. + */ + private DataConnectionRealTimeInfo(Parcel in) { + mTime = in.readLong(); + mDcPowerState = in.readInt(); + } + + /** + * @return time the information was collected or Long.MAX_VALUE if unknown + */ + public long getTime() { + return mTime; + } + + /** + * @return DC_POWER_STATE_[LOW | MEDIUM | HIGH | UNKNOWN] + */ + public int getDcPowerState() { + return mDcPowerState; + } + + @Override + public int describeContents() { + return 0; + } + + @Override + public void writeToParcel(Parcel out, int flags) { + out.writeLong(mTime); + out.writeInt(mDcPowerState); + } + + public static final Parcelable.Creator<DataConnectionRealTimeInfo> CREATOR + = new Parcelable.Creator<DataConnectionRealTimeInfo>() { + + @Override + public DataConnectionRealTimeInfo createFromParcel(Parcel in) { + return new DataConnectionRealTimeInfo(in); + } + + @Override + public DataConnectionRealTimeInfo[] newArray(int size) { + return new DataConnectionRealTimeInfo[size]; + } + }; + + @Override + public int hashCode() { + final long prime = 17; + long result = 1; + result = (prime * result) + mTime; + result += (prime * result) + mDcPowerState; + return (int)result; + } + + @Override + public boolean equals(Object obj) { + if (this == obj) { + return true; + } + if (obj == null) { + return false; + } + if (getClass() != obj.getClass()) { + return false; + } + DataConnectionRealTimeInfo other = (DataConnectionRealTimeInfo) obj; + return (mTime == other.mTime) + && (mDcPowerState == other.mDcPowerState); + } + + @Override + public String toString() { + StringBuffer sb = new StringBuffer(); + + sb.append("mTime=").append(mTime); + sb.append(" mDcPowerState=").append(mDcPowerState); + + return sb.toString(); + } +} diff --git a/telephony/java/android/telephony/PhoneNumberFormattingTextWatcher.java b/telephony/java/android/telephony/PhoneNumberFormattingTextWatcher.java index 983c349..438b572 100644 --- a/telephony/java/android/telephony/PhoneNumberFormattingTextWatcher.java +++ b/telephony/java/android/telephony/PhoneNumberFormattingTextWatcher.java @@ -65,8 +65,6 @@ public class PhoneNumberFormattingTextWatcher implements TextWatcher { * * @param countryCode the ISO 3166-1 two-letter country code that indicates the country/region * where the phone number is being entered. - * - * @hide */ public PhoneNumberFormattingTextWatcher(String countryCode) { if (countryCode == null) throw new IllegalArgumentException(); diff --git a/telephony/java/android/telephony/PhoneNumberUtils.java b/telephony/java/android/telephony/PhoneNumberUtils.java index e3a1aa6..c79e9bf 100644 --- a/telephony/java/android/telephony/PhoneNumberUtils.java +++ b/telephony/java/android/telephony/PhoneNumberUtils.java @@ -1143,6 +1143,8 @@ public class PhoneNumberUtils * @param source The phone number to format * @return A locally acceptable formatting of the input, or the raw input if * formatting rules aren't known for the number + * + * @deprecated Use {@link #formatNumber(String phoneNumber, String defaultCountryIso)} instead */ public static String formatNumber(String source) { SpannableStringBuilder text = new SpannableStringBuilder(source); @@ -1159,7 +1161,8 @@ public class PhoneNumberUtils * not begin with +[country_code] * @return The phone number formatted with the given formatting type. * - * @hide TODO: Should be unhidden. + * @hide + * @deprecated Use {@link #formatNumber(String phoneNumber, String defaultCountryIso)} instead */ public static String formatNumber(String source, int defaultFormattingType) { SpannableStringBuilder text = new SpannableStringBuilder(source); @@ -1173,6 +1176,8 @@ public class PhoneNumberUtils * @param locale The locale of interest, usually {@link Locale#getDefault()} * @return The formatting type for the given locale, or FORMAT_UNKNOWN if the formatting * rules are not known for the given locale + * + * @deprecated Use {@link #formatNumber(String phoneNumber, String defaultCountryIso)} instead */ public static int getFormatTypeForLocale(Locale locale) { String country = locale.getCountry(); @@ -1187,6 +1192,8 @@ public class PhoneNumberUtils * @param text The number to be formatted, will be modified with the formatting * @param defaultFormattingType The default formatting rules to apply if the number does * not begin with +[country_code] + * + * @deprecated Use {@link #formatNumber(String phoneNumber, String defaultCountryIso)} instead */ public static void formatNumber(Editable text, int defaultFormattingType) { int formatType = defaultFormattingType; @@ -1233,6 +1240,8 @@ public class PhoneNumberUtils * </code></p> * * @param text the number to be formatted, will be modified with the formatting + * + * @deprecated Use {@link #formatNumber(String phoneNumber, String defaultCountryIso)} instead */ public static void formatNanpNumber(Editable text) { int length = text.length(); @@ -1346,6 +1355,8 @@ public class PhoneNumberUtils * * @param text the number to be formatted, will be modified with * the formatting + * + * @deprecated Use {@link #formatNumber(String phoneNumber, String defaultCountryIso)} instead */ public static void formatJapaneseNumber(Editable text) { JapanesePhoneNumberFormatter.format(text); @@ -1382,8 +1393,6 @@ public class PhoneNumberUtils * the ISO 3166-1 two letters country code * @return the E.164 representation, or null if the given phone number is * not valid. - * - * @hide */ public static String formatNumberToE164(String phoneNumber, String defaultCountryIso) { PhoneNumberUtil util = PhoneNumberUtil.getInstance(); @@ -1410,8 +1419,6 @@ public class PhoneNumberUtils * the ISO 3166-1 two letters country code whose convention will * be used if the given number doesn't have the country code. * @return the formatted number, or null if the given number is not valid. - * - * @hide */ public static String formatNumber(String phoneNumber, String defaultCountryIso) { // Do not attempt to format numbers that start with a hash or star symbol. @@ -1446,8 +1453,6 @@ public class PhoneNumberUtils * contains IDD. * @return the formatted number if the given number has been formatted, * otherwise, return the given number. - * - * @hide */ public static String formatNumber( String phoneNumber, String phoneNumberE164, String defaultCountryIso) { @@ -1483,11 +1488,8 @@ public class PhoneNumberUtils * the given number has keypad letters, the letters will be converted to * digits first. * - * @param phoneNumber - * the number to be normalized. + * @param phoneNumber the number to be normalized. * @return the normalized number. - * - * @hide */ public static String normalizeNumber(String phoneNumber) { StringBuilder sb = new StringBuilder(); @@ -1508,12 +1510,10 @@ public class PhoneNumberUtils } /** - * Replace arabic/unicode digits with decimal digits. - * @param number - * the number to be normalized. - * @return the replaced number. + * Replaces all unicode(e.g. Arabic, Persian) digits with their decimal digit equivalents. * - * @hide + * @param number the number to perform the replacement on. + * @return the replaced number. */ public static String replaceUnicodeDigits(String number) { StringBuilder normalizedDigits = new StringBuilder(number.length()); @@ -1737,16 +1737,12 @@ public class PhoneNumberUtils } /** - * Checks if a given number is an emergency number for the country that the user is in. The - * current country is determined using the CountryDetector. + * Checks if a given number is an emergency number for the country that the user is in. * * @param number the number to look up. * @param context the specific context which the number should be checked against - * @return true if the specified number is an emergency number for a local country, based on the - * CountryDetector. - * - * @see android.location.CountryDetector - * @hide + * @return true if the specified number is an emergency number for the country the user + * is currently in. */ public static boolean isLocalEmergencyNumber(String number, Context context) { return isLocalEmergencyNumberInternal(number, @@ -1825,7 +1821,6 @@ public class PhoneNumberUtils * @return true if the number is in the list of voicemail. False * otherwise, including if the caller does not have the permission * to read the VM number. - * @hide TODO: pending API Council approval */ public static boolean isVoiceMailNumber(String number) { String vmNumber; diff --git a/telephony/java/android/telephony/PhoneStateListener.java b/telephony/java/android/telephony/PhoneStateListener.java index 538548d..7c5c648 100644 --- a/telephony/java/android/telephony/PhoneStateListener.java +++ b/telephony/java/android/telephony/PhoneStateListener.java @@ -188,6 +188,17 @@ public class PhoneStateListener { */ public static final int LISTEN_PRECISE_DATA_CONNECTION_STATE = 0x00001000; + /** + * Listen for real time info for all data connections (cellular)). + * {@more} + * Requires Permission: {@link android.Manifest.permission#READ_PRECISE_PHONE_STATE + * READ_PRECISE_PHONE_STATE} + * + * @see #onDataConnectionRealTimeInfoChanged(DataConnectionRealTimeInfo) + * @hide + */ + public static final int LISTEN_DATA_CONNECTION_REAL_TIME_INFO = 0x00002000; + public PhoneStateListener() { } @@ -299,7 +310,7 @@ public class PhoneStateListener { * @param otaspMode is integer <code>OTASP_UNKNOWN=1<code> * means the value is currently unknown and the system should wait until * <code>OTASP_NEEDED=2<code> or <code>OTASP_NOT_NEEDED=3<code> is received before - * making the decisision to perform OTASP or not. + * making the decision to perform OTASP or not. * * @hide */ @@ -335,6 +346,16 @@ public class PhoneStateListener { } /** + * Callback invoked when data connection state changes with precise information. + * + * @hide + */ + public void onDataConnectionRealTimeInfoChanged( + DataConnectionRealTimeInfo dcRtInfo) { + // default implementation empty + } + + /** * The callback methods need to be called on the handler thread where * this object was created. If the binder did that for us it'd be nice. */ @@ -396,6 +417,12 @@ public class PhoneStateListener { Message.obtain(mHandler, LISTEN_PRECISE_DATA_CONNECTION_STATE, 0, 0, dataConnectionState).sendToTarget(); } + + public void onDataConnectionRealTimeInfoChanged( + DataConnectionRealTimeInfo dcRtInfo) { + Message.obtain(mHandler, LISTEN_DATA_CONNECTION_REAL_TIME_INFO, 0, 0, + dcRtInfo).sendToTarget(); + } }; Handler mHandler = new Handler() { @@ -441,6 +468,11 @@ public class PhoneStateListener { break; case LISTEN_PRECISE_DATA_CONNECTION_STATE: PhoneStateListener.this.onPreciseDataConnectionStateChanged((PreciseDataConnectionState)msg.obj); + break; + case LISTEN_DATA_CONNECTION_REAL_TIME_INFO: + PhoneStateListener.this.onDataConnectionRealTimeInfoChanged( + (DataConnectionRealTimeInfo)msg.obj); + break; } } }; diff --git a/telephony/java/android/telephony/Rlog.java b/telephony/java/android/telephony/Rlog.java index 9ac7bda..2a7f7af 100644 --- a/telephony/java/android/telephony/Rlog.java +++ b/telephony/java/android/telephony/Rlog.java @@ -16,13 +16,8 @@ package android.telephony; -import com.android.internal.os.RuntimeInit; - import android.util.Log; -import java.io.PrintWriter; -import java.io.StringWriter; - /** * A class to log strings to the RADIO LOG. * diff --git a/telephony/java/android/telephony/TelephonyManager.java b/telephony/java/android/telephony/TelephonyManager.java index b9a1da4..d5c7caa 100644 --- a/telephony/java/android/telephony/TelephonyManager.java +++ b/telephony/java/android/telephony/TelephonyManager.java @@ -733,7 +733,7 @@ public class TelephonyManager { case RILConstants.NETWORK_MODE_GSM_UMTS: case RILConstants.NETWORK_MODE_LTE_GSM_WCDMA: case RILConstants.NETWORK_MODE_LTE_WCDMA: - case RILConstants.NETWORK_MODE_LTE_CMDA_EVDO_GSM_WCDMA: + case RILConstants.NETWORK_MODE_LTE_CDMA_EVDO_GSM_WCDMA: return PhoneConstants.PHONE_TYPE_GSM; // Use CDMA Phone for the global mode including CDMA @@ -1558,7 +1558,7 @@ public class TelephonyManager { * At registration, and when a specified telephony state * changes, the telephony manager invokes the appropriate * callback method on the listener object and passes the - * current (udpated) values. + * current (updated) values. * <p> * To unregister a listener, pass the listener object and set the * events argument to @@ -1740,6 +1740,189 @@ public class TelephonyManager { com.android.internal.R.string.config_mms_user_agent_profile_url); } + /** + * Opens a logical channel to the ICC card. + * + * Input parameters equivalent to TS 27.007 AT+CCHO command. + * + * @param AID Application id. See ETSI 102.221 and 101.220. + * @return The logical channel id which is negative on error. + */ + public int iccOpenLogicalChannel(String AID) { + try { + return getITelephony().iccOpenLogicalChannel(AID); + } catch (RemoteException ex) { + } catch (NullPointerException ex) { + } + return -1; + } + + /** + * Closes a previously opened logical channel to the ICC card. + * + * Input parameters equivalent to TS 27.007 AT+CCHC command. + * + * @param channel is the channel id to be closed as retruned by a successful + * iccOpenLogicalChannel. + * @return true if the channel was closed successfully. + */ + public boolean iccCloseLogicalChannel(int channel) { + try { + return getITelephony().iccCloseLogicalChannel(channel); + } catch (RemoteException ex) { + } catch (NullPointerException ex) { + } + return false; + } + + /** + * Transmit an APDU to the ICC card over a logical channel. + * + * Input parameters equivalent to TS 27.007 AT+CGLA command. + * + * @param channel is the channel id to be closed as returned by a successful + * iccOpenLogicalChannel. + * @param cla Class of the APDU command. + * @param instruction Instruction of the APDU command. + * @param p1 P1 value of the APDU command. + * @param p2 P2 value of the APDU command. + * @param p3 P3 value of the APDU command. If p3 is negative a 4 byte APDU + * is sent to the SIM. + * @param data Data to be sent with the APDU. + * @return The APDU response from the ICC card with the status appended at + * the end. If an error occurs, an empty string is returned. + */ + public String iccTransmitApduLogicalChannel(int channel, int cla, + int instruction, int p1, int p2, int p3, String data) { + try { + return getITelephony().iccTransmitApduLogicalChannel(channel, cla, + instruction, p1, p2, p3, data); + } catch (RemoteException ex) { + } catch (NullPointerException ex) { + } + return ""; + } + + /** + * Read one of the NV items defined in {@link com.android.internal.telephony.RadioNVItems}. + * Used for device configuration by some CDMA operators. + * + * @param itemID the ID of the item to read. + * @return the NV item as a String, or null on any failure. + * @hide + */ + public String nvReadItem(int itemID) { + try { + return getITelephony().nvReadItem(itemID); + } catch (RemoteException ex) { + Rlog.e(TAG, "nvReadItem RemoteException", ex); + } catch (NullPointerException ex) { + Rlog.e(TAG, "nvReadItem NPE", ex); + } + return ""; + } + + + /** + * Write one of the NV items defined in {@link com.android.internal.telephony.RadioNVItems}. + * Used for device configuration by some CDMA operators. + * + * @param itemID the ID of the item to read. + * @param itemValue the value to write, as a String. + * @return true on success; false on any failure. + * @hide + */ + public boolean nvWriteItem(int itemID, String itemValue) { + try { + return getITelephony().nvWriteItem(itemID, itemValue); + } catch (RemoteException ex) { + Rlog.e(TAG, "nvWriteItem RemoteException", ex); + } catch (NullPointerException ex) { + Rlog.e(TAG, "nvWriteItem NPE", ex); + } + return false; + } + + /** + * Update the CDMA Preferred Roaming List (PRL) in the radio NV storage. + * Used for device configuration by some CDMA operators. + * + * @param preferredRoamingList byte array containing the new PRL. + * @return true on success; false on any failure. + * @hide + */ + public boolean nvWriteCdmaPrl(byte[] preferredRoamingList) { + try { + return getITelephony().nvWriteCdmaPrl(preferredRoamingList); + } catch (RemoteException ex) { + Rlog.e(TAG, "nvWriteCdmaPrl RemoteException", ex); + } catch (NullPointerException ex) { + Rlog.e(TAG, "nvWriteCdmaPrl NPE", ex); + } + return false; + } + + /** + * Perform the specified type of NV config reset. The radio will be taken offline + * and the device must be rebooted after the operation. Used for device + * configuration by some CDMA operators. + * + * @param resetType reset type: 1: reload NV reset, 2: erase NV reset, 3: factory NV reset + * @return true on success; false on any failure. + * @hide + */ + public boolean nvResetConfig(int resetType) { + try { + return getITelephony().nvResetConfig(resetType); + } catch (RemoteException ex) { + Rlog.e(TAG, "nvResetConfig RemoteException", ex); + } catch (NullPointerException ex) { + Rlog.e(TAG, "nvResetConfig NPE", ex); + } + return false; + } + + /** + * Get the preferred network type. + * Used for device configuration by some CDMA operators. + * + * @return the preferred network type, defined in RILConstants.java. + * @hide + */ + public int getPreferredNetworkType() { + try { + return getITelephony().getPreferredNetworkType(); + } catch (RemoteException ex) { + Rlog.e(TAG, "getPreferredNetworkType RemoteException", ex); + } catch (NullPointerException ex) { + Rlog.e(TAG, "getPreferredNetworkType NPE", ex); + } + return -1; + } + + /** + * Set the preferred network type. + * Used for device configuration by some CDMA operators. + * + * @param networkType the preferred network type, defined in RILConstants.java. + * @return true on success; false on any failure. + * @hide + */ + public boolean setPreferredNetworkType(int networkType) { + try { + return getITelephony().setPreferredNetworkType(networkType); + } catch (RemoteException ex) { + Rlog.e(TAG, "setPreferredNetworkType RemoteException", ex); + } catch (NullPointerException ex) { + Rlog.e(TAG, "setPreferredNetworkType NPE", ex); + } + return false; + } + + /** + * Expose the rest of ITelephony to @PrivateApi + */ + /** @hide */ @PrivateApi public void dial(String number) { |