1 /*
2  * Copyright (C) 2017 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.settings.testutils.shadow;
18 
19 import android.app.admin.DevicePolicyManager;
20 import android.content.ComponentName;
21 
22 import com.android.internal.widget.LockPatternUtils;
23 
24 import org.robolectric.annotation.Implementation;
25 import org.robolectric.annotation.Implements;
26 
27 import java.util.List;
28 
29 @Implements(LockPatternUtils.class)
30 public class ShadowLockPatternUtils {
31 
32     private static boolean sDeviceEncryptionEnabled;
33 
34     @Implementation
hasSecureLockScreen()35     protected boolean hasSecureLockScreen() {
36         return true;
37     }
38 
39     @Implementation
isSecure(int id)40     protected boolean isSecure(int id) {
41         return true;
42     }
43 
44     @Implementation
getActivePasswordQuality(int userId)45     protected int getActivePasswordQuality(int userId) {
46         return DevicePolicyManager.PASSWORD_QUALITY_UNSPECIFIED;
47     }
48 
49     @Implementation
getKeyguardStoredPasswordQuality(int userHandle)50     protected int getKeyguardStoredPasswordQuality(int userHandle) {
51         return 1;
52     }
53 
54     @Implementation
isDeviceEncryptionEnabled()55     protected static boolean isDeviceEncryptionEnabled() {
56         return sDeviceEncryptionEnabled;
57     }
58 
59     @Implementation
getEnabledTrustAgents(int userId)60     protected List<ComponentName> getEnabledTrustAgents(int userId) {
61         return null;
62     }
63 
setDeviceEncryptionEnabled(boolean deviceEncryptionEnabled)64     public static void setDeviceEncryptionEnabled(boolean deviceEncryptionEnabled) {
65         sDeviceEncryptionEnabled = deviceEncryptionEnabled;
66     }
67 
68     @Implementation
getPasswordHistoryHashFactor(byte[] currentPassword, int userId)69     protected byte[] getPasswordHistoryHashFactor(byte[] currentPassword, int userId) {
70         return null;
71     }
72 
73     @Implementation
checkPasswordHistory(byte[] passwordToCheck, byte[] hashFactor, int userId)74     protected boolean checkPasswordHistory(byte[] passwordToCheck, byte[] hashFactor, int userId) {
75         return false;
76     }
77 }
78