Commit 0e39bd62 authored by Benjamin Pastene's avatar Benjamin Pastene Committed by Commit Bot

Revert "VR: Use isInVrSession API to keep Chrome in VR until user has left VR"

This reverts commit dc55fd14.

Reason for revert: Suspected to have broken chrome_public_test_vr_apk on main waterfall
https://ci.chromium.org/buildbot/chromium.android/Marshmallow%20Phone%20Tester%20%28rel%29/?limit=200
first failing build contains this cl:
https://ci.chromium.org/buildbot/chromium.android/Marshmallow%20Phone%20Tester%20%28rel%29/3088

Original change's description:
> VR: Use isInVrSession API to keep Chrome in VR until user has left VR
> 
> This fixes the Daydream Dashboard issues so that if Chrome is simply
> stopped/started in VR without any intents, Chrome stays in VR.
> 
> Also makes resuming Chrome from DD home way faster if Chrome was
> already in VR.
> 
> Bug: 780887
> Change-Id: Iab7f713bfc5b85972f908ea141e3b495297d7286
> Reviewed-on: https://chromium-review.googlesource.com/944547
> Reviewed-by: Yash Malik <ymalik@chromium.org>
> Commit-Queue: Michael Thiessen <mthiesse@chromium.org>
> Cr-Commit-Position: refs/heads/master@{#540403}

TBR=mthiesse@chromium.org,ymalik@chromium.org

Change-Id: I7ae67f5d23d816796cc7f567792e181900b3012a
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Bug: 780887
Reviewed-on: https://chromium-review.googlesource.com/946709Reviewed-by: default avatarBenjamin Pastene <bpastene@chromium.org>
Commit-Queue: Benjamin Pastene <bpastene@chromium.org>
Cr-Commit-Position: refs/heads/master@{#540588}
parent b36a6c8d
...@@ -77,12 +77,6 @@ public interface VrDaydreamApi { ...@@ -77,12 +77,6 @@ public interface VrDaydreamApi {
*/ */
Intent setupVrIntent(Intent intent); Intent setupVrIntent(Intent intent);
/**
* Whether the user is currently in a VR session. Note that this should be treated as heuristic,
* and may at times be wrong.
*/
boolean isInVrSession();
/** /**
* Closes this DaydreamApi instance. * Closes this DaydreamApi instance.
*/ */
......
...@@ -134,11 +134,6 @@ public class VrDaydreamApiImpl implements VrDaydreamApi { ...@@ -134,11 +134,6 @@ public class VrDaydreamApiImpl implements VrDaydreamApi {
return DaydreamApi.setupVrIntent(intent); return DaydreamApi.setupVrIntent(intent);
} }
@Override
public boolean isInVrSession() {
return DaydreamApi.isInVrSession(mContext);
}
@Override @Override
public void close() { public void close() {
if (mDaydreamApi == null) return; if (mDaydreamApi == null) return;
......
...@@ -971,16 +971,16 @@ public class VrShellDelegate ...@@ -971,16 +971,16 @@ public class VrShellDelegate
} }
private void onVrIntent() { private void onVrIntent() {
mNeedsAnimationCancel = true;
mInVrAtChromeLaunch = true;
if (mInVr) return; if (mInVr) return;
mNeedsAnimationCancel = true;
mEnterVrOnStartup = true; mEnterVrOnStartup = true;
// TODO(mthiesse): Assuming we've gone through DON flow saves ~2 seconds on VR entry. See // TODO(mthiesse): Assuming we've gone through DON flow saves ~2 seconds on VR entry. See
// the comments in enterVr(). This may not always be the case in the future, but for now // the comments in enterVr(). This may not always be the case in the future, but for now
// it's a reasonable assumption. // it's a reasonable assumption.
mDonSucceeded = true; mDonSucceeded = true;
mInVrAtChromeLaunch = true;
if (!mPaused) enterVrAfterDon(); if (!mPaused) enterVrAfterDon();
} }
...@@ -1362,23 +1362,24 @@ public class VrShellDelegate ...@@ -1362,23 +1362,24 @@ public class VrShellDelegate
}); });
} }
mCancellingEntryAnimation = false;
if (mEnterVrOnStartup) { if (mEnterVrOnStartup) {
// This means that Chrome was started with a VR intent, so we should enter VR. // This means that Chrome was started with a VR intent, so we should enter VR.
// TODO(crbug.com/776235): VR intents are dispatched to ChromeActivity via a launcher // TODO(crbug.com/776235): VR intents are dispatched to ChromeActivity via a launcher
// which should handle the DON flow to simplify the logic in VrShellDelegate. // which should handle the DON flow to simplify the logic in VrShellDelegate.
assert !mProbablyInDon; assert !mProbablyInDon;
if (DEBUG_LOGS) Log.i(TAG, "onResume: entering VR mode for VR intent"); if (DEBUG_LOGS) Log.i(TAG, "onResume: entering VR mode for VR intent");
mCancellingEntryAnimation = false;
if (enterVrInternal() == ENTER_VR_CANCELLED) { if (enterVrInternal() == ENTER_VR_CANCELLED) {
cancelPendingVrEntry(); cancelPendingVrEntry();
} }
} else if (mDonSucceeded) { } else if (mDonSucceeded) {
mCancellingEntryAnimation = false;
handleDonFlowSuccess(); handleDonFlowSuccess();
} else { } else {
if (mProbablyInDon) { if (mProbablyInDon) {
// This means the user backed out of the DON flow, and we won't be entering VR. // This means the user backed out of the DON flow, and we won't be entering VR.
maybeSetPresentResult(false, mDonSucceeded); maybeSetPresentResult(false, mDonSucceeded);
shutdownVr(true, false); shutdownVr(true, false);
} }
// If we were resumed at the wrong density, we need to trigger activity recreation. // If we were resumed at the wrong density, we need to trigger activity recreation.
...@@ -1425,6 +1426,10 @@ public class VrShellDelegate ...@@ -1425,6 +1426,10 @@ public class VrShellDelegate
// are safe. // are safe.
if (mInVr) mVrShell.pause(); if (mInVr) mVrShell.pause();
if (mShowingDaydreamDoff || mProbablyInDon) return; if (mShowingDaydreamDoff || mProbablyInDon) return;
// TODO(mthiesse): When the user resumes Chrome in a 2D context, we don't want to tear down
// VR UI, so for now, exit VR.
shutdownVr(true /* disableVrMode */, false /* stayingInChrome */);
} }
protected void onPause() { protected void onPause() {
...@@ -1435,6 +1440,10 @@ public class VrShellDelegate ...@@ -1435,6 +1440,10 @@ public class VrShellDelegate
unregisterDaydreamIntent(mVrDaydreamApi); unregisterDaydreamIntent(mVrDaydreamApi);
if (mVrSupportLevel == VrSupportLevel.VR_NOT_AVAILABLE) return; if (mVrSupportLevel == VrSupportLevel.VR_NOT_AVAILABLE) return;
// TODO(ymalik): We should be able to remove this if we handle it for multi-window in
// {@link onMultiWindowModeChanged} since we're calling it in onStop.
if (!mInVr && !mProbablyInDon) cancelPendingVrEntry();
// When the active web page has a vrdisplayactivate event handler, // When the active web page has a vrdisplayactivate event handler,
// mListeningForWebVrActivate should be set to true, which means a vrdisplayactive event // mListeningForWebVrActivate should be set to true, which means a vrdisplayactive event
// should be fired once DON flow finished. However, DON flow will pause our activity, // should be fired once DON flow finished. However, DON flow will pause our activity,
...@@ -1453,12 +1462,12 @@ public class VrShellDelegate ...@@ -1453,12 +1462,12 @@ public class VrShellDelegate
private void onStart() { private void onStart() {
mStopped = false; mStopped = false;
if (mDonSucceeded) setWindowModeForVr(); if (mDonSucceeded) setWindowModeForVr();
if (mInVr && !mVrDaydreamApi.isInVrSession()) shutdownVr(true, false);
} }
private void onStop() { private void onStop() {
if (DEBUG_LOGS) Log.i(TAG, "onStop"); if (DEBUG_LOGS) Log.i(TAG, "onStop");
mStopped = true; mStopped = true;
if (!mProbablyInDon) cancelPendingVrEntry();
assert !mCancellingEntryAnimation; assert !mCancellingEntryAnimation;
} }
......
...@@ -100,9 +100,4 @@ public class MockVrDaydreamApi implements VrDaydreamApi { ...@@ -100,9 +100,4 @@ public class MockVrDaydreamApi implements VrDaydreamApi {
public void setForwardSetupIntent(boolean forward) { public void setForwardSetupIntent(boolean forward) {
mForwardSetupIntent = forward; mForwardSetupIntent = forward;
} }
@Override
public boolean isInVrSession() {
return true;
}
} }
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment