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

Commit 8f0903ae authored by Danning Chen's avatar Danning Chen Committed by Android (Google) Code Review
Browse files

Merge "Add a new method queryEventsForUser() to UsageStatsManagerInternal for...

Merge "Add a new method queryEventsForUser() to UsageStatsManagerInternal for People Service to call"
parents 78bfd35a 6a5982f3
Loading
Loading
Loading
Loading
+25 −17
Original line number Diff line number Diff line
@@ -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;
        }

        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;
        }
+6 −2
Original line number Diff line number Diff line
@@ -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
+7 −0
Original line number Diff line number Diff line
@@ -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);