diff options
author | 2024-12-11 14:55:58 +0100 | |
---|---|---|
committer | 2024-12-11 15:10:46 +0100 | |
commit | 6fd78130b75d5549c20a1998264607a7b1709ce3 (patch) | |
tree | 250bd5354eaab1ad0bbe37a352536627d3ad73fc | |
parent | 683620cdc174abb9c2194e946a13c60457389671 (diff) |
Inline the custom Lazy implementation in shell
This causes difficulties from the clockwork shell implementation
building `wm_shell-shared-utils` into binaries both from source and
as a library.
Change-Id: Ifb627a5d091d9bb6dcf2810d2f8ae6ce7745b46b
Test: cf_gwear_x86-trunk_staging-userdebug
Flag: EXEMPT proguard is not flaggable
Bug: 382028320
3 files changed, 8 insertions, 51 deletions
diff --git a/libs/WindowManager/Shell/shared/Android.bp b/libs/WindowManager/Shell/shared/Android.bp index 5bbda95c466f..c3ee0f76f550 100644 --- a/libs/WindowManager/Shell/shared/Android.bp +++ b/libs/WindowManager/Shell/shared/Android.bp @@ -26,7 +26,6 @@ filegroup { name: "wm_shell-shared-utils", srcs: [ "src/com/android/wm/shell/shared/TransitionUtil.java", - "src/com/android/wm/shell/shared/Utils.java", ], } diff --git a/libs/WindowManager/Shell/shared/src/com/android/wm/shell/shared/Utils.java b/libs/WindowManager/Shell/shared/src/com/android/wm/shell/shared/Utils.java deleted file mode 100644 index e19027a352f7..000000000000 --- a/libs/WindowManager/Shell/shared/src/com/android/wm/shell/shared/Utils.java +++ /dev/null @@ -1,46 +0,0 @@ -/* - * Copyright (C) 2024 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.android.wm.shell.shared; - -import android.annotation.NonNull; - -import java.util.function.Supplier; - -/** - * This class provides generic utility methods and classes for shell - */ -public class Utils { - - /** - * Lazily returns object from a supplier with caching - * @param <T> type of object to get - */ - public static class Lazy<T> { - private T mInstance; - - /** - * @param supplier the supplier to use, when the instance has not yet been initialized - * @return the cached value or the value from the supplier - */ - public final T get(@NonNull Supplier<T> supplier) { - if (mInstance == null) { - mInstance = supplier.get(); - } - return mInstance; - } - } -} diff --git a/libs/WindowManager/Shell/shared/src/com/android/wm/shell/shared/desktopmode/DesktopModeStatus.java b/libs/WindowManager/Shell/shared/src/com/android/wm/shell/shared/desktopmode/DesktopModeStatus.java index a5d698aff2a2..755f472ee22e 100644 --- a/libs/WindowManager/Shell/shared/src/com/android/wm/shell/shared/desktopmode/DesktopModeStatus.java +++ b/libs/WindowManager/Shell/shared/src/com/android/wm/shell/shared/desktopmode/DesktopModeStatus.java @@ -19,6 +19,7 @@ package com.android.wm.shell.shared.desktopmode; import static android.hardware.display.DisplayManager.DISPLAY_CATEGORY_ALL_INCLUDING_DISABLED; import android.annotation.NonNull; +import android.annotation.Nullable; import android.content.Context; import android.hardware.display.DisplayManager; import android.os.SystemProperties; @@ -29,7 +30,6 @@ import android.window.DesktopModeFlags; import com.android.internal.R; import com.android.internal.annotations.VisibleForTesting; import com.android.window.flags.Flags; -import com.android.wm.shell.shared.Utils.Lazy; import java.io.PrintWriter; import java.util.Arrays; @@ -42,7 +42,8 @@ public class DesktopModeStatus { private static final String TAG = "DesktopModeStatus"; - private static Lazy<Boolean> sIsLargeScreenDevice = new Lazy<>(); + @Nullable + private static Boolean sIsLargeScreenDevice = null; /** * Flag to indicate whether task resizing is veiled. @@ -287,12 +288,15 @@ public class DesktopModeStatus { * @return {@code true} if this device has an internal large screen */ private static boolean deviceHasLargeScreen(@NonNull Context context) { - return sIsLargeScreenDevice.get(() -> Arrays.stream( + if (sIsLargeScreenDevice == null) { + sIsLargeScreenDevice = Arrays.stream( context.getSystemService(DisplayManager.class) .getDisplays(DISPLAY_CATEGORY_ALL_INCLUDING_DISABLED)) .filter(display -> display.getType() == Display.TYPE_INTERNAL) .anyMatch(display -> display.getMinSizeDimensionDp() - >= WindowManager.LARGE_SCREEN_SMALLEST_SCREEN_WIDTH_DP)); + >= WindowManager.LARGE_SCREEN_SMALLEST_SCREEN_WIDTH_DP); + } + return sIsLargeScreenDevice; } /** |