Skip to content

Commit 00d520b

Browse files
author
John Wang
committed
Clear request list while timeout.
The wakelock will be kept held if there is outstanding requests in request list. When WAKE_LOCK_TIMEOUT occurs, all requests in mRequestList already waited at least DEFAULT_WAKE_LOCK_TIMEOUT but no response. Those lost requests return GENERIC_FAILURE and request list is cleared. bug:3292426 Change-Id: I369c6ba4d6836d65ef616140e48c7304faf888f0
1 parent 6eef0ca commit 00d520b

File tree

1 file changed

+47
-24
lines changed
  • telephony/java/com/android/internal/telephony

1 file changed

+47
-24
lines changed

telephony/java/com/android/internal/telephony/RIL.java

Lines changed: 47 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -370,23 +370,26 @@ public RILSender(Looper looper) {
370370
case EVENT_WAKE_LOCK_TIMEOUT:
371371
// Haven't heard back from the last request. Assume we're
372372
// not getting a response and release the wake lock.
373-
// TODO should we clean up mRequestList and mRequestPending
374373
synchronized (mWakeLock) {
375374
if (mWakeLock.isHeld()) {
376-
if (RILJ_LOGD) {
377-
synchronized (mRequestsList) {
378-
int count = mRequestsList.size();
379-
Log.d(LOG_TAG, "WAKE_LOCK_TIMEOUT " +
380-
" mReqPending=" + mRequestMessagesPending +
381-
" mRequestList=" + count);
382-
383-
for (int i = 0; i < count; i++) {
384-
rr = mRequestsList.get(i);
385-
Log.d(LOG_TAG, i + ": [" + rr.mSerial + "] " +
386-
requestToString(rr.mRequest));
387-
388-
}
389-
}
375+
// The timer of WAKE_LOCK_TIMEOUT is reset with each
376+
// new send request. So when WAKE_LOCK_TIMEOUT occurs
377+
// all requests in mRequestList already waited at
378+
// least DEFAULT_WAKE_LOCK_TIMEOUT but no response.
379+
// Therefore all should be treated as lost requests.
380+
// Those lost requests return GENERIC_FAILURE and
381+
// request list is cleared.
382+
//
383+
// Note: mRequestMessagesPending shows how many
384+
// requests are waiting to be sent (and before
385+
// to be added in request list) since star the
386+
// timer. It should be
387+
// zero here since all request should already
388+
// be put in request list while TIMEOUT occurs.
389+
clearRequestsList(GENERIC_FAILURE, true);
390+
if (mRequestMessagesPending != 0) {
391+
Log.e(LOG_TAG, "ERROR: mReqPending is NOT 0 at TIMEOUT, "
392+
+ "mReqPending = " + mRequestMessagesPending);
390393
}
391394
mWakeLock.release();
392395
}
@@ -558,15 +561,7 @@ class RILReceiver implements Runnable {
558561
RILRequest.resetSerial();
559562

560563
// Clear request list on close
561-
synchronized (mRequestsList) {
562-
for (int i = 0, sz = mRequestsList.size() ; i < sz ; i++) {
563-
RILRequest rr = mRequestsList.get(i);
564-
rr.onError(RADIO_NOT_AVAILABLE, null);
565-
rr.release();
566-
}
567-
568-
mRequestsList.clear();
569-
}
564+
clearRequestsList(RADIO_NOT_AVAILABLE, false);
570565
}} catch (Throwable tr) {
571566
Log.e(LOG_TAG,"Uncaught exception", tr);
572567
}
@@ -2061,6 +2056,34 @@ private void setRadioStateFromRILInt(int state) {
20612056
releaseWakeLockIfDone();
20622057
}
20632058

2059+
/**
2060+
* Release each request in mReqeustsList then clear the list
2061+
* @param error is the RIL_Errno sent back
2062+
* @param loggable true means to print all requests in mRequestslist
2063+
*/
2064+
private void clearRequestsList(int error, boolean loggable) {
2065+
RILRequest rr;
2066+
synchronized (mRequestsList) {
2067+
int count = mRequestsList.size();
2068+
if (RILJ_LOGD && loggable) {
2069+
Log.d(LOG_TAG, "WAKE_LOCK_TIMEOUT " +
2070+
" mReqPending=" + mRequestMessagesPending +
2071+
" mRequestList=" + count);
2072+
}
2073+
2074+
for (int i = 0; i < count ; i++) {
2075+
rr = mRequestsList.get(i);
2076+
if (RILJ_LOGD && loggable) {
2077+
Log.d(LOG_TAG, i + ": [" + rr.mSerial + "] " +
2078+
requestToString(rr.mRequest));
2079+
}
2080+
rr.onError(error, null);
2081+
rr.release();
2082+
}
2083+
mRequestsList.clear();
2084+
}
2085+
}
2086+
20642087
private RILRequest findAndRemoveRequestFromList(int serial) {
20652088
synchronized (mRequestsList) {
20662089
for (int i = 0, s = mRequestsList.size() ; i < s ; i++) {

0 commit comments

Comments
 (0)