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

Commit a01a1f69 authored by Lais Andrade's avatar Lais Andrade
Browse files

Deprecate boolean settings for haptic feedback and vibrate when ringing

Deprecate HAPTIC_FEEDBACK_ENABLED in favor or HAPTIC_FEEDBACK_INTENSITY,
and VIBRATE_WHEN_RINGING in favor or RING_VIBRATION_INTENSITY.

Introduce hidden flag
VibrationAttributes.FLAG_BYPASS_USER_VIBRATION_INTENSITY_OFF
to represent HapticFeedbackConstants.FLAG_IGNORE_GLOBAL_SETTING in the
vibrator service. This is applied by:

- PhoneWindowManager, that converts HapticFeedbackConstants into
(VibrationEffect, VibrationAttributes).

- CellBroadcastAlertAudio, that triggers alerts using AudioAttributes
with flags FLAG_BYPASS_INTERRUPTION_POLICY (that translates to same flag
in VibratorManager, to bypass DnD) and FLAG_BYPASS_MUTE (that translates
to this new flag, to bypass the new alarm intensity settings).

The new flag is erased from request that are not from privileged apps,
similar to the other bypass flag. The public
HapticFeedbackConstants.FLAG_IGNORE_GLOBAL_SETTING has also been
deprecated in T with a documentation explaining the removal of platform
support.

Remove SysUI dependencies on the deprecated settings, it should use the
USAGE_TOUCH attribute and rely on the vibrator service to apply the user
settings.

Keep other SysUI dependencies that needs to run in older Android
versions (like Launcher3).

