Bug 1612785 - GVE should set WindowManager.LayoutParams.LAYOUT_IN_DISPLAY_CUTOUT_* via onMetaViewportFitChange. r=geckoview-reviewers,snorp
authorMakoto Kato <m_kato@ga2.so-net.ne.jp>
Thu, 06 Feb 2020 16:55:15 +0000
changeset 512982 816d915c7743bf7864ed72e90243600137b4063e
parent 512981 dff38d5e834ad654a3109a6512ead06b95ba9ad6
child 512983 d7d2319910a1863871f4c21b081f48f3690b0129
push id37105
push userapavel@mozilla.com
push dateMon, 10 Feb 2020 09:39:12 +0000
treeherdermozilla-central@4c08723ed20a [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersgeckoview-reviewers, snorp
bugs1612785, 1574307, 1503656
milestone74.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1612785 - GVE should set WindowManager.LayoutParams.LAYOUT_IN_DISPLAY_CUTOUT_* via onMetaViewportFitChange. r=geckoview-reviewers,snorp This is follow up of bug 1574307 (and bug 1503656). Differential Revision: https://phabricator.services.mozilla.com/D61431
mobile/android/geckoview_example/src/main/java/org/mozilla/geckoview_example/GeckoViewActivity.java
--- a/mobile/android/geckoview_example/src/main/java/org/mozilla/geckoview_example/GeckoViewActivity.java
+++ b/mobile/android/geckoview_example/src/main/java/org/mozilla/geckoview_example/GeckoViewActivity.java
@@ -1130,16 +1130,32 @@ public class GeckoViewActivity
                 }
                 return result.then(value -> {
                     activeAlert = false;
                     return GeckoResult.fromValue(value);
                 });
             }
             return null;
         }
+
+        @Override
+        public void onMetaViewportFitChange(final GeckoSession session, final String viewportFit) {
+            if (Build.VERSION.SDK_INT < Build.VERSION_CODES.P) {
+                return;
+            }
+            WindowManager.LayoutParams layoutParams = getWindow().getAttributes();
+            if (viewportFit.equals("cover")) {
+                layoutParams.layoutInDisplayCutoutMode = WindowManager.LayoutParams.LAYOUT_IN_DISPLAY_CUTOUT_MODE_SHORT_EDGES;
+            } else if (viewportFit.equals("contain")) {
+                layoutParams.layoutInDisplayCutoutMode = WindowManager.LayoutParams.LAYOUT_IN_DISPLAY_CUTOUT_MODE_NEVER;
+            } else {
+                layoutParams.layoutInDisplayCutoutMode = WindowManager.LayoutParams.LAYOUT_IN_DISPLAY_CUTOUT_MODE_DEFAULT;
+            }
+            getWindow().setAttributes(layoutParams);
+        }
     }
 
     private class ExampleProgressDelegate implements GeckoSession.ProgressDelegate {
         private ExampleContentBlockingDelegate mCb;
 
         private ExampleProgressDelegate(final ExampleContentBlockingDelegate cb) {
             mCb = cb;
         }