Search in sources :

Example 46 with SparseBooleanArray

use of android.util.SparseBooleanArray in project android_frameworks_base by DirtyUnicorns.

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 47 with SparseBooleanArray

use of android.util.SparseBooleanArray in project android_frameworks_base by DirtyUnicorns.

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 48 with SparseBooleanArray

use of android.util.SparseBooleanArray in project android_frameworks_base by ParanoidAndroid.

the class TableLayout method trackCollapsedColumns.

/**
     * <p>Applies the columns collapse status to a new row added to this
     * table. This method is invoked by PassThroughHierarchyChangeListener
     * upon child insertion.</p>
     *
     * <p>This method only applies to {@link android.widget.TableRow}
     * instances.</p>
     *
     * @param child the newly added child
     */
private void trackCollapsedColumns(View child) {
    if (child instanceof TableRow) {
        final TableRow row = (TableRow) child;
        final SparseBooleanArray collapsedColumns = mCollapsedColumns;
        final int count = collapsedColumns.size();
        for (int i = 0; i < count; i++) {
            int columnIndex = collapsedColumns.keyAt(i);
            boolean isCollapsed = collapsedColumns.valueAt(i);
            // visibility of the row's children
            if (isCollapsed) {
                row.setColumnCollapsed(columnIndex, isCollapsed);
            }
        }
    }
}
Also used : SparseBooleanArray(android.util.SparseBooleanArray)

Example 49 with SparseBooleanArray

use of android.util.SparseBooleanArray in project android_frameworks_base by ParanoidAndroid.

the class AbsListView method setChoiceMode.

/**
     * Defines the choice behavior for the List. By default, Lists do not have any choice behavior
     * ({@link #CHOICE_MODE_NONE}). By setting the choiceMode to {@link #CHOICE_MODE_SINGLE}, the
     * List allows up to one item to  be in a chosen state. By setting the choiceMode to
     * {@link #CHOICE_MODE_MULTIPLE}, the list allows any number of items to be chosen.
     *
     * @param choiceMode One of {@link #CHOICE_MODE_NONE}, {@link #CHOICE_MODE_SINGLE}, or
     * {@link #CHOICE_MODE_MULTIPLE}
     */
public void setChoiceMode(int choiceMode) {
    mChoiceMode = choiceMode;
    if (mChoiceActionMode != null) {
        mChoiceActionMode.finish();
        mChoiceActionMode = null;
    }
    if (mChoiceMode != CHOICE_MODE_NONE) {
        if (mCheckStates == null) {
            mCheckStates = new SparseBooleanArray();
        }
        if (mCheckedIdStates == null && mAdapter != null && mAdapter.hasStableIds()) {
            mCheckedIdStates = new LongSparseArray<Integer>();
        }
        // Modal multi-choice mode only has choices when the mode is active. Clear them.
        if (mChoiceMode == CHOICE_MODE_MULTIPLE_MODAL) {
            clearChoices();
            setLongClickable(true);
        }
    }
}
Also used : SparseBooleanArray(android.util.SparseBooleanArray)

Example 50 with SparseBooleanArray

use of android.util.SparseBooleanArray in project android_frameworks_base by ParanoidAndroid.

the class ListView method getCheckItemIds.

/**
     * Returns the set of checked items ids. The result is only valid if the
     * choice mode has not been set to {@link #CHOICE_MODE_NONE}.
     * 
     * @return A new array which contains the id of each checked item in the
     *         list.
     *         
     * @deprecated Use {@link #getCheckedItemIds()} instead.
     */
@Deprecated
public long[] getCheckItemIds() {
    // Use new behavior that correctly handles stable ID mapping.
    if (mAdapter != null && mAdapter.hasStableIds()) {
        return getCheckedItemIds();
    }
    // Fall back to it to support legacy apps.
    if (mChoiceMode != CHOICE_MODE_NONE && mCheckStates != null && mAdapter != null) {
        final SparseBooleanArray states = mCheckStates;
        final int count = states.size();
        final long[] ids = new long[count];
        final ListAdapter adapter = mAdapter;
        int checkedCount = 0;
        for (int i = 0; i < count; i++) {
            if (states.valueAt(i)) {
                ids[checkedCount++] = adapter.getItemId(states.keyAt(i));
            }
        }
        // resulting in checkedCount being smaller than count.
        if (checkedCount == count) {
            return ids;
        } else {
            final long[] result = new long[checkedCount];
            System.arraycopy(ids, 0, result, 0, checkedCount);
            return result;
        }
    }
    return new long[0];
}
Also used : SparseBooleanArray(android.util.SparseBooleanArray) Paint(android.graphics.Paint)

Aggregations

SparseBooleanArray (android.util.SparseBooleanArray)283 ArrayList (java.util.ArrayList)43 View (android.view.View)32 Selection (com.android.documentsui.dirlist.MultiSelectManager.Selection)30 Point (android.graphics.Point)28 ViewGroup (android.view.ViewGroup)20 ListView (android.widget.ListView)15 HashMap (java.util.HashMap)15 Paint (android.graphics.Paint)13 Intent (android.content.Intent)11 Map (java.util.Map)11 File (java.io.File)10 SparseArray (android.util.SparseArray)8 SuppressLint (android.annotation.SuppressLint)7 SparseIntArray (android.util.SparseIntArray)7 AdapterView (android.widget.AdapterView)7 Cursor (android.database.Cursor)6 ActionMenuChildView (com.actionbarsherlock.internal.view.menu.ActionMenuView.ActionMenuChildView)6 IndentingPrintWriter (com.android.internal.util.IndentingPrintWriter)6 List (java.util.List)6