summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Sudheer Shanka <sudheersai@google.com> 2023-03-01 08:31:45 +0000
committer Sudheer Shanka <sudheersai@google.com> 2023-03-07 00:16:21 +0000
commit7a42cc181acf82b7949762585299146877657f78 (patch)
treed64f214b67d11b0e436be4d632c718c647d3a925
parent08cd63f7057dfe09a242b278d8df001d1c3d581f (diff)
Send ACTION_SHUTDOWN as unordered broadcast with callback.
This broadcast was being sent as ordered in order to get the finish callback. Since the modern broadcast queue supports sending the finish callback without the need for having the broadcast marked as ordered, convert this broadcast to be sent as unordered with callback. Bug: 253226131 Test: TH Change-Id: I744884d846a9bdffca424ddbc07f9016d9300d02 Merged-In: I744884d846a9bdffca424ddbc07f9016d9300d02
-rw-r--r--services/core/java/com/android/server/power/ShutdownThread.java23
1 files changed, 13 insertions, 10 deletions
diff --git a/services/core/java/com/android/server/power/ShutdownThread.java b/services/core/java/com/android/server/power/ShutdownThread.java
index 5096ad1faf73..c2d4ac694c39 100644
--- a/services/core/java/com/android/server/power/ShutdownThread.java
+++ b/services/core/java/com/android/server/power/ShutdownThread.java
@@ -17,6 +17,7 @@
package com.android.server.power;
+import android.app.ActivityManagerInternal;
import android.app.AlertDialog;
import android.app.Dialog;
import android.app.IActivityManager;
@@ -25,10 +26,12 @@ import android.app.admin.SecurityLog;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.DialogInterface;
+import android.content.IIntentReceiver;
import android.content.Intent;
import android.content.IntentFilter;
import android.content.pm.PackageManagerInternal;
import android.media.AudioAttributes;
+import android.os.Bundle;
import android.os.FileUtils;
import android.os.Handler;
import android.os.PowerManager;
@@ -51,7 +54,6 @@ import android.view.WindowManager;
import com.android.server.LocalServices;
import com.android.server.RescueParty;
-import com.android.server.pm.PackageManagerService;
import com.android.server.statusbar.StatusBarManagerInternal;
import java.io.File;
@@ -448,13 +450,6 @@ public final class ShutdownThread extends Thread {
new File(CHECK_POINTS_FILE_BASENAME));
dumpCheckPointsThread.start();
- BroadcastReceiver br = new BroadcastReceiver() {
- @Override public void onReceive(Context context, Intent intent) {
- // We don't allow apps to cancel this, so ignore the result.
- actionDone();
- }
- };
-
/*
* Write a system property in case the system_server reboots before we
* get to the actual hardware restart. If that happens, we'll retry at
@@ -490,8 +485,16 @@ public final class ShutdownThread extends Thread {
mActionDone = false;
Intent intent = new Intent(Intent.ACTION_SHUTDOWN);
intent.addFlags(Intent.FLAG_RECEIVER_FOREGROUND | Intent.FLAG_RECEIVER_REGISTERED_ONLY);
- mContext.sendOrderedBroadcastAsUser(intent,
- UserHandle.ALL, null, br, mHandler, 0, null, null);
+ final ActivityManagerInternal activityManagerInternal = LocalServices.getService(
+ ActivityManagerInternal.class);
+ activityManagerInternal.broadcastIntentWithCallback(intent,
+ new IIntentReceiver.Stub() {
+ @Override
+ public void performReceive(Intent intent, int resultCode, String data,
+ Bundle extras, boolean ordered, boolean sticky, int sendingUser) {
+ mHandler.post(ShutdownThread.this::actionDone);
+ }
+ }, null, UserHandle.USER_ALL, null, null, null);
final long endTime = SystemClock.elapsedRealtime() + MAX_BROADCAST_TIME;
synchronized (mActionDoneSync) {