Search in sources :

Example 46 with ArrayMap

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;
}
Also used : TokenBucket(com.android.internal.util.TokenBucket) ArrayMap(android.util.ArrayMap)

Example 47 with ArrayMap

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);
    }
}
Also used : Field(java.lang.reflect.Field) LoadedApk(android.app.LoadedApk) ArrayMap(android.util.ArrayMap) Intent(android.content.Intent) Method(java.lang.reflect.Method) MalformedURLException(java.net.MalformedURLException) IOException(java.io.IOException) InterruptedException(java.lang.InterruptedException)

Example 48 with ArrayMap

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;
}
Also used : PrintWriterPrinter(android.util.PrintWriterPrinter) MutableInt(android.util.MutableInt) ArrayMap(android.util.ArrayMap) PrintWriterPrinter(android.util.PrintWriterPrinter) LogPrinter(android.util.LogPrinter) Printer(android.util.Printer)

Example 49 with ArrayMap

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)");
    }
}
Also used : ArrayMap(android.util.ArrayMap) Point(android.graphics.Point) SparseArray(android.util.SparseArray) IPackageManager(android.content.pm.IPackageManager) ComponentName(android.content.ComponentName) RemoteException(android.os.RemoteException)

Example 50 with ArrayMap

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;
                        }
                    }
                }
            }
        }
    }
}
Also used : SparseArray(android.util.SparseArray) ArrayMap(android.util.ArrayMap) ComponentName(android.content.ComponentName) Point(android.graphics.Point)

Aggregations

ArrayMap (android.util.ArrayMap)365 ArraySet (android.util.ArraySet)77 ArrayList (java.util.ArrayList)75 PublicKey (java.security.PublicKey)49 HashMap (java.util.HashMap)32 Preference (android.support.v7.preference.Preference)30 IOException (java.io.IOException)30 Map (java.util.Map)29 HashSet (java.util.HashSet)28 Intent (android.content.Intent)24 Test (org.junit.Test)24 ComponentName (android.content.ComponentName)22 RemoteException (android.os.RemoteException)22 Field (java.lang.reflect.Field)21 Activity (android.app.Activity)20 SparseArray (android.util.SparseArray)18 List (java.util.List)18 XmlPullParserException (org.xmlpull.v1.XmlPullParserException)18 Point (android.graphics.Point)17 Method (java.lang.reflect.Method)17