Search in sources :

Example 91 with SparseBooleanArray

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

the class NetworkPolicyManagerService method dump.

@Override
protected void dump(FileDescriptor fd, PrintWriter writer, String[] args) {
    mContext.enforceCallingOrSelfPermission(DUMP, TAG);
    final IndentingPrintWriter fout = new IndentingPrintWriter(writer, "  ");
    final ArraySet<String> argSet = new ArraySet<String>(args.length);
    for (String arg : args) {
        argSet.add(arg);
    }
    synchronized (mUidRulesFirstLock) {
        synchronized (mNetworkPoliciesSecondLock) {
            if (argSet.contains("--unsnooze")) {
                for (int i = mNetworkPolicy.size() - 1; i >= 0; i--) {
                    mNetworkPolicy.valueAt(i).clearSnooze();
                }
                normalizePoliciesNL();
                updateNetworkEnabledNL();
                updateNetworkRulesNL();
                updateNotificationsNL();
                writePolicyAL();
                fout.println("Cleared snooze timestamps");
                return;
            }
            fout.print("System ready: ");
            fout.println(mSystemReady);
            fout.print("Restrict background: ");
            fout.println(mRestrictBackground);
            fout.print("Restrict power: ");
            fout.println(mRestrictPower);
            fout.print("Device idle: ");
            fout.println(mDeviceIdleMode);
            fout.println("Network policies:");
            fout.increaseIndent();
            for (int i = 0; i < mNetworkPolicy.size(); i++) {
                fout.println(mNetworkPolicy.valueAt(i).toString());
            }
            fout.decreaseIndent();
            fout.print("Metered ifaces: ");
            fout.println(String.valueOf(mMeteredIfaces));
            fout.println("Policy for UIDs:");
            fout.increaseIndent();
            int size = mUidPolicy.size();
            for (int i = 0; i < size; i++) {
                final int uid = mUidPolicy.keyAt(i);
                final int policy = mUidPolicy.valueAt(i);
                fout.print("UID=");
                fout.print(uid);
                fout.print(" policy=");
                fout.print(DebugUtils.flagsToString(NetworkPolicyManager.class, "POLICY_", policy));
                fout.println();
            }
            fout.decreaseIndent();
            size = mPowerSaveWhitelistExceptIdleAppIds.size();
            if (size > 0) {
                fout.println("Power save whitelist (except idle) app ids:");
                fout.increaseIndent();
                for (int i = 0; i < size; i++) {
                    fout.print("UID=");
                    fout.print(mPowerSaveWhitelistExceptIdleAppIds.keyAt(i));
                    fout.print(": ");
                    fout.print(mPowerSaveWhitelistExceptIdleAppIds.valueAt(i));
                    fout.println();
                }
                fout.decreaseIndent();
            }
            size = mPowerSaveWhitelistAppIds.size();
            if (size > 0) {
                fout.println("Power save whitelist app ids:");
                fout.increaseIndent();
                for (int i = 0; i < size; i++) {
                    fout.print("UID=");
                    fout.print(mPowerSaveWhitelistAppIds.keyAt(i));
                    fout.print(": ");
                    fout.print(mPowerSaveWhitelistAppIds.valueAt(i));
                    fout.println();
                }
                fout.decreaseIndent();
            }
            size = mRestrictBackgroundWhitelistUids.size();
            if (size > 0) {
                fout.println("Restrict background whitelist uids:");
                fout.increaseIndent();
                for (int i = 0; i < size; i++) {
                    fout.print("UID=");
                    fout.print(mRestrictBackgroundWhitelistUids.keyAt(i));
                    fout.println();
                }
                fout.decreaseIndent();
            }
            size = mDefaultRestrictBackgroundWhitelistUids.size();
            if (size > 0) {
                fout.println("Default restrict background whitelist uids:");
                fout.increaseIndent();
                for (int i = 0; i < size; i++) {
                    fout.print("UID=");
                    fout.print(mDefaultRestrictBackgroundWhitelistUids.keyAt(i));
                    fout.println();
                }
                fout.decreaseIndent();
            }
            size = mRestrictBackgroundWhitelistRevokedUids.size();
            if (size > 0) {
                fout.println("Default restrict background whitelist uids revoked by users:");
                fout.increaseIndent();
                for (int i = 0; i < size; i++) {
                    fout.print("UID=");
                    fout.print(mRestrictBackgroundWhitelistRevokedUids.keyAt(i));
                    fout.println();
                }
                fout.decreaseIndent();
            }
            final SparseBooleanArray knownUids = new SparseBooleanArray();
            collectKeys(mUidState, knownUids);
            collectKeys(mUidRules, knownUids);
            fout.println("Status for all known UIDs:");
            fout.increaseIndent();
            size = knownUids.size();
            for (int i = 0; i < size; i++) {
                final int uid = knownUids.keyAt(i);
                fout.print("UID=");
                fout.print(uid);
                final int state = mUidState.get(uid, ActivityManager.PROCESS_STATE_CACHED_EMPTY);
                fout.print(" state=");
                fout.print(state);
                if (state <= ActivityManager.PROCESS_STATE_TOP) {
                    fout.print(" (fg)");
                } else {
                    fout.print(state <= ActivityManager.PROCESS_STATE_FOREGROUND_SERVICE ? " (fg svc)" : " (bg)");
                }
                final int uidRules = mUidRules.get(uid, RULE_NONE);
                fout.print(" rules=");
                fout.print(uidRulesToString(uidRules));
                fout.println();
            }
            fout.decreaseIndent();
            fout.println("Status for just UIDs with rules:");
            fout.increaseIndent();
            size = mUidRules.size();
            for (int i = 0; i < size; i++) {
                final int uid = mUidRules.keyAt(i);
                fout.print("UID=");
                fout.print(uid);
                final int uidRules = mUidRules.get(uid, RULE_NONE);
                fout.print(" rules=");
                fout.print(uidRulesToString(uidRules));
                fout.println();
            }
            fout.decreaseIndent();
        }
    }
}
Also used : ArraySet(android.util.ArraySet) NetworkPolicyManager(android.net.NetworkPolicyManager) INetworkPolicyManager(android.net.INetworkPolicyManager) SparseBooleanArray(android.util.SparseBooleanArray) NetworkPolicyManager.uidRulesToString(android.net.NetworkPolicyManager.uidRulesToString) IndentingPrintWriter(com.android.internal.util.IndentingPrintWriter)

