diff options
Diffstat (limited to 'telephony/java/android/telephony')
-rw-r--r-- | telephony/java/android/telephony/CarrierConfigManager.java | 4 | ||||
-rw-r--r-- | telephony/java/android/telephony/DisconnectCause.java | 66 | ||||
-rw-r--r-- | telephony/java/android/telephony/PhoneNumberUtils.java | 119 | ||||
-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 | 31 | ||||
-rw-r--r-- | telephony/java/android/telephony/TelephonyManager.java | 116 |
7 files changed, 336 insertions, 43 deletions
diff --git a/telephony/java/android/telephony/CarrierConfigManager.java b/telephony/java/android/telephony/CarrierConfigManager.java index aa4da4b..94bf4eb 100644 --- a/telephony/java/android/telephony/CarrierConfigManager.java +++ b/telephony/java/android/telephony/CarrierConfigManager.java @@ -502,7 +502,7 @@ public class CarrierConfigManager { sDefaults.putBoolean(KEY_OPERATOR_SELECTION_EXPAND_BOOL, true); sDefaults.putBoolean(KEY_PREFER_2G_BOOL, true); sDefaults.putBoolean(KEY_SHOW_APN_SETTING_CDMA_BOOL, false); - sDefaults.putBoolean(KEY_SHOW_CDMA_CHOICES_BOOL, false); + sDefaults.putBoolean(KEY_SHOW_CDMA_CHOICES_BOOL, true); sDefaults.putBoolean(KEY_SHOW_ONSCREEN_DIAL_BUTTON_BOOL, true); sDefaults.putBoolean(KEY_SIM_NETWORK_UNLOCK_ALLOW_DISMISS_BOOL, true); sDefaults.putBoolean(KEY_SUPPORT_PAUSE_IMS_VIDEO_CALLS_BOOL, true); @@ -511,7 +511,7 @@ public class CarrierConfigManager { sDefaults.putBoolean(KEY_USE_OTASP_FOR_PROVISIONING_BOOL, false); sDefaults.putBoolean(KEY_VOICEMAIL_NOTIFICATION_PERSISTENT_BOOL, false); sDefaults.putBoolean(KEY_VOICE_PRIVACY_DISABLE_UI_BOOL, false); - sDefaults.putBoolean(KEY_WORLD_PHONE_BOOL, false); + sDefaults.putBoolean(KEY_WORLD_PHONE_BOOL, true); sDefaults.putBoolean(KEY_REQUIRE_ENTITLEMENT_CHECKS_BOOL, true); sDefaults.putInt(KEY_VOLTE_REPLACEMENT_RAT_INT, 0); sDefaults.putString(KEY_DEFAULT_SIM_CALL_MANAGER_STRING, ""); diff --git a/telephony/java/android/telephony/DisconnectCause.java b/telephony/java/android/telephony/DisconnectCause.java index 8443490..e2e8326 100644 --- a/telephony/java/android/telephony/DisconnectCause.java +++ b/telephony/java/android/telephony/DisconnectCause.java @@ -187,6 +187,15 @@ 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; + + /** + * 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 +204,63 @@ 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: 51 //********************************************************************************************* /** 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 = HO_NOT_FEASIBLE; + public static final int NO_CIRCUIT_AVAIL = 48; + public static final int NO_ROUTE_TO_DESTINAON = 49; + public static final int OPERATOR_DETERMINED_BARRING = 50; + public static final int CALL_FAIL_NO_USER_RESPONDING = 51; + public static final int CALL_FAIL_NO_ANSWER_FROM_USER = 52; + public static final int CALL_FAIL_DESTINATION_OUT_OF_ORDER = 53; + public static final int BEARER_CAPABILITY_NOT_AUTHORIZED = 54; + public static final int CHANNEL_UNACCEPTABLE = 55; + public static final int CALL_REJECTED = 56; + public static final int NUMBER_CHANGED = 57; + public static final int PREEMPTION = 58; + public static final int FACILITY_REJECTED = 59; + public static final int RESP_TO_STATUS_ENQUIRY = 60; + public static final int NORMAL_UNSPECIFIED = 61; + public static final int NETWORK_OUT_OF_ORDER = 62; + public static final int TEMPORARY_FAILURE = 63; + public static final int SWITCHING_EQUIPMENT_CONGESTION = 64; + public static final int ACCESS_INFORMATION_DISCARDED = 65; + public static final int REQUESTED_CIRCUIT_OR_CHANNEL_NOT_AVAILABLE = 66; + public static final int RESOURCES_UNAVAILABLE_OR_UNSPECIFIED = 67; + public static final int QOS_UNAVAILABLE = 68; + public static final int REQUESTED_FACILITY_NOT_SUBSCRIBED = 69; + public static final int INCOMING_CALLS_BARRED_WITHIN_CUG = 70; + public static final int BEARER_CAPABILITY_UNAVAILABLE = 71; + public static final int SERVICE_OPTION_NOT_AVAILABLE = 72; + public static final int BEARER_SERVICE_NOT_IMPLEMENTED = 73; + public static final int REQUESTED_FACILITY_NOT_IMPLEMENTED = 74; + public static final int ONLY_DIGITAL_INFORMATION_BEARER_AVAILABLE = 75; + public static final int SERVICE_OR_OPTION_NOT_IMPLEMENTED = 76; + public static final int INVALID_TRANSACTION_IDENTIFIER = 77; + public static final int USER_NOT_MEMBER_OF_CUG = 78; + public static final int INCOMPATIBLE_DESTINATION = 79; + public static final int INVALID_TRANSIT_NW_SELECTION = 80; + public static final int SEMANTICALLY_INCORRECT_MESSAGE = 81; + public static final int INVALID_MANDATORY_INFORMATION = 82; + public static final int MESSAGE_TYPE_NON_IMPLEMENTED = 83; + public static final int MESSAGE_TYPE_NOT_COMPATIBLE_WITH_PROTOCOL_STATE = 84; + public static final int INFORMATION_ELEMENT_NON_EXISTENT = 85; + public static final int CONDITIONAL_IE_ERROR = 86; + public static final int MESSAGE_NOT_COMPATIBLE_WITH_PROTOCOL_STATE = 87; + public static final int RECOVERY_ON_TIMER_EXPIRED = 88; + public static final int PROTOCOL_ERROR_UNSPECIFIED = 89; + public static final int INTERWORKING_UNSPECIFIED = 90; + public static final int LOCAL_LOW_BATTERY = 91; + public static final int LOW_BATTERY = 92; + /** EMERGENCY call failed with temporary fail cause */ + public static final int EMERGENCY_TEMP_FAILURE = 93; + /** EMERGENCY call failed with permanent fail cause */ + public static final int EMERGENCY_PERM_FAILURE = 94; /** Private constructor to avoid class instantiation. */ private DisconnectCause() { @@ -310,6 +368,10 @@ public class DisconnectCause { return "IMS_MERGED_SUCCESSFULLY"; case CDMA_ALREADY_ACTIVATED: return "CDMA_ALREADY_ACTIVATED"; + case HO_NOT_FEASIBLE: + return "HO_NOT_FEASIBLE"; + 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..4b37cdb 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 @@ -148,6 +200,7 @@ public class PhoneNumberUtils * <code>null</code> if the number cannot be found. */ public static String getNumberFromIntent(Intent intent, Context context) { + android.util.SeempLog.record(12); String number = null; Uri uri = intent.getData(); @@ -2057,12 +2110,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 +2121,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 +2632,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 +2717,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 f535e5d..c941a28 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; @@ -146,11 +147,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 +162,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 +399,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 +496,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 +518,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 +552,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 +589,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 { @@ -933,7 +948,7 @@ public class SignalStrength implements Parcelable { return tdScdmaAsuLevel; } - /** + /** * @return hash code */ @Override diff --git a/telephony/java/android/telephony/TelephonyManager.java b/telephony/java/android/telephony/TelephonyManager.java index 47f13c9..dd86830 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; @@ -699,6 +706,7 @@ public class TelephonyManager { * {@link android.Manifest.permission#READ_PHONE_STATE READ_PHONE_STATE} */ public String getDeviceId() { + android.util.SeempLog.record(9); try { ITelephony telephony = getITelephony(); if (telephony == null) @@ -721,6 +729,7 @@ public class TelephonyManager { * @param slotId of which deviceID is returned */ public String getDeviceId(int slotId) { + android.util.SeempLog.record(9); // FIXME this assumes phoneId == slotId try { IPhoneSubInfo info = getSubscriberInfo(); @@ -817,6 +826,7 @@ public class TelephonyManager { * {@link android.Manifest.permission#ACCESS_COARSE_LOCATION ACCESS_FINE_LOCATION}. */ public CellLocation getCellLocation() { + android.util.SeempLog.record(66); try { ITelephony telephony = getITelephony(); if (telephony == null) { @@ -914,6 +924,7 @@ public class TelephonyManager { */ @Deprecated public List<NeighboringCellInfo> getNeighboringCellInfo() { + android.util.SeempLog.record(67); try { ITelephony telephony = getITelephony(); if (telephony == null) @@ -1164,6 +1175,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 +1360,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 +1410,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 +1535,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 +1587,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 +1651,8 @@ public class TelephonyManager { return "TD_SCDMA"; case NETWORK_TYPE_IWLAN: return "IWLAN"; + case NETWORK_TYPE_LTE_CA: + return "LTE_CA"; default: return "UNKNOWN"; } @@ -1904,6 +1945,7 @@ public class TelephonyManager { * {@link android.Manifest.permission#READ_PHONE_STATE READ_PHONE_STATE} */ public String getSimSerialNumber() { + android.util.SeempLog.record(10); return getSimSerialNumber(getDefaultSubscription()); } @@ -1917,6 +1959,7 @@ public class TelephonyManager { */ /** {@hide} */ public String getSimSerialNumber(int subId) { + android.util.SeempLog.record(10); try { IPhoneSubInfo info = getSubscriberInfo(); if (info == null) @@ -1977,6 +2020,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 @@ -1991,6 +2049,7 @@ public class TelephonyManager { * {@link android.Manifest.permission#READ_PHONE_STATE READ_PHONE_STATE} */ public String getSubscriberId() { + android.util.SeempLog.record(114); return getSubscriberId(getDefaultSubscription()); } @@ -2006,6 +2065,7 @@ public class TelephonyManager { */ /** {@hide} */ public String getSubscriberId(int subId) { + android.util.SeempLog.record(114); try { IPhoneSubInfo info = getSubscriberInfo(); if (info == null) @@ -2076,6 +2136,7 @@ public class TelephonyManager { * The default SMS app can also use this. */ public String getLine1Number() { + android.util.SeempLog.record(11); return getLine1NumberForSubscriber(getDefaultSubscription()); } @@ -2888,6 +2949,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() { @@ -3353,13 +3448,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(); } /** @@ -4155,11 +4244,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); } } |