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

Unified Diff: chrome/android/java/src/org/chromium/chrome/browser/vr_shell/VrShellDelegate.java

Issue 2779223004: Fix showing 2D chrome shortly after DON finished (Closed)
Patch Set: rebase and comments Created 3 years, 9 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/android/java/src/org/chromium/chrome/browser/vr_shell/VrShellDelegate.java
diff --git a/chrome/android/java/src/org/chromium/chrome/browser/vr_shell/VrShellDelegate.java b/chrome/android/java/src/org/chromium/chrome/browser/vr_shell/VrShellDelegate.java
index 5fed60093b0ba0df5411b81bd1f76db19fb56200..e57f78a08b459d949b4fc65b360047dcacca73c6 100644
--- a/chrome/android/java/src/org/chromium/chrome/browser/vr_shell/VrShellDelegate.java
+++ b/chrome/android/java/src/org/chromium/chrome/browser/vr_shell/VrShellDelegate.java
@@ -389,7 +389,6 @@ public class VrShellDelegate implements ApplicationStatus.ActivityStateListener,
if (mPaused) {
// We can't enter VR before the application resumes, or we encounter bizarre crashes
// related to gpu surfaces. Set this flag to enter VR on the next resume.
- setWindowModeForVr();
mEnteringVr = true;
} else {
enterVR();
@@ -401,7 +400,7 @@ public class VrShellDelegate implements ApplicationStatus.ActivityStateListener,
if (mNativeVrShellDelegate == 0) return;
if (mInVr) return;
if (!isWindowModeCorrectForVr()) {
- setWindowModeForVr();
+ setWindowModeForVr(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);
new Handler().post(new Runnable() {
@Override
public void run() {
@@ -412,14 +411,14 @@ public class VrShellDelegate implements ApplicationStatus.ActivityStateListener,
}
mEnteringVr = false;
if (!createVrShell()) {
- if (mRestoreOrientation != null) mActivity.setRequestedOrientation(mRestoreOrientation);
- mRestoreOrientation = null;
- clearVrModeWindowFlags();
+ restoreWindowMode();
setEnterVRResult(false);
return;
}
mVrClassesWrapper.setVrModeEnabled(mActivity, true);
mInVr = true;
+ // Lock orientation to landscape after enter VR.
mthiesse 2017/03/30 18:40:14 Is this redundant with the call above to setWindow
bshe 2017/03/30 21:04:19 you mean line 403? It might not be called if we re
+ mActivity.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);
addVrViews();
mVrShell.initializeNative(mActivity.getActivityTab(), mRequestedWebVR);
@@ -435,7 +434,9 @@ public class VrShellDelegate implements ApplicationStatus.ActivityStateListener,
@Override
public void onSystemUiVisibilityChange(int visibility) {
mthiesse 2017/03/30 18:22:48 Won't this get called immediately when you call se
bshe 2017/03/30 18:33:54 I think we have mInVr to protect against this from
- if (mInVr && !isWindowModeCorrectForVr()) setWindowModeForVr();
+ if (mInVr && !isWindowModeCorrectForVr()) {
+ setWindowModeForVr(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);
+ }
}
private boolean isWindowModeCorrectForVr() {
@@ -444,14 +445,20 @@ public class VrShellDelegate implements ApplicationStatus.ActivityStateListener,
return flags == VR_SYSTEM_UI_FLAGS && orientation == Configuration.ORIENTATION_LANDSCAPE;
}
- private void setWindowModeForVr() {
+ private void setWindowModeForVr(int requestedOrientation) {
if (mRestoreOrientation == null) {
mRestoreOrientation = mActivity.getRequestedOrientation();
}
- mActivity.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);
+ mActivity.setRequestedOrientation(requestedOrientation);
setupVrModeWindowFlags();
}
+ private void restoreWindowMode() {
+ if (mRestoreOrientation != null) mActivity.setRequestedOrientation(mRestoreOrientation);
+ mRestoreOrientation = null;
+ clearVrModeWindowFlags();
+ }
+
private void setEnterVRResult(boolean success) {
if (mRequestedWebVR) nativeSetPresentResult(mNativeVrShellDelegate, success);
if (!success && !mVrDaydreamApi.exitFromVr(EXIT_VR_RESULT, new Intent())) {
@@ -529,7 +536,12 @@ public class VrShellDelegate implements ApplicationStatus.ActivityStateListener,
// due to the lack of support for unexported activities.
enterVR();
} else {
+ // LANDSCAPE orientation is needed before we can safely enter VR. DON can make sure that
+ // the device is at LANDSCAPE orientation once it is finished. So here we use SENSOR to
+ // avoid forcing LANDSCAPE orientation in order to have a smoother transition.
+ setWindowModeForVr(ActivityInfo.SCREEN_ORIENTATION_SENSOR);
if (!mVrDaydreamApi.launchInVr(getEnterVRPendingIntent(mVrDaydreamApi, mActivity))) {
+ restoreWindowMode();
return ENTER_VR_CANCELLED;
}
}
@@ -568,6 +580,7 @@ public class VrShellDelegate implements ApplicationStatus.ActivityStateListener,
// If this is still set, it means the user backed out of the DON flow, and we won't be
// receiving an intent from daydream.
nativeSetPresentResult(mNativeVrShellDelegate, false);
+ restoreWindowMode();
mRequestedWebVR = false;
}
@@ -679,11 +692,9 @@ public class VrShellDelegate implements ApplicationStatus.ActivityStateListener,
mVrClassesWrapper.setVrModeEnabled(mActivity, false);
mLastVRExit = SystemClock.uptimeMillis();
}
- if (mRestoreOrientation != null) mActivity.setRequestedOrientation(mRestoreOrientation);
- mRestoreOrientation = null;
+ restoreWindowMode();
mVrShell.pause();
removeVrViews();
- clearVrModeWindowFlags();
destroyVrShell();
mActivity.getFullscreenManager().setPositionsForTabToNonFullscreen();
}
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698