Fix a couple static leaks.

Change-Id: If2564dc822fbcb3bb3baf270ad2b3c29c78bf421
This commit is contained in:
Dianne Hackborn
2011-07-17 13:42:47 -07:00
parent 9cbf8e270d
commit de4c26fa1a
2 changed files with 19 additions and 13 deletions

View File

@@ -114,6 +114,23 @@ public class LockPatternUtils {
private static final AtomicBoolean sHaveNonZeroPasswordFile = new AtomicBoolean(false);
private static FileObserver sPasswordObserver;
private static class PasswordFileObserver extends FileObserver {
public PasswordFileObserver(String path, int mask) {
super(path, mask);
}
@Override
public void onEvent(int event, String path) {
if (LOCK_PATTERN_FILE.equals(path)) {
Log.d(TAG, "lock pattern file changed");
sHaveNonZeroPatternFile.set(new File(sLockPatternFilename).length() > 0);
} else if (LOCK_PASSWORD_FILE.equals(path)) {
Log.d(TAG, "lock password file changed");
sHaveNonZeroPasswordFile.set(new File(sLockPasswordFilename).length() > 0);
}
}
}
public DevicePolicyManager getDevicePolicyManager() {
if (mDevicePolicyManager == null) {
mDevicePolicyManager =
@@ -143,18 +160,7 @@ public class LockPatternUtils {
sHaveNonZeroPasswordFile.set(new File(sLockPasswordFilename).length() > 0);
int fileObserverMask = FileObserver.CLOSE_WRITE | FileObserver.DELETE |
FileObserver.MOVED_TO | FileObserver.CREATE;
sPasswordObserver = new FileObserver(dataSystemDirectory, fileObserverMask) {
@Override
public void onEvent(int event, String path) {
if (LOCK_PATTERN_FILE.equals(path)) {
Log.d(TAG, "lock pattern file changed");
sHaveNonZeroPatternFile.set(new File(sLockPatternFilename).length() > 0);
} else if (LOCK_PASSWORD_FILE.equals(path)) {
Log.d(TAG, "lock password file changed");
sHaveNonZeroPasswordFile.set(new File(sLockPasswordFilename).length() > 0);
}
}
};
sPasswordObserver = new PasswordFileObserver(dataSystemDirectory, fileObserverMask);
sPasswordObserver.startWatching();
}
}

View File

@@ -61,7 +61,7 @@ public class TelephonyManager {
/** @hide */
public TelephonyManager(Context context) {
if (sContext == null) {
sContext = context;
sContext = context.getApplicationContext();
sRegistry = ITelephonyRegistry.Stub.asInterface(ServiceManager.getService(
"telephony.registry"));