Commit 0062abf0 authored by Brian Sheedy's avatar Brian Sheedy Committed by Commit Bot

Revert "VR: Ensure we remove black overlay if VR is exited while entering."

This reverts commit 9f8158c1.

Reason for revert: Culprit of failed VR tests https://ci.chromium.org/p/chromium/builders/luci.chromium.ci/Nougat%20Phone%20Tester/6884

Original change's description:
> VR: Ensure we remove black overlay if VR is exited while entering.
> 
> This fixes a failure mode where we shutdownVR after handling the VR NFC
> broadcast, and fail to properly cancel VR entry.
> 
> Also does some other random cleanup of comments/visibility.
> 
> Bug: 862829
> Change-Id: Ic382692d7255aa5893391a602a6c949b4b4d498b
> Reviewed-on: https://chromium-review.googlesource.com/1138726
> Reviewed-by: Tibor Goldschwendt <tiborg@chromium.org>
> Commit-Queue: Michael Thiessen <mthiesse@chromium.org>
> Cr-Commit-Position: refs/heads/master@{#575388}

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

Change-Id: Ibe67ee8c09dc44ac34d40c3eaf890884b400fc24
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Bug: 862829
Reviewed-on: https://chromium-review.googlesource.com/1140813Reviewed-by: default avatarBrian Sheedy <bsheedy@chromium.org>
Commit-Queue: Brian Sheedy <bsheedy@chromium.org>
Cr-Commit-Position: refs/heads/master@{#575725}
parent 7c9ea3ee
...@@ -16,15 +16,19 @@ import org.chromium.chrome.browser.modaldialog.ModalDialogView; ...@@ -16,15 +16,19 @@ import org.chromium.chrome.browser.modaldialog.ModalDialogView;
* This class implements a VrAlertDialog which is similar to Android AlertDialog in VR. * This class implements a VrAlertDialog which is similar to Android AlertDialog in VR.
*/ */
public class VrAlertDialog extends AlertDialog { public class VrAlertDialog extends AlertDialog {
private VrDialogManager mVrDialogManager;
private ModalDialogManager mModalDialogManager; private ModalDialogManager mModalDialogManager;
private ModalDialogView mModalDialogView; private ModalDialogView mModalDialogView;
private boolean mIsShowing;
private CharSequence mMessage; private CharSequence mMessage;
private DialogButton mButtonPositive; private DialogButton mButtonPositive;
private DialogButton mButtonNegative; private DialogButton mButtonNegative;
protected View mView; protected View mView;
public VrAlertDialog(Context context, ModalDialogManager modalDialogManager) { public VrAlertDialog(Context context, VrDialogManager vrDialogManager,
ModalDialogManager modalDialogManager) {
super(context); super(context);
mVrDialogManager = vrDialogManager;
mModalDialogManager = modalDialogManager; mModalDialogManager = modalDialogManager;
} }
...@@ -56,6 +60,7 @@ public class VrAlertDialog extends AlertDialog { ...@@ -56,6 +60,7 @@ public class VrAlertDialog extends AlertDialog {
public void show() { public void show() {
mModalDialogView = createView(); mModalDialogView = createView();
mModalDialogManager.showDialog(mModalDialogView, ModalDialogManager.APP_MODAL); mModalDialogManager.showDialog(mModalDialogView, ModalDialogManager.APP_MODAL);
mIsShowing = true;
} }
/** /**
...@@ -98,6 +103,7 @@ public class VrAlertDialog extends AlertDialog { ...@@ -98,6 +103,7 @@ public class VrAlertDialog extends AlertDialog {
*/ */
@Override @Override
public void dismiss() { public void dismiss() {
mIsShowing = false;
mModalDialogManager.cancelDialog(mModalDialogView); mModalDialogManager.cancelDialog(mModalDialogView);
} }
......
...@@ -24,6 +24,8 @@ public class VrFirstRunActivity extends Activity { ...@@ -24,6 +24,8 @@ public class VrFirstRunActivity extends Activity {
private static final BooleanHistogramSample sFreNotCompleteBrowserHistogram = private static final BooleanHistogramSample sFreNotCompleteBrowserHistogram =
new BooleanHistogramSample("VRFreNotComplete.Browser"); new BooleanHistogramSample("VRFreNotComplete.Browser");
private static final BooleanHistogramSample sFreNotCompleteAutopresentHistogram =
new BooleanHistogramSample("VRFreNotComplete.WebVRAutopresent");
@Override @Override
protected void onCreate(Bundle savedInstanceState) { protected void onCreate(Bundle savedInstanceState) {
......
...@@ -42,7 +42,6 @@ import org.chromium.base.ContextUtils; ...@@ -42,7 +42,6 @@ import org.chromium.base.ContextUtils;
import org.chromium.base.Log; import org.chromium.base.Log;
import org.chromium.base.PackageUtils; import org.chromium.base.PackageUtils;
import org.chromium.base.ThreadUtils; import org.chromium.base.ThreadUtils;
import org.chromium.base.VisibleForTesting;
import org.chromium.base.annotations.CalledByNative; import org.chromium.base.annotations.CalledByNative;
import org.chromium.base.annotations.JNINamespace; import org.chromium.base.annotations.JNINamespace;
import org.chromium.base.library_loader.LibraryLoader; import org.chromium.base.library_loader.LibraryLoader;
...@@ -207,7 +206,6 @@ public class VrShellDelegate ...@@ -207,7 +206,6 @@ public class VrShellDelegate
private static final List<VrModeObserver> sVrModeObservers = new ArrayList<>(); private static final List<VrModeObserver> sVrModeObservers = new ArrayList<>();
@VisibleForTesting
protected boolean mTestWorkaroundDontCancelVrEntryOnResume; protected boolean mTestWorkaroundDontCancelVrEntryOnResume;
private long mNativeVrShellDelegate; private long mNativeVrShellDelegate;
...@@ -908,7 +906,7 @@ public class VrShellDelegate ...@@ -908,7 +906,7 @@ public class VrShellDelegate
} }
/** /**
* @return Whether or not VR is enabled in this build. * @return Whether or not VR is supported on this platform.
*/ */
/* package */ static boolean isVrEnabled() { /* package */ static boolean isVrEnabled() {
return getVrClassesWrapper() != null; return getVrClassesWrapper() != null;
...@@ -1044,8 +1042,8 @@ public class VrShellDelegate ...@@ -1044,8 +1042,8 @@ public class VrShellDelegate
// If an activity isn't resumed at the point, it must have been paused. // If an activity isn't resumed at the point, it must have been paused.
mPaused = ApplicationStatus.getStateForActivity(activity) != ActivityState.RESUMED; mPaused = ApplicationStatus.getStateForActivity(activity) != ActivityState.RESUMED;
mVisible = activity.hasWindowFocus(); mVisible = activity.hasWindowFocus();
mNativeVrShellDelegate = nativeInit();
updateVrSupportLevel(null); updateVrSupportLevel(null);
mNativeVrShellDelegate = nativeInit();
mFeedbackFrequency = VrFeedbackStatus.getFeedbackFrequency(); mFeedbackFrequency = VrFeedbackStatus.getFeedbackFrequency();
ensureLifecycleObserverInitialized(); ensureLifecycleObserverInitialized();
if (!mPaused) onResume(); if (!mPaused) onResume();
...@@ -1161,7 +1159,6 @@ public class VrShellDelegate ...@@ -1161,7 +1159,6 @@ public class VrShellDelegate
buttonText, null, true); buttonText, null, true);
} }
@VisibleForTesting
protected boolean isVrBrowsingEnabled() { protected boolean isVrBrowsingEnabled() {
return isVrBrowsingEnabled(mActivity, getVrSupportLevel()); return isVrBrowsingEnabled(mActivity, getVrSupportLevel());
} }
...@@ -1218,11 +1215,16 @@ public class VrShellDelegate ...@@ -1218,11 +1215,16 @@ public class VrShellDelegate
} }
private void enterVr(final boolean tentativeWebVrMode) { private void enterVr(final boolean tentativeWebVrMode) {
// We should only enter VR when we're the resumed Activity or our changes to things like // We can't enter VR before the application resumes, or we encounter bizarre crashes
// system UI flags might get lost. // related to gpu surfaces.
// TODO(mthiesse): Is the above comment still accurate? It may have been tied to our HTML
// UI which is gone.
assert !mPaused; assert !mPaused;
assert mNativeVrShellDelegate != 0;
if (mInVr) return; if (mInVr) return;
if (mNativeVrShellDelegate == 0) {
cancelPendingVrEntry();
return;
}
mInVr = true; mInVr = true;
setVrModeEnabled(mActivity, true); setVrModeEnabled(mActivity, true);
...@@ -1242,11 +1244,11 @@ public class VrShellDelegate ...@@ -1242,11 +1244,11 @@ public class VrShellDelegate
mExitedDueToUnsupportedMode = false; mExitedDueToUnsupportedMode = false;
addVrViews(); addVrViews();
boolean webVrMode = mRequestedWebVr || tentativeWebVrMode;
// Make sure that assets component is registered when creating native VR shell. // Make sure that assets component is registered when creating native VR shell.
if (!sRegisteredVrAssetsComponent) { if (!sRegisteredVrAssetsComponent) {
registerVrAssetsComponentIfDaydreamUser(isDaydreamCurrentViewer()); registerVrAssetsComponentIfDaydreamUser(isDaydreamCurrentViewer());
} }
boolean webVrMode = mRequestedWebVr || tentativeWebVrMode;
mVrShell.initializeNative(webVrMode, getVrClassesWrapper().bootsToVr()); mVrShell.initializeNative(webVrMode, getVrClassesWrapper().bootsToVr());
mVrShell.setWebVrModeEnabled(webVrMode); mVrShell.setWebVrModeEnabled(webVrMode);
...@@ -1288,9 +1290,6 @@ public class VrShellDelegate ...@@ -1288,9 +1290,6 @@ public class VrShellDelegate
// Nothing to do if we were launched by an internal intent. // Nothing to do if we were launched by an internal intent.
if (mInternalIntentUsedToStartVr) { if (mInternalIntentUsedToStartVr) {
mInternalIntentUsedToStartVr = false; mInternalIntentUsedToStartVr = false;
// This is extremely unlikely in practice. Some code must have called shutdownVR() while
// we were entering VR through NFC insertion.
if (!mDonSucceeded) cancelPendingVrEntry();
return; return;
} }
...@@ -1545,7 +1544,6 @@ public class VrShellDelegate ...@@ -1545,7 +1544,6 @@ public class VrShellDelegate
return true; return true;
} }
@VisibleForTesting
protected void onResume() { protected void onResume() {
if (DEBUG_LOGS) Log.i(TAG, "onResume"); if (DEBUG_LOGS) Log.i(TAG, "onResume");
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.JELLY_BEAN_MR1) return; if (Build.VERSION.SDK_INT < Build.VERSION_CODES.JELLY_BEAN_MR1) return;
...@@ -1666,7 +1664,7 @@ public class VrShellDelegate ...@@ -1666,7 +1664,7 @@ public class VrShellDelegate
if (mInVr) mVrShell.pause(); if (mInVr) mVrShell.pause();
} }
private 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;
...@@ -1757,9 +1755,13 @@ public class VrShellDelegate ...@@ -1757,9 +1755,13 @@ public class VrShellDelegate
mShowingDaydreamDoff = false; mShowingDaydreamDoff = false;
if (mShowingDoffForGvrUpdate) mShowVrServicesUpdatePrompt = success; if (mShowingDoffForGvrUpdate) {
mShowVrServicesUpdatePrompt = success;
}
if (success) shutdownVr(true /* disableVrMode */, true /* stayingInChrome */); if (success) {
shutdownVr(true /* disableVrMode */, true /* stayingInChrome */);
}
callOnExitVrRequestListener(success); callOnExitVrRequestListener(success);
mShowingDoffForGvrUpdate = false; mShowingDoffForGvrUpdate = false;
...@@ -1776,7 +1778,8 @@ public class VrShellDelegate ...@@ -1776,7 +1778,8 @@ public class VrShellDelegate
@CalledByNative @CalledByNative
private void setListeningForWebVrActivate(boolean listening) { private void setListeningForWebVrActivate(boolean listening) {
if (DEBUG_LOGS) Log.i(TAG, "WebVR page listening for vrdisplayactivate: " + listening); if (DEBUG_LOGS) Log.i(TAG, "WebVR page listening for vrdisplayactivate: " + listening);
// Non-Daydream devices do not have the concept of activation. // Non-Daydream devices may not have the concept of display activate. So disable
// mListeningForWebVrActivate for them.
if (getVrSupportLevel() != VrSupportLevel.VR_DAYDREAM) return; if (getVrSupportLevel() != VrSupportLevel.VR_DAYDREAM) return;
if (mListeningForWebVrActivate == listening) return; if (mListeningForWebVrActivate == listening) return;
mListeningForWebVrActivate = listening; mListeningForWebVrActivate = listening;
...@@ -1821,7 +1824,7 @@ public class VrShellDelegate ...@@ -1821,7 +1824,7 @@ public class VrShellDelegate
/** /**
* Exits VR Shell, performing all necessary cleanup. * Exits VR Shell, performing all necessary cleanup.
*/ */
private void shutdownVr(boolean disableVrMode, boolean stayingInChrome) { protected void shutdownVr(boolean disableVrMode, boolean stayingInChrome) {
if (DEBUG_LOGS) Log.i(TAG, "shuttdown VR"); if (DEBUG_LOGS) Log.i(TAG, "shuttdown VR");
cancelPendingVrEntry(); cancelPendingVrEntry();
...@@ -1938,13 +1941,11 @@ public class VrShellDelegate ...@@ -1938,13 +1941,11 @@ public class VrShellDelegate
GVR_KEYBOARD_UPDATE_RESULT); GVR_KEYBOARD_UPDATE_RESULT);
} }
@VisibleForTesting
protected boolean canLaunch2DIntentsInternal() { protected boolean canLaunch2DIntentsInternal() {
return getVrClassesWrapper().supports2dInVr() return getVrClassesWrapper().supports2dInVr()
&& !sVrModeEnabledActivitys.contains(sInstance.mActivity); && !sVrModeEnabledActivitys.contains(sInstance.mActivity);
} }
@VisibleForTesting
protected boolean createVrShell() { protected boolean createVrShell() {
assert mVrShell == null; assert mVrShell == null;
if (getVrClassesWrapper() == null) return false; if (getVrClassesWrapper() == null) return false;
...@@ -1971,7 +1972,6 @@ public class VrShellDelegate ...@@ -1971,7 +1972,6 @@ public class VrShellDelegate
mActivity.onEnterVr(); mActivity.onEnterVr();
} }
@VisibleForTesting
protected boolean isBlackOverlayVisible() { protected boolean isBlackOverlayVisible() {
View overlay = mActivity.getWindow().findViewById(R.id.vr_overlay_view); View overlay = mActivity.getWindow().findViewById(R.id.vr_overlay_view);
return overlay != null; return overlay != null;
...@@ -1997,7 +1997,6 @@ public class VrShellDelegate ...@@ -1997,7 +1997,6 @@ public class VrShellDelegate
/** /**
* @param api The VrDaydreamApi object this delegate will use instead of the default one * @param api The VrDaydreamApi object this delegate will use instead of the default one
*/ */
@VisibleForTesting
protected void overrideDaydreamApi(VrDaydreamApi api) { protected void overrideDaydreamApi(VrDaydreamApi api) {
sVrDaydreamApi = api; sVrDaydreamApi = api;
} }
...@@ -2005,7 +2004,6 @@ public class VrShellDelegate ...@@ -2005,7 +2004,6 @@ public class VrShellDelegate
/** /**
* @return The VrShell for the VrShellDelegate instance * @return The VrShell for the VrShellDelegate instance
*/ */
@VisibleForTesting
protected VrShell getVrShell() { protected VrShell getVrShell() {
return mVrShell; return mVrShell;
} }
...@@ -2013,7 +2011,6 @@ public class VrShellDelegate ...@@ -2013,7 +2011,6 @@ public class VrShellDelegate
/** /**
* @param versionChecker The VrCoreVersionChecker object this delegate will use * @param versionChecker The VrCoreVersionChecker object this delegate will use
*/ */
@VisibleForTesting
protected void overrideVrCoreVersionChecker(VrCoreVersionChecker versionChecker) { protected void overrideVrCoreVersionChecker(VrCoreVersionChecker versionChecker) {
sVrCoreVersionChecker = versionChecker; sVrCoreVersionChecker = versionChecker;
updateVrSupportLevel(null); updateVrSupportLevel(null);
...@@ -2022,30 +2019,24 @@ public class VrShellDelegate ...@@ -2022,30 +2019,24 @@ public class VrShellDelegate
/** /**
* @param frequency Sets how often to show the feedback prompt. * @param frequency Sets how often to show the feedback prompt.
*/ */
@VisibleForTesting
protected void setFeedbackFrequency(int frequency) { protected void setFeedbackFrequency(int frequency) {
mFeedbackFrequency = frequency; mFeedbackFrequency = frequency;
} }
@VisibleForTesting
protected boolean isListeningForWebVrActivate() { protected boolean isListeningForWebVrActivate() {
return mListeningForWebVrActivate; return mListeningForWebVrActivate;
} }
@VisibleForTesting
protected boolean isVrEntryComplete() { protected boolean isVrEntryComplete() {
return mInVr && !mProbablyInDon; return mInVr && !mProbablyInDon;
} }
@VisibleForTesting
protected boolean isShowingDoff() { protected boolean isShowingDoff() {
return mShowingDaydreamDoff; return mShowingDaydreamDoff;
} }
@VisibleForTesting
protected void onBroadcastReceived() {} protected void onBroadcastReceived() {}
@VisibleForTesting
protected void setExpectingIntent(boolean expectingIntent) {} protected void setExpectingIntent(boolean expectingIntent) {}
/** /**
......
...@@ -12,6 +12,7 @@ import android.widget.TextView; ...@@ -12,6 +12,7 @@ import android.widget.TextView;
/** /**
* This class implements a Toast which is similar to Android Toast in VR. * This class implements a Toast which is similar to Android Toast in VR.
*/ */
public class VrToast extends android.widget.Toast { public class VrToast extends android.widget.Toast {
private VrToastManager mVrToastManager; private VrToastManager mVrToastManager;
......
...@@ -36,7 +36,7 @@ public class VrUiWidgetFactory extends UiWidgetFactory { ...@@ -36,7 +36,7 @@ public class VrUiWidgetFactory extends UiWidgetFactory {
@Override @Override
public AlertDialog createAlertDialog(Context context) { public AlertDialog createAlertDialog(Context context) {
return new VrAlertDialog(context, mModalDialogManager); return new VrAlertDialog(context, mVrShell, mModalDialogManager);
} }
@Override @Override
......
...@@ -48,6 +48,11 @@ public class TestVrShellDelegate extends VrShellDelegate { ...@@ -48,6 +48,11 @@ public class TestVrShellDelegate extends VrShellDelegate {
return TestVrShellDelegate.getInstance().getVrShell(); return TestVrShellDelegate.getInstance().getVrShell();
} }
@Override
public void shutdownVr(boolean disableVrMode, boolean stayingInChrome) {
super.shutdownVr(disableVrMode, stayingInChrome);
}
public void overrideDaydreamApiForTesting(VrDaydreamApi api) { public void overrideDaydreamApiForTesting(VrDaydreamApi api) {
super.overrideDaydreamApi(api); super.overrideDaydreamApi(api);
} }
......
...@@ -69,7 +69,8 @@ public class TransitionUtils { ...@@ -69,7 +69,8 @@ public class TransitionUtils {
ThreadUtils.runOnUiThreadBlocking(new Runnable() { ThreadUtils.runOnUiThreadBlocking(new Runnable() {
@Override @Override
public void run() { public void run() {
VrShellDelegate.forceExitVrImmediately(); VrShellDelegateUtils.getDelegateInstance().shutdownVr(
true /* disableVrMode */, true /* stayingInChrome */);
} }
}); });
} }
......
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