am d3924fe9: Merge "Data Connection: Use Alarm for all delayed data retries." into honeycomb-LTE
* commit 'd3924fe9f6c99bc92ed86195e07ba82d39043812': Data Connection: Use Alarm for all delayed data retries.
This commit is contained in:
@@ -521,19 +521,7 @@ public final class CdmaDataConnectionTracker extends DataConnectionTracker {
|
|||||||
* TODO: Make this configurable?
|
* TODO: Make this configurable?
|
||||||
*/
|
*/
|
||||||
int nextReconnectDelay = mDataConnections.get(0).getRetryTimer();
|
int nextReconnectDelay = mDataConnections.get(0).getRetryTimer();
|
||||||
log("Data Connection activate failed. Scheduling next attempt for "
|
startAlarmForReconnect(nextReconnectDelay, reason);
|
||||||
+ (nextReconnectDelay / 1000) + "s");
|
|
||||||
|
|
||||||
AlarmManager am =
|
|
||||||
(AlarmManager) mPhone.getContext().getSystemService(Context.ALARM_SERVICE);
|
|
||||||
Intent intent = new Intent(INTENT_RECONNECT_ALARM);
|
|
||||||
intent.putExtra(INTENT_RECONNECT_ALARM_EXTRA_REASON, reason);
|
|
||||||
mReconnectIntent = PendingIntent.getBroadcast(
|
|
||||||
mPhone.getContext(), 0, intent, 0);
|
|
||||||
am.set(AlarmManager.ELAPSED_REALTIME_WAKEUP,
|
|
||||||
SystemClock.elapsedRealtime() + nextReconnectDelay,
|
|
||||||
mReconnectIntent);
|
|
||||||
|
|
||||||
mDataConnections.get(0).increaseRetryCount();
|
mDataConnections.get(0).increaseRetryCount();
|
||||||
|
|
||||||
if (!shouldPostNotification(lastFailCauseCode)) {
|
if (!shouldPostNotification(lastFailCauseCode)) {
|
||||||
@@ -545,6 +533,22 @@ public final class CdmaDataConnectionTracker extends DataConnectionTracker {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void startAlarmForReconnect(int delay, String reason) {
|
||||||
|
|
||||||
|
log("Data Connection activate failed. Scheduling next attempt for "
|
||||||
|
+ (delay / 1000) + "s");
|
||||||
|
|
||||||
|
AlarmManager am =
|
||||||
|
(AlarmManager) mPhone.getContext().getSystemService(Context.ALARM_SERVICE);
|
||||||
|
Intent intent = new Intent(INTENT_RECONNECT_ALARM);
|
||||||
|
intent.putExtra(INTENT_RECONNECT_ALARM_EXTRA_REASON, reason);
|
||||||
|
mReconnectIntent = PendingIntent.getBroadcast(
|
||||||
|
mPhone.getContext(), 0, intent, 0);
|
||||||
|
am.set(AlarmManager.ELAPSED_REALTIME_WAKEUP,
|
||||||
|
SystemClock.elapsedRealtime() + delay, mReconnectIntent);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
private void notifyNoData(FailCause lastFailCauseCode) {
|
private void notifyNoData(FailCause lastFailCauseCode) {
|
||||||
setState(State.FAILED);
|
setState(State.FAILED);
|
||||||
notifyDataAvailability(null);
|
notifyDataAvailability(null);
|
||||||
@@ -702,7 +706,7 @@ public final class CdmaDataConnectionTracker extends DataConnectionTracker {
|
|||||||
mActiveApn = null;
|
mActiveApn = null;
|
||||||
if (retryAfterDisconnected(reason)) {
|
if (retryAfterDisconnected(reason)) {
|
||||||
// Wait a bit before trying, so we're not tying up RIL command channel.
|
// Wait a bit before trying, so we're not tying up RIL command channel.
|
||||||
sendMessageDelayed(obtainMessage(EVENT_TRY_SETUP_DATA, reason), APN_DELAY_MILLIS);
|
startAlarmForReconnect(APN_DELAY_MILLIS, reason);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1406,23 +1406,7 @@ public final class GsmDataConnectionTracker extends DataConnectionTracker {
|
|||||||
}
|
}
|
||||||
|
|
||||||
int nextReconnectDelay = apnContext.getDataConnection().getRetryTimer();
|
int nextReconnectDelay = apnContext.getDataConnection().getRetryTimer();
|
||||||
if (DBG) {
|
startAlarmForReconnect(nextReconnectDelay, apnContext);
|
||||||
log("reconnectAfterFail: activate failed. Scheduling next attempt for "
|
|
||||||
+ (nextReconnectDelay / 1000) + "s");
|
|
||||||
}
|
|
||||||
|
|
||||||
AlarmManager am =
|
|
||||||
(AlarmManager) mPhone.getContext().getSystemService(Context.ALARM_SERVICE);
|
|
||||||
Intent intent = new Intent(INTENT_RECONNECT_ALARM);
|
|
||||||
intent.putExtra(INTENT_RECONNECT_ALARM_EXTRA_REASON, apnContext.getReason());
|
|
||||||
// Should put an extra of apn type?
|
|
||||||
intent.putExtra(INTENT_RECONNECT_ALARM_EXTRA_TYPE, apnContext.getApnType());
|
|
||||||
apnContext.setReconnectIntent(PendingIntent.getBroadcast (
|
|
||||||
mPhone.getContext(), 0, intent, 0));
|
|
||||||
am.set(AlarmManager.ELAPSED_REALTIME_WAKEUP,
|
|
||||||
SystemClock.elapsedRealtime() + nextReconnectDelay,
|
|
||||||
apnContext.getReconnectIntent());
|
|
||||||
|
|
||||||
apnContext.getDataConnection().increaseRetryCount();
|
apnContext.getDataConnection().increaseRetryCount();
|
||||||
|
|
||||||
if (!shouldPostNotification(lastFailCauseCode)) {
|
if (!shouldPostNotification(lastFailCauseCode)) {
|
||||||
@@ -1436,6 +1420,25 @@ public final class GsmDataConnectionTracker extends DataConnectionTracker {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void startAlarmForReconnect(int delay, ApnContext apnContext) {
|
||||||
|
|
||||||
|
if (DBG) {
|
||||||
|
log("Schedule alarm for reconnect: activate failed. Scheduling next attempt for "
|
||||||
|
+ (delay / 1000) + "s");
|
||||||
|
}
|
||||||
|
|
||||||
|
AlarmManager am =
|
||||||
|
(AlarmManager) mPhone.getContext().getSystemService(Context.ALARM_SERVICE);
|
||||||
|
Intent intent = new Intent(INTENT_RECONNECT_ALARM);
|
||||||
|
intent.putExtra(INTENT_RECONNECT_ALARM_EXTRA_REASON, apnContext.getReason());
|
||||||
|
intent.putExtra(INTENT_RECONNECT_ALARM_EXTRA_TYPE, apnContext.getApnType());
|
||||||
|
apnContext.setReconnectIntent(PendingIntent.getBroadcast (
|
||||||
|
mPhone.getContext(), 0, intent, 0));
|
||||||
|
am.set(AlarmManager.ELAPSED_REALTIME_WAKEUP,
|
||||||
|
SystemClock.elapsedRealtime() + delay, apnContext.getReconnectIntent());
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
private void notifyNoData(GsmDataConnection.FailCause lastFailCauseCode,
|
private void notifyNoData(GsmDataConnection.FailCause lastFailCauseCode,
|
||||||
ApnContext apnContext) {
|
ApnContext apnContext) {
|
||||||
if (DBG) log( "notifyNoData: type=" + apnContext.getApnType());
|
if (DBG) log( "notifyNoData: type=" + apnContext.getApnType());
|
||||||
@@ -1723,8 +1726,7 @@ public final class GsmDataConnectionTracker extends DataConnectionTracker {
|
|||||||
apnContext.setState(State.SCANNING);
|
apnContext.setState(State.SCANNING);
|
||||||
// Wait a bit before trying the next APN, so that
|
// Wait a bit before trying the next APN, so that
|
||||||
// we're not tying up the RIL command channel
|
// we're not tying up the RIL command channel
|
||||||
sendMessageDelayed(obtainMessage(EVENT_TRY_SETUP_DATA, apnContext),
|
startAlarmForReconnect(APN_DELAY_MILLIS, apnContext);
|
||||||
APN_DELAY_MILLIS);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1764,7 +1766,7 @@ public final class GsmDataConnectionTracker extends DataConnectionTracker {
|
|||||||
// Wait a bit before trying the next APN, so that
|
// Wait a bit before trying the next APN, so that
|
||||||
// we're not tying up the RIL command channel.
|
// we're not tying up the RIL command channel.
|
||||||
// This also helps in any external dependency to turn off the context.
|
// This also helps in any external dependency to turn off the context.
|
||||||
sendMessageDelayed(obtainMessage(EVENT_TRY_SETUP_DATA, apnContext),APN_DELAY_MILLIS);
|
startAlarmForReconnect(APN_DELAY_MILLIS, apnContext);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user