Skip to content

Commit 7efb89b

Browse files
Kazuhiro OndoWink Saville
authored andcommitted
Enhancement on ICS data stall polling logic
Put enhancements on data stall polling logic in ICS so that stall recovery can kick in earler while screen is on. Bug: 5767897 Change-Id: I4683fc45c0161f4374749c8e5840261c19a48f77
1 parent 0582da6 commit 7efb89b

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
@@ -3642,11 +3642,20 @@ public static final String getBluetoothInputDevicePriorityKey(String address) {
36423642
"pdp_watchdog_max_pdp_reset_fail_count";
36433643

36443644
/**
3645-
* The number of milliseconds to delay when checking for data stalls
3645+
* The number of milliseconds to delay when checking for data stalls during
3646+
* non-aggressive detection. (screen is turned off.)
36463647
* @hide
36473648
*/
3648-
public static final String DATA_STALL_ALARM_DELAY_IN_MS =
3649-
"data_stall_alarm_delay_in_ms";
3649+
public static final String DATA_STALL_ALARM_NON_AGGRESSIVE_DELAY_IN_MS =
3650+
"data_stall_alarm_non_aggressive_delay_in_ms";
3651+
3652+
/**
3653+
* The number of milliseconds to delay when checking for data stalls during
3654+
* aggressive detection. (screen on or suspected data stall)
3655+
* @hide
3656+
*/
3657+
public static final String DATA_STALL_ALARM_AGGRESSIVE_DELAY_IN_MS =
3658+
"data_stall_alarm_aggressive_delay_in_ms";
36503659

36513660
/**
36523661
* 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
@@ -157,6 +157,9 @@ protected String getActionIntentDataStallAlarm() {
157157
return INTENT_DATA_STALL_ALARM;
158158
}
159159

160+
@Override
161+
protected void restartDataStallAlarm() {}
162+
160163
@Override
161164
protected void setState(State s) {
162165
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.
@@ -1271,7 +1282,7 @@ private void notifyDefaultData(ApnContext apnContext) {
12711282
// setState(State.CONNECTED);
12721283
mPhone.notifyDataConnection(apnContext.getReason(), apnContext.getApnType());
12731284
startNetStatPoll();
1274-
startDataStallAlarm();
1285+
startDataStallAlarm(DATA_STALL_NOT_SUSPECTED);
12751286
// reset reconnect timer
12761287
apnContext.getDataConnection().resetRetryCount();
12771288
}
@@ -1437,18 +1448,20 @@ protected void onDataStallAlarm(int tag) {
14371448
Settings.Secure.PDP_WATCHDOG_TRIGGER_PACKET_COUNT,
14381449
NUMBER_SENT_PACKETS_OF_HANG);
14391450

1451+
boolean suspectedStall = DATA_STALL_NOT_SUSPECTED;
14401452
if (mSentSinceLastRecv >= hangWatchdogTrigger) {
14411453
if (DBG) {
14421454
log("onDataStallAlarm: tag=" + tag + " do recovery action=" + getRecoveryAction());
14431455
}
1456+
suspectedStall = DATA_STALL_SUSPECTED;
14441457
sendMessage(obtainMessage(EVENT_DO_RECOVERY));
14451458
} else {
14461459
if (VDBG) {
14471460
log("onDataStallAlarm: tag=" + tag + " Sent " + String.valueOf(mSentSinceLastRecv) +
14481461
" pkts since last received, < watchdogTrigger=" + hangWatchdogTrigger);
14491462
}
14501463
}
1451-
startDataStallAlarm();
1464+
startDataStallAlarm(suspectedStall);
14521465
}
14531466

14541467

@@ -1614,12 +1627,24 @@ private void startAlarmForReconnect(int delay, ApnContext apnContext) {
16141627

16151628
}
16161629

1617-
private void startDataStallAlarm() {
1618-
int delayInMs = Settings.Secure.getInt(mResolver,
1619-
Settings.Secure.DATA_STALL_ALARM_DELAY_IN_MS,
1620-
DATA_STALL_ALARM_DELAY_IN_MS_DEFAULT);
1630+
private void startDataStallAlarm(boolean suspectedStall) {
1631+
int nextAction = getRecoveryAction();
1632+
int delayInMs;
1633+
1634+
// If screen is on or data stall is currently suspected, set the alarm
1635+
// with an aggresive timeout.
1636+
if (mIsScreenOn || suspectedStall || RecoveryAction.isAggressiveRecovery(nextAction)) {
1637+
delayInMs = Settings.Secure.getInt(mResolver,
1638+
Settings.Secure.DATA_STALL_ALARM_AGGRESSIVE_DELAY_IN_MS,
1639+
DATA_STALL_ALARM_AGGRESSIVE_DELAY_IN_MS_DEFAULT);
1640+
} else {
1641+
delayInMs = Settings.Secure.getInt(mResolver,
1642+
Settings.Secure.DATA_STALL_ALARM_NON_AGGRESSIVE_DELAY_IN_MS,
1643+
DATA_STALL_ALARM_NON_AGGRESSIVE_DELAY_IN_MS_DEFAULT);
1644+
}
1645+
16211646
mDataStallAlarmTag += 1;
1622-
if (DBG) {
1647+
if (VDBG) {
16231648
log("startDataStallAlarm: tag=" + mDataStallAlarmTag +
16241649
" delay=" + (delayInMs / 1000) + "s");
16251650
}
@@ -1638,7 +1663,7 @@ private void stopDataStallAlarm() {
16381663
AlarmManager am =
16391664
(AlarmManager) mPhone.getContext().getSystemService(Context.ALARM_SERVICE);
16401665

1641-
if (DBG) {
1666+
if (VDBG) {
16421667
log("stopDataStallAlarm: current tag=" + mDataStallAlarmTag +
16431668
" mDataStallAlarmIntent=" + mDataStallAlarmIntent);
16441669
}
@@ -1649,6 +1674,20 @@ private void stopDataStallAlarm() {
16491674
}
16501675
}
16511676

1677+
@Override
1678+
protected void restartDataStallAlarm() {
1679+
// To be called on screen status change.
1680+
// Do not cancel the alarm if it is set with aggressive timeout.
1681+
int nextAction = getRecoveryAction();
1682+
1683+
if (RecoveryAction.isAggressiveRecovery(nextAction)) {
1684+
if (DBG) log("data stall recovery action is pending. not resetting the alarm.");
1685+
return;
1686+
}
1687+
stopDataStallAlarm();
1688+
startDataStallAlarm(DATA_STALL_NOT_SUSPECTED);
1689+
}
1690+
16521691
private void notifyNoData(GsmDataConnection.FailCause lastFailCauseCode,
16531692
ApnContext apnContext) {
16541693
if (DBG) log( "notifyNoData: type=" + apnContext.getApnType());
@@ -2044,7 +2083,7 @@ protected void onVoiceCallEnded() {
20442083
if (isConnected()) {
20452084
if (!mPhone.getServiceStateTracker().isConcurrentVoiceAndDataAllowed()) {
20462085
startNetStatPoll();
2047-
startDataStallAlarm();
2086+
startDataStallAlarm(DATA_STALL_NOT_SUSPECTED);
20482087
notifyDataConnection(Phone.REASON_VOICE_CALL_ENDED);
20492088
} else {
20502089
// clean slate after call end.
@@ -2386,7 +2425,7 @@ public void handleMessage (Message msg) {
23862425
mIsPsRestricted = false;
23872426
if (isConnected()) {
23882427
startNetStatPoll();
2389-
startDataStallAlarm();
2428+
startDataStallAlarm(DATA_STALL_NOT_SUSPECTED);
23902429
} else {
23912430
// TODO: Should all PDN states be checked to fail?
23922431
if (mState == State.FAILED) {

0 commit comments

Comments
 (0)