Merge "Initialize the app last used timestamps to 0 in test setup." into tm-dev
This commit is contained in:
committed by
Android (Google) Code Review
commit
7bcee6bcbc
@@ -2103,6 +2103,13 @@ public class AppStandbyController
|
|||||||
.sendToTarget();
|
.sendToTarget();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@VisibleForTesting
|
||||||
|
AppIdleHistory getAppIdleHistoryForTest() {
|
||||||
|
synchronized (mAppIdleLock) {
|
||||||
|
return mAppIdleHistory;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void dumpUsers(IndentingPrintWriter idpw, int[] userIds, List<String> pkgs) {
|
public void dumpUsers(IndentingPrintWriter idpw, int[] userIds, List<String> pkgs) {
|
||||||
synchronized (mAppIdleLock) {
|
synchronized (mAppIdleLock) {
|
||||||
|
|||||||
@@ -512,8 +512,30 @@ public class AppStandbyControllerTests {
|
|||||||
return controller;
|
return controller;
|
||||||
}
|
}
|
||||||
|
|
||||||
private long getCurrentTime() {
|
private void setupInitialUsageHistory() throws Exception {
|
||||||
return TimeUnit.NANOSECONDS.toMillis(System.nanoTime());
|
final int[] userIds = new int[] { USER_ID, USER_ID2, USER_ID3 };
|
||||||
|
final String[] packages = new String[] {
|
||||||
|
PACKAGE_1,
|
||||||
|
PACKAGE_2,
|
||||||
|
PACKAGE_EXEMPTED_1,
|
||||||
|
PACKAGE_SYSTEM_HEADFULL,
|
||||||
|
PACKAGE_SYSTEM_HEADLESS,
|
||||||
|
PACKAGE_WELLBEING,
|
||||||
|
PACKAGE_BACKGROUND_LOCATION,
|
||||||
|
ADMIN_PKG,
|
||||||
|
ADMIN_PKG2,
|
||||||
|
ADMIN_PKG3
|
||||||
|
};
|
||||||
|
for (int userId : userIds) {
|
||||||
|
for (String pkg : packages) {
|
||||||
|
final AppIdleHistory.AppUsageHistory usageHistory = mController
|
||||||
|
.getAppIdleHistoryForTest().getAppUsageHistory(
|
||||||
|
pkg, userId, mInjector.mElapsedRealtime);
|
||||||
|
usageHistory.lastUsedElapsedTime = 0;
|
||||||
|
usageHistory.lastUsedByUserElapsedTime = 0;
|
||||||
|
usageHistory.lastUsedScreenTime = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Before
|
@Before
|
||||||
@@ -524,6 +546,7 @@ public class AppStandbyControllerTests {
|
|||||||
MyContextWrapper myContext = new MyContextWrapper(InstrumentationRegistry.getContext());
|
MyContextWrapper myContext = new MyContextWrapper(InstrumentationRegistry.getContext());
|
||||||
mInjector = new MyInjector(myContext, Looper.getMainLooper());
|
mInjector = new MyInjector(myContext, Looper.getMainLooper());
|
||||||
mController = setupController();
|
mController = setupController();
|
||||||
|
setupInitialUsageHistory();
|
||||||
}
|
}
|
||||||
|
|
||||||
@After
|
@After
|
||||||
|
|||||||
Reference in New Issue
Block a user