Java Code Examples for android.app.activitymanager#PROCESS_STATE_NONEXISTENT

The following examples show how to use android.app.activitymanager#PROCESS_STATE_NONEXISTENT . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ContentService.java    From android_9.0.0_r45 with Apache License 2.0 6 votes vote down vote up
@SyncExemption
private int getSyncExemptionAndCleanUpExtrasForCaller(int callingUid, Bundle extras) {
    if (extras != null) {
        final int exemption =
                extras.getInt(ContentResolver.SYNC_VIRTUAL_EXTRAS_EXEMPTION_FLAG, -1);

        // Need to remove the virtual extra.
        extras.remove(ContentResolver.SYNC_VIRTUAL_EXTRAS_EXEMPTION_FLAG);
        if (exemption != -1) {
            return exemption;
        }
    }
    final ActivityManagerInternal ami =
            LocalServices.getService(ActivityManagerInternal.class);
    final int procState = (ami != null)
            ? ami.getUidProcessState(callingUid)
            : ActivityManager.PROCESS_STATE_NONEXISTENT;

    if (procState <= ActivityManager.PROCESS_STATE_TOP) {
        return ContentResolver.SYNC_EXEMPTION_PROMOTE_BUCKET_WITH_TEMP;
    }
    if (procState <= ActivityManager.PROCESS_STATE_IMPORTANT_FOREGROUND) {
        return ContentResolver.SYNC_EXEMPTION_PROMOTE_BUCKET;
    }
    return ContentResolver.SYNC_EXEMPTION_NONE;
}
 
Example 2
Source File: PowerManagerService.java    From android_9.0.0_r45 with Apache License 2.0 5 votes vote down vote up
private void removeWakeLockLocked(WakeLock wakeLock, int index) {
    mWakeLocks.remove(index);
    UidState state = wakeLock.mUidState;
    state.mNumWakeLocks--;
    if (state.mNumWakeLocks <= 0 &&
            state.mProcState == ActivityManager.PROCESS_STATE_NONEXISTENT) {
        mUidState.remove(state.mUid);
    }
    notifyWakeLockReleasedLocked(wakeLock);

    applyWakeLockFlagsOnReleaseLocked(wakeLock);
    mDirty |= DIRTY_WAKE_LOCKS;
    updatePowerStateLocked();
}
 
Example 3
Source File: PowerManagerService.java    From android_9.0.0_r45 with Apache License 2.0 5 votes vote down vote up
void uidGoneInternal(int uid) {
    synchronized (mLock) {
        final int index = mUidState.indexOfKey(uid);
        if (index >= 0) {
            UidState state = mUidState.valueAt(index);
            state.mProcState = ActivityManager.PROCESS_STATE_NONEXISTENT;
            state.mActive = false;
            mUidState.removeAt(index);
            if (mDeviceIdleMode && state.mNumWakeLocks > 0) {
                handleUidStateChangeLocked();
            }
        }
    }
}
 
Example 4
Source File: PowerManagerService.java    From android_9.0.0_r45 with Apache License 2.0 5 votes vote down vote up
private boolean setWakeLockDisabledStateLocked(WakeLock wakeLock) {
    if ((wakeLock.mFlags & PowerManager.WAKE_LOCK_LEVEL_MASK)
            == PowerManager.PARTIAL_WAKE_LOCK) {
        boolean disabled = false;
        final int appid = UserHandle.getAppId(wakeLock.mOwnerUid);
        if (appid >= Process.FIRST_APPLICATION_UID) {
            // Cached inactive processes are never allowed to hold wake locks.
            if (mConstants.NO_CACHED_WAKE_LOCKS) {
                disabled = !wakeLock.mUidState.mActive &&
                        wakeLock.mUidState.mProcState
                                != ActivityManager.PROCESS_STATE_NONEXISTENT &&
                        wakeLock.mUidState.mProcState > ActivityManager.PROCESS_STATE_RECEIVER;
            }
            if (mDeviceIdleMode) {
                // If we are in idle mode, we will also ignore all partial wake locks that are
                // for application uids that are not whitelisted.
                final UidState state = wakeLock.mUidState;
                if (Arrays.binarySearch(mDeviceIdleWhitelist, appid) < 0 &&
                        Arrays.binarySearch(mDeviceIdleTempWhitelist, appid) < 0 &&
                        state.mProcState != ActivityManager.PROCESS_STATE_NONEXISTENT &&
                        state.mProcState >
                                ActivityManager.PROCESS_STATE_BOUND_FOREGROUND_SERVICE) {
                    disabled = true;
                }
            }
        }
        if (wakeLock.mDisabled != disabled) {
            wakeLock.mDisabled = disabled;
            return true;
        }
    }
    return false;
}
 
