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

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

Merge "Prevent nav bar vibrations when overview proxy is connected (1/2)"

parents b87a7a74 64543e66
Loading
Loading
Loading
Loading
+5 −0
Original line number Diff line number Diff line
@@ -283,6 +283,11 @@ interface IWindowManager
     */
    oneway void setPipVisibility(boolean visible);

   /**
     * Called by System UI to enable or disable haptic feedback on the navigation bar buttons.
     */
    void setNavBarVirtualKeyHapticFeedbackEnabled(boolean enabled);

    /**
     * Device has a software navigation bar (separate from the status bar).
     */
+12 −0
Original line number Diff line number Diff line
@@ -109,4 +109,16 @@ public class WindowManagerWrapper {
            Log.w(TAG, "Failed to end prolonged animations: ", e);
        }
    }

    /**
     * Enable or disable haptic feedback on the navigation bar buttons.
     */
    public void setNavBarVirtualKeyHapticFeedbackEnabled(boolean enabled) {
        try {
            WindowManagerGlobal.getWindowManagerService()
                    .setNavBarVirtualKeyHapticFeedbackEnabled(enabled);
        } catch (RemoteException e) {
            Log.w(TAG, "Failed to enable or disable navigation bar button haptics: ", e);
        }
    }
}
+3 −1
Original line number Diff line number Diff line
@@ -46,7 +46,6 @@ import android.database.ContentObserver;
import android.graphics.PixelFormat;
import android.graphics.Rect;
import android.graphics.drawable.AnimatedVectorDrawable;
import android.graphics.drawable.Drawable;
import android.inputmethodservice.InputMethodService;
import android.os.Binder;
import android.os.Bundle;
@@ -88,6 +87,7 @@ import com.android.systemui.fragments.FragmentHostManager.FragmentListener;
import com.android.systemui.recents.Recents;
import com.android.systemui.recents.misc.SysUiTaskStackChangeListener;
import com.android.systemui.shared.system.ActivityManagerWrapper;
import com.android.systemui.shared.system.WindowManagerWrapper;
import com.android.systemui.stackdivider.Divider;
import com.android.systemui.statusbar.CommandQueue;
import com.android.systemui.statusbar.CommandQueue.Callbacks;
@@ -165,6 +165,8 @@ public class NavigationBarFragment extends Fragment implements Callbacks {
        public void onConnectionChanged(boolean isConnected) {
            mNavigationBarView.onOverviewProxyConnectionChanged(isConnected);
            updateScreenPinningGestures();
            WindowManagerWrapper.getInstance()
                    .setNavBarVirtualKeyHapticFeedbackEnabled(!isConnected);
        }

        @Override
+1 −6
Original line number Diff line number Diff line
@@ -232,12 +232,7 @@ public class KeyButtonView extends ImageView implements ButtonInterface {
                    performHapticFeedback(HapticFeedbackConstants.VIRTUAL_KEY);
                }
                mIsPressed = true;
                if (isProxyConnected) {
                    // Provide small vibration for quick step or immediate down feedback
                    AsyncTask.execute(() ->
                            mVibrator.vibrate(VibrationEffect
                                    .get(VibrationEffect.EFFECT_TICK, false)));
                } else {
                if (!isProxyConnected) {
                    playSoundEffect(SoundEffectConstants.CLICK);
                    setPressed(mIsPressed);
                }
+10 −0
Original line number Diff line number Diff line
@@ -541,6 +541,7 @@ public class PhoneWindowManager implements WindowManagerPolicy {
    volatile boolean mGoingToSleep;
    volatile boolean mRequestedOrGoingToSleep;
    volatile boolean mRecentsVisible;
    volatile boolean mNavBarVirtualKeyHapticFeedbackEnabled;
    volatile boolean mPictureInPictureVisible;
    // Written by vr manager thread, only read in this class.
    volatile private boolean mPersistentVrModeEnabled;
@@ -4367,6 +4368,11 @@ public class PhoneWindowManager implements WindowManagerPolicy {
        mPictureInPictureVisible = visible;
    }

    @Override
    public void setNavBarVirtualKeyHapticFeedbackEnabledLw(boolean enabled) {
        mNavBarVirtualKeyHapticFeedbackEnabled = enabled;
    }

    @Override
    public int adjustSystemUiVisibilityLw(int visibility) {
        mStatusBarController.adjustSystemUiVisibilityLw(mLastSystemUiFlags, visibility);
@@ -5892,8 +5898,12 @@ public class PhoneWindowManager implements WindowManagerPolicy {
            return result;
        }

        // Enable haptics if down and virtual key without multiple repetitions. If this is a hard
        // virtual key such as a navigation bar button, only vibrate if flag is enabled.
        final boolean isNavBarVirtKey = ((event.getFlags() & KeyEvent.FLAG_VIRTUAL_HARD_KEY) != 0);
        boolean useHapticFeedback = down
                && (policyFlags & WindowManagerPolicy.FLAG_VIRTUAL) != 0
                && (!isNavBarVirtKey || mNavBarVirtualKeyHapticFeedbackEnabled)
                && event.getRepeatCount() == 0;

        // Handle special keys.
Loading