Example 92 with SparseBooleanArray

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

the class UsbSettingsManager method grantAccessoryPermission.

public void grantAccessoryPermission(UsbAccessory accessory, int uid) {
    synchronized (mLock) {
        SparseBooleanArray uidList = mAccessoryPermissionMap.get(accessory);
        if (uidList == null) {
            uidList = new SparseBooleanArray(1);
            mAccessoryPermissionMap.put(accessory, uidList);
        }
        uidList.put(uid, true);
    }
}
Also used : SparseBooleanArray(android.util.SparseBooleanArray)

Example 93 with SparseBooleanArray

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

the class UsbSettingsManager method hasPermission.

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

Example 94 with SparseBooleanArray

use of android.util.SparseBooleanArray in project cwac-masterdetail by commonsguy.

the class MasterDetailController method removeChecked.

@SuppressWarnings("unchecked")
void removeChecked() {
    SparseBooleanArray checked = getListView().getCheckedItemPositions();
    ArrayList<Integer> positions = new ArrayList<Integer>();
    for (int i = 0; i < checked.size(); i++) {
        if (checked.valueAt(i)) {
            positions.add(checked.keyAt(i));
        }
    }
    Collections.sort(positions, Collections.reverseOrder());
    for (int position : positions) {
        removeModel(getModelCollection().get(position));
        getModelCollection().remove(position);
        ((ModelPagerAdapter) getPagerAdapter()).remove(position);
    }
    getListView().clearChoices();
    ((ModelPagerAdapter) getPagerAdapter()).notifyDataSetChanged();
}
Also used : SparseBooleanArray(android.util.SparseBooleanArray) ArrayList(java.util.ArrayList)

Example 95 with SparseBooleanArray

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

the class NetworkStats method getUniqueUids.

/**
     * Return list of unique UIDs known by this data structure.
     */
public int[] getUniqueUids() {
    final SparseBooleanArray uids = new SparseBooleanArray();
    for (int uid : this.uid) {
        uids.put(uid, true);
    }
    final int size = uids.size();
    final int[] result = new int[size];
    for (int i = 0; i < size; i++) {
        result[i] = uids.keyAt(i);
    }
    return result;
}
Also used : SparseBooleanArray(android.util.SparseBooleanArray)

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