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));
}
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);
}
}
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));
}
}
}
use of android.util.SparseBooleanArray in project platform_frameworks_base by android.
the class RecentTasks method syncPersistentTaskIdsLocked.
private void syncPersistentTaskIdsLocked() {
for (int i = mPersistedTaskIds.size() - 1; i >= 0; i--) {
int userId = mPersistedTaskIds.keyAt(i);
if (mUsersWithRecentsLoaded.get(userId)) {
// Recents are loaded only after task ids are loaded. Therefore, the set of taskids
// referenced here should not be null.
mPersistedTaskIds.valueAt(i).clear();
}
}
for (int i = size() - 1; i >= 0; i--) {
TaskRecord task = get(i);
if (task.isPersistable && (task.stack == null || !task.stack.isHomeStack())) {
// TODO Investigate why it can happen. For now initialize with an empty set
if (mPersistedTaskIds.get(task.userId) == null) {
Slog.wtf(TAG, "No task ids found for userId " + task.userId + ". task=" + task + " mPersistedTaskIds=" + mPersistedTaskIds);
mPersistedTaskIds.put(task.userId, new SparseBooleanArray());
}
mPersistedTaskIds.get(task.userId).put(task.taskId, true);
}
}
}
use of android.util.SparseBooleanArray in project platform_frameworks_base by android.
the class TaskPersister method loadPersistedTaskIdsForUser.
@NonNull
SparseBooleanArray loadPersistedTaskIdsForUser(int userId) {
if (mTaskIdsInFile.get(userId) != null) {
return mTaskIdsInFile.get(userId).clone();
}
final SparseBooleanArray persistedTaskIds = new SparseBooleanArray();
synchronized (mIoLock) {
BufferedReader reader = null;
String line;
try {
reader = new BufferedReader(new FileReader(getUserPersistedTaskIdsFile(userId)));
while ((line = reader.readLine()) != null) {
for (String taskIdString : line.split("\\s+")) {
int id = Integer.parseInt(taskIdString);
persistedTaskIds.put(id, true);
}
}
} catch (FileNotFoundException e) {
// File doesn't exist. Ignore.
} catch (Exception e) {
Slog.e(TAG, "Error while reading taskIds file for user " + userId, e);
} finally {
IoUtils.closeQuietly(reader);
}
}
mTaskIdsInFile.put(userId, persistedTaskIds);
return persistedTaskIds.clone();
}
Aggregations