use of android.util.ArrayMap in project android_frameworks_base by DirtyUnicorns.
the class IpConnectivityMetrics method makeRateLimitingBuckets.
private static ArrayMap<Class<?>, TokenBucket> makeRateLimitingBuckets() {
ArrayMap<Class<?>, TokenBucket> map = new ArrayMap<>();
// one token every minute, 50 tokens max: burst of ~50 events every hour.
map.put(ApfProgramEvent.class, new TokenBucket((int) DateUtils.MINUTE_IN_MILLIS, 50));
return map;
}
use of android.util.ArrayMap in project android_frameworks_base by DirtyUnicorns.
the class CaptivePortalLoginActivity method setWebViewProxy.
// Find WebView's proxy BroadcastReceiver and prompt it to read proxy system properties.
private void setWebViewProxy() {
LoadedApk loadedApk = getApplication().mLoadedApk;
try {
Field receiversField = LoadedApk.class.getDeclaredField("mReceivers");
receiversField.setAccessible(true);
ArrayMap receivers = (ArrayMap) receiversField.get(loadedApk);
for (Object receiverMap : receivers.values()) {
for (Object rec : ((ArrayMap) receiverMap).keySet()) {
Class clazz = rec.getClass();
if (clazz.getName().contains("ProxyChangeListener")) {
Method onReceiveMethod = clazz.getDeclaredMethod("onReceive", Context.class, Intent.class);
Intent intent = new Intent(Proxy.PROXY_CHANGE_ACTION);
onReceiveMethod.invoke(rec, getApplicationContext(), intent);
Log.v(TAG, "Prompting WebView proxy reload.");
}
}
}
} catch (Exception e) {
Log.e(TAG, "Exception while setting WebView proxy: " + e);
}
}
use of android.util.ArrayMap in project android_frameworks_base by DirtyUnicorns.
the class IntentResolver method dumpMap.
boolean dumpMap(PrintWriter out, String titlePrefix, String title, String prefix, ArrayMap<String, F[]> map, String packageName, boolean printFilter, boolean collapseDuplicates) {
final String eprefix = prefix + " ";
final String fprefix = prefix + " ";
final ArrayMap<Object, MutableInt> found = new ArrayMap<>();
boolean printedSomething = false;
Printer printer = null;
for (int mapi = 0; mapi < map.size(); mapi++) {
F[] a = map.valueAt(mapi);
final int N = a.length;
boolean printedHeader = false;
F filter;
if (collapseDuplicates && !printFilter) {
found.clear();
for (int i = 0; i < N && (filter = a[i]) != null; i++) {
if (packageName != null && !isPackageForFilter(packageName, filter)) {
continue;
}
Object label = filterToLabel(filter);
int index = found.indexOfKey(label);
if (index < 0) {
found.put(label, new MutableInt(1));
} else {
found.valueAt(index).value++;
}
}
for (int i = 0; i < found.size(); i++) {
if (title != null) {
out.print(titlePrefix);
out.println(title);
title = null;
}
if (!printedHeader) {
out.print(eprefix);
out.print(map.keyAt(mapi));
out.println(":");
printedHeader = true;
}
printedSomething = true;
dumpFilterLabel(out, fprefix, found.keyAt(i), found.valueAt(i).value);
}
} else {
for (int i = 0; i < N && (filter = a[i]) != null; i++) {
if (packageName != null && !isPackageForFilter(packageName, filter)) {
continue;
}
if (title != null) {
out.print(titlePrefix);
out.println(title);
title = null;
}
if (!printedHeader) {
out.print(eprefix);
out.print(map.keyAt(mapi));
out.println(":");
printedHeader = true;
}
printedSomething = true;
dumpFilter(out, fprefix, filter);
if (printFilter) {
if (printer == null) {
printer = new PrintWriterPrinter(out);
}
filter.dump(printer, fprefix + " ");
}
}
}
}
return printedSomething;
}
use of android.util.ArrayMap in project android_frameworks_base by DirtyUnicorns.
the class ActivityManagerService method dumpAssociationsLocked.
void dumpAssociationsLocked(FileDescriptor fd, PrintWriter pw, String[] args, int opti, boolean dumpAll, boolean dumpClient, String dumpPackage) {
pw.println("ACTIVITY MANAGER ASSOCIATIONS (dumpsys activity associations)");
int dumpUid = 0;
if (dumpPackage != null) {
IPackageManager pm = AppGlobals.getPackageManager();
try {
dumpUid = pm.getPackageUid(dumpPackage, MATCH_UNINSTALLED_PACKAGES, 0);
} catch (RemoteException e) {
}
}
boolean printedAnything = false;
final long now = SystemClock.uptimeMillis();
for (int i1 = 0, N1 = mAssociations.size(); i1 < N1; i1++) {
ArrayMap<ComponentName, SparseArray<ArrayMap<String, Association>>> targetComponents = mAssociations.valueAt(i1);
for (int i2 = 0, N2 = targetComponents.size(); i2 < N2; i2++) {
SparseArray<ArrayMap<String, Association>> sourceUids = targetComponents.valueAt(i2);
for (int i3 = 0, N3 = sourceUids.size(); i3 < N3; i3++) {
ArrayMap<String, Association> sourceProcesses = sourceUids.valueAt(i3);
for (int i4 = 0, N4 = sourceProcesses.size(); i4 < N4; i4++) {
Association ass = sourceProcesses.valueAt(i4);
if (dumpPackage != null) {
if (!ass.mTargetComponent.getPackageName().equals(dumpPackage) && UserHandle.getAppId(ass.mSourceUid) != dumpUid) {
continue;
}
}
printedAnything = true;
pw.print(" ");
pw.print(ass.mTargetProcess);
pw.print("/");
UserHandle.formatUid(pw, ass.mTargetUid);
pw.print(" <- ");
pw.print(ass.mSourceProcess);
pw.print("/");
UserHandle.formatUid(pw, ass.mSourceUid);
pw.println();
pw.print(" via ");
pw.print(ass.mTargetComponent.flattenToShortString());
pw.println();
pw.print(" ");
long dur = ass.mTime;
if (ass.mNesting > 0) {
dur += now - ass.mStartTime;
}
TimeUtils.formatDuration(dur, pw);
pw.print(" (");
pw.print(ass.mCount);
pw.print(" times)");
pw.print(" ");
for (int i = 0; i < ass.mStateTimes.length; i++) {
long amt = ass.mStateTimes[i];
if (ass.mLastState - ActivityManager.MIN_PROCESS_STATE == i) {
amt += now - ass.mLastStateUptime;
}
if (amt != 0) {
pw.print(" ");
pw.print(ProcessList.makeProcStateString(i + ActivityManager.MIN_PROCESS_STATE));
pw.print("=");
TimeUtils.formatDuration(amt, pw);
if (ass.mLastState - ActivityManager.MIN_PROCESS_STATE == i) {
pw.print("*");
}
}
}
pw.println();
if (ass.mNesting > 0) {
pw.print(" Currently active: ");
TimeUtils.formatDuration(now - ass.mStartTime, pw);
pw.println();
}
}
}
}
}
if (!printedAnything) {
pw.println(" (nothing)");
}
}
use of android.util.ArrayMap in project android_frameworks_base by DirtyUnicorns.
the class ActivityManagerService method noteUidProcessState.
private void noteUidProcessState(final int uid, final int state) {
mBatteryStatsService.noteUidProcessState(uid, state);
if (mTrackingAssociations) {
for (int i1 = 0, N1 = mAssociations.size(); i1 < N1; i1++) {
ArrayMap<ComponentName, SparseArray<ArrayMap<String, Association>>> targetComponents = mAssociations.valueAt(i1);
for (int i2 = 0, N2 = targetComponents.size(); i2 < N2; i2++) {
SparseArray<ArrayMap<String, Association>> sourceUids = targetComponents.valueAt(i2);
ArrayMap<String, Association> sourceProcesses = sourceUids.get(uid);
if (sourceProcesses != null) {
for (int i4 = 0, N4 = sourceProcesses.size(); i4 < N4; i4++) {
Association ass = sourceProcesses.valueAt(i4);
if (ass.mNesting >= 1) {
// currently associated
long uptime = SystemClock.uptimeMillis();
ass.mStateTimes[ass.mLastState - ActivityManager.MIN_PROCESS_STATE] += uptime - ass.mLastStateUptime;
ass.mLastState = state;
ass.mLastStateUptime = uptime;
}
}
}
}
}
}
}
Aggregations