Search in sources :

Example 11 with SparseBooleanArray

use of android.util.SparseBooleanArray in project platform_frameworks_base by android.

the class NetworkManagementService method prepareNativeDaemon.

/**
     * Prepare native daemon once connected, enabling modules and pushing any
     * existing in-memory rules.
     */
private void prepareNativeDaemon() {
    mBandwidthControlEnabled = false;
    // only enable bandwidth control when support exists
    final boolean hasKernelSupport = new File("/proc/net/xt_qtaguid/ctrl").exists();
    if (hasKernelSupport) {
        Slog.d(TAG, "enabling bandwidth control");
        try {
            mConnector.execute("bandwidth", "enable");
            mBandwidthControlEnabled = true;
        } catch (NativeDaemonConnectorException e) {
            Log.wtf(TAG, "problem enabling bandwidth controls", e);
        }
    } else {
        Slog.i(TAG, "not enabling bandwidth control");
    }
    SystemProperties.set(PROP_QTAGUID_ENABLED, mBandwidthControlEnabled ? "1" : "0");
    if (mBandwidthControlEnabled) {
        try {
            getBatteryStats().noteNetworkStatsEnabled();
        } catch (RemoteException e) {
        }
    }
    try {
        mConnector.execute("strict", "enable");
        mStrictEnabled = true;
    } catch (NativeDaemonConnectorException e) {
        Log.wtf(TAG, "Failed strict enable", e);
    }
    // push any existing quota or UID rules
    synchronized (mQuotaLock) {
        setDataSaverModeEnabled(mDataSaverMode);
        int size = mActiveQuotas.size();
        if (size > 0) {
            if (DBG)
                Slog.d(TAG, "Pushing " + size + " active quota rules");
            final HashMap<String, Long> activeQuotas = mActiveQuotas;
            mActiveQuotas = Maps.newHashMap();
            for (Map.Entry<String, Long> entry : activeQuotas.entrySet()) {
                setInterfaceQuota(entry.getKey(), entry.getValue());
            }
        }
        size = mActiveAlerts.size();
        if (size > 0) {
            if (DBG)
                Slog.d(TAG, "Pushing " + size + " active alert rules");
            final HashMap<String, Long> activeAlerts = mActiveAlerts;
            mActiveAlerts = Maps.newHashMap();
            for (Map.Entry<String, Long> entry : activeAlerts.entrySet()) {
                setInterfaceAlert(entry.getKey(), entry.getValue());
            }
        }
        size = mUidRejectOnMetered.size();
        if (size > 0) {
            if (DBG)
                Slog.d(TAG, "Pushing " + size + " UIDs to metered whitelist rules");
            final SparseBooleanArray uidRejectOnQuota = mUidRejectOnMetered;
            mUidRejectOnMetered = new SparseBooleanArray();
            for (int i = 0; i < uidRejectOnQuota.size(); i++) {
                setUidMeteredNetworkBlacklist(uidRejectOnQuota.keyAt(i), uidRejectOnQuota.valueAt(i));
            }
        }
        size = mUidAllowOnMetered.size();
        if (size > 0) {
            if (DBG)
                Slog.d(TAG, "Pushing " + size + " UIDs to metered blacklist rules");
            final SparseBooleanArray uidAcceptOnQuota = mUidAllowOnMetered;
            mUidAllowOnMetered = new SparseBooleanArray();
            for (int i = 0; i < uidAcceptOnQuota.size(); i++) {
                setUidMeteredNetworkWhitelist(uidAcceptOnQuota.keyAt(i), uidAcceptOnQuota.valueAt(i));
            }
        }
        size = mUidCleartextPolicy.size();
        if (size > 0) {
            if (DBG)
                Slog.d(TAG, "Pushing " + size + " active UID cleartext policies");
            final SparseIntArray local = mUidCleartextPolicy;
            mUidCleartextPolicy = new SparseIntArray();
            for (int i = 0; i < local.size(); i++) {
                setUidCleartextNetworkPolicy(local.keyAt(i), local.valueAt(i));
            }
        }
        setFirewallEnabled(mFirewallEnabled || LockdownVpnTracker.isEnabled());
        syncFirewallChainLocked(FIREWALL_CHAIN_NONE, mUidFirewallRules, "");
        syncFirewallChainLocked(FIREWALL_CHAIN_STANDBY, mUidFirewallStandbyRules, "standby ");
        syncFirewallChainLocked(FIREWALL_CHAIN_DOZABLE, mUidFirewallDozableRules, "dozable ");
        syncFirewallChainLocked(FIREWALL_CHAIN_POWERSAVE, mUidFirewallPowerSaveRules, "powersave ");
        if (mFirewallChainStates.get(FIREWALL_CHAIN_STANDBY)) {
            setFirewallChainEnabled(FIREWALL_CHAIN_STANDBY, true);
        }
        if (mFirewallChainStates.get(FIREWALL_CHAIN_DOZABLE)) {
            setFirewallChainEnabled(FIREWALL_CHAIN_DOZABLE, true);
        }
        if (mFirewallChainStates.get(FIREWALL_CHAIN_POWERSAVE)) {
            setFirewallChainEnabled(FIREWALL_CHAIN_POWERSAVE, true);
        }
    }
}
Also used : SparseIntArray(android.util.SparseIntArray) SparseBooleanArray(android.util.SparseBooleanArray) RemoteException(android.os.RemoteException) File(java.io.File) Map(java.util.Map) HashMap(java.util.HashMap)

