Commit 15aba2f0 authored by Tibor Goldschwendt's avatar Tibor Goldschwendt Committed by Commit Bot

[vr] Handle FRE if VR module is not installed

On smartphone VR, close Chrome and show failure notification.
On standalones, show FRE in 2D-in-VR mode.

TBR=mthiesse@chromium.org

Bug: 918915
Change-Id: I205b727b4dd1fd8f609d6c945a4711bd73f23ea4
Reviewed-on: https://chromium-review.googlesource.com/c/1406020
Commit-Queue: Tibor Goldschwendt <tiborg@chromium.org>
Reviewed-by: default avatarPeter Kotwicz <pkotwicz@chromium.org>
Reviewed-by: default avatarMichael Thiessen <mthiesse@chromium.org>
Cr-Commit-Position: refs/heads/master@{#622154}
parent 63cfe5b8
......@@ -402,6 +402,8 @@ public abstract class FirstRunFlowSequencer {
if (isVrIntent) {
freIntent =
VrModuleProvider.getIntentDelegate().setupVrFreIntent(caller, freIntent);
// We cannot access Chrome right now, e.g. because the VR module is not installed.
if (freIntent == null) return true;
}
IntentUtils.safeStartActivity(caller, freIntent);
} else {
......
......@@ -5,12 +5,10 @@
package org.chromium.chrome.browser.vr;
import android.app.Activity;
import android.app.Notification;
import android.content.ComponentName;
import android.content.Intent;
import android.content.pm.PackageManager;
import android.os.Bundle;
import android.support.v4.app.NotificationCompat;
import org.chromium.base.ActivityState;
import org.chromium.base.ApplicationStatus;
......@@ -21,11 +19,6 @@ import org.chromium.base.compat.ApiHelperForN;
import org.chromium.base.library_loader.LibraryLoader;
import org.chromium.chrome.R;
import org.chromium.chrome.browser.ChromeActivity;
import org.chromium.chrome.browser.notifications.NotificationBuilderFactory;
import org.chromium.chrome.browser.notifications.NotificationConstants;
import org.chromium.chrome.browser.notifications.NotificationManagerProxy;
import org.chromium.chrome.browser.notifications.NotificationManagerProxyImpl;
import org.chromium.chrome.browser.notifications.channels.ChannelDefinitions;
import org.chromium.ui.widget.Toast;
/**
......@@ -37,8 +30,6 @@ import org.chromium.ui.widget.Toast;
private static final String DEFAULT_VR_MODE_PACKAGE = "com.google.vr.vrcore";
private static final String DEFAULT_VR_MODE_CLASS =
"com.google.vr.vrcore.common.VrCoreListenerService";
private static final int PREPARING_VR_NOTIFICATION_TIMEOUT_MS = 5000;
private static final int PREPARING_VR_NOTIFICATION_DELAY_MS = 2000;
private static final int WAITING_FOR_MODULE_TIMEOUT_MS = 1500;
@Override
......@@ -220,32 +211,7 @@ import org.chromium.ui.widget.Toast;
} else {
// Create immersive notification to inform user that Chrome's VR browser cannot be
// accessed yet.
ThreadUtils.postOnUiThreadDelayed(() -> {
NotificationManagerProxy notificationManager =
new NotificationManagerProxyImpl(activity);
Notification notification =
NotificationBuilderFactory
.createChromeNotificationBuilder(
true, ChannelDefinitions.ChannelId.VR)
.setContentTitle(activity.getResources().getString(
R.string.vr_preparing_vr_notification_title))
.setContentText(activity.getResources().getString(
R.string.vr_preparing_vr_notification_body))
.setSmallIcon(R.drawable.ic_chrome)
// Need to set category and max priority. Otherwise, notification
// won't show up.
.setCategory(Notification.CATEGORY_MESSAGE)
.setPriorityBeforeO(NotificationCompat.PRIORITY_MAX)
.build();
notificationManager.notify(
NotificationConstants.NOTIFICATION_ID_PREPARING_VR, notification);
// Close notification after a few seconds as it is only really relevant right after
// accessing the VR browser failed.
ThreadUtils.postOnUiThreadDelayed(() -> {
notificationManager.cancel(NotificationConstants.NOTIFICATION_ID_PREPARING_VR);
}, PREPARING_VR_NOTIFICATION_TIMEOUT_MS);
}, PREPARING_VR_NOTIFICATION_DELAY_MS);
VrFallbackUtils.showFailureNotification(activity);
activity.finish();
}
}
......
// Copyright 2019 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
package org.chromium.chrome.browser.vr;
import android.app.Notification;
import android.content.Context;
import android.support.v4.app.NotificationCompat;
import org.chromium.base.ThreadUtils;
import org.chromium.chrome.R;
import org.chromium.chrome.browser.notifications.NotificationBuilderFactory;
import org.chromium.chrome.browser.notifications.NotificationConstants;
import org.chromium.chrome.browser.notifications.NotificationManagerProxy;
import org.chromium.chrome.browser.notifications.NotificationManagerProxyImpl;
import org.chromium.chrome.browser.notifications.channels.ChannelDefinitions;
/** Class providing utils for when the VR module is not installed. */
/* package */ class VrFallbackUtils {
private static final int PREPARING_VR_NOTIFICATION_TIMEOUT_MS = 5000;
private static final int PREPARING_VR_NOTIFICATION_DELAY_MS = 2000;
/** Shows immersive notification informing the user that the VR browser is not ready yet. */
public static void showFailureNotification(Context context) {
ThreadUtils.postOnUiThreadDelayed(() -> {
NotificationManagerProxy notificationManager =
new NotificationManagerProxyImpl(context);
Notification notification =
NotificationBuilderFactory
.createChromeNotificationBuilder(true, ChannelDefinitions.ChannelId.VR)
.setContentTitle(context.getResources().getString(
R.string.vr_preparing_vr_notification_title))
.setContentText(context.getResources().getString(
R.string.vr_preparing_vr_notification_body))
.setSmallIcon(R.drawable.ic_chrome)
// Need to set category and max priority. Otherwise, notification
// won't show up.
.setCategory(Notification.CATEGORY_MESSAGE)
.setPriorityBeforeO(NotificationCompat.PRIORITY_MAX)
.build();
notificationManager.notify(
NotificationConstants.NOTIFICATION_ID_PREPARING_VR, notification);
// Close notification after a few seconds as it is only really relevant right after
// accessing the VR browser failed.
ThreadUtils.postOnUiThreadDelayed(() -> {
notificationManager.cancel(NotificationConstants.NOTIFICATION_ID_PREPARING_VR);
}, PREPARING_VR_NOTIFICATION_TIMEOUT_MS);
}, PREPARING_VR_NOTIFICATION_DELAY_MS);
}
}
......@@ -13,9 +13,12 @@ import android.content.Intent;
public class VrIntentDelegateFallback extends VrIntentDelegate {
@Override
public Intent setupVrFreIntent(Context context, Intent freIntent) {
// TODO(tiborg): Handle first run if VR module not installed.
assert false;
return freIntent;
if (VrModuleProvider.getDelegate().bootsToVr()) return freIntent;
// Don't bother handling FRE without VR module on smartphone VR. Just request module and
// return to caller.
VrModuleProvider.installModule((success) -> {});
VrFallbackUtils.showFailureNotification(context);
return null;
}
@Override
......
......@@ -1663,6 +1663,7 @@ chrome_java_sources = [
"java/src/org/chromium/chrome/browser/vr/OnExitVrRequestListener.java",
"java/src/org/chromium/chrome/browser/vr/VrDelegate.java",
"java/src/org/chromium/chrome/browser/vr/VrDelegateFallback.java",
"java/src/org/chromium/chrome/browser/vr/VrFallbackUtils.java",
"java/src/org/chromium/chrome/browser/vr/VrIntentDelegateFallback.java",
"java/src/org/chromium/chrome/browser/vr/VrDelegateProvider.java",
"java/src/org/chromium/chrome/browser/vr/VrDelegateProviderFallback.java",
......
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