@@ -91,20 +91,6 @@ private ContextUtils() {}
9191 // to avoid doing a bunch of Binder calls we use LazyEvaluator to cache the values that are static
9292 // during the app process running
9393
94- private static final @ NotNull LazyEvaluator <Boolean > isForegroundImportance =
95- new LazyEvaluator <>(
96- () -> {
97- try {
98- final ActivityManager .RunningAppProcessInfo appProcessInfo =
99- new ActivityManager .RunningAppProcessInfo ();
100- ActivityManager .getMyMemoryState (appProcessInfo );
101- return appProcessInfo .importance == IMPORTANCE_FOREGROUND ;
102- } catch (Throwable ignored ) {
103- // should never happen
104- }
105- return false ;
106- });
107-
10894 /**
10995 * Since this packageInfo uses flags 0 we can assume it's static and cache it as the package name
11096 * or version code cannot change during runtime, only after app update (which will spin up a new
@@ -284,7 +270,15 @@ static String getVersionName(final @NotNull PackageInfo packageInfo) {
284270 */
285271 @ ApiStatus .Internal
286272 public static boolean isForegroundImportance () {
287- return isForegroundImportance .getValue ();
273+ try {
274+ final ActivityManager .RunningAppProcessInfo appProcessInfo =
275+ new ActivityManager .RunningAppProcessInfo ();
276+ ActivityManager .getMyMemoryState (appProcessInfo );
277+ return appProcessInfo .importance == IMPORTANCE_FOREGROUND ;
278+ } catch (Throwable ignored ) {
279+ // should never happen
280+ }
281+ return false ;
288282 }
289283
290284 /**
@@ -544,7 +538,6 @@ public static Context getApplicationContext(final @NotNull Context context) {
544538
545539 @ TestOnly
546540 static void resetInstance () {
547- isForegroundImportance .resetValue ();
548541 staticPackageInfo33 .resetValue ();
549542 staticPackageInfo .resetValue ();
550543 applicationName .resetValue ();
0 commit comments