Commit 7d984150 authored by Michael Thiessen's avatar Michael Thiessen Committed by Commit Bot

VR: Clean up VrSupportLevel and various other bits of cleanup

I was just doing a cleanup pass on VrShellDelegate, and ended up pulling
on a cleanup thread for VrSupportLevel.

I could split this into multiple changes if necessary, but that sounds
like a waste of time.

Change-Id: I2a5b962b4b7558b64f792c806314a7eb7b2e81ed
Reviewed-on: https://chromium-review.googlesource.com/1135727Reviewed-by: default avatarTibor Goldschwendt <tiborg@chromium.org>
Commit-Queue: Michael Thiessen <mthiesse@chromium.org>
Cr-Commit-Position: refs/heads/master@{#574925}
parent 72099a93
...@@ -8,7 +8,6 @@ import android.app.Activity; ...@@ -8,7 +8,6 @@ import android.app.Activity;
import android.app.ActivityOptions; import android.app.ActivityOptions;
import android.content.Context; import android.content.Context;
import android.content.Intent; import android.content.Intent;
import android.content.res.Configuration;
import android.os.Build; import android.os.Build;
import android.os.Bundle; import android.os.Bundle;
import android.view.Display; import android.view.Display;
...@@ -110,40 +109,6 @@ public class VrIntentUtils { ...@@ -110,40 +109,6 @@ public class VrIntentUtils {
VrShellDelegate.getVrDaydreamApi().launchInVr(intent); VrShellDelegate.getVrDaydreamApi().launchInVr(intent);
} }
/**
* @param intent The intent to possibly forward to the VR launcher.
* @param activity The activity launching the intent.
* @return whether the intent was forwarded to the VR launcher.
*/
public static boolean maybeForwardToVrLauncher(Intent intent, Activity activity) {
// Standalone VR devices use 2D-in-VR rendering on O+.
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.O) return false;
if (activity instanceof VrMainActivity) return false;
if (wouldUse2DInVrRenderingMode(activity) && VrShellDelegate.deviceSupportsVrLaunches()) {
Intent vrIntent = new Intent(intent);
vrIntent.setComponent(null);
vrIntent.setPackage(activity.getPackageName());
vrIntent.addCategory(VrIntentUtils.DAYDREAM_CATEGORY);
if (vrIntent.resolveActivity(activity.getPackageManager()) != null) {
VrIntentUtils.launchInVr(vrIntent, activity);
return true;
}
}
return false;
}
/**
* @param activity A context for reading the current device configuration.
* @return Whether launching a non-VR Activity would trigger the 2D-in-VR rendering path.
*/
public static boolean wouldUse2DInVrRenderingMode(Activity activity) {
Configuration config = activity.getResources().getConfiguration();
int uiMode = config.uiMode & Configuration.UI_MODE_TYPE_MASK;
if (uiMode != Configuration.UI_MODE_TYPE_VR_HEADSET) return false;
VrClassesWrapper wrapper = VrShellDelegate.getVrClassesWrapper();
return wrapper != null && (wrapper.bootsToVr() || wrapper.supports2dInVr());
}
/** /**
* @return Whether the intent is fired from the recent apps overview. * @return Whether the intent is fired from the recent apps overview.
*/ */
......
...@@ -93,13 +93,14 @@ public class VrShellDelegate ...@@ -93,13 +93,14 @@ public class VrShellDelegate
// Pseudo-random number to avoid request id collisions. Result codes must fit in lower 16 bits // Pseudo-random number to avoid request id collisions. Result codes must fit in lower 16 bits
// when used with startActivityForResult... // when used with startActivityForResult...
public static final int EXIT_VR_RESULT = 7212; /* package */ static final int EXIT_VR_RESULT = 7212;
public static final int VR_SERVICES_UPDATE_RESULT = 7213; private static final int VR_SERVICES_UPDATE_RESULT = 7213;
public static final int GVR_KEYBOARD_UPDATE_RESULT = 7214; private static final int GVR_KEYBOARD_UPDATE_RESULT = 7214;
// Android N doesn't allow us to dynamically control the preview window based on headset mode, // Android N doesn't allow us to dynamically control the preview window based on headset mode,
// so we used an animation to hide the preview window instead. // so we used an animation to hide the preview window instead.
public static final boolean USE_HIDE_ANIMATION = Build.VERSION.SDK_INT < Build.VERSION_CODES.O; /* package */ static final boolean USE_HIDE_ANIMATION =
Build.VERSION.SDK_INT < Build.VERSION_CODES.O;
private static final int ENTER_VR_NOT_NECESSARY = 0; private static final int ENTER_VR_NOT_NECESSARY = 0;
private static final int ENTER_VR_CANCELLED = 1; private static final int ENTER_VR_CANCELLED = 1;
...@@ -110,9 +111,8 @@ public class VrShellDelegate ...@@ -110,9 +111,8 @@ public class VrShellDelegate
@IntDef({ENTER_VR_NOT_NECESSARY, ENTER_VR_CANCELLED, ENTER_VR_REQUESTED, ENTER_VR_SUCCEEDED}) @IntDef({ENTER_VR_NOT_NECESSARY, ENTER_VR_CANCELLED, ENTER_VR_REQUESTED, ENTER_VR_SUCCEEDED})
private @interface EnterVRResult {} private @interface EnterVRResult {}
// Linter and formatter disagree on how the line below should be formatted. private static final String VR_ENTRY_RESULT_ACTION =
/* package */ "org.chromium.chrome.browser.vr.VrEntryResult";
static final String VR_ENTRY_RESULT_ACTION = "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 int EXPECT_DON_TIMEOUT_MS = 2000;
...@@ -150,10 +150,10 @@ public class VrShellDelegate ...@@ -150,10 +150,10 @@ public class VrShellDelegate
private static Set<Activity> sVrModeEnabledActivitys = new HashSet<>(); private static Set<Activity> sVrModeEnabledActivitys = new HashSet<>();
private static boolean sRegisteredDaydreamHook; private static boolean sRegisteredDaydreamHook;
private static boolean sRegisteredVrAssetsComponent; private static boolean sRegisteredVrAssetsComponent;
private static @VrSupportLevel Integer sVrSupportLevel;
private ChromeActivity mActivity; private ChromeActivity mActivity;
private @VrSupportLevel int mVrSupportLevel;
private int mCachedVrCorePackageVersion; private int mCachedVrCorePackageVersion;
private int mCachedGvrKeyboardPackageVersion; private int mCachedGvrKeyboardPackageVersion;
...@@ -402,11 +402,6 @@ public class VrShellDelegate ...@@ -402,11 +402,6 @@ public class VrShellDelegate
nativeOnLibraryAvailable(); nativeOnLibraryAvailable();
} }
protected static boolean isDisplayingUrl() {
if (sInstance == null) return false;
return sInstance.mVrShell.isDisplayingUrlForTesting();
}
/** /**
* Whether or not we are currently in VR. * Whether or not we are currently in VR.
*/ */
...@@ -450,17 +445,20 @@ public class VrShellDelegate ...@@ -450,17 +445,20 @@ public class VrShellDelegate
/** /**
* Returns the current {@VrSupportLevel}. * Returns the current {@VrSupportLevel}.
*/ */
public static int getVrSupportLevel(Tab tabToShowInfobarIn) { @CalledByNative
// TODO(mthiesse, crbug.com/791090): Re-enable VR mode for devices that boot to VR once we public static int getVrSupportLevel() {
// support those devices. if (sVrSupportLevel != null) return sVrSupportLevel;
VrClassesWrapper wrapper = getVrClassesWrapper(); VrClassesWrapper wrapper = getVrClassesWrapper();
if (wrapper == null || !isVrCoreCompatible(tabToShowInfobarIn)) { if (wrapper == null) {
return VrSupportLevel.VR_NOT_AVAILABLE; sVrSupportLevel = VrSupportLevel.VR_DISABLED;
} else if (!isVrCoreCompatible()) {
sVrSupportLevel = VrSupportLevel.VR_NEEDS_UPDATE;
} else if (wrapper.isDaydreamReadyDevice()) {
sVrSupportLevel = VrSupportLevel.VR_DAYDREAM;
} else {
sVrSupportLevel = VrSupportLevel.VR_CARDBOARD;
} }
return sVrSupportLevel;
if (wrapper.isDaydreamReadyDevice()) return VrSupportLevel.VR_DAYDREAM;
return VrSupportLevel.VR_CARDBOARD;
} }
/** /**
...@@ -478,10 +476,7 @@ public class VrShellDelegate ...@@ -478,10 +476,7 @@ public class VrShellDelegate
new AsyncTask<Void, Void, Integer>() { new AsyncTask<Void, Void, Integer>() {
@Override @Override
protected Integer doInBackground(Void... params) { protected Integer doInBackground(Void... params) {
VrClassesWrapper wrapper = getVrClassesWrapper(); return getVrSupportLevel();
if (wrapper == null) return VrSupportLevel.VR_NOT_AVAILABLE;
int vrSupportLevel = getVrSupportLevel(null);
return vrSupportLevel;
} }
@Override @Override
...@@ -891,10 +886,8 @@ public class VrShellDelegate ...@@ -891,10 +886,8 @@ public class VrShellDelegate
// If the screen density changed while in VR, we have to disable the VR browser as java UI // If the screen density changed while in VR, we have to disable the VR browser as java UI
// used or created by VR browsing will be broken. // used or created by VR browsing will be broken.
if (sInstance != null) { if (sInstance != null && sInstance.mExpectedDensityChange != 0) return true;
if (sInstance.mExpectedDensityChange != 0) return true; if (getVrSupportLevel() != VrSupportLevel.VR_DAYDREAM) return false;
if (sInstance.mVrSupportLevel != VrSupportLevel.VR_DAYDREAM) return false;
}
Display display = DisplayAndroidManager.getDefaultDisplayForContext( Display display = DisplayAndroidManager.getDefaultDisplayForContext(
ContextUtils.getApplicationContext()); ContextUtils.getApplicationContext());
...@@ -993,54 +986,10 @@ public class VrShellDelegate ...@@ -993,54 +986,10 @@ public class VrShellDelegate
} }
} }
private static boolean isVrCoreCompatible(final Tab tabToShowInfobarIn) { private static boolean isVrCoreCompatible() {
final int vrCoreCompatibility = getVrCoreVersionChecker().getVrCoreCompatibility(); VrCoreVersionChecker checker = getVrCoreVersionChecker();
boolean needsUpdate = vrCoreCompatibility == VrCoreCompatibility.VR_NOT_AVAILABLE if (checker == null) return false;
|| vrCoreCompatibility == VrCoreCompatibility.VR_OUT_OF_DATE; return checker.getVrCoreCompatibility() == VrCoreCompatibility.VR_READY;
if (tabToShowInfobarIn != null && needsUpdate) {
ThreadUtils.assertOnUiThread();
new Handler().post(new Runnable() {
@Override
public void run() {
promptToUpdateVrServices(vrCoreCompatibility, tabToShowInfobarIn);
}
});
}
return vrCoreCompatibility == VrCoreCompatibility.VR_READY;
}
private static void promptToUpdateVrServices(int vrCoreCompatibility, Tab tab) {
final Activity activity = tab.getActivity();
String infobarText;
String buttonText;
if (vrCoreCompatibility == VrCoreCompatibility.VR_NOT_AVAILABLE) {
// Supported, but not installed. Ask user to install instead of upgrade.
infobarText = activity.getString(R.string.vr_services_check_infobar_install_text);
buttonText = activity.getString(R.string.vr_services_check_infobar_install_button);
} else if (vrCoreCompatibility == VrCoreCompatibility.VR_OUT_OF_DATE) {
infobarText = activity.getString(R.string.vr_services_check_infobar_update_text);
buttonText = activity.getString(R.string.vr_services_check_infobar_update_button);
} else {
Log.e(TAG, "Unknown VrCore compatibility: " + vrCoreCompatibility);
return;
}
SimpleConfirmInfoBarBuilder.Listener listener = new SimpleConfirmInfoBarBuilder.Listener() {
@Override
public void onInfoBarDismissed() {}
@Override
public boolean onInfoBarButtonClicked(boolean isPrimary) {
activity.startActivityForResult(
new Intent(Intent.ACTION_VIEW, Uri.parse(VR_CORE_MARKET_URI)),
VR_SERVICES_UPDATE_RESULT);
return false;
}
};
SimpleConfirmInfoBarBuilder.create(tab, listener,
InfoBarIdentifier.VR_SERVICES_UPGRADE_ANDROID, R.drawable.vr_services, infobarText,
buttonText, null, true);
} }
private static void startFeedback(Tab tab) { private static void startFeedback(Tab tab) {
...@@ -1083,6 +1032,11 @@ public class VrShellDelegate ...@@ -1083,6 +1032,11 @@ public class VrShellDelegate
ApplicationStatus.registerStateListenerForAllActivities(sVrLifecycleObserver); ApplicationStatus.registerStateListenerForAllActivities(sVrLifecycleObserver);
} }
protected static boolean isDisplayingUrl() {
if (sInstance == null) return false;
return sInstance.mVrShell.isDisplayingUrlForTesting();
}
protected VrShellDelegate(ChromeActivity activity) { protected VrShellDelegate(ChromeActivity activity) {
mActivity = activity; mActivity = activity;
// 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.
...@@ -1137,7 +1091,7 @@ public class VrShellDelegate ...@@ -1137,7 +1091,7 @@ public class VrShellDelegate
private void maybeUpdateVrSupportLevel() { private void maybeUpdateVrSupportLevel() {
// If we're on Daydream support level, Chrome will get restarted by Android in response to // If we're on Daydream support level, Chrome will get restarted by Android in response to
// VrCore being updated/downgraded, so we don't need to check. // VrCore being updated/downgraded, so we don't need to check.
if (mVrSupportLevel == VrSupportLevel.VR_DAYDREAM) return; if (getVrSupportLevel() == VrSupportLevel.VR_DAYDREAM) return;
if (getVrClassesWrapper() == null) return; if (getVrClassesWrapper() == null) return;
int version = getVrCorePackageVersion(); int version = getVrCorePackageVersion();
// If VrCore package hasn't changed, no need to update. // If VrCore package hasn't changed, no need to update.
...@@ -1159,31 +1113,56 @@ public class VrShellDelegate ...@@ -1159,31 +1113,56 @@ public class VrShellDelegate
} }
/** /**
* Updates mVrSupportLevel to the correct value. isVrCoreCompatible might return different value * Updates sVrSupportLevel to the correct value as VR support can change over time.
* at runtime.
*/ */
// TODO(bshe): Find a place to call this function again, i.e. page refresh or onResume.
private void updateVrSupportLevel(Integer vrCorePackageVersion) { private void updateVrSupportLevel(Integer vrCorePackageVersion) {
if (getVrClassesWrapper() == null) { sVrSupportLevel = null;
mVrSupportLevel = VrSupportLevel.VR_NOT_AVAILABLE; if (getVrSupportLevel() != VrSupportLevel.VR_NEEDS_UPDATE) return;
return;
}
if (vrCorePackageVersion == null) vrCorePackageVersion = getVrCorePackageVersion(); if (vrCorePackageVersion == null) vrCorePackageVersion = getVrCorePackageVersion();
mCachedVrCorePackageVersion = vrCorePackageVersion; mCachedVrCorePackageVersion = vrCorePackageVersion;
promptToUpdateVrServices();
int supportLevel = getVrSupportLevel(mActivity.getActivityTab());
if (supportLevel == mVrSupportLevel) return;
mVrSupportLevel = supportLevel;
} }
@CalledByNative private void promptToUpdateVrServices() {
@VrSupportLevel assert getVrSupportLevel() == VrSupportLevel.VR_NEEDS_UPDATE;
/* package */ int getVrSupportLevel() { Tab tab = mActivity.getActivityTab();
return mVrSupportLevel; if (tab == null) return;
int vrCoreCompatibility = getVrCoreVersionChecker().getVrCoreCompatibility();
String infobarText;
String buttonText;
if (vrCoreCompatibility == VrCoreCompatibility.VR_NOT_AVAILABLE) {
// Supported, but not installed. Ask user to install instead of upgrade.
infobarText = mActivity.getString(R.string.vr_services_check_infobar_install_text);
buttonText = mActivity.getString(R.string.vr_services_check_infobar_install_button);
} else if (vrCoreCompatibility == VrCoreCompatibility.VR_OUT_OF_DATE) {
infobarText = mActivity.getString(R.string.vr_services_check_infobar_update_text);
buttonText = mActivity.getString(R.string.vr_services_check_infobar_update_button);
} else {
Log.e(TAG, "Unknown VrCore compatibility: " + vrCoreCompatibility);
return;
}
SimpleConfirmInfoBarBuilder.Listener listener = new SimpleConfirmInfoBarBuilder.Listener() {
@Override
public void onInfoBarDismissed() {}
@Override
public boolean onInfoBarButtonClicked(boolean isPrimary) {
mActivity.startActivityForResult(
new Intent(Intent.ACTION_VIEW, Uri.parse(VR_CORE_MARKET_URI)),
VR_SERVICES_UPDATE_RESULT);
return false;
}
};
SimpleConfirmInfoBarBuilder.create(tab, listener,
InfoBarIdentifier.VR_SERVICES_UPGRADE_ANDROID, R.drawable.vr_services, infobarText,
buttonText, null, true);
} }
protected boolean isVrBrowsingEnabled() { protected boolean isVrBrowsingEnabled() {
return isVrBrowsingEnabled(mActivity, mVrSupportLevel); return isVrBrowsingEnabled(mActivity, getVrSupportLevel());
} }
private void onVrServicesMaybeUpdated() { private void onVrServicesMaybeUpdated() {
...@@ -1200,7 +1179,7 @@ public class VrShellDelegate ...@@ -1200,7 +1179,7 @@ public class VrShellDelegate
* Returns whether the device has support for Daydream. * Returns whether the device has support for Daydream.
*/ */
/* package */ boolean hasDaydreamSupport() { /* package */ boolean hasDaydreamSupport() {
return mVrSupportLevel == VrSupportLevel.VR_DAYDREAM; return getVrSupportLevel() == VrSupportLevel.VR_DAYDREAM;
} }
private void maybeSetPresentResult(boolean result, boolean donCompleted) { private void maybeSetPresentResult(boolean result, boolean donCompleted) {
...@@ -1501,13 +1480,10 @@ public class VrShellDelegate ...@@ -1501,13 +1480,10 @@ public class VrShellDelegate
} }
/* package */ boolean canEnterVr() { /* package */ boolean canEnterVr() {
if (!LibraryLoader.getInstance().isInitialized()) return false; if (getVrSupportLevel() <= VrSupportLevel.VR_NEEDS_UPDATE) return false;
if (mVrSupportLevel == VrSupportLevel.VR_NOT_AVAILABLE || mNativeVrShellDelegate == 0)
return false;
// If vr shell is not enabled and this is not a web vr request, then return false. // If VR browsing is not enabled and this is not a WebXR request, then return false.
boolean presenting = boolean presenting = mRequestedWebVr || mActivateFromHeadsetInsertion;
mRequestedWebVr || mListeningForWebVrActivate || mActivateFromHeadsetInsertion;
if (!isVrBrowsingEnabled() && !presenting) return false; if (!isVrBrowsingEnabled() && !presenting) return false;
return true; return true;
} }
...@@ -1548,9 +1524,9 @@ public class VrShellDelegate ...@@ -1548,9 +1524,9 @@ public class VrShellDelegate
// Update VR support level as it can change at runtime // Update VR support level as it can change at runtime
maybeUpdateVrSupportLevel(); maybeUpdateVrSupportLevel();
if (mVrSupportLevel == VrSupportLevel.VR_NOT_AVAILABLE) return ENTER_VR_CANCELLED;
if (!canEnterVr()) return ENTER_VR_CANCELLED; if (!canEnterVr()) return ENTER_VR_CANCELLED;
if (mVrSupportLevel == VrSupportLevel.VR_DAYDREAM && isDaydreamCurrentViewerInternal()) { if (getVrSupportLevel() == VrSupportLevel.VR_DAYDREAM
&& isDaydreamCurrentViewerInternal()) {
// TODO(mthiesse): This is a workaround for b/66486878 (see also crbug.com/767594). // TODO(mthiesse): This is a workaround for b/66486878 (see also crbug.com/767594).
// We have to trigger the DON flow before setting VR mode enabled to prevent the DON // We have to trigger the DON flow before setting VR mode enabled to prevent the DON
// flow from failing on the S8/S8+. // flow from failing on the S8/S8+.
...@@ -1624,9 +1600,11 @@ public class VrShellDelegate ...@@ -1624,9 +1600,11 @@ public class VrShellDelegate
} }
private boolean maybeExitVrToUpdateVrServices() { private boolean maybeExitVrToUpdateVrServices() {
if (!mEnterVrOnStartup || mVrSupportLevel != VrSupportLevel.VR_NOT_AVAILABLE) return false; if (!mEnterVrOnStartup || getVrSupportLevel() != VrSupportLevel.VR_NEEDS_UPDATE) {
// This means that we were started in VR mode but the vr services may be out of date. We return false;
// should exit VR and prompt the user to update. }
// This means that we were started in VR mode but the vr services are out of date. We should
// exit VR and prompt the user to update.
if (DEBUG_LOGS) Log.i(TAG, "VR services update needed"); if (DEBUG_LOGS) Log.i(TAG, "VR services update needed");
mShowingDoffForGvrUpdate = true; mShowingDoffForGvrUpdate = true;
showDoff(false /* optional */); showDoff(false /* optional */);
...@@ -1682,7 +1660,7 @@ public class VrShellDelegate ...@@ -1682,7 +1660,7 @@ public class VrShellDelegate
} }
// If mEnterVrOnStartup is set, we show DOFF in handleDonFlowSuccess below. // If mEnterVrOnStartup is set, we show DOFF in handleDonFlowSuccess below.
if (mVrSupportLevel != VrSupportLevel.VR_DAYDREAM && !mEnterVrOnStartup) return; if (getVrSupportLevel() != VrSupportLevel.VR_DAYDREAM && !mEnterVrOnStartup) return;
if (isVrBrowsingEnabled()) { if (isVrBrowsingEnabled()) {
// Perform slow initialization asynchronously. // Perform slow initialization asynchronously.
...@@ -1761,7 +1739,7 @@ public class VrShellDelegate ...@@ -1761,7 +1739,7 @@ public class VrShellDelegate
if (mCancellingEntryAnimation) return; if (mCancellingEntryAnimation) return;
mExpectPauseOrDonSucceeded.removeCallbacksAndMessages(null); mExpectPauseOrDonSucceeded.removeCallbacksAndMessages(null);
unregisterDaydreamIntent(); unregisterDaydreamIntent();
if (mVrSupportLevel == VrSupportLevel.VR_NOT_AVAILABLE) return; if (getVrSupportLevel() <= VrSupportLevel.VR_NEEDS_UPDATE) return;
if (mMaybeActivateAfterHeadsetInsertion) { if (mMaybeActivateAfterHeadsetInsertion) {
mClearMaybeActivateHandler.removeCallbacksAndMessages(null); mClearMaybeActivateHandler.removeCallbacksAndMessages(null);
...@@ -1799,7 +1777,7 @@ public class VrShellDelegate ...@@ -1799,7 +1777,7 @@ public class VrShellDelegate
} }
private boolean onBackPressedInternal() { private boolean onBackPressedInternal() {
if (mVrSupportLevel == VrSupportLevel.VR_NOT_AVAILABLE) return false; if (getVrSupportLevel() <= VrSupportLevel.VR_NEEDS_UPDATE) return false;
cancelPendingVrEntry(); cancelPendingVrEntry();
if (!mInVr) return false; if (!mInVr) return false;
// Back button should be handled the same way as the close button. // Back button should be handled the same way as the close button.
...@@ -1874,7 +1852,7 @@ public class VrShellDelegate ...@@ -1874,7 +1852,7 @@ public class VrShellDelegate
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 may not have the concept of display activate. So disable // Non-Daydream devices may not have the concept of display activate. So disable
// mListeningForWebVrActivate for them. // mListeningForWebVrActivate for them.
if (mVrSupportLevel != VrSupportLevel.VR_DAYDREAM) return; if (getVrSupportLevel() != VrSupportLevel.VR_DAYDREAM) return;
if (mListeningForWebVrActivate == listening) return; if (mListeningForWebVrActivate == listening) return;
mListeningForWebVrActivate = listening; mListeningForWebVrActivate = listening;
if (mListeningForWebVrActivate) { if (mListeningForWebVrActivate) {
......
...@@ -278,11 +278,10 @@ void VrShellDelegate::Destroy(JNIEnv* env, const JavaParamRef<jobject>& obj) { ...@@ -278,11 +278,10 @@ void VrShellDelegate::Destroy(JNIEnv* env, const JavaParamRef<jobject>& obj) {
} }
bool VrShellDelegate::ShouldDisableGvrDevice() { bool VrShellDelegate::ShouldDisableGvrDevice() {
JNIEnv* env = AttachCurrentThread();
int vr_support_level = int vr_support_level =
Java_VrShellDelegate_getVrSupportLevel(env, j_vr_shell_delegate_); Java_VrShellDelegate_getVrSupportLevel(AttachCurrentThread());
return static_cast<VrSupportLevel>(vr_support_level) == return static_cast<VrSupportLevel>(vr_support_level) <=
VrSupportLevel::kVrNotAvailable; VrSupportLevel::kVrNeedsUpdate;
} }
void VrShellDelegate::SetDeviceId(unsigned int device_id) { void VrShellDelegate::SetDeviceId(unsigned int device_id) {
......
...@@ -30,9 +30,10 @@ namespace vr { ...@@ -30,9 +30,10 @@ namespace vr {
// GENERATED_JAVA_ENUM_PACKAGE: org.chromium.chrome.browser.vr // GENERATED_JAVA_ENUM_PACKAGE: org.chromium.chrome.browser.vr
enum class VrSupportLevel : int { enum class VrSupportLevel : int {
kVrNotAvailable = 0, kVrDisabled = 0,
kVrCardboard = 1, kVrNeedsUpdate = 1, // VR Support is available, but needs update.
kVrDaydream = 2, // Supports both Cardboard and Daydream viewer. kVrCardboard = 2,
kVrDaydream = 3, // Supports both Cardboard and Daydream viewer.
}; };
class VrShell; class VrShell;
......
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