use of android.util.SparseIntArray in project android_frameworks_base by ResurrectionRemix.
the class StreamConfigurationMap method getInternalFormatSizes.
private Size[] getInternalFormatSizes(int format, int dataspace, boolean output, boolean highRes) {
// All depth formats are non-high-res.
if (dataspace == HAL_DATASPACE_DEPTH && highRes) {
return new Size[0];
}
SparseIntArray formatsMap = !output ? mInputFormats : dataspace == HAL_DATASPACE_DEPTH ? mDepthOutputFormats : highRes ? mHighResOutputFormats : mOutputFormats;
int sizesCount = formatsMap.get(format);
if (((!output || dataspace == HAL_DATASPACE_DEPTH) && sizesCount == 0) || (output && dataspace != HAL_DATASPACE_DEPTH && mAllOutputFormats.get(format) == 0)) {
// Only throw if this is really not supported at all
throw new IllegalArgumentException("format not available");
}
Size[] sizes = new Size[sizesCount];
int sizeIndex = 0;
StreamConfiguration[] configurations = (dataspace == HAL_DATASPACE_DEPTH) ? mDepthConfigurations : mConfigurations;
StreamConfigurationDuration[] minFrameDurations = (dataspace == HAL_DATASPACE_DEPTH) ? mDepthMinFrameDurations : mMinFrameDurations;
for (StreamConfiguration config : configurations) {
int fmt = config.getFormat();
if (fmt == format && config.isOutput() == output) {
if (output && mListHighResolution) {
// Filter slow high-res output formats; include for
// highRes, remove for !highRes
long duration = 0;
for (int i = 0; i < minFrameDurations.length; i++) {
StreamConfigurationDuration d = minFrameDurations[i];
if (d.getFormat() == fmt && d.getWidth() == config.getSize().getWidth() && d.getHeight() == config.getSize().getHeight()) {
duration = d.getDuration();
break;
}
}
if (dataspace != HAL_DATASPACE_DEPTH && highRes != (duration > DURATION_20FPS_NS)) {
continue;
}
}
sizes[sizeIndex++] = config.getSize();
}
}
if (sizeIndex != sizesCount) {
throw new AssertionError("Too few sizes (expected " + sizesCount + ", actual " + sizeIndex + ")");
}
return sizes;
}
use of android.util.SparseIntArray in project android_frameworks_base by ResurrectionRemix.
the class StreamConfigurationMap method getPublicFormatCount.
/** Count the number of publicly-visible output formats */
private int getPublicFormatCount(boolean output) {
SparseIntArray formatsMap = getFormatsMap(output);
int size = formatsMap.size();
if (output) {
size += mDepthOutputFormats.size();
}
return size;
}
use of android.util.SparseIntArray in project android_frameworks_base by ResurrectionRemix.
the class StreamConfigurationMap method getPublicFormats.
/** Get the list of publically visible output formats; does not include IMPL_DEFINED */
private int[] getPublicFormats(boolean output) {
int[] formats = new int[getPublicFormatCount(output)];
int i = 0;
SparseIntArray map = getFormatsMap(output);
for (int j = 0; j < map.size(); j++) {
int format = map.keyAt(j);
formats[i++] = imageFormatToPublic(format);
}
if (output) {
for (int j = 0; j < mDepthOutputFormats.size(); j++) {
formats[i++] = depthFormatToPublic(mDepthOutputFormats.keyAt(j));
}
}
if (formats.length != i) {
throw new AssertionError("Too few formats " + i + ", expected " + formats.length);
}
return formats;
}
use of android.util.SparseIntArray in project android_frameworks_base by ResurrectionRemix.
the class CursorWindow method printStats.
private String printStats() {
StringBuilder buff = new StringBuilder();
int myPid = Process.myPid();
int total = 0;
SparseIntArray pidCounts = new SparseIntArray();
synchronized (sWindowToPidMap) {
int size = sWindowToPidMap.size();
if (size == 0) {
// this means we are not in the ContentProvider.
return "";
}
for (int indx = 0; indx < size; indx++) {
int pid = sWindowToPidMap.valueAt(indx);
int value = pidCounts.get(pid);
pidCounts.put(pid, ++value);
}
}
int numPids = pidCounts.size();
for (int i = 0; i < numPids; i++) {
buff.append(" (# cursors opened by ");
int pid = pidCounts.keyAt(i);
if (pid == myPid) {
buff.append("this proc=");
} else {
buff.append("pid " + pid + "=");
}
int num = pidCounts.get(pid);
buff.append(num + ")");
total += num;
}
// limit the returned string size to 1000
String s = (buff.length() > 980) ? buff.substring(0, 980) : buff.toString();
return "# Open Cursors=" + total + s;
}
use of android.util.SparseIntArray in project android_frameworks_base by DirtyUnicorns.
the class AppOpsService method setUidMode.
@Override
public void setUidMode(int code, int uid, int mode) {
if (Binder.getCallingPid() != Process.myPid()) {
mContext.enforcePermission(android.Manifest.permission.UPDATE_APP_OPS_STATS, Binder.getCallingPid(), Binder.getCallingUid(), null);
}
verifyIncomingOp(code);
code = AppOpsManager.opToSwitch(code);
synchronized (this) {
final int defaultMode = AppOpsManager.opToDefaultMode(code);
UidState uidState = getUidStateLocked(uid, false);
if (uidState == null) {
if (mode == defaultMode) {
return;
}
uidState = new UidState(uid);
uidState.opModes = new SparseIntArray();
uidState.opModes.put(code, mode);
mUidStates.put(uid, uidState);
scheduleWriteLocked();
} else if (uidState.opModes == null) {
if (mode != defaultMode) {
uidState.opModes = new SparseIntArray();
uidState.opModes.put(code, mode);
scheduleWriteLocked();
}
} else {
if (uidState.opModes.get(code) == mode) {
return;
}
if (mode == defaultMode) {
uidState.opModes.delete(code);
if (uidState.opModes.size() <= 0) {
uidState.opModes = null;
}
} else {
uidState.opModes.put(code, mode);
}
scheduleWriteLocked();
}
}
String[] uidPackageNames = getPackagesForUid(uid);
ArrayMap<Callback, ArraySet<String>> callbackSpecs = null;
synchronized (this) {
ArrayList<Callback> callbacks = mOpModeWatchers.get(code);
if (callbacks != null) {
final int callbackCount = callbacks.size();
for (int i = 0; i < callbackCount; i++) {
Callback callback = callbacks.get(i);
ArraySet<String> changedPackages = new ArraySet<>();
Collections.addAll(changedPackages, uidPackageNames);
callbackSpecs = new ArrayMap<>();
callbackSpecs.put(callback, changedPackages);
}
}
for (String uidPackageName : uidPackageNames) {
callbacks = mPackageModeWatchers.get(uidPackageName);
if (callbacks != null) {
if (callbackSpecs == null) {
callbackSpecs = new ArrayMap<>();
}
final int callbackCount = callbacks.size();
for (int i = 0; i < callbackCount; i++) {
Callback callback = callbacks.get(i);
ArraySet<String> changedPackages = callbackSpecs.get(callback);
if (changedPackages == null) {
changedPackages = new ArraySet<>();
callbackSpecs.put(callback, changedPackages);
}
changedPackages.add(uidPackageName);
}
}
}
}
if (callbackSpecs == null) {
return;
}
// There are components watching for mode changes such as window manager
// and location manager which are in our process. The callbacks in these
// components may require permissions our remote caller does not have.
final long identity = Binder.clearCallingIdentity();
try {
for (int i = 0; i < callbackSpecs.size(); i++) {
Callback callback = callbackSpecs.keyAt(i);
ArraySet<String> reportedPackageNames = callbackSpecs.valueAt(i);
try {
if (reportedPackageNames == null) {
callback.mCallback.opChanged(code, uid, null);
} else {
final int reportedPackageCount = reportedPackageNames.size();
for (int j = 0; j < reportedPackageCount; j++) {
String reportedPackageName = reportedPackageNames.valueAt(j);
callback.mCallback.opChanged(code, uid, reportedPackageName);
}
}
} catch (RemoteException e) {
Log.w(TAG, "Error dispatching op op change", e);
}
}
} finally {
Binder.restoreCallingIdentity(identity);
}
}
Aggregations