From cecaedb56ff6c47f9929f8a4f7f06d34cc7ecb19 Mon Sep 17 00:00:00 2001 From: Butkovits Atila Date: Tue, 27 Dec 2022 21:29:51 +0200 Subject: [PATCH] Backed out changeset ddf5f22cd611 (bug 1806072) for blocking Android Components from being updated in Fenix nightly. CLOSED TREE --- .../java/org/mozilla/gecko/GeckoAppShell.java | 23 ------------------- .../mozilla/gecko/GeckoScreenOrientation.java | 22 ++++++++++++++---- .../java/org/mozilla/geckoview/GeckoView.java | 6 ++--- 3 files changed, 19 insertions(+), 32 deletions(-) diff --git a/mobile/android/geckoview/src/main/java/org/mozilla/gecko/GeckoAppShell.java b/mobile/android/geckoview/src/main/java/org/mozilla/gecko/GeckoAppShell.java index bb7408fbc27b..0aa734411bea 100644 --- a/mobile/android/geckoview/src/main/java/org/mozilla/gecko/GeckoAppShell.java +++ b/mobile/android/geckoview/src/main/java/org/mozilla/gecko/GeckoAppShell.java @@ -1261,10 +1261,6 @@ public class GeckoAppShell { return GeckoScreenOrientation.getInstance().getScreenOrientation().value; } - /* package */ static int getRotation() { - return sScreenCompat.getRotation(); - } - @WrapForJNI(calledFrom = "gecko") private static int getScreenAngle() { return GeckoScreenOrientation.getInstance().getAngle(); @@ -1390,8 +1386,6 @@ public class GeckoAppShell { private interface ScreenCompat { Rect getScreenSize(); - - int getRotation(); } @TargetApi(Build.VERSION_CODES.JELLY_BEAN) @@ -1402,12 +1396,6 @@ public class GeckoAppShell { final Display disp = wm.getDefaultDisplay(); return new Rect(0, 0, disp.getWidth(), disp.getHeight()); } - - public int getRotation() { - final WindowManager wm = - (WindowManager) getApplicationContext().getSystemService(Context.WINDOW_SERVICE); - return wm.getDefaultDisplay().getRotation(); - } } @TargetApi(Build.VERSION_CODES.JELLY_BEAN_MR1) @@ -1420,12 +1408,6 @@ public class GeckoAppShell { disp.getRealSize(size); return new Rect(0, 0, size.x, size.y); } - - public int getRotation() { - final WindowManager wm = - (WindowManager) getApplicationContext().getSystemService(Context.WINDOW_SERVICE); - return wm.getDefaultDisplay().getRotation(); - } } @TargetApi(Build.VERSION_CODES.S) @@ -1449,11 +1431,6 @@ public class GeckoAppShell { final WindowManager windowManager = getWindowContext().getSystemService(WindowManager.class); return windowManager.getCurrentWindowMetrics().getBounds(); } - - public int getRotation() { - final WindowManager windowManager = getWindowContext().getSystemService(WindowManager.class); - return windowManager.getDefaultDisplay().getRotation(); - } } static { diff --git a/mobile/android/geckoview/src/main/java/org/mozilla/gecko/GeckoScreenOrientation.java b/mobile/android/geckoview/src/main/java/org/mozilla/gecko/GeckoScreenOrientation.java index 54d01a90215b..6e91d019bdbb 100644 --- a/mobile/android/geckoview/src/main/java/org/mozilla/gecko/GeckoScreenOrientation.java +++ b/mobile/android/geckoview/src/main/java/org/mozilla/gecko/GeckoScreenOrientation.java @@ -8,10 +8,12 @@ package org.mozilla.gecko; import static android.content.res.Configuration.ORIENTATION_LANDSCAPE; import static android.content.res.Configuration.ORIENTATION_PORTRAIT; +import android.content.Context; import android.graphics.Rect; import android.util.Log; import android.view.Display; import android.view.Surface; +import android.view.WindowManager; import java.util.ArrayList; import java.util.List; import org.mozilla.gecko.util.ThreadUtils; @@ -103,10 +105,14 @@ public class GeckoScreenOrientation { * @return Whether the screen orientation has changed. */ public boolean update() { - final Rect rect = GeckoAppShell.getScreenSizeIgnoreOverride(); - final int orientation = - rect.width() >= rect.height() ? ORIENTATION_LANDSCAPE : ORIENTATION_PORTRAIT; - return update(getScreenOrientation(orientation, getRotation())); + final Context appContext = GeckoAppShell.getApplicationContext(); + if (appContext == null) { + return false; + } + final WindowManager windowManager = + (WindowManager) appContext.getSystemService(Context.WINDOW_SERVICE); + final Display display = windowManager.getDefaultDisplay(); + return update(getScreenOrientation(display)); } /* @@ -262,6 +268,12 @@ public class GeckoScreenOrientation { * @return Device rotation. */ private int getRotation() { - return GeckoAppShell.getRotation(); + final Context appContext = GeckoAppShell.getApplicationContext(); + if (appContext == null) { + return DEFAULT_ROTATION; + } + final WindowManager windowManager = + (WindowManager) appContext.getSystemService(Context.WINDOW_SERVICE); + return windowManager.getDefaultDisplay().getRotation(); } } diff --git a/mobile/android/geckoview/src/main/java/org/mozilla/geckoview/GeckoView.java b/mobile/android/geckoview/src/main/java/org/mozilla/geckoview/GeckoView.java index 933620139518..b78809a670c7 100644 --- a/mobile/android/geckoview/src/main/java/org/mozilla/geckoview/GeckoView.java +++ b/mobile/android/geckoview/src/main/java/org/mozilla/geckoview/GeckoView.java @@ -635,15 +635,13 @@ public class GeckoView extends FrameLayout { if (mSession != null) { final GeckoRuntime runtime = mSession.getRuntime(); if (runtime != null) { - if (Build.VERSION.SDK_INT < Build.VERSION_CODES.JELLY_BEAN_MR1 - || Build.VERSION.SDK_INT >= Build.VERSION_CODES.S) { + if (Build.VERSION.SDK_INT < Build.VERSION_CODES.JELLY_BEAN_MR1) { // onConfigurationChanged is not called for 180 degree orientation changes, // we will miss such rotations and the screen orientation will not be // updated. // // If API is 17+, we use DisplayManager API to detect all degree - // orientation change. But if API is 31+, DisplayManager API may report previous - // information. So we have to report it again. + // orientation change. runtime.orientationChanged(newConfig.orientation); }