Commit 2412b89c authored by Tibor Goldschwendt's avatar Tibor Goldschwendt Committed by Commit Bot

[vr] Remove Java code and resources from APK builds

Bug: 951492
Change-Id: Ie993974ea7bb5779bf396921a3931020d90e7f53
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1564554
Commit-Queue: Tibor Goldschwendt <tiborg@chromium.org>
Auto-Submit: Tibor Goldschwendt <tiborg@chromium.org>
Reviewed-by: default avatarBill Orr <billorr@chromium.org>
Reviewed-by: default avatarYaron Friedman <yfriedman@chromium.org>
Cr-Commit-Position: refs/heads/master@{#656384}
parent b4d098e3
......@@ -13,6 +13,11 @@
namespace base {
namespace android {
// static
bool BundleUtils::IsBundle() {
return Java_BundleUtils_isBundle(base::android::AttachCurrentThread());
}
// static
void* BundleUtils::DlOpenModuleLibrary(const std::string& libary_name) {
JNIEnv* env = AttachCurrentThread();
......
......@@ -15,6 +15,9 @@ namespace android {
// Utils to help working with android app bundles.
class BASE_EXPORT BundleUtils {
public:
// Returns true if the current build is a bundle.
static bool IsBundle();
// dlopen variant that works for native libraries in dynamic feature modules.
static void* DlOpenModuleLibrary(const std::string& libary_name);
};
......
......@@ -24,6 +24,7 @@ public class BundleUtils {
}
/* Returns true if the current build is a bundle. */
@CalledByNative
public static boolean isBundle() {
return sIsBundle;
}
......
......@@ -4,6 +4,7 @@
package org.chromium.chrome.browser.vr;
import org.chromium.base.BundleUtils;
import org.chromium.base.annotations.CalledByNative;
import org.chromium.base.annotations.JNINamespace;
import org.chromium.chrome.R;
......@@ -44,6 +45,7 @@ public class VrModuleProvider implements ModuleInstallUi.FailureUiListener {
*/
public static void maybeRequestModuleIfDaydreamReady() {
if (!VrBuildConfig.IS_VR_ENABLED) return;
if (!BundleUtils.isBundle()) return;
if (VrModule.isInstalled()) return;
if (!getDelegate().isDaydreamReadyDevice()) return;
......
......@@ -48,7 +48,7 @@ import java.util.concurrent.Callable;
@UseRunnerDelegate(ChromeJUnit4RunnerDelegate.class)
@CommandLineFlags.Add({ChromeSwitches.DISABLE_FIRST_RUN_EXPERIENCE,
"enable-features=LogJsConsoleMessages", "enable-webvr"})
@MinAndroidSdkLevel(Build.VERSION_CODES.KITKAT) // WebVR is only supported on K+
@MinAndroidSdkLevel(Build.VERSION_CODES.LOLLIPOP) // WebVR is only supported on L+
public class WebXrVrDeviceTest {
@ClassParameter
private static List<ParameterSet> sClassParams =
......
......@@ -65,7 +65,7 @@ import java.util.concurrent.TimeUnit;
@UseRunnerDelegate(ChromeJUnit4RunnerDelegate.class)
@CommandLineFlags.Add({ChromeSwitches.DISABLE_FIRST_RUN_EXPERIENCE,
"enable-features=LogJsConsoleMessages", "enable-webvr"})
@MinAndroidSdkLevel(Build.VERSION_CODES.KITKAT) // WebVR and WebXR are only supported on K+
@MinAndroidSdkLevel(Build.VERSION_CODES.LOLLIPOP) // WebVR and WebXR are only supported on L+
public class WebXrVrInputTest {
@ClassParameter
private static List<ParameterSet> sClassParams =
......
......@@ -69,7 +69,7 @@ import java.util.concurrent.TimeoutException;
@UseRunnerDelegate(ChromeJUnit4RunnerDelegate.class)
@CommandLineFlags.Add({ChromeSwitches.DISABLE_FIRST_RUN_EXPERIENCE,
"enable-features=LogJsConsoleMessages", "enable-webvr"})
@MinAndroidSdkLevel(Build.VERSION_CODES.KITKAT) // WebVR and WebXR are only supported on K+
@MinAndroidSdkLevel(Build.VERSION_CODES.LOLLIPOP) // WebVR and WebXR are only supported on L+
@TargetApi(Build.VERSION_CODES.KITKAT) // Necessary to allow taking screenshots with UiAutomation
public class WebXrVrTransitionTest {
@ClassParameter
......
......@@ -5,6 +5,7 @@
#include "device/vr/android/gvr/gvr_device_provider.h"
#include "base/android/build_info.h"
#include "base/android/bundle_utils.h"
#include "device/vr/android/gvr/gvr_device.h"
namespace device {
......@@ -19,14 +20,18 @@ void GvrDeviceProvider::Initialize(
base::RepeatingCallback<void(mojom::XRDeviceId)> remove_device_callback,
base::OnceClosure initialization_complete) {
// Version check should match MIN_SDK_VERSION in VrCoreVersionChecker.java.
// We only expose GvrDevice if we could potentially install VRServices to
// support presentation.
// We only expose GvrDevice if
// - we could potentially install VRServices to support presentation, and
// - this build is a bundle and, thus, supports installing the VR module.
if (base::android::BuildInfo::GetInstance()->sdk_int() >=
base::android::SDK_VERSION_KITKAT)
base::android::SDK_VERSION_LOLLIPOP &&
base::android::BundleUtils::IsBundle()) {
vr_device_ = base::WrapUnique(new GvrDevice());
if (vr_device_)
}
if (vr_device_) {
add_device_callback.Run(vr_device_->GetId(), vr_device_->GetVRDisplayInfo(),
vr_device_->BindXRRuntimePtr());
}
initialized_ = true;
std::move(initialization_complete).Run();
}
......
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