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
17package com.android.keyguard;
18
19import android.content.Context;
20import android.os.Bundle;
21import android.util.AttributeSet;
22import android.view.MotionEvent;
23
24public class KeyguardSimpleHostView extends KeyguardViewBase {
25
26    public KeyguardSimpleHostView(Context context, AttributeSet attrs) {
27        super(context, attrs);
28        KeyguardUpdateMonitor.getInstance(context).registerCallback(mUpdateCallback);
29    }
30
31    @Override
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
42    public void cleanUp() {
43        getSecurityContainer().onPause();
44    }
45
46    @Override
47    public long getUserActivityTimeout() {
48        return -1; // not used
49    }
50
51    @Override
52    protected void onUserSwitching(boolean switching) {
53        // TODO Auto-generated method stub
54    }
55
56    @Override
57    protected void onCreateOptions(Bundle options) {
58        // TODO Auto-generated method stub
59    }
60
61    @Override
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