DcRetryAlarmControllerpublic class DcRetryAlarmController extends Object The Data Connection Retry Alarm Controller. |
Fields Summary |
---|
private String | mLogTag | private static final boolean | DBG | private com.android.internal.telephony.PhoneBase | mPhone | private DataConnection | mDc | private android.app.AlarmManager | mAlarmManager | private String | mActionRetry | private static final String | INTENT_RETRY_ALARM_WHAT | private static final String | INTENT_RETRY_ALARM_TAG | private android.content.BroadcastReceiver | mIntentReceiver |
Constructors Summary |
---|
DcRetryAlarmController(com.android.internal.telephony.PhoneBase phone, DataConnection dc)
mLogTag = dc.getName();
mPhone = phone;
mDc = dc;
mAlarmManager = (AlarmManager) mPhone.getContext().getSystemService(Context.ALARM_SERVICE);
mActionRetry = mDc.getClass().getCanonicalName() + "." + mDc.getName() + ".action_retry";
IntentFilter filter = new IntentFilter();
filter.addAction(mActionRetry);
log("DcRetryAlarmController: register for intent action=" + mActionRetry);
mPhone.getContext().registerReceiver(mIntentReceiver, filter, null, mDc.getHandler());
|
Methods Summary |
---|
void | dispose()Dispose of resources when shutting down
if (DBG) log("dispose");
mPhone.getContext().unregisterReceiver(mIntentReceiver);
mPhone = null;
mDc = null;
mAlarmManager = null;
mActionRetry = null;
| int | getSuggestedRetryTime(DataConnection dc, android.os.AsyncResult ar)Using dc.mRetryManager and the result of the SETUP_DATA_CALL determine
the retry delay.
int retryDelay;
DataCallResponse response = (DataCallResponse) ar.result;
retryDelay = response.suggestedRetryTime;
if (retryDelay == RILConstants.MAX_INT) {
if (DBG) log("getSuggestedRetryTime: suggestedRetryTime is MAX_INT, retry NOT needed");
retryDelay = -1;
} else if (retryDelay >= 0) {
if (DBG) log("getSuggestedRetryTime: suggestedRetryTime is >= 0 use it");
} else if (dc.mRetryManager.isRetryNeeded()) {
retryDelay = dc.mRetryManager.getRetryTimer();
if (retryDelay < 0) {
retryDelay = 0;
}
if (DBG) log("getSuggestedRetryTime: retry is needed");
} else {
if (DBG) log("getSuggestedRetryTime: retry is NOT needed");
retryDelay = -1;
}
if (DBG) {
log("getSuggestedRetryTime: " + retryDelay + " response=" + response + " dc=" + dc);
}
return retryDelay;
| private void | log(java.lang.String s)
Rlog.d(mLogTag, "[dcRac] " + s);
| public void | startRetryAlarm(int what, int tag, int delay)
Intent intent = new Intent(mActionRetry);
intent.putExtra(INTENT_RETRY_ALARM_WHAT, what);
intent.putExtra(INTENT_RETRY_ALARM_TAG, tag);
if (DBG) {
log("startRetryAlarm: next attempt in " + (delay / 1000) + "s" +
" what=" + what + " tag=" + tag);
}
PendingIntent retryIntent = PendingIntent.getBroadcast (mPhone.getContext(), 0,
intent, PendingIntent.FLAG_UPDATE_CURRENT);
mAlarmManager.set(AlarmManager.ELAPSED_REALTIME_WAKEUP,
SystemClock.elapsedRealtime() + delay, retryIntent);
| public java.lang.String | toString()
StringBuilder sb = new StringBuilder();
sb.append(mLogTag).append(" [dcRac] ");
sb.append(" mPhone=").append(mPhone);
sb.append(" mDc=").append(mDc);
sb.append(" mAlaramManager=").append(mAlarmManager);
sb.append(" mActionRetry=").append(mActionRetry);
return sb.toString();
|
|