use of android.util.SparseArray in project android_frameworks_base by DirtyUnicorns.
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);
}
}
}
use of android.util.SparseArray in project android_frameworks_base by DirtyUnicorns.
the class ProcessStats method dumpCheckinLocked.
public void dumpCheckinLocked(PrintWriter pw, String reqPackage) {
final long now = SystemClock.uptimeMillis();
final ArrayMap<String, SparseArray<SparseArray<PackageState>>> pkgMap = mPackages.getMap();
pw.println("vers,5");
pw.print("period,");
pw.print(mTimePeriodStartClockStr);
pw.print(",");
pw.print(mTimePeriodStartRealtime);
pw.print(",");
pw.print(mRunning ? SystemClock.elapsedRealtime() : mTimePeriodEndRealtime);
boolean partial = true;
if ((mFlags & FLAG_SHUTDOWN) != 0) {
pw.print(",shutdown");
partial = false;
}
if ((mFlags & FLAG_SYSPROPS) != 0) {
pw.print(",sysprops");
partial = false;
}
if ((mFlags & FLAG_COMPLETE) != 0) {
pw.print(",complete");
partial = false;
}
if (partial) {
pw.print(",partial");
}
if (mHasSwappedOutPss) {
pw.print(",swapped-out-pss");
}
pw.println();
pw.print("config,");
pw.println(mRuntime);
for (int ip = 0; ip < pkgMap.size(); ip++) {
final String pkgName = pkgMap.keyAt(ip);
if (reqPackage != null && !reqPackage.equals(pkgName)) {
continue;
}
final SparseArray<SparseArray<PackageState>> uids = pkgMap.valueAt(ip);
for (int iu = 0; iu < uids.size(); iu++) {
final int uid = uids.keyAt(iu);
final SparseArray<PackageState> vpkgs = uids.valueAt(iu);
for (int iv = 0; iv < vpkgs.size(); iv++) {
final int vers = vpkgs.keyAt(iv);
final PackageState pkgState = vpkgs.valueAt(iv);
final int NPROCS = pkgState.mProcesses.size();
final int NSRVS = pkgState.mServices.size();
for (int iproc = 0; iproc < NPROCS; iproc++) {
ProcessState proc = pkgState.mProcesses.valueAt(iproc);
proc.dumpPackageProcCheckin(pw, pkgName, uid, vers, pkgState.mProcesses.keyAt(iproc), now);
}
for (int isvc = 0; isvc < NSRVS; isvc++) {
final String serviceName = DumpUtils.collapseString(pkgName, pkgState.mServices.keyAt(isvc));
final ServiceState svc = pkgState.mServices.valueAt(isvc);
svc.dumpTimesCheckin(pw, pkgName, uid, vers, serviceName, now);
}
}
}
}
ArrayMap<String, SparseArray<ProcessState>> procMap = mProcesses.getMap();
for (int ip = 0; ip < procMap.size(); ip++) {
String procName = procMap.keyAt(ip);
SparseArray<ProcessState> uids = procMap.valueAt(ip);
for (int iu = 0; iu < uids.size(); iu++) {
final int uid = uids.keyAt(iu);
final ProcessState procState = uids.valueAt(iu);
procState.dumpProcCheckin(pw, procName, uid, now);
}
}
pw.print("total");
DumpUtils.dumpAdjTimesCheckin(pw, ",", mMemFactorDurations, mMemFactor, mStartTime, now);
pw.println();
final int sysMemUsageCount = mSysMemUsage.getKeyCount();
if (sysMemUsageCount > 0) {
pw.print("sysmemusage");
for (int i = 0; i < sysMemUsageCount; i++) {
final int key = mSysMemUsage.getKeyAt(i);
final int type = SparseMappingTable.getIdFromKey(key);
pw.print(",");
DumpUtils.printProcStateTag(pw, type);
for (int j = SYS_MEM_USAGE_SAMPLE_COUNT; j < SYS_MEM_USAGE_COUNT; j++) {
if (j > SYS_MEM_USAGE_CACHED_MINIMUM) {
pw.print(":");
}
pw.print(mSysMemUsage.getValue(key, j));
}
}
}
pw.println();
TotalMemoryUseCollection totalMem = new TotalMemoryUseCollection(ALL_SCREEN_ADJ, ALL_MEM_ADJ);
computeTotalMemoryUse(totalMem, now);
pw.print("weights,");
pw.print(totalMem.totalTime);
pw.print(",");
pw.print(totalMem.sysMemCachedWeight);
pw.print(":");
pw.print(totalMem.sysMemSamples);
pw.print(",");
pw.print(totalMem.sysMemFreeWeight);
pw.print(":");
pw.print(totalMem.sysMemSamples);
pw.print(",");
pw.print(totalMem.sysMemZRamWeight);
pw.print(":");
pw.print(totalMem.sysMemSamples);
pw.print(",");
pw.print(totalMem.sysMemKernelWeight);
pw.print(":");
pw.print(totalMem.sysMemSamples);
pw.print(",");
pw.print(totalMem.sysMemNativeWeight);
pw.print(":");
pw.print(totalMem.sysMemSamples);
for (int i = 0; i < STATE_COUNT; i++) {
pw.print(",");
pw.print(totalMem.processStateWeight[i]);
pw.print(":");
pw.print(totalMem.processStateSamples[i]);
}
pw.println();
final int NPAGETYPES = mPageTypeLabels.size();
for (int i = 0; i < NPAGETYPES; i++) {
pw.print("availablepages,");
pw.print(mPageTypeLabels.get(i));
pw.print(",");
pw.print(mPageTypeZones.get(i));
pw.print(",");
final int[] sizes = mPageTypeSizes.get(i);
final int N = sizes == null ? 0 : sizes.length;
for (int j = 0; j < N; j++) {
if (j != 0) {
pw.print(",");
}
pw.print(sizes[j]);
}
pw.println();
}
}
use of android.util.SparseArray in project android_frameworks_base by DirtyUnicorns.
the class ProcessStats method writeToParcel.
/** @hide */
public void writeToParcel(Parcel out, long now, int flags) {
out.writeInt(MAGIC);
out.writeInt(PARCEL_VERSION);
out.writeInt(STATE_COUNT);
out.writeInt(ADJ_COUNT);
out.writeInt(PSS_COUNT);
out.writeInt(SYS_MEM_USAGE_COUNT);
out.writeInt(SparseMappingTable.ARRAY_SIZE);
mCommonStringToIndex = new ArrayMap<String, Integer>(mProcesses.size());
// First commit all running times.
ArrayMap<String, SparseArray<ProcessState>> procMap = mProcesses.getMap();
final int NPROC = procMap.size();
for (int ip = 0; ip < NPROC; ip++) {
SparseArray<ProcessState> uids = procMap.valueAt(ip);
final int NUID = uids.size();
for (int iu = 0; iu < NUID; iu++) {
uids.valueAt(iu).commitStateTime(now);
}
}
final ArrayMap<String, SparseArray<SparseArray<PackageState>>> pkgMap = mPackages.getMap();
final int NPKG = pkgMap.size();
for (int ip = 0; ip < NPKG; ip++) {
final SparseArray<SparseArray<PackageState>> uids = pkgMap.valueAt(ip);
final int NUID = uids.size();
for (int iu = 0; iu < NUID; iu++) {
final SparseArray<PackageState> vpkgs = uids.valueAt(iu);
final int NVERS = vpkgs.size();
for (int iv = 0; iv < NVERS; iv++) {
PackageState pkgState = vpkgs.valueAt(iv);
final int NPROCS = pkgState.mProcesses.size();
for (int iproc = 0; iproc < NPROCS; iproc++) {
ProcessState proc = pkgState.mProcesses.valueAt(iproc);
if (proc.getCommonProcess() != proc) {
proc.commitStateTime(now);
}
}
final int NSRVS = pkgState.mServices.size();
for (int isvc = 0; isvc < NSRVS; isvc++) {
pkgState.mServices.valueAt(isvc).commitStateTime(now);
}
}
}
}
out.writeLong(mTimePeriodStartClock);
out.writeLong(mTimePeriodStartRealtime);
out.writeLong(mTimePeriodEndRealtime);
out.writeLong(mTimePeriodStartUptime);
out.writeLong(mTimePeriodEndUptime);
out.writeString(mRuntime);
out.writeInt(mHasSwappedOutPss ? 1 : 0);
out.writeInt(mFlags);
mTableData.writeToParcel(out);
if (mMemFactor != STATE_NOTHING) {
mMemFactorDurations[mMemFactor] += now - mStartTime;
mStartTime = now;
}
writeCompactedLongArray(out, mMemFactorDurations, mMemFactorDurations.length);
mSysMemUsage.writeToParcel(out);
out.writeInt(NPROC);
for (int ip = 0; ip < NPROC; ip++) {
writeCommonString(out, procMap.keyAt(ip));
final SparseArray<ProcessState> uids = procMap.valueAt(ip);
final int NUID = uids.size();
out.writeInt(NUID);
for (int iu = 0; iu < NUID; iu++) {
out.writeInt(uids.keyAt(iu));
final ProcessState proc = uids.valueAt(iu);
writeCommonString(out, proc.getPackage());
out.writeInt(proc.getVersion());
proc.writeToParcel(out, now);
}
}
out.writeInt(NPKG);
for (int ip = 0; ip < NPKG; ip++) {
writeCommonString(out, pkgMap.keyAt(ip));
final SparseArray<SparseArray<PackageState>> uids = pkgMap.valueAt(ip);
final int NUID = uids.size();
out.writeInt(NUID);
for (int iu = 0; iu < NUID; iu++) {
out.writeInt(uids.keyAt(iu));
final SparseArray<PackageState> vpkgs = uids.valueAt(iu);
final int NVERS = vpkgs.size();
out.writeInt(NVERS);
for (int iv = 0; iv < NVERS; iv++) {
out.writeInt(vpkgs.keyAt(iv));
final PackageState pkgState = vpkgs.valueAt(iv);
final int NPROCS = pkgState.mProcesses.size();
out.writeInt(NPROCS);
for (int iproc = 0; iproc < NPROCS; iproc++) {
writeCommonString(out, pkgState.mProcesses.keyAt(iproc));
final ProcessState proc = pkgState.mProcesses.valueAt(iproc);
if (proc.getCommonProcess() == proc) {
// This is the same as the common process we wrote above.
out.writeInt(0);
} else {
// There is separate data for this package's process.
out.writeInt(1);
proc.writeToParcel(out, now);
}
}
final int NSRVS = pkgState.mServices.size();
out.writeInt(NSRVS);
for (int isvc = 0; isvc < NSRVS; isvc++) {
out.writeString(pkgState.mServices.keyAt(isvc));
final ServiceState svc = pkgState.mServices.valueAt(isvc);
writeCommonString(out, svc.getProcessName());
svc.writeToParcel(out, now);
}
}
}
}
// Fragmentation info (/proc/pagetypeinfo)
final int NPAGETYPES = mPageTypeLabels.size();
out.writeInt(NPAGETYPES);
for (int i = 0; i < NPAGETYPES; i++) {
out.writeInt(mPageTypeZones.get(i));
out.writeString(mPageTypeLabels.get(i));
out.writeIntArray(mPageTypeSizes.get(i));
}
mCommonStringToIndex = null;
}
use of android.util.SparseArray in project android_frameworks_base by DirtyUnicorns.
the class ProcessStats method collectProcessesLocked.
public ArrayList<ProcessState> collectProcessesLocked(int[] screenStates, int[] memStates, int[] procStates, int[] sortProcStates, long now, String reqPackage, boolean activeOnly) {
final ArraySet<ProcessState> foundProcs = new ArraySet<ProcessState>();
final ArrayMap<String, SparseArray<SparseArray<PackageState>>> pkgMap = mPackages.getMap();
for (int ip = 0; ip < pkgMap.size(); ip++) {
final String pkgName = pkgMap.keyAt(ip);
final SparseArray<SparseArray<PackageState>> procs = pkgMap.valueAt(ip);
for (int iu = 0; iu < procs.size(); iu++) {
final SparseArray<PackageState> vpkgs = procs.valueAt(iu);
final int NVERS = vpkgs.size();
for (int iv = 0; iv < NVERS; iv++) {
final PackageState state = vpkgs.valueAt(iv);
final int NPROCS = state.mProcesses.size();
final boolean pkgMatch = reqPackage == null || reqPackage.equals(pkgName);
for (int iproc = 0; iproc < NPROCS; iproc++) {
final ProcessState proc = state.mProcesses.valueAt(iproc);
if (!pkgMatch && !reqPackage.equals(proc.getName())) {
continue;
}
if (activeOnly && !proc.isInUse()) {
continue;
}
foundProcs.add(proc.getCommonProcess());
}
}
}
}
ArrayList<ProcessState> outProcs = new ArrayList<ProcessState>(foundProcs.size());
for (int i = 0; i < foundProcs.size(); i++) {
ProcessState proc = foundProcs.valueAt(i);
if (proc.computeProcessTimeLocked(screenStates, memStates, procStates, now) > 0) {
outProcs.add(proc);
if (procStates != sortProcStates) {
proc.computeProcessTimeLocked(screenStates, memStates, sortProcStates, now);
}
}
}
Collections.sort(outProcs, ProcessState.COMPARATOR);
return outProcs;
}
use of android.util.SparseArray in project android_frameworks_base by DirtyUnicorns.
the class ManagedServices method rebindServices.
/**
* Called whenever packages change, the user switches, or the secure setting
* is altered. (For example in response to USER_SWITCHED in our broadcast receiver)
*/
private void rebindServices(boolean forceRebind) {
if (DEBUG)
Slog.d(TAG, "rebindServices");
final int[] userIds = mUserProfiles.getCurrentProfileIds();
final int nUserIds = userIds.length;
final SparseArray<ArraySet<ComponentName>> componentsByUser = new SparseArray<>();
for (int i = 0; i < nUserIds; ++i) {
componentsByUser.put(userIds[i], loadComponentNamesFromSetting(mConfig.secureSettingName, userIds[i]));
if (mConfig.secondarySettingName != null) {
componentsByUser.get(userIds[i]).addAll(loadComponentNamesFromSetting(mConfig.secondarySettingName, userIds[i]));
}
}
final ArrayList<ManagedServiceInfo> removableBoundServices = new ArrayList<>();
final SparseArray<Set<ComponentName>> toAdd = new SparseArray<>();
synchronized (mMutex) {
// Rebind to non-system services if user switched
for (ManagedServiceInfo service : mServices) {
if (!service.isSystem && !service.isGuest(this)) {
removableBoundServices.add(service);
}
}
mEnabledServicesForCurrentProfiles.clear();
mEnabledServicesPackageNames.clear();
for (int i = 0; i < nUserIds; ++i) {
// decode the list of components
final ArraySet<ComponentName> userComponents = componentsByUser.get(userIds[i]);
if (null == userComponents) {
toAdd.put(userIds[i], new ArraySet<ComponentName>());
continue;
}
final Set<ComponentName> add = new HashSet<>(userComponents);
add.removeAll(mSnoozingForCurrentProfiles);
toAdd.put(userIds[i], add);
mEnabledServicesForCurrentProfiles.addAll(userComponents);
for (int j = 0; j < userComponents.size(); j++) {
final ComponentName component = userComponents.valueAt(j);
mEnabledServicesPackageNames.add(component.getPackageName());
}
}
}
for (ManagedServiceInfo info : removableBoundServices) {
final ComponentName component = info.component;
final int oldUser = info.userid;
final Set<ComponentName> allowedComponents = toAdd.get(info.userid);
if (allowedComponents != null) {
if (allowedComponents.contains(component) && !forceRebind) {
// Already bound, don't need to bind again.
allowedComponents.remove(component);
} else {
// No longer allowed to be bound, or must rebind.
Slog.v(TAG, "disabling " + getCaption() + " for user " + oldUser + ": " + component);
unregisterService(component, oldUser);
}
}
}
for (int i = 0; i < nUserIds; ++i) {
final Set<ComponentName> add = toAdd.get(userIds[i]);
for (ComponentName component : add) {
Slog.v(TAG, "enabling " + getCaption() + " for " + userIds[i] + ": " + component);
registerService(component, userIds[i]);
}
}
mLastSeenProfileIds = userIds;
}
Aggregations