Bug 1488691 - Prevent registering listeners if PIP failed; r=jchen a=pascalc DEVEDITION_63_0b5_BUILD1 DEVEDITION_63_0b5_RELEASE FENNEC_63_0b5_BUILD1 FENNEC_63_0b5_RELEASE FIREFOX_63_0b5_BUILD1 FIREFOX_63_0b5_RELEASE
authorPetru Lingurar <petru.lingurar@softvision.ro>
Thu, 06 Sep 2018 18:41:09 +0000
changeset 489793 554953db0c6120f7c67794dfb1bd5b493f15749d
parent 489792 69daa09be6b7b325dd099f3080020910cb2964e3
child 489794 b0456d21ba3ebd26912ddfce555cc75f150ab9cf
push id9777
push userarchaeopteryx@coole-files.de
push dateMon, 10 Sep 2018 13:24:16 +0000
treeherdermozilla-beta@554953db0c61 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjchen, pascalc
bugs1488691
milestone63.0
Bug 1488691 - Prevent registering listeners if PIP failed; r=jchen a=pascalc Also, if entering PIP fails will make sure that upon restarting the activity it's orientation will match device's. Differential Revision: https://phabricator.services.mozilla.com/D5035
mobile/android/base/java/org/mozilla/gecko/BrowserApp.java
mobile/android/base/java/org/mozilla/gecko/media/PictureInPictureController.java
--- a/mobile/android/base/java/org/mozilla/gecko/BrowserApp.java
+++ b/mobile/android/base/java/org/mozilla/gecko/BrowserApp.java
@@ -1053,16 +1053,17 @@ public class BrowserApp extends GeckoApp
 
     @Override
     protected void onUserLeaveHint() {
         super.onUserLeaveHint();
         try {
             mPipController.tryEnteringPictureInPictureMode();
         } catch (IllegalStateException exception) {
             Log.e(LOGTAG, "Cannot enter in Picture In Picture mode:\n" + exception.getMessage());
+            setRequestedOrientationForCurrentActivity(ActivityInfo.SCREEN_ORIENTATION_FULL_SENSOR);
         }
     }
 
     @Override
     public void onPictureInPictureModeChanged(boolean isInPictureInPictureMode, Configuration newConfig) {
         super.onPictureInPictureModeChanged(isInPictureInPictureMode, newConfig);
 
         if (!isInPictureInPictureMode) {
--- a/mobile/android/base/java/org/mozilla/gecko/media/PictureInPictureController.java
+++ b/mobile/android/base/java/org/mozilla/gecko/media/PictureInPictureController.java
@@ -38,19 +38,19 @@ public class PictureInPictureController 
     }
 
     /**
      * If the feature is supported and media is playing in fullscreen will try to activate
      * Picture In Picture mode for the current activity.
      * @throws IllegalStateException if entering Picture In Picture mode was not possible.
      */
     public void tryEnteringPictureInPictureMode() throws IllegalStateException {
-        if (shouldTryPipMode()) {
+        if (shouldTryPipMode() &&
+                pipActivity.enterPictureInPictureMode(getPipParams(isMediaPlaying()))) {
             EventDispatcher.getInstance().registerUiThreadListener(this, "MediaControlService:MediaPlayingStatus");
-            pipActivity.enterPictureInPictureMode(getPipParams(isMediaPlaying()));
             isInPipMode = true;
         }
     }
 
     public void cleanResources() {
         if (isInPipMode) {
             EventDispatcher.getInstance().unregisterUiThreadListener(this, "MediaControlService:MediaPlayingStatus");
             isInPipMode = false;