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

Commit ef17e84e authored by Johannes Gallmann's avatar Johannes Gallmann
Browse files

Prevent double haptics for back events

Injected back key events should not cause any haptics on the PhoneWindowManager side. The haptics are already executed by the taskbar and gesture nav implementations.

Bug: 327556397
Bug: 374069218
Test: Manual, i.e. verify that no double haptics are played in 3-button-nav and gesture-nav
Flag: EXEMPT bugfix
Change-Id: Idc924332094afe32353fd117d2ac35e0446e95d4
parent 3ebccb43
Loading
Loading
Loading
Loading
+11 −0
Original line number Diff line number Diff line
@@ -68,6 +68,7 @@ import android.view.Surface;
import android.view.ViewConfiguration;
import android.view.WindowInsets;
import android.view.WindowManager;
import android.view.WindowManagerGlobal;
import android.window.BackEvent;

import androidx.annotation.DimenRes;
@@ -585,6 +586,7 @@ public class EdgeBackGestureHandler implements PluginListener<NavigationEdgeBack
        mNonLinearFactor = getDimenFloat(res,
                com.android.internal.R.dimen.back_progress_non_linear_factor);
        updateBackAnimationThresholds();
        mBackgroundExecutor.execute(this::disableNavBarVirtualKeyHapticFeedback);
    }

    private float getDimenFloat(Resources res, @DimenRes int resId) {
@@ -1287,6 +1289,15 @@ public class EdgeBackGestureHandler implements PluginListener<NavigationEdgeBack
        }
    }

    private void disableNavBarVirtualKeyHapticFeedback() {
        try {
            WindowManagerGlobal.getWindowManagerService()
                    .setNavBarVirtualKeyHapticFeedbackEnabled(false);
        } catch (RemoteException e) {
            Log.w(TAG, "Failed to disable navigation bar button haptics: ", e);
        }
    }

    public void dump(PrintWriter pw) {
        pw.println("EdgeBackGestureHandler:");
        pw.println("  mIsEnabled=" + mIsEnabled);