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

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

Issue 2797703002: Fix showing 2D chrome shortly after DON finished (Closed)
Patch Set: Created 3 years, 8 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 d16b4d45d162d6deac6b87e0479de233bc6a4e5d..7908aa6e91e324f58620cfb3297d5acd699d2611 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
@@ -393,7 +393,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();
@@ -405,7 +404,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() {
@@ -416,14 +415,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.
+ mActivity.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);
addVrViews();
mVrShell.initializeNative(mActivity.getActivityTab(), mRequestedWebVR);
@@ -437,7 +436,9 @@ public class VrShellDelegate implements ApplicationStatus.ActivityStateListener,
@Override
public void onSystemUiVisibilityChange(int visibility) {
- if (mInVr && !isWindowModeCorrectForVr()) setWindowModeForVr();
+ if (mInVr && !isWindowModeCorrectForVr()) {
+ setWindowModeForVr(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);
+ }
}
private boolean isWindowModeCorrectForVr() {
@@ -446,14 +447,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())) {
@@ -531,7 +538,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;
}
}
@@ -570,6 +582,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;
}
@@ -681,11 +694,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