use of com.android.server.SystemConfig in project platform_frameworks_base by android.
the class NetworkPolicyManagerService method addDefaultRestrictBackgroundWhitelistUidsUL.
private boolean addDefaultRestrictBackgroundWhitelistUidsUL(int userId) {
final SystemConfig sysConfig = SystemConfig.getInstance();
final PackageManager pm = mContext.getPackageManager();
final ArraySet<String> allowDataUsage = sysConfig.getAllowInDataUsageSave();
boolean changed = false;
for (int i = 0; i < allowDataUsage.size(); i++) {
final String pkg = allowDataUsage.valueAt(i);
if (LOGD)
Slog.d(TAG, "checking restricted background whitelisting for package " + pkg + " and user " + userId);
final ApplicationInfo app;
try {
app = pm.getApplicationInfoAsUser(pkg, PackageManager.MATCH_SYSTEM_ONLY, userId);
} catch (PackageManager.NameNotFoundException e) {
if (LOGD)
Slog.d(TAG, "No ApplicationInfo for package " + pkg);
// Ignore it - some apps on allow-in-data-usage-save are optional.
continue;
}
if (!app.isPrivilegedApp()) {
Slog.e(TAG, "addDefaultRestrictBackgroundWhitelistUidsUL(): " + "skipping non-privileged app " + pkg);
continue;
}
final int uid = UserHandle.getUid(userId, app.uid);
mDefaultRestrictBackgroundWhitelistUids.append(uid, true);
if (LOGD)
Slog.d(TAG, "Adding uid " + uid + " (user " + userId + ") to default restricted " + "background whitelist. Revoked status: " + mRestrictBackgroundWhitelistRevokedUids.get(uid));
if (!mRestrictBackgroundWhitelistRevokedUids.get(uid)) {
if (LOGD)
Slog.d(TAG, "adding default package " + pkg + " (uid " + uid + " for user " + userId + ") to restrict background whitelist");
mRestrictBackgroundWhitelistUids.append(uid, true);
changed = true;
}
}
return changed;
}
use of com.android.server.SystemConfig in project platform_frameworks_base by android.
the class CarrierAppUtils method disableCarrierAppsUntilPrivileged.
/**
* Like {@link #disableCarrierAppsUntilPrivileged(String, IPackageManager, TelephonyManager,
* ContentResolver, int)}, but assumes that no carrier apps have carrier privileges.
*
* This prevents a potential race condition on first boot - since the app's default state is
* enabled, we will initially disable it when the telephony stack is first initialized as it has
* not yet read the carrier privilege rules. However, since telephony is initialized later on
* late in boot, the app being disabled may have already been started in response to certain
* broadcasts. The app will continue to run (briefly) after being disabled, before the Package
* Manager can kill it, and this can lead to crashes as the app is in an unexpected state.
*/
public static synchronized void disableCarrierAppsUntilPrivileged(String callingPackage, IPackageManager packageManager, ContentResolver contentResolver, int userId) {
if (DEBUG) {
Slog.d(TAG, "disableCarrierAppsUntilPrivileged");
}
SystemConfig config = SystemConfig.getInstance();
String[] systemCarrierAppsDisabledUntilUsed = Resources.getSystem().getStringArray(com.android.internal.R.array.config_disabledUntilUsedPreinstalledCarrierApps);
ArrayMap<String, List<String>> systemCarrierAssociatedAppsDisabledUntilUsed = config.getDisabledUntilUsedPreinstalledCarrierAssociatedApps();
disableCarrierAppsUntilPrivileged(callingPackage, packageManager, null, /* telephonyManager */
contentResolver, userId, systemCarrierAppsDisabledUntilUsed, systemCarrierAssociatedAppsDisabledUntilUsed);
}
use of com.android.server.SystemConfig in project android_frameworks_base by DirtyUnicorns.
the class CarrierAppUtils method disableCarrierAppsUntilPrivileged.
/**
* Like {@link #disableCarrierAppsUntilPrivileged(String, IPackageManager, TelephonyManager,
* ContentResolver, int)}, but assumes that no carrier apps have carrier privileges.
*
* This prevents a potential race condition on first boot - since the app's default state is
* enabled, we will initially disable it when the telephony stack is first initialized as it has
* not yet read the carrier privilege rules. However, since telephony is initialized later on
* late in boot, the app being disabled may have already been started in response to certain
* broadcasts. The app will continue to run (briefly) after being disabled, before the Package
* Manager can kill it, and this can lead to crashes as the app is in an unexpected state.
*/
public static synchronized void disableCarrierAppsUntilPrivileged(String callingPackage, IPackageManager packageManager, ContentResolver contentResolver, int userId) {
if (DEBUG) {
Slog.d(TAG, "disableCarrierAppsUntilPrivileged");
}
SystemConfig config = SystemConfig.getInstance();
String[] systemCarrierAppsDisabledUntilUsed = Resources.getSystem().getStringArray(com.android.internal.R.array.config_disabledUntilUsedPreinstalledCarrierApps);
ArrayMap<String, List<String>> systemCarrierAssociatedAppsDisabledUntilUsed = config.getDisabledUntilUsedPreinstalledCarrierAssociatedApps();
disableCarrierAppsUntilPrivileged(callingPackage, packageManager, null, /* telephonyManager */
contentResolver, userId, systemCarrierAppsDisabledUntilUsed, systemCarrierAssociatedAppsDisabledUntilUsed);
}
use of com.android.server.SystemConfig in project android_frameworks_base by DirtyUnicorns.
the class NetworkPolicyManagerService method addDefaultRestrictBackgroundWhitelistUidsUL.
private boolean addDefaultRestrictBackgroundWhitelistUidsUL(int userId) {
final SystemConfig sysConfig = SystemConfig.getInstance();
final PackageManager pm = mContext.getPackageManager();
final ArraySet<String> allowDataUsage = sysConfig.getAllowInDataUsageSave();
boolean changed = false;
for (int i = 0; i < allowDataUsage.size(); i++) {
final String pkg = allowDataUsage.valueAt(i);
if (LOGD)
Slog.d(TAG, "checking restricted background whitelisting for package " + pkg + " and user " + userId);
final ApplicationInfo app;
try {
app = pm.getApplicationInfoAsUser(pkg, PackageManager.MATCH_SYSTEM_ONLY, userId);
} catch (PackageManager.NameNotFoundException e) {
if (LOGD)
Slog.d(TAG, "No ApplicationInfo for package " + pkg);
// Ignore it - some apps on allow-in-data-usage-save are optional.
continue;
}
if (!app.isPrivilegedApp()) {
Slog.e(TAG, "addDefaultRestrictBackgroundWhitelistUidsUL(): " + "skipping non-privileged app " + pkg);
continue;
}
final int uid = UserHandle.getUid(userId, app.uid);
mDefaultRestrictBackgroundWhitelistUids.append(uid, true);
if (LOGD)
Slog.d(TAG, "Adding uid " + uid + " (user " + userId + ") to default restricted " + "background whitelist. Revoked status: " + mRestrictBackgroundWhitelistRevokedUids.get(uid));
if (!mRestrictBackgroundWhitelistRevokedUids.get(uid)) {
if (LOGD)
Slog.d(TAG, "adding default package " + pkg + " (uid " + uid + " for user " + userId + ") to restrict background whitelist");
mRestrictBackgroundWhitelistUids.append(uid, true);
changed = true;
}
}
return changed;
}
use of com.android.server.SystemConfig in project android_frameworks_base by ResurrectionRemix.
the class NetworkPolicyManagerService method addDefaultRestrictBackgroundWhitelistUidsUL.
private boolean addDefaultRestrictBackgroundWhitelistUidsUL(int userId) {
final SystemConfig sysConfig = SystemConfig.getInstance();
final PackageManager pm = mContext.getPackageManager();
final ArraySet<String> allowDataUsage = sysConfig.getAllowInDataUsageSave();
boolean changed = false;
for (int i = 0; i < allowDataUsage.size(); i++) {
final String pkg = allowDataUsage.valueAt(i);
if (LOGD)
Slog.d(TAG, "checking restricted background whitelisting for package " + pkg + " and user " + userId);
final ApplicationInfo app;
try {
app = pm.getApplicationInfoAsUser(pkg, PackageManager.MATCH_SYSTEM_ONLY, userId);
} catch (PackageManager.NameNotFoundException e) {
if (LOGD)
Slog.d(TAG, "No ApplicationInfo for package " + pkg);
// Ignore it - some apps on allow-in-data-usage-save are optional.
continue;
}
if (!app.isPrivilegedApp()) {
Slog.e(TAG, "addDefaultRestrictBackgroundWhitelistUidsUL(): " + "skipping non-privileged app " + pkg);
continue;
}
final int uid = UserHandle.getUid(userId, app.uid);
mDefaultRestrictBackgroundWhitelistUids.append(uid, true);
if (LOGD)
Slog.d(TAG, "Adding uid " + uid + " (user " + userId + ") to default restricted " + "background whitelist. Revoked status: " + mRestrictBackgroundWhitelistRevokedUids.get(uid));
if (!mRestrictBackgroundWhitelistRevokedUids.get(uid)) {
if (LOGD)
Slog.d(TAG, "adding default package " + pkg + " (uid " + uid + " for user " + userId + ") to restrict background whitelist");
mRestrictBackgroundWhitelistUids.append(uid, true);
changed = true;
}
}
return changed;
}
Aggregations