diff options
Diffstat (limited to 'telephony/java/android/telephony')
-rw-r--r-- | telephony/java/android/telephony/DisconnectCause.java | 166 | ||||
-rw-r--r-- | telephony/java/android/telephony/PhoneNumberUtils.java | 118 | ||||
-rwxr-xr-x[-rw-r--r--] | telephony/java/android/telephony/RadioAccessFamily.java | 24 | ||||
-rw-r--r-- | telephony/java/android/telephony/ServiceState.java | 19 | ||||
-rw-r--r-- | telephony/java/android/telephony/SignalStrength.java | 35 | ||||
-rw-r--r-- | telephony/java/android/telephony/SubscriptionInfo.java | 22 | ||||
-rw-r--r-- | telephony/java/android/telephony/SubscriptionManager.java | 88 | ||||
-rw-r--r-- | telephony/java/android/telephony/TelephonyManager.java | 118 |
8 files changed, 546 insertions, 44 deletions
diff --git a/telephony/java/android/telephony/DisconnectCause.java b/telephony/java/android/telephony/DisconnectCause.java index 8443490..1821f30 100644 --- a/telephony/java/android/telephony/DisconnectCause.java +++ b/telephony/java/android/telephony/DisconnectCause.java @@ -187,6 +187,68 @@ public class DisconnectCause { */ public static final int CDMA_ALREADY_ACTIVATED = 49; + /** call failed due to LTE to 3G/2G handover not feasible */ + public static final int HO_NOT_FEASIBLE = 50; + + public static final int NO_CIRCUIT_AVAIL = 51; + public static final int NO_ROUTE_TO_DESTINAON = 52; + public static final int OPERATOR_DETERMINED_BARRING = 53; + public static final int CALL_FAIL_NO_USER_RESPONDING = 54; + public static final int CALL_FAIL_NO_ANSWER_FROM_USER = 55; + public static final int CALL_FAIL_DESTINATION_OUT_OF_ORDER = 56; + public static final int BEARER_CAPABILITY_NOT_AUTHORIZED = 57; + public static final int CHANNEL_UNACCEPTABLE = 58; + public static final int CALL_REJECTED = 59; + public static final int NUMBER_CHANGED = 60; + public static final int PREEMPTION = 61; + public static final int FACILITY_REJECTED = 62; + public static final int RESP_TO_STATUS_ENQUIRY = 63; + public static final int NORMAL_UNSPECIFIED = 64; + public static final int NETWORK_OUT_OF_ORDER = 65; + public static final int TEMPORARY_FAILURE = 66; + public static final int SWITCHING_EQUIPMENT_CONGESTION = 67; + public static final int ACCESS_INFORMATION_DISCARDED = 68; + public static final int REQUESTED_CIRCUIT_OR_CHANNEL_NOT_AVAILABLE = 69; + public static final int RESOURCES_UNAVAILABLE_OR_UNSPECIFIED = 70; + public static final int QOS_UNAVAILABLE = 71; + public static final int REQUESTED_FACILITY_NOT_SUBSCRIBED = 72; + public static final int INCOMING_CALLS_BARRED_WITHIN_CUG = 73; + public static final int BEARER_CAPABILITY_UNAVAILABLE = 74; + public static final int SERVICE_OPTION_NOT_AVAILABLE = 75; + public static final int BEARER_SERVICE_NOT_IMPLEMENTED = 76; + public static final int REQUESTED_FACILITY_NOT_IMPLEMENTED = 77; + public static final int ONLY_DIGITAL_INFORMATION_BEARER_AVAILABLE = 78; + public static final int SERVICE_OR_OPTION_NOT_IMPLEMENTED = 79; + public static final int INVALID_TRANSACTION_IDENTIFIER = 80; + public static final int USER_NOT_MEMBER_OF_CUG = 81; + public static final int INCOMPATIBLE_DESTINATION = 82; + public static final int INVALID_TRANSIT_NW_SELECTION = 83; + public static final int SEMANTICALLY_INCORRECT_MESSAGE = 84; + public static final int INVALID_MANDATORY_INFORMATION = 85; + public static final int MESSAGE_TYPE_NON_IMPLEMENTED = 86; + public static final int MESSAGE_TYPE_NOT_COMPATIBLE_WITH_PROTOCOL_STATE = 87; + public static final int INFORMATION_ELEMENT_NON_EXISTENT = 88; + public static final int CONDITIONAL_IE_ERROR = 89; + public static final int MESSAGE_NOT_COMPATIBLE_WITH_PROTOCOL_STATE = 90; + public static final int RECOVERY_ON_TIMER_EXPIRED = 91; + public static final int PROTOCOL_ERROR_UNSPECIFIED = 92; + public static final int INTERWORKING_UNSPECIFIED = 93; + public static final int LOCAL_LOW_BATTERY = 94; + public static final int LOW_BATTERY = 95; + + /** EMERGENCY call failed with temporary fail cause */ + public static final int EMERGENCY_TEMP_FAILURE = 96; + /** EMERGENCY call failed with permanent fail cause */ + public static final int EMERGENCY_PERM_FAILURE = 97; + + public static final int NON_SELECTED_USER_CLEARING = 98; + + /** + * Call was rejected due to number being blacklisted by user. + * {@@hide} + */ + public static final int CALL_BLACKLISTED = 400; + //********************************************************************************************* // When adding a disconnect type: // 1) Please assign the new type the next id value below. @@ -195,14 +257,14 @@ public class DisconnectCause { // 4) Update toString() with the newly added disconnect type. // 5) Update android.telecom.DisconnectCauseUtil with any mappings to a telecom.DisconnectCause. // - // NextId: 50 + // NextId: 99 //********************************************************************************************* /** Smallest valid value for call disconnect codes. */ public static final int MINIMUM_VALID_VALUE = NOT_DISCONNECTED; /** Largest valid value for call disconnect codes. */ - public static final int MAXIMUM_VALID_VALUE = CDMA_ALREADY_ACTIVATED; + public static final int MAXIMUM_VALID_VALUE = CALL_BLACKLISTED; /** Private constructor to avoid class instantiation. */ private DisconnectCause() { @@ -310,6 +372,106 @@ public class DisconnectCause { return "IMS_MERGED_SUCCESSFULLY"; case CDMA_ALREADY_ACTIVATED: return "CDMA_ALREADY_ACTIVATED"; + case NON_SELECTED_USER_CLEARING: + return "NON_SELECTED_USER_CLEARING"; + case HO_NOT_FEASIBLE: + return "HO_NOT_FEASIBLE"; + case NO_CIRCUIT_AVAIL: + return "NO_CIRCUIT_AVAIL"; + case NO_ROUTE_TO_DESTINAON: + return "NO_ROUTE_TO_DESTINAON"; + case OPERATOR_DETERMINED_BARRING: + return "OPERATOR_DETERMINED_BARRING"; + case CALL_FAIL_NO_USER_RESPONDING: + return "CALL_FAIL_NO_USER_RESPONDING"; + case CALL_FAIL_NO_ANSWER_FROM_USER: + return "CALL_FAIL_NO_ANSWER_FROM_USER"; + case CALL_FAIL_DESTINATION_OUT_OF_ORDER: + return "CALL_FAIL_DESTINATION_OUT_OF_ORDER"; + case BEARER_CAPABILITY_NOT_AUTHORIZED: + return "BEARER_CAPABILITY_NOT_AUTHORIZED"; + case CHANNEL_UNACCEPTABLE: + return "CHANNEL_UNACCEPTABLE"; + case CALL_REJECTED: + return "CALL_REJECTED"; + case NUMBER_CHANGED: + return "NUMBER_CHANGED"; + case PREEMPTION: + return "PREEMPTION"; + case FACILITY_REJECTED: + return "FACILITY_REJECTED"; + case RESP_TO_STATUS_ENQUIRY: + return "RESP_TO_STATUS_ENQUIRY"; + case NORMAL_UNSPECIFIED: + return "NORMAL_UNSPECIFIED"; + case NETWORK_OUT_OF_ORDER: + return "NETWORK_OUT_OF_ORDER"; + case TEMPORARY_FAILURE: + return "TEMPORARY_FAILURE"; + case SWITCHING_EQUIPMENT_CONGESTION: + return "SWITCHING_EQUIPMENT_CONGESTION"; + case ACCESS_INFORMATION_DISCARDED: + return "ACCESS_INFORMATION_DISCARDED"; + case REQUESTED_CIRCUIT_OR_CHANNEL_NOT_AVAILABLE: + return "REQUESTED_CIRCUIT_OR_CHANNEL_NOT_AVAILABLE"; + case RESOURCES_UNAVAILABLE_OR_UNSPECIFIED: + return "RESOURCES_UNAVAILABLE_OR_UNSPECIFIED"; + case QOS_UNAVAILABLE: + return "QOS_UNAVAILABLE"; + case REQUESTED_FACILITY_NOT_SUBSCRIBED: + return "REQUESTED_FACILITY_NOT_SUBSCRIBED"; + case INCOMING_CALLS_BARRED_WITHIN_CUG: + return "INCOMING_CALLS_BARRED_WITHIN_CUG"; + case BEARER_CAPABILITY_UNAVAILABLE: + return "BEARER_CAPABILITY_UNAVAILABLE"; + case SERVICE_OPTION_NOT_AVAILABLE: + return "SERVICE_OPTION_NOT_AVAILABLE"; + case BEARER_SERVICE_NOT_IMPLEMENTED: + return "BEARER_SERVICE_NOT_IMPLEMENTED"; + case REQUESTED_FACILITY_NOT_IMPLEMENTED: + return "REQUESTED_FACILITY_NOT_IMPLEMENTED"; + case ONLY_DIGITAL_INFORMATION_BEARER_AVAILABLE: + return "ONLY_DIGITAL_INFORMATION_BEARER_AVAILABLE"; + case SERVICE_OR_OPTION_NOT_IMPLEMENTED: + return "SERVICE_OR_OPTION_NOT_IMPLEMENTED"; + case INVALID_TRANSACTION_IDENTIFIER: + return "INVALID_TRANSACTION_IDENTIFIER"; + case USER_NOT_MEMBER_OF_CUG: + return "USER_NOT_MEMBER_OF_CUG"; + case INCOMPATIBLE_DESTINATION: + return "INCOMPATIBLE_DESTINATION"; + case INVALID_TRANSIT_NW_SELECTION: + return "INVALID_TRANSIT_NW_SELECTION"; + case SEMANTICALLY_INCORRECT_MESSAGE: + return "SEMANTICALLY_INCORRECT_MESSAGE"; + case INVALID_MANDATORY_INFORMATION: + return "INVALID_MANDATORY_INFORMATION"; + case MESSAGE_TYPE_NON_IMPLEMENTED: + return "MESSAGE_TYPE_NON_IMPLEMENTED"; + case MESSAGE_TYPE_NOT_COMPATIBLE_WITH_PROTOCOL_STATE: + return "MESSAGE_TYPE_NOT_COMPATIBLE_WITH_PROTOCOL_STATE"; + case INFORMATION_ELEMENT_NON_EXISTENT: + return "INFORMATION_ELEMENT_NON_EXISTENT"; + case CONDITIONAL_IE_ERROR: + return "CONDITIONAL_IE_ERROR"; + case MESSAGE_NOT_COMPATIBLE_WITH_PROTOCOL_STATE: + return "MESSAGE_NOT_COMPATIBLE_WITH_PROTOCOL_STATE"; + case RECOVERY_ON_TIMER_EXPIRED: + return "RECOVERY_ON_TIMER_EXPIRED"; + case PROTOCOL_ERROR_UNSPECIFIED: + return "PROTOCOL_ERROR_UNSPECIFIED"; + case INTERWORKING_UNSPECIFIED: + return "INTERWORKING_UNSPECIFIED"; + case LOCAL_LOW_BATTERY: + return "LOCAL_LOW_BATTERY"; + case LOW_BATTERY: + return "LOW_BATTERY"; + case EMERGENCY_TEMP_FAILURE: + return "EMERGENCY_TEMP_FAILURE"; + case EMERGENCY_PERM_FAILURE: + return "EMERGENCY_PERM_FAILURE"; + case CALL_BLACKLISTED: + return "CALL_BLACKLISTED"; default: return "INVALID: " + cause; } diff --git a/telephony/java/android/telephony/PhoneNumberUtils.java b/telephony/java/android/telephony/PhoneNumberUtils.java index b430340..5ee1fb2 100644 --- a/telephony/java/android/telephony/PhoneNumberUtils.java +++ b/telephony/java/android/telephony/PhoneNumberUtils.java @@ -16,6 +16,7 @@ package android.telephony; +import android.util.SparseArray; import com.android.i18n.phonenumbers.NumberParseException; import com.android.i18n.phonenumbers.PhoneNumberUtil; import com.android.i18n.phonenumbers.PhoneNumberUtil.PhoneNumberFormat; @@ -25,6 +26,7 @@ import com.android.i18n.phonenumbers.ShortNumberUtil; import android.content.Context; import android.content.Intent; import android.database.Cursor; +import android.location.Country; import android.location.CountryDetector; import android.net.Uri; import android.os.SystemProperties; @@ -77,6 +79,7 @@ public class PhoneNumberUtils static final String LOG_TAG = "PhoneNumberUtils"; private static final boolean DBG = false; + private static Country sCountryDetector = null; /* * global-phone-number = ["+"] 1*( DIGIT / written-sep ) * written-sep = ("-"/".") @@ -139,6 +142,55 @@ public class PhoneNumberUtils return !isDialable(ch) && !(('a' <= ch && ch <= 'z') || ('A' <= ch && ch <= 'Z')); } + /** + * On some CDMA networks +COUNTRYCODE must be rewritten to 0 when making a local + * call from within the user's home network. We maintain a white list of + * (country code prefix) -> (rewrite rule) to perform this substitution. + * + * Since country codes are variable length it is easiest to compile a regex + */ + private static SparseArray<RewriteRule> sCdmaLocalRewriteWhitelist; + private static Pattern sCdmaLocalRewritePattern; + static { + sCdmaLocalRewriteWhitelist = new SparseArray<RewriteRule>(); + addRewriteRule(62, "ID", "0"); // indonesia + addRewriteRule(380, "UA", "0"); // ukraine + + StringBuffer regex = new StringBuffer(); + regex.append("[+]("); + for (int i=0; i < sCdmaLocalRewriteWhitelist.size(); ++i) { + int countryCode = sCdmaLocalRewriteWhitelist.keyAt(i); + if (i > 0) { + regex.append("|"); + } + regex.append(countryCode); + } + regex.append(")"); + sCdmaLocalRewritePattern = Pattern.compile(regex.toString()); + } + + private static class RewriteRule { + public int countryCodePrefix; + public String isoCountryCode; + public String replacement; + + public RewriteRule(int countryCodePrefix, String isoCountryCode, String replacement) { + this.countryCodePrefix = countryCodePrefix; + this.isoCountryCode = isoCountryCode; + this.replacement = replacement; + } + + public String apply(String dialStr) { + return dialStr.replaceFirst("[+]" + countryCodePrefix, replacement); + } + } + + private static void addRewriteRule(int countryCodePrefix, + String isoCountryCode, String replacement) { + sCdmaLocalRewriteWhitelist.put(countryCodePrefix, + new RewriteRule(countryCodePrefix, isoCountryCode, replacement)); + } + /** Extracts the phone number from an Intent. * * @param intent the intent to get the number of @@ -2057,12 +2109,9 @@ public class PhoneNumberUtils private static boolean isLocalEmergencyNumberInternal(int subId, String number, Context context, boolean useExactMatch) { - String countryIso; - CountryDetector detector = (CountryDetector) context.getSystemService( - Context.COUNTRY_DETECTOR); - if (detector != null && detector.detectCountry() != null) { - countryIso = detector.detectCountry().getCountryIso(); - } else { + String countryIso = getCountryIso(context); + Rlog.w(LOG_TAG, "isLocalEmergencyNumberInternal" + countryIso); + if (countryIso == null) { Locale locale = context.getResources().getConfiguration().locale; countryIso = locale.getCountry(); Rlog.w(LOG_TAG, "No CountryDetector; falling back to countryIso based on locale: " @@ -2071,6 +2120,28 @@ public class PhoneNumberUtils return isEmergencyNumberInternal(subId, number, countryIso, useExactMatch); } + private static String getCountryIso(Context context) { + Rlog.w(LOG_TAG, "getCountryIso " + sCountryDetector); + if (sCountryDetector == null) { + CountryDetector detector = (CountryDetector) context.getSystemService( + Context.COUNTRY_DETECTOR); + if (detector != null) { + sCountryDetector = detector.detectCountry(); + } + } + + if (sCountryDetector == null) { + return null; + } else { + return sCountryDetector.getCountryIso(); + } + } + + /** @hide */ + public static void resetCountryDetectorInfo() { + sCountryDetector = null; + } + /** * isVoiceMailNumber: checks a given number against the voicemail * number provided by the RIL and SIM card. The caller must have @@ -2560,6 +2631,29 @@ public class PhoneNumberUtils } /** + * Returns a rewrite rule for the country code prefix if the dial string matches the + * whitelist and the user is in their home network + * + * @param dialStr number being dialed + * @param currIso ISO code of currently attached network + * @param defaultIso ISO code of user's sim + * @return RewriteRule or null if conditions fail + */ + private static RewriteRule getCdmaLocalRewriteRule(String dialStr, + String currIso, String defaultIso) { + Matcher m = sCdmaLocalRewritePattern.matcher(dialStr); + if (m.find()) { + String dialPrefix = m.group(1); + RewriteRule rule = sCdmaLocalRewriteWhitelist.get(Integer.valueOf(dialPrefix)); + if (currIso.equalsIgnoreCase(defaultIso) && + currIso.equalsIgnoreCase(rule.isoCountryCode)) { + return rule; + } + } + return null; + } + + /** * Determines if the specified number is actually a URI * (i.e. a SIP address) rather than a regular PSTN phone number, * based on whether or not the number contains an "@" character. @@ -2622,8 +2716,16 @@ public class PhoneNumberUtils // Remove the leading plus sign retStr = newStr; } else { - // Replaces the plus sign with the default IDP - retStr = networkDialStr.replaceFirst("[+]", getCurrentIdp(useNanp)); + RewriteRule rewriteRule = + getCdmaLocalRewriteRule(networkDialStr, + TelephonyManager.getDefault().getNetworkCountryIso(), + TelephonyManager.getDefault().getSimCountryIso()); + if (rewriteRule != null) { + retStr = rewriteRule.apply(networkDialStr); + } else { + // Replaces the plus sign with the default IDP + retStr = networkDialStr.replaceFirst("[+]", getCurrentIdp(useNanp)); + } } } if (DBG) log("processPlusCode, retStr=" + retStr); diff --git a/telephony/java/android/telephony/RadioAccessFamily.java b/telephony/java/android/telephony/RadioAccessFamily.java index 2bfaf1b..2906a2d 100644..100755 --- a/telephony/java/android/telephony/RadioAccessFamily.java +++ b/telephony/java/android/telephony/RadioAccessFamily.java @@ -47,6 +47,7 @@ public class RadioAccessFamily implements Parcelable { public static final int RAF_HSPAP = (1 << ServiceState.RIL_RADIO_TECHNOLOGY_HSPAP); public static final int RAF_GSM = (1 << ServiceState.RIL_RADIO_TECHNOLOGY_GSM); public static final int RAF_TD_SCDMA = (1 << ServiceState.RIL_RADIO_TECHNOLOGY_TD_SCDMA); + public static final int RAF_LTE_CA = (1 << ServiceState.RIL_RADIO_TECHNOLOGY_LTE_CA); // Grouping of RAFs private static final int GSM = RAF_GSM | RAF_GPRS | RAF_EDGE; @@ -54,6 +55,7 @@ public class RadioAccessFamily implements Parcelable { private static final int CDMA = RAF_IS95A | RAF_IS95B | RAF_1xRTT; private static final int EVDO = RAF_EVDO_0 | RAF_EVDO_A | RAF_EVDO_B | RAF_EHRPD; private static final int WCDMA = HS | RAF_UMTS; + private static final int LTE = RAF_LTE | RAF_LTE_CA; /* Phone ID of phone */ private int mPhoneId; @@ -162,19 +164,19 @@ public class RadioAccessFamily implements Parcelable { raf = CDMA | EVDO; break; case RILConstants.NETWORK_MODE_LTE_CDMA_EVDO: - raf = RAF_LTE | CDMA | EVDO; + raf = LTE | CDMA | EVDO; break; case RILConstants.NETWORK_MODE_LTE_GSM_WCDMA: - raf = RAF_LTE | GSM | WCDMA; + raf = LTE | GSM | WCDMA; break; case RILConstants.NETWORK_MODE_LTE_CDMA_EVDO_GSM_WCDMA: - raf = RAF_LTE | CDMA | EVDO | GSM | WCDMA; + raf = LTE | CDMA | EVDO | GSM | WCDMA; break; case RILConstants.NETWORK_MODE_LTE_ONLY: - raf = RAF_LTE; + raf = LTE; break; case RILConstants.NETWORK_MODE_LTE_WCDMA: - raf = RAF_LTE | WCDMA; + raf = LTE | WCDMA; break; case RILConstants.NETWORK_MODE_CDMA_NO_EVDO: raf = CDMA; @@ -232,6 +234,7 @@ public class RadioAccessFamily implements Parcelable { raf = ((WCDMA & raf) > 0) ? (WCDMA | raf) : raf; raf = ((CDMA & raf) > 0) ? (CDMA | raf) : raf; raf = ((EVDO & raf) > 0) ? (EVDO | raf) : raf; + raf = ((LTE & raf) > 0) ? (LTE | raf) : raf; return raf; } @@ -254,19 +257,19 @@ public class RadioAccessFamily implements Parcelable { case (CDMA | EVDO): type = RILConstants.NETWORK_MODE_CDMA; break; - case (RAF_LTE | CDMA | EVDO): + case (LTE | CDMA | EVDO): type = RILConstants.NETWORK_MODE_LTE_CDMA_EVDO; break; - case (RAF_LTE | GSM | WCDMA): + case (LTE | GSM | WCDMA): type = RILConstants.NETWORK_MODE_LTE_GSM_WCDMA; break; - case (RAF_LTE | CDMA | EVDO | GSM | WCDMA): + case (LTE | CDMA | EVDO | GSM | WCDMA): type = RILConstants.NETWORK_MODE_LTE_CDMA_EVDO_GSM_WCDMA; break; - case RAF_LTE: + case LTE: type = RILConstants.NETWORK_MODE_LTE_ONLY; break; - case (RAF_LTE | WCDMA): + case (LTE | WCDMA): type = RILConstants.NETWORK_MODE_LTE_WCDMA; break; case CDMA: @@ -339,6 +342,7 @@ public class RadioAccessFamily implements Parcelable { case "CDMA": return CDMA; case "EVDO": return EVDO; case "WCDMA": return WCDMA; + case "LTE_CA": return RAF_LTE_CA; default: return RAF_UNKNOWN; } } diff --git a/telephony/java/android/telephony/ServiceState.java b/telephony/java/android/telephony/ServiceState.java index 1337487..d411376 100644 --- a/telephony/java/android/telephony/ServiceState.java +++ b/telephony/java/android/telephony/ServiceState.java @@ -154,6 +154,12 @@ public class ServiceState implements Parcelable { */ public static final int RIL_RADIO_TECHNOLOGY_IWLAN = 18; /** + * LTE_CA + * @hide + */ + public static final int RIL_RADIO_TECHNOLOGY_LTE_CA = 19; + + /** * Available registration states for GSM, UMTS and CDMA. */ /** @hide */ @@ -728,11 +734,14 @@ public class ServiceState implements Parcelable { case RIL_RADIO_TECHNOLOGY_GSM: rtString = "GSM"; break; + case RIL_RADIO_TECHNOLOGY_TD_SCDMA: + rtString = "TD-SCDMA"; + break; case RIL_RADIO_TECHNOLOGY_IWLAN: rtString = "IWLAN"; break; - case RIL_RADIO_TECHNOLOGY_TD_SCDMA: - rtString = "TD-SCDMA"; + case RIL_RADIO_TECHNOLOGY_LTE_CA: + rtString = "LTE_CA"; break; default: rtString = "Unexpected"; @@ -1075,6 +1084,8 @@ public class ServiceState implements Parcelable { return TelephonyManager.NETWORK_TYPE_TD_SCDMA; case ServiceState.RIL_RADIO_TECHNOLOGY_IWLAN: return TelephonyManager.NETWORK_TYPE_IWLAN; + case ServiceState.RIL_RADIO_TECHNOLOGY_LTE_CA: + return TelephonyManager.NETWORK_TYPE_LTE_CA; default: return TelephonyManager.NETWORK_TYPE_UNKNOWN; } @@ -1126,7 +1137,9 @@ public class ServiceState implements Parcelable { || radioTechnology == RIL_RADIO_TECHNOLOGY_HSPAP || radioTechnology == RIL_RADIO_TECHNOLOGY_GSM || radioTechnology == RIL_RADIO_TECHNOLOGY_TD_SCDMA - || radioTechnology == RIL_RADIO_TECHNOLOGY_IWLAN; + || radioTechnology == RIL_RADIO_TECHNOLOGY_IWLAN + || radioTechnology == RIL_RADIO_TECHNOLOGY_LTE_CA; + } /** @hide */ diff --git a/telephony/java/android/telephony/SignalStrength.java b/telephony/java/android/telephony/SignalStrength.java index fced667..997b6ff 100644 --- a/telephony/java/android/telephony/SignalStrength.java +++ b/telephony/java/android/telephony/SignalStrength.java @@ -19,6 +19,7 @@ package android.telephony; import android.os.Bundle; import android.os.Parcel; import android.os.Parcelable; +import android.os.SystemProperties; import android.telephony.Rlog; import android.content.res.Resources; @@ -52,6 +53,7 @@ public class SignalStrength implements Parcelable { public static final int INVALID = 0x7FFFFFFF; private static final int RSRP_THRESH_TYPE_STRICT = 0; + private static final int RSRP_THRESH_TYPE_CUSTOM = 2; private static final int[] RSRP_THRESH_STRICT = new int[] {-140, -115, -105, -95, -85, -44}; private static final int[] RSRP_THRESH_LENIENT = new int[] {-140, -128, -118, -108, -98, -44}; @@ -146,11 +148,10 @@ public class SignalStrength implements Parcelable { int cdmaDbm, int cdmaEcio, int evdoDbm, int evdoEcio, int evdoSnr, int lteSignalStrength, int lteRsrp, int lteRsrq, int lteRssnr, int lteCqi, - int tdScdmaRscp, boolean gsmFlag) { + boolean gsmFlag) { initialize(gsmSignalStrength, gsmBitErrorRate, cdmaDbm, cdmaEcio, evdoDbm, evdoEcio, evdoSnr, lteSignalStrength, lteRsrp, lteRsrq, lteRssnr, lteCqi, gsmFlag); - mTdScdmaRscp = tdScdmaRscp; } /** @@ -162,10 +163,11 @@ public class SignalStrength implements Parcelable { int cdmaDbm, int cdmaEcio, int evdoDbm, int evdoEcio, int evdoSnr, int lteSignalStrength, int lteRsrp, int lteRsrq, int lteRssnr, int lteCqi, - boolean gsmFlag) { + int tdScdmaRscp, boolean gsmFlag) { initialize(gsmSignalStrength, gsmBitErrorRate, cdmaDbm, cdmaEcio, evdoDbm, evdoEcio, evdoSnr, lteSignalStrength, lteRsrp, lteRsrq, lteRssnr, lteCqi, gsmFlag); + mTdScdmaRscp = tdScdmaRscp; } /** @@ -398,11 +400,12 @@ public class SignalStrength implements Parcelable { mLteSignalStrength = (mLteSignalStrength >= 0) ? mLteSignalStrength : 99; mLteRsrp = ((mLteRsrp >= 44) && (mLteRsrp <= 140)) ? -mLteRsrp : SignalStrength.INVALID; mLteRsrq = ((mLteRsrq >= 3) && (mLteRsrq <= 20)) ? -mLteRsrq : SignalStrength.INVALID; - mLteRssnr = ((mLteRssnr >= -200) && (mLteRssnr <= 300)) ? mLteRssnr + mLteRssnr = ((mLteRssnr >= -200) && (mLteRssnr <= 300) && !(mLteRsrq == SignalStrength.INVALID && mLteRssnr == -1)) ? mLteRssnr : SignalStrength.INVALID; mTdScdmaRscp = ((mTdScdmaRscp >= 25) && (mTdScdmaRscp <= 120)) ? -mTdScdmaRscp : SignalStrength.INVALID; + // Cqi no change if (DBG) log("Signal after validate=" + this); } @@ -494,6 +497,16 @@ public class SignalStrength implements Parcelable { return mLteCqi; } + /** @hide */ + public boolean needsOldRilFeature(String feature) { + String[] features = SystemProperties.get("ro.telephony.ril.config", "").split(","); + for (String found: features) { + if (found.equals(feature)) + return true; + } + return false; + } + /** * Retrieve an abstract level value for the overall signal strength. * @@ -506,8 +519,9 @@ public class SignalStrength implements Parcelable { int level = 0; if (isGsm) { + boolean oldRil = needsOldRilFeature("signalstrength"); level = getLteLevel(); - if (level == SIGNAL_STRENGTH_NONE_OR_UNKNOWN) { + if (level == SIGNAL_STRENGTH_NONE_OR_UNKNOWN || oldRil) { level = getTdScdmaLevel(); if (level == SIGNAL_STRENGTH_NONE_OR_UNKNOWN) { level = getGsmLevel(); @@ -539,7 +553,8 @@ public class SignalStrength implements Parcelable { public int getAsuLevel() { int asuLevel = 0; if (isGsm) { - if (getLteLevel() == SIGNAL_STRENGTH_NONE_OR_UNKNOWN) { + boolean oldRil = needsOldRilFeature("signalstrength"); + if (getLteLevel() == SIGNAL_STRENGTH_NONE_OR_UNKNOWN || oldRil) { if (getTdScdmaLevel() == SIGNAL_STRENGTH_NONE_OR_UNKNOWN) { asuLevel = getGsmAsuLevel(); } else { @@ -575,8 +590,9 @@ public class SignalStrength implements Parcelable { int dBm = INVALID; if(isGsm()) { + boolean oldRil = needsOldRilFeature("signalstrength"); dBm = getLteDbm(); - if (dBm == INVALID) { + if (dBm == INVALID || oldRil) { if (getTdScdmaLevel() == SIGNAL_STRENGTH_NONE_OR_UNKNOWN) { dBm = getGsmDbm(); } else { @@ -796,6 +812,9 @@ public class SignalStrength implements Parcelable { int[] threshRsrp; if (rsrpThreshType == RSRP_THRESH_TYPE_STRICT) { threshRsrp = RSRP_THRESH_STRICT; + } else if (rsrpThreshType == RSRP_THRESH_TYPE_CUSTOM) { + threshRsrp = Resources.getSystem().getIntArray(com.android.internal.R.array. + config_LTE_RSRP_custom_levels); } else { threshRsrp = RSRP_THRESH_LENIENT; } @@ -933,7 +952,7 @@ public class SignalStrength implements Parcelable { return tdScdmaAsuLevel; } - /** + /** * @return hash code */ @Override diff --git a/telephony/java/android/telephony/SubscriptionInfo.java b/telephony/java/android/telephony/SubscriptionInfo.java index d1d6e0d..5e5b70d 100644 --- a/telephony/java/android/telephony/SubscriptionInfo.java +++ b/telephony/java/android/telephony/SubscriptionInfo.java @@ -111,9 +111,14 @@ public class SubscriptionInfo implements Parcelable { /** * @hide */ + public int mUserNwMode; + + /** + * @hide + */ public SubscriptionInfo(int id, String iccId, int simSlotIndex, CharSequence displayName, CharSequence carrierName, int nameSource, int iconTint, String number, int roaming, - Bitmap icon, int mcc, int mnc, String countryIso) { + Bitmap icon, int mcc, int mnc, String countryIso, int userNwMode) { this.mId = id; this.mIccId = iccId; this.mSimSlotIndex = simSlotIndex; @@ -126,6 +131,7 @@ public class SubscriptionInfo implements Parcelable { this.mIconBitmap = icon; this.mMcc = mcc; this.mMnc = mnc; + this.mUserNwMode = userNwMode; this.mCountryIso = countryIso; } @@ -277,6 +283,14 @@ public class SubscriptionInfo implements Parcelable { } /** + * Returns the User set Network mode. + * @hide + */ + public int getUserNwMode() { + return this.mUserNwMode; + } + + /** * @return the ISO country code */ public String getCountryIso() { @@ -297,11 +311,12 @@ public class SubscriptionInfo implements Parcelable { int dataRoaming = source.readInt(); int mcc = source.readInt(); int mnc = source.readInt(); + int userNwMode = source.readInt(); String countryIso = source.readString(); Bitmap iconBitmap = Bitmap.CREATOR.createFromParcel(source); return new SubscriptionInfo(id, iccId, simSlotIndex, displayName, carrierName, - nameSource, iconTint, number, dataRoaming, iconBitmap, mcc, mnc, countryIso); + nameSource, iconTint, number, dataRoaming, iconBitmap, mcc, mnc, countryIso, userNwMode); } @Override @@ -323,6 +338,7 @@ public class SubscriptionInfo implements Parcelable { dest.writeInt(mDataRoaming); dest.writeInt(mMcc); dest.writeInt(mMnc); + dest.writeInt(mUserNwMode); dest.writeString(mCountryIso); mIconBitmap.writeToParcel(dest, flags); } @@ -354,6 +370,6 @@ public class SubscriptionInfo implements Parcelable { + " displayName=" + mDisplayName + " carrierName=" + mCarrierName + " nameSource=" + mNameSource + " iconTint=" + mIconTint + " dataRoaming=" + mDataRoaming + " iconBitmap=" + mIconBitmap + " mcc " + mMcc - + " mnc " + mMnc + "}"; + + " mnc " + mMnc + " mUserNwMode=" + mUserNwMode + "}"; } } diff --git a/telephony/java/android/telephony/SubscriptionManager.java b/telephony/java/android/telephony/SubscriptionManager.java index 32b7383..86021e0 100644 --- a/telephony/java/android/telephony/SubscriptionManager.java +++ b/telephony/java/android/telephony/SubscriptionManager.java @@ -121,6 +121,39 @@ public class SubscriptionManager { public static final int SIM_NOT_INSERTED = -1; /** + * The Network mode of SIM/sub. + * <P>Type: INTEGER (int)</P> + */ + /** @hide */ + public static final String NETWORK_MODE = "network_mode"; + + /** + * The user configured Network mode of SIM/sub. + * <P>Type: INTEGER (int)</P> + * {@hide} + */ + public static final String USER_NETWORK_MODE = "user_network_mode"; + + /** @hide */ + public static final int DEFAULT_NW_MODE = -1; + + /** + * The activation state of SIM/sub. + * <P>Type: INTEGER (int)</P> + */ + /** @hide */ + public static final String SUB_STATE = "sub_state"; + + /** @hide */ + public static final int INACTIVE = 0; + + /** @hide */ + public static final int ACTIVE = 1; + + /** @hide */ + public static final int SUB_CONFIGURATION_IN_PROGRESS = 2; + + /** * TelephonyProvider column name for user displayed name. * <P>Type: TEXT (String)</P> */ @@ -310,6 +343,14 @@ public class SubscriptionManager { */ public static final String CB_CHANNEL_50_ALERT = "enable_channel_50_alerts"; + + + /** + * TelephonyProvider column name for enable channel60 alert in CB settings + *@hide + */ + public static final String CB_CHANNEL_60_ALERT = "enable_channel_60_alerts"; + /** * TelephonyProvider column name for CMAS test alert in CB settings *@hide @@ -1118,6 +1159,53 @@ public class SubscriptionManager { } /** @hide */ + public static void activateSubId(int subId) { + logd("activateSubId sub id = " + subId); + try { + getISubInfo().activateSubId(subId); + } catch (RemoteException ex) { + return; + } + } + + /** @hide */ + public static void deactivateSubId(int subId) { + logd("deactivateSubId sub id = " + subId); + try { + getISubInfo().deactivateSubId(subId); + } catch (RemoteException ex) { + return; + } + } + + /** @hide */ + public static int getSubState(int subId) { + logd("getSubState sub id = " + subId); + try { + return getISubInfo().getSubState(subId); + } catch (RemoteException ex) { + return INACTIVE; + } + } + + /** @hide */ + public static int setSubState(int subId, int subState) { + logd("setSubState sub id = " + subId + " state = " + subState); + try { + return getISubInfo().setSubState(subId, subState); + } catch (RemoteException ex) { + return INACTIVE; + } + } + + /** + @hide + */ + private static ISub getISubInfo() { + return ISub.Stub.asInterface(ServiceManager.getService("isub")); + } + + /** @hide */ public static void putPhoneIdAndSubIdExtra(Intent intent, int phoneId) { int[] subIds = SubscriptionManager.getSubId(phoneId); if (subIds != null && subIds.length > 0) { diff --git a/telephony/java/android/telephony/TelephonyManager.java b/telephony/java/android/telephony/TelephonyManager.java index 2e25ec7..12c039e 100644 --- a/telephony/java/android/telephony/TelephonyManager.java +++ b/telephony/java/android/telephony/TelephonyManager.java @@ -1,4 +1,7 @@ /* + * Copyright (c) 2014, The Linux Foundation. All rights reserved. + * Not a Contribution. + * * Copyright (C) 2008 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); @@ -18,10 +21,12 @@ package android.telephony; import android.annotation.Nullable; import android.annotation.SystemApi; +import android.Manifest; import android.annotation.SdkConstant; import android.annotation.SdkConstant.SdkConstantType; import android.app.ActivityThread; import android.content.ContentResolver; +import android.app.AppOpsManager; import android.content.Context; import android.content.Intent; import android.provider.Settings; @@ -31,6 +36,7 @@ import android.os.RemoteException; import android.os.ServiceManager; import android.os.SystemProperties; import android.telecom.PhoneAccount; +import android.text.TextUtils; import android.util.Log; import com.android.internal.telecom.ITelecomService; @@ -45,6 +51,7 @@ import com.android.internal.telephony.TelephonyProperties; import java.io.FileInputStream; import java.io.IOException; +import java.util.ArrayList; import java.util.List; import java.util.regex.Matcher; import java.util.regex.Pattern; @@ -644,6 +651,11 @@ public class TelephonyManager { */ public static final String VVM_TYPE_CVVM = "vvm_type_cvvm"; + /** + * @hide + */ + public static final String EXTRA_IS_FORWARDED = "is_forwarded"; + // // // Device Info @@ -721,6 +733,7 @@ public class TelephonyManager { * @param slotId of which deviceID is returned */ public String getDeviceId(int slotId) { + android.util.SeempLog.record_str(8, ""+slotId); // FIXME this assumes phoneId == slotId try { IPhoneSubInfo info = getSubscriberInfo(); @@ -817,6 +830,7 @@ public class TelephonyManager { * {@link android.Manifest.permission#ACCESS_COARSE_LOCATION ACCESS_FINE_LOCATION}. */ public CellLocation getCellLocation() { + android.util.SeempLog.record(49); try { ITelephony telephony = getITelephony(); if (telephony == null) { @@ -914,6 +928,7 @@ public class TelephonyManager { */ @Deprecated public List<NeighboringCellInfo> getNeighboringCellInfo() { + android.util.SeempLog.record(50); try { ITelephony telephony = getITelephony(); if (telephony == null) @@ -1164,6 +1179,15 @@ public class TelephonyManager { return retVal; } + /** + * Return if the current radio is LTE on GSM + * @hide + */ + public static int getLteOnGsmModeStatic() { + return SystemProperties.getInt(TelephonyProperties.PROPERTY_LTE_ON_GSM_DEVICE, + 0); + } + // // // Current Network @@ -1340,11 +1364,12 @@ public class TelephonyManager { public static final int NETWORK_TYPE_HSPAP = 15; /** Current network is GSM {@hide} */ public static final int NETWORK_TYPE_GSM = 16; - /** Current network is TD_SCDMA {@hide} */ + /** Current network is TD_SCDMA {@hide} */ public static final int NETWORK_TYPE_TD_SCDMA = 17; /** Current network is IWLAN {@hide} */ public static final int NETWORK_TYPE_IWLAN = 18; - + /** Current network is LTE_CA {@hide} */ + public static final int NETWORK_TYPE_LTE_CA = 19; /** * @return the NETWORK_TYPE_xxxx for current data connection. */ @@ -1389,10 +1414,12 @@ public class TelephonyManager { * @see #NETWORK_TYPE_LTE * @see #NETWORK_TYPE_EHRPD * @see #NETWORK_TYPE_HSPAP + * @see #NETWORK_TYPE_TD_SCDMA * * <p> * Requires Permission: * {@link android.Manifest.permission#READ_PHONE_STATE READ_PHONE_STATE} + * @hide */ /** {@hide} */ public int getNetworkType(int subId) { @@ -1512,6 +1539,21 @@ public class TelephonyManager { } } + /** + * Returns the icc operator numeric for a given subId + * + */ + /** {@hide} */ + public String getIccOperatorNumericForData(int subId) { + try{ + return getITelephony().getIccOperatorNumericForData(subId); + } catch (RemoteException ex) { + return null; + } catch (NullPointerException ex) { + return null; + } + } + /** Unknown network class. {@hide} */ public static final int NETWORK_CLASS_UNKNOWN = 0; /** Class of broadly defined "2G" networks. {@hide} */ @@ -1549,6 +1591,7 @@ public class TelephonyManager { return NETWORK_CLASS_3_G; case NETWORK_TYPE_LTE: case NETWORK_TYPE_IWLAN: + case NETWORK_TYPE_LTE_CA: return NETWORK_CLASS_4_G; default: return NETWORK_CLASS_UNKNOWN; @@ -1612,6 +1655,8 @@ public class TelephonyManager { return "TD_SCDMA"; case NETWORK_TYPE_IWLAN: return "IWLAN"; + case NETWORK_TYPE_LTE_CA: + return "LTE_CA"; default: return "UNKNOWN"; } @@ -1917,6 +1962,7 @@ public class TelephonyManager { */ /** {@hide} */ public String getSimSerialNumber(int subId) { + android.util.SeempLog.record_str(388, ""+subId); try { IPhoneSubInfo info = getSubscriberInfo(); if (info == null) @@ -1977,6 +2023,21 @@ public class TelephonyManager { } } + /** + * Return if the current radio is LTE on GSM + * @hide + */ + public int getLteOnGsmMode() { + try { + return getITelephony().getLteOnGsmMode(); + } catch (RemoteException ex) { + return 0; + } catch (NullPointerException ex) { + // This could happen before phone restarts due to crashing + return 0; + } + } + // // // Subscriber Info @@ -2006,6 +2067,7 @@ public class TelephonyManager { */ /** {@hide} */ public String getSubscriberId(int subId) { + android.util.SeempLog.record_str(389, ""+subId); try { IPhoneSubInfo info = getSubscriberInfo(); if (info == null) @@ -2094,6 +2156,7 @@ public class TelephonyManager { */ /** {@hide} */ public String getLine1NumberForSubscriber(int subId) { + android.util.SeempLog.record_str(9, ""+subId); String number = null; try { ITelephony telephony = getITelephony(); @@ -2891,6 +2954,40 @@ public class TelephonyManager { } /** + * Allows an application to add a protected sms address if the application has + * been granted the permission MODIFY_PROTECTED_SMS_LIST. + * @param address + * @hide + */ + public void addProtectedSmsAddress(String address) { + mContext.enforceCallingOrSelfPermission( + Manifest.permission.MODIFY_PROTECTED_SMS_LIST, null); + try { + getITelephony().addProtectedSmsAddress(address); + } catch (RemoteException ex) { + } catch (NullPointerException ex) { + } + } + + /** + * Allows an application to revoke/remove a protected sms address if the application has been + * granted the permission MODIFY_PROTECTED_SMS_LIST. + * @param address + * @return true if address is successfully removed + * @hide + */ + public boolean revokeProtectedSmsAddress(String address) { + mContext.enforceCallingOrSelfPermission( + Manifest.permission.MODIFY_PROTECTED_SMS_LIST, null); + try { + return getITelephony().revokeProtectedSmsAddress(address); + } catch (RemoteException ex) { + } catch (NullPointerException ex) { + } + return false; + } + + /** * Returns the MMS user agent. */ public String getMmsUserAgent() { @@ -3356,13 +3453,7 @@ public class TelephonyManager { /** @hide */ public int getSimCount() { - // FIXME Need to get it from Telephony Dev Controller when that gets implemented! - // and then this method shouldn't be used at all! - if(isMultiSimEnabled()) { - return 2; - } else { - return 1; - } + return getPhoneCount(); } /** @@ -4158,11 +4249,18 @@ public class TelephonyManager { public void setDataEnabled(int subId, boolean enable) { try { Log.d(TAG, "setDataEnabled: enabled=" + enable); + AppOpsManager appOps = (AppOpsManager)mContext.getSystemService(Context.APP_OPS_SERVICE); + if (enable) { + if (appOps.noteOp(AppOpsManager.OP_DATA_CONNECT_CHANGE) != AppOpsManager.MODE_ALLOWED) { + Log.w(TAG, "Permission denied by user."); + return; + } + } ITelephony telephony = getITelephony(); if (telephony != null) telephony.setDataEnabled(subId, enable); } catch (RemoteException e) { - Log.e(TAG, "Error calling ITelephony#setDataEnabled", e); + Log.e(TAG, "Error calling setDataEnabled", e); } } |