Search in sources :

Example 11 with SystemConfig

use of com.android.server.SystemConfig in project android_frameworks_base by AOSPA.

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 12 with SystemConfig

use of com.android.server.SystemConfig in project android_frameworks_base by DirtyUnicorns.

the class PackageManagerService method primeDomainVerificationsLPw.

private void primeDomainVerificationsLPw(int userId) {
    if (DEBUG_DOMAIN_VERIFICATION) {
        Slog.d(TAG, "Priming domain verifications in user " + userId);
    }
    SystemConfig systemConfig = SystemConfig.getInstance();
    ArraySet<String> packages = systemConfig.getLinkedApps();
    ArraySet<String> domains = new ArraySet<String>();
    for (String packageName : packages) {
        PackageParser.Package pkg = mPackages.get(packageName);
        if (pkg != null) {
            if (!pkg.isSystemApp()) {
                Slog.w(TAG, "Non-system app '" + packageName + "' in sysconfig <app-link>");
                continue;
            }
            domains.clear();
            for (PackageParser.Activity a : pkg.activities) {
                for (ActivityIntentInfo filter : a.intents) {
                    if (hasValidDomains(filter)) {
                        domains.addAll(filter.getHostsList());
                    }
                }
            }
            if (domains.size() > 0) {
                if (DEBUG_DOMAIN_VERIFICATION) {
                    Slog.v(TAG, "      + " + packageName);
                }
                // 'Undefined' in the global IntentFilterVerificationInfo, i.e. the usual
                // state w.r.t. the formal app-linkage "no verification attempted" state;
                // and then 'always' in the per-user state actually used for intent resolution.
                final IntentFilterVerificationInfo ivi;
                ivi = mSettings.createIntentFilterVerificationIfNeededLPw(packageName, new ArrayList<String>(domains));
                ivi.setStatus(INTENT_FILTER_DOMAIN_VERIFICATION_STATUS_UNDEFINED);
                mSettings.updateIntentFilterVerificationStatusLPw(packageName, INTENT_FILTER_DOMAIN_VERIFICATION_STATUS_ALWAYS, userId);
            } else {
                Slog.w(TAG, "Sysconfig <app-link> package '" + packageName + "' does not handle web links");
            }
        } else {
            Slog.w(TAG, "Unknown package " + packageName + " in sysconfig <app-link>");
        }
    }
    scheduleWritePackageRestrictionsLocked(userId);
    scheduleWriteSettingsLocked();
}
Also used : SystemConfig(com.android.server.SystemConfig) ArraySet(android.util.ArraySet) PackageParser(android.content.pm.PackageParser) ArrayList(java.util.ArrayList) ActivityIntentInfo(android.content.pm.PackageParser.ActivityIntentInfo) IntentFilterVerificationInfo(android.content.pm.IntentFilterVerificationInfo)

Example 13 with SystemConfig

use of com.android.server.SystemConfig in project android_frameworks_base by DirtyUnicorns.

the class CarrierAppUtils method disableCarrierAppsUntilPrivileged.

/**
     * Handle preinstalled carrier apps which should be disabled until a matching SIM is inserted.
     *
     * Evaluates the list of applications in config_disabledUntilUsedPreinstalledCarrierApps. We
     * want to disable each such application which is present on the system image until the user
     * inserts a SIM which causes that application to gain carrier privilege (indicating a "match"),
     * without interfering with the user if they opt to enable/disable the app explicitly.
     *
     * So, for each such app, we either disable until used IFF the app is not carrier privileged AND
     * in the default state (e.g. not explicitly DISABLED/DISABLED_BY_USER/ENABLED), or we enable if
     * the app is carrier privileged and in either the default state or DISABLED_UNTIL_USED.
     *
     * In addition, there is a list of carrier-associated applications in
     * {@link SystemConfig#getDisabledUntilUsedPreinstalledCarrierAssociatedApps}. Each app in this
     * list is associated with a carrier app. When the given carrier app is enabled/disabled per the
     * above, the associated applications are enabled/disabled to match.
     *
     * When enabling a carrier app we also grant it default permissions.
     *
     * This method is idempotent and is safe to be called at any time; it should be called once at
     * system startup prior to any application running, as well as any time the set of carrier
     * privileged apps may have changed.
     */
public static synchronized void disableCarrierAppsUntilPrivileged(String callingPackage, IPackageManager packageManager, TelephonyManager telephonyManager, 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, telephonyManager, contentResolver, userId, systemCarrierAppsDisabledUntilUsed, systemCarrierAssociatedAppsDisabledUntilUsed);
}
Also used : SystemConfig(com.android.server.SystemConfig) ArrayList(java.util.ArrayList) List(java.util.List)

Example 14 with SystemConfig

use of com.android.server.SystemConfig in project android_frameworks_base by ResurrectionRemix.

the class CarrierAppUtils method disableCarrierAppsUntilPrivileged.

/**
     * Handle preinstalled carrier apps which should be disabled until a matching SIM is inserted.
     *
     * Evaluates the list of applications in config_disabledUntilUsedPreinstalledCarrierApps. We
     * want to disable each such application which is present on the system image until the user
     * inserts a SIM which causes that application to gain carrier privilege (indicating a "match"),
     * without interfering with the user if they opt to enable/disable the app explicitly.
     *
     * So, for each such app, we either disable until used IFF the app is not carrier privileged AND
     * in the default state (e.g. not explicitly DISABLED/DISABLED_BY_USER/ENABLED), or we enable if
     * the app is carrier privileged and in either the default state or DISABLED_UNTIL_USED.
     *
     * In addition, there is a list of carrier-associated applications in
     * {@link SystemConfig#getDisabledUntilUsedPreinstalledCarrierAssociatedApps}. Each app in this
     * list is associated with a carrier app. When the given carrier app is enabled/disabled per the
     * above, the associated applications are enabled/disabled to match.
     *
     * When enabling a carrier app we also grant it default permissions.
     *
     * This method is idempotent and is safe to be called at any time; it should be called once at
     * system startup prior to any application running, as well as any time the set of carrier
     * privileged apps may have changed.
     */
public static synchronized void disableCarrierAppsUntilPrivileged(String callingPackage, IPackageManager packageManager, TelephonyManager telephonyManager, 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, telephonyManager, contentResolver, userId, systemCarrierAppsDisabledUntilUsed, systemCarrierAssociatedAppsDisabledUntilUsed);
}
Also used : SystemConfig(com.android.server.SystemConfig) ArrayList(java.util.ArrayList) List(java.util.List)

Example 15 with SystemConfig

use of com.android.server.SystemConfig in project android_frameworks_base by crdroidandroid.

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