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

Commit cb22d9b4 authored by Yeabkal Wubshit's avatar Yeabkal Wubshit
Browse files

[ShutdownThread] Move to VibrationEffect and VibrationAttributes

The API that shutdown thread uses for vibration has been deprecated.
This change moves the vibration API usage to a currently-supported API
that uses VibrationEffect and VibrationAttributes.

Bug: 269213721
Test: manual
Change-Id: Iebefddb8e1b77128feae29f4f3cad60649522f3f
parent 103b1e46
Loading
Loading
Loading
Loading
+6 −7
Original line number Diff line number Diff line
@@ -28,7 +28,6 @@ import android.content.DialogInterface;
import android.content.Intent;
import android.content.IntentFilter;
import android.content.pm.PackageManagerInternal;
import android.media.AudioAttributes;
import android.os.FileUtils;
import android.os.Handler;
import android.os.PowerManager;
@@ -41,6 +40,8 @@ import android.os.SystemVibrator;
import android.os.Trace;
import android.os.UserHandle;
import android.os.UserManager;
import android.os.VibrationAttributes;
import android.os.VibrationEffect;
import android.os.Vibrator;
import android.telephony.TelephonyManager;
import android.util.ArrayMap;
@@ -99,11 +100,6 @@ public final class ShutdownThread extends Thread {
    // static instance of this thread
    private static final ShutdownThread sInstance = new ShutdownThread();

    private static final AudioAttributes VIBRATION_ATTRIBUTES = new AudioAttributes.Builder()
            .setContentType(AudioAttributes.CONTENT_TYPE_SONIFICATION)
            .setUsage(AudioAttributes.USAGE_ASSISTANCE_SONIFICATION)
            .build();

    // Metrics that will be reported to tron after reboot
    private static final ArrayMap<String, Long> TRON_METRICS = new ArrayMap<>();

@@ -700,7 +696,10 @@ public final class ShutdownThread extends Thread {
            // vibrate before shutting down
            Vibrator vibrator = new SystemVibrator(context);
            try {
                vibrator.vibrate(SHUTDOWN_VIBRATE_MS, VIBRATION_ATTRIBUTES);
                vibrator.vibrate(
                        VibrationEffect.createOneShot(
                                SHUTDOWN_VIBRATE_MS, VibrationEffect.DEFAULT_AMPLITUDE),
                        VibrationAttributes.createForUsage(VibrationAttributes.USAGE_TOUCH));
            } catch (Exception e) {
                // Failure to vibrate shouldn't interrupt shutdown.  Just log it.
                Log.w(TAG, "Failed to vibrate during shutdown.", e);