7676 */
7777public final class GsmDataConnectionTracker extends DataConnectionTracker {
7878 protected final String LOG_TAG = "GSM" ;
79+ private static final boolean RADIO_TESTS = false ;
7980
8081 /**
8182 * Handles changes to the APN db.
@@ -1405,7 +1406,7 @@ private void updateDataStallInfo() {
14051406 sent = mDataStallTxRxSum .txPkts - preTxRxSum .txPkts ;
14061407 received = mDataStallTxRxSum .rxPkts - preTxRxSum .rxPkts ;
14071408
1408- if (VDBG ) {
1409+ if (RADIO_TESTS ) {
14091410 if (SystemProperties .getBoolean ("radio.test.data.stall" , false )) {
14101411 log ("updateDataStallInfo: radio.test.data.stall true received = 0;" );
14111412 received = 0 ;
@@ -1891,6 +1892,8 @@ protected void onRadioOffOrNotAvailable() {
18911892 @ Override
18921893 protected void onDataSetupComplete (AsyncResult ar ) {
18931894
1895+ DataConnection .FailCause cause = DataConnection .FailCause .UNKNOWN ;
1896+ boolean handleError = false ;
18941897 ApnContext apnContext = null ;
18951898
18961899 if (ar .userObj instanceof ApnContext ){
@@ -1901,52 +1904,73 @@ protected void onDataSetupComplete(AsyncResult ar) {
19011904
19021905 if (isDataSetupCompleteOk (ar )) {
19031906 DataConnectionAc dcac = apnContext .getDataConnectionAc ();
1904- if (dcac == null ) {
1905- throw new RuntimeException ("onDataSetupCompete: No dcac" );
1906- }
1907- DataConnection dc = apnContext .getDataConnection ();
19081907
1909- if (DBG ) {
1910- // TODO We may use apnContext.getApnSetting() directly
1911- // instead of getWaitingApns().get(0)
1912- String apnStr = "<unknown>" ;
1913- if (apnContext .getWaitingApns () != null
1914- && !apnContext .getWaitingApns ().isEmpty ()){
1915- apnStr = apnContext .getWaitingApns ().get (0 ).apn ;
1908+ if (RADIO_TESTS ) {
1909+ // Note: To change radio.test.onDSC.null.dcac from command line you need to
1910+ // adb root and adb remount and from the command line you can only change the
1911+ // value to 1 once. To change it a second time you can reboot or execute
1912+ // adb shell stop and then adb shell start. The command line to set the value is:
1913+ // adb shell sqlite3 /data/data/com.android.providers.settings/databases/settings.db "insert into system (name,value) values ('radio.test.onDSC.null.dcac', '1');"
1914+ ContentResolver cr = mPhone .getContext ().getContentResolver ();
1915+ String radioTestProperty = "radio.test.onDSC.null.dcac" ;
1916+ if (Settings .System .getInt (cr , radioTestProperty , 0 ) == 1 ) {
1917+ log ("onDataSetupComplete: " + radioTestProperty +
1918+ " is true, set dcac to null and reset property to false" );
1919+ dcac = null ;
1920+ Settings .System .putInt (cr , radioTestProperty , 0 );
1921+ log ("onDataSetupComplete: " + radioTestProperty + "=" +
1922+ Settings .System .getInt (mPhone .getContext ().getContentResolver (),
1923+ radioTestProperty , -1 ));
19161924 }
1917- log ("onDataSetupComplete: success apn=" + apnStr );
19181925 }
1919- ApnSetting apn = apnContext .getApnSetting ();
1920- if (apn .proxy != null && apn .proxy .length () != 0 ) {
1921- try {
1922- String port = apn .port ;
1923- if (TextUtils .isEmpty (port )) port = "8080" ;
1924- ProxyProperties proxy = new ProxyProperties (apn .proxy ,
1925- Integer .parseInt (port ), null );
1926- dcac .setLinkPropertiesHttpProxySync (proxy );
1927- } catch (NumberFormatException e ) {
1928- loge ("onDataSetupComplete: NumberFormatException making ProxyProperties (" +
1929- apn .port + "): " + e );
1926+ if (dcac == null ) {
1927+ log ("onDataSetupComplete: no connection to DC, handle as error" );
1928+ cause = DataConnection .FailCause .CONNECTION_TO_DATACONNECTIONAC_BROKEN ;
1929+ handleError = true ;
1930+ } else {
1931+ DataConnection dc = apnContext .getDataConnection ();
1932+
1933+ if (DBG ) {
1934+ // TODO We may use apnContext.getApnSetting() directly
1935+ // instead of getWaitingApns().get(0)
1936+ String apnStr = "<unknown>" ;
1937+ if (apnContext .getWaitingApns () != null
1938+ && !apnContext .getWaitingApns ().isEmpty ()){
1939+ apnStr = apnContext .getWaitingApns ().get (0 ).apn ;
1940+ }
1941+ log ("onDataSetupComplete: success apn=" + apnStr );
1942+ }
1943+ ApnSetting apn = apnContext .getApnSetting ();
1944+ if (apn .proxy != null && apn .proxy .length () != 0 ) {
1945+ try {
1946+ String port = apn .port ;
1947+ if (TextUtils .isEmpty (port )) port = "8080" ;
1948+ ProxyProperties proxy = new ProxyProperties (apn .proxy ,
1949+ Integer .parseInt (port ), null );
1950+ dcac .setLinkPropertiesHttpProxySync (proxy );
1951+ } catch (NumberFormatException e ) {
1952+ loge ("onDataSetupComplete: NumberFormatException making ProxyProperties (" +
1953+ apn .port + "): " + e );
1954+ }
19301955 }
1931- }
19321956
1933- // everything is setup
1934- if (TextUtils .equals (apnContext .getApnType (),Phone .APN_TYPE_DEFAULT )) {
1935- SystemProperties .set ("gsm.defaultpdpcontext.active" , "true" );
1936- if (canSetPreferApn && mPreferredApn == null ) {
1937- if (DBG ) log ("onDataSetupComplete: PREFERED APN is null" );
1938- mPreferredApn = apnContext .getApnSetting ();
1939- if (mPreferredApn != null ) {
1940- setPreferredApn (mPreferredApn .id );
1957+ // everything is setup
1958+ if (TextUtils .equals (apnContext .getApnType (),Phone .APN_TYPE_DEFAULT )) {
1959+ SystemProperties .set ("gsm.defaultpdpcontext.active" , "true" );
1960+ if (canSetPreferApn && mPreferredApn == null ) {
1961+ if (DBG ) log ("onDataSetupComplete: PREFERED APN is null" );
1962+ mPreferredApn = apnContext .getApnSetting ();
1963+ if (mPreferredApn != null ) {
1964+ setPreferredApn (mPreferredApn .id );
1965+ }
19411966 }
1967+ } else {
1968+ SystemProperties .set ("gsm.defaultpdpcontext.active" , "false" );
19421969 }
1943- } else {
1944- SystemProperties .set ("gsm.defaultpdpcontext.active" , "false" );
1970+ notifyDefaultData (apnContext );
19451971 }
1946- notifyDefaultData (apnContext );
19471972 } else {
19481973 String apnString ;
1949- DataConnection .FailCause cause ;
19501974
19511975 cause = (DataConnection .FailCause ) (ar .result );
19521976 if (DBG ) {
@@ -1974,7 +1998,10 @@ protected void onDataSetupComplete(AsyncResult ar) {
19741998 apnContext .getWaitingApns ().size (),
19751999 apnContext .getWaitingApnsPermFailCount ()));
19762000 }
2001+ handleError = true ;
2002+ }
19772003
2004+ if (handleError ) {
19782005 // See if there are more APN's to try
19792006 if (apnContext .getWaitingApns ().isEmpty ()) {
19802007 if (apnContext .getWaitingApnsPermFailCount () == 0 ) {
@@ -1986,9 +2013,6 @@ protected void onDataSetupComplete(AsyncResult ar) {
19862013
19872014 apnContext .setDataConnection (null );
19882015 apnContext .setDataConnectionAc (null );
1989- if (DBG ) {
1990- log ("onDataSetupComplete: permanent error apn=%s" + apnString );
1991- }
19922016 } else {
19932017 if (DBG ) log ("onDataSetupComplete: Not all permanent failures, retry" );
19942018 // check to see if retry should be overridden for this failure.
0 commit comments