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

Commit f781a3e5 authored by Android Build Merger (Role)'s avatar Android Build Merger (Role) Committed by Android (Google) Code Review
Browse files

Merge "Merge "Work on issue #74404949: Screen state usage API" into pi-dev am:...

Merge "Merge "Work on issue #74404949: Screen state usage API" into pi-dev am: 886fc6ae am: b45bc522"
parents a488d004 91359985
Loading
Loading
Loading
Loading
+3 −1
Original line number Diff line number Diff line
@@ -7360,8 +7360,8 @@ package android.app.usage {
    method public int getCount();
    method public int getEventType();
    method public long getFirstTimeStamp();
    method public long getLastEventTime();
    method public long getLastTimeStamp();
    method public long getLastTimeUsed();
    method public long getTotalTime();
    method public void writeToParcel(android.os.Parcel, int);
    field public static final android.os.Parcelable.Creator<android.app.usage.EventStats> CREATOR;
@@ -7469,6 +7469,8 @@ package android.app.usage {
    method public int getStandbyBucket();
    method public long getTimeStamp();
    field public static final int CONFIGURATION_CHANGE = 5; // 0x5
    field public static final int KEYGUARD_HIDDEN = 18; // 0x12
    field public static final int KEYGUARD_SHOWN = 17; // 0x11
    field public static final int MOVE_TO_BACKGROUND = 2; // 0x2
    field public static final int MOVE_TO_FOREGROUND = 1; // 0x1
    field public static final int NONE = 0; // 0x0
+8 −9
Original line number Diff line number Diff line
@@ -41,10 +41,9 @@ public final class EventStats implements Parcelable {
    public long mEndTimeStamp;

    /**
     * Last time used by the user with an explicit action (notification, activity launch).
     * {@hide}
     */
    public long mLastTimeUsed;
    public long mLastEventTime;

    /**
     * {@hide}
@@ -66,7 +65,7 @@ public final class EventStats implements Parcelable {
        mEventType = stats.mEventType;
        mBeginTimeStamp = stats.mBeginTimeStamp;
        mEndTimeStamp = stats.mEndTimeStamp;
        mLastTimeUsed = stats.mLastTimeUsed;
        mLastEventTime = stats.mLastEventTime;
        mTotalTime = stats.mTotalTime;
        mCount = stats.mCount;
    }
@@ -100,12 +99,12 @@ public final class EventStats implements Parcelable {
    }

    /**
     * Get the last time this event was used, measured in milliseconds since the epoch.
     * Get the last time this event triggered, measured in milliseconds since the epoch.
     * <p/>
     * See {@link System#currentTimeMillis()}.
     */
    public long getLastTimeUsed() {
        return mLastTimeUsed;
    public long getLastEventTime() {
        return mLastEventTime;
    }

    /**
@@ -138,7 +137,7 @@ public final class EventStats implements Parcelable {
        // We use the mBeginTimeStamp due to a bug where UsageStats files can overlap with
        // regards to their mEndTimeStamp.
        if (right.mBeginTimeStamp > mBeginTimeStamp) {
            mLastTimeUsed = Math.max(mLastTimeUsed, right.mLastTimeUsed);
            mLastEventTime = Math.max(mLastEventTime, right.mLastEventTime);
        }
        mBeginTimeStamp = Math.min(mBeginTimeStamp, right.mBeginTimeStamp);
        mEndTimeStamp = Math.max(mEndTimeStamp, right.mEndTimeStamp);
@@ -156,7 +155,7 @@ public final class EventStats implements Parcelable {
        dest.writeInt(mEventType);
        dest.writeLong(mBeginTimeStamp);
        dest.writeLong(mEndTimeStamp);
        dest.writeLong(mLastTimeUsed);
        dest.writeLong(mLastEventTime);
        dest.writeLong(mTotalTime);
        dest.writeInt(mCount);
    }
@@ -168,7 +167,7 @@ public final class EventStats implements Parcelable {
            stats.mEventType = in.readInt();
            stats.mBeginTimeStamp = in.readLong();
            stats.mEndTimeStamp = in.readLong();
            stats.mLastTimeUsed = in.readLong();
            stats.mLastEventTime = in.readLong();
            stats.mTotalTime = in.readLong();
            stats.mCount = in.readInt();
            return stats;
+12 −0
Original line number Diff line number Diff line
@@ -152,6 +152,18 @@ public final class UsageEvents implements Parcelable {
         */
        public static final int SCREEN_NON_INTERACTIVE = 16;

        /**
         * An event type denoting that the screen's keyguard has been shown, whether or not
         * the screen is off.
         */
        public static final int KEYGUARD_SHOWN = 17;

        /**
         * An event type denoting that the screen's keyguard has been hidden.  This typically
         * happens when the user unlocks their phone after turning it on.
         */
        public static final int KEYGUARD_HIDDEN = 18;

        /** @hide */
        public static final int FLAG_IS_PACKAGE_INSTANT_APP = 1 << 0;

+2 −0
Original line number Diff line number Diff line
@@ -319,6 +319,8 @@ public final class UsageStatsManager {
     * <ul>
     *     <li>{@link UsageEvents.Event#SCREEN_INTERACTIVE}</li>
     *     <li>{@link UsageEvents.Event#SCREEN_NON_INTERACTIVE}</li>
     *     <li>{@link UsageEvents.Event#KEYGUARD_SHOWN}</li>
     *     <li>{@link UsageEvents.Event#KEYGUARD_HIDDEN}</li>
     * </ul>
     *
     * <p> The caller must have {@link android.Manifest.permission#PACKAGE_USAGE_STATS} </p>
+15 −0
Original line number Diff line number Diff line
@@ -1529,6 +1529,11 @@ public class ActivityManagerService extends IActivityManager.Stub
     */
    private int mWakefulness = PowerManagerInternal.WAKEFULNESS_AWAKE;
    /**
     * State of external calls telling us if the device is awake or asleep.
     */
    private boolean mKeyguardShown = false;
    /**
     * Set if we are shutting down the system, similar to sleeping.
     */
@@ -12968,6 +12973,12 @@ public class ActivityManagerService extends IActivityManager.Stub
                : UsageEvents.Event.SCREEN_NON_INTERACTIVE);
    }
    void reportCurKeyguardUsageEventLocked() {
        reportGlobalUsageEventLocked(mKeyguardShown
                ? UsageEvents.Event.KEYGUARD_SHOWN
                : UsageEvents.Event.KEYGUARD_HIDDEN);
    }
    void onWakefulnessChanged(int wakefulness) {
        synchronized(this) {
            boolean wasAwake = mWakefulness == PowerManagerInternal.WAKEFULNESS_AWAKE;
@@ -13131,6 +13142,10 @@ public class ActivityManagerService extends IActivityManager.Stub
        synchronized(this) {
            long ident = Binder.clearCallingIdentity();
            if (mKeyguardShown != keyguardShowing) {
                mKeyguardShown = keyguardShowing;
                reportCurKeyguardUsageEventLocked();
            }
            try {
                mKeyguardController.setKeyguardShown(keyguardShowing, aodShowing,
                        secondaryDisplayShowing);
Loading