Bug: 185351540
Test: VibrationSettingsTest + manual
Change-Id: I0372e4db19e09523795d7e79b9f7a15ae48a8cd9
parent f5a7230c
Loading
Loading
Loading
Loading
+3 −3
Original line number Diff line number Diff line
@@ -36118,7 +36118,7 @@ package android.provider {
    field public static final String DTMF_TONE_WHEN_DIALING = "dtmf_tone";
    field public static final String END_BUTTON_BEHAVIOR = "end_button_behavior";
    field public static final String FONT_SCALE = "font_scale";
    field public static final String HAPTIC_FEEDBACK_ENABLED = "haptic_feedback_enabled";
    field @Deprecated public static final String HAPTIC_FEEDBACK_ENABLED = "haptic_feedback_enabled";
    field @Deprecated public static final String HTTP_PROXY = "http_proxy";
    field @Deprecated public static final String INSTALL_NON_MARKET_APPS = "install_non_market_apps";
    field @Deprecated public static final String LOCATION_PROVIDERS_ALLOWED = "location_providers_allowed";
@@ -36162,7 +36162,7 @@ package android.provider {
    field public static final String USER_ROTATION = "user_rotation";
    field @Deprecated public static final String USE_GOOGLE_MAIL = "use_google_mail";
    field public static final String VIBRATE_ON = "vibrate_on";
    field public static final String VIBRATE_WHEN_RINGING = "vibrate_when_ringing";
    field @Deprecated public static final String VIBRATE_WHEN_RINGING = "vibrate_when_ringing";
    field @Deprecated public static final String WAIT_FOR_DEBUGGER = "wait_for_debugger";
    field @Deprecated public static final String WALLPAPER_ACTIVITY = "wallpaper_activity";
    field @Deprecated public static final String WIFI_MAX_DHCP_RETRY_COUNT = "wifi_max_dhcp_retry_count";
@@ -48227,7 +48227,7 @@ package android.view {
    field public static final int CLOCK_TICK = 4; // 0x4
    field public static final int CONFIRM = 16; // 0x10
    field public static final int CONTEXT_CLICK = 6; // 0x6
    field public static final int FLAG_IGNORE_GLOBAL_SETTING = 2; // 0x2
    field @Deprecated public static final int FLAG_IGNORE_GLOBAL_SETTING = 2; // 0x2
    field public static final int FLAG_IGNORE_VIEW_SETTING = 1; // 0x1
    field public static final int GESTURE_END = 13; // 0xd
    field public static final int GESTURE_START = 12; // 0xc
+19 −1
Original line number Diff line number Diff line
@@ -136,6 +136,7 @@ public final class VibrationAttributes implements Parcelable {
     */
    @IntDef(prefix = { "FLAG_" }, flag = true, value = {
            FLAG_BYPASS_INTERRUPTION_POLICY,
            FLAG_BYPASS_USER_VIBRATION_INTENSITY_OFF
    })
    @Retention(RetentionPolicy.SOURCE)
    public @interface Flag{}
@@ -145,11 +146,23 @@ public final class VibrationAttributes implements Parcelable {
     */
    public static final int FLAG_BYPASS_INTERRUPTION_POLICY = 0x1;

    /**
     * Flag requesting vibration effect to be played even when user settings are disabling it.
     *
     * <p>Flag introduced to represent
     * {@link android.view.HapticFeedbackConstants#FLAG_IGNORE_GLOBAL_SETTING} and
     * {@link AudioAttributes#FLAG_BYPASS_MUTE}.
     *
     * @hide
     */
    public static final int FLAG_BYPASS_USER_VIBRATION_INTENSITY_OFF = 0x2;

    /**
     * All flags supported by vibrator service, update it when adding new flag.
     * @hide
     */
    public static final int FLAG_ALL_SUPPORTED = FLAG_BYPASS_INTERRUPTION_POLICY;
    public static final int FLAG_ALL_SUPPORTED =
            FLAG_BYPASS_INTERRUPTION_POLICY | FLAG_BYPASS_USER_VIBRATION_INTENSITY_OFF;

    /** Creates a new {@link VibrationAttributes} instance with given usage. */
    public static @NonNull VibrationAttributes createForUsage(int usage) {
@@ -397,6 +410,11 @@ public final class VibrationAttributes implements Parcelable {
            if ((audio.getAllFlags() & AudioAttributes.FLAG_BYPASS_INTERRUPTION_POLICY) != 0) {
                mFlags |= FLAG_BYPASS_INTERRUPTION_POLICY;
            }
            if ((audio.getAllFlags() & AudioAttributes.FLAG_BYPASS_MUTE) != 0) {
                // Muted audio stream translates to vibration usage having the value
                // Vibrator.VIBRATION_INTENSITY_OFF set in the user setting.
                mFlags |= FLAG_BYPASS_USER_VIBRATION_INTENSITY_OFF;
            }
        }

        /**
+10 −0
Original line number Diff line number Diff line
@@ -5120,7 +5120,12 @@ public final class Settings {
         * It was about AudioManager's setting and thus affected all the applications which
         * relied on the setting, while this is purely about the vibration setting for incoming
         * calls.
         *
         * @deprecated Replaced by using {@link android.os.VibrationAttributes#USAGE_RINGTONE} on
         * vibrations for incoming calls. User settings are applied automatically by the service and
         * should not be applied by individual apps.
         */
        @Deprecated
        @Readable
        public static final String VIBRATE_WHEN_RINGING = "vibrate_when_ringing";
@@ -5181,7 +5186,12 @@ public final class Settings {
        /**
         * Whether haptic feedback (Vibrate on tap) is enabled. The value is
         * boolean (1 or 0).
         *
         * @deprecated Replaced by using {@link android.os.VibrationAttributes#USAGE_TOUCH} on
         * vibrations. User settings are applied automatically by the service and should not be
         * applied by individual apps.
         */
        @Deprecated
        @Readable
        public static final String HAPTIC_FEEDBACK_ENABLED = "haptic_feedback_enabled";
+4 −0
Original line number Diff line number Diff line
@@ -177,6 +177,10 @@ public class HapticFeedbackConstants {
     * Flag for {@link View#performHapticFeedback(int, int)
     * View.performHapticFeedback(int, int)}: Ignore the global setting
     * for whether to perform haptic feedback, do it always.
     *
     * @deprecated Starting from {@link android.os.Build.VERSION_CODES#TIRAMISU} only privileged
     * apps can ignore user settings for touch feedback.
     */
    @Deprecated
    public static final int FLAG_IGNORE_GLOBAL_SETTING = 0x0002;
}
+0 −9
Original line number Diff line number Diff line
@@ -1027,15 +1027,6 @@ public class LockPatternUtils {
        }
    }

    /**
     * @return Whether tactile feedback for the pattern is enabled.
     */
    @UnsupportedAppUsage
    public boolean isTactileFeedbackEnabled() {
        return Settings.System.getIntForUser(mContentResolver,
                Settings.System.HAPTIC_FEEDBACK_ENABLED, 1, UserHandle.USER_CURRENT) != 0;
    }

    /**
     * Set and store the lockout deadline, meaning the user can't attempt their unlock
     * pattern until the deadline has passed.
Loading