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