Search in sources :

Example 56 with SparseArray

use of android.util.SparseArray in project android_frameworks_base by ResurrectionRemix.

the class BatteryStatsHelper method refreshStats.

/**
     * Refreshes the power usage list.
     */
public void refreshStats(int statsType, List<UserHandle> asUsers) {
    final int n = asUsers.size();
    SparseArray<UserHandle> users = new SparseArray<>(n);
    for (int i = 0; i < n; ++i) {
        UserHandle userHandle = asUsers.get(i);
        users.put(userHandle.getIdentifier(), userHandle);
    }
    refreshStats(statsType, users);
}
Also used : SparseArray(android.util.SparseArray) UserHandle(android.os.UserHandle)

Example 57 with SparseArray

use of android.util.SparseArray in project android_frameworks_base by ResurrectionRemix.

the class ModelBackedDocumentsAdapter method hide.

@Override
public SparseArray<String> hide(String... ids) {
    if (DEBUG)
        Log.d(TAG, "Hiding ids: " + ids);
    Set<String> toHide = Sets.newHashSet(ids);
    // Proceed backwards through the list of items, because each removal causes the
    // positions of all subsequent items to change.
    SparseArray<String> hiddenItems = new SparseArray<>();
    for (int i = mModelIds.size() - 1; i >= 0; --i) {
        String id = mModelIds.get(i);
        if (toHide.contains(id)) {
            mHiddenIds.add(id);
            hiddenItems.put(i, mModelIds.remove(i));
            notifyItemRemoved(i);
        }
    }
    return hiddenItems;
}
Also used : SparseArray(android.util.SparseArray) DocumentInfo.getCursorString(com.android.documentsui.model.DocumentInfo.getCursorString)

Example 58 with SparseArray

use of android.util.SparseArray in project android_frameworks_base by ResurrectionRemix.

the class TaskStack method updateFilteredTasks.

/** Updates the list of filtered tasks whenever the base task list changes */
private void updateFilteredTasks() {
    mFilteredTasks.clear();
    if (mFilter != null) {
        // Create a sparse array from task id to Task
        SparseArray<Task> taskIdMap = new SparseArray<>();
        int taskCount = mTasks.size();
        for (int i = 0; i < taskCount; i++) {
            Task t = mTasks.get(i);
            taskIdMap.put(t.key.id, t);
        }
        for (int i = 0; i < taskCount; i++) {
            Task t = mTasks.get(i);
            if (mFilter.acceptTask(taskIdMap, t, i)) {
                mFilteredTasks.add(t);
            }
        }
    } else {
        mFilteredTasks.addAll(mTasks);
    }
    updateFilteredTaskIndices();
}
Also used : SparseArray(android.util.SparseArray) Paint(android.graphics.Paint) Point(android.graphics.Point)

Example 59 with SparseArray

use of android.util.SparseArray in project android_frameworks_base by ResurrectionRemix.

the class SecurityControllerImpl method updateState.

private void updateState() {
    // Find all users with an active VPN
    SparseArray<VpnConfig> vpns = new SparseArray<>();
    try {
        for (UserInfo user : mUserManager.getUsers()) {
            VpnConfig cfg = mConnectivityManagerService.getVpnConfig(user.id);
            if (cfg == null) {
                continue;
            } else if (cfg.legacy) {
                // Legacy VPNs should do nothing if the network is disconnected. Third-party
                // VPN warnings need to continue as traffic can still go to the app.
                LegacyVpnInfo legacyVpn = mConnectivityManagerService.getLegacyVpnInfo(user.id);
                if (legacyVpn == null || legacyVpn.state != LegacyVpnInfo.STATE_CONNECTED) {
                    continue;
                }
            }
            vpns.put(user.id, cfg);
        }
    } catch (RemoteException rme) {
        // Roll back to previous state
        Log.e(TAG, "Unable to list active VPNs", rme);
        return;
    }
    mCurrentVpns = vpns;
}
Also used : SparseArray(android.util.SparseArray) VpnConfig(com.android.internal.net.VpnConfig) LegacyVpnInfo(com.android.internal.net.LegacyVpnInfo) UserInfo(android.content.pm.UserInfo) RemoteException(android.os.RemoteException)

Example 60 with SparseArray

use of android.util.SparseArray in project android_frameworks_base by ResurrectionRemix.

the class TaskPersister method writeTaskIdsFiles.

private void writeTaskIdsFiles() {
    SparseArray<SparseBooleanArray> changedTaskIdsPerUser = new SparseArray<>();
    synchronized (mService) {
        for (int userId : mRecentTasks.usersWithRecentsLoadedLocked()) {
            SparseBooleanArray taskIdsToSave = mRecentTasks.mPersistedTaskIds.get(userId);
            SparseBooleanArray persistedIdsInFile = mTaskIdsInFile.get(userId);
            if (persistedIdsInFile != null && persistedIdsInFile.equals(taskIdsToSave)) {
                continue;
            } else {
                SparseBooleanArray taskIdsToSaveCopy = taskIdsToSave.clone();
                mTaskIdsInFile.put(userId, taskIdsToSaveCopy);
                changedTaskIdsPerUser.put(userId, taskIdsToSaveCopy);
            }
        }
    }
    for (int i = 0; i < changedTaskIdsPerUser.size(); i++) {
        writePersistedTaskIdsForUser(changedTaskIdsPerUser.valueAt(i), changedTaskIdsPerUser.keyAt(i));
    }
}
Also used : SparseArray(android.util.SparseArray) SparseBooleanArray(android.util.SparseBooleanArray)

Aggregations

SparseArray (android.util.SparseArray)250 ArrayList (java.util.ArrayList)74 ProcessState (com.android.internal.app.procstats.ProcessState)41 Parcelable (android.os.Parcelable)37 View (android.view.View)35 ServiceState (com.android.internal.app.procstats.ServiceState)31 RemoteException (android.os.RemoteException)24 Point (android.graphics.Point)19 ArraySet (android.util.ArraySet)17 HashMap (java.util.HashMap)17 ComponentName (android.content.ComponentName)15 ProcessStats (com.android.internal.app.procstats.ProcessStats)15 UserHandle (android.os.UserHandle)14 ArrayMap (android.util.ArrayMap)14 UserInfo (android.content.pm.UserInfo)13 Paint (android.graphics.Paint)13 Bitmap (android.graphics.Bitmap)12 IOException (java.io.IOException)12 ApplicationInfo (android.content.pm.ApplicationInfo)11 SparseIntArray (android.util.SparseIntArray)11