Loading packages/SystemUI/src/com/android/keyguard/KeyguardPasswordView.java +0 −8 Original line number Diff line number Diff line Loading @@ -140,12 +140,6 @@ public class KeyguardPasswordView extends KeyguardAbsKeyInputView mImm.hideSoftInputFromWindow(getWindowToken(), 0); } @Override public void reset() { super.reset(); mPasswordEntry.requestFocus(); } private void updateSwitchImeButton() { // If there's more than one IME, enable the IME switcher button final boolean wasVisible = mSwitchImeButton.getVisibility() == View.VISIBLE; Loading Loading @@ -193,8 +187,6 @@ public class KeyguardPasswordView extends KeyguardAbsKeyInputView // Set selected property on so the view can send accessibility events. mPasswordEntry.setSelected(true); mPasswordEntry.requestFocus(); mSwitchImeButton = findViewById(R.id.switch_ime_button); mSwitchImeButton.setOnClickListener(new OnClickListener() { @Override Loading packages/SystemUI/src/com/android/keyguard/KeyguardPinBasedInputView.java +10 −7 Original line number Diff line number Diff line Loading @@ -23,13 +23,16 @@ import android.view.KeyEvent; import android.view.MotionEvent; import android.view.View; import com.android.internal.annotations.VisibleForTesting; /** * A Pin based Keyguard input view */ public abstract class KeyguardPinBasedInputView extends KeyguardAbsKeyInputView implements View.OnKeyListener, View.OnTouchListener { protected PasswordTextView mPasswordEntry; @VisibleForTesting PasswordTextView mPasswordEntry; private View mOkButton; private View mDeleteButton; private View mButton0; Loading @@ -51,12 +54,6 @@ public abstract class KeyguardPinBasedInputView extends KeyguardAbsKeyInputView super(context, attrs); } @Override public void reset() { mPasswordEntry.requestFocus(); super.reset(); } @Override protected boolean onRequestFocusInDescendants(int direction, Rect previouslyFocusedRect) { // send focus to the password field Loading Loading @@ -237,6 +234,12 @@ public abstract class KeyguardPinBasedInputView extends KeyguardAbsKeyInputView super.onFinishInflate(); } @Override public void onResume(int reason) { super.onResume(reason); mPasswordEntry.requestFocus(); } @Override public boolean onTouch(View v, MotionEvent event) { if (event.getActionMasked() == MotionEvent.ACTION_DOWN) { Loading packages/SystemUI/src/com/android/systemui/statusbar/phone/KeyguardBouncer.java +19 −8 Original line number Diff line number Diff line Loading @@ -54,6 +54,8 @@ public class KeyguardBouncer { private static final String TAG = "KeyguardBouncer"; static final float ALPHA_EXPANSION_THRESHOLD = 0.95f; private static final float EXPANSION_HIDDEN = 1f; private static final float EXPANSION_VISIBLE = 0f; protected final Context mContext; protected final ViewMediatorCallback mCallback; Loading @@ -71,10 +73,15 @@ public class KeyguardBouncer { } }; private final Runnable mRemoveViewRunnable = this::removeView; protected KeyguardHostView mKeyguardView; private final Runnable mResetRunnable = ()-> { if (mKeyguardView != null) { mKeyguardView.reset(); } }; private int mStatusBarHeight; private float mExpansion; protected KeyguardHostView mKeyguardView; private float mExpansion = EXPANSION_HIDDEN; protected ViewGroup mRoot; private boolean mShowingSoon; private int mBouncerPromptReason; Loading @@ -96,7 +103,7 @@ public class KeyguardBouncer { } public void show(boolean resetSecuritySelection) { show(resetSecuritySelection, true /* notifyFalsing */); show(resetSecuritySelection, true /* animated */); } /** Loading @@ -120,8 +127,7 @@ public class KeyguardBouncer { // Later, at the end of the animation, when the bouncer is at the top of the screen, // onFullyShown() will be called and FalsingManager will stop recording touches. if (animated) { mFalsingManager.onBouncerShown(); setExpansion(0); setExpansion(EXPANSION_VISIBLE); } if (resetSecuritySelection) { Loading Loading @@ -152,6 +158,7 @@ public class KeyguardBouncer { mShowingSoon = true; // Split up the work over multiple frames. DejankUtils.removeCallbacks(mResetRunnable); DejankUtils.postAfterTraversal(mShowRunnable); mCallback.onBouncerVisiblityChanged(true /* shown */); Loading Loading @@ -181,6 +188,7 @@ public class KeyguardBouncer { mRoot.setVisibility(View.INVISIBLE); } mFalsingManager.onBouncerHidden(); DejankUtils.postAfterTraversal(mResetRunnable); } } Loading Loading @@ -210,6 +218,9 @@ public class KeyguardBouncer { mKeyguardView.requestLayout(); } mShowingSoon = false; if (mExpansion == EXPANSION_VISIBLE) { mKeyguardView.onResume(); } StatsLog.write(StatsLog.KEYGUARD_BOUNCER_STATE_CHANGED, StatsLog.KEYGUARD_BOUNCER_STATE_CHANGED__STATE__SHOWN); } Loading Loading @@ -303,7 +314,7 @@ public class KeyguardBouncer { public boolean isShowing() { return (mShowingSoon || (mRoot != null && mRoot.getVisibility() == View.VISIBLE)) && mExpansion == 0 && !isAnimatingAway(); && mExpansion == EXPANSION_VISIBLE && !isAnimatingAway(); } /** Loading Loading @@ -337,10 +348,10 @@ public class KeyguardBouncer { mKeyguardView.setTranslationY(fraction * mKeyguardView.getHeight()); } if (fraction == 0 && oldExpansion != 0) { if (fraction == EXPANSION_VISIBLE && oldExpansion != EXPANSION_VISIBLE) { onFullyShown(); mExpansionCallback.onFullyShown(); } else if (fraction == 1 && oldExpansion != 0) { } else if (fraction == EXPANSION_HIDDEN && oldExpansion != EXPANSION_HIDDEN) { onFullyHidden(); mExpansionCallback.onFullyHidden(); } Loading packages/SystemUI/tests/src/com/android/keyguard/KeyguardPinBasedInputViewTest.java 0 → 100644 +57 −0 Original line number Diff line number Diff line /* * Copyright (C) 2018 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License */ package com.android.keyguard; import static org.mockito.Mockito.verify; import android.support.test.filters.SmallTest; import android.testing.AndroidTestingRunner; import android.testing.TestableLooper.RunWithLooper; import android.view.LayoutInflater; import com.android.systemui.SysuiTestCase; import org.junit.Before; import org.junit.Test; import org.junit.runner.RunWith; import org.mockito.Mock; import org.mockito.MockitoAnnotations; @SmallTest @RunWith(AndroidTestingRunner.class) @RunWithLooper(setAsMainLooper = true) public class KeyguardPinBasedInputViewTest extends SysuiTestCase { @Mock private PasswordTextView mPasswordTextView; private KeyguardPinBasedInputView mKeyguardPinView; @Before public void setup() { MockitoAnnotations.initMocks(this); LayoutInflater inflater = LayoutInflater.from(getContext()); mKeyguardPinView = (KeyguardPinBasedInputView) inflater.inflate(R.layout.keyguard_pin_view, null); mKeyguardPinView.mPasswordEntry = mPasswordTextView; } @Test public void onResume_requestsFocus() { mKeyguardPinView.onResume(KeyguardSecurityView.SCREEN_ON); verify(mPasswordTextView).requestFocus(); } } Loading
packages/SystemUI/src/com/android/keyguard/KeyguardPasswordView.java +0 −8 Original line number Diff line number Diff line Loading @@ -140,12 +140,6 @@ public class KeyguardPasswordView extends KeyguardAbsKeyInputView mImm.hideSoftInputFromWindow(getWindowToken(), 0); } @Override public void reset() { super.reset(); mPasswordEntry.requestFocus(); } private void updateSwitchImeButton() { // If there's more than one IME, enable the IME switcher button final boolean wasVisible = mSwitchImeButton.getVisibility() == View.VISIBLE; Loading Loading @@ -193,8 +187,6 @@ public class KeyguardPasswordView extends KeyguardAbsKeyInputView // Set selected property on so the view can send accessibility events. mPasswordEntry.setSelected(true); mPasswordEntry.requestFocus(); mSwitchImeButton = findViewById(R.id.switch_ime_button); mSwitchImeButton.setOnClickListener(new OnClickListener() { @Override Loading
packages/SystemUI/src/com/android/keyguard/KeyguardPinBasedInputView.java +10 −7 Original line number Diff line number Diff line Loading @@ -23,13 +23,16 @@ import android.view.KeyEvent; import android.view.MotionEvent; import android.view.View; import com.android.internal.annotations.VisibleForTesting; /** * A Pin based Keyguard input view */ public abstract class KeyguardPinBasedInputView extends KeyguardAbsKeyInputView implements View.OnKeyListener, View.OnTouchListener { protected PasswordTextView mPasswordEntry; @VisibleForTesting PasswordTextView mPasswordEntry; private View mOkButton; private View mDeleteButton; private View mButton0; Loading @@ -51,12 +54,6 @@ public abstract class KeyguardPinBasedInputView extends KeyguardAbsKeyInputView super(context, attrs); } @Override public void reset() { mPasswordEntry.requestFocus(); super.reset(); } @Override protected boolean onRequestFocusInDescendants(int direction, Rect previouslyFocusedRect) { // send focus to the password field Loading Loading @@ -237,6 +234,12 @@ public abstract class KeyguardPinBasedInputView extends KeyguardAbsKeyInputView super.onFinishInflate(); } @Override public void onResume(int reason) { super.onResume(reason); mPasswordEntry.requestFocus(); } @Override public boolean onTouch(View v, MotionEvent event) { if (event.getActionMasked() == MotionEvent.ACTION_DOWN) { Loading
packages/SystemUI/src/com/android/systemui/statusbar/phone/KeyguardBouncer.java +19 −8 Original line number Diff line number Diff line Loading @@ -54,6 +54,8 @@ public class KeyguardBouncer { private static final String TAG = "KeyguardBouncer"; static final float ALPHA_EXPANSION_THRESHOLD = 0.95f; private static final float EXPANSION_HIDDEN = 1f; private static final float EXPANSION_VISIBLE = 0f; protected final Context mContext; protected final ViewMediatorCallback mCallback; Loading @@ -71,10 +73,15 @@ public class KeyguardBouncer { } }; private final Runnable mRemoveViewRunnable = this::removeView; protected KeyguardHostView mKeyguardView; private final Runnable mResetRunnable = ()-> { if (mKeyguardView != null) { mKeyguardView.reset(); } }; private int mStatusBarHeight; private float mExpansion; protected KeyguardHostView mKeyguardView; private float mExpansion = EXPANSION_HIDDEN; protected ViewGroup mRoot; private boolean mShowingSoon; private int mBouncerPromptReason; Loading @@ -96,7 +103,7 @@ public class KeyguardBouncer { } public void show(boolean resetSecuritySelection) { show(resetSecuritySelection, true /* notifyFalsing */); show(resetSecuritySelection, true /* animated */); } /** Loading @@ -120,8 +127,7 @@ public class KeyguardBouncer { // Later, at the end of the animation, when the bouncer is at the top of the screen, // onFullyShown() will be called and FalsingManager will stop recording touches. if (animated) { mFalsingManager.onBouncerShown(); setExpansion(0); setExpansion(EXPANSION_VISIBLE); } if (resetSecuritySelection) { Loading Loading @@ -152,6 +158,7 @@ public class KeyguardBouncer { mShowingSoon = true; // Split up the work over multiple frames. DejankUtils.removeCallbacks(mResetRunnable); DejankUtils.postAfterTraversal(mShowRunnable); mCallback.onBouncerVisiblityChanged(true /* shown */); Loading Loading @@ -181,6 +188,7 @@ public class KeyguardBouncer { mRoot.setVisibility(View.INVISIBLE); } mFalsingManager.onBouncerHidden(); DejankUtils.postAfterTraversal(mResetRunnable); } } Loading Loading @@ -210,6 +218,9 @@ public class KeyguardBouncer { mKeyguardView.requestLayout(); } mShowingSoon = false; if (mExpansion == EXPANSION_VISIBLE) { mKeyguardView.onResume(); } StatsLog.write(StatsLog.KEYGUARD_BOUNCER_STATE_CHANGED, StatsLog.KEYGUARD_BOUNCER_STATE_CHANGED__STATE__SHOWN); } Loading Loading @@ -303,7 +314,7 @@ public class KeyguardBouncer { public boolean isShowing() { return (mShowingSoon || (mRoot != null && mRoot.getVisibility() == View.VISIBLE)) && mExpansion == 0 && !isAnimatingAway(); && mExpansion == EXPANSION_VISIBLE && !isAnimatingAway(); } /** Loading Loading @@ -337,10 +348,10 @@ public class KeyguardBouncer { mKeyguardView.setTranslationY(fraction * mKeyguardView.getHeight()); } if (fraction == 0 && oldExpansion != 0) { if (fraction == EXPANSION_VISIBLE && oldExpansion != EXPANSION_VISIBLE) { onFullyShown(); mExpansionCallback.onFullyShown(); } else if (fraction == 1 && oldExpansion != 0) { } else if (fraction == EXPANSION_HIDDEN && oldExpansion != EXPANSION_HIDDEN) { onFullyHidden(); mExpansionCallback.onFullyHidden(); } Loading
packages/SystemUI/tests/src/com/android/keyguard/KeyguardPinBasedInputViewTest.java 0 → 100644 +57 −0 Original line number Diff line number Diff line /* * Copyright (C) 2018 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License */ package com.android.keyguard; import static org.mockito.Mockito.verify; import android.support.test.filters.SmallTest; import android.testing.AndroidTestingRunner; import android.testing.TestableLooper.RunWithLooper; import android.view.LayoutInflater; import com.android.systemui.SysuiTestCase; import org.junit.Before; import org.junit.Test; import org.junit.runner.RunWith; import org.mockito.Mock; import org.mockito.MockitoAnnotations; @SmallTest @RunWith(AndroidTestingRunner.class) @RunWithLooper(setAsMainLooper = true) public class KeyguardPinBasedInputViewTest extends SysuiTestCase { @Mock private PasswordTextView mPasswordTextView; private KeyguardPinBasedInputView mKeyguardPinView; @Before public void setup() { MockitoAnnotations.initMocks(this); LayoutInflater inflater = LayoutInflater.from(getContext()); mKeyguardPinView = (KeyguardPinBasedInputView) inflater.inflate(R.layout.keyguard_pin_view, null); mKeyguardPinView.mPasswordEntry = mPasswordTextView; } @Test public void onResume_requestsFocus() { mKeyguardPinView.onResume(KeyguardSecurityView.SCREEN_ON); verify(mPasswordTextView).requestFocus(); } }