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;
}
/* 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 {

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_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();
}
}

View file

@ -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);
}