Commit 2612b07d authored by Michael Thiessen's avatar Michael Thiessen Committed by Commit Bot

VR: Clean up (old) unused DON flow workarounds.

No functional changes - we haven't hit the deleted code path in many
months and it's no longer relevant now that we don't exit VR when
paused.

Change-Id: I1131de9f43675d000c366e7174dacae6e300c7d8
Reviewed-on: https://chromium-review.googlesource.com/1135824Reviewed-by: default avatarTibor Goldschwendt <tiborg@chromium.org>
Commit-Queue: Michael Thiessen <mthiesse@chromium.org>
Cr-Commit-Position: refs/heads/master@{#574994}
parent 11a4669a
...@@ -115,7 +115,6 @@ public class VrShellDelegate ...@@ -115,7 +115,6 @@ public class VrShellDelegate
"org.chromium.chrome.browser.vr.VrEntryResult"; "org.chromium.chrome.browser.vr.VrEntryResult";
private static final long REENTER_VR_TIMEOUT_MS = 1000; private static final long REENTER_VR_TIMEOUT_MS = 1000;
private static final int EXPECT_DON_TIMEOUT_MS = 2000;
private static final String FEEDBACK_REPORT_TYPE = "USER_INITIATED_FEEDBACK_REPORT_VR"; private static final String FEEDBACK_REPORT_TYPE = "USER_INITIATED_FEEDBACK_REPORT_VR";
...@@ -164,7 +163,6 @@ public class VrShellDelegate ...@@ -164,7 +163,6 @@ public class VrShellDelegate
private Boolean mIsDaydreamCurrentViewer; private Boolean mIsDaydreamCurrentViewer;
private boolean mProbablyInDon; private boolean mProbablyInDon;
private boolean mInVr; private boolean mInVr;
private final Handler mExpectPauseOrDonSucceeded;
private boolean mNeedsAnimationCancel; private boolean mNeedsAnimationCancel;
private boolean mCancellingEntryAnimation; private boolean mCancellingEntryAnimation;
...@@ -276,7 +274,6 @@ public class VrShellDelegate ...@@ -276,7 +274,6 @@ public class VrShellDelegate
sInstance.mDonSucceeded = true; sInstance.mDonSucceeded = true;
sInstance.mProbablyInDon = false; sInstance.mProbablyInDon = false;
sInstance.mExpectPauseOrDonSucceeded.removeCallbacksAndMessages(null);
setVrModeEnabled(sInstance.mActivity, true); setVrModeEnabled(sInstance.mActivity, true);
if (DEBUG_LOGS) Log.i(TAG, "VrBroadcastReceiver onReceive"); if (DEBUG_LOGS) Log.i(TAG, "VrBroadcastReceiver onReceive");
...@@ -1046,7 +1043,6 @@ public class VrShellDelegate ...@@ -1046,7 +1043,6 @@ public class VrShellDelegate
updateVrSupportLevel(null); updateVrSupportLevel(null);
mNativeVrShellDelegate = nativeInit(); mNativeVrShellDelegate = nativeInit();
mFeedbackFrequency = VrFeedbackStatus.getFeedbackFrequency(); mFeedbackFrequency = VrFeedbackStatus.getFeedbackFrequency();
mExpectPauseOrDonSucceeded = new Handler();
ensureLifecycleObserverInitialized(); ensureLifecycleObserverInitialized();
if (!mPaused) onResume(); if (!mPaused) onResume();
sInstance = this; sInstance = this;
...@@ -1182,16 +1178,10 @@ public class VrShellDelegate ...@@ -1182,16 +1178,10 @@ public class VrShellDelegate
return getVrSupportLevel() == VrSupportLevel.VR_DAYDREAM; return getVrSupportLevel() == VrSupportLevel.VR_DAYDREAM;
} }
private void maybeSetPresentResult(boolean result, boolean donCompleted) { private void maybeSetPresentResult(boolean result) {
if (mNativeVrShellDelegate == 0 || !mRequestedWebVr) return; if (mNativeVrShellDelegate == 0 || !mRequestedWebVr) return;
if (!result) { nativeSetPresentResult(mNativeVrShellDelegate, result);
nativeSetPresentResult(mNativeVrShellDelegate, false); mRequestedWebVr = false;
mRequestedWebVr = false;
} else if (!isDaydreamCurrentViewerInternal() || donCompleted) {
// Wait until DON success to report presentation success.
nativeSetPresentResult(mNativeVrShellDelegate, true);
mRequestedWebVr = false;
}
} }
/** /**
...@@ -1238,7 +1228,11 @@ public class VrShellDelegate ...@@ -1238,7 +1228,11 @@ public class VrShellDelegate
setVrModeEnabled(mActivity, true); setVrModeEnabled(mActivity, true);
setWindowModeForVr(); setWindowModeForVr();
boolean donSuceeded = mDonSucceeded;
// We assume that we triggered the DON flow already for Daydream viewers. If that changes,
// we need to make sure not to report success/fail to WebXR until after the DON flow runs.
assert mDonSucceeded || !isDaydreamCurrentViewerInternal();
mDonSucceeded = false; mDonSucceeded = false;
if (!createVrShell()) { if (!createVrShell()) {
cancelPendingVrEntry(); cancelPendingVrEntry();
...@@ -1263,28 +1257,9 @@ public class VrShellDelegate ...@@ -1263,28 +1257,9 @@ public class VrShellDelegate
// resume needs to be called on GvrLayout after initialization to make sure DON flow works // resume needs to be called on GvrLayout after initialization to make sure DON flow works
// properly. // properly.
if (mVisible) mVrShell.resume(); if (mVisible) mVrShell.resume();
mVrShell.getContainer().setOnSystemUiVisibilityChangeListener(this); mVrShell.getContainer().setOnSystemUiVisibilityChangeListener(this);
if (!donSuceeded && isDaydreamCurrentViewerInternal()) { maybeSetPresentResult(true);
// TODO(mthiesse): This is a VERY dirty hack. We need to know whether or not entering VR
// will trigger the DON flow, so that we can wait for it to complete before we let the
// webVR page know that it can present. However, Daydream APIs currently make this
// impossible for apps to know, so if the DON hasn't started after a delay we just
// assume it will never start. Once we know whether or not entering VR will trigger the
// DON flow, we should remove this. See b/63116739.
mProbablyInDon = true;
mExpectPauseOrDonSucceeded.postDelayed(new Runnable() {
@Override
public void run() {
mProbablyInDon = false;
mDonSucceeded = true;
mEnterVrOnStartup = false;
handleDonFlowSuccess();
}
}, EXPECT_DON_TIMEOUT_MS);
}
maybeSetPresentResult(true, donSuceeded);
if (ChromeFeatureList.isEnabled(ChromeFeatureList.VR_BROWSING_NATIVE_ANDROID_UI)) { if (ChromeFeatureList.isEnabled(ChromeFeatureList.VR_BROWSING_NATIVE_ANDROID_UI)) {
mUiWidgetFactoryBeforeEnterVr = UiWidgetFactory.getInstance(); mUiWidgetFactoryBeforeEnterVr = UiWidgetFactory.getInstance();
UiWidgetFactory.setInstance( UiWidgetFactory.setInstance(
...@@ -1493,21 +1468,21 @@ public class VrShellDelegate ...@@ -1493,21 +1468,21 @@ public class VrShellDelegate
if (DEBUG_LOGS) Log.i(TAG, "WebVR page requested presentation"); if (DEBUG_LOGS) Log.i(TAG, "WebVR page requested presentation");
mRequestedWebVr = true; mRequestedWebVr = true;
if (VrShellDelegate.bootsToVr() && !mInVr) { if (VrShellDelegate.bootsToVr() && !mInVr) {
maybeSetPresentResult(false, false); maybeSetPresentResult(false);
return; return;
} }
switch (enterVrInternal()) { switch (enterVrInternal()) {
case ENTER_VR_NOT_NECESSARY: case ENTER_VR_NOT_NECESSARY:
mVrShell.setWebVrModeEnabled(true); mVrShell.setWebVrModeEnabled(true);
maybeSetPresentResult(true, true); maybeSetPresentResult(true);
break; break;
case ENTER_VR_CANCELLED: case ENTER_VR_CANCELLED:
maybeSetPresentResult(false, mDonSucceeded); maybeSetPresentResult(false);
break; break;
case ENTER_VR_REQUESTED: case ENTER_VR_REQUESTED:
break; break;
case ENTER_VR_SUCCEEDED: case ENTER_VR_SUCCEEDED:
maybeSetPresentResult(true, mDonSucceeded); maybeSetPresentResult(true);
break; break;
default: default:
Log.e(TAG, "Unexpected enum."); Log.e(TAG, "Unexpected enum.");
...@@ -1680,7 +1655,7 @@ public class VrShellDelegate ...@@ -1680,7 +1655,7 @@ public class VrShellDelegate
} else { } else {
if (mProbablyInDon && !mTestWorkaroundDontCancelVrEntryOnResume) { if (mProbablyInDon && !mTestWorkaroundDontCancelVrEntryOnResume) {
// 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);
shutdownVr(true, false); shutdownVr(true, false);
} }
...@@ -1701,7 +1676,7 @@ public class VrShellDelegate ...@@ -1701,7 +1676,7 @@ public class VrShellDelegate
private void handleDonFlowSuccess() { private void handleDonFlowSuccess() {
setWindowModeForVr(); setWindowModeForVr();
if (mInVr) { if (mInVr) {
maybeSetPresentResult(true, mDonSucceeded); maybeSetPresentResult(true);
mDonSucceeded = false; mDonSucceeded = false;
assert !mActivateFromHeadsetInsertion; assert !mActivateFromHeadsetInsertion;
return; return;
...@@ -1730,14 +1705,12 @@ public class VrShellDelegate ...@@ -1730,14 +1705,12 @@ public class VrShellDelegate
// In case we're hidden before onPause is called, we pause here. Duplicate calls to pause // In case we're hidden before onPause is called, we pause here. Duplicate calls to pause
// are safe. // are safe.
if (mInVr) mVrShell.pause(); if (mInVr) mVrShell.pause();
if (mShowingDaydreamDoff || mProbablyInDon) return;
} }
protected void onPause() { protected void onPause() {
if (DEBUG_LOGS) Log.i(TAG, "onPause"); if (DEBUG_LOGS) Log.i(TAG, "onPause");
mPaused = true; mPaused = true;
if (mCancellingEntryAnimation) return; if (mCancellingEntryAnimation) return;
mExpectPauseOrDonSucceeded.removeCallbacksAndMessages(null);
unregisterDaydreamIntent(); unregisterDaydreamIntent();
if (getVrSupportLevel() <= VrSupportLevel.VR_NEEDS_UPDATE) return; if (getVrSupportLevel() <= VrSupportLevel.VR_NEEDS_UPDATE) return;
...@@ -1886,7 +1859,7 @@ public class VrShellDelegate ...@@ -1886,7 +1859,7 @@ public class VrShellDelegate
removeBlackOverlayView(mActivity, false /* animate */); removeBlackOverlayView(mActivity, false /* animate */);
mDonSucceeded = false; mDonSucceeded = false;
mActivateFromHeadsetInsertion = false; mActivateFromHeadsetInsertion = false;
maybeSetPresentResult(false, false); maybeSetPresentResult(false);
if (!mShowingDaydreamDoff) { if (!mShowingDaydreamDoff) {
setVrModeEnabled(mActivity, false); setVrModeEnabled(mActivity, false);
restoreWindowMode(); restoreWindowMode();
......
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