Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(689)

Unified Diff: content/public/android/java/src/org/chromium/content/browser/ScreenOrientationProvider.java

Issue 2696303004: Android screen orientation lock should lock/unlock the same activity (Closed)
Patch Set: Add data deps to chrome_test_java Created 3 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: content/public/android/java/src/org/chromium/content/browser/ScreenOrientationProvider.java
diff --git a/content/public/android/java/src/org/chromium/content/browser/ScreenOrientationProvider.java b/content/public/android/java/src/org/chromium/content/browser/ScreenOrientationProvider.java
index 80a80cdc7f972e1b7121681b04313b1d226b3271..5fd2b41106db04aed0d7295fa03eab30ed7efaa0 100644
--- a/content/public/android/java/src/org/chromium/content/browser/ScreenOrientationProvider.java
+++ b/content/public/android/java/src/org/chromium/content/browser/ScreenOrientationProvider.java
@@ -10,7 +10,6 @@ import android.content.pm.ActivityInfo;
import android.content.pm.PackageManager;
import android.view.Surface;
-import org.chromium.base.ApplicationStatus;
import org.chromium.base.Log;
import org.chromium.base.ThreadUtils;
import org.chromium.base.annotations.CalledByNative;
@@ -71,14 +70,15 @@ public class ScreenOrientationProvider {
}
}
- // Note that WindowAndroid may be null if the tab is being reparented.
@CalledByNative
- static void lockOrientation(@Nullable WindowAndroid window, byte orientation) {
- lockOrientation(window, orientation, ApplicationStatus.getLastTrackedFocusedActivity());
- }
-
- public static void lockOrientation(@Nullable WindowAndroid window, byte webScreenOrientation,
- Activity activity) {
+ public static void lockOrientation(@Nullable WindowAndroid window, byte webScreenOrientation) {
+ // WindowAndroid may be null if the tab is being reparented.
+ if (window == null) return;
+ Activity activity = window.getActivity().get();
+
+ // Locking orientation is only supported for web contents that have an associated activity.
+ // Note that we can't just use the focused activity, as that would lead to bugs where
+ // unlockOrientation unlocks a different activity to the one that was locked.
if (activity == null) return;
int orientation = getOrientationFromWebScreenOrientations(webScreenOrientation, window,
@@ -90,13 +90,16 @@ public class ScreenOrientationProvider {
activity.setRequestedOrientation(orientation);
}
- // Note that WindowAndroid may be null if the tab is being reparented.
@CalledByNative
static void unlockOrientation(@Nullable WindowAndroid window) {
- Activity activity = ApplicationStatus.getLastTrackedFocusedActivity();
- if (activity == null) {
- return;
- }
+ // WindowAndroid may be null if the tab is being reparented.
+ if (window == null) return;
+ Activity activity = window.getActivity().get();
+
+ // Locking orientation is only supported for web contents that have an associated activity.
+ // Note that we can't just use the focused activity, as that would lead to bugs where
+ // unlockOrientation unlocks a different activity to the one that was locked.
+ if (activity == null) return;
int defaultOrientation = ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED;

Powered by Google App Engine
This is Rietveld 408576698