Loading core/api/system-current.txt +1 −0 Original line number Diff line number Diff line Loading @@ -1795,6 +1795,7 @@ package android.app.usage { public final class UsageStats implements android.os.Parcelable { method public int getAppLaunchCount(); method public long getLastTimeComponentUsed(); } public final class UsageStatsManager { Loading core/java/android/app/usage/UsageStats.java +25 −0 Original line number Diff line number Diff line Loading @@ -20,6 +20,7 @@ import static android.app.usage.UsageEvents.Event.ACTIVITY_DESTROYED; 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.APP_COMPONENT_USED; 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; Loading Loading @@ -108,6 +109,13 @@ public final class UsageStats implements Parcelable { */ public long mTotalTimeForegroundServiceUsed; /** * Last time this package's component is used, measured in milliseconds since the epoch. * See {@link UsageEvents.Event#APP_COMPONENT_USED} * @hide */ public long mLastTimeComponentUsed; /** * {@hide} */ Loading Loading @@ -166,6 +174,7 @@ public final class UsageStats implements Parcelable { mEndTimeStamp = stats.mEndTimeStamp; mLastTimeUsed = stats.mLastTimeUsed; mLastTimeVisible = stats.mLastTimeVisible; mLastTimeComponentUsed = stats.mLastTimeComponentUsed; mLastTimeForegroundServiceUsed = stats.mLastTimeForegroundServiceUsed; mTotalTimeInForeground = stats.mTotalTimeInForeground; mTotalTimeVisible = stats.mTotalTimeVisible; Loading Loading @@ -264,6 +273,16 @@ public final class UsageStats implements Parcelable { return mTotalTimeForegroundServiceUsed; } /** * Get the last time this package's component was used, measured in milliseconds since the * epoch. * @hide */ @SystemApi public long getLastTimeComponentUsed() { return mLastTimeComponentUsed; } /** * Returns the number of times the app was launched as an activity from outside of the app. * Excludes intra-app activity transitions. Loading Loading @@ -323,6 +342,7 @@ public final class UsageStats implements Parcelable { mergeEventMap(mForegroundServices, right.mForegroundServices); mLastTimeUsed = Math.max(mLastTimeUsed, right.mLastTimeUsed); mLastTimeVisible = Math.max(mLastTimeVisible, right.mLastTimeVisible); mLastTimeComponentUsed = Math.max(mLastTimeComponentUsed, right.mLastTimeComponentUsed); mLastTimeForegroundServiceUsed = Math.max(mLastTimeForegroundServiceUsed, right.mLastTimeForegroundServiceUsed); } Loading Loading @@ -598,6 +618,9 @@ public final class UsageStats implements Parcelable { mLastTimeVisible = timeStamp; } break; case APP_COMPONENT_USED: mLastTimeComponentUsed = timeStamp; break; default: break; } Loading @@ -620,6 +643,7 @@ public final class UsageStats implements Parcelable { dest.writeLong(mEndTimeStamp); dest.writeLong(mLastTimeUsed); dest.writeLong(mLastTimeVisible); dest.writeLong(mLastTimeComponentUsed); dest.writeLong(mLastTimeForegroundServiceUsed); dest.writeLong(mTotalTimeInForeground); dest.writeLong(mTotalTimeVisible); Loading Loading @@ -674,6 +698,7 @@ public final class UsageStats implements Parcelable { stats.mEndTimeStamp = in.readLong(); stats.mLastTimeUsed = in.readLong(); stats.mLastTimeVisible = in.readLong(); stats.mLastTimeComponentUsed = in.readLong(); stats.mLastTimeForegroundServiceUsed = in.readLong(); stats.mTotalTimeInForeground = in.readLong(); stats.mTotalTimeVisible = in.readLong(); Loading core/proto/android/server/usagestatsservice.proto +2 −0 Original line number Diff line number Diff line Loading @@ -57,6 +57,8 @@ message IntervalStatsProto { // Time attributes stored as an offset of the IntervalStats's beginTime. optional int64 last_time_visible_ms = 10; optional int64 total_time_visible_ms = 11; // Time attributes stored as an offset of the IntervalStats's beginTime. optional int64 last_time_component_used_ms = 12; } // Stores the relevant information an IntervalStats will have about a Configuration Loading core/proto/android/server/usagestatsservice_v2.proto +1 −0 Original line number Diff line number Diff line Loading @@ -81,6 +81,7 @@ message UsageStatsObfuscatedProto { optional int64 total_time_service_used_ms = 9; optional int64 last_time_visible_ms = 10; optional int64 total_time_visible_ms = 11; optional int64 last_time_component_used_ms = 12; } /** Loading core/tests/coretests/src/android/app/usage/UsageStatsPersistenceTest.java +2 −1 Original line number Diff line number Diff line Loading @@ -46,7 +46,8 @@ public class UsageStatsPersistenceTest { private static final String[] USAGESTATS_PERSISTED_FIELDS = {"mBeginTimeStamp", "mEndTimeStamp", "mPackageName", "mPackageToken", "mLastEvent", "mAppLaunchCount", "mChooserCounts", "mLastTimeUsed", "mTotalTimeInForeground", "mLastTimeForegroundServiceUsed", "mTotalTimeForegroundServiceUsed", "mLastTimeVisible", "mTotalTimeVisible"}; "mTotalTimeForegroundServiceUsed", "mLastTimeVisible", "mTotalTimeVisible", "mLastTimeComponentUsed"}; // All fields in this list are defined in UsageStats but not persisted private static final String[] USAGESTATS_IGNORED_FIELDS = {"CREATOR", "mActivities", "mForegroundServices", "mLaunchCount", "mChooserCountsObfuscated"}; Loading Loading
core/api/system-current.txt +1 −0 Original line number Diff line number Diff line Loading @@ -1795,6 +1795,7 @@ package android.app.usage { public final class UsageStats implements android.os.Parcelable { method public int getAppLaunchCount(); method public long getLastTimeComponentUsed(); } public final class UsageStatsManager { Loading
core/java/android/app/usage/UsageStats.java +25 −0 Original line number Diff line number Diff line Loading @@ -20,6 +20,7 @@ import static android.app.usage.UsageEvents.Event.ACTIVITY_DESTROYED; 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.APP_COMPONENT_USED; 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; Loading Loading @@ -108,6 +109,13 @@ public final class UsageStats implements Parcelable { */ public long mTotalTimeForegroundServiceUsed; /** * Last time this package's component is used, measured in milliseconds since the epoch. * See {@link UsageEvents.Event#APP_COMPONENT_USED} * @hide */ public long mLastTimeComponentUsed; /** * {@hide} */ Loading Loading @@ -166,6 +174,7 @@ public final class UsageStats implements Parcelable { mEndTimeStamp = stats.mEndTimeStamp; mLastTimeUsed = stats.mLastTimeUsed; mLastTimeVisible = stats.mLastTimeVisible; mLastTimeComponentUsed = stats.mLastTimeComponentUsed; mLastTimeForegroundServiceUsed = stats.mLastTimeForegroundServiceUsed; mTotalTimeInForeground = stats.mTotalTimeInForeground; mTotalTimeVisible = stats.mTotalTimeVisible; Loading Loading @@ -264,6 +273,16 @@ public final class UsageStats implements Parcelable { return mTotalTimeForegroundServiceUsed; } /** * Get the last time this package's component was used, measured in milliseconds since the * epoch. * @hide */ @SystemApi public long getLastTimeComponentUsed() { return mLastTimeComponentUsed; } /** * Returns the number of times the app was launched as an activity from outside of the app. * Excludes intra-app activity transitions. Loading Loading @@ -323,6 +342,7 @@ public final class UsageStats implements Parcelable { mergeEventMap(mForegroundServices, right.mForegroundServices); mLastTimeUsed = Math.max(mLastTimeUsed, right.mLastTimeUsed); mLastTimeVisible = Math.max(mLastTimeVisible, right.mLastTimeVisible); mLastTimeComponentUsed = Math.max(mLastTimeComponentUsed, right.mLastTimeComponentUsed); mLastTimeForegroundServiceUsed = Math.max(mLastTimeForegroundServiceUsed, right.mLastTimeForegroundServiceUsed); } Loading Loading @@ -598,6 +618,9 @@ public final class UsageStats implements Parcelable { mLastTimeVisible = timeStamp; } break; case APP_COMPONENT_USED: mLastTimeComponentUsed = timeStamp; break; default: break; } Loading @@ -620,6 +643,7 @@ public final class UsageStats implements Parcelable { dest.writeLong(mEndTimeStamp); dest.writeLong(mLastTimeUsed); dest.writeLong(mLastTimeVisible); dest.writeLong(mLastTimeComponentUsed); dest.writeLong(mLastTimeForegroundServiceUsed); dest.writeLong(mTotalTimeInForeground); dest.writeLong(mTotalTimeVisible); Loading Loading @@ -674,6 +698,7 @@ public final class UsageStats implements Parcelable { stats.mEndTimeStamp = in.readLong(); stats.mLastTimeUsed = in.readLong(); stats.mLastTimeVisible = in.readLong(); stats.mLastTimeComponentUsed = in.readLong(); stats.mLastTimeForegroundServiceUsed = in.readLong(); stats.mTotalTimeInForeground = in.readLong(); stats.mTotalTimeVisible = in.readLong(); Loading
core/proto/android/server/usagestatsservice.proto +2 −0 Original line number Diff line number Diff line Loading @@ -57,6 +57,8 @@ message IntervalStatsProto { // Time attributes stored as an offset of the IntervalStats's beginTime. optional int64 last_time_visible_ms = 10; optional int64 total_time_visible_ms = 11; // Time attributes stored as an offset of the IntervalStats's beginTime. optional int64 last_time_component_used_ms = 12; } // Stores the relevant information an IntervalStats will have about a Configuration Loading
core/proto/android/server/usagestatsservice_v2.proto +1 −0 Original line number Diff line number Diff line Loading @@ -81,6 +81,7 @@ message UsageStatsObfuscatedProto { optional int64 total_time_service_used_ms = 9; optional int64 last_time_visible_ms = 10; optional int64 total_time_visible_ms = 11; optional int64 last_time_component_used_ms = 12; } /** Loading
core/tests/coretests/src/android/app/usage/UsageStatsPersistenceTest.java +2 −1 Original line number Diff line number Diff line Loading @@ -46,7 +46,8 @@ public class UsageStatsPersistenceTest { private static final String[] USAGESTATS_PERSISTED_FIELDS = {"mBeginTimeStamp", "mEndTimeStamp", "mPackageName", "mPackageToken", "mLastEvent", "mAppLaunchCount", "mChooserCounts", "mLastTimeUsed", "mTotalTimeInForeground", "mLastTimeForegroundServiceUsed", "mTotalTimeForegroundServiceUsed", "mLastTimeVisible", "mTotalTimeVisible"}; "mTotalTimeForegroundServiceUsed", "mLastTimeVisible", "mTotalTimeVisible", "mLastTimeComponentUsed"}; // All fields in this list are defined in UsageStats but not persisted private static final String[] USAGESTATS_IGNORED_FIELDS = {"CREATOR", "mActivities", "mForegroundServices", "mLaunchCount", "mChooserCountsObfuscated"}; Loading