Search in sources :

Example 91 with SparseIntArray

use of android.util.SparseIntArray in project android_frameworks_base by crdroidandroid.

the class TableRow method mapIndexAndColumns.

private void mapIndexAndColumns() {
    if (mColumnToChildIndex == null) {
        int virtualCount = 0;
        final int count = getChildCount();
        mColumnToChildIndex = new SparseIntArray();
        final SparseIntArray columnToChild = mColumnToChildIndex;
        for (int i = 0; i < count; i++) {
            final View child = getChildAt(i);
            final LayoutParams layoutParams = (LayoutParams) child.getLayoutParams();
            if (layoutParams.column >= virtualCount) {
                virtualCount = layoutParams.column;
            }
            for (int j = 0; j < layoutParams.span; j++) {
                columnToChild.put(virtualCount++, i);
            }
        }
        mNumColumns = virtualCount;
    }
}
Also used : SparseIntArray(android.util.SparseIntArray) View(android.view.View)

Example 92 with SparseIntArray

use of android.util.SparseIntArray in project android_frameworks_base by crdroidandroid.

the class BatteryStats method dumpHistoryLocked.

private void dumpHistoryLocked(PrintWriter pw, int flags, long histStart, boolean checkin) {
    final HistoryPrinter hprinter = new HistoryPrinter();
    final HistoryItem rec = new HistoryItem();
    long lastTime = -1;
    long baseTime = -1;
    boolean printed = false;
    HistoryEventTracker tracker = null;
    while (getNextHistoryLocked(rec)) {
        lastTime = rec.time;
        if (baseTime < 0) {
            baseTime = lastTime;
        }
        if (rec.time >= histStart) {
            if (histStart >= 0 && !printed) {
                if (rec.cmd == HistoryItem.CMD_CURRENT_TIME || rec.cmd == HistoryItem.CMD_RESET || rec.cmd == HistoryItem.CMD_START || rec.cmd == HistoryItem.CMD_SHUTDOWN) {
                    printed = true;
                    hprinter.printNextItem(pw, rec, baseTime, checkin, (flags & DUMP_VERBOSE) != 0);
                    rec.cmd = HistoryItem.CMD_UPDATE;
                } else if (rec.currentTime != 0) {
                    printed = true;
                    byte cmd = rec.cmd;
                    rec.cmd = HistoryItem.CMD_CURRENT_TIME;
                    hprinter.printNextItem(pw, rec, baseTime, checkin, (flags & DUMP_VERBOSE) != 0);
                    rec.cmd = cmd;
                }
                if (tracker != null) {
                    if (rec.cmd != HistoryItem.CMD_UPDATE) {
                        hprinter.printNextItem(pw, rec, baseTime, checkin, (flags & DUMP_VERBOSE) != 0);
                        rec.cmd = HistoryItem.CMD_UPDATE;
                    }
                    int oldEventCode = rec.eventCode;
                    HistoryTag oldEventTag = rec.eventTag;
                    rec.eventTag = new HistoryTag();
                    for (int i = 0; i < HistoryItem.EVENT_COUNT; i++) {
                        HashMap<String, SparseIntArray> active = tracker.getStateForEvent(i);
                        if (active == null) {
                            continue;
                        }
                        for (HashMap.Entry<String, SparseIntArray> ent : active.entrySet()) {
                            SparseIntArray uids = ent.getValue();
                            for (int j = 0; j < uids.size(); j++) {
                                rec.eventCode = i;
                                rec.eventTag.string = ent.getKey();
                                rec.eventTag.uid = uids.keyAt(j);
                                rec.eventTag.poolIdx = uids.valueAt(j);
                                hprinter.printNextItem(pw, rec, baseTime, checkin, (flags & DUMP_VERBOSE) != 0);
                                rec.wakeReasonTag = null;
                                rec.wakelockTag = null;
                            }
                        }
                    }
                    rec.eventCode = oldEventCode;
                    rec.eventTag = oldEventTag;
                    tracker = null;
                }
            }
            hprinter.printNextItem(pw, rec, baseTime, checkin, (flags & DUMP_VERBOSE) != 0);
        } else if (false && rec.eventCode != HistoryItem.EVENT_NONE) {
            // printing real events.  It doesn't really work right, so is turned off.
            if (tracker == null) {
                tracker = new HistoryEventTracker();
            }
            tracker.updateState(rec.eventCode, rec.eventTag.string, rec.eventTag.uid, rec.eventTag.poolIdx);
        }
    }
    if (histStart >= 0) {
        commitCurrentHistoryBatchLocked();
        pw.print(checkin ? "NEXT: " : "  NEXT: ");
        pw.println(lastTime + 1);
    }
}
Also used : SparseIntArray(android.util.SparseIntArray) HashMap(java.util.HashMap)

