Skip to content

Commit 9a03482

Browse files
Wink SavilleAndroid Git Automerger
authored andcommitted
am 3ed2803: am c697ebf: Merge "Enhancement on ICS data stall polling logic" into ics-mr1
* commit '3ed2803691cc271fe6b893dc46d49fca2fce61df': Enhancement on ICS data stall polling logic
2 parents efd617e + 3ed2803 commit 9a03482

File tree

4 files changed

+73
-17
lines changed

4 files changed

+73
-17
lines changed

core/java/android/provider/Settings.java

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3678,11 +3678,20 @@ public static final String getBluetoothInputDevicePriorityKey(String address) {
36783678
"pdp_watchdog_max_pdp_reset_fail_count";
36793679

36803680
/**
3681-
* The number of milliseconds to delay when checking for data stalls
3681+
* The number of milliseconds to delay when checking for data stalls during
3682+
* non-aggressive detection. (screen is turned off.)
36823683
* @hide
36833684
*/
3684-
public static final String DATA_STALL_ALARM_DELAY_IN_MS =
3685-
"data_stall_alarm_delay_in_ms";
3685+
public static final String DATA_STALL_ALARM_NON_AGGRESSIVE_DELAY_IN_MS =
3686+
"data_stall_alarm_non_aggressive_delay_in_ms";
3687+
3688+
/**
3689+
* The number of milliseconds to delay when checking for data stalls during
3690+
* aggressive detection. (screen on or suspected data stall)
3691+
* @hide
3692+
*/
3693+
public static final String DATA_STALL_ALARM_AGGRESSIVE_DELAY_IN_MS =
3694+
"data_stall_alarm_aggressive_delay_in_ms";
36863695

36873696
/**
36883697
* The interval in milliseconds at which to check gprs registration

telephony/java/com/android/internal/telephony/DataConnectionTracker.java

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -212,8 +212,10 @@ public enum Activity {
212212
// represents an invalid IP address
213213
protected static final String NULL_IP = "0.0.0.0";
214214

215-
// Default for the data stall alarm
216-
protected static final int DATA_STALL_ALARM_DELAY_IN_MS_DEFAULT = 1000 * 60 * 6;
215+
// Default for the data stall alarm while non-aggressive stall detection
216+
protected static final int DATA_STALL_ALARM_NON_AGGRESSIVE_DELAY_IN_MS_DEFAULT = 1000 * 60 * 6;
217+
// Default for the data stall alarm for aggressive stall detection
218+
protected static final int DATA_STALL_ALARM_AGGRESSIVE_DELAY_IN_MS_DEFAULT = 1000 * 60;
217219
// If attempt is less than this value we're doing first level recovery
218220
protected static final int DATA_STALL_NO_RECV_POLL_LIMIT = 1;
219221
// Tag for tracking stale alarms
@@ -323,10 +325,12 @@ public void onReceive(Context context, Intent intent)
323325
mIsScreenOn = true;
324326
stopNetStatPoll();
325327
startNetStatPoll();
328+
restartDataStallAlarm();
326329
} else if (action.equals(Intent.ACTION_SCREEN_OFF)) {
327330
mIsScreenOn = false;
328331
stopNetStatPoll();
329332
startNetStatPoll();
333+
restartDataStallAlarm();
330334
} else if (action.startsWith(getActionIntentReconnectAlarm())) {
331335
log("Reconnect alarm. Previous state was " + mState);
332336
onActionIntentReconnectAlarm(intent);
@@ -622,6 +626,7 @@ private void handleDataOnRoamingChange() {
622626
protected abstract String getActionIntentDataStallAlarm();
623627
protected abstract void startNetStatPoll();
624628
protected abstract void stopNetStatPoll();
629+
protected abstract void restartDataStallAlarm();
625630
protected abstract void restartRadio();
626631
protected abstract void log(String s);
627632
protected abstract void loge(String s);

telephony/java/com/android/internal/telephony/cdma/CdmaDataConnectionTracker.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -161,6 +161,9 @@ protected String getActionIntentDataStallAlarm() {
161161
return INTENT_DATA_STALL_ALARM;
162162
}
163163

164+
@Override
165+
protected void restartDataStallAlarm() {}
166+
164167
@Override
165168
protected void setState(State s) {
166169
if (DBG) log ("setState: " + s);

telephony/java/com/android/internal/telephony/gsm/GsmDataConnectionTracker.java

Lines changed: 51 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -97,13 +97,21 @@ public void onChange(boolean selfChange) {
9797
private ContentResolver mResolver;
9898

9999
// Recovery action taken in case of data stall
100-
class RecoveryAction {
100+
private static class RecoveryAction {
101101
public static final int GET_DATA_CALL_LIST = 0;
102102
public static final int CLEANUP = 1;
103103
public static final int REREGISTER = 2;
104104
public static final int RADIO_RESTART = 3;
105105
public static final int RADIO_RESTART_WITH_PROP = 4;
106+
107+
private static boolean isAggressiveRecovery(int value) {
108+
return ((value == RecoveryAction.CLEANUP) ||
109+
(value == RecoveryAction.REREGISTER) ||
110+
(value == RecoveryAction.RADIO_RESTART) ||
111+
(value == RecoveryAction.RADIO_RESTART_WITH_PROP));
112+
}
106113
}
114+
107115
public int getRecoveryAction() {
108116
int action = Settings.System.getInt(mPhone.getContext().getContentResolver(),
109117
"radio.data.stall.recovery.action", RecoveryAction.GET_DATA_CALL_LIST);
@@ -131,6 +139,9 @@ public void putRecoveryAction(int action) {
131139
static final String APN_ID = "apn_id";
132140
private boolean canSetPreferApn = false;
133141

142+
private static final boolean DATA_STALL_SUSPECTED = true;
143+
private static final boolean DATA_STALL_NOT_SUSPECTED = false;
144+
134145
@Override
135146
protected void onActionIntentReconnectAlarm(Intent intent) {
136147
if (DBG) log("GPRS reconnect alarm. Previous state was " + mState);
@@ -586,7 +597,7 @@ private void onDataConnectionAttached() {
586597
if (getOverallState() == State.CONNECTED) {
587598
if (DBG) log("onDataConnectionAttached: start polling notify attached");
588599
startNetStatPoll();
589-
startDataStallAlarm();
600+
startDataStallAlarm(DATA_STALL_NOT_SUSPECTED);
590601
notifyDataConnection(Phone.REASON_DATA_ATTACHED);
591602
} else {
592603
// update APN availability so that APN can be enabled.
@@ -1267,7 +1278,7 @@ private void notifyDefaultData(ApnContext apnContext) {
12671278
// setState(State.CONNECTED);
12681279
mPhone.notifyDataConnection(apnContext.getReason(), apnContext.getApnType());
12691280
startNetStatPoll();
1270-
startDataStallAlarm();
1281+
startDataStallAlarm(DATA_STALL_NOT_SUSPECTED);
12711282
// reset reconnect timer
12721283
apnContext.getDataConnection().resetRetryCount();
12731284
}
@@ -1433,18 +1444,20 @@ protected void onDataStallAlarm(int tag) {
14331444
Settings.Secure.PDP_WATCHDOG_TRIGGER_PACKET_COUNT,
14341445
NUMBER_SENT_PACKETS_OF_HANG);
14351446

1447+
boolean suspectedStall = DATA_STALL_NOT_SUSPECTED;
14361448
if (mSentSinceLastRecv >= hangWatchdogTrigger) {
14371449
if (DBG) {
14381450
log("onDataStallAlarm: tag=" + tag + " do recovery action=" + getRecoveryAction());
14391451
}
1452+
suspectedStall = DATA_STALL_SUSPECTED;
14401453
sendMessage(obtainMessage(EVENT_DO_RECOVERY));
14411454
} else {
14421455
if (VDBG) {
14431456
log("onDataStallAlarm: tag=" + tag + " Sent " + String.valueOf(mSentSinceLastRecv) +
14441457
" pkts since last received, < watchdogTrigger=" + hangWatchdogTrigger);
14451458
}
14461459
}
1447-
startDataStallAlarm();
1460+
startDataStallAlarm(suspectedStall);
14481461
}
14491462

14501463

@@ -1610,12 +1623,24 @@ private void startAlarmForReconnect(int delay, ApnContext apnContext) {
16101623

16111624
}
16121625

1613-
private void startDataStallAlarm() {
1614-
int delayInMs = Settings.Secure.getInt(mResolver,
1615-
Settings.Secure.DATA_STALL_ALARM_DELAY_IN_MS,
1616-
DATA_STALL_ALARM_DELAY_IN_MS_DEFAULT);
1626+
private void startDataStallAlarm(boolean suspectedStall) {
1627+
int nextAction = getRecoveryAction();
1628+
int delayInMs;
1629+
1630+
// If screen is on or data stall is currently suspected, set the alarm
1631+
// with an aggresive timeout.
1632+
if (mIsScreenOn || suspectedStall || RecoveryAction.isAggressiveRecovery(nextAction)) {
1633+
delayInMs = Settings.Secure.getInt(mResolver,
1634+
Settings.Secure.DATA_STALL_ALARM_AGGRESSIVE_DELAY_IN_MS,
1635+
DATA_STALL_ALARM_AGGRESSIVE_DELAY_IN_MS_DEFAULT);
1636+
} else {
1637+
delayInMs = Settings.Secure.getInt(mResolver,
1638+
Settings.Secure.DATA_STALL_ALARM_NON_AGGRESSIVE_DELAY_IN_MS,
1639+
DATA_STALL_ALARM_NON_AGGRESSIVE_DELAY_IN_MS_DEFAULT);
1640+
}
1641+
16171642
mDataStallAlarmTag += 1;
1618-
if (DBG) {
1643+
if (VDBG) {
16191644
log("startDataStallAlarm: tag=" + mDataStallAlarmTag +
16201645
" delay=" + (delayInMs / 1000) + "s");
16211646
}
@@ -1634,7 +1659,7 @@ private void stopDataStallAlarm() {
16341659
AlarmManager am =
16351660
(AlarmManager) mPhone.getContext().getSystemService(Context.ALARM_SERVICE);
16361661

1637-
if (DBG) {
1662+
if (VDBG) {
16381663
log("stopDataStallAlarm: current tag=" + mDataStallAlarmTag +
16391664
" mDataStallAlarmIntent=" + mDataStallAlarmIntent);
16401665
}
@@ -1645,6 +1670,20 @@ private void stopDataStallAlarm() {
16451670
}
16461671
}
16471672

1673+
@Override
1674+
protected void restartDataStallAlarm() {
1675+
// To be called on screen status change.
1676+
// Do not cancel the alarm if it is set with aggressive timeout.
1677+
int nextAction = getRecoveryAction();
1678+
1679+
if (RecoveryAction.isAggressiveRecovery(nextAction)) {
1680+
if (DBG) log("data stall recovery action is pending. not resetting the alarm.");
1681+
return;
1682+
}
1683+
stopDataStallAlarm();
1684+
startDataStallAlarm(DATA_STALL_NOT_SUSPECTED);
1685+
}
1686+
16481687
private void notifyNoData(GsmDataConnection.FailCause lastFailCauseCode,
16491688
ApnContext apnContext) {
16501689
if (DBG) log( "notifyNoData: type=" + apnContext.getApnType());
@@ -2059,7 +2098,7 @@ protected void onVoiceCallEnded() {
20592098
if (isConnected()) {
20602099
if (!mPhone.getServiceStateTracker().isConcurrentVoiceAndDataAllowed()) {
20612100
startNetStatPoll();
2062-
startDataStallAlarm();
2101+
startDataStallAlarm(DATA_STALL_NOT_SUSPECTED);
20632102
notifyDataConnection(Phone.REASON_VOICE_CALL_ENDED);
20642103
} else {
20652104
// clean slate after call end.
@@ -2401,7 +2440,7 @@ public void handleMessage (Message msg) {
24012440
mIsPsRestricted = false;
24022441
if (isConnected()) {
24032442
startNetStatPoll();
2404-
startDataStallAlarm();
2443+
startDataStallAlarm(DATA_STALL_NOT_SUSPECTED);
24052444
} else {
24062445
// TODO: Should all PDN states be checked to fail?
24072446
if (mState == State.FAILED) {

0 commit comments

Comments
 (0)