am 93300ce2: Merge "Enable recovery in RIL wakelock release check." into gingerbread
* commit '93300ce2d398195d5616a2e924eb4a785274538e': Enable recovery in RIL wakelock release check.
This commit is contained in:
@@ -226,7 +226,15 @@ public final class RIL extends BaseCommands implements CommandsInterface {
|
|||||||
private Context mContext;
|
private Context mContext;
|
||||||
WakeLock mWakeLock;
|
WakeLock mWakeLock;
|
||||||
int mWakeLockTimeout;
|
int mWakeLockTimeout;
|
||||||
|
// The number of requests pending to be sent out, it increases before calling
|
||||||
|
// EVENT_SEND and decreases while handling EVENT_SEND. It gets cleared while
|
||||||
|
// WAKE_LOCK_TIMEOUT occurs.
|
||||||
int mRequestMessagesPending;
|
int mRequestMessagesPending;
|
||||||
|
// The number of requests sent out but waiting for response. It increases while
|
||||||
|
// sending request and decreases while handling response. It should match
|
||||||
|
// mRequestList.size() unless there are requests no replied while
|
||||||
|
// WAKE_LOCK_TIMEOUT occurs.
|
||||||
|
int mRequestMessagesWaiting;
|
||||||
|
|
||||||
// Is this the first radio state change?
|
// Is this the first radio state change?
|
||||||
private boolean mInitialRadioStateChange = true;
|
private boolean mInitialRadioStateChange = true;
|
||||||
@@ -309,16 +317,19 @@ public final class RIL extends BaseCommands implements CommandsInterface {
|
|||||||
if (s == null) {
|
if (s == null) {
|
||||||
rr.onError(RADIO_NOT_AVAILABLE, null);
|
rr.onError(RADIO_NOT_AVAILABLE, null);
|
||||||
rr.release();
|
rr.release();
|
||||||
mRequestMessagesPending--;
|
if (mRequestMessagesPending > 0)
|
||||||
|
mRequestMessagesPending--;
|
||||||
alreadySubtracted = true;
|
alreadySubtracted = true;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
synchronized (mRequestsList) {
|
synchronized (mRequestsList) {
|
||||||
mRequestsList.add(rr);
|
mRequestsList.add(rr);
|
||||||
|
mRequestMessagesWaiting++;
|
||||||
}
|
}
|
||||||
|
|
||||||
mRequestMessagesPending--;
|
if (mRequestMessagesPending > 0)
|
||||||
|
mRequestMessagesPending--;
|
||||||
alreadySubtracted = true;
|
alreadySubtracted = true;
|
||||||
|
|
||||||
byte[] data;
|
byte[] data;
|
||||||
@@ -367,7 +378,7 @@ public final class RIL extends BaseCommands implements CommandsInterface {
|
|||||||
releaseWakeLockIfDone();
|
releaseWakeLockIfDone();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!alreadySubtracted) {
|
if (!alreadySubtracted && mRequestMessagesPending > 0) {
|
||||||
mRequestMessagesPending--;
|
mRequestMessagesPending--;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -382,25 +393,48 @@ public final class RIL extends BaseCommands implements CommandsInterface {
|
|||||||
// new send request. So when WAKE_LOCK_TIMEOUT occurs
|
// new send request. So when WAKE_LOCK_TIMEOUT occurs
|
||||||
// all requests in mRequestList already waited at
|
// all requests in mRequestList already waited at
|
||||||
// least DEFAULT_WAKE_LOCK_TIMEOUT but no response.
|
// least DEFAULT_WAKE_LOCK_TIMEOUT but no response.
|
||||||
// Therefore all should be treated as lost requests.
|
// Reset mRequestMessagesWaiting to enable
|
||||||
// Those lost requests return GENERIC_FAILURE and
|
// releaseWakeLockIfDone().
|
||||||
// request list is cleared.
|
|
||||||
//
|
//
|
||||||
// Note: mRequestMessagesPending shows how many
|
// Note: Keep mRequestList so that delayed response
|
||||||
// requests are waiting to be sent (and before
|
// can still be handled when response finally comes.
|
||||||
// to be added in request list) since star the
|
if (mRequestMessagesWaiting != 0) {
|
||||||
// timer. It should be
|
Log.d(LOG_TAG, "NOTE: mReqWaiting is NOT 0 but"
|
||||||
// zero here since all request should already
|
+ mRequestMessagesWaiting + " at TIMEOUT, reset!"
|
||||||
// be put in request list while TIMEOUT occurs.
|
+ " There still msg waitng for response");
|
||||||
clearRequestsList(GENERIC_FAILURE, true);
|
|
||||||
|
mRequestMessagesWaiting = 0;
|
||||||
|
|
||||||
|
if (RILJ_LOGD) {
|
||||||
|
synchronized (mRequestsList) {
|
||||||
|
int count = mRequestsList.size();
|
||||||
|
Log.d(LOG_TAG, "WAKE_LOCK_TIMEOUT " +
|
||||||
|
" mRequestList=" + count);
|
||||||
|
|
||||||
|
for (int i = 0; i < count; i++) {
|
||||||
|
rr = mRequestsList.get(i);
|
||||||
|
Log.d(LOG_TAG, i + ": [" + rr.mSerial + "] "
|
||||||
|
+ requestToString(rr.mRequest));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// mRequestMessagesPending shows how many
|
||||||
|
// requests are waiting to be sent (and before
|
||||||
|
// to be added in request list) since star the
|
||||||
|
// WAKE_LOCK_TIMEOUT timer. Since WAKE_LOCK_TIMEOUT
|
||||||
|
// is the expected time to get response, all requests
|
||||||
|
// should already sent out (i.e.
|
||||||
|
// mRequestMessagesPending is 0 )while TIMEOUT occurs.
|
||||||
if (mRequestMessagesPending != 0) {
|
if (mRequestMessagesPending != 0) {
|
||||||
Log.e(LOG_TAG, "ERROR: mReqPending is NOT 0 at TIMEOUT, "
|
Log.e(LOG_TAG, "ERROR: mReqPending is NOT 0 but"
|
||||||
+ "mReqPending = " + mRequestMessagesPending);
|
+ mRequestMessagesPending + " at TIMEOUT, reset!");
|
||||||
|
mRequestMessagesPending = 0;
|
||||||
|
|
||||||
}
|
}
|
||||||
mWakeLock.release();
|
mWakeLock.release();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -613,6 +647,7 @@ public final class RIL extends BaseCommands implements CommandsInterface {
|
|||||||
mWakeLockTimeout = SystemProperties.getInt(TelephonyProperties.PROPERTY_WAKE_LOCK_TIMEOUT,
|
mWakeLockTimeout = SystemProperties.getInt(TelephonyProperties.PROPERTY_WAKE_LOCK_TIMEOUT,
|
||||||
DEFAULT_WAKE_LOCK_TIMEOUT);
|
DEFAULT_WAKE_LOCK_TIMEOUT);
|
||||||
mRequestMessagesPending = 0;
|
mRequestMessagesPending = 0;
|
||||||
|
mRequestMessagesWaiting = 0;
|
||||||
|
|
||||||
mContext = context;
|
mContext = context;
|
||||||
|
|
||||||
@@ -2010,7 +2045,7 @@ public final class RIL extends BaseCommands implements CommandsInterface {
|
|||||||
/**
|
/**
|
||||||
* Holds a PARTIAL_WAKE_LOCK whenever
|
* Holds a PARTIAL_WAKE_LOCK whenever
|
||||||
* a) There is outstanding RIL request sent to RIL deamon and no replied
|
* a) There is outstanding RIL request sent to RIL deamon and no replied
|
||||||
* b) There is a request waiting to be sent out.
|
* b) There is a request pending to be sent out.
|
||||||
*
|
*
|
||||||
* There is a WAKE_LOCK_TIMEOUT to release the lock, though it shouldn't
|
* There is a WAKE_LOCK_TIMEOUT to release the lock, though it shouldn't
|
||||||
* happen often.
|
* happen often.
|
||||||
@@ -2033,7 +2068,7 @@ public final class RIL extends BaseCommands implements CommandsInterface {
|
|||||||
synchronized (mWakeLock) {
|
synchronized (mWakeLock) {
|
||||||
if (mWakeLock.isHeld() &&
|
if (mWakeLock.isHeld() &&
|
||||||
(mRequestMessagesPending == 0) &&
|
(mRequestMessagesPending == 0) &&
|
||||||
(mRequestsList.size() == 0)) {
|
(mRequestMessagesWaiting == 0)) {
|
||||||
mSender.removeMessages(EVENT_WAKE_LOCK_TIMEOUT);
|
mSender.removeMessages(EVENT_WAKE_LOCK_TIMEOUT);
|
||||||
mWakeLock.release();
|
mWakeLock.release();
|
||||||
}
|
}
|
||||||
@@ -2097,6 +2132,7 @@ public final class RIL extends BaseCommands implements CommandsInterface {
|
|||||||
rr.release();
|
rr.release();
|
||||||
}
|
}
|
||||||
mRequestsList.clear();
|
mRequestsList.clear();
|
||||||
|
mRequestMessagesWaiting = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -2107,6 +2143,8 @@ public final class RIL extends BaseCommands implements CommandsInterface {
|
|||||||
|
|
||||||
if (rr.mSerial == serial) {
|
if (rr.mSerial == serial) {
|
||||||
mRequestsList.remove(i);
|
mRequestsList.remove(i);
|
||||||
|
if (mRequestMessagesWaiting > 0)
|
||||||
|
mRequestMessagesWaiting--;
|
||||||
return rr;
|
return rr;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user