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
This commit is contained in:
Lucas Dupin
2019-08-27 16:46:16 -07:00
parent 7459ad0aec
commit 1fae62abc1

View File

@@ -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);