Skip to content

Commit dc46f6f

Browse files
jhamAndroid (Google) Code Review
authored andcommitted
Merge "Don't enforce broadcast timeouts for PRE_BOOT_COMPLETED broadcasts." into froyo
2 parents b3f3cae + acf8474 commit dc46f6f

File tree

1 file changed

+14
-4
lines changed

1 file changed

+14
-4
lines changed

services/java/com/android/server/am/ActivityManagerService.java

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1106,7 +1106,12 @@ public void handleMessage(Message msg) {
11061106
mHandler.sendMessageDelayed(nmsg, BROADCAST_TIMEOUT);
11071107
return;
11081108
}
1109-
broadcastTimeout();
1109+
// Only process broadcast timeouts if the system is ready. That way
1110+
// PRE_BOOT_COMPLETED broadcasts can't timeout as they are intended
1111+
// to do heavy lifting for system up
1112+
if (mSystemReady) {
1113+
broadcastTimeout();
1114+
}
11101115
} break;
11111116
case PAUSE_TIMEOUT_MSG: {
11121117
IBinder token = (IBinder)msg.obj;
@@ -13116,10 +13121,15 @@ private final void processNextBroadcast(boolean fromMsg) {
1311613121

1311713122
// Ensure that even if something goes awry with the timeout
1311813123
// detection, we catch "hung" broadcasts here, discard them,
13119-
// and continue to make progress.
13124+
// and continue to make progress.
13125+
//
13126+
// This is only done if the system is ready so that PRE_BOOT_COMPLETED
13127+
// receivers don't get executed with with timeouts. They're intended for
13128+
// one time heavy lifting after system upgrades and can take
13129+
// significant amounts of time.
1312013130
int numReceivers = (r.receivers != null) ? r.receivers.size() : 0;
13121-
long now = SystemClock.uptimeMillis();
13122-
if (r.dispatchTime > 0) {
13131+
if (mSystemReady && r.dispatchTime > 0) {
13132+
long now = SystemClock.uptimeMillis();
1312313133
if ((numReceivers > 0) &&
1312413134
(now > r.dispatchTime + (2*BROADCAST_TIMEOUT*numReceivers))) {
1312513135
Slog.w(TAG, "Hung broadcast discarded after timeout failure:"

0 commit comments

Comments
 (0)