Example 93 with SparseIntArray

use of android.util.SparseIntArray in project android_frameworks_base by crdroidandroid.

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;
}
Also used : SparseIntArray(android.util.SparseIntArray)

Example 94 with SparseIntArray

use of android.util.SparseIntArray in project android_frameworks_base by crdroidandroid.

the class ExifInterface method setTagDefinition.

/**
     * Creates a new tag definition in this ExifInterface object for a given TID
     * and default IFD. Creating a definition with the same TID and default IFD
     * as a previous definition will override it.
     *
     * @param tagId the TID for the tag.
     * @param defaultIfd the default IFD for the tag.
     * @param tagType the type of the tag (see {@link ExifTag#getDataType()}).
     * @param defaultComponentCount the number of elements of this tag's type in
     *            the tags value.
     * @param allowedIfds the IFD's this tag is allowed to be put in.
     * @return the defined tag constant (e.g. {@link #TAG_IMAGE_WIDTH}) or
     *         {@link #TAG_NULL} if the definition could not be made.
     */
public int setTagDefinition(short tagId, int defaultIfd, short tagType, short defaultComponentCount, int[] allowedIfds) {
    if (sBannedDefines.contains(tagId)) {
        return TAG_NULL;
    }
    if (ExifTag.isValidType(tagType) && ExifTag.isValidIfd(defaultIfd)) {
        int tagDef = defineTag(defaultIfd, tagId);
        if (tagDef == TAG_NULL) {
            return TAG_NULL;
        }
        int[] otherDefs = getTagDefinitionsForTagId(tagId);
        SparseIntArray infos = getTagInfo();
        // Make sure defaultIfd is in allowedIfds
        boolean defaultCheck = false;
        for (int i : allowedIfds) {
            if (defaultIfd == i) {
                defaultCheck = true;
            }
            if (!ExifTag.isValidIfd(i)) {
                return TAG_NULL;
            }
        }
        if (!defaultCheck) {
            return TAG_NULL;
        }
        int ifdFlags = getFlagsFromAllowedIfds(allowedIfds);
        // Make sure no identical tags can exist in allowedIfds
        if (otherDefs != null) {
            for (int def : otherDefs) {
                int tagInfo = infos.get(def);
                int allowedFlags = getAllowedIfdFlagsFromInfo(tagInfo);
                if ((ifdFlags & allowedFlags) != 0) {
                    return TAG_NULL;
                }
            }
        }
        getTagInfo().put(tagDef, ifdFlags << 24 | (tagType << 16) | defaultComponentCount);
        return tagDef;
    }
    return TAG_NULL;
}
Also used : SparseIntArray(android.util.SparseIntArray)

Example 95 with SparseIntArray

use of android.util.SparseIntArray in project android_frameworks_base by crdroidandroid.

the class ExifInterface method getTagDefinitionForTag.

protected int getTagDefinitionForTag(short tagId, short type, int count, int ifd) {
    int[] defs = getTagDefinitionsForTagId(tagId);
    if (defs == null) {
        return TAG_NULL;
    }
    SparseIntArray infos = getTagInfo();
    int ret = TAG_NULL;
    for (int i : defs) {
        int info = infos.get(i);
        short def_type = getTypeFromInfo(info);
        int def_count = getComponentCountFromInfo(info);
        int[] def_ifds = getAllowedIfdsFromInfo(info);
        boolean valid_ifd = false;
        for (int j : def_ifds) {
            if (j == ifd) {
                valid_ifd = true;
                break;
            }
        }
        if (valid_ifd && type == def_type && (count == def_count || def_count == ExifTag.SIZE_UNDEFINED)) {
            ret = i;
            break;
        }
    }
    return ret;
}
Also used : SparseIntArray(android.util.SparseIntArray)

Aggregations

SparseIntArray (android.util.SparseIntArray)249 RemoteException (android.os.RemoteException)40 ArrayList (java.util.ArrayList)28 HashMap (java.util.HashMap)20 IAppOpsCallback (com.android.internal.app.IAppOpsCallback)15 IOException (java.io.IOException)12 Point (android.graphics.Point)11 SparseArray (android.util.SparseArray)11 UserInfo (android.content.pm.UserInfo)10 ArraySet (android.util.ArraySet)10 Map (java.util.Map)10 HashSet (java.util.HashSet)9 Cursor (android.database.Cursor)8 View (android.view.View)7 SparseBooleanArray (android.util.SparseBooleanArray)6 ActivityManager (android.app.ActivityManager)5 Context (android.content.Context)5 ActivityInfo (android.content.pm.ActivityInfo)5 Configuration (android.content.res.Configuration)5 Resources (android.content.res.Resources)5