Commit d68f6dc4 authored by Yash Malik's avatar Yash Malik Committed by Commit Bot

VR: Early return in VrMainActivity for non-Daydream ready devices

This CL also wraps the DaydreamApi.isInVrSession call with isDaydreamReadyDevice
to prevent a Daydream-side crash

Bug: 827174
Change-Id: I7207bae82818bc0a77bc66f5c45bb8401675796e
Reviewed-on: https://chromium-review.googlesource.com/986672Reviewed-by: default avatarMichael Thiessen <mthiesse@chromium.org>
Commit-Queue: Yash Malik <ymalik@chromium.org>
Cr-Commit-Position: refs/heads/master@{#547717}
parent 8f035f98
...@@ -39,6 +39,11 @@ public class VrMainActivity extends Activity { ...@@ -39,6 +39,11 @@ public class VrMainActivity extends Activity {
try { try {
super.onCreate(savedInstanceState); super.onCreate(savedInstanceState);
if (!VrShellDelegate.isDaydreamReadyDevice(this)) {
finish();
return;
}
// If the launcher was launched from a 2D context (without calling // If the launcher was launched from a 2D context (without calling
// DaydreamApi#launchInVr), then we need to relaunch the launcher in VR to allow // DaydreamApi#launchInVr), then we need to relaunch the launcher in VR to allow
// downstream Activities to make assumptions about whether they're in VR or not, and // downstream Activities to make assumptions about whether they're in VR or not, and
......
...@@ -146,7 +146,9 @@ public class VrDaydreamApiImpl implements VrDaydreamApi { ...@@ -146,7 +146,9 @@ public class VrDaydreamApiImpl implements VrDaydreamApi {
@Override @Override
public boolean isInVrSession() { public boolean isInVrSession() {
return DaydreamApi.isInVrSession(mContext); // The call to isInVrSession crashes when called on a non-Daydream ready device, so we add
// the device check (b/77268533).
return isDaydreamReadyDevice() && DaydreamApi.isInVrSession(mContext);
} }
@Override @Override
......
...@@ -784,6 +784,15 @@ public class VrShellDelegate ...@@ -784,6 +784,15 @@ public class VrShellDelegate
return api.isInVrSession(); return api.isInVrSession();
} }
public static boolean isDaydreamReadyDevice(Activity activty) {
if (sInstance != null) return sInstance.mVrDaydreamApi.isDaydreamReadyDevice();
VrClassesWrapper wrapper = getVrClassesWrapper();
if (wrapper == null) return false;
VrDaydreamApi api = wrapper.createVrDaydreamApi(activty);
if (api == null) return false;
return api.isDaydreamReadyDevice();
}
// TODO(mthiesse): Should have package visibility only. We need to unify our vr and vr_shell // TODO(mthiesse): Should have package visibility only. We need to unify our vr and vr_shell
// packages. // packages.
public static boolean willChangeDensityInVr(ChromeActivity activity) { public static boolean willChangeDensityInVr(ChromeActivity activity) {
......
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