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

Commit 2dda2584 authored by Lais Andrade's avatar Lais Andrade Committed by Android (Google) Code Review
Browse files

Merge "Introduce separate setting key for hardware haptic feedback"

parents 811ae06b 657b009b
Loading
Loading
Loading
Loading
+19 −0
Original line number Diff line number Diff line
@@ -4536,6 +4536,25 @@ public final class Settings {
        public static final String HAPTIC_FEEDBACK_INTENSITY =
                "haptic_feedback_intensity";
        /**
         * The intensity of haptic feedback vibrations for interaction with hardware components from
         * the device, like buttons and sensors, if configurable.
         *
         * Not all devices are capable of changing their feedback intensity; on these devices
         * there will likely be no difference between the various vibration intensities except for
         * intensity 0 (off) and the rest.
         *
         * <b>Values:</b><br/>
         * 0 - Vibration is disabled<br/>
         * 1 - Weak vibrations<br/>
         * 2 - Medium vibrations<br/>
         * 3 - Strong vibrations
         * @hide
         */
        @Readable
        public static final String HARDWARE_HAPTIC_FEEDBACK_INTENSITY =
                "hardware_haptic_feedback_intensity";
        /**
         * Ringer volume. This is used internally, changing this value will not
         * change the volume. See AudioManager.
+9 −0
Original line number Diff line number Diff line
@@ -153,10 +153,19 @@ public class HapticFeedbackConstants {

    /**
     * Invocation of the voice assistant via hardware button.
     * This is a private constant.  Feel free to renumber as desired.
     * @hide
     */
    public static final int ASSISTANT_BUTTON = 10002;

    /**
     * The user has performed a long press on the power button hardware that is resulting
     * in an action being performed.
     * This is a private constant.  Feel free to renumber as desired.
     * @hide
     */
    public static final int LONG_PRESS_POWER_BUTTON = 10003;

    /**
     * Flag for {@link View#performHapticFeedback(int, int)
     * View.performHapticFeedback(int, int)}: Ignore the setting in the
+1 −0
Original line number Diff line number Diff line
@@ -80,6 +80,7 @@ public class SystemSettings {
        Settings.System.NOTIFICATION_VIBRATION_INTENSITY,
        Settings.System.RING_VIBRATION_INTENSITY,
        Settings.System.HAPTIC_FEEDBACK_INTENSITY,
        Settings.System.HARDWARE_HAPTIC_FEEDBACK_INTENSITY,
        Settings.System.DISPLAY_COLOR_MODE_VENDOR_HINT, // must precede DISPLAY_COLOR_MODE
        Settings.System.DISPLAY_COLOR_MODE,
        Settings.System.ALARM_ALERT,
+1 −0
Original line number Diff line number Diff line
@@ -120,6 +120,7 @@ public class SystemSettingsValidators {
        VALIDATORS.put(System.NOTIFICATION_VIBRATION_INTENSITY, VIBRATION_INTENSITY_VALIDATOR);
        VALIDATORS.put(System.RING_VIBRATION_INTENSITY, VIBRATION_INTENSITY_VALIDATOR);
        VALIDATORS.put(System.HAPTIC_FEEDBACK_INTENSITY, VIBRATION_INTENSITY_VALIDATOR);
        VALIDATORS.put(System.HARDWARE_HAPTIC_FEEDBACK_INTENSITY, VIBRATION_INTENSITY_VALIDATOR);
        VALIDATORS.put(System.RINGTONE, URI_VALIDATOR);
        VALIDATORS.put(System.NOTIFICATION_SOUND, URI_VALIDATOR);
        VALIDATORS.put(System.ALARM_ALERT, URI_VALIDATOR);
+7 −7
Original line number Diff line number Diff line
@@ -30,11 +30,11 @@ import android.content.ComponentName;
import android.content.Context;
import android.content.Intent;
import android.content.res.Resources;
import android.media.AudioAttributes;
import android.os.Bundle;
import android.os.PowerManager;
import android.os.SystemClock;
import android.os.UserHandle;
import android.os.VibrationAttributes;
import android.os.VibrationEffect;
import android.os.Vibrator;
import android.util.Log;
@@ -106,10 +106,8 @@ public class StatusBarCommandQueueCallbacks implements CommandQueue.Callbacks {
    private final VibrationEffect mCameraLaunchGestureVibrationEffect;


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

    @Inject
    StatusBarCommandQueueCallbacks(
@@ -611,9 +609,9 @@ public class StatusBarCommandQueueCallbacks implements CommandQueue.Callbacks {
    }

    private void vibrateForCameraGesture() {
        // Make sure to pass -1 for repeat so VibratorService doesn't stop us when going to sleep.
        mVibratorOptional.ifPresent(
                v -> v.vibrate(mCameraLaunchGestureVibrationEffect, VIBRATION_ATTRIBUTES));
                v -> v.vibrate(mCameraLaunchGestureVibrationEffect,
                        HARDWARE_FEEDBACK_VIBRATION_ATTRIBUTES));
    }

    private static VibrationEffect getCameraGestureVibrationEffect(
@@ -627,6 +625,8 @@ public class StatusBarCommandQueueCallbacks implements CommandQueue.Callbacks {
                    .compose();
        }
        if (vibratorOptional.isPresent() && vibratorOptional.get().hasAmplitudeControl()) {
            // Make sure to pass -1 for repeat so VibratorManagerService doesn't stop us when going
            // to sleep.
            return VibrationEffect.createWaveform(
                    StatusBar.CAMERA_LAUNCH_GESTURE_VIBRATION_TIMINGS,
                    StatusBar.CAMERA_LAUNCH_GESTURE_VIBRATION_AMPLITUDES,
Loading