From a81d7dace6e729a1f4f5dd3afc3d53c536e1996c Mon Sep 17 00:00:00 2001 From: Martin Wallgren Date: Mon, 4 Feb 2013 14:26:51 +0100 Subject: Set foreground priority for shutdown receivers. The broadcast of ACTION_SHUTDOWN has a timeout of 10 seconds. To reduce the risk of hitting the timeout and speeding up the shutdown sequence in ShutdownThread we set the priority of the BroadcastReceivers to FLAG_RECEIVER_FOREGROUND. We have seen that this change reduces the shutdown time when the system is under heavy load. Change-Id: I22cbf6af8cf6fc4bdefaa1c3da8a7eed7e7b7674 --- services/java/com/android/server/power/ShutdownThread.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'services') diff --git a/services/java/com/android/server/power/ShutdownThread.java b/services/java/com/android/server/power/ShutdownThread.java index c7f7390..c084666 100644 --- a/services/java/com/android/server/power/ShutdownThread.java +++ b/services/java/com/android/server/power/ShutdownThread.java @@ -297,7 +297,9 @@ public final class ShutdownThread extends Thread { // First send the high-level shut down broadcast. mActionDone = false; - mContext.sendOrderedBroadcastAsUser(new Intent(Intent.ACTION_SHUTDOWN), + Intent intent = new Intent(Intent.ACTION_SHUTDOWN); + intent.addFlags(Intent.FLAG_RECEIVER_FOREGROUND); + mContext.sendOrderedBroadcastAsUser(intent, UserHandle.ALL, null, br, mHandler, 0, null, null); final long endTime = SystemClock.elapsedRealtime() + MAX_BROADCAST_TIME; -- cgit v1.1