Commit e0074774 authored by Alex Cooper's avatar Alex Cooper Committed by Commit Bot

Remove Unused AR DFM installation code

Fixed: 1043224
Change-Id: Idbdee58a5fc733055bf1cb0de095b3c36ded5b47
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2029330
Commit-Queue: Alexander Cooper <alcooper@chromium.org>
Reviewed-by: default avatarPiotr Bialecki <bialpio@chromium.org>
Cr-Commit-Position: refs/heads/master@{#737115}
parent 20e89d1f
......@@ -14,23 +14,18 @@ import org.chromium.base.annotations.NativeMethods;
import org.chromium.chrome.R;
import org.chromium.chrome.browser.infobar.InfoBarIdentifier;
import org.chromium.chrome.browser.infobar.SimpleConfirmInfoBarBuilder;
import org.chromium.chrome.browser.modules.ModuleInstallUi;
import org.chromium.chrome.browser.tab.Tab;
import org.chromium.chrome.browser.tab.TabImpl;
import org.chromium.components.module_installer.engine.EngineFactory;
import org.chromium.components.module_installer.engine.InstallEngine;
/**
* Installs AR DFM and ArCore runtimes.
*/
@JNINamespace("vr")
public class ArCoreInstallUtils implements ModuleInstallUi.FailureUiListener {
public class ArCoreInstallUtils {
private static final String TAG = "ArCoreInstallUtils";
private long mNativeArCoreInstallUtils;
private Tab mTab;
// Instance that requested installation of ARCore.
// Should be non-null only if there is a pending request to install ARCore.
private static ArCoreInstallUtils sRequestInstallInstance;
......@@ -71,73 +66,6 @@ public class ArCoreInstallUtils implements ModuleInstallUi.FailureUiListener {
mNativeArCoreInstallUtils = nativeArCoreInstallUtils;
}
@Override
public void onFailureUiResponse(boolean retry) {
if (mNativeArCoreInstallUtils == 0) return;
if (retry) {
requestInstallArModule(mTab);
} else {
ArCoreInstallUtilsJni.get().onRequestInstallArModuleResult(
mNativeArCoreInstallUtils, false);
}
}
@CalledByNative
private boolean shouldRequestInstallArModule() {
try {
// Try to find class in AR module that has not been obfuscated.
Class.forName("com.google.ar.core.ArCoreApk");
return false;
} catch (ClassNotFoundException e) {
return true;
}
}
private boolean canRequestInstallArModule() {
// We can only try to install the AR module if we are in a bundle mode.
// Currently, AR DFM is disabled so we should never have to install it.
return false;
}
private void requestInstallArModule(Tab tab) {
mTab = tab;
ModuleInstallUi ui = new ModuleInstallUi(mTab, R.string.ar_module_title, this);
InstallEngine installEngine = new EngineFactory().getEngine();
ui.showInstallStartUi();
installEngine.install("ar", success -> {
assert shouldRequestInstallArModule() != success;
if (success) {
// As per documentation, it's recommended to issue a call to
// ArCoreApk.checkAvailability() early in application lifecycle & ignore the result
// so that subsequent calls can return cached result:
// https://developers.google.com/ar/develop/java/enable-arcore
// This is as early in the app lifecycle as it gets for us - just after installing
// AR module.
// In the event that a remote call is required, it will not block on that remote
// call per:
// https://developers.google.com/ar/reference/java/arcore/reference/com/google/ar/core/ArCoreApk#checkAvailability
getArCoreInstallStatus();
}
if (mNativeArCoreInstallUtils != 0) {
if (success) {
ui.showInstallSuccessUi();
ArCoreInstallUtilsJni.get().onRequestInstallArModuleResult(
mNativeArCoreInstallUtils, success);
} else {
ui.showInstallFailureUi();
// early exit - user will be offered a choice to retry & install flow will
// continue from onFailureUiResponse().
return;
}
}
});
}
private static @ArCoreShim.Availability int getArCoreInstallStatus() {
try {
return getArCoreShimInstance().checkAvailability(ContextUtils.getApplicationContext());
......@@ -275,7 +203,6 @@ public class ArCoreInstallUtils implements ModuleInstallUi.FailureUiListener {
@NativeMethods
/* package */ interface ArInstallHelperNative {
void onRequestInstallArModuleResult(long nativeArCoreInstallHelper, boolean success);
void onRequestInstallSupportedArCoreResult(long nativeArCoreInstallHelper, boolean success);
void installArCoreDeviceProviderFactory();
}
......
......@@ -66,43 +66,12 @@ void ArCoreInstallHelper::EnsureInstalled(
OnInstallFinishedCallback install_callback) {
DCHECK(!install_finished_callback_);
install_finished_callback_ = std::move(install_callback);
render_process_id_ = render_process_id;
render_frame_id_ = render_frame_id;
if (java_install_utils_.is_null()) {
RunInstallFinishedCallback(false);
return;
}
// First check if the DFM needs to be installed.
if (Java_ArCoreInstallUtils_shouldRequestInstallArModule(
AttachCurrentThread(), java_install_utils_)) {
// AR DFM is disabled - if we think we should install AR module, then it
// means that we are using a build that does not support AR capabilities.
// Treat this as if the AR module installation failed.
LOG(WARNING) << "AR is not supported on this build";
RunInstallFinishedCallback(false);
return;
}
// The AR DFM is disabled, so pretend like its installation succeeded.
OnRequestInstallArModuleResult(nullptr, true);
}
void ArCoreInstallHelper::OnRequestInstallArModuleResult(JNIEnv* env,
bool success) {
DVLOG(1) << __func__;
DCHECK(success) << "AR DFM installation disabled, so should always 'succeed'";
// Now that the DFM is successfully installed, check if ARCore needs to be
// installed or updated next.
RequestArCoreInstallOrUpdate();
}
void ArCoreInstallHelper::RequestArCoreInstallOrUpdate() {
DVLOG(1) << __func__;
JNIEnv* env = AttachCurrentThread();
if (Java_ArCoreInstallUtils_shouldRequestInstallSupportedArCore(env)) {
......@@ -110,7 +79,7 @@ void ArCoreInstallHelper::RequestArCoreInstallOrUpdate() {
// When completed, java will call: OnRequestInstallSupportedArCoreResult
Java_ArCoreInstallUtils_requestInstallSupportedArCore(
env, java_install_utils_,
GetTabFromRenderer(render_process_id_, render_frame_id_));
GetTabFromRenderer(render_process_id, render_frame_id));
return;
}
......
......@@ -27,18 +27,12 @@ class VR_EXPORT ArCoreInstallHelper : public XrInstallHelper {
OnInstallFinishedCallback install_callback) override;
// Called from Java end.
void OnRequestInstallArModuleResult(JNIEnv* env, bool success);
void OnRequestInstallSupportedArCoreResult(JNIEnv* env, bool success);
private:
void RequestArCoreInstallOrUpdate();
void RunInstallFinishedCallback(bool succeeded);
OnInstallFinishedCallback install_finished_callback_;
int render_process_id_;
int render_frame_id_;
OnInstallFinishedCallback install_finished_callback_;
base::android::ScopedJavaGlobalRef<jobject> java_install_utils_;
};
......
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