Search in sources :

Example 51 with SparseArray

use of android.util.SparseArray in project android_frameworks_base by ResurrectionRemix.

the class ProcessStatsService method readLocked.

boolean readLocked(ProcessStats stats, AtomicFile file) {
    try {
        FileInputStream stream = file.openRead();
        stats.read(stream);
        stream.close();
        if (stats.mReadError != null) {
            Slog.w(TAG, "Ignoring existing stats; " + stats.mReadError);
            if (DEBUG) {
                ArrayMap<String, SparseArray<ProcessState>> procMap = stats.mProcesses.getMap();
                final int NPROC = procMap.size();
                for (int ip = 0; ip < NPROC; ip++) {
                    Slog.w(TAG, "Process: " + procMap.keyAt(ip));
                    SparseArray<ProcessState> uids = procMap.valueAt(ip);
                    final int NUID = uids.size();
                    for (int iu = 0; iu < NUID; iu++) {
                        Slog.w(TAG, "  Uid " + uids.keyAt(iu) + ": " + uids.valueAt(iu));
                    }
                }
                ArrayMap<String, SparseArray<SparseArray<ProcessStats.PackageState>>> pkgMap = stats.mPackages.getMap();
                final int NPKG = pkgMap.size();
                for (int ip = 0; ip < NPKG; ip++) {
                    Slog.w(TAG, "Package: " + pkgMap.keyAt(ip));
                    SparseArray<SparseArray<ProcessStats.PackageState>> uids = pkgMap.valueAt(ip);
                    final int NUID = uids.size();
                    for (int iu = 0; iu < NUID; iu++) {
                        Slog.w(TAG, "  Uid: " + uids.keyAt(iu));
                        SparseArray<ProcessStats.PackageState> vers = uids.valueAt(iu);
                        final int NVERS = vers.size();
                        for (int iv = 0; iv < NVERS; iv++) {
                            Slog.w(TAG, "    Vers: " + vers.keyAt(iv));
                            ProcessStats.PackageState pkgState = vers.valueAt(iv);
                            final int NPROCS = pkgState.mProcesses.size();
                            for (int iproc = 0; iproc < NPROCS; iproc++) {
                                Slog.w(TAG, "      Process " + pkgState.mProcesses.keyAt(iproc) + ": " + pkgState.mProcesses.valueAt(iproc));
                            }
                            final int NSRVS = pkgState.mServices.size();
                            for (int isvc = 0; isvc < NSRVS; isvc++) {
                                Slog.w(TAG, "      Service " + pkgState.mServices.keyAt(isvc) + ": " + pkgState.mServices.valueAt(isvc));
                            }
                        }
                    }
                }
            }
            return false;
        }
    } catch (Throwable e) {
        stats.mReadError = "caught exception: " + e;
        Slog.e(TAG, "Error reading process statistics", e);
        return false;
    }
    return true;
}
Also used : IProcessStats(com.android.internal.app.procstats.IProcessStats) ProcessStats(com.android.internal.app.procstats.ProcessStats) FileInputStream(java.io.FileInputStream) ProcessState(com.android.internal.app.procstats.ProcessState) SparseArray(android.util.SparseArray)

Example 52 with SparseArray

use of android.util.SparseArray in project android_frameworks_base by ResurrectionRemix.

the class PhoneWindow method saveHierarchyState.

