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

Commit aae9202a authored by Treehugger Robot's avatar Treehugger Robot Committed by Android (Google) Code Review
Browse files

Merge changes I079b7542,I72775ec4,Ibe5612f4,I46ed5e3e into main

* changes:
  Remove SAFE_MODE_ENABLED's custom waveform vibration config
  Introduce haptic vibration customization for USAGE_GESTURE_INPUT
  Remove android.os.vibrator.haptic_feedback_vibration_oem_customization_enabled
  Refactor: rename InputDevice specific vibration provider methods
parents fb293b51 29d0c490
Loading
Loading
Loading
Loading
+0 −10
Original line number Diff line number Diff line
package: "android.os.vibrator"
container: "system"

flag {
    namespace: "haptics"
    name: "haptic_feedback_vibration_oem_customization_enabled"
    description: "Enables OEMs/devices to customize vibrations for haptic feedback"
    # Make read only. This is because the flag is used only once, and this could happen before
    # the read-write flag values propagate to the device.
    is_fixed_read_only: true
    bug: "291128479"
}

flag {
    namespace: "haptics"
    name: "adaptive_haptics_enabled"
+0 −10
Original line number Diff line number Diff line
@@ -1384,16 +1384,6 @@
        <item>10</item>
    </integer-array>

    <!-- Vibrator pattern for feedback about booting with safe mode enabled -->
    <integer-array name="config_safeModeEnabledVibePattern">
        <item>0</item>
        <item>1</item>
        <item>20</item>
        <item>21</item>
        <item>500</item>
        <item>600</item>
    </integer-array>

    <!-- The URI to associate with each ringtone effect constant, intended to be used with the
         android.os.VibrationEffect#get(Uri, Context) API.
         The position of the string in the string-array determines which ringtone effect is chosen.
+1 −1
Original line number Diff line number Diff line
@@ -1802,7 +1802,6 @@
  <java-symbol type="array" name="config_longPressVibePattern" />
  <java-symbol type="array" name="config_virtualKeyVibePattern" />
  <java-symbol type="array" name="config_doubleClickVibePattern" />
  <java-symbol type="array" name="config_safeModeEnabledVibePattern" />
  <java-symbol type="attr" name="actionModePopupWindowStyle" />
  <java-symbol type="attr" name="dialogCustomTitleDecorLayout" />
  <java-symbol type="attr" name="dialogTitleDecorLayout" />
@@ -5918,6 +5917,7 @@
  <java-symbol type="xml" name="haptic_feedback_customization" />
  <java-symbol type="xml" name="haptic_feedback_customization_source_rotary_encoder" />
  <java-symbol type="xml" name="haptic_feedback_customization_source_touchscreen" />
  <java-symbol type="xml" name="haptic_feedback_customization_usage_gesture_input" />

  <!-- For ActivityManager PSS profiling configurability -->
  <java-symbol type="bool" name="config_am_disablePssProfiling" />
+18 −0
Original line number Diff line number Diff line
<?xml version="1.0" encoding="utf-8"?>
<!--
  ~ Copyright (C) 2025 The Android Open Source Project
  ~
  ~ Licensed under the Apache License, Version 2.0 (the "License");
  ~ you may not use this file except in compliance with the License.
  ~ You may obtain a copy of the License at
  ~
  ~      http://www.apache.org/licenses/LICENSE-2.0
  ~
  ~ Unless required by applicable law or agreed to in writing, software
  ~ distributed under the License is distributed on an "AS IS" BASIS,
  ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  ~ See the License for the specific language governing permissions and
  ~ limitations under the License.
  -->

<haptic-feedback-constants/>
+28 −12
Original line number Diff line number Diff line
@@ -16,10 +16,13 @@

package com.android.server.vibrator;

import static android.os.VibrationAttributes.USAGE_GESTURE_INPUT;

import android.annotation.NonNull;
import android.annotation.Nullable;
import android.content.res.Resources;
import android.content.res.XmlResourceParser;
import android.os.VibrationAttributes;
import android.os.VibrationEffect;
import android.os.VibratorInfo;
import android.os.vibrator.Flags;
@@ -118,15 +121,10 @@ final class HapticFeedbackCustomization {
    @NonNull
    private final SparseArray<VibrationEffect> mHapticCustomizationsForSourceTouchScreen;

    HapticFeedbackCustomization(Resources res, VibratorInfo vibratorInfo) {
        if (!Flags.hapticFeedbackVibrationOemCustomizationEnabled()) {
            Slog.d(TAG, "Haptic feedback customization feature is not enabled.");
            mHapticCustomizations = new SparseArray<>();
            mHapticCustomizationsForSourceRotary = new SparseArray<>();
            mHapticCustomizationsForSourceTouchScreen = new SparseArray<>();
            return;
        }
    @NonNull
    private final SparseArray<VibrationEffect> mHapticCustomizationsForUsageGestureInput;

    HapticFeedbackCustomization(Resources res, VibratorInfo vibratorInfo) {
        // Load base customizations.
        SparseArray<VibrationEffect> hapticCustomizations;
        hapticCustomizations = loadCustomizedFeedbackVibrationFromFile(res, vibratorInfo);
@@ -150,24 +148,42 @@ final class HapticFeedbackCustomization {
            mHapticCustomizationsForSourceRotary = new SparseArray<>();
            mHapticCustomizationsForSourceTouchScreen = new SparseArray<>();
        }

        // Load customizations specified for usages.
        if (android.os.vibrator.Flags.hapticFeedbackWithCustomUsage()) {
            mHapticCustomizationsForUsageGestureInput =
                    loadCustomizedFeedbackVibrationFromRes(res, vibratorInfo,
                            R.xml.haptic_feedback_customization_usage_gesture_input);
        } else {
            mHapticCustomizationsForUsageGestureInput = new SparseArray<>();
        }
    }

    @VisibleForTesting
    HapticFeedbackCustomization(@NonNull SparseArray<VibrationEffect> hapticCustomizations,
            @NonNull SparseArray<VibrationEffect> hapticCustomizationsForSourceRotary,
            @NonNull SparseArray<VibrationEffect> hapticCustomizationsForSourceTouchScreen) {
            @NonNull SparseArray<VibrationEffect> hapticCustomizationsForSourceTouchScreen,
            @NonNull SparseArray<VibrationEffect> hapticCustomizationsForUsageGestureInput) {
        mHapticCustomizations = hapticCustomizations;
        mHapticCustomizationsForSourceRotary = hapticCustomizationsForSourceRotary;
        mHapticCustomizationsForSourceTouchScreen = hapticCustomizationsForSourceTouchScreen;
        mHapticCustomizationsForUsageGestureInput = hapticCustomizationsForUsageGestureInput;
    }

    @Nullable
    VibrationEffect getEffect(int effectId) {
        return mHapticCustomizations.get(effectId);
    VibrationEffect getEffect(int effectId, @VibrationAttributes.Usage int usage) {
        VibrationEffect resultVibration = null;
        if (usage == USAGE_GESTURE_INPUT) {
            resultVibration = mHapticCustomizationsForUsageGestureInput.get(effectId);
        }
        if (resultVibration == null) {
            resultVibration = mHapticCustomizations.get(effectId);
        }
        return resultVibration;
    }

    @Nullable
    VibrationEffect getEffect(int effectId, int inputSource) {
    VibrationEffect getEffectForInputDevice(int effectId, int inputSource) {
        VibrationEffect resultVibration = null;
        if ((InputDevice.SOURCE_ROTARY_ENCODER & inputSource) != 0) {
            resultVibration = mHapticCustomizationsForSourceRotary.get(effectId);
Loading