Add last time unhibernated to dumped info
Add the last time a package was unhibernated to app hibernation dump. This can be used in bug reports or dumps to know that an app was recently unhibernated. Bug: 183142988 Test: adb shell dumpsys app_hibernation Change-Id: I5bc1969d9385206b43e73b42d9d2067a66e9b609
This commit is contained in:
@@ -362,6 +362,7 @@ public final class AppHibernationService extends SystemService {
|
||||
UserLevelState pkgState) {
|
||||
Trace.traceBegin(Trace.TRACE_TAG_SYSTEM_SERVER, "unhibernatePackage");
|
||||
pkgState.hibernated = false;
|
||||
pkgState.lastUnhibernatedMs = System.currentTimeMillis();
|
||||
Trace.traceEnd(Trace.TRACE_TAG_SYSTEM_SERVER);
|
||||
}
|
||||
|
||||
@@ -383,6 +384,7 @@ public final class AppHibernationService extends SystemService {
|
||||
private void unhibernatePackageGlobally(@NonNull String packageName, GlobalLevelState state) {
|
||||
Trace.traceBegin(Trace.TRACE_TAG_SYSTEM_SERVER, "unhibernatePackageGlobally");
|
||||
state.hibernated = false;
|
||||
state.lastUnhibernatedMs = System.currentTimeMillis();
|
||||
Trace.traceEnd(Trace.TRACE_TAG_SYSTEM_SERVER);
|
||||
}
|
||||
|
||||
|
||||
@@ -16,18 +16,28 @@
|
||||
|
||||
package com.android.server.apphibernation;
|
||||
|
||||
import android.annotation.CurrentTimeMillisLong;
|
||||
|
||||
import java.text.SimpleDateFormat;
|
||||
|
||||
/**
|
||||
* Data class that contains global hibernation state for a package.
|
||||
*/
|
||||
final class GlobalLevelState {
|
||||
// Only show day for privacy purposes.
|
||||
private static final SimpleDateFormat DATE_FORMAT = new SimpleDateFormat("yyyy-MM-dd");
|
||||
|
||||
public String packageName;
|
||||
public boolean hibernated;
|
||||
@CurrentTimeMillisLong
|
||||
public long lastUnhibernatedMs;
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "GlobalLevelState{"
|
||||
+ "packageName='" + packageName + '\''
|
||||
+ ", hibernated=" + hibernated
|
||||
+ ", hibernated=" + hibernated + '\''
|
||||
+ ", lastUnhibernated=" + DATE_FORMAT.format(lastUnhibernatedMs)
|
||||
+ '}';
|
||||
}
|
||||
}
|
||||
|
||||
@@ -16,18 +16,27 @@
|
||||
|
||||
package com.android.server.apphibernation;
|
||||
|
||||
import android.annotation.CurrentTimeMillisLong;
|
||||
|
||||
import java.text.SimpleDateFormat;
|
||||
|
||||
/**
|
||||
* Data class that contains hibernation state info of a package for a user.
|
||||
*/
|
||||
final class UserLevelState {
|
||||
private static final SimpleDateFormat DATE_FORMAT = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
||||
|
||||
public String packageName;
|
||||
public boolean hibernated;
|
||||
@CurrentTimeMillisLong
|
||||
public long lastUnhibernatedMs;
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "UserLevelState{"
|
||||
+ "packageName='" + packageName + '\''
|
||||
+ ", hibernated=" + hibernated
|
||||
+ ", hibernated=" + hibernated + '\''
|
||||
+ ", lastUnhibernated=" + DATE_FORMAT.format(lastUnhibernatedMs)
|
||||
+ '}';
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user