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

Commit 82379ba8 authored by Jeff Brown's avatar Jeff Brown
Browse files

Don't suppress haptic feedback on keyguard anymore.

This enables haptic feedback from virtual keys, lift-to-wake,
and long-press power to work as expected on the keyguard.

There doesn't seem to be a good reason for us to block haptic feedback
on keyguard anymore.  The PIN, pattern, and password locks already
bypass this check and vibrate and require a swipe to access in
the first place.  So there doesn't seem to be much potential
for accidental vibration anymore.

If this becomes a problem then we can investigate more targeted
means to suppress undesired vibration.

Added some debugging code to VibratorService.

Bug: 16535403
Change-Id: Ia7a5d8c35244009db36c358e5cbcbf8cf5d68768
parent 90d7a3e9
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -5401,7 +5401,7 @@ public class PhoneWindowManager implements WindowManagerPolicy {
        }
        final boolean hapticsDisabled = Settings.System.getIntForUser(mContext.getContentResolver(),
                Settings.System.HAPTIC_FEEDBACK_ENABLED, 0, UserHandle.USER_CURRENT) == 0;
        if (!always && (hapticsDisabled || mKeyguardDelegate.isShowingAndNotOccluded())) {
        if (hapticsDisabled && !always) {
            return false;
        }
        long[] pattern = null;
+21 −2
Original line number Diff line number Diff line
@@ -55,6 +55,7 @@ import java.util.ListIterator;
public class VibratorService extends IVibratorService.Stub
        implements InputManager.InputDeviceListener {
    private static final String TAG = "VibratorService";
    private static final boolean DEBUG = false;

    private final LinkedList<Vibration> mVibrations;
    private Vibration mCurrentVibration;
@@ -205,6 +206,7 @@ public class VibratorService extends IVibratorService.Stub
        }
    }

    @Override // Binder call
    public boolean hasVibrator() {
        return doVibratorExists();
    }
@@ -220,6 +222,7 @@ public class VibratorService extends IVibratorService.Stub
                Binder.getCallingPid(), Binder.getCallingUid(), null);
    }

    @Override // Binder call
    public void vibrate(int uid, String opPkg, long milliseconds, int usageHint,
            IBinder token) {
        if (mContext.checkCallingOrSelfPermission(android.Manifest.permission.VIBRATE)
@@ -237,6 +240,10 @@ public class VibratorService extends IVibratorService.Stub
            return;
        }

        if (DEBUG) {
            Slog.d(TAG, "Vibrating for " + milliseconds + " ms.");
        }

        Vibration vib = new Vibration(token, milliseconds, usageHint, uid, opPkg);

        final long ident = Binder.clearCallingIdentity();
@@ -262,6 +269,7 @@ public class VibratorService extends IVibratorService.Stub
        return true;
    }

    @Override // Binder call
    public void vibratePattern(int uid, String packageName, long[] pattern, int repeat,
            int usageHint, IBinder token) {
        if (mContext.checkCallingOrSelfPermission(android.Manifest.permission.VIBRATE)
@@ -272,13 +280,13 @@ public class VibratorService extends IVibratorService.Stub
        // so wakelock calls will succeed
        long identity = Binder.clearCallingIdentity();
        try {
            if (false) {
            if (DEBUG) {
                String s = "";
                int N = pattern.length;
                for (int i=0; i<N; i++) {
                    s += " " + pattern[i];
                }
                Slog.i(TAG, "vibrating with pattern: " + s);
                Slog.d(TAG, "Vibrating with pattern:" + s);
            }

            // we're running in the server so we can't fail
@@ -314,6 +322,7 @@ public class VibratorService extends IVibratorService.Stub
        }
    }

    @Override // Binder call
    public void cancelVibrate(IBinder token) {
        mContext.enforceCallingOrSelfPermission(
                android.Manifest.permission.VIBRATE,
@@ -325,6 +334,9 @@ public class VibratorService extends IVibratorService.Stub
            synchronized (mVibrations) {
                final Vibration vib = removeVibrationLocked(token);
                if (vib == mCurrentVibration) {
                    if (DEBUG) {
                        Slog.d(TAG, "Canceling vibration.");
                    }
                    doCancelVibrateLocked();
                    startNextVibrationLocked();
                }
@@ -336,6 +348,7 @@ public class VibratorService extends IVibratorService.Stub
    }

    private final Runnable mVibrationRunnable = new Runnable() {
        @Override
        public void run() {
            synchronized (mVibrations) {
                doCancelVibrateLocked();
@@ -516,6 +529,9 @@ public class VibratorService extends IVibratorService.Stub

    private void doVibratorOn(long millis, int uid, int usageHint) {
        synchronized (mInputDeviceVibrators) {
            if (DEBUG) {
                Slog.d(TAG, "Turning vibrator on for " + millis + " ms.");
            }
            try {
                mBatteryStatsService.noteVibratorOn(uid, millis);
                mCurVibUid = uid;
@@ -536,6 +552,9 @@ public class VibratorService extends IVibratorService.Stub

    private void doVibratorOff() {
        synchronized (mInputDeviceVibrators) {
            if (DEBUG) {
                Slog.d(TAG, "Turning vibrator off.");
            }
            if (mCurVibUid >= 0) {
                try {
                    mBatteryStatsService.noteVibratorOff(mCurVibUid);