Example 12 with SparseBooleanArray

use of android.util.SparseBooleanArray in project platform_frameworks_base by android.

the class AccountManagerService method getUidsOfInstalledOrUpdatedPackagesAsUser.

private SparseBooleanArray getUidsOfInstalledOrUpdatedPackagesAsUser(int userId) {
    // Get the UIDs of all apps that might have data on the device. We want
    // to preserve user data if the app might otherwise be storing data.
    List<PackageInfo> pkgsWithData = mPackageManager.getInstalledPackagesAsUser(PackageManager.MATCH_UNINSTALLED_PACKAGES, userId);
    SparseBooleanArray knownUids = new SparseBooleanArray(pkgsWithData.size());
    for (PackageInfo pkgInfo : pkgsWithData) {
        if (pkgInfo.applicationInfo != null && (pkgInfo.applicationInfo.flags & ApplicationInfo.FLAG_INSTALLED) != 0) {
            knownUids.put(pkgInfo.applicationInfo.uid, true);
        }
    }
    return knownUids;
}
Also used : PackageInfo(android.content.pm.PackageInfo) SparseBooleanArray(android.util.SparseBooleanArray)

Example 13 with SparseBooleanArray

use of android.util.SparseBooleanArray in project platform_frameworks_base by android.

the class TaskPersisterTest method testTaskIdsPersistence.

public void testTaskIdsPersistence() {
    SparseBooleanArray taskIdsOnFile = mTaskPersister.loadPersistedTaskIdsForUser(testUserId);
    for (int i = 0; i < 100; i++) {
        taskIdsOnFile.put(getRandomTaskIdForUser(testUserId), true);
    }
    mTaskPersister.writePersistedTaskIdsForUser(taskIdsOnFile, testUserId);
    SparseBooleanArray newTaskIdsOnFile = mTaskPersister.loadPersistedTaskIdsForUser(testUserId);
    assertTrue("TaskIds written differ from TaskIds read back from file", taskIdsOnFile.equals(newTaskIdsOnFile));
}
Also used : SparseBooleanArray(android.util.SparseBooleanArray)

Example 14 with SparseBooleanArray

use of android.util.SparseBooleanArray in project platform_frameworks_base by android.

the class UsbSettingsManager method hasPermission.

public boolean hasPermission(UsbDevice device) {
    synchronized (mLock) {
        int uid = Binder.getCallingUid();
        if (uid == Process.SYSTEM_UID || mDisablePermissionDialogs) {
            return true;
        }
        SparseBooleanArray uidList = mDevicePermissionMap.get(device.getDeviceName());
        if (uidList == null) {
            return false;
        }
        return uidList.get(uid);
    }
}
Also used : SparseBooleanArray(android.util.SparseBooleanArray)

Example 15 with SparseBooleanArray

use of android.util.SparseBooleanArray in project platform_frameworks_base by android.

the class UsbSettingsManager method dump.

public void dump(IndentingPrintWriter pw) {
    synchronized (mLock) {
        pw.println("Device permissions:");
        for (String deviceName : mDevicePermissionMap.keySet()) {
            pw.print("  " + deviceName + ": ");
            SparseBooleanArray uidList = mDevicePermissionMap.get(deviceName);
            int count = uidList.size();
            for (int i = 0; i < count; i++) {
                pw.print(Integer.toString(uidList.keyAt(i)) + " ");
            }
            pw.println();
        }
        pw.println("Accessory permissions:");
        for (UsbAccessory accessory : mAccessoryPermissionMap.keySet()) {
            pw.print("  " + accessory + ": ");
            SparseBooleanArray uidList = mAccessoryPermissionMap.get(accessory);
            int count = uidList.size();
            for (int i = 0; i < count; i++) {
                pw.print(Integer.toString(uidList.keyAt(i)) + " ");
            }
            pw.println();
        }
        pw.println("Device preferences:");
        for (DeviceFilter filter : mDevicePreferenceMap.keySet()) {
            pw.println("  " + filter + ": " + mDevicePreferenceMap.get(filter));
        }
        pw.println("Accessory preferences:");
        for (AccessoryFilter filter : mAccessoryPreferenceMap.keySet()) {
            pw.println("  " + filter + ": " + mAccessoryPreferenceMap.get(filter));
        }
    }
}
Also used : SparseBooleanArray(android.util.SparseBooleanArray) UsbAccessory(android.hardware.usb.UsbAccessory)

Aggregations

SparseBooleanArray (android.util.SparseBooleanArray)235 Selection (com.android.documentsui.dirlist.MultiSelectManager.Selection)30 ArrayList (java.util.ArrayList)25 View (android.view.View)20 Point (android.graphics.Point)18 ViewGroup (android.view.ViewGroup)16 Paint (android.graphics.Paint)13 HashMap (java.util.HashMap)12 Map (java.util.Map)11 SparseArray (android.util.SparseArray)7 File (java.io.File)7 Pattern (java.util.regex.Pattern)7 Cursor (android.database.Cursor)6 SparseIntArray (android.util.SparseIntArray)6 ActionMenuChildView (com.actionbarsherlock.internal.view.menu.ActionMenuView.ActionMenuChildView)6 IndentingPrintWriter (com.android.internal.util.IndentingPrintWriter)6 Account (android.accounts.Account)5 NonNull (android.annotation.NonNull)5 ContentValues (android.content.ContentValues)5 SQLiteDatabase (android.database.sqlite.SQLiteDatabase)5