Backed out changeset ddf5f22cd611 (bug 1806072) for blocking Android Components from being updated in Fenix nightly. CLOSED TREE

This commit is contained in:
Butkovits Atila 2022-12-27 21:29:51 +02:00
parent 4f2a45d1eb
commit cecaedb56f
3 changed files with 19 additions and 32 deletions

View file

@ -1261,10 +1261,6 @@ public class GeckoAppShell {
return GeckoScreenOrientation.getInstance().getScreenOrientation().value; return GeckoScreenOrientation.getInstance().getScreenOrientation().value;
} }
/* package */ static int getRotation() {
return sScreenCompat.getRotation();
}
@WrapForJNI(calledFrom = "gecko") @WrapForJNI(calledFrom = "gecko")
private static int getScreenAngle() { private static int getScreenAngle() {
return GeckoScreenOrientation.getInstance().getAngle(); return GeckoScreenOrientation.getInstance().getAngle();
@ -1390,8 +1386,6 @@ public class GeckoAppShell {
private interface ScreenCompat { private interface ScreenCompat {
Rect getScreenSize(); Rect getScreenSize();
int getRotation();
} }
@TargetApi(Build.VERSION_CODES.JELLY_BEAN) @TargetApi(Build.VERSION_CODES.JELLY_BEAN)
@ -1402,12 +1396,6 @@ public class GeckoAppShell {
final Display disp = wm.getDefaultDisplay(); final Display disp = wm.getDefaultDisplay();
return new Rect(0, 0, disp.getWidth(), disp.getHeight()); 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) @TargetApi(Build.VERSION_CODES.JELLY_BEAN_MR1)
@ -1420,12 +1408,6 @@ public class GeckoAppShell {
disp.getRealSize(size); disp.getRealSize(size);
return new Rect(0, 0, size.x, size.y); 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) @TargetApi(Build.VERSION_CODES.S)
@ -1449,11 +1431,6 @@ public class GeckoAppShell {
final WindowManager windowManager = getWindowContext().getSystemService(WindowManager.class); final WindowManager windowManager = getWindowContext().getSystemService(WindowManager.class);
return windowManager.getCurrentWindowMetrics().getBounds(); return windowManager.getCurrentWindowMetrics().getBounds();
} }
public int getRotation() {
final WindowManager windowManager = getWindowContext().getSystemService(WindowManager.class);
return windowManager.getDefaultDisplay().getRotation();
}
} }
static { static {

View file

@ -8,10 +8,12 @@ package org.mozilla.gecko;
import static android.content.res.Configuration.ORIENTATION_LANDSCAPE; import static android.content.res.Configuration.ORIENTATION_LANDSCAPE;
import static android.content.res.Configuration.ORIENTATION_PORTRAIT; import static android.content.res.Configuration.ORIENTATION_PORTRAIT;
import android.content.Context;
import android.graphics.Rect; import android.graphics.Rect;
import android.util.Log; import android.util.Log;
import android.view.Display; import android.view.Display;
import android.view.Surface; import android.view.Surface;
import android.view.WindowManager;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import org.mozilla.gecko.util.ThreadUtils; import org.mozilla.gecko.util.ThreadUtils;
@ -103,10 +105,14 @@ public class GeckoScreenOrientation {
* @return Whether the screen orientation has changed. * @return Whether the screen orientation has changed.
*/ */
public boolean update() { public boolean update() {
final Rect rect = GeckoAppShell.getScreenSizeIgnoreOverride(); final Context appContext = GeckoAppShell.getApplicationContext();
final int orientation = if (appContext == null) {
rect.width() >= rect.height() ? ORIENTATION_LANDSCAPE : ORIENTATION_PORTRAIT; return false;
return update(getScreenOrientation(orientation, getRotation())); }
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. * @return Device rotation.
*/ */
private int getRotation() { 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();
} }
} }

View file

@ -635,15 +635,13 @@ public class GeckoView extends FrameLayout {
if (mSession != null) { if (mSession != null) {
final GeckoRuntime runtime = mSession.getRuntime(); final GeckoRuntime runtime = mSession.getRuntime();
if (runtime != null) { if (runtime != null) {
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.JELLY_BEAN_MR1 if (Build.VERSION.SDK_INT < Build.VERSION_CODES.JELLY_BEAN_MR1) {
|| Build.VERSION.SDK_INT >= Build.VERSION_CODES.S) {
// onConfigurationChanged is not called for 180 degree orientation changes, // onConfigurationChanged is not called for 180 degree orientation changes,
// we will miss such rotations and the screen orientation will not be // we will miss such rotations and the screen orientation will not be
// updated. // updated.
// //
// If API is 17+, we use DisplayManager API to detect all degree // If API is 17+, we use DisplayManager API to detect all degree
// orientation change. But if API is 31+, DisplayManager API may report previous // orientation change.
// information. So we have to report it again.
runtime.orientationChanged(newConfig.orientation); runtime.orientationChanged(newConfig.orientation);
} }