Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 19965bc4 authored by Sudheer Shanka's avatar Sudheer Shanka
Browse files

Add deferral-until-active policy to ACTION_SHUTDOWN broadcast.

We shouldn't need to wake the frozen apps for delivering this
broadcast. This is only sent to registered receivers and apps
would have been killed and wouldn't have received this broadcast
if weren't freezing them.

Bug: 313680784
Test: boot and shutdown works
Change-Id: I06412e2a93190a45436ec85c541a128d3cb395f1
parent 546a73c3
Loading
Loading
Loading
Loading
+5 −1
Original line number Diff line number Diff line
@@ -19,6 +19,7 @@ package com.android.server.power;

import android.app.ActivityManagerInternal;
import android.app.AlertDialog;
import android.app.BroadcastOptions;
import android.app.Dialog;
import android.app.IActivityManager;
import android.app.ProgressDialog;
@@ -493,6 +494,9 @@ 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);
        final Bundle opts = BroadcastOptions.makeBasic()
                .setDeferralPolicy(BroadcastOptions.DEFERRAL_POLICY_UNTIL_ACTIVE)
                .toBundle();
        final ActivityManagerInternal activityManagerInternal = LocalServices.getService(
                ActivityManagerInternal.class);
        activityManagerInternal.broadcastIntentWithCallback(intent,
@@ -502,7 +506,7 @@ public final class ShutdownThread extends Thread {
                            Bundle extras, boolean ordered, boolean sticky, int sendingUser) {
                        mHandler.post(ShutdownThread.this::actionDone);
                    }
                }, null, UserHandle.USER_ALL, null, null, null);
                }, null, UserHandle.USER_ALL, null, null, opts);

        final long endTime = SystemClock.elapsedRealtime() + MAX_BROADCAST_TIME;
        synchronized (mActionDoneSync) {