diff options
3 files changed, 166 insertions, 219 deletions
diff --git a/telephony/java/com/android/internal/telephony/ServiceStateTracker.java b/telephony/java/com/android/internal/telephony/ServiceStateTracker.java index c74bb8d..cc13450 100644 --- a/telephony/java/com/android/internal/telephony/ServiceStateTracker.java +++ b/telephony/java/com/android/internal/telephony/ServiceStateTracker.java @@ -28,20 +28,9 @@ import android.telephony.SignalStrength; * {@hide} */ public abstract class ServiceStateTracker extends Handler { + /** - * The access technology currently in use: - * 0 = unknown - * 1 = GPRS only - * 2 = EDGE - * 3 = UMTS - * 4 = IS95A - * 5 = IS95B - * 6 = 1xRTT - * 7 = EvDo_0 - * 8 = EvDo_A - * 9 = HSDPA - * 10 = HSUPA - * 11 = HSPA + * Access technology currently in use. */ protected static final int DATA_ACCESS_UNKNOWN = 0; protected static final int DATA_ACCESS_GPRS = 1; @@ -55,7 +44,6 @@ public abstract class ServiceStateTracker extends Handler { protected static final int DATA_ACCESS_HSDPA = 9; protected static final int DATA_ACCESS_HSUPA = 10; protected static final int DATA_ACCESS_HSPA = 11; - //***** Instance Variables protected CommandsInterface cm; @@ -64,33 +52,36 @@ public abstract class ServiceStateTracker extends Handler { public SignalStrength mSignalStrength; - // Used as a unique identifier to track requests associated with a poll - // and ignore stale responses.The value is a count-down of expected responses - // in this pollingContext + /** + * A unique identifier to track requests associated with a poll + * and ignore stale responses. The value is a count-down of + * expected responses in this pollingContext. + */ protected int[] pollingContext; protected boolean mDesiredPowerState; - protected boolean dontPollSignalStrength = false; // Default is to poll strength - // If we're getting unsolicited signal strength updates from the radio, - // set value to true and don't bother polling any more + /** + * By default, strength polling is enabled. However, if we're + * getting unsolicited signal strength updates from the radio, set + * value to true and don't bother polling any more. + */ + protected boolean dontPollSignalStrength = false; protected RegistrantList networkAttachedRegistrants = new RegistrantList(); protected RegistrantList roamingOnRegistrants = new RegistrantList(); protected RegistrantList roamingOffRegistrants = new RegistrantList(); - //***** Constants - protected static final boolean DBG = true; - // signal strength poll rate + /** Signal strength poll rate. */ protected static final int POLL_PERIOD_MILLIS = 20 * 1000; - // waiting period before recheck gprs and voice registration + /** Waiting period before recheck gprs and voice registration. */ public static final int DEFAULT_GPRS_CHECK_PERIOD_MILLIS = 60 * 1000; public static final int DATA_STATE_POLL_SLEEP_MS = 100; - //*****GSM events + /** GSM events */ protected static final int EVENT_RADIO_STATE_CHANGED = 1; protected static final int EVENT_NETWORK_STATE_CHANGED = 2; protected static final int EVENT_GET_SIGNAL_STRENGTH = 3; @@ -112,7 +103,7 @@ public abstract class ServiceStateTracker extends Handler { protected static final int EVENT_CHECK_REPORT_GPRS = 22; protected static final int EVENT_RESTRICTED_STATE_CHANGED = 23; - //*****CDMA events: + /** CDMA events */ protected static final int EVENT_POLL_STATE_REGISTRATION_CDMA = 24; protected static final int EVENT_POLL_STATE_OPERATOR_CDMA = 25; protected static final int EVENT_RUIM_READY = 26; @@ -129,13 +120,14 @@ public abstract class ServiceStateTracker extends Handler { protected static final int EVENT_OTA_PROVISION_STATUS_CHANGE = 37; protected static final int EVENT_SET_RADIO_POWER_OFF = 38; - //***** Time Zones protected static final String TIMEZONE_PROPERTY = "persist.sys.timezone"; - // List of ISO codes for countries that can have an offset of GMT+0 - // when not in daylight savings time. This ignores some small places - // such as the Canary Islands (Spain) and Danmarkshavn (Denmark). - // The list must be sorted by code. + /** + * List of ISO codes for countries that can have an offset of + * GMT+0 when not in daylight savings time. This ignores some + * small places such as the Canary Islands (Spain) and + * Danmarkshavn (Denmark). The list must be sorted by code. + */ protected static final String[] GMT_COUNTRY_CODES = { "bf", // Burkina Faso "ci", // Cote d'Ivoire @@ -159,11 +151,10 @@ public abstract class ServiceStateTracker extends Handler { "uk", // U.K }; - //***** Registration denied reason + /** Reason for registration denial. */ protected static final String REGISTRATION_DENIED_GEN = "General"; protected static final String REGISTRATION_DENIED_AUTH = "Authentication Failure"; - //***** Constructors public ServiceStateTracker() { } @@ -228,8 +219,6 @@ public abstract class ServiceStateTracker extends Handler { obtainMessage(EVENT_GET_PREFERRED_NETWORK_TYPE, onComplete)); } - - //***** Called from Phone public void setRadioPower(boolean power) { mDesiredPowerState = power; @@ -237,7 +226,6 @@ public abstract class ServiceStateTracker extends Handler { setPowerStateToDesired(); } - public void enableLocationUpdates() { cm.setLocationUpdates(true, obtainMessage(EVENT_LOCATION_UPDATES_ENABLED)); } @@ -246,17 +234,15 @@ public abstract class ServiceStateTracker extends Handler { cm.setLocationUpdates(false, null); } - //***** Overridden from Handler public abstract void handleMessage(Message msg); - //***** Protected abstract Methods protected abstract void handlePollStateResult(int what, AsyncResult ar); protected abstract void updateSpnDisplay(); protected abstract void setPowerStateToDesired(); /** Cancel a pending (if any) pollState() operation */ protected void cancelPollState() { - // This will effectively cancel the rest of the poll requests + // This will effectively cancel the rest of the poll requests. pollingContext = new int[1]; } } diff --git a/telephony/java/com/android/internal/telephony/cdma/CdmaServiceStateTracker.java b/telephony/java/com/android/internal/telephony/cdma/CdmaServiceStateTracker.java index b4de09b..4c958f6 100644 --- a/telephony/java/com/android/internal/telephony/cdma/CdmaServiceStateTracker.java +++ b/telephony/java/com/android/internal/telephony/cdma/CdmaServiceStateTracker.java @@ -41,28 +41,19 @@ import android.util.EventLog; import android.util.Log; import android.util.Config; import android.util.TimeUtils; -import java.util.Calendar; import com.android.internal.telephony.CommandException; import com.android.internal.telephony.CommandsInterface; import com.android.internal.telephony.DataConnectionTracker; -// pretty sure importing stuff from GSM is bad: import com.android.internal.telephony.gsm.MccTable; import com.android.internal.telephony.PhoneProxy; import com.android.internal.telephony.ServiceStateTracker; import com.android.internal.telephony.TelephonyEventLog; import com.android.internal.telephony.TelephonyIntents; - -import static com.android.internal.telephony.TelephonyProperties.PROPERTY_DATA_NETWORK_TYPE; -import static com.android.internal.telephony.TelephonyProperties.PROPERTY_OPERATOR_ALPHA; -import static com.android.internal.telephony.TelephonyProperties.PROPERTY_OPERATOR_ISO_COUNTRY; -import static com.android.internal.telephony.TelephonyProperties.PROPERTY_OPERATOR_ISMANUAL; -import static com.android.internal.telephony.TelephonyProperties.PROPERTY_OPERATOR_ISROAMING; -import static com.android.internal.telephony.TelephonyProperties.PROPERTY_OPERATOR_NUMERIC; -import static com.android.internal.telephony.TelephonyProperties.PROPERTY_ICC_OPERATOR_ALPHA; -import static com.android.internal.telephony.TelephonyProperties.PROPERTY_ICC_OPERATOR_NUMERIC; +import com.android.internal.telephony.TelephonyProperties; import java.util.Arrays; +import java.util.Calendar; import java.util.Date; import java.util.TimeZone; @@ -70,14 +61,14 @@ import java.util.TimeZone; * {@hide} */ final class CdmaServiceStateTracker extends ServiceStateTracker { + static final String LOG_TAG = "CDMA"; - //***** Instance Variables CDMAPhone phone; CdmaCellLocation cellLoc; CdmaCellLocation newCellLoc; /** - * The access technology currently in use: DATA_ACCESS_ + * Values correspond to ServiceStateTracker.DATA_ACCESS_ definitions. */ private int networkType = 0; private int newNetworkType = 0; @@ -87,7 +78,9 @@ final class CdmaServiceStateTracker extends ServiceStateTracker { private boolean mIsInPrl; private int mDefaultRoamingIndicator; - // Initially we assume no data connection + /** + * Initially assume no data connection. + */ private int cdmaDataConnectionState = ServiceState.STATE_OUT_OF_SERVICE; private int newCdmaDataConnectionState = ServiceState.STATE_OUT_OF_SERVICE; private int mRegistrationState = -1; @@ -95,9 +88,11 @@ final class CdmaServiceStateTracker extends ServiceStateTracker { private RegistrantList cdmaDataConnectionDetachedRegistrants = new RegistrantList(); private RegistrantList cdmaForSubscriptionInfoReadyRegistrants = new RegistrantList(); - // Sometimes we get the NITZ time before we know what country we are in. - // Keep the time zone information from the NITZ string so we can fix - // the time zone once know the country. + /** + * Sometimes we get the NITZ time before we know what country we + * are in. Keep the time zone information from the NITZ string so + * we can fix the time zone once know the country. + */ private boolean mNeedFixZone = false; private int mZoneOffset; private boolean mZoneDst; @@ -107,20 +102,23 @@ final class CdmaServiceStateTracker extends ServiceStateTracker { long mSavedTime; long mSavedAtTime; - // We can't register for SIM_RECORDS_LOADED immediately because the - // SIMRecords object may not be instantiated yet. + /** + * We can't register for SIM_RECORDS_LOADED immediately because the + * SIMRecords object may not be instantiated yet. + */ private boolean mNeedToRegForRuimLoaded = false; - // Wake lock used while setting time of day. + /** Wake lock used while setting time of day. */ private PowerManager.WakeLock mWakeLock; private static final String WAKELOCK_TAG = "ServiceStateTracker"; - // Keep track of SPN display rules, so we only broadcast intent if something changes. + /** Track of SPN display rules, so we only broadcast intent if something changes. */ private String curSpn = null; - private String curPlmn = null; // it contains the name of the registered network in CDMA can - // be the ONS or ERI text private int curSpnRule = 0; + /** Contains the name of the registered network in CDMA (either ONS or ERI text). */ + private String curPlmn = null; + private String mMdn; private int mHomeSystemId[] = null; private int mHomeNetworkId[] = null; @@ -133,12 +131,9 @@ final class CdmaServiceStateTracker extends ServiceStateTracker { private boolean mPendingRadioPowerOffAfterDataOff = false; - // Registration Denied Reason, General/Authentication Failure, used only for debugging purposes + /* Used only for debugging purposes. */ private String mRegistrationDeniedReason; - //***** Constants - static final String LOG_TAG = "CDMA"; - private ContentResolver cr; private String currentCarrier = null; @@ -151,9 +146,6 @@ final class CdmaServiceStateTracker extends ServiceStateTracker { } }; - - //***** Constructors - public CdmaServiceStateTracker(CDMAPhone phone) { super(); @@ -182,7 +174,7 @@ final class CdmaServiceStateTracker extends ServiceStateTracker { phone.registerForEriFileLoaded(this, EVENT_ERI_FILE_LOADED, null); cm.registerForCdmaOtaProvision(this,EVENT_OTA_PROVISION_STATUS_CHANGE, null); - // system setting property AIRPLANE_MODE_ON is set in Settings. + // System setting property AIRPLANE_MODE_ON is set in Settings. int airplaneMode = Settings.System.getInt( phone.getContext().getContentResolver(), Settings.System.AIRPLANE_MODE_ON, 0); @@ -198,7 +190,7 @@ final class CdmaServiceStateTracker extends ServiceStateTracker { } public void dispose() { - //Unregister for all events + // Unregister for all events. cm.unregisterForAvailable(this); cm.unregisterForRadioStateChanged(this); cm.unregisterForNetworkStateChanged(this); @@ -236,8 +228,7 @@ final class CdmaServiceStateTracker extends ServiceStateTracker { * @param what what code of message when delivered * @param obj placed in Message.obj */ - /*protected*/ void - registerForCdmaDataConnectionAttached(Handler h, int what, Object obj) { + void registerForCdmaDataConnectionAttached(Handler h, int what, Object obj) { Registrant r = new Registrant(h, what, obj); cdmaDataConnectionAttachedRegistrants.add(r); @@ -245,6 +236,7 @@ final class CdmaServiceStateTracker extends ServiceStateTracker { r.notifyRegistrant(); } } + void unregisterForCdmaDataConnectionAttached(Handler h) { cdmaDataConnectionAttachedRegistrants.remove(h); } @@ -255,8 +247,7 @@ final class CdmaServiceStateTracker extends ServiceStateTracker { * @param what what code of message when delivered * @param obj placed in Message.obj */ - /*protected*/ void - registerForCdmaDataConnectionDetached(Handler h, int what, Object obj) { + void registerForCdmaDataConnectionDetached(Handler h, int what, Object obj) { Registrant r = new Registrant(h, what, obj); cdmaDataConnectionDetachedRegistrants.add(r); @@ -264,6 +255,7 @@ final class CdmaServiceStateTracker extends ServiceStateTracker { r.notifyRegistrant(); } } + void unregisterForCdmaDataConnectionDetached(Handler h) { cdmaDataConnectionDetachedRegistrants.remove(h); } @@ -287,7 +279,6 @@ final class CdmaServiceStateTracker extends ServiceStateTracker { cdmaForSubscriptionInfoReadyRegistrants.remove(h); } - //***** Called from CDMAPhone public void getLacAndCid(Message onComplete) { cm.getRegistrationState(obtainMessage( @@ -302,14 +293,11 @@ final class CdmaServiceStateTracker extends ServiceStateTracker { switch (msg.what) { case EVENT_RADIO_AVAILABLE: - //this is unnecessary - //setPowerStateToDesired(); break; case EVENT_RUIM_READY: - // The RUIM is now ready i.e if it was locked - // it has been unlocked. At this stage, the radio is already - // powered on. + // The RUIM is now ready i.e if it was locked it has been + // unlocked. At this stage, the radio is already powered on. isSubscriptionFromRuim = true; if (mNeedToRegForRuimLoaded) { phone.mRuimRecords.registerForRecordsLoaded(this, @@ -320,10 +308,10 @@ final class CdmaServiceStateTracker extends ServiceStateTracker { cm.getCDMASubscription(obtainMessage(EVENT_POLL_STATE_CDMA_SUBSCRIPTION)); if (DBG) log("Receive EVENT_RUIM_READY and Send Request getCDMASubscription."); - // restore the previous network selection. + // Restore the previous network selection. pollState(); - // Signal strength polling stops when radio is off + // Signal strength polling stops when radio is off. queueNextSignalStrengthPoll(); break; @@ -334,13 +322,12 @@ final class CdmaServiceStateTracker extends ServiceStateTracker { // subscription info. cm.getCDMASubscription( obtainMessage(EVENT_POLL_STATE_CDMA_SUBSCRIPTION)); pollState(); - // Signal strength polling stops when radio is off + // Signal strength polling stops when radio is off. queueNextSignalStrengthPoll(); break; case EVENT_RADIO_STATE_CHANGED: - // This will do nothing in the radio not - // available case + // This will do nothing in the 'radio not available' case. setPowerStateToDesired(); pollState(); break; @@ -351,10 +338,10 @@ final class CdmaServiceStateTracker extends ServiceStateTracker { case EVENT_GET_SIGNAL_STRENGTH: // This callback is called when signal strength is polled - // all by itself + // all by itself. if (!(cm.getRadioState().isOn()) || (cm.getRadioState().isGsm())) { - // Polling will continue when radio turns back on + // Polling will continue when radio turns back on. return; } ar = (AsyncResult) msg.obj; @@ -390,7 +377,7 @@ final class CdmaServiceStateTracker extends ServiceStateTracker { } } - // only update if cell location really changed + // Only update if cell location really changed. if (cellLoc.getBaseStationId() != baseStationData[0] || cellLoc.getBaseStationLatitude() != baseStationData[1] || cellLoc.getBaseStationLongitude() != baseStationData[2]) { @@ -479,13 +466,12 @@ final class CdmaServiceStateTracker extends ServiceStateTracker { break; case EVENT_SIGNAL_STRENGTH_UPDATE: - // This is a notification from - // CommandsInterface.setOnSignalStrengthUpdate + // This is a notification from CommandsInterface.setOnSignalStrengthUpdate. ar = (AsyncResult) msg.obj; - // The radio is telling us about signal strength changes - // we don't have to ask it + // The radio is telling us about signal strength changes, + // so we don't have to ask it. dontPollSignalStrength = true; onSignalStrengthResult(ar); @@ -504,7 +490,7 @@ final class CdmaServiceStateTracker extends ServiceStateTracker { break; case EVENT_ERI_FILE_LOADED: - // Repoll the state once the ERI file has been loaded + // Repoll the state once the ERI file has been loaded. if (DBG) log("[CdmaServiceStateTracker] ERI file has been loaded, repolling."); pollState(); break; @@ -627,7 +613,7 @@ final class CdmaServiceStateTracker extends ServiceStateTracker { int ints[]; String states[]; - // Ignore stale requests from last poll + // Ignore stale requests from last poll. if (ar.userObj != pollingContext) return; if (ar.exception != null) { @@ -638,13 +624,13 @@ final class CdmaServiceStateTracker extends ServiceStateTracker { } if (err == CommandException.Error.RADIO_NOT_AVAILABLE) { - // Radio has crashed or turned off + // Radio has crashed or turned off. cancelPollState(); return; } if (!cm.getRadioState().isOn()) { - // Radio has crashed or turned off + // Radio has crashed or turned off. cancelPollState(); return; } @@ -698,13 +684,15 @@ final class CdmaServiceStateTracker extends ServiceStateTracker { } mRegistrationState = registrationState; - // mCdmaRoaming is true when registration state is roaming and TSB58 roaming - // indicator is not in the carrier-specified list of ERIs for home system + // When registration state is roaming and TSB58 + // roaming indicator is not in the carrier-specified + // list of ERIs for home system, mCdmaRoaming is true. mCdmaRoaming = regCodeIsRoaming(registrationState) && !isRoamIndForHomeSystem(states[10]); newSS.setState (regCodeToServiceState(registrationState)); - this.newCdmaDataConnectionState = radioTechnologyToDataServiceState(radioTechnology); + this.newCdmaDataConnectionState = + radioTechnologyToDataServiceState(radioTechnology); newSS.setRadioTechnology(radioTechnology); newNetworkType = radioTechnology; @@ -715,7 +703,7 @@ final class CdmaServiceStateTracker extends ServiceStateTracker { mDefaultRoamingIndicator = defaultRoamingIndicator; - // values are -1 if not available + // Values are -1 if not available. newCellLoc.setCellLocationData(baseStationId, baseStationLatitude, baseStationLongitude, systemId, networkId); @@ -737,8 +725,8 @@ final class CdmaServiceStateTracker extends ServiceStateTracker { if (opNames != null && opNames.length >= 3) { if (cm.getRadioState().isNVReady()) { - // In CDMA in case on NV the ss.mOperatorAlphaLong is set later with the - // ERI text, so here it is ignored what is coming from the modem + // In CDMA in case on NV, the ss.mOperatorAlphaLong is set later with the + // ERI text, so here it is ignored what is coming from the modem. newSS.setOperatorName(null, opNames[1], opNames[2]); } else { newSS.setOperatorName(opNames[0], opNames[1], opNames[2]); @@ -803,9 +791,8 @@ final class CdmaServiceStateTracker extends ServiceStateTracker { } } - - // NOTE: Some operator may require to override the mCdmaRoaming (set by the modem) - // depending on the mRoamingIndicator. + // NOTE: Some operator may require overriding mCdmaRoaming + // (set by the modem), depending on the mRoamingIndicator. if (DBG) { log("Set CDMA Roaming Indicator to: " + newSS.getCdmaRoamingIndicator() @@ -865,13 +852,13 @@ final class CdmaServiceStateTracker extends ServiceStateTracker { setSignalStrengthDefaultValues(); mGotCountryCode = false; - //NOTE: pollStateDone() is not needed in this case + // NOTE: pollStateDone() is not needed in this case break; default: - // Issue all poll-related commands at once - // then count down the responses, which - // are allowed to arrive out-of-order + // Issue all poll-related commands at once, then count + // down the responses which are allowed to arrive + // out-of-order. pollingContext[0]++; // RIL_REQUEST_OPERATOR is necessary for CDMA @@ -1000,7 +987,7 @@ final class CdmaServiceStateTracker extends ServiceStateTracker { newSS.setStateOutOfService(); // clean slate for next time if (hasNetworkTypeChanged) { - phone.setSystemProperty(PROPERTY_DATA_NETWORK_TYPE, + phone.setSystemProperty(TelephonyProperties.PROPERTY_DATA_NETWORK_TYPE, networkTypeToString(networkType)); } @@ -1027,14 +1014,14 @@ final class CdmaServiceStateTracker extends ServiceStateTracker { String operatorNumeric; - phone.setSystemProperty(PROPERTY_OPERATOR_ALPHA, + phone.setSystemProperty(TelephonyProperties.PROPERTY_OPERATOR_ALPHA, ss.getOperatorAlphaLong()); operatorNumeric = ss.getOperatorNumeric(); - phone.setSystemProperty(PROPERTY_OPERATOR_NUMERIC, operatorNumeric); + phone.setSystemProperty(TelephonyProperties.PROPERTY_OPERATOR_NUMERIC, operatorNumeric); if (operatorNumeric == null) { - phone.setSystemProperty(PROPERTY_OPERATOR_ISO_COUNTRY, ""); + phone.setSystemProperty(TelephonyProperties.PROPERTY_OPERATOR_ISO_COUNTRY, ""); } else { String isoCountryCode = ""; try{ @@ -1046,14 +1033,15 @@ final class CdmaServiceStateTracker extends ServiceStateTracker { Log.w(LOG_TAG, "countryCodeForMcc error" + ex); } - phone.setSystemProperty(PROPERTY_OPERATOR_ISO_COUNTRY, isoCountryCode); + phone.setSystemProperty(TelephonyProperties.PROPERTY_OPERATOR_ISO_COUNTRY, + isoCountryCode); mGotCountryCode = true; if (mNeedFixZone) { fixTimeZone(isoCountryCode); } } - phone.setSystemProperty(PROPERTY_OPERATOR_ISROAMING, + phone.setSystemProperty(TelephonyProperties.PROPERTY_OPERATOR_ISROAMING, ss.getRoaming() ? "true" : "false"); updateSpnDisplay(); @@ -1282,7 +1270,7 @@ final class CdmaServiceStateTracker extends ServiceStateTracker { */ private boolean isRoamingBetweenOperators(boolean cdmaRoaming, ServiceState s) { - String spn = SystemProperties.get(PROPERTY_ICC_OPERATOR_ALPHA, "empty"); + String spn = SystemProperties.get(TelephonyProperties.PROPERTY_ICC_OPERATOR_ALPHA, "empty"); // NOTE: in case of RUIM we should completely ignore the ERI data file and // mOperatorAlphaLong is set from RIL_REQUEST_OPERATOR response 0 (alpha ONS) @@ -1366,7 +1354,7 @@ final class CdmaServiceStateTracker extends ServiceStateTracker { zone = TimeZone.getTimeZone( tzname ); } - String iso = SystemProperties.get(PROPERTY_OPERATOR_ISO_COUNTRY); + String iso = SystemProperties.get(TelephonyProperties.PROPERTY_OPERATOR_ISO_COUNTRY); if (zone == null) { @@ -1549,7 +1537,6 @@ final class CdmaServiceStateTracker extends ServiceStateTracker { * that could support voice and data simultaneously. */ boolean isConcurrentVoiceAndData() { - // Note: it needs to be confirmed which CDMA network types // can support voice and data calls concurrently. // For the time-being, the return value will be false. @@ -1576,11 +1563,12 @@ final class CdmaServiceStateTracker extends ServiceStateTracker { /** * Returns IMSI as MCC + MNC + MIN */ - /*package*/ String getImsi() { + String getImsi() { // TODO(Moto): When RUIM is enabled, IMSI will come from RUIM // not build-time props. Moto will provide implementation // for RUIM-ready case later. - String operatorNumeric = SystemProperties.get(PROPERTY_ICC_OPERATOR_NUMERIC, ""); + String operatorNumeric = SystemProperties.get( + TelephonyProperties.PROPERTY_ICC_OPERATOR_NUMERIC, ""); if (!TextUtils.isEmpty(operatorNumeric) && getCdmaMin() != null) { return (operatorNumeric + getCdmaMin()); diff --git a/telephony/java/com/android/internal/telephony/gsm/GsmServiceStateTracker.java b/telephony/java/com/android/internal/telephony/gsm/GsmServiceStateTracker.java index e7406e2..a9be068 100644 --- a/telephony/java/com/android/internal/telephony/gsm/GsmServiceStateTracker.java +++ b/telephony/java/com/android/internal/telephony/gsm/GsmServiceStateTracker.java @@ -16,13 +16,6 @@ package com.android.internal.telephony.gsm; -import static com.android.internal.telephony.TelephonyProperties.PROPERTY_DATA_NETWORK_TYPE; -import static com.android.internal.telephony.TelephonyProperties.PROPERTY_ICC_OPERATOR_ALPHA; -import static com.android.internal.telephony.TelephonyProperties.PROPERTY_ICC_OPERATOR_NUMERIC; -import static com.android.internal.telephony.TelephonyProperties.PROPERTY_OPERATOR_ALPHA; -import static com.android.internal.telephony.TelephonyProperties.PROPERTY_OPERATOR_ISO_COUNTRY; -import static com.android.internal.telephony.TelephonyProperties.PROPERTY_OPERATOR_ISROAMING; -import static com.android.internal.telephony.TelephonyProperties.PROPERTY_OPERATOR_NUMERIC; import android.app.AlarmManager; import android.app.Notification; import android.app.NotificationManager; @@ -60,6 +53,7 @@ import com.android.internal.telephony.RILConstants; import com.android.internal.telephony.ServiceStateTracker; import com.android.internal.telephony.TelephonyEventLog; import com.android.internal.telephony.TelephonyIntents; +import com.android.internal.telephony.TelephonyProperties; import java.util.Arrays; import java.util.Calendar; @@ -70,8 +64,9 @@ import java.util.TimeZone; * {@hide} */ final class GsmServiceStateTracker extends ServiceStateTracker { + static final String LOG_TAG = "GSM"; + static final boolean DBG = true; - //***** Instance Variables GSMPhone phone; GsmCellLocation cellLoc; GsmCellLocation newCellLoc; @@ -82,13 +77,15 @@ final class GsmServiceStateTracker extends ServiceStateTracker { private int newGPRSState = ServiceState.STATE_OUT_OF_SERVICE; /** - * The access technology currently in use: DATA_ACCESS_ + * Values correspond to ServiceStateTracker.DATA_ACCESS_ definitions. */ private int networkType = 0; private int newNetworkType = 0; - /* gsm roaming status solely based on TS 27.007 7.2 CREG */ + + /** GSM roaming status solely based on TS 27.007 7.2 CREG. */ private boolean mGsmRoaming = false; - /* data roaming status solely based on TS 27.007 10.1.19 CGREG */ + + /** Data roaming status solely based on TS 27.007 10.1.19 CGREG. */ private boolean mDataRoaming = false; private boolean newDataRoaming = false; @@ -97,9 +94,11 @@ final class GsmServiceStateTracker extends ServiceStateTracker { private RegistrantList psRestrictEnabledRegistrants = new RegistrantList(); private RegistrantList psRestrictDisabledRegistrants = new RegistrantList(); - // Sometimes we get the NITZ time before we know what country we are in. - // Keep the time zone information from the NITZ string so we can fix - // the time zone once know the country. + /** + * Sometimes we get the NITZ time before we know what country we + * are in. Keep the time zone information from the NITZ string so + * we can fix the time zone once know the country. + */ private boolean mNeedFixZone = false; private int mZoneOffset; private boolean mZoneDst; @@ -111,13 +110,16 @@ final class GsmServiceStateTracker extends ServiceStateTracker { long mSavedTime; long mSavedAtTime; - // We can't register for SIM_RECORDS_LOADED immediately because the - // SIMRecords object may not be instantiated yet. + /** + * We can't register for SIM_RECORDS_LOADED immediately because the + * SIMRecords object may not be instantiated yet. + */ private boolean mNeedToRegForSimLoaded; - // Started the recheck process after finding gprs should registerd but not + /** Started the recheck process after finding gprs should registerd but not. */ private boolean mStartedGprsRegCheck = false; - // Already sent the event-log for no gprs register + + /** Already sent the event-log for no gprs register. */ private boolean mReportedGprsNoReg = false; /** @@ -125,34 +127,29 @@ final class GsmServiceStateTracker extends ServiceStateTracker { */ private Notification mNotification; - // Wake lock used while setting time of day. + /** Wake lock used while setting time of day. */ private PowerManager.WakeLock mWakeLock; private static final String WAKELOCK_TAG = "ServiceStateTracker"; - // Keep track of SPN display rules, so we only broadcast intent if something changes. + /** Keep track of SPN display rules, so we only broadcast intent if something changes. */ private String curSpn = null; private String curPlmn = null; private int curSpnRule = 0; - //***** Constants - - static final boolean DBG = true; - static final String LOG_TAG = "GSM"; - - // waiting period before recheck gprs and voice registration + /** waiting period before recheck gprs and voice registration. */ static final int DEFAULT_GPRS_CHECK_PERIOD_MILLIS = 60 * 1000; - // notification type - static final int PS_ENABLED = 1001; // Access Control blocks data service - static final int PS_DISABLED = 1002; // Access Control enables data service - static final int CS_ENABLED = 1003; // Access Control blocks all voice/sms service - static final int CS_DISABLED = 1004; // Access Control enables all voice/sms service - static final int CS_NORMAL_ENABLED = 1005; // Access Control blocks normal voice/sms service - static final int CS_EMERGENCY_ENABLED = 1006; // Access Control blocks emergency call service + /** Notification type. */ + static final int PS_ENABLED = 1001; // Access Control blocks data service + static final int PS_DISABLED = 1002; // Access Control enables data service + static final int CS_ENABLED = 1003; // Access Control blocks all voice/sms service + static final int CS_DISABLED = 1004; // Access Control enables all voice/sms service + static final int CS_NORMAL_ENABLED = 1005; // Access Control blocks normal voice/sms service + static final int CS_EMERGENCY_ENABLED = 1006; // Access Control blocks emergency call service - // notification id - static final int PS_NOTIFICATION = 888; //id to update and cancel PS restricted - static final int CS_NOTIFICATION = 999; //id to update and cancel CS restricted + /** Notification id. */ + static final int PS_NOTIFICATION = 888; // Id to update and cancel PS restricted + static final int CS_NOTIFICATION = 999; // Id to update and cancel CS restricted static final int MAX_NUM_DATA_STATE_READS = 15; @@ -164,9 +161,6 @@ final class GsmServiceStateTracker extends ServiceStateTracker { } }; - - //***** Constructors - public GsmServiceStateTracker(GSMPhone phone) { super(); @@ -207,7 +201,7 @@ final class GsmServiceStateTracker extends ServiceStateTracker { } public void dispose() { - //Unregister for all events + // Unregister for all events. cm.unregisterForAvailable(this); cm.unregisterForRadioStateChanged(this); cm.unregisterForNetworkStateChanged(this); @@ -230,7 +224,7 @@ final class GsmServiceStateTracker extends ServiceStateTracker { * @param what what code of message when delivered * @param obj placed in Message.obj */ - /*protected*/ void registerForGprsAttached(Handler h, int what, Object obj) { + void registerForGprsAttached(Handler h, int what, Object obj) { Registrant r = new Registrant(h, what, obj); gprsAttachedRegistrants.add(r); @@ -239,11 +233,11 @@ final class GsmServiceStateTracker extends ServiceStateTracker { } } - /*protected*/ void unregisterForGprsAttached(Handler h) { + void unregisterForGprsAttached(Handler h) { gprsAttachedRegistrants.remove(h); } - /*protected*/ void registerForNetworkAttach(Handler h, int what, Object obj) { + void registerForNetworkAttach(Handler h, int what, Object obj) { Registrant r = new Registrant(h, what, obj); networkAttachedRegistrants.add(r); @@ -252,16 +246,17 @@ final class GsmServiceStateTracker extends ServiceStateTracker { } } - /*protected*/ void unregisterForNetworkAttach(Handler h) { + void unregisterForNetworkAttach(Handler h) { networkAttachedRegistrants.remove(h); } + /** * Registration point for transition into GPRS detached. * @param h handler to notify * @param what what code of message when delivered * @param obj placed in Message.obj */ - /*protected*/ void registerForGprsDetached(Handler h, int what, Object obj) { + void registerForGprsDetached(Handler h, int what, Object obj) { Registrant r = new Registrant(h, what, obj); gprsDetachedRegistrants.add(r); @@ -270,7 +265,7 @@ final class GsmServiceStateTracker extends ServiceStateTracker { } } - /*protected*/ void unregisterForGprsDetached(Handler h) { + void unregisterForGprsDetached(Handler h) { gprsDetachedRegistrants.remove(h); } @@ -280,7 +275,7 @@ final class GsmServiceStateTracker extends ServiceStateTracker { * @param what what code of message when delivered * @param obj placed in Message.obj */ - /*protected*/ void registerForPsRestrictedEnabled(Handler h, int what, Object obj) { + void registerForPsRestrictedEnabled(Handler h, int what, Object obj) { Log.d(LOG_TAG, "[DSAC DEB] " + "registerForPsRestrictedEnabled "); Registrant r = new Registrant(h, what, obj); psRestrictEnabledRegistrants.add(r); @@ -290,7 +285,7 @@ final class GsmServiceStateTracker extends ServiceStateTracker { } } - /*protected*/ void unregisterForPsRestrictedEnabled(Handler h) { + void unregisterForPsRestrictedEnabled(Handler h) { psRestrictEnabledRegistrants.remove(h); } @@ -300,7 +295,7 @@ final class GsmServiceStateTracker extends ServiceStateTracker { * @param what what code of message when delivered * @param obj placed in Message.obj */ - /*protected*/ void registerForPsRestrictedDisabled(Handler h, int what, Object obj) { + void registerForPsRestrictedDisabled(Handler h, int what, Object obj) { Log.d(LOG_TAG, "[DSAC DEB] " + "registerForPsRestrictedDisabled "); Registrant r = new Registrant(h, what, obj); psRestrictDisabledRegistrants.add(r); @@ -310,25 +305,20 @@ final class GsmServiceStateTracker extends ServiceStateTracker { } } - /*protected*/ void unregisterForPsRestrictedDisabled(Handler h) { + void unregisterForPsRestrictedDisabled(Handler h) { psRestrictDisabledRegistrants.remove(h); } - /*protected*/ boolean getDataRoaming() { + boolean getDataRoaming() { return mDataRoaming; } - //***** Called from GSMPhone - public void - getLacAndCid(Message onComplete) { + public void getLacAndCid(Message onComplete) { cm.getRegistrationState(obtainMessage( EVENT_GET_LOC_DONE, onComplete)); } - - //***** Overridden from ServiceStateTracker - public void - handleMessage (Message msg) { + public void handleMessage (Message msg) { AsyncResult ar; int[] ints; String[] strings; @@ -529,10 +519,7 @@ final class GsmServiceStateTracker extends ServiceStateTracker { } } - //***** Private Instance Methods - - protected void setPowerStateToDesired() - { + protected void setPowerStateToDesired() { // If we want it on and it's off, turn it on if (mDesiredPowerState && cm.getRadioState() == CommandsInterface.RadioState.RADIO_OFF) { @@ -593,9 +580,7 @@ final class GsmServiceStateTracker extends ServiceStateTracker { /** * Handle the result of one of the pollState()-related requests */ - - protected void - handlePollStateResult (int what, AsyncResult ar) { + protected void handlePollStateResult (int what, AsyncResult ar) { int ints[]; String states[]; @@ -726,9 +711,7 @@ final class GsmServiceStateTracker extends ServiceStateTracker { * and start over again if the radio notifies us that some * event has changed */ - - private void - pollState() { + private void pollState() { pollingContext = new int[1]; pollingContext[0] = 0; @@ -828,8 +811,7 @@ final class GsmServiceStateTracker extends ServiceStateTracker { return ret; } - private void - pollStateDone() { + private void pollStateDone() { if (DBG) { Log.d(LOG_TAG, "Poll ServiceState done: " + " oldSS=[" + ss + "] newSS=[" + newSS + @@ -882,7 +864,7 @@ final class GsmServiceStateTracker extends ServiceStateTracker { newSS.setStateOutOfService(); // clean slate for next time if (hasNetworkTypeChanged) { - phone.setSystemProperty(PROPERTY_DATA_NETWORK_TYPE, + phone.setSystemProperty(TelephonyProperties.PROPERTY_DATA_NETWORK_TYPE, networkTypeToString(networkType)); } @@ -895,14 +877,14 @@ final class GsmServiceStateTracker extends ServiceStateTracker { if (hasChanged) { String operatorNumeric; - phone.setSystemProperty(PROPERTY_OPERATOR_ALPHA, + phone.setSystemProperty(TelephonyProperties.PROPERTY_OPERATOR_ALPHA, ss.getOperatorAlphaLong()); operatorNumeric = ss.getOperatorNumeric(); - phone.setSystemProperty(PROPERTY_OPERATOR_NUMERIC, operatorNumeric); + phone.setSystemProperty(TelephonyProperties.PROPERTY_OPERATOR_NUMERIC, operatorNumeric); if (operatorNumeric == null) { - phone.setSystemProperty(PROPERTY_OPERATOR_ISO_COUNTRY, ""); + phone.setSystemProperty(TelephonyProperties.PROPERTY_OPERATOR_ISO_COUNTRY, ""); } else { String iso = ""; try{ @@ -914,7 +896,7 @@ final class GsmServiceStateTracker extends ServiceStateTracker { Log.w(LOG_TAG, "countryCodeForMcc error" + ex); } - phone.setSystemProperty(PROPERTY_OPERATOR_ISO_COUNTRY, iso); + phone.setSystemProperty(TelephonyProperties.PROPERTY_OPERATOR_ISO_COUNTRY, iso); mGotCountryCode = true; if (mNeedFixZone) { @@ -957,7 +939,7 @@ final class GsmServiceStateTracker extends ServiceStateTracker { } } - phone.setSystemProperty(PROPERTY_OPERATOR_ISROAMING, + phone.setSystemProperty(TelephonyProperties.PROPERTY_OPERATOR_ISROAMING, ss.getRoaming() ? "true" : "false"); updateSpnDisplay(); @@ -1052,8 +1034,7 @@ final class GsmServiceStateTracker extends ServiceStateTracker { return guess; } - private void - queueNextSignalStrengthPoll() { + private void queueNextSignalStrengthPoll() { if (dontPollSignalStrength || (cm.getRadioState().isCdma())) { // The radio is telling us about signal strength changes // we don't have to ask it @@ -1075,8 +1056,7 @@ final class GsmServiceStateTracker extends ServiceStateTracker { * send signal-strength-changed notification if changed * Called both for solicited and unsolicited signal stength updates */ - private void - onSignalStrengthResult(AsyncResult ar) { + private void onSignalStrengthResult(AsyncResult ar) { SignalStrength oldSignalStrength = mSignalStrength; int rssi = 99; @@ -1117,8 +1097,7 @@ final class GsmServiceStateTracker extends ServiceStateTracker { * * @param ar an int value of RIL_RESTRICTED_STATE_* */ - private void onRestrictedStateChanged(AsyncResult ar) - { + private void onRestrictedStateChanged(AsyncResult ar) { Log.d(LOG_TAG, "[DSAC DEB] " + "onRestrictedStateChanged"); RestrictedState newRs = new RestrictedState(); @@ -1207,8 +1186,7 @@ final class GsmServiceStateTracker extends ServiceStateTracker { } /** code is registration state 0-5 from TS 27.007 7.2 */ - private int - regCodeToServiceState(int code) { + private int regCodeToServiceState(int code) { switch (code) { case 0: case 2: // 2 is "searching" @@ -1234,8 +1212,7 @@ final class GsmServiceStateTracker extends ServiceStateTracker { * code is registration state 0-5 from TS 27.007 7.2 * returns true if registered roam, false otherwise */ - private boolean - regCodeIsRoaming (int code) { + private boolean regCodeIsRoaming (int code) { // 5 is "in service -- roam" return 5 == code; } @@ -1247,9 +1224,8 @@ final class GsmServiceStateTracker extends ServiceStateTracker { * @param s ServiceState hold current ons * @return true for roaming state set */ - private - boolean isRoamingBetweenOperators(boolean gsmRoaming, ServiceState s) { - String spn = SystemProperties.get(PROPERTY_ICC_OPERATOR_ALPHA, "empty"); + private boolean isRoamingBetweenOperators(boolean gsmRoaming, ServiceState s) { + String spn = SystemProperties.get(TelephonyProperties.PROPERTY_ICC_OPERATOR_ALPHA, "empty"); String onsl = s.getOperatorAlphaLong(); String onss = s.getOperatorAlphaShort(); @@ -1257,7 +1233,8 @@ final class GsmServiceStateTracker extends ServiceStateTracker { boolean equalsOnsl = onsl != null && spn.equals(onsl); boolean equalsOnss = onss != null && spn.equals(onss); - String simNumeric = SystemProperties.get(PROPERTY_ICC_OPERATOR_NUMERIC, ""); + String simNumeric = SystemProperties.get( + TelephonyProperties.PROPERTY_ICC_OPERATOR_NUMERIC, ""); String operatorNumeric = s.getOperatorNumeric(); boolean equalsMcc = true; @@ -1270,8 +1247,7 @@ final class GsmServiceStateTracker extends ServiceStateTracker { return gsmRoaming && !(equalsMcc && (equalsOnsl || equalsOnss)); } - private static - int twoDigitsAt(String s, int offset) { + private static int twoDigitsAt(String s, int offset) { int a, b; a = Character.digit(s.charAt(offset), 10); @@ -1289,7 +1265,7 @@ final class GsmServiceStateTracker extends ServiceStateTracker { * @return The current GPRS state. IN_SERVICE is the same as "attached" * and OUT_OF_SERVICE is the same as detached. */ - /*package*/ int getCurrentGprsState() { + int getCurrentGprsState() { return gprsState; } @@ -1337,10 +1313,7 @@ final class GsmServiceStateTracker extends ServiceStateTracker { /** * nitzReceiveTime is time_t that the NITZ time was posted */ - - private - void setTimeFromNITZString (String nitz, long nitzReceiveTime) - { + private void setTimeFromNITZString (String nitz, long nitzReceiveTime) { // "yy/mm/dd,hh:mm:ss(+/-)tz" // tz is in number of quarter-hours @@ -1404,7 +1377,7 @@ final class GsmServiceStateTracker extends ServiceStateTracker { zone = TimeZone.getTimeZone( tzname ); } - String iso = SystemProperties.get(PROPERTY_OPERATOR_ISO_COUNTRY); + String iso = SystemProperties.get(TelephonyProperties.PROPERTY_OPERATOR_ISO_COUNTRY); if (zone == null) { |