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

Commit 1fae62ab authored by Lucas Dupin's avatar Lucas Dupin
Browse files

Move IPC out of critical path

isTactileFeedbackEnabled will consult a Setting. Let's postpone the
possible IPC until we actually need to read the value.
Subsequent calls will be cached by the Settings internal cache.

Fixes: 140043085
Test: unlock with pin, feel haptics
Change-Id: I50d43ff25ee4ff32044ca626e5a87929bb163170
parent 7459ad0a
Loading
Loading
Loading
Loading
+7 −11
Original line number Diff line number Diff line
@@ -16,8 +16,6 @@

package com.android.keyguard;

import static com.android.systemui.DejankUtils.whitelistIpcs;

import android.content.Context;
import android.content.res.TypedArray;
import android.os.PowerManager;
@@ -36,13 +34,14 @@ public class NumPadKey extends ViewGroup {
    // list of "ABC", etc per digit, starting with '0'
    static String sKlondike[];

    private final TextView mDigitText;
    private final TextView mKlondikeText;
    private final LockPatternUtils mLockPatternUtils;
    private final PowerManager mPM;

    private int mDigit = -1;
    private int mTextViewResId;
    private PasswordTextView mTextView;
    private TextView mDigitText;
    private TextView mKlondikeText;
    private boolean mEnableHaptics;
    private PowerManager mPM;

    private View.OnClickListener mListener = new View.OnClickListener() {
        @Override
@@ -92,10 +91,7 @@ public class NumPadKey extends ViewGroup {
        setOnClickListener(mListener);
        setOnHoverListener(new LiftToActivateListener(context));

        // TODO(b/140043085)
        mEnableHaptics = whitelistIpcs(() ->
                new LockPatternUtils(context).isTactileFeedbackEnabled());

        mLockPatternUtils = new LockPatternUtils(context);
        mPM = (PowerManager) mContext.getSystemService(Context.POWER_SERVICE);
        LayoutInflater inflater = (LayoutInflater) getContext().getSystemService(
                Context.LAYOUT_INFLATER_SERVICE);
@@ -166,7 +162,7 @@ public class NumPadKey extends ViewGroup {

    // Cause a VIRTUAL_KEY vibration
    public void doHapticKeyClick() {
        if (mEnableHaptics) {
        if (mLockPatternUtils.isTactileFeedbackEnabled()) {
            performHapticFeedback(HapticFeedbackConstants.VIRTUAL_KEY,
                    HapticFeedbackConstants.FLAG_IGNORE_VIEW_SETTING
                    | HapticFeedbackConstants.FLAG_IGNORE_GLOBAL_SETTING);