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;
import android.app.ActivityOptions;
import android.content.Context;
import android.content.Intent;
import android.content.res.Configuration;
import android.os.Build;
import android.os.Bundle;
import android.view.Display;
......@@ -110,40 +109,6 @@ public class VrIntentUtils {
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.
*/
......
......@@ -278,11 +278,10 @@ void VrShellDelegate::Destroy(JNIEnv* env, const JavaParamRef<jobject>& obj) {
}
bool VrShellDelegate::ShouldDisableGvrDevice() {
JNIEnv* env = AttachCurrentThread();
int vr_support_level =
Java_VrShellDelegate_getVrSupportLevel(env, j_vr_shell_delegate_);
return static_cast<VrSupportLevel>(vr_support_level) ==
VrSupportLevel::kVrNotAvailable;
Java_VrShellDelegate_getVrSupportLevel(AttachCurrentThread());
return static_cast<VrSupportLevel>(vr_support_level) <=
VrSupportLevel::kVrNeedsUpdate;
}
void VrShellDelegate::SetDeviceId(unsigned int device_id) {
......
......@@ -30,9 +30,10 @@ namespace vr {
// GENERATED_JAVA_ENUM_PACKAGE: org.chromium.chrome.browser.vr
enum class VrSupportLevel : int {
kVrNotAvailable = 0,
kVrCardboard = 1,
kVrDaydream = 2, // Supports both Cardboard and Daydream viewer.
kVrDisabled = 0,
kVrNeedsUpdate = 1, // VR Support is available, but needs update.
kVrCardboard = 2,
kVrDaydream = 3, // Supports both Cardboard and Daydream viewer.
};
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