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

Commit e21fcb2f authored by Yeabkal Wubshit's avatar Yeabkal Wubshit Committed by Android (Google) Code Review
Browse files

Merge "Create View.performHapticFeedback API that takes vibration usage" into main

parents 93a91e36 3f912b02
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -54493,6 +54493,7 @@ package android.view {
    method public boolean performContextClick();
    method public boolean performHapticFeedback(int);
    method public boolean performHapticFeedback(int, int);
    method @FlaggedApi("android.os.vibrator.haptic_feedback_with_custom_usage") public boolean performHapticFeedback(@NonNull android.os.vibrator.HapticFeedbackRequest);
    method public boolean performLongClick();
    method public boolean performLongClick(float, float);
    method @Nullable public android.view.ContentInfo performReceiveContent(@NonNull android.view.ContentInfo);
+1 −1
Original line number Diff line number Diff line
@@ -45,7 +45,7 @@ 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,
            String reason, int flags, int privFlags);
            int usage, String reason, int flags, int privFlags);

    // Similar to performHapticFeedback but the effect is customized to the input device. The
    // customization for each constant is defined on a device basis, and the behavior will be the
+3 −2
Original line number Diff line number Diff line
@@ -226,12 +226,13 @@ public class SystemVibrator extends Vibrator {
    }

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

    @Override
+7 −4
Original line number Diff line number Diff line
@@ -163,7 +163,8 @@ public class SystemVibratorManager extends VibratorManager {
    }

    @Override
    public void performHapticFeedback(int constant, String reason, int flags, int privFlags) {
    public void performHapticFeedback(int constant, @VibrationAttributes.Usage int usage,
            String reason, int flags, int privFlags) {
        if (mService == null) {
            Log.w(TAG, "Failed to perform haptic feedback; no vibrator manager service.");
            return;
@@ -171,7 +172,7 @@ public class SystemVibratorManager extends VibratorManager {
        Trace.traceBegin(TRACE_TAG_VIBRATOR, "performHapticFeedback");
        try {
            mService.performHapticFeedback(mUid, mContext.getDeviceId(), mPackageName, constant,
                    reason, flags, privFlags);
                    usage, reason, flags, privFlags);
        } catch (RemoteException e) {
            Log.w(TAG, "Failed to perform haptic feedback.", e);
        } finally {
@@ -364,8 +365,10 @@ public class SystemVibratorManager extends VibratorManager {
        }

        @Override
        public void performHapticFeedback(int effectId, String reason, int flags, int privFlags) {
            SystemVibratorManager.this.performHapticFeedback(effectId, reason, flags, privFlags);
        public void performHapticFeedback(int effectId, @VibrationAttributes.Usage int usage,
                String reason, int flags, int privFlags) {
            SystemVibratorManager.this.performHapticFeedback(
                    effectId, usage, reason, flags, privFlags);
        }

        @Override
+5 −2
Original line number Diff line number Diff line
@@ -643,14 +643,17 @@ public abstract class Vibrator {
     *
     * @param constant the ID for the haptic feedback. This should be one of the constants defined
     *          in {@link HapticFeedbackConstants}.
     * @param usage one of the {@link VibrationAttributes} usages with the class
     *      {@link USAGE_CLASS_FEEDBACK}. Use {@link USAGE_UNKNOWN} if you are not sure about which
     *      usage to use, and the system will assign a default usage.
     * @param reason the reason for this haptic feedback.
     * @param flags Additional flags as per {@link HapticFeedbackConstants}.
     * @param privFlags Additional private flags as per {@link HapticFeedbackConstants}.
     *
     * @hide
     */
    public void performHapticFeedback(int constant, String reason,
            @HapticFeedbackConstants.Flags int flags,
    public void performHapticFeedback(int constant, @VibrationAttributes.Usage int usage,
            String reason, @HapticFeedbackConstants.Flags int flags,
            @HapticFeedbackConstants.PrivateFlags int privFlags) {
        Log.w(TAG, "performHapticFeedback is not supported");
    }
Loading