diff --git a/hal/android/AndroidHal.cpp b/hal/android/AndroidHal.cpp index 77ecf6459387..e1f2f792b522 100644 --- a/hal/android/AndroidHal.cpp +++ b/hal/android/AndroidHal.cpp @@ -124,33 +124,10 @@ void GetCurrentScreenConfiguration(ScreenConfiguration* aScreenConfiguration) { } bool LockScreenOrientation(const hal::ScreenOrientation& aOrientation) { - // Force the default orientation to be portrait-primary. - hal::ScreenOrientation orientation = - aOrientation == eScreenOrientation_Default - ? eScreenOrientation_PortraitPrimary - : aOrientation; - - switch (orientation) { - // The Android backend only supports these orientations. - case eScreenOrientation_PortraitPrimary: - case eScreenOrientation_PortraitSecondary: - case eScreenOrientation_PortraitPrimary | - eScreenOrientation_PortraitSecondary: - case eScreenOrientation_LandscapePrimary: - case eScreenOrientation_LandscapeSecondary: - case eScreenOrientation_LandscapePrimary | - eScreenOrientation_LandscapeSecondary: - case eScreenOrientation_Default: - java::GeckoAppShell::LockScreenOrientation(orientation); - return true; - default: - return false; - } + return false; } -void UnlockScreenOrientation() { - java::GeckoAppShell::UnlockScreenOrientation(); -} +void UnlockScreenOrientation() {} } // namespace hal_impl } // namespace mozilla 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 a646a94353b0..2021b846ac0a 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 @@ -379,7 +379,6 @@ public class GeckoAppShell { private static class DefaultListeners implements SensorEventListener, LocationListener, NotificationListener, - ScreenOrientationDelegate, WakeLockDelegate, HapticFeedbackDelegate { @Override @@ -516,13 +515,6 @@ public class GeckoAppShell { // Do nothing. } - @Override // ScreenOrientationDelegate - public boolean setRequestedOrientationForCurrentActivity( - final int requestedActivityInfoOrientation) { - // Do nothing, and report that the orientation was not set. - return false; - } - private SimpleArrayMap mWakeLocks; @Override // WakeLockDelegate @@ -591,11 +583,6 @@ public class GeckoAppShell { private static WakeLockDelegate sWakeLockDelegate = DEFAULT_LISTENERS; private static HapticFeedbackDelegate sHapticFeedbackDelegate = DEFAULT_LISTENERS; - /** - * A delegate for supporting the Screen Orientation API. - */ - private static ScreenOrientationDelegate sScreenOrientationDelegate = DEFAULT_LISTENERS; - public static SensorEventListener getSensorListener() { return sSensorListener; } @@ -620,15 +607,6 @@ public class GeckoAppShell { sNotificationListener = (listener != null) ? listener : DEFAULT_LISTENERS; } - public static ScreenOrientationDelegate getScreenOrientationDelegate() { - return sScreenOrientationDelegate; - } - - public static void setScreenOrientationDelegate( - final @Nullable ScreenOrientationDelegate screenOrientationDelegate) { - sScreenOrientationDelegate = (screenOrientationDelegate != null) ? screenOrientationDelegate : DEFAULT_LISTENERS; - } - public static WakeLockDelegate getWakeLockDelegate() { return sWakeLockDelegate; } @@ -1531,18 +1509,6 @@ public class GeckoAppShell { GeckoScreenOrientation.getInstance().disableNotifications(); } - @WrapForJNI(calledFrom = "gecko") - private static void lockScreenOrientation(final int aOrientation) { - // TODO: don't vector through GeckoAppShell. - GeckoScreenOrientation.getInstance().lock(aOrientation); - } - - @WrapForJNI(calledFrom = "gecko") - private static void unlockScreenOrientation() { - // TODO: don't vector through GeckoAppShell. - GeckoScreenOrientation.getInstance().unlock(); - } - @WrapForJNI(calledFrom = "gecko") private static void notifyWakeLockChanged(final String topic, final String state) { final int intState; 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 21ae490f860d..3622de403295 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 @@ -6,7 +6,6 @@ package org.mozilla.gecko; import android.content.Context; -import android.content.pm.ActivityInfo; import android.content.res.Configuration; import android.util.Log; import android.view.Surface; @@ -215,58 +214,6 @@ public class GeckoScreenOrientation { return mScreenOrientation; } - /** - * Lock screen orientation given the Gecko screen orientation. - * - * @param aGeckoOrientation - * The Gecko orientation provided. - */ - public void lock(final int aGeckoOrientation) { - lock(ScreenOrientation.get(aGeckoOrientation)); - } - - /** - * Lock screen orientation given the Gecko screen orientation. - * - * @param aScreenOrientation - * Gecko screen orientation derived from Android orientation and - * rotation. - * - * @return Whether the locking was successful. - */ - public boolean lock(final ScreenOrientation aScreenOrientation) { - Log.d(LOGTAG, "locking to " + aScreenOrientation); - final ScreenOrientationDelegate delegate = GeckoAppShell.getScreenOrientationDelegate(); - final int activityInfoOrientation = screenOrientationToActivityInfoOrientation(aScreenOrientation); - synchronized (this) { - if (delegate.setRequestedOrientationForCurrentActivity(activityInfoOrientation)) { - update(aScreenOrientation); - return true; - } else { - return false; - } - } - } - - /** - * Unlock and update screen orientation. - * - * @return Whether the unlocking was successful. - */ - public boolean unlock() { - Log.d(LOGTAG, "unlocking"); - final ScreenOrientationDelegate delegate = GeckoAppShell.getScreenOrientationDelegate(); - final int activityInfoOrientation = screenOrientationToActivityInfoOrientation(ScreenOrientation.DEFAULT); - synchronized (this) { - if (delegate.setRequestedOrientationForCurrentActivity(activityInfoOrientation)) { - update(); - return true; - } else { - return false; - } - } - } - /* * Combine the Android orientation and rotation to the Gecko orientation. * @@ -330,64 +277,4 @@ public class GeckoScreenOrientation { (WindowManager) appContext.getSystemService(Context.WINDOW_SERVICE); return windowManager.getDefaultDisplay().getRotation(); } - - /* - * Convert Gecko screen orientation to Android orientation. - * - * @param aScreenOrientation - * Gecko screen orientation. - * @return Android orientation. This conversion is lossy, the Android - * orientation does not differentiate between primary and secondary - * orientations. - */ - public static int screenOrientationToAndroidOrientation( - final ScreenOrientation aScreenOrientation) { - switch (aScreenOrientation) { - case PORTRAIT: - case PORTRAIT_PRIMARY: - case PORTRAIT_SECONDARY: - return Configuration.ORIENTATION_PORTRAIT; - case LANDSCAPE: - case LANDSCAPE_PRIMARY: - case LANDSCAPE_SECONDARY: - return Configuration.ORIENTATION_LANDSCAPE; - case NONE: - case DEFAULT: - default: - return Configuration.ORIENTATION_UNDEFINED; - } - } - - /* - * Convert Gecko screen orientation to Android ActivityInfo orientation. - * This is yet another orientation used by Android, but it's more detailed - * than the Android orientation. - * It is required for screen orientation locking and unlocking. - * - * @param aScreenOrientation - * Gecko screen orientation. - * @return Android ActivityInfo orientation. - */ - public static int screenOrientationToActivityInfoOrientation( - final ScreenOrientation aScreenOrientation) { - switch (aScreenOrientation) { - case PORTRAIT: - return ActivityInfo.SCREEN_ORIENTATION_SENSOR_PORTRAIT; - case PORTRAIT_PRIMARY: - return ActivityInfo.SCREEN_ORIENTATION_PORTRAIT; - case PORTRAIT_SECONDARY: - return ActivityInfo.SCREEN_ORIENTATION_REVERSE_PORTRAIT; - case LANDSCAPE: - return ActivityInfo.SCREEN_ORIENTATION_SENSOR_LANDSCAPE; - case LANDSCAPE_PRIMARY: - return ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE; - case LANDSCAPE_SECONDARY: - return ActivityInfo.SCREEN_ORIENTATION_REVERSE_LANDSCAPE; - case DEFAULT: - case NONE: - return ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED; - default: - return ActivityInfo.SCREEN_ORIENTATION_NOSENSOR; - } - } } diff --git a/mobile/android/geckoview/src/main/java/org/mozilla/gecko/ScreenOrientationDelegate.java b/mobile/android/geckoview/src/main/java/org/mozilla/gecko/ScreenOrientationDelegate.java deleted file mode 100644 index 0731abf39724..000000000000 --- a/mobile/android/geckoview/src/main/java/org/mozilla/gecko/ScreenOrientationDelegate.java +++ /dev/null @@ -1,26 +0,0 @@ -/* -*- Mode: Java; c-basic-offset: 4; tab-width: 20; indent-tabs-mode: nil; -*- - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ - -package org.mozilla.gecko; - -/** - * A ScreenOrientationDelegate is responsible for setting the screen orientation. - *

- * A browser that wants to support the Screen - * Orientation API MUST implement these methods. A GeckoView consumer MAY implement these - * methods. - *

To implement, consider registering an - * {@link android.app.Application.ActivityLifecycleCallbacks} handler to track the current - * foreground {@link android.app.Activity}. - */ -public interface ScreenOrientationDelegate { - /** - * If possible, set the current screen orientation. - * - * @param requestedActivityInfoOrientation An orientation constant as used in {@link android.content.pm.ActivityInfo#screenOrientation}. - * @return true if screen orientation could be set; false otherwise. - */ - boolean setRequestedOrientationForCurrentActivity(int requestedActivityInfoOrientation); -} diff --git a/testing/web-platform/meta/screen-orientation/active-lock.html.ini b/testing/web-platform/meta/screen-orientation/active-lock.html.ini index 05702d01dca4..7bc9f88c8f44 100644 --- a/testing/web-platform/meta/screen-orientation/active-lock.html.ini +++ b/testing/web-platform/meta/screen-orientation/active-lock.html.ini @@ -1,8 +1,5 @@ [active-lock.html] - expected: - if os == "android": TIMEOUT [When performing a fragment navigation, the orientation must not change or unlock] expected: - if os == "android": TIMEOUT FAIL diff --git a/testing/web-platform/meta/screen-orientation/event-before-promise.html.ini b/testing/web-platform/meta/screen-orientation/event-before-promise.html.ini index 615626adc256..c4659249af53 100644 --- a/testing/web-platform/meta/screen-orientation/event-before-promise.html.ini +++ b/testing/web-platform/meta/screen-orientation/event-before-promise.html.ini @@ -1,10 +1,8 @@ [event-before-promise.html] expected: if (os == "win") and (processor == "x86") and not debug: ["ERROR", "OK"] - if os == "android": TIMEOUT [OK, ERROR] [The 'change' event must fire before the [[orientationPendingPromise\]\] is resolved.] expected: - if os == "android": TIMEOUT FAIL diff --git a/testing/web-platform/meta/screen-orientation/lock-basic.html.ini b/testing/web-platform/meta/screen-orientation/lock-basic.html.ini index 45d9047cb933..888fb90db44b 100644 --- a/testing/web-platform/meta/screen-orientation/lock-basic.html.ini +++ b/testing/web-platform/meta/screen-orientation/lock-basic.html.ini @@ -8,6 +8,5 @@ [Test that screen.orientation.lock() is actually async] expected: - if os == "android": TIMEOUT FAIL diff --git a/testing/web-platform/meta/screen-orientation/lock-unlock-check.html.ini b/testing/web-platform/meta/screen-orientation/lock-unlock-check.html.ini index 604ecfa6cb4e..d1c893b3a4e6 100644 --- a/testing/web-platform/meta/screen-orientation/lock-unlock-check.html.ini +++ b/testing/web-platform/meta/screen-orientation/lock-unlock-check.html.ini @@ -1,9 +1,7 @@ [lock-unlock-check.html] expected: - if os == "android": TIMEOUT [OK, ERROR] [Re-locking orientation during event dispatch must reject existing orientationPendingPromise] expected: - if os == "android": TIMEOUT FAIL diff --git a/testing/web-platform/meta/screen-orientation/onchange-event.html.ini b/testing/web-platform/meta/screen-orientation/onchange-event.html.ini index 03fe419bf720..b27eb480ff74 100644 --- a/testing/web-platform/meta/screen-orientation/onchange-event.html.ini +++ b/testing/web-platform/meta/screen-orientation/onchange-event.html.ini @@ -2,15 +2,12 @@ expected: if (os == "win") and (processor == "x86") and not debug: ["ERROR", "OK"] if (os == "win") and (processor == "x86") and debug: ["ERROR", "OK"] - if os == "android": ["TIMEOUT", "OK", "ERROR"] [OK, ERROR] [Test that orientationchange event is fired when the orientation changes.] expected: - if os == "android": TIMEOUT FAIL [Test that orientationchange event is not fired when the orientation does not change.] expected: - if os == "android": PASS FAIL diff --git a/testing/web-platform/meta/screen-orientation/orientation-reading.html.ini b/testing/web-platform/meta/screen-orientation/orientation-reading.html.ini index da9d9104b5bf..2f56eaab20c5 100644 --- a/testing/web-platform/meta/screen-orientation/orientation-reading.html.ini +++ b/testing/web-platform/meta/screen-orientation/orientation-reading.html.ini @@ -6,11 +6,9 @@ [OK, ERROR] [Test that screen.orientation values change if the orientation changes] expected: - if os == "android": NOTRUN FAIL [Test the orientations and associated angles] expected: - if os == "android": TIMEOUT FAIL