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

Add gvr-android-keyboard to third_party/

This CL adds the header and .aidl file that Chrome needs to dynamically load the
Keyboard API implementation from the Daydream Keyboard apk.

Bug: 641470
Change-Id: Id47074cc0fdff786d0ab23dd0e43faabc0c2b023
Reviewed-on: https://chromium-review.googlesource.com/771537
Commit-Queue: Yash Malik <ymalik@chromium.org>
Reviewed-by: default avatarDavid Dorwin <ddorwin@chromium.org>
Reviewed-by: default avatarBiao She <bshe@chromium.org>
Reviewed-by: default avatarMax Moroz <mmoroz@chromium.org>
Reviewed-by: default avatarBrett Wilson <brettw@chromium.org>
Cr-Commit-Position: refs/heads/master@{#517235}
parent 05b79709
# Copyright 2017 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.
import("//build/config/android/rules.gni")
android_library("kb_java") {
deps = [
"//base:base_java",
]
srcjar_deps = [ ":aidl" ]
}
android_aidl("aidl") {
sources = [
"com/google/vr/keyboard/IGvrKeyboardLoader.aidl",
]
}
config("kb_config") {
include_dirs = [ "src/libraries/headers/" ]
}
Apache License
Version 2.0, January 2004
http://www.apache.org/licenses/
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
1. Definitions.
"License" shall mean the terms and conditions for use, reproduction,
and distribution as defined by Sections 1 through 9 of this document.
"Licensor" shall mean the copyright owner or entity authorized by
the copyright owner that is granting the License.
"Legal Entity" shall mean the union of the acting entity and all
other entities that control, are controlled by, or are under common
control with that entity. For the purposes of this definition,
"control" means (i) the power, direct or indirect, to cause the
direction or management of such entity, whether by contract or
otherwise, or (ii) ownership of fifty percent (50%) or more of the
outstanding shares, or (iii) beneficial ownership of such entity.
"You" (or "Your") shall mean an individual or Legal Entity
exercising permissions granted by this License.
"Source" form shall mean the preferred form for making modifications,
including but not limited to software source code, documentation
source, and configuration files.
"Object" form shall mean any form resulting from mechanical
transformation or translation of a Source form, including but
not limited to compiled object code, generated documentation,
and conversions to other media types.
"Work" shall mean the work of authorship, whether in Source or
Object form, made available under the License, as indicated by a
copyright notice that is included in or attached to the work
(an example is provided in the Appendix below).
"Derivative Works" shall mean any work, whether in Source or Object
form, that is based on (or derived from) the Work and for which the
editorial revisions, annotations, elaborations, or other modifications
represent, as a whole, an original work of authorship. For the purposes
of this License, Derivative Works shall not include works that remain
separable from, or merely link (or bind by name) to the interfaces of,
the Work and Derivative Works thereof.
"Contribution" shall mean any work of authorship, including
the original version of the Work and any modifications or additions
to that Work or Derivative Works thereof, that is intentionally
submitted to Licensor for inclusion in the Work by the copyright owner
or by an individual or Legal Entity authorized to submit on behalf of
the copyright owner. For the purposes of this definition, "submitted"
means any form of electronic, verbal, or written communication sent
to the Licensor or its representatives, including but not limited to
communication on electronic mailing lists, source code control systems,
and issue tracking systems that are managed by, or on behalf of, the
Licensor for the purpose of discussing and improving the Work, but
excluding communication that is conspicuously marked or otherwise
designated in writing by the copyright owner as "Not a Contribution."
"Contributor" shall mean Licensor and any individual or Legal Entity
on behalf of whom a Contribution has been received by Licensor and
subsequently incorporated within the Work.
2. Grant of Copyright License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
copyright license to reproduce, prepare Derivative Works of,
publicly display, publicly perform, sublicense, and distribute the
Work and such Derivative Works in Source or Object form.
3. Grant of Patent License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
(except as stated in this section) patent license to make, have made,
use, offer to sell, sell, import, and otherwise transfer the Work,
where such license applies only to those patent claims licensable
by such Contributor that are necessarily infringed by their
Contribution(s) alone or by combination of their Contribution(s)
with the Work to which such Contribution(s) was submitted. If You
institute patent litigation against any entity (including a
cross-claim or counterclaim in a lawsuit) alleging that the Work
or a Contribution incorporated within the Work constitutes direct
or contributory patent infringement, then any patent licenses
granted to You under this License for that Work shall terminate
as of the date such litigation is filed.
4. Redistribution. You may reproduce and distribute copies of the
Work or Derivative Works thereof in any medium, with or without
modifications, and in Source or Object form, provided that You
meet the following conditions:
(a) You must give any other recipients of the Work or
Derivative Works a copy of this License; and
(b) You must cause any modified files to carry prominent notices
stating that You changed the files; and
(c) You must retain, in the Source form of any Derivative Works
that You distribute, all copyright, patent, trademark, and
attribution notices from the Source form of the Work,
excluding those notices that do not pertain to any part of
the Derivative Works; and
(d) If the Work includes a "NOTICE" text file as part of its
distribution, then any Derivative Works that You distribute must
include a readable copy of the attribution notices contained
within such NOTICE file, excluding those notices that do not
pertain to any part of the Derivative Works, in at least one
of the following places: within a NOTICE text file distributed
as part of the Derivative Works; within the Source form or
documentation, if provided along with the Derivative Works; or,
within a display generated by the Derivative Works, if and
wherever such third-party notices normally appear. The contents
of the NOTICE file are for informational purposes only and
do not modify the License. You may add Your own attribution
notices within Derivative Works that You distribute, alongside
or as an addendum to the NOTICE text from the Work, provided
that such additional attribution notices cannot be construed
as modifying the License.
You may add Your own copyright statement to Your modifications and
may provide additional or different license terms and conditions
for use, reproduction, or distribution of Your modifications, or
for any such Derivative Works as a whole, provided Your use,
reproduction, and distribution of the Work otherwise complies with
the conditions stated in this License.
5. Submission of Contributions. Unless You explicitly state otherwise,
any Contribution intentionally submitted for inclusion in the Work
by You to the Licensor shall be under the terms and conditions of
this License, without any additional terms or conditions.
Notwithstanding the above, nothing herein shall supersede or modify
the terms of any separate license agreement you may have executed
with Licensor regarding such Contributions.
6. Trademarks. This License does not grant permission to use the trade
names, trademarks, service marks, or product names of the Licensor,
except as required for reasonable and customary use in describing the
origin of the Work and reproducing the content of the NOTICE file.
7. Disclaimer of Warranty. Unless required by applicable law or
agreed to in writing, Licensor provides the Work (and each
Contributor provides its Contributions) on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
implied, including, without limitation, any warranties or conditions
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
PARTICULAR PURPOSE. You are solely responsible for determining the
appropriateness of using or redistributing the Work and assume any
risks associated with Your exercise of permissions under this License.
8. Limitation of Liability. In no event and under no legal theory,
whether in tort (including negligence), contract, or otherwise,
unless required by applicable law (such as deliberate and grossly
negligent acts) or agreed to in writing, shall any Contributor be
liable to You for damages, including any direct, indirect, special,
incidental, or consequential damages of any character arising as a
result of this License or out of the use or inability to use the
Work (including but not limited to damages for loss of goodwill,
work stoppage, computer failure or malfunction, or any and all
other commercial damages or losses), even if such Contributor
has been advised of the possibility of such damages.
9. Accepting Warranty or Additional Liability. While redistributing
the Work or Derivative Works thereof, You may choose to offer,
and charge a fee for, acceptance of support, warranty, indemnity,
or other liability obligations and/or rights consistent with this
License. However, in accepting such obligations, You may act only
on Your own behalf and on Your sole responsibility, not on behalf
of any other Contributor, and only if You agree to indemnify,
defend, and hold each Contributor harmless for any liability
incurred by, or claims asserted against, such Contributor by reason
of your accepting any such warranty or additional liability.
END OF TERMS AND CONDITIONS
APPENDIX: How to apply the Apache License to your work.
To apply the Apache License to your work, attach the following
boilerplate notice, with the fields enclosed by brackets "[]"
replaced with your own identifying information. (Don't include
the brackets!) The text should be enclosed in the appropriate
comment syntax for the file format. We also recommend that a
file or class name and description of purpose be included on the
same "printed page" as the copyright notice for easier
identification within third-party archives.
Copyright 2014 The Android Open Source Project
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
ymalik@chromium.org
asimjour@chromium.org
# COMPONENT: UI>Browser>VR
Name: GVR Keyboard
Short Name: gvr-android-keyboard
URL: NA
Version: 0
Date: 2017-11-14
License: Apache 2.0
License File: LICENSE
Security Critical: yes
Description:
Chrome VR dynamically loads the keyboard API packaged as part of the GVR
keyboard APK. This directory includes the header for the API and the resources
needed to dynamically load the implementation. Note that the GVR keyboard isn't
uploaded to a public repository yet.
Local Modifications:
We added a dependency to gvr_types.h in third_party/gvr-android-sdk, which is
needed by gvr_header.h.
/* Copyright 2017 Google Inc. All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.google.vr.keyboard;
/**
* @hide
* Provides loading of the GVR keyboard library.
*/
interface IGvrKeyboardLoader {
/**
* Attempts to load (dlopen) GVR keyboard library.
* <p>
* The library will be loaded only if a matching library can be found
* that is recent enough. If the library is out-of-date, or cannot be found,
* 0 will be returned.
*
* @param the version of the target library.
* @return the native handle to the library. 0 if the load fails.
*/
long loadGvrKeyboard(long version) = 1;
/**
* Closes a library (dlclose).
*
* @param nativeLibrary the native handle of the library to be closed.
*/
void closeGvrKeyboard(long nativeLibrary) = 2;
}
per-file *.aidl=set noparent
per-file *.aidl=file://ipc/SECURITY_OWNERS
/* Copyright 2017 Google Inc. All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef VR_GVR_KEYBOARD_CAPI_INCLUDE_GVR_KEYBOARD_H_
#define VR_GVR_KEYBOARD_CAPI_INCLUDE_GVR_KEYBOARD_H_
#ifdef __ANDROID__
#include <jni.h>
#endif
#include "third_party/gvr-android-sdk/src/libraries/headers/vr/gvr/capi/include/gvr_types.h"
/// @defgroup keyboard GVR Keyboard API
/// @brief The Google VR Keyboard provides a virtual keyboard designed for VR
/// apps.
///
/// Any changes to this API must be backwards compatible (ie old clients should
/// be able to call a newer SDK). Any time a change is made, the API_VERSION in
/// GvrKeyboardLoaderClient.java should be updated.
///
/// ## API usage
///
/// * `gvr_keyboard_initialize()` initializes the Android JVM. This must be
/// done only once during the entire lifecycle of your application,
/// and before calling any other GVR Keyboard API calls.
/// * `gvr_keyboard_create()` creates a keyboard and returns a pointer to
/// its context. The keyboard is not shown.
/// * Call `gvr_keyboard_advance_frame()` on every frame after a keyboard is
/// created with `gvr_create_keyboard()`. This is necessary even when the
/// keyboard is not visible as there may be events to process.
/// * Call `gvr_keyboard_render()` after `gvr_keyboard_advance_frame()` twice
/// to render keyboard for both eyes.
/// * `gvr_keyboard_show()` displays the keyboard at a specified location.
/// * `gvr_keyboard_set_input_mode()` sets input mode of the keyboard.
/// * Use `gvr_keyboard_on_event()` to send controller updates to the
/// keyboard. This should be done on every frame the keyboard is visible.
/// * `gvr_keyboard_hide()` hides the keyboard.
/// * Call `gvr_keyboard_destroy()` to destroy the keyboard when it is no
/// longer used.
///
/// This API is designed to be thread-safe, with some exceptions.
/// `gvr_keyboard_advance_frame()` and `gvr_keyboard_render()` must be called
/// from the GL thread.
/// `gvr_keyboard_destroy()` has potential threading issues as it destroys the
/// `gvr_keyboard_context` pointer. Make sure that when `gvr_keyboard_destroy()`
/// is called, `gvr_keyboard_context` is not used by another thread.
/// @{
#ifdef __cplusplus
extern "C" {
#endif
/// Events from the keyboard. To receive events, set a `gvr_keyboard_callback`
/// callback when you create the keyboard with `gvr_keyboard_create`.
typedef enum {
/// Unknown error.
GVR_KEYBOARD_ERROR_UNKNOWN = 0,
/// The keyboard service could not be connected. This is usually due to the
/// keyboard service not being installed.
GVR_KEYBOARD_ERROR_SERVICE_NOT_CONNECTED = 1,
/// No locale was found in the keyboard service.
GVR_KEYBOARD_ERROR_NO_LOCALES_FOUND = 2,
/// The keyboard SDK tried to load dynamically but failed. This is usually due
/// to the keyboard service not being installed or being out of date.
GVR_KEYBOARD_ERROR_SDK_LOAD_FAILED = 3,
/// Keyboard becomes visible.
GVR_KEYBOARD_SHOWN = 4,
/// Keyboard becomes hidden.
GVR_KEYBOARD_HIDDEN = 5,
/// Text has been updated.
GVR_KEYBOARD_TEXT_UPDATED = 6,
/// Text has been committed.
GVR_KEYBOARD_TEXT_COMMITTED = 7,
} gvr_keyboard_event;
/// The input mode of the keyboard.
typedef enum {
/// Default keyboard layout.
GVR_KEYBOARD_MODE_DEFAULT = 0,
/// Keyboard layout for inputing numbers.
GVR_KEYBOARD_MODE_NUMERIC = 1,
} gvr_keyboard_input_mode;
typedef struct gvr_mat4f gvr_mat4f;
typedef struct gvr_keyboard_context_ gvr_keyboard_context;
/// Callback for various keyboard events.
/// @param void* Custom closure pointer.
typedef void (*gvr_keyboard_callback)(void* closure, int32_t event);
#ifdef __ANDROID__
/// Initializes the JVM for Android. This must be called exactly once, and
/// before using the Keyboard API.
///
/// @param env The JNIEnv associated with the current thread.
/// @param app_context The Android application context. This must be the
/// application context, NOT an Activity context. (Note: From any Android
/// Activity in your app, you can call getApplicationContext() to retrieve
/// the application context).
/// @param class_loader The class loader to use when loading Java classes.
/// This must be your app's main class loader, usually accessible through
/// activity.getClassLoader() on any of your Activities.
void gvr_keyboard_initialize(JNIEnv* env,
jobject app_context,
jobject class_loader);
#endif
/// Creates a keyboard and connects to to the Keyboard Service.
///
/// @param closure Custom closure pointer, passed to all the callbacks.
/// @param callback A pointer to the callback function to receive events.
/// @return A pointer to the new keyboard's context.
gvr_keyboard_context* gvr_keyboard_create(void* closure,
gvr_keyboard_callback callback);
/// Gets the current input mode.
///
/// @param context A pointer to the keyboard's context.
/// @return The input mode of the keyboard.
int32_t gvr_keyboard_get_input_mode(gvr_keyboard_context* context);
/// Sets the input mode of the keyboard.
///
/// @param context A pointer to the keyboard context.
/// @param input_mode The input mode to set.
void gvr_keyboard_set_input_mode(gvr_keyboard_context* context,
int32_t input_mode);
/// Gets the recommended matrix for showing the keyboard. Use
/// `distance_from_eye` to specify the distance from the eyes to the keyboard.
///
/// @param distance_from_eye How far away to render the keyboard, in meters.
/// This number should normally be within [1.0f, 5.0f].
/// @param matrix The matrix to be filled in with the recommended matrix values.
void gvr_keyboard_get_recommended_world_from_keyboard_matrix(
float distance_from_eye,
gvr_mat4f* matrix);
/// Shows the keyboard, as specified by `keyboard_matrix`. The matrix should
/// generally be filled using `gvr_keyboard_get_recommended_matrix()`.
///
/// @param context A pointer to the keyboard's context.
/// @param keyboard_matrix A transformation matrix defining where and how to
/// show the keyboard.
void gvr_keyboard_show(gvr_keyboard_context* context);
/// Sets keyboard to world matrix.
///
/// @param context A pointer to the keyboard's context.
/// @param matrix The keyboard to world matrix.
void gvr_keyboard_set_world_from_keyboard_matrix(gvr_keyboard_context* context,
const gvr_mat4f* matrix);
/// Updates the keyboard with the controller's button state.
///
/// @param context A pointer to the keyboard's context.
/// @param button_index The controller's button defined in gvr.
/// @param pressed Whether button is being pressed.
void gvr_keyboard_update_button_state(gvr_keyboard_context* context,
int32_t button_index,
bool pressed);
/// Updates the ray of the controller.
///
/// @param context A pointer to the keyboard's context.
/// @param start Start position of the ray.
/// @param end End position of the ray.
/// @param hit Hit position if the ray intersects with the keyboard.
/// @return true if the ray hits the keyboard.
bool gvr_keyboard_update_controller_ray(gvr_keyboard_context* context,
const gvr_vec3f* start,
const gvr_vec3f* end,
gvr_vec3f* hit);
/// Gets the contents of the keyboard's text field.
///
/// @param context A pointer to the keyboard's context.
/// @return The current text field content of the keyboard. Caller must free
/// the returned pointer when it's not being used.
char* gvr_keyboard_get_text(gvr_keyboard_context* context);
/// Sets the contents of the keyboard's text field.
///
/// @param context A pointer to the keyboard's context.
/// @param edit_text The new text field content.
void gvr_keyboard_set_text(gvr_keyboard_context* context, const char* text);
/// Gets selection range of the keyboard's text field.
///
/// @param context A pointer to the keyboard's context.
/// @param start A pointer to receive the start index, must not be NULL.
/// @param start A pointer to receive the end index, must not be NULL.
void gvr_keyboard_get_selection_indices(gvr_keyboard_context* context,
size_t* start,
size_t* end);
/// Sets selection range of the keyboard's text field.
///
/// @param context A pointer to the keyboard's context.
/// @param start start index.
/// @param start end index.
void gvr_keyboard_set_selection_indices(gvr_keyboard_context* context,
size_t start,
size_t end);
/// Gets composing range of the keyboard's text field.
///
/// @param context A pointer to the keyboard's context.
/// @param start A pointer to receive the start index, must not be NULL.
/// @param start A pointer to receive the end index, must not be NULL.
void gvr_keyboard_get_composing_indices(gvr_keyboard_context* context,
size_t* start,
size_t* end);
/// Sets composing range of the keyboard's text field.
///
/// @param context A pointer to the keyboard's context.
/// @param start start index.
/// @param start end index.
void gvr_keyboard_set_composing_indices(gvr_keyboard_context* context,
size_t start,
size_t end);
/// Sets frame timestamp. This should be called once per frame.
///
/// @param context A pointer to the keyboard's context.
/// @param time The scheduled time of the next frame.
void gvr_keyboard_set_frame_time(gvr_keyboard_context* context,
const gvr_clock_time_point* time);
/// Sets world to camera matrix.
///
/// @param context A pointer to the keyboard's context.
/// @param eye_type Left or right eye variable
/// @param matrix The eye from world matrix.
void gvr_keyboard_set_eye_from_world_matrix(gvr_keyboard_context* context,
int32_t eye_type,
const gvr_mat4f* matrix);
/// Sets projection matrix.
///
/// @param context A pointer to the keyboard's context.
/// @param eye_type Left or right eye variable
/// @param projection The current camera's projection matrix
void gvr_keyboard_set_projection_matrix(gvr_keyboard_context* context,
int32_t eye_type,
const gvr_mat4f* projection);
/// Sets viewport.
///
/// @param context A pointer to the keyboard's context.
/// @param eye_type Left or right eye variable
/// @param viewport The current camera's viewport
void gvr_keyboard_set_viewport(gvr_keyboard_context* context,
int32_t eye_type,
const gvr_recti* viewport);
/// Handles the new frame. This should be called once from the GL thread on
/// every frame after the keyboard context is created and before calling
/// `gvr_keyboard_render`.
///
/// @param context A pointer to the keyboard's context.
void gvr_keyboard_advance_frame(gvr_keyboard_context* context);
/// Renders the keyboard for a given eye. This should be called from the GL
/// thread.
///
/// @param eye_type gvr eye type.
void gvr_keyboard_render(gvr_keyboard_context* context, int32_t eye_type);
/// Hides the keyboard.
///
/// @param context A pointer to the keyboard's context.
void gvr_keyboard_hide(gvr_keyboard_context* context);
/// Destroys the keyboard. Resources related to the keyboard are released.
/// The `gvr_keyboard_context` pointer is also deleted. This part is not
/// thread-safe, so you must make sure that no other thread is using
/// `gvr_keyboard_context` when this method is getting called.
///
/// @param context A pointer to the keyboard context pointer to destroy.
void gvr_keyboard_destroy(gvr_keyboard_context** context);
#ifdef __cplusplus
} // extern "C"
#endif
/// @}
#endif // VR_GVR_KEYBOARD_CAPI_INCLUDE_GVR_KEYBOARD_H_
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