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

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

Vibrate before shutting down.



BUG: 2439291

Change-Id: I0f5abba34a14f1dd1cbe2077122d6f3e940b4d90
Signed-off-by: default avatarMike Lockwood <lockwood@android.com>
parent af8c900a
Loading
Loading
Loading
Loading
+13 −0
Original line number Diff line number Diff line
@@ -33,6 +33,7 @@ import android.os.PowerManager;
import android.os.RemoteException;
import android.os.ServiceManager;
import android.os.SystemClock;
import android.os.Vibrator;
import android.os.storage.IMountService;
import android.os.storage.IMountShutdownObserver;

@@ -49,6 +50,9 @@ public final class ShutdownThread extends Thread {
    private static final int MAX_BROADCAST_TIME = 10*1000;
    private static final int MAX_SHUTDOWN_WAIT_TIME = 20*1000;

    // length of vibration before shutting down
    private static final int SHUTDOWN_VIBRATE_MS = 500;
    
    // state tracking
    private static Object sIsStartedGuard = new Object();
    private static boolean sIsStarted = false;
@@ -324,6 +328,15 @@ public final class ShutdownThread extends Thread {
            } catch (Exception e) {
                Log.e(TAG, "Reboot failed, will attempt shutdown instead", e);
            }
        } else if (SHUTDOWN_VIBRATE_MS > 0) {
            // vibrate before shutting down
            Vibrator vibrator = new Vibrator();
            vibrator.vibrate(SHUTDOWN_VIBRATE_MS);
            // vibrator is asynchronous so we need to wait to avoid shutting down too soon.
            try {
                Thread.sleep(SHUTDOWN_VIBRATE_MS);
            } catch (InterruptedException e) {
            }
        }

        // Shutdown power