Example 5
Source File: PowerManagerService.java    From android_9.0.0_r45 with Apache License 2.0 4 votes vote down vote up
private void acquireWakeLockInternal(IBinder lock, int flags, String tag, String packageName,
        WorkSource ws, String historyTag, int uid, int pid) {
    synchronized (mLock) {
        if (DEBUG_SPEW) {
            Slog.d(TAG, "acquireWakeLockInternal: lock=" + Objects.hashCode(lock)
                    + ", flags=0x" + Integer.toHexString(flags)
                    + ", tag=\"" + tag + "\", ws=" + ws + ", uid=" + uid + ", pid=" + pid);
        }

        WakeLock wakeLock;
        int index = findWakeLockIndexLocked(lock);
        boolean notifyAcquire;
        if (index >= 0) {
            wakeLock = mWakeLocks.get(index);
            if (!wakeLock.hasSameProperties(flags, tag, ws, uid, pid)) {
                // Update existing wake lock.  This shouldn't happen but is harmless.
                notifyWakeLockChangingLocked(wakeLock, flags, tag, packageName,
                        uid, pid, ws, historyTag);
                wakeLock.updateProperties(flags, tag, packageName, ws, historyTag, uid, pid);
            }
            notifyAcquire = false;
        } else {
            UidState state = mUidState.get(uid);
            if (state == null) {
                state = new UidState(uid);
                state.mProcState = ActivityManager.PROCESS_STATE_NONEXISTENT;
                mUidState.put(uid, state);
            }
            state.mNumWakeLocks++;
            wakeLock = new WakeLock(lock, flags, tag, packageName, ws, historyTag, uid, pid,
                    state);
            try {
                lock.linkToDeath(wakeLock, 0);
            } catch (RemoteException ex) {
                throw new IllegalArgumentException("Wake lock is already dead.");
            }
            mWakeLocks.add(wakeLock);
            setWakeLockDisabledStateLocked(wakeLock);
            notifyAcquire = true;
        }

        applyWakeLockFlagsOnAcquireLocked(wakeLock, uid);
        mDirty |= DIRTY_WAKE_LOCKS;
        updatePowerStateLocked();
        if (notifyAcquire) {
            // This needs to be done last so we are sure we have acquired the
            // kernel wake lock.  Otherwise we have a race where the system may
            // go to sleep between the time we start the accounting in battery
            // stats and when we actually get around to telling the kernel to
            // stay awake.
            notifyWakeLockAcquiredLocked(wakeLock);
        }
    }
}
 
Example 6
Source File: ProcessList.java    From android_9.0.0_r45 with Apache License 2.0 4 votes vote down vote up
public static String makeProcStateString(int curProcState) {
    String procState;
    switch (curProcState) {
        case ActivityManager.PROCESS_STATE_PERSISTENT:
            procState = "PER ";
            break;
        case ActivityManager.PROCESS_STATE_PERSISTENT_UI:
            procState = "PERU";
            break;
        case ActivityManager.PROCESS_STATE_TOP:
            procState = "TOP ";
            break;
        case ActivityManager.PROCESS_STATE_FOREGROUND_SERVICE:
            procState = "FGS ";
            break;
        case ActivityManager.PROCESS_STATE_BOUND_FOREGROUND_SERVICE:
            procState = "BFGS";
            break;
        case ActivityManager.PROCESS_STATE_IMPORTANT_FOREGROUND:
            procState = "IMPF";
            break;
        case ActivityManager.PROCESS_STATE_IMPORTANT_BACKGROUND:
            procState = "IMPB";
            break;
        case ActivityManager.PROCESS_STATE_TRANSIENT_BACKGROUND:
            procState = "TRNB";
            break;
        case ActivityManager.PROCESS_STATE_BACKUP:
            procState = "BKUP";
            break;
        case ActivityManager.PROCESS_STATE_SERVICE:
            procState = "SVC ";
            break;
        case ActivityManager.PROCESS_STATE_RECEIVER:
            procState = "RCVR";
            break;
        case ActivityManager.PROCESS_STATE_TOP_SLEEPING:
            procState = "TPSL";
            break;
        case ActivityManager.PROCESS_STATE_HEAVY_WEIGHT:
            procState = "HVY ";
            break;
        case ActivityManager.PROCESS_STATE_HOME:
            procState = "HOME";
            break;
        case ActivityManager.PROCESS_STATE_LAST_ACTIVITY:
            procState = "LAST";
            break;
        case ActivityManager.PROCESS_STATE_CACHED_ACTIVITY:
            procState = "CAC ";
            break;
        case ActivityManager.PROCESS_STATE_CACHED_ACTIVITY_CLIENT:
            procState = "CACC";
            break;
        case ActivityManager.PROCESS_STATE_CACHED_RECENT:
            procState = "CRE ";
            break;
        case ActivityManager.PROCESS_STATE_CACHED_EMPTY:
            procState = "CEM ";
            break;
        case ActivityManager.PROCESS_STATE_NONEXISTENT:
            procState = "NONE";
            break;
        default:
            procState = "??";
            break;
    }
    return procState;
}
 
