Merge "Fix 4379712 NPE in GsmDataConnectionTracker" into honeycomb-LTE
This commit is contained in:
@@ -38,6 +38,7 @@ import android.text.TextUtils;
|
||||
import android.util.Log;
|
||||
|
||||
import com.android.internal.R;
|
||||
import com.android.internal.telephony.DataConnection.FailCause;
|
||||
import com.android.internal.util.AsyncChannel;
|
||||
import com.android.internal.util.Protocol;
|
||||
|
||||
@@ -202,6 +203,19 @@ public abstract class DataConnectionTracker extends Handler {
|
||||
// getActionIntentReconnectAlarm.
|
||||
protected static final String INTENT_RECONNECT_ALARM_EXTRA_REASON = "reason";
|
||||
|
||||
// Used for debugging. Send the INTENT with an optional counter value with the number
|
||||
// of times the setup is to fail before succeeding. If the counter isn't passed the
|
||||
// setup will fail once. Example fail two times with FailCause.SIGNAL_LOST(-3)
|
||||
// adb shell am broadcast \
|
||||
// -a com.android.internal.telephony.dataconnectiontracker.intent_set_fail_data_setup_counter \
|
||||
// --ei fail_data_setup_counter 3 --ei fail_data_setup_fail_cause -3
|
||||
protected static final String INTENT_SET_FAIL_DATA_SETUP_COUNTER =
|
||||
"com.android.internal.telephony.dataconnectiontracker.intent_set_fail_data_setup_counter";
|
||||
protected static final String FAIL_DATA_SETUP_COUNTER = "fail_data_setup_counter";
|
||||
protected int mFailDataSetupCounter = 0;
|
||||
protected static final String FAIL_DATA_SETUP_FAIL_CAUSE = "fail_data_setup_fail_cause";
|
||||
protected FailCause mFailDataSetupFailCause = FailCause.ERROR_UNSPECIFIED;
|
||||
|
||||
// member variables
|
||||
protected PhoneBase mPhone;
|
||||
protected Activity mActivity = Activity.NONE;
|
||||
@@ -275,6 +289,7 @@ public abstract class DataConnectionTracker extends Handler {
|
||||
public void onReceive(Context context, Intent intent)
|
||||
{
|
||||
String action = intent.getAction();
|
||||
if (DBG) log("onReceive: action=" + action);
|
||||
if (action.equals(Intent.ACTION_SCREEN_ON)) {
|
||||
mIsScreenOn = true;
|
||||
stopNetStatPoll();
|
||||
@@ -300,10 +315,36 @@ public abstract class DataConnectionTracker extends Handler {
|
||||
// quit and won't report disconnected until next enabling.
|
||||
mIsWifiConnected = false;
|
||||
}
|
||||
} else if (action.equals(INTENT_SET_FAIL_DATA_SETUP_COUNTER)) {
|
||||
mFailDataSetupCounter = intent.getIntExtra(FAIL_DATA_SETUP_COUNTER, 1);
|
||||
mFailDataSetupFailCause = FailCause.fromInt(
|
||||
intent.getIntExtra(FAIL_DATA_SETUP_FAIL_CAUSE,
|
||||
FailCause.ERROR_UNSPECIFIED.getErrorCode()));
|
||||
if (DBG) log("set mFailDataSetupCounter=" + mFailDataSetupCounter +
|
||||
" mFailDataSetupFailCause=" + mFailDataSetupFailCause);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
protected boolean isDataSetupCompleteOk(AsyncResult ar) {
|
||||
if (ar.exception != null) {
|
||||
if (DBG) log("isDataSetupCompleteOk return false, ar.result=" + ar.result);
|
||||
return false;
|
||||
}
|
||||
if (mFailDataSetupCounter <= 0) {
|
||||
if (DBG) log("isDataSetupCompleteOk return true");
|
||||
return true;
|
||||
}
|
||||
ar.result = mFailDataSetupFailCause;
|
||||
if (DBG) {
|
||||
log("isDataSetupCompleteOk return false" +
|
||||
" mFailDataSetupCounter=" + mFailDataSetupCounter +
|
||||
" mFailDataSetupFailCause=" + mFailDataSetupFailCause);
|
||||
}
|
||||
mFailDataSetupCounter -= 1;
|
||||
return false;
|
||||
}
|
||||
|
||||
protected void onActionIntentReconnectAlarm(Intent intent) {
|
||||
String reason = intent.getStringExtra(INTENT_RECONNECT_ALARM_EXTRA_REASON);
|
||||
if (mState == State.FAILED) {
|
||||
@@ -329,6 +370,7 @@ public abstract class DataConnectionTracker extends Handler {
|
||||
filter.addAction(Intent.ACTION_SCREEN_OFF);
|
||||
filter.addAction(WifiManager.NETWORK_STATE_CHANGED_ACTION);
|
||||
filter.addAction(WifiManager.WIFI_STATE_CHANGED_ACTION);
|
||||
filter.addAction(INTENT_SET_FAIL_DATA_SETUP_COUNTER);
|
||||
|
||||
mDataEnabled = Settings.Secure.getInt(mPhone.getContext().getContentResolver(),
|
||||
Settings.Secure.MOBILE_DATA, 1) == 1;
|
||||
|
||||
@@ -54,9 +54,6 @@ public final class CdmaDataConnectionTracker extends DataConnectionTracker {
|
||||
|
||||
private CDMAPhone mCdmaPhone;
|
||||
|
||||
//useful for debugging
|
||||
boolean mFailNextConnect = false;
|
||||
|
||||
/** The DataConnection being setup */
|
||||
private CdmaDataConnection mPendingDataConnection;
|
||||
|
||||
@@ -660,7 +657,7 @@ public final class CdmaDataConnectionTracker extends DataConnectionTracker {
|
||||
reason = (String) ar.userObj;
|
||||
}
|
||||
|
||||
if (ar.exception == null) {
|
||||
if (isDataSetupCompleteOk(ar)) {
|
||||
// Everything is setup
|
||||
notifyDefaultData(reason);
|
||||
} else {
|
||||
|
||||
@@ -104,9 +104,6 @@ public final class GsmDataConnectionTracker extends DataConnectionTracker {
|
||||
/** Delay between APN attempts */
|
||||
protected static final int APN_DELAY_MILLIS = 5000;
|
||||
|
||||
//useful for debugging
|
||||
boolean mFailNextConnect = false;
|
||||
|
||||
//***** Constants
|
||||
|
||||
private static final int POLL_PDP_MILLIS = 5 * 1000;
|
||||
@@ -1574,13 +1571,14 @@ public final class GsmDataConnectionTracker extends DataConnectionTracker {
|
||||
} else {
|
||||
throw new RuntimeException("onDataSetupComplete: No apnContext");
|
||||
}
|
||||
DataConnectionAc dcac = apnContext.getDataConnectionAc();
|
||||
if (dcac == null) {
|
||||
throw new RuntimeException("onDataSetupCompete: No dcac");
|
||||
}
|
||||
DataConnection dc = apnContext.getDataConnection();
|
||||
|
||||
if (ar.exception == null) {
|
||||
if (isDataSetupCompleteOk(ar)) {
|
||||
DataConnectionAc dcac = apnContext.getDataConnectionAc();
|
||||
if (dcac == null) {
|
||||
throw new RuntimeException("onDataSetupCompete: No dcac");
|
||||
}
|
||||
DataConnection dc = apnContext.getDataConnection();
|
||||
|
||||
if (DBG) {
|
||||
log(String.format("onDataSetupComplete: success apn=%s",
|
||||
apnContext.getWaitingApns().get(0).apn) + " refCount=" + dc.getRefCount());
|
||||
@@ -1612,16 +1610,11 @@ public final class GsmDataConnectionTracker extends DataConnectionTracker {
|
||||
}
|
||||
notifyDefaultData(apnContext);
|
||||
} else {
|
||||
int refCount = releaseApnContext(apnContext, false);
|
||||
if (DBG) {
|
||||
log(String.format("onDataSetupComplete: error apn=%s",
|
||||
apnContext.getWaitingApns().get(0).apn) + " refCount=" + refCount);
|
||||
}
|
||||
String apnString;
|
||||
DataConnection.FailCause cause;
|
||||
|
||||
GsmDataConnection.FailCause cause;
|
||||
cause = (GsmDataConnection.FailCause) (ar.result);
|
||||
cause = (DataConnection.FailCause) (ar.result);
|
||||
if (DBG) {
|
||||
String apnString;
|
||||
try {
|
||||
apnString = apnContext.getWaitingApns().get(0).apn;
|
||||
} catch (Exception e) {
|
||||
@@ -1667,6 +1660,11 @@ public final class GsmDataConnectionTracker extends DataConnectionTracker {
|
||||
sendMessageDelayed(obtainMessage(EVENT_TRY_SETUP_DATA, apnContext),
|
||||
APN_DELAY_MILLIS);
|
||||
}
|
||||
|
||||
int refCount = releaseApnContext(apnContext, false);
|
||||
if (DBG) {
|
||||
log("onDataSetupComplete: error apn=%s" + apnString + " refCount=" + refCount);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user