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

Commit 43e960b4 authored by Ming-Shin Lu's avatar Ming-Shin Lu
Browse files

Replace boolean params with int flags in performHapticFeedback

Flag: EXEMPT refactor
Bug: 332661770
Test: atest HapticFeedbackVibrationProviderTest
Test: atest ViewRootImplTest
Test: atest VibratorManagerServiceTest
Change-Id: I60125ee73ea21a5ca33a4181b94394f41a48bce9
parent 2bebdf21
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -41,5 +41,5 @@ interface IVibratorManagerService {
    // There is no order guarantee with respect to the two-way APIs above like
    // vibrate/isVibrating/cancel.
    oneway void performHapticFeedback(int uid, int deviceId, String opPkg, int constant,
            boolean always, String reason, boolean fromIme);
            String reason, int flags, int privFlags);
}
+2 −3
Original line number Diff line number Diff line
@@ -206,13 +206,12 @@ public class SystemVibrator extends Vibrator {
    }

    @Override
    public void performHapticFeedback(
            int constant, boolean always, String reason, boolean fromIme) {
    public void performHapticFeedback(int constant, String reason, int flags, int privFlags) {
        if (mVibratorManager == null) {
            Log.w(TAG, "Failed to perform haptic feedback; no vibrator manager.");
            return;
        }
        mVibratorManager.performHapticFeedback(constant, always, reason, fromIme);
        mVibratorManager.performHapticFeedback(constant, reason, flags, privFlags);
    }

    @Override
+5 −7
Original line number Diff line number Diff line
@@ -147,15 +147,14 @@ public class SystemVibratorManager extends VibratorManager {
    }

    @Override
    public void performHapticFeedback(int constant, boolean always, String reason,
            boolean fromIme) {
    public void performHapticFeedback(int constant, String reason, int flags, int privFlags) {
        if (mService == null) {
            Log.w(TAG, "Failed to perform haptic feedback; no vibrator manager service.");
            return;
        }
        try {
            mService.performHapticFeedback(
                    mUid, mContext.getDeviceId(), mPackageName, constant, always, reason, fromIme);
            mService.performHapticFeedback(mUid, mContext.getDeviceId(), mPackageName, constant,
                    reason, flags, privFlags);
        } catch (RemoteException e) {
            Log.w(TAG, "Failed to perform haptic feedback.", e);
        }
@@ -245,9 +244,8 @@ public class SystemVibratorManager extends VibratorManager {
        }

        @Override
        public void performHapticFeedback(int effectId, boolean always, String reason,
                boolean fromIme) {
            SystemVibratorManager.this.performHapticFeedback(effectId, always, reason, fromIme);
        public void performHapticFeedback(int effectId, String reason, int flags, int privFlags) {
            SystemVibratorManager.this.performHapticFeedback(effectId, reason, flags, privFlags);
        }

        @Override
+6 −7
Original line number Diff line number Diff line
@@ -33,6 +33,7 @@ import android.media.AudioAttributes;
import android.os.vibrator.VibrationConfig;
import android.os.vibrator.VibratorFrequencyProfile;
import android.util.Log;
import android.view.HapticFeedbackConstants;

import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
@@ -519,17 +520,15 @@ public abstract class Vibrator {
     *
     * @param constant the ID for the haptic feedback. This should be one of the constants defined
     *          in {@link HapticFeedbackConstants}.
     * @param always {@code true} if the haptic feedback should be played regardless of the user
     *          vibration intensity settings applicable to the corresponding vibration.
     *          {@code false} if the vibration for the haptic feedback should respect the applicable
     *          vibration intensity settings.
     * @param reason the reason for this haptic feedback.
     * @param fromIme the haptic feedback is performed from an IME.
     * @param flags Additional flags as per {@link HapticFeedbackConstants}.
     * @param privFlags Additional private flags as per {@link HapticFeedbackConstants}.
     *
     * @hide
     */
    public void performHapticFeedback(int constant, boolean always, String reason,
            boolean fromIme) {
    public void performHapticFeedback(int constant, String reason,
            @HapticFeedbackConstants.Flags int flags,
            @HapticFeedbackConstants.PrivateFlags int privFlags) {
        Log.w(TAG, "performHapticFeedback is not supported");
    }

+6 −6
Original line number Diff line number Diff line
@@ -23,6 +23,7 @@ import android.annotation.SystemService;
import android.app.ActivityThread;
import android.content.Context;
import android.util.Log;
import android.view.HapticFeedbackConstants;

/**
 * Provides access to all vibrators from the device, as well as the ability to run them
@@ -142,15 +143,14 @@ public abstract class VibratorManager {
     *
     * @param constant the ID of the requested haptic feedback. Should be one of the constants
     *          defined in {@link HapticFeedbackConstants}.
     * @param always {@code true} if the haptic feedback should be played regardless of the user
     *          vibration intensity settings applicable to the corresponding vibration.
     *          {@code false} otherwise.
     * @param reason the reason for this haptic feedback.
     * @param fromIme the haptic feedback is performed from an IME.
     * @param flags Additional flags as per {@link HapticFeedbackConstants}.
     * @param privFlags Additional private flags as per {@link HapticFeedbackConstants}.
     * @hide
     */
    public void performHapticFeedback(int constant, boolean always, String reason,
            boolean fromIme) {
    public void performHapticFeedback(int constant, String reason,
            @HapticFeedbackConstants.Flags int flags,
            @HapticFeedbackConstants.PrivateFlags int privFlags) {
        Log.w(TAG, "performHapticFeedback is not supported");
    }

Loading