diff options
author | Justin Klaassen <justinklaassen@google.com> | 2018-04-03 23:21:57 -0400 |
---|---|---|
committer | Justin Klaassen <justinklaassen@google.com> | 2018-04-03 23:21:57 -0400 |
commit | 4d01eeaffaa720e4458a118baa137a11614f00f7 (patch) | |
tree | 66751893566986236788e3c796a7cc5e90d05f52 /android/app/usage/UsageEvents.java | |
parent | a192cc2a132cb0ee8588e2df755563ec7008c179 (diff) | |
download | android-28-4d01eeaffaa720e4458a118baa137a11614f00f7.tar.gz |
Import Android SDK Platform P [4697573]
/google/data/ro/projects/android/fetch_artifact \
--bid 4697573 \
--target sdk_phone_armv7-win_sdk \
sdk-repo-linux-sources-4697573.zip
AndroidVersion.ApiLevel has been modified to appear as 28
Change-Id: If80578c3c657366cc9cf75f8db13d46e2dd4e077
Diffstat (limited to 'android/app/usage/UsageEvents.java')
-rw-r--r-- | android/app/usage/UsageEvents.java | 122 |
1 files changed, 113 insertions, 9 deletions
diff --git a/android/app/usage/UsageEvents.java b/android/app/usage/UsageEvents.java index edb992bd..84f57a30 100644 --- a/android/app/usage/UsageEvents.java +++ b/android/app/usage/UsageEvents.java @@ -16,6 +16,7 @@ package android.app.usage; import android.annotation.IntDef; +import android.annotation.SystemApi; import android.content.res.Configuration; import android.os.Parcel; import android.os.Parcelable; @@ -80,6 +81,7 @@ public final class UsageEvents implements Parcelable { * An event type denoting that a package was interacted with in some way by the system. * @hide */ + @SystemApi public static final int SYSTEM_INTERACTION = 6; /** @@ -104,14 +106,64 @@ public final class UsageEvents implements Parcelable { * An event type denoting that a notification was viewed by the user. * @hide */ + @SystemApi public static final int NOTIFICATION_SEEN = 10; /** - * An event type denoting a change in App Standby Bucket. - * @hide + * An event type denoting a change in App Standby Bucket. The new bucket can be + * retrieved by calling {@link #getStandbyBucket()}. + * + * @see UsageStatsManager#getAppStandbyBucket() */ public static final int STANDBY_BUCKET_CHANGED = 11; + /** + * An event type denoting that an app posted an interruptive notification. Visual and + * audible interruptions are included. + * @hide + */ + @SystemApi + public static final int NOTIFICATION_INTERRUPTION = 12; + + /** + * A Slice was pinned by the default launcher or the default assistant. + * @hide + */ + @SystemApi + public static final int SLICE_PINNED_PRIV = 13; + + /** + * A Slice was pinned by an app. + * @hide + */ + @SystemApi + public static final int SLICE_PINNED = 14; + + /** + * An event type denoting that the screen has gone in to an interactive state (turned + * on for full user interaction, not ambient display or other non-interactive state). + */ + public static final int SCREEN_INTERACTIVE = 15; + + /** + * An event type denoting that the screen has gone in to a non-interactive state + * (completely turned off or turned on only in a non-interactive state like ambient + * display). + */ + 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; @@ -177,11 +229,20 @@ public final class UsageEvents implements Parcelable { public String[] mContentAnnotations; /** - * The app standby bucket assigned. + * The app standby bucket assigned and reason. Bucket is the high order 16 bits, reason + * is the low order 16 bits. * Only present for {@link #STANDBY_BUCKET_CHANGED} event types * {@hide} */ - public int mBucket; + public int mBucketAndReason; + + /** + * The id of the {@link android.app.NotificationChannel} to which an interruptive + * notification was posted. + * Only present for {@link #NOTIFICATION_INTERRUPTION} event types. + * {@hide} + */ + public String mNotificationChannelId; /** @hide */ @EventFlags @@ -202,7 +263,8 @@ public final class UsageEvents implements Parcelable { mContentType = orig.mContentType; mContentAnnotations = orig.mContentAnnotations; mFlags = orig.mFlags; - mBucket = orig.mBucket; + mBucketAndReason = orig.mBucketAndReason; + mNotificationChannelId = orig.mNotificationChannelId; } /** @@ -232,8 +294,11 @@ public final class UsageEvents implements Parcelable { /** * The event type. * - * See {@link #MOVE_TO_BACKGROUND} - * See {@link #MOVE_TO_FOREGROUND} + * @see #MOVE_TO_BACKGROUND + * @see #MOVE_TO_FOREGROUND + * @see #CONFIGURATION_CHANGE + * @see #USER_INTERACTION + * @see #STANDBY_BUCKET_CHANGED */ public int getEventType() { return mEventType; @@ -257,6 +322,38 @@ public final class UsageEvents implements Parcelable { return mShortcutId; } + /** + * Returns the standby bucket of the app, if the event is of type + * {@link #STANDBY_BUCKET_CHANGED}, otherwise returns 0. + * @return the standby bucket associated with the event. + * + */ + public int getStandbyBucket() { + return (mBucketAndReason & 0xFFFF0000) >>> 16; + } + + /** + * Returns the reason for the bucketing, if the event is of type + * {@link #STANDBY_BUCKET_CHANGED}, otherwise returns 0. Reason values include + * the main reason which is one of REASON_MAIN_*, OR'ed with REASON_SUB_*, if there + * are sub-reasons for the main reason, such as REASON_SUB_USAGE_* when the main reason + * is REASON_MAIN_USAGE. + * @hide + */ + public int getStandbyReason() { + return mBucketAndReason & 0x0000FFFF; + } + + /** + * Returns the ID of the {@link android.app.NotificationChannel} for this event if the + * event is of type {@link #NOTIFICATION_INTERRUPTION}, otherwise it returns null; + * @hide + */ + @SystemApi + public String getNotificationChannelId() { + return mNotificationChannelId; + } + /** @hide */ public Event getObfuscatedIfInstantApp() { if ((mFlags & FLAG_IS_PACKAGE_INSTANT_APP) == 0) { @@ -414,7 +511,10 @@ public final class UsageEvents implements Parcelable { p.writeStringArray(event.mContentAnnotations); break; case Event.STANDBY_BUCKET_CHANGED: - p.writeInt(event.mBucket); + p.writeInt(event.mBucketAndReason); + break; + case Event.NOTIFICATION_INTERRUPTION: + p.writeString(event.mNotificationChannelId); break; } } @@ -445,6 +545,7 @@ public final class UsageEvents implements Parcelable { eventOut.mAction = null; eventOut.mContentType = null; eventOut.mContentAnnotations = null; + eventOut.mNotificationChannelId = null; switch (eventOut.mEventType) { case Event.CONFIGURATION_CHANGE: @@ -460,7 +561,10 @@ public final class UsageEvents implements Parcelable { eventOut.mContentAnnotations = p.createStringArray(); break; case Event.STANDBY_BUCKET_CHANGED: - eventOut.mBucket = p.readInt(); + eventOut.mBucketAndReason = p.readInt(); + break; + case Event.NOTIFICATION_INTERRUPTION: + eventOut.mNotificationChannelId = p.readString(); break; } } |