Skip to content

Commit d0e1c0c

Browse files
committed
Fix test for lock pattern for api 23+
1 parent 348cce9 commit d0e1c0c

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

src/android/secureDevice.java

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -135,8 +135,15 @@ private static boolean isPatternSet(Context context)
135135
ContentResolver cr = context.getContentResolver();
136136
try
137137
{
138-
int lockPatternEnable = Settings.Secure.getInt(cr, Settings.Secure.LOCK_PATTERN_ENABLED);
139-
return lockPatternEnable == 1;
138+
// This constant was deprecated in API level 23.
139+
// Use KeyguardManager to determine the state and security level of the keyguard.
140+
// Accessing this setting from an app that is targeting M or later throws a SecurityException.
141+
if (android.os.Build.VERSION.SDK_INT < android.os.Build.VERSION_CODES.M) {
142+
int lockPatternEnable = Settings.Secure.getInt(cr, Settings.Secure.LOCK_PATTERN_ENABLED);
143+
return lockPatternEnable == 1;
144+
} else {
145+
return false;
146+
}
140147
}
141148
catch (Settings.SettingNotFoundException e)
142149
{

0 commit comments

Comments
 (0)