/** {@inheritDoc} */
@Override
public Bundle saveHierarchyState() {
    Bundle outState = new Bundle();
    if (mContentParent == null) {
        return outState;
    }
    SparseArray<Parcelable> states = new SparseArray<Parcelable>();
    mContentParent.saveHierarchyState(states);
    outState.putSparseParcelableArray(VIEWS_TAG, states);
    // Save the focused view ID.
    final View focusedView = mContentParent.findFocus();
    if (focusedView != null && focusedView.getId() != View.NO_ID) {
        outState.putInt(FOCUSED_ID_TAG, focusedView.getId());
    }
    // save the panels
    SparseArray<Parcelable> panelStates = new SparseArray<Parcelable>();
    savePanelState(panelStates);
    if (panelStates.size() > 0) {
        outState.putSparseParcelableArray(PANELS_TAG, panelStates);
    }
    if (mDecorContentParent != null) {
        SparseArray<Parcelable> actionBarStates = new SparseArray<Parcelable>();
        mDecorContentParent.saveToolbarHierarchyState(actionBarStates);
        outState.putSparseParcelableArray(ACTION_BAR_TAG, actionBarStates);
    }
    return outState;
}
Also used : SparseArray(android.util.SparseArray) Bundle(android.os.Bundle) Parcelable(android.os.Parcelable) MenuView(com.android.internal.view.menu.MenuView) ImageView(android.widget.ImageView) View(android.view.View) TextView(android.widget.TextView)

Example 53 with SparseArray

use of android.util.SparseArray in project simple-stack by Zhuinden.

the class BackstackManager method persistViewToState.

// ----- viewstate persistence
/**
     * Provides the means to save the provided view's hierarchy state
     * and its optional StateBundle via {@link Bundleable} into a {@link SavedState}.
     *
     * @param view the view that belongs to a certain key
     */
public void persistViewToState(@Nullable View view) {
    if (view != null) {
        Object key = KeyContextWrapper.getKey(view.getContext());
        if (key == null) {
            throw new IllegalArgumentException("The view [" + view + "] contained no key!");
        }
        SparseArray<Parcelable> viewHierarchyState = new SparseArray<>();
        view.saveHierarchyState(viewHierarchyState);
        StateBundle bundle = null;
        if (view instanceof Bundleable) {
            bundle = ((Bundleable) view).toBundle();
        }
        SavedState previousSavedState = //
        SavedState.builder().setKey(//
        key).setViewHierarchyState(//
        viewHierarchyState).setBundle(//
        bundle).build();
        keyStateMap.put(key, previousSavedState);
    }
}
Also used : SparseArray(android.util.SparseArray) Parcelable(android.os.Parcelable) StateBundle(com.zhuinden.statebundle.StateBundle)

Example 54 with SparseArray

use of android.util.SparseArray in project android_frameworks_base by ResurrectionRemix.

the class StringBlock method get.

public CharSequence get(int idx) {
    synchronized (this) {
        if (mStrings != null) {
            CharSequence res = mStrings[idx];
            if (res != null) {
                return res;
            }
        } else if (mSparseStrings != null) {
            CharSequence res = mSparseStrings.get(idx);
            if (res != null) {
                return res;
            }
        } else {
            final int num = nativeGetSize(mNative);
            if (mUseSparse && num > 250) {
                mSparseStrings = new SparseArray<CharSequence>();
            } else {
                mStrings = new CharSequence[num];
            }
        }
        String str = nativeGetString(mNative, idx);
        CharSequence res = str;
        int[] style = nativeGetStyle(mNative, idx);
        if (localLOGV)
            Log.v(TAG, "Got string: " + str);
        if (localLOGV)
            Log.v(TAG, "Got styles: " + Arrays.toString(style));
        if (style != null) {
            if (mStyleIDs == null) {
                mStyleIDs = new StyleIDs();
            }
            // the magic constant 3.
            for (int styleIndex = 0; styleIndex < style.length; styleIndex += 3) {
                int styleId = style[styleIndex];
                if (styleId == mStyleIDs.boldId || styleId == mStyleIDs.italicId || styleId == mStyleIDs.underlineId || styleId == mStyleIDs.ttId || styleId == mStyleIDs.bigId || styleId == mStyleIDs.smallId || styleId == mStyleIDs.subId || styleId == mStyleIDs.supId || styleId == mStyleIDs.strikeId || styleId == mStyleIDs.listItemId || styleId == mStyleIDs.marqueeId) {
                    // id already found skip to next style
                    continue;
                }
                String styleTag = nativeGetString(mNative, styleId);
                if (styleTag.equals("b")) {
                    mStyleIDs.boldId = styleId;
                } else if (styleTag.equals("i")) {
                    mStyleIDs.italicId = styleId;
                } else if (styleTag.equals("u")) {
                    mStyleIDs.underlineId = styleId;
                } else if (styleTag.equals("tt")) {
                    mStyleIDs.ttId = styleId;
                } else if (styleTag.equals("big")) {
                    mStyleIDs.bigId = styleId;
                } else if (styleTag.equals("small")) {
                    mStyleIDs.smallId = styleId;
                } else if (styleTag.equals("sup")) {
                    mStyleIDs.supId = styleId;
                } else if (styleTag.equals("sub")) {
                    mStyleIDs.subId = styleId;
                } else if (styleTag.equals("strike")) {
                    mStyleIDs.strikeId = styleId;
                } else if (styleTag.equals("li")) {
                    mStyleIDs.listItemId = styleId;
                } else if (styleTag.equals("marquee")) {
                    mStyleIDs.marqueeId = styleId;
                }
            }
            res = applyStyles(str, style, mStyleIDs);
        }
        if (mStrings != null)
            mStrings[idx] = res;
        else
            mSparseStrings.put(idx, res);
        return res;
    }
}
Also used : SparseArray(android.util.SparseArray) Paint(android.graphics.Paint)

