From 8a9dc6a8a0c15e76bf72aab764891cc6dffc84f0 Mon Sep 17 00:00:00 2001 From: Pun Butrach Date: Sat, 17 Jan 2026 20:40:43 +0700 Subject: [PATCH] fix: Crash when trying to access Window/Display context in Backup & Restore Signed-off-by: Pun Butrach --- GITHUB_CHANGELOG.md | 1 + .../android/launcher3/preview/LauncherPreviewRenderer.java | 4 +++- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/GITHUB_CHANGELOG.md b/GITHUB_CHANGELOG.md index 5f7cf83c42..acf4b9c956 100644 --- a/GITHUB_CHANGELOG.md +++ b/GITHUB_CHANGELOG.md @@ -41,6 +41,7 @@ Compatibility list: * [Launcher] Crash due to incorrect thread looper for accessing cache * [Launcher] Make icon shapes change instantaneous * [Build] Update dependency to fully support 16-kb page size in Android (x86_64 architecture) +* [Lawnchair] Crash due to unable to access Window/Display context on Android 8.0 and above ### 🥞 Development 4 Release 1 (Snapshot 10) diff --git a/src/com/android/launcher3/preview/LauncherPreviewRenderer.java b/src/com/android/launcher3/preview/LauncherPreviewRenderer.java index eab5572fae..9e730ea96e 100644 --- a/src/com/android/launcher3/preview/LauncherPreviewRenderer.java +++ b/src/com/android/launcher3/preview/LauncherPreviewRenderer.java @@ -40,6 +40,7 @@ import android.view.LayoutInflater; import android.view.MotionEvent; import android.view.View; import android.view.ViewGroup; +import android.view.WindowManager; import android.widget.TextClock; import androidx.annotation.NonNull; @@ -397,7 +398,8 @@ public class LauncherPreviewRenderer extends BaseContext * Returns the insets of the screen closest to the display given by the context */ private static Rect getInsets(Context context) { - Display display = context.getDisplay(); + WindowManager windowManager = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE); + Display display = windowManager.getDefaultDisplay(); return DisplayController.INSTANCE.get(context).getInfo().supportedBounds.stream() .filter(w -> w.rotationHint == display.getRotation()) .min(comparingDouble(w ->