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);
}
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;
}
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();
}
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;
}
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));
}
}
Aggregations