Example 7
Source File: ProcessList.java    From android_9.0.0_r45 with Apache License 2.0 4 votes vote down vote up
public static int makeProcStateProtoEnum(int curProcState) {
    switch (curProcState) {
        case ActivityManager.PROCESS_STATE_PERSISTENT:
            return AppProtoEnums.PROCESS_STATE_PERSISTENT;
        case ActivityManager.PROCESS_STATE_PERSISTENT_UI:
            return AppProtoEnums.PROCESS_STATE_PERSISTENT_UI;
        case ActivityManager.PROCESS_STATE_TOP:
            return AppProtoEnums.PROCESS_STATE_TOP;
        case ActivityManager.PROCESS_STATE_BOUND_FOREGROUND_SERVICE:
            return AppProtoEnums.PROCESS_STATE_BOUND_FOREGROUND_SERVICE;
        case ActivityManager.PROCESS_STATE_FOREGROUND_SERVICE:
            return AppProtoEnums.PROCESS_STATE_FOREGROUND_SERVICE;
        case ActivityManager.PROCESS_STATE_TOP_SLEEPING:
            return AppProtoEnums.PROCESS_STATE_TOP_SLEEPING;
        case ActivityManager.PROCESS_STATE_IMPORTANT_FOREGROUND:
            return AppProtoEnums.PROCESS_STATE_IMPORTANT_FOREGROUND;
        case ActivityManager.PROCESS_STATE_IMPORTANT_BACKGROUND:
            return AppProtoEnums.PROCESS_STATE_IMPORTANT_BACKGROUND;
        case ActivityManager.PROCESS_STATE_TRANSIENT_BACKGROUND:
            return AppProtoEnums.PROCESS_STATE_TRANSIENT_BACKGROUND;
        case ActivityManager.PROCESS_STATE_BACKUP:
            return AppProtoEnums.PROCESS_STATE_BACKUP;
        case ActivityManager.PROCESS_STATE_HEAVY_WEIGHT:
            return AppProtoEnums.PROCESS_STATE_HEAVY_WEIGHT;
        case ActivityManager.PROCESS_STATE_SERVICE:
            return AppProtoEnums.PROCESS_STATE_SERVICE;
        case ActivityManager.PROCESS_STATE_RECEIVER:
            return AppProtoEnums.PROCESS_STATE_RECEIVER;
        case ActivityManager.PROCESS_STATE_HOME:
            return AppProtoEnums.PROCESS_STATE_HOME;
        case ActivityManager.PROCESS_STATE_LAST_ACTIVITY:
            return AppProtoEnums.PROCESS_STATE_LAST_ACTIVITY;
        case ActivityManager.PROCESS_STATE_CACHED_ACTIVITY:
            return AppProtoEnums.PROCESS_STATE_CACHED_ACTIVITY;
        case ActivityManager.PROCESS_STATE_CACHED_ACTIVITY_CLIENT:
            return AppProtoEnums.PROCESS_STATE_CACHED_ACTIVITY_CLIENT;
        case ActivityManager.PROCESS_STATE_CACHED_RECENT:
            return AppProtoEnums.PROCESS_STATE_CACHED_RECENT;
        case ActivityManager.PROCESS_STATE_CACHED_EMPTY:
            return AppProtoEnums.PROCESS_STATE_CACHED_EMPTY;
        case ActivityManager.PROCESS_STATE_NONEXISTENT:
            return AppProtoEnums.PROCESS_STATE_NONEXISTENT;
        case ActivityManager.PROCESS_STATE_UNKNOWN:
            return AppProtoEnums.PROCESS_STATE_UNKNOWN;
        default:
            return AppProtoEnums.PROCESS_STATE_UNKNOWN_TO_PROTO;
    }
}