Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 46c2a56f authored by Hui Yu's avatar Hui Yu Committed by Android (Google) Code Review
Browse files

Merge "UsageStats DEVICE_SHUTDOWN event."

parents ca42e48c b1d243a5
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -7682,6 +7682,7 @@ package android.app.usage {
    field public static final int ACTIVITY_RESUMED = 1; // 0x1
    field public static final int ACTIVITY_STOPPED = 23; // 0x17
    field public static final int CONFIGURATION_CHANGE = 5; // 0x5
    field public static final int DEVICE_SHUTDOWN = 26; // 0x1a
    field public static final int FOREGROUND_SERVICE_START = 19; // 0x13
    field public static final int FOREGROUND_SERVICE_STOP = 20; // 0x14
    field public static final int KEYGUARD_HIDDEN = 18; // 0x12
+6 −0
Original line number Diff line number Diff line
@@ -320,4 +320,10 @@ public abstract class ActivityManagerInternal {

    /** Remove pending backup for the given userId. */
    public abstract void clearPendingBackup(int userId);

    /**
     * When power button is very long pressed, call this interface to do some pre-shutdown work
     * like persisting database etc.
     */
    public abstract void prepareForPossibleShutdown();
}
+0 −17
Original line number Diff line number Diff line
@@ -103,21 +103,4 @@ public class EventList {
        }
        return result;
    }

    /**
     * Remove events of certain type on or after a timestamp.
     * @param type The type of event to remove.
     * @param timeStamp the timeStamp on or after which to remove the event.
     */
    public void removeOnOrAfter(int type, long timeStamp) {
        for (int i = mEvents.size() - 1; i >= 0; i--) {
            UsageEvents.Event event = mEvents.get(i);
            if (event.mTimeStamp < timeStamp) {
                break;
            }
            if (event.mEventType == type) {
                mEvents.remove(i);
            }
        }
    }
}
+9 −1
Original line number Diff line number Diff line
@@ -244,11 +244,19 @@ public final class UsageEvents implements Parcelable {
         */
        public static final int FLUSH_TO_DISK = 25;

        /**
         * An event type denoting that the device underwent a shutdown process.
         * A DEVICE_SHUTDOWN event should be treated as if all started activities and foreground
         * services are now stopped and no explicit {@link #ACTIVITY_STOPPED} and
         * {@link #FOREGROUND_SERVICE_STOP} events will be generated for them.
         */
        public static final int DEVICE_SHUTDOWN = 26;

        /**
         * Keep in sync with the greatest event type value.
         * @hide
         */
        public static final int MAX_EVENT_TYPE = 25;
        public static final int MAX_EVENT_TYPE = 26;

        /** @hide */
        public static final int FLAG_IS_PACKAGE_INSTANT_APP = 1 << 0;
+4 −5
Original line number Diff line number Diff line
@@ -21,6 +21,7 @@ import static android.app.usage.UsageEvents.Event.ACTIVITY_PAUSED;
import static android.app.usage.UsageEvents.Event.ACTIVITY_RESUMED;
import static android.app.usage.UsageEvents.Event.ACTIVITY_STOPPED;
import static android.app.usage.UsageEvents.Event.CONTINUING_FOREGROUND_SERVICE;
import static android.app.usage.UsageEvents.Event.DEVICE_SHUTDOWN;
import static android.app.usage.UsageEvents.Event.END_OF_DAY;
import static android.app.usage.UsageEvents.Event.FLUSH_TO_DISK;
import static android.app.usage.UsageEvents.Event.FOREGROUND_SERVICE_START;
@@ -119,12 +120,9 @@ public final class UsageStats implements Parcelable {
    public int mLastEvent;

    /**
     * If an activity is visible(onStart(), onPause() states) or in foreground (onResume() state),
     * it has one entry in this map. When an activity becomes invisible (onStop() or onDestroy()),
     * it is removed from this map.
     * Key is instanceId of the activity (ActivityRecode appToken hashCode)..
     * Value is this activity's last event, one of ACTIVITY_RESUMED or
     * ACTIVITY_PAUSED.
     * Value is this activity's last event, one of ACTIVITY_RESUMED, ACTIVITY_PAUSED or
     * ACTIVITY_STOPPED.
     * {@hide}
     */
    public SparseIntArray mActivities = new SparseIntArray();
@@ -560,6 +558,7 @@ public final class UsageStats implements Parcelable {
                mLastTimeForegroundServiceUsed = timeStamp;
                mForegroundServices.put(className, eventType);
                break;
            case DEVICE_SHUTDOWN:
            case FLUSH_TO_DISK:
                // update usage of all active activities/services.
                if (hasForegroundActivity()) {
Loading