-
Notifications
You must be signed in to change notification settings - Fork 139
Expand file tree
/
Copy pathAppLockManager.java
More file actions
60 lines (49 loc) · 1.85 KB
/
Copy pathAppLockManager.java
File metadata and controls
60 lines (49 loc) · 1.85 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
package org.wordpress.passcodelock;
import android.app.Application;
public class AppLockManager {
private static AppLockManager instance;
private AbstractAppLock currentAppLocker;
public static AppLockManager getInstance() {
if (instance == null) {
instance = new AppLockManager();
}
return instance;
}
public void enableDefaultAppLockIfAvailable(Application currentApp) {
if (!DefaultAppLock.isSupportedApi()) return;
if (currentAppLocker != null) {
if (currentAppLocker instanceof DefaultAppLock) {
// A previous default applocker is already in place
// No need to re-enable it
return;
}
// A previous NON-default applockr is in place. Disable it.
currentAppLocker.disable();
}
currentAppLocker = new DefaultAppLock(currentApp);
currentAppLocker.enable();
}
public boolean isDefaultLock() {
return getAppLock() != null && getAppLock() instanceof DefaultAppLock;
}
/**
* @return true when an App lock is available. It could be either a the Default App lock on
* Android-v14 or higher, or a non default App lock
*/
public boolean isAppLockFeatureEnabled() {
return getAppLock() != null && (!isDefaultLock() || DefaultAppLock.isSupportedApi());
}
public void setCurrentAppLock(AbstractAppLock newAppLocker) {
if( currentAppLocker != null ) {
currentAppLocker.disable(); //disable the old applocker if available
}
currentAppLocker = newAppLocker;
}
public AbstractAppLock getAppLock() {
return currentAppLocker;
}
public void setExtendedTimeout(){
if (getAppLock() == null) return;
getAppLock().setOneTimeTimeout(AbstractAppLock.EXTENDED_TIMEOUT_S);
}
}