• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2014 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.content.Context;
20 import android.os.Bundle;
21 import android.util.AttributeSet;
22 import android.view.MotionEvent;
23 
24 public class KeyguardSimpleHostView extends KeyguardViewBase {
25 
KeyguardSimpleHostView(Context context, AttributeSet attrs)26     public KeyguardSimpleHostView(Context context, AttributeSet attrs) {
27         super(context, attrs);
28         KeyguardUpdateMonitor.getInstance(context).registerCallback(mUpdateCallback);
29     }
30 
31     @Override
showBouncer(boolean show)32     protected void showBouncer(boolean show) {
33         super.showBouncer(show);
34         if (show) {
35             getSecurityContainer().showBouncer(250);
36         } else {
37             getSecurityContainer().hideBouncer(250);
38         }
39     }
40 
41     @Override
cleanUp()42     public void cleanUp() {
43         getSecurityContainer().onPause();
44     }
45 
46     @Override
getUserActivityTimeout()47     public long getUserActivityTimeout() {
48         return -1; // not used
49     }
50 
51     @Override
onUserSwitching(boolean switching)52     protected void onUserSwitching(boolean switching) {
53         // TODO Auto-generated method stub
54     }
55 
56     @Override
onCreateOptions(Bundle options)57     protected void onCreateOptions(Bundle options) {
58         // TODO Auto-generated method stub
59     }
60 
61     @Override
onExternalMotionEvent(MotionEvent event)62     protected void onExternalMotionEvent(MotionEvent event) {
63         // TODO Auto-generated method stub
64     }
65 
66     private KeyguardUpdateMonitorCallback mUpdateCallback = new KeyguardUpdateMonitorCallback() {
67         @Override
68         public void onUserSwitchComplete(int userId) {
69             getSecurityContainer().showPrimarySecurityScreen(false /* turning off */);
70         }
71 
72         @Override
73         public void onTrustInitiatedByUser(int userId) {
74             if (userId != mLockPatternUtils.getCurrentUser()) return;
75             if (!isAttachedToWindow()) return;
76 
77             if (isVisibleToUser()) {
78                 dismiss(false /* authenticated */);
79             } else {
80                 mViewMediatorCallback.playTrustedSound();
81             }
82         }
83     };
84 }
85