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

Commit b62f9594 authored by Mike Lockwood's avatar Mike Lockwood
Browse files

Fix problems with new PowerManager.reboot() implementation.



ShutdownThread.reboot() does return so we need to block after calling it
to prevent PowerManager.reboot() from returning.

Since PowerManager.reboot() can now take significantly longer than before,
we now ignore ANRs during shutdown.

Change-Id: Ibceeb265ae382567215f6a399108d8be3a7bbc95
Signed-off-by: default avatarMike Lockwood <lockwood@android.com>
parent a91e9727
Loading
Loading
Loading
Loading
+8 −12
Original line number Diff line number Diff line
@@ -2211,26 +2211,22 @@ class PowerManagerService extends IPowerManager.Stub
            public void run() {
                synchronized (this) {
                    ShutdownThread.reboot(mContext, finalReason, false);
                    // if we get here we failed
                    notify();
                }
                
            }
        };

        // ShutdownThread must run on a looper capable of displaying the UI.
        mHandler.post(runnable);

        // block until we reboot or fail.
        // throw an exception if we failed to reboot
        // PowerManager.reboot() is documented not to return so just wait for the inevitable.
        synchronized (runnable) {
            while (true) {
                try {
                    runnable.wait();
                } catch (InterruptedException e) {
                }
            }
     
        // if we get here we failed
        throw new IllegalStateException("unable to reboot!");
        }
    }

    /**
+2 −1
Original line number Diff line number Diff line
@@ -4708,7 +4708,8 @@ public final class ActivityManagerService extends ActivityManagerNative implemen
    final void appNotRespondingLocked(ProcessRecord app, HistoryRecord activity,
            HistoryRecord parent, final String annotation) {
        if (app.notResponding || app.crashing) {
        // PowerManager.reboot() can block for a long time, so ignore ANRs while shutting down.
        if (mShuttingDown || app.notResponding || app.crashing) {
            return;
        }