-
Notifications
You must be signed in to change notification settings - Fork 139
Expand file tree
/
Copy pathAbstractAppLock.java
More file actions
86 lines (74 loc) · 2.92 KB
/
Copy pathAbstractAppLock.java
File metadata and controls
86 lines (74 loc) · 2.92 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
package org.wordpress.passcodelock;
import android.annotation.TargetApi;
import android.app.Application;
import android.os.Build;
/**
* Interface for AppLock implementations.
*
* There are situations where the AppLock should not be required within an app. Methods for tracking
* exempt {@link android.app.Activity}'s are provided and sub-class implementations are expected to
* comply with requested exemptions.
* @see #isExemptActivity(String)
* @see #setExemptActivities(String[])
* @see #getExemptActivities()
*
* Applications can request a one-time delay in locking the app. This can be useful for activities
* that launch external applications with the expectation that the user will return to the calling
* application shortly.
*/
@TargetApi(Build.VERSION_CODES.ICE_CREAM_SANDWICH)
public abstract class AbstractAppLock implements Application.ActivityLifecycleCallbacks {
public static final String FINGERPRINT_VERIFICATION_BYPASS = "fingerprint-bypass__";
public static final int DEFAULT_TIMEOUT_S = 2;
public static final int EXTENDED_TIMEOUT_S = 60;
private int mLockTimeout = DEFAULT_TIMEOUT_S;
private String[] mExemptActivities;
public boolean isExemptActivity(String name) {
if (name == null) return false;
for (String activityName : getExemptActivities()) {
if (name.equals(activityName)) return true;
}
return false;
}
public void setExemptActivities(String[] exemptActivities) {
mExemptActivities = exemptActivities;
}
public String[] getExemptActivities() {
if (mExemptActivities == null) setExemptActivities(new String[0]);
return mExemptActivities;
}
public void setOneTimeTimeout(int timeout) {
mLockTimeout = timeout;
}
public int getTimeout() {
return mLockTimeout;
}
protected boolean isFingerprintPassword(String password) {
return FINGERPRINT_VERIFICATION_BYPASS.equals(password);
}
/**
* Whether the fingerprint unlocking should be available as option in the unlock screen.
* Default is true, but implementation can override this and make their choice.
*
* Note that this doesn't affect system setting, the device must already have fingerprint unlock
* available and correctly working.
*
* @return true if fingerprint unlock should be enabled on the lock screen
*/
public boolean isFingerprintEnabled() {
return true;
}
// Stub methods to avoid sub-classes to override to many unused methods.
public boolean enableFingerprint() {
return true;
}
public boolean disableFingerprint() {
return false;
}
public abstract void enable();
public abstract void disable();
public abstract void forcePasswordLock();
public abstract boolean verifyPassword(String password);
public abstract boolean isPasswordLocked();
public abstract boolean setPassword(String password);
}