Bug 1694481 - Remove unused android lock screen orientation support. r=aklotz

Differential Revision: https://phabricator.services.mozilla.com/D106184
This commit is contained in:
Agi Sferro 2021-03-10 22:43:09 +00:00
Родитель eac41f1807
Коммит 0d3819e98e
10 изменённых файлов: 2 добавлений и 211 удалений

Просмотреть файл

@ -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

Просмотреть файл

@ -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<String, PowerManager.WakeLock> 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;

Просмотреть файл

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

Просмотреть файл

@ -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 <code>ScreenOrientationDelegate</code> is responsible for setting the screen orientation.
* <p>
* A browser that wants to support the <a href="https://w3c.github.io/screen-orientation/">Screen
* Orientation API</a> MUST implement these methods. A GeckoView consumer MAY implement these
* methods.
* <p> 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);
}

Просмотреть файл

@ -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

Просмотреть файл

@ -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

Просмотреть файл

@ -8,6 +8,5 @@
[Test that screen.orientation.lock() is actually async]
expected:
if os == "android": TIMEOUT
FAIL

Просмотреть файл

@ -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

Просмотреть файл

@ -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

Просмотреть файл

@ -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