Example 55 with SparseArray

use of android.util.SparseArray in project android_frameworks_base by ResurrectionRemix.

the class ActionMenuPresenter method computeMenuItemAnimationInfo.

/**
     * Store layout information about current items in the menu. This is stored for
     * both pre- and post-layout phases and compared in runItemAnimations() to determine
     * the animations that need to be run on any item changes.
     *
     * @param preLayout Whether this is being called in the pre-layout phase. This is passed
     * into the MenuItemLayoutInfo structure to store the appropriate position values.
     */
private void computeMenuItemAnimationInfo(boolean preLayout) {
    final ViewGroup menuView = (ViewGroup) mMenuView;
    final int count = menuView.getChildCount();
    SparseArray items = preLayout ? mPreLayoutItems : mPostLayoutItems;
    for (int i = 0; i < count; ++i) {
        View child = menuView.getChildAt(i);
        final int id = child.getId();
        if (id > 0 && child.getWidth() != 0 && child.getHeight() != 0) {
            MenuItemLayoutInfo info = new MenuItemLayoutInfo(child, preLayout);
            items.put(id, info);
        }
    }
}
Also used : SparseArray(android.util.SparseArray) ViewGroup(android.view.ViewGroup) MenuView(com.android.internal.view.menu.MenuView) View(android.view.View) ActionMenuItemView(com.android.internal.view.menu.ActionMenuItemView)

Aggregations

SparseArray (android.util.SparseArray)250 ArrayList (java.util.ArrayList)74 ProcessState (com.android.internal.app.procstats.ProcessState)41 Parcelable (android.os.Parcelable)37 View (android.view.View)35 ServiceState (com.android.internal.app.procstats.ServiceState)31 RemoteException (android.os.RemoteException)24 Point (android.graphics.Point)19 ArraySet (android.util.ArraySet)17 HashMap (java.util.HashMap)17 ComponentName (android.content.ComponentName)15 ProcessStats (com.android.internal.app.procstats.ProcessStats)15 UserHandle (android.os.UserHandle)14 ArrayMap (android.util.ArrayMap)14 UserInfo (android.content.pm.UserInfo)13 Paint (android.graphics.Paint)13 Bitmap (android.graphics.Bitmap)12 IOException (java.io.IOException)12 ApplicationInfo (android.content.pm.ApplicationInfo)11 SparseIntArray (android.util.SparseIntArray)11