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

Commit dc15e243 authored by Amith Yamasani's avatar Amith Yamasani Committed by Android Git Automerger
Browse files

am bb9d9278: Merge "Idle timebase" into mnc-dev

* commit 'bb9d9278':
  Idle timebase
parents 0598d730 bb9d9278
Loading
Loading
Loading
Loading
+20 −0
Original line number Original line Diff line number Diff line
@@ -45,6 +45,13 @@ public final class UsageStats implements Parcelable {
     */
     */
    public long mLastTimeUsed;
    public long mLastTimeUsed;


    /**
     * Last time the package was used and the beginning of the idle countdown.
     * This uses a different timebase that is about how much the device has been in use in general.
     * {@hide}
     */
    public long mBeginIdleTime;

    /**
    /**
     * {@hide}
     * {@hide}
     */
     */
@@ -74,6 +81,7 @@ public final class UsageStats implements Parcelable {
        mTotalTimeInForeground = stats.mTotalTimeInForeground;
        mTotalTimeInForeground = stats.mTotalTimeInForeground;
        mLaunchCount = stats.mLaunchCount;
        mLaunchCount = stats.mLaunchCount;
        mLastEvent = stats.mLastEvent;
        mLastEvent = stats.mLastEvent;
        mBeginIdleTime = stats.mBeginIdleTime;
    }
    }


    public String getPackageName() {
    public String getPackageName() {
@@ -109,6 +117,15 @@ public final class UsageStats implements Parcelable {
        return mLastTimeUsed;
        return mLastTimeUsed;
    }
    }


    /**
     * @hide
     * Get the last time this package was active, measured in milliseconds. This timestamp
     * uses a timebase that represents how much the device was used and not wallclock time.
     */
    public long getBeginIdleTime() {
        return mBeginIdleTime;
    }

    /**
    /**
     * Get the total time this package spent in the foreground, measured in milliseconds.
     * Get the total time this package spent in the foreground, measured in milliseconds.
     */
     */
@@ -133,6 +150,7 @@ public final class UsageStats implements Parcelable {
            mLastEvent = right.mLastEvent;
            mLastEvent = right.mLastEvent;
            mEndTimeStamp = right.mEndTimeStamp;
            mEndTimeStamp = right.mEndTimeStamp;
            mLastTimeUsed = right.mLastTimeUsed;
            mLastTimeUsed = right.mLastTimeUsed;
            mBeginIdleTime = right.mBeginIdleTime;
        }
        }
        mBeginTimeStamp = Math.min(mBeginTimeStamp, right.mBeginTimeStamp);
        mBeginTimeStamp = Math.min(mBeginTimeStamp, right.mBeginTimeStamp);
        mTotalTimeInForeground += right.mTotalTimeInForeground;
        mTotalTimeInForeground += right.mTotalTimeInForeground;
@@ -153,6 +171,7 @@ public final class UsageStats implements Parcelable {
        dest.writeLong(mTotalTimeInForeground);
        dest.writeLong(mTotalTimeInForeground);
        dest.writeInt(mLaunchCount);
        dest.writeInt(mLaunchCount);
        dest.writeInt(mLastEvent);
        dest.writeInt(mLastEvent);
        dest.writeLong(mBeginIdleTime);
    }
    }


    public static final Creator<UsageStats> CREATOR = new Creator<UsageStats>() {
    public static final Creator<UsageStats> CREATOR = new Creator<UsageStats>() {
@@ -166,6 +185,7 @@ public final class UsageStats implements Parcelable {
            stats.mTotalTimeInForeground = in.readLong();
            stats.mTotalTimeInForeground = in.readLong();
            stats.mLaunchCount = in.readInt();
            stats.mLaunchCount = in.readInt();
            stats.mLastEvent = in.readInt();
            stats.mLastEvent = in.readInt();
            stats.mBeginIdleTime = in.readLong();
            return stats;
            return stats;
        }
        }


+0 −8
Original line number Original line Diff line number Diff line
@@ -68,14 +68,6 @@ public abstract class UsageStatsManagerInternal {
     */
     */
    public abstract boolean isAppIdle(String packageName, int userId);
    public abstract boolean isAppIdle(String packageName, int userId);


    /**
     * Returns the most recent time that the specified package was active for the given user.
     * @param packageName The package to search.
     * @param userId The user id of the user of interest.
     * @return The timestamp of when the package was last used, or -1 if it hasn't been used.
     */
    public abstract long getLastPackageAccessTime(String packageName, int userId);

    /**
    /**
     * Sets up a listener for changes to packages being accessed.
     * Sets up a listener for changes to packages being accessed.
     * @param listener A listener within the system process.
     * @param listener A listener within the system process.
+1 −0
Original line number Original line Diff line number Diff line
@@ -23,4 +23,5 @@ interface IDeviceIdleController {
    String[] getSystemPowerWhitelist();
    String[] getSystemPowerWhitelist();
    String[] getFullPowerWhitelist();
    String[] getFullPowerWhitelist();
    int[] getAppIdWhitelist();
    int[] getAppIdWhitelist();
    boolean isPowerSaveWhitelistApp(String name);
}
}
+11 −0
Original line number Original line Diff line number Diff line
@@ -313,6 +313,10 @@ public class DeviceIdleController extends SystemService {
            return getAppIdWhitelistInternal();
            return getAppIdWhitelistInternal();
        }
        }


        @Override public boolean isPowerSaveWhitelistApp(String name) {
            return isPowerSaveWhitelistAppInternal(name);
        }

        @Override protected void dump(FileDescriptor fd, PrintWriter pw, String[] args) {
        @Override protected void dump(FileDescriptor fd, PrintWriter pw, String[] args) {
            DeviceIdleController.this.dump(fd, pw, args);
            DeviceIdleController.this.dump(fd, pw, args);
        }
        }
@@ -452,6 +456,13 @@ public class DeviceIdleController extends SystemService {
        }
        }
    }
    }


    public boolean isPowerSaveWhitelistAppInternal(String packageName) {
        synchronized (this) {
            return mPowerSaveWhitelistApps.containsKey(packageName)
                    || mPowerSaveWhitelistUserApps.containsKey(packageName);
        }
    }

    public int[] getAppIdWhitelistInternal() {
    public int[] getAppIdWhitelistInternal() {
        synchronized (this) {
        synchronized (this) {
            return mPowerSaveWhitelistAppIdArray;
            return mPowerSaveWhitelistAppIdArray;
+1 −1
Original line number Original line Diff line number Diff line
@@ -19490,7 +19490,7 @@ public final class ActivityManagerService extends ActivityManagerNative
            mStackSupervisor.resumeTopActivitiesLocked();
            mStackSupervisor.resumeTopActivitiesLocked();
        }
        }
        EventLogTags.writeAmSwitchUser(newUserId);
        EventLogTags.writeAmSwitchUser(newUserId);
        getUserManagerLocked().userForeground(newUserId);
        getUserManagerLocked().onUserForeground(newUserId);
        sendUserSwitchBroadcastsLocked(oldUserId, newUserId);
        sendUserSwitchBroadcastsLocked(oldUserId, newUserId);
    }
    }
Loading