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

VR: Add java-side plumbing for updating GVR Keyboard

Note that this path is not exercised yet.

Bug: 799584
Cq-Include-Trybots: master.tryserver.chromium.android:android_optional_gpu_tests_rel;master.tryserver.chromium.linux:linux_optional_gpu_tests_rel;master.tryserver.chromium.linux:linux_vr;master.tryserver.chromium.mac:mac_optional_gpu_tests_rel;master.tryserver.chromium.win:win_optional_gpu_tests_rel
Change-Id: I45f34d54eabcbd539c17d3d87ba8c029489a0f28
Reviewed-on: https://chromium-review.googlesource.com/944750
Commit-Queue: Yash Malik <ymalik@chromium.org>
Reviewed-by: default avatarMichael Thiessen <mthiesse@chromium.org>
Cr-Commit-Position: refs/heads/master@{#540391}
parent 614415c6
...@@ -87,6 +87,7 @@ public class VrShellDelegate ...@@ -87,6 +87,7 @@ public class VrShellDelegate
// when used with startActivityForResult... // when used with startActivityForResult...
public static final int EXIT_VR_RESULT = 7212; public static final int EXIT_VR_RESULT = 7212;
public static final int VR_SERVICES_UPDATE_RESULT = 7213; public static final int VR_SERVICES_UPDATE_RESULT = 7213;
public static final int GVR_KEYBOARD_UPDATE_RESULT = 7214;
private static final int ENTER_VR_NOT_NECESSARY = 0; private static final int ENTER_VR_NOT_NECESSARY = 0;
private static final int ENTER_VR_CANCELLED = 1; private static final int ENTER_VR_CANCELLED = 1;
...@@ -113,6 +114,9 @@ public class VrShellDelegate ...@@ -113,6 +114,9 @@ public class VrShellDelegate
private static final String VR_CORE_MARKET_URI = private static final String VR_CORE_MARKET_URI =
"market://details?id=" + VrCoreVersionChecker.VR_CORE_PACKAGE_ID; "market://details?id=" + VrCoreVersionChecker.VR_CORE_PACKAGE_ID;
private static final String GVR_KEYBOARD_MARKET_URI =
"market://details?id=com.google.android.vr.inputmethod";
// This value is intentionally probably overkill. This is the time we need to wait from when // This value is intentionally probably overkill. This is the time we need to wait from when
// Chrome is resumed, to when Chrome actually renders a black frame, so that we can cancel the // Chrome is resumed, to when Chrome actually renders a black frame, so that we can cancel the
// stay_hidden animation and not see a white monoscopic frame in-headset. 150ms is definitely // stay_hidden animation and not see a white monoscopic frame in-headset. 150ms is definitely
...@@ -322,6 +326,10 @@ public class VrShellDelegate ...@@ -322,6 +326,10 @@ public class VrShellDelegate
if (sInstance != null) sInstance.onVrServicesMaybeUpdated(); if (sInstance != null) sInstance.onVrServicesMaybeUpdated();
return true; return true;
} }
// Handles the result of requesting to update GVR Keyboard.
if (requestCode == GVR_KEYBOARD_UPDATE_RESULT) {
return true;
}
return false; return false;
} }
...@@ -1776,6 +1784,12 @@ public class VrShellDelegate ...@@ -1776,6 +1784,12 @@ public class VrShellDelegate
buttonText, null, true); buttonText, null, true);
} }
/* package */ void promptForKeyboardUpdate() {
mActivity.startActivityForResult(
new Intent(Intent.ACTION_VIEW, Uri.parse(GVR_KEYBOARD_MARKET_URI)),
GVR_KEYBOARD_UPDATE_RESULT);
}
private boolean createVrShell() { private boolean createVrShell() {
assert mVrShell == null; assert mVrShell == null;
if (mVrClassesWrapper == null) return false; if (mVrClassesWrapper == null) return false;
......
...@@ -513,6 +513,21 @@ public class VrShellImpl ...@@ -513,6 +513,21 @@ public class VrShellImpl
}, UiUnsupportedMode.VOICE_SEARCH_NEEDS_RECORD_AUDIO_OS_PERMISSION); }, UiUnsupportedMode.VOICE_SEARCH_NEEDS_RECORD_AUDIO_OS_PERMISSION);
} }
// Called when the user has an older GVR Keyboard installed on their device and we need them to
// have a newer one.
@CalledByNative
public void onNeedsKeyboardUpdate() {
VrShellDelegate.requestToExitVr(new OnExitVrRequestListener() {
@Override
public void onSucceeded() {
mDelegate.promptForKeyboardUpdate();
}
@Override
public void onDenied() {}
}, UiUnsupportedMode.NEEDS_KEYBOARD_UPDATE);
}
// Exits CCT, returning to the app that opened it. // Exits CCT, returning to the app that opened it.
@CalledByNative @CalledByNative
public void exitCct() { public void exitCct() {
......
...@@ -17,10 +17,14 @@ ...@@ -17,10 +17,14 @@
// This method is supplied by the VR keyboard shim, but is not part of the // This method is supplied by the VR keyboard shim, but is not part of the
// GVR interface. // GVR interface.
bool gvr_keyboard_supports_selection(gvr_keyboard_context* context); bool gvr_keyboard_supports_selection();
int64_t gvr_keyboard_version();
namespace vr { namespace vr {
// The minimum keyboard version required for the needed features to work.
constexpr int64_t kMinRequiredApiVersion = 2;
namespace { namespace {
void OnKeyboardEvent(void* closure, GvrKeyboardDelegate::EventType event) { void OnKeyboardEvent(void* closure, GvrKeyboardDelegate::EventType event) {
...@@ -38,6 +42,12 @@ std::unique_ptr<GvrKeyboardDelegate> GvrKeyboardDelegate::Create() { ...@@ -38,6 +42,12 @@ std::unique_ptr<GvrKeyboardDelegate> GvrKeyboardDelegate::Create() {
auto* gvr_keyboard = gvr_keyboard_create(callback, OnKeyboardEvent); auto* gvr_keyboard = gvr_keyboard_create(callback, OnKeyboardEvent);
if (!gvr_keyboard) if (!gvr_keyboard)
return nullptr; return nullptr;
if (gvr_keyboard_version() < kMinRequiredApiVersion) {
gvr_keyboard_destroy(&gvr_keyboard);
return nullptr;
}
delegate->Init(gvr_keyboard); delegate->Init(gvr_keyboard);
return delegate; return delegate;
} }
...@@ -126,7 +136,7 @@ void GvrKeyboardDelegate::Draw(const CameraModel& model) { ...@@ -126,7 +136,7 @@ void GvrKeyboardDelegate::Draw(const CameraModel& model) {
} }
bool GvrKeyboardDelegate::SupportsSelection() { bool GvrKeyboardDelegate::SupportsSelection() {
return gvr_keyboard_supports_selection(gvr_keyboard_); return gvr_keyboard_supports_selection();
} }
void GvrKeyboardDelegate::OnTouchStateUpdated( void GvrKeyboardDelegate::OnTouchStateUpdated(
......
...@@ -282,7 +282,14 @@ void gvr_keyboard_hide(gvr_keyboard_context* context) { ...@@ -282,7 +282,14 @@ void gvr_keyboard_hide(gvr_keyboard_context* context) {
keyboard_api->impl_gvr_keyboard_hide(context); keyboard_api->impl_gvr_keyboard_hide(context);
} }
bool gvr_keyboard_supports_selection(gvr_keyboard_context* context) { bool gvr_keyboard_supports_selection() {
if (!keyboard_api)
return false;
return keyboard_api->min_version >= kSelectionSupportApiVersion; return keyboard_api->min_version >= kSelectionSupportApiVersion;
} }
int64_t gvr_keyboard_version() {
if (!keyboard_api)
return -1;
return keyboard_api->min_version;
}
...@@ -64,6 +64,8 @@ void VrGLThread::Init() { ...@@ -64,6 +64,8 @@ void VrGLThread::Init() {
} }
auto* keyboard_delegate = auto* keyboard_delegate =
!keyboard_delegate_ ? nullptr : keyboard_delegate_.get(); !keyboard_delegate_ ? nullptr : keyboard_delegate_.get();
if (!keyboard_delegate)
ui_initial_state_.needs_keyboard_update = true;
auto ui = std::make_unique<Ui>(this, this, keyboard_delegate, auto ui = std::make_unique<Ui>(this, this, keyboard_delegate,
text_input_delegate_.get(), ui_initial_state_); text_input_delegate_.get(), ui_initial_state_);
if (keyboard_enabled) { if (keyboard_enabled) {
......
...@@ -729,6 +729,11 @@ void VrShell::OnUnsupportedMode(UiUnsupportedMode mode) { ...@@ -729,6 +729,11 @@ void VrShell::OnUnsupportedMode(UiUnsupportedMode mode) {
Java_VrShellImpl_onUnhandledPermissionPrompt(env, j_vr_shell_); Java_VrShellImpl_onUnhandledPermissionPrompt(env, j_vr_shell_);
return; return;
} }
case UiUnsupportedMode::kNeedsKeyboardUpdate: {
JNIEnv* env = base::android::AttachCurrentThread();
Java_VrShellImpl_onNeedsKeyboardUpdate(env, j_vr_shell_);
return;
}
case UiUnsupportedMode::kCount: case UiUnsupportedMode::kCount:
NOTREACHED(); // Should never be used as a mode. NOTREACHED(); // Should never be used as a mode.
return; return;
......
...@@ -16,6 +16,8 @@ UiUnsupportedMode GetReasonForPrompt(ModalPromptType prompt) { ...@@ -16,6 +16,8 @@ UiUnsupportedMode GetReasonForPrompt(ModalPromptType prompt) {
return UiUnsupportedMode::kVoiceSearchNeedsRecordAudioOsPermission; return UiUnsupportedMode::kVoiceSearchNeedsRecordAudioOsPermission;
case kModalPromptTypeGenericUnsupportedFeature: case kModalPromptTypeGenericUnsupportedFeature:
return UiUnsupportedMode::kGenericUnsupportedFeature; return UiUnsupportedMode::kGenericUnsupportedFeature;
case kModalPromptTypeUpdateKeyboard:
return UiUnsupportedMode::kNeedsKeyboardUpdate;
case kModalPromptTypeNone: case kModalPromptTypeNone:
return UiUnsupportedMode::kCount; return UiUnsupportedMode::kCount;
} }
......
...@@ -14,6 +14,7 @@ enum ModalPromptType { ...@@ -14,6 +14,7 @@ enum ModalPromptType {
kModalPromptTypeExitVRForSiteInfo, kModalPromptTypeExitVRForSiteInfo,
kModalPromptTypeExitVRForVoiceSearchRecordAudioOsPermission, kModalPromptTypeExitVRForVoiceSearchRecordAudioOsPermission,
kModalPromptTypeGenericUnsupportedFeature, kModalPromptTypeGenericUnsupportedFeature,
kModalPromptTypeUpdateKeyboard,
}; };
UiUnsupportedMode GetReasonForPrompt(ModalPromptType prompt); UiUnsupportedMode GetReasonForPrompt(ModalPromptType prompt);
......
...@@ -49,6 +49,7 @@ struct Model { ...@@ -49,6 +49,7 @@ struct Model {
bool can_apply_new_background = false; bool can_apply_new_background = false;
bool background_loaded = false; bool background_loaded = false;
bool supports_selection = true; bool supports_selection = true;
bool needs_keyboard_update = false;
// WebVR state. // WebVR state.
WebVrModel web_vr; WebVrModel web_vr;
......
...@@ -160,6 +160,9 @@ void Ui::ShowExitVrPrompt(UiUnsupportedMode reason) { ...@@ -160,6 +160,9 @@ void Ui::ShowExitVrPrompt(UiUnsupportedMode reason) {
model_->active_modal_prompt_type = model_->active_modal_prompt_type =
kModalPromptTypeGenericUnsupportedFeature; kModalPromptTypeGenericUnsupportedFeature;
return; return;
case UiUnsupportedMode::kNeedsKeyboardUpdate:
model_->active_modal_prompt_type = kModalPromptTypeUpdateKeyboard;
return;
case UiUnsupportedMode::kCount: case UiUnsupportedMode::kCount:
NOTREACHED(); // Should never be used as a mode (when |enabled| is true). NOTREACHED(); // Should never be used as a mode (when |enabled| is true).
return; return;
...@@ -439,6 +442,7 @@ void Ui::InitializeModel(const UiInitialState& ui_initial_state) { ...@@ -439,6 +442,7 @@ void Ui::InitializeModel(const UiInitialState& ui_initial_state) {
ui_initial_state.skips_redraw_when_not_dirty; ui_initial_state.skips_redraw_when_not_dirty;
model_->waiting_for_background = ui_initial_state.assets_available; model_->waiting_for_background = ui_initial_state.assets_available;
model_->supports_selection = ui_initial_state.supports_selection; model_->supports_selection = ui_initial_state.supports_selection;
model_->needs_keyboard_update = ui_initial_state.needs_keyboard_update;
} }
void Ui::AcceptDoffPromptForTesting() { void Ui::AcceptDoffPromptForTesting() {
......
...@@ -43,6 +43,7 @@ struct UiInitialState { ...@@ -43,6 +43,7 @@ struct UiInitialState {
// TODO(tiborg): Remove this flag. // TODO(tiborg): Remove this flag.
bool assets_available = false; bool assets_available = false;
bool supports_selection = true; bool supports_selection = true;
bool needs_keyboard_update = false;
}; };
// This class manages all GLThread owned objects and GL rendering for VrShell. // This class manages all GLThread owned objects and GL rendering for VrShell.
......
...@@ -18,6 +18,7 @@ enum class UiUnsupportedMode : int { ...@@ -18,6 +18,7 @@ enum class UiUnsupportedMode : int {
// kURLWithStrongRTLChars = 3, // Obsolete. // kURLWithStrongRTLChars = 3, // Obsolete.
kVoiceSearchNeedsRecordAudioOsPermission = 4, // TODO(ddorwin): Android only. kVoiceSearchNeedsRecordAudioOsPermission = 4, // TODO(ddorwin): Android only.
kGenericUnsupportedFeature = 5, kGenericUnsupportedFeature = 5,
kNeedsKeyboardUpdate = 6,
// This must be last. // This must be last.
kCount, kCount,
}; };
......
...@@ -45293,6 +45293,8 @@ Called by update_traffic_annotation_histograms.py.--> ...@@ -45293,6 +45293,8 @@ Called by update_traffic_annotation_histograms.py.-->
<int value="2" label="Unhandled PageInfo"/> <int value="2" label="Unhandled PageInfo"/>
<int value="3" label="URL contained strong RTL chars (obsolete)"/> <int value="3" label="URL contained strong RTL chars (obsolete)"/>
<int value="4" label="Chrome needs audio permission for voice input"/> <int value="4" label="Chrome needs audio permission for voice input"/>
<int value="5" label="A non-specific unsupported feature was encountered"/>
<int value="6" label="The keyboard version is out-of-date"/>
</enum> </enum>
<enum name="VRViewerType"> <enum name="VRViewerType">
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