Search in sources :

Example 1 with ServiceState

use of com.android.internal.app.procstats.ServiceState in project platform_frameworks_base by android.

the class ActiveServices method bumpServiceExecutingLocked.

private final void bumpServiceExecutingLocked(ServiceRecord r, boolean fg, String why) {
    if (DEBUG_SERVICE)
        Slog.v(TAG_SERVICE, ">>> EXECUTING " + why + " of " + r + " in app " + r.app);
    else if (DEBUG_SERVICE_EXECUTING)
        Slog.v(TAG_SERVICE_EXECUTING, ">>> EXECUTING " + why + " of " + r.shortName);
    long now = SystemClock.uptimeMillis();
    if (r.executeNesting == 0) {
        r.executeFg = fg;
        ServiceState stracker = r.getTracker();
        if (stracker != null) {
            stracker.setExecuting(true, mAm.mProcessStats.getMemFactorLocked(), now);
        }
        if (r.app != null) {
            r.app.executingServices.add(r);
            r.app.execServicesFg |= fg;
            if (r.app.executingServices.size() == 1) {
                scheduleServiceTimeoutLocked(r.app);
            }
        }
    } else if (r.app != null && fg && !r.app.execServicesFg) {
        r.app.execServicesFg = true;
        scheduleServiceTimeoutLocked(r.app);
    }
    r.executeFg |= fg;
    r.executeNesting++;
    r.executingStart = now;
}
Also used : ServiceState(com.android.internal.app.procstats.ServiceState)

Example 2 with ServiceState

use of com.android.internal.app.procstats.ServiceState in project platform_frameworks_base by android.

the class ActiveServices method startServiceInnerLocked.

ComponentName startServiceInnerLocked(ServiceMap smap, Intent service, ServiceRecord r, boolean callerFg, boolean addToStarting) throws TransactionTooLargeException {
    ServiceState stracker = r.getTracker();
    if (stracker != null) {
        stracker.setStarted(true, mAm.mProcessStats.getMemFactorLocked(), r.lastActivity);
    }
    r.callStart = false;
    synchronized (r.stats.getBatteryStats()) {
        r.stats.startRunningLocked();
    }
    String error = bringUpServiceLocked(r, service.getFlags(), callerFg, false, false);
    if (error != null) {
        return new ComponentName("!!", error);
    }
    if (r.startRequested && addToStarting) {
        boolean first = smap.mStartingBackground.size() == 0;
        smap.mStartingBackground.add(r);
        r.startingBgTimeout = SystemClock.uptimeMillis() + BG_START_TIMEOUT;
        if (DEBUG_DELAYED_SERVICE) {
            RuntimeException here = new RuntimeException("here");
            here.fillInStackTrace();
            Slog.v(TAG_SERVICE, "Starting background (first=" + first + "): " + r, here);
        } else if (DEBUG_DELAYED_STARTS) {
            Slog.v(TAG_SERVICE, "Starting background (first=" + first + "): " + r);
        }
        if (first) {
            smap.rescheduleDelayedStarts();
        }
    } else if (callerFg) {
        smap.ensureNotStartingBackground(r);
    }
    return r.name;
}
Also used : ServiceState(com.android.internal.app.procstats.ServiceState) ComponentName(android.content.ComponentName)

Example 3 with ServiceState

use of com.android.internal.app.procstats.ServiceState in project platform_frameworks_base by android.

the class ProcessStatsService method setMemFactorLocked.

public boolean setMemFactorLocked(int memFactor, boolean screenOn, long now) {
    mMemFactorLowered = memFactor < mLastMemOnlyState;
    mLastMemOnlyState = memFactor;
    if (screenOn) {
        memFactor += ProcessStats.ADJ_SCREEN_ON;
    }
    if (memFactor != mProcessStats.mMemFactor) {
        if (mProcessStats.mMemFactor != ProcessStats.STATE_NOTHING) {
            mProcessStats.mMemFactorDurations[mProcessStats.mMemFactor] += now - mProcessStats.mStartTime;
        }
        mProcessStats.mMemFactor = memFactor;
        mProcessStats.mStartTime = now;
        final ArrayMap<String, SparseArray<SparseArray<ProcessStats.PackageState>>> pmap = mProcessStats.mPackages.getMap();
        for (int ipkg = pmap.size() - 1; ipkg >= 0; ipkg--) {
            final SparseArray<SparseArray<ProcessStats.PackageState>> uids = pmap.valueAt(ipkg);
            for (int iuid = uids.size() - 1; iuid >= 0; iuid--) {
                final SparseArray<ProcessStats.PackageState> vers = uids.valueAt(iuid);
                for (int iver = vers.size() - 1; iver >= 0; iver--) {
                    final ProcessStats.PackageState pkg = vers.valueAt(iver);
                    final ArrayMap<String, ServiceState> services = pkg.mServices;
                    for (int isvc = services.size() - 1; isvc >= 0; isvc--) {
                        final ServiceState service = services.valueAt(isvc);
                        service.setMemFactor(memFactor, now);
                    }
                }
            }
        }
        return true;
    }
    return false;
}
Also used : SparseArray(android.util.SparseArray) IProcessStats(com.android.internal.app.procstats.IProcessStats) ProcessStats(com.android.internal.app.procstats.ProcessStats) ServiceState(com.android.internal.app.procstats.ServiceState)

Example 4 with ServiceState

use of com.android.internal.app.procstats.ServiceState in project platform_frameworks_base by android.

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;
}
Also used : ServiceState(com.android.internal.app.procstats.ServiceState) ProcessState(com.android.internal.app.procstats.ProcessState) SparseArray(android.util.SparseArray)

Example 5 with ServiceState

use of com.android.internal.app.procstats.ServiceState in project platform_frameworks_base by android.

the class ProcessStats method getServiceStateLocked.

public ServiceState getServiceStateLocked(String packageName, int uid, int vers, String processName, String className) {
    final ProcessStats.PackageState as = getPackageStateLocked(packageName, uid, vers);
    ServiceState ss = as.mServices.get(className);
    if (ss != null) {
        if (DEBUG)
            Slog.d(TAG, "GETSVC: returning existing " + ss);
        return ss;
    }
    final ProcessState ps = processName != null ? getProcessStateLocked(packageName, uid, vers, processName) : null;
    ss = new ServiceState(this, packageName, className, processName, ps);
    as.mServices.put(className, ss);
    if (DEBUG)
        Slog.d(TAG, "GETSVC: creating " + ss + " in " + ps);
    return ss;
}
Also used : ProcessState(com.android.internal.app.procstats.ProcessState) ServiceState(com.android.internal.app.procstats.ServiceState)

Aggregations

ServiceState (com.android.internal.app.procstats.ServiceState)61 ProcessState (com.android.internal.app.procstats.ProcessState)41 SparseArray (android.util.SparseArray)31 IProcessStats (com.android.internal.app.procstats.IProcessStats)6 ProcessStats (com.android.internal.app.procstats.ProcessStats)6 ArrayList (java.util.ArrayList)6 PendingIntent (android.app.PendingIntent)5 ComponentName (android.content.ComponentName)5 Intent (android.content.Intent)5 Bundle (android.os.Bundle)5 DeadObjectException (android.os.DeadObjectException)5 IBinder (android.os.IBinder)5 RemoteCallback (android.os.RemoteCallback)5 RemoteException (android.os.RemoteException)5 TransactionTooLargeException (android.os.TransactionTooLargeException)5 UserHandle (android.os.UserHandle)5 IOException (java.io.IOException)5 ProcessMap (com.android.internal.app.ProcessMap)1