Merge "Add a public test method to reset package version"

This commit is contained in:
Remi NGUYEN VAN 2021-02-22 05:31:05 +00:00 • committed by Gerrit Code Review
commit 779cba3698
2 changed files with 6 additions and 2 deletions

View file

@ -36,7 +36,11 @@ public final class DeviceConfigUtils {
private static final String TAG = DeviceConfigUtils.class.getSimpleName();
@VisibleForTesting
protected static volatile long sPackageVersion = -1;
public static void resetPackageVersionCacheForTest() {
sPackageVersion = -1;
}
private static volatile long sPackageVersion = -1;
private static long getPackageVersion(@NonNull final Context context)
throws PackageManager.NameNotFoundException {
// sPackageVersion may be set by another thread just after this check, but querying the

View file

@ -88,7 +88,7 @@ public class DeviceConfigUtilsTest {
@After
public void tearDown() {
mSession.finishMocking();
DeviceConfigUtils.sPackageVersion = -1L;
DeviceConfigUtils.resetPackageVersionCacheForTest();
}
@Test