Search in sources :

Example 1 with SystemConfig

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;
}
Also used : SystemConfig(com.android.server.SystemConfig) PackageManager(android.content.pm.PackageManager) IPackageManager(android.content.pm.IPackageManager) NameNotFoundException(android.content.pm.PackageManager.NameNotFoundException) ApplicationInfo(android.content.pm.ApplicationInfo) NetworkPolicyManager.uidRulesToString(android.net.NetworkPolicyManager.uidRulesToString)

Example 2 with SystemConfig

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);
}
Also used : SystemConfig(com.android.server.SystemConfig) ArrayList(java.util.ArrayList) List(java.util.List)

Example 3 with SystemConfig

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);
}
Also used : SystemConfig(com.android.server.SystemConfig) ArrayList(java.util.ArrayList) List(java.util.List)

Example 4 with SystemConfig

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;
}
Also used : SystemConfig(com.android.server.SystemConfig) PackageManager(android.content.pm.PackageManager) IPackageManager(android.content.pm.IPackageManager) NameNotFoundException(android.content.pm.PackageManager.NameNotFoundException) ApplicationInfo(android.content.pm.ApplicationInfo) NetworkPolicyManager.uidRulesToString(android.net.NetworkPolicyManager.uidRulesToString)

Example 5 with SystemConfig

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;
}
Also used : SystemConfig(com.android.server.SystemConfig) PackageManager(android.content.pm.PackageManager) IPackageManager(android.content.pm.IPackageManager) NameNotFoundException(android.content.pm.PackageManager.NameNotFoundException) ApplicationInfo(android.content.pm.ApplicationInfo) NetworkPolicyManager.uidRulesToString(android.net.NetworkPolicyManager.uidRulesToString)

Aggregations

SystemConfig (com.android.server.SystemConfig)15 ArrayList (java.util.ArrayList)10 List (java.util.List)8 ApplicationInfo (android.content.pm.ApplicationInfo)5 IPackageManager (android.content.pm.IPackageManager)5 PackageManager (android.content.pm.PackageManager)5 NameNotFoundException (android.content.pm.PackageManager.NameNotFoundException)5 NetworkPolicyManager.uidRulesToString (android.net.NetworkPolicyManager.uidRulesToString)5 IntentFilterVerificationInfo (android.content.pm.IntentFilterVerificationInfo)2 PackageParser (android.content.pm.PackageParser)2 ActivityIntentInfo (android.content.pm.PackageParser.ActivityIntentInfo)2 ArraySet (android.util.ArraySet)2