OSDN Git Service

original
[gb-231r1-is01/Gingerbread_2.3.3_r1_IS01.git] / frameworks / base / policy / src / com / android / internal / policy / impl / LockPatternKeyguardViewProperties.java
1 /*
2  * Copyright (C) 2008 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.internal.policy.impl;
18
19 import com.android.internal.widget.LockPatternUtils;
20
21 import android.content.Context;
22 import com.android.internal.telephony.IccCard;
23
24 /**
25  * Knows how to create a lock pattern keyguard view, and answer questions about
26  * it (even if it hasn't been created, per the interface specs).
27  */
28 public class LockPatternKeyguardViewProperties implements KeyguardViewProperties {
29
30     private final LockPatternUtils mLockPatternUtils;
31     private final KeyguardUpdateMonitor mUpdateMonitor;
32
33     /**
34      * @param lockPatternUtils Used to know whether the pattern enabled, and passed
35      *   onto the keygaurd view when it is created.
36      * @param updateMonitor Used to know whether the sim pin is enabled, and passed
37      *   onto the keyguard view when it is created.
38      */
39     public LockPatternKeyguardViewProperties(LockPatternUtils lockPatternUtils,
40             KeyguardUpdateMonitor updateMonitor) {
41         mLockPatternUtils = lockPatternUtils;
42         mUpdateMonitor = updateMonitor;
43     }
44
45     public KeyguardViewBase createKeyguardView(Context context,
46             KeyguardUpdateMonitor updateMonitor,
47             KeyguardWindowController controller) {
48         return new LockPatternKeyguardView(context, updateMonitor,
49                 mLockPatternUtils, controller);
50     }
51
52     public boolean isSecure() {
53         return mLockPatternUtils.isSecure() || isSimPinSecure();
54     }
55
56     private boolean isSimPinSecure() {
57         final IccCard.State simState = mUpdateMonitor.getSimState();
58         return (simState == IccCard.State.PIN_REQUIRED || simState == IccCard.State.PUK_REQUIRED
59             || simState == IccCard.State.ABSENT);
60     }
61
62 }