• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2020 The Android Open Source Project
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *      http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 package com.android.keyguard;
18 
19 import android.view.View;
20 
21 import com.android.internal.util.LatencyTracker;
22 import com.android.internal.widget.LockPatternUtils;
23 import com.android.keyguard.KeyguardSecurityModel.SecurityMode;
24 import com.android.systemui.R;
25 import com.android.systemui.classifier.FalsingCollector;
26 import com.android.systemui.statusbar.policy.DevicePostureController;
27 
28 public class KeyguardPinViewController
29         extends KeyguardPinBasedInputViewController<KeyguardPINView> {
30     private final KeyguardUpdateMonitor mKeyguardUpdateMonitor;
31     private final DevicePostureController mPostureController;
32     private final DevicePostureController.Callback mPostureCallback = posture ->
33             mView.onDevicePostureChanged(posture);
34 
KeyguardPinViewController(KeyguardPINView view, KeyguardUpdateMonitor keyguardUpdateMonitor, SecurityMode securityMode, LockPatternUtils lockPatternUtils, KeyguardSecurityCallback keyguardSecurityCallback, KeyguardMessageAreaController.Factory messageAreaControllerFactory, LatencyTracker latencyTracker, LiftToActivateListener liftToActivateListener, EmergencyButtonController emergencyButtonController, FalsingCollector falsingCollector, DevicePostureController postureController)35     protected KeyguardPinViewController(KeyguardPINView view,
36             KeyguardUpdateMonitor keyguardUpdateMonitor,
37             SecurityMode securityMode, LockPatternUtils lockPatternUtils,
38             KeyguardSecurityCallback keyguardSecurityCallback,
39             KeyguardMessageAreaController.Factory messageAreaControllerFactory,
40             LatencyTracker latencyTracker, LiftToActivateListener liftToActivateListener,
41             EmergencyButtonController emergencyButtonController,
42             FalsingCollector falsingCollector,
43             DevicePostureController postureController) {
44         super(view, keyguardUpdateMonitor, securityMode, lockPatternUtils, keyguardSecurityCallback,
45                 messageAreaControllerFactory, latencyTracker, liftToActivateListener,
46                 emergencyButtonController, falsingCollector);
47         mKeyguardUpdateMonitor = keyguardUpdateMonitor;
48         mPostureController = postureController;
49     }
50 
51     @Override
onViewAttached()52     protected void onViewAttached() {
53         super.onViewAttached();
54 
55         View cancelBtn = mView.findViewById(R.id.cancel_button);
56         if (cancelBtn != null) {
57             cancelBtn.setOnClickListener(view -> {
58                 getKeyguardSecurityCallback().reset();
59                 getKeyguardSecurityCallback().onCancelClicked();
60             });
61         }
62 
63         mPostureController.addCallback(mPostureCallback);
64     }
65 
66     @Override
onViewDetached()67     protected void onViewDetached() {
68         super.onViewDetached();
69         mPostureController.removeCallback(mPostureCallback);
70     }
71 
72     @Override
startDisappearAnimation(Runnable finishRunnable)73     public boolean startDisappearAnimation(Runnable finishRunnable) {
74         return mView.startDisappearAnimation(
75                 mKeyguardUpdateMonitor.needsSlowUnlockTransition(), finishRunnable);
76     }
77 }
78