Methods Summary |
---|
public void | dump(java.io.PrintWriter pw)
pw.println("mWhitelist=" + Arrays.toString(mWhitelist) + " mBlacklist=" +
Arrays.toString(mBlacklist));
|
private java.lang.String[] | getStringArrayLocked(java.lang.String key)
String flatString;
synchronized(mLock) {
flatString = Settings.Secure.getStringForUser(mContext.getContentResolver(), key,
mCurrentUserId);
}
if (flatString == null) {
return new String[0];
}
String[] splitStrings = flatString.split(",");
ArrayList<String> result = new ArrayList<String>();
for (String pkg : splitStrings) {
pkg = pkg.trim();
if (pkg.isEmpty()) {
continue;
}
result.add(pkg);
}
return result.toArray(new String[result.size()]);
|
private boolean | inWhitelist(java.lang.String pkg)Return true if any of packages are in whitelist
synchronized (mLock) {
for (String white : mWhitelist) {
if (pkg.startsWith(white)) return true;
}
}
return false;
|
public void | init()
mContext.getContentResolver().registerContentObserver(Settings.Secure.getUriFor(
BLACKLIST_CONFIG_NAME), false, this, UserHandle.USER_ALL);
// mContext.getContentResolver().registerContentObserver(Settings.Secure.getUriFor(
// WHITELIST_CONFIG_NAME), false, this, UserHandle.USER_ALL);
reloadBlacklist();
|
public boolean | isBlacklisted(java.lang.String packageName)Return true if in blacklist
(package name matches blacklist, and does not match whitelist)
synchronized (mLock) {
for (String black : mBlacklist) {
if (packageName.startsWith(black)) {
if (inWhitelist(packageName)) {
continue;
} else {
if (D) Log.d(TAG, "dropping location (blacklisted): "
+ packageName + " matches " + black);
return true;
}
}
}
}
return false;
|
public void | onChange(boolean selfChange)
reloadBlacklist();
|
private void | reloadBlacklist()
synchronized (mLock) {
reloadBlacklistLocked();
}
|
private void | reloadBlacklistLocked()
mWhitelist = getStringArrayLocked(WHITELIST_CONFIG_NAME);
if (D) Slog.d(TAG, "whitelist: " + Arrays.toString(mWhitelist));
mBlacklist = getStringArrayLocked(BLACKLIST_CONFIG_NAME);
if (D) Slog.d(TAG, "blacklist: " + Arrays.toString(mBlacklist));
|
public void | switchUser(int userId)
synchronized(mLock) {
mCurrentUserId = userId;
reloadBlacklistLocked();
}
|