Add a new method queryEventsForUser() to UsageStatsManagerInternal for People Service to call
Change-Id: I4baf755a3dc1af421ea755ed2f4cfe3440741290 Test: Build and run on a test device Bug: 146522621
This commit is contained in:
@@ -451,21 +451,7 @@ public final class UsageEvents implements Parcelable {
|
||||
|
||||
/** @hide */
|
||||
public Event(Event orig) {
|
||||
mPackage = orig.mPackage;
|
||||
mClass = orig.mClass;
|
||||
mInstanceId = orig.mInstanceId;
|
||||
mTaskRootPackage = orig.mTaskRootPackage;
|
||||
mTaskRootClass = orig.mTaskRootClass;
|
||||
mTimeStamp = orig.mTimeStamp;
|
||||
mEventType = orig.mEventType;
|
||||
mConfiguration = orig.mConfiguration;
|
||||
mShortcutId = orig.mShortcutId;
|
||||
mAction = orig.mAction;
|
||||
mContentType = orig.mContentType;
|
||||
mContentAnnotations = orig.mContentAnnotations;
|
||||
mFlags = orig.mFlags;
|
||||
mBucketAndReason = orig.mBucketAndReason;
|
||||
mNotificationChannelId = orig.mNotificationChannelId;
|
||||
copyFrom(orig);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -622,6 +608,24 @@ public final class UsageEvents implements Parcelable {
|
||||
// which instant apps can't use anyway, so there's no need to hide them.
|
||||
return ret;
|
||||
}
|
||||
|
||||
private void copyFrom(Event orig) {
|
||||
mPackage = orig.mPackage;
|
||||
mClass = orig.mClass;
|
||||
mInstanceId = orig.mInstanceId;
|
||||
mTaskRootPackage = orig.mTaskRootPackage;
|
||||
mTaskRootClass = orig.mTaskRootClass;
|
||||
mTimeStamp = orig.mTimeStamp;
|
||||
mEventType = orig.mEventType;
|
||||
mConfiguration = orig.mConfiguration;
|
||||
mShortcutId = orig.mShortcutId;
|
||||
mAction = orig.mAction;
|
||||
mContentType = orig.mContentType;
|
||||
mContentAnnotations = orig.mContentAnnotations;
|
||||
mFlags = orig.mFlags;
|
||||
mBucketAndReason = orig.mBucketAndReason;
|
||||
mNotificationChannelId = orig.mNotificationChannelId;
|
||||
}
|
||||
}
|
||||
|
||||
// Only used when creating the resulting events. Not used for reading/unparceling.
|
||||
@@ -725,10 +729,14 @@ public final class UsageEvents implements Parcelable {
|
||||
return false;
|
||||
}
|
||||
|
||||
readEventFromParcel(mParcel, eventOut);
|
||||
if (mParcel != null) {
|
||||
readEventFromParcel(mParcel, eventOut);
|
||||
} else {
|
||||
eventOut.copyFrom(mEventsToWrite.get(mIndex));
|
||||
}
|
||||
|
||||
mIndex++;
|
||||
if (mIndex >= mEventCount) {
|
||||
if (mIndex >= mEventCount && mParcel != null) {
|
||||
mParcel.recycle();
|
||||
mParcel = null;
|
||||
}
|
||||
|
||||
@@ -23,8 +23,6 @@ import android.content.res.Configuration;
|
||||
import android.os.UserHandle;
|
||||
import android.os.UserManager;
|
||||
|
||||
import com.android.server.usage.AppStandbyInternal.AppIdleStateChangeListener;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
@@ -197,6 +195,12 @@ public abstract class UsageStatsManagerInternal {
|
||||
public abstract List<UsageStats> queryUsageStatsForUser(@UserIdInt int userId, int interval,
|
||||
long beginTime, long endTime, boolean obfuscateInstantApps);
|
||||
|
||||
/**
|
||||
* Returns the events for the user in the given time period.
|
||||
*/
|
||||
public abstract UsageEvents queryEventsForUser(@UserIdInt int userId, long beginTime,
|
||||
long endTime, boolean shouldObfuscateInstantApps);
|
||||
|
||||
/**
|
||||
* Used to persist the last time a job was run for this app, in order to make decisions later
|
||||
* whether a job should be deferred until later. The time passed in should be in elapsed
|
||||
|
||||
@@ -2068,6 +2068,13 @@ public class UsageStatsService extends SystemService implements
|
||||
userId, intervalType, beginTime, endTime, obfuscateInstantApps);
|
||||
}
|
||||
|
||||
@Override
|
||||
public UsageEvents queryEventsForUser(int userId, long beginTime, long endTime,
|
||||
boolean shouldObfuscateInstantApps) {
|
||||
return UsageStatsService.this.queryEvents(
|
||||
userId, beginTime, endTime, shouldObfuscateInstantApps);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setLastJobRunTime(String packageName, int userId, long elapsedRealtime) {
|
||||
mAppStandby.setLastJobRunTime(packageName, userId, elapsedRealtime);
|
||||
|
||||
Reference in New Issue
Block a user