This repository has been archived by the owner on Nov 1, 2020. It is now read-only.
forked from LineageOS/android_frameworks_base
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add the vr platform library, which allows client code to load the dvr api and access the getVrBoot() method. Bug: 38134403 Test: Booted a Marlin. Change-Id: I884a623ec9a297a2973f1c42c3da094c6c155630
- Loading branch information
Steven Thomas
committed
May 10, 2017
1 parent
ef57006
commit 054f235
Showing
5 changed files
with
124 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
# Copyright (C) 2017 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. | ||
LOCAL_PATH := $(call my-dir) | ||
|
||
# Library to perform dlopen on the actual shared library. | ||
include $(CLEAR_VARS) | ||
LOCAL_MODULE := libdvr_loader | ||
LOCAL_MODULE_OWNER := google | ||
LOCAL_SRC_FILES := dvr_library_loader.cpp | ||
include $(BUILD_SHARED_LIBRARY) | ||
|
||
# Java platform library for vr stuff. | ||
include $(CLEAR_VARS) | ||
LOCAL_MODULE := com.google.vr.platform | ||
LOCAL_MODULE_OWNER := google | ||
LOCAL_REQUIRED_MODULES := libdvr_loader libdvr | ||
LOCAL_SRC_FILES := $(call all-java-files-under, java) | ||
include $(BUILD_JAVA_LIBRARY) | ||
|
||
include $(CLEAR_VARS) | ||
LOCAL_MODULE := com.google.vr.platform.xml | ||
LOCAL_SRC_FILES := com.google.vr.platform.xml | ||
LOCAL_MODULE_TAGS := optional | ||
LOCAL_MODULE_CLASS := ETC | ||
LOCAL_MODULE_OWNER := google | ||
LOCAL_MODULE_PATH := $(TARGET_OUT_ETC)/permissions | ||
include $(BUILD_PREBUILT) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<!-- Copyright (C) 2017 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. | ||
--> | ||
|
||
<permissions> | ||
<library name="com.google.vr.platform" | ||
file="/system/framework/com.google.vr.platform.jar" /> | ||
</permissions> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
#include <dlfcn.h> | ||
#include <jni.h> | ||
|
||
#include <string> | ||
|
||
extern "C" { | ||
|
||
JNIEXPORT jlong JNICALL | ||
Java_com_google_vr_platform_Dvr_nativeLoadLibrary( | ||
JNIEnv* env, jclass, jstring java_library) { | ||
if (!java_library) | ||
return 0; | ||
|
||
// Convert the Java String object to a C++ null-terminated string. | ||
const char* data = env->GetStringUTFChars(java_library, NULL); | ||
size_t size = env->GetStringUTFLength(java_library); | ||
std::string library(data, size); | ||
env->ReleaseStringUTFChars(java_library, data); | ||
|
||
// Return the handle to the requested library. | ||
return reinterpret_cast<jlong>( | ||
dlopen(library.c_str(), RTLD_NOW | RTLD_LOCAL)); | ||
} | ||
|
||
} // extern "C" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
package com.google.vr.platform; | ||
|
||
import android.os.SystemProperties; | ||
|
||
/** | ||
* Class to get information about the vr device. | ||
* @hide | ||
*/ | ||
public class DeviceInfo { | ||
|
||
private static final String VR_MODE_BOOT = "ro.boot.vr"; | ||
|
||
/** | ||
* Returns true if this device boots directly in VR mode. | ||
*/ | ||
public static boolean getVrBoot() { | ||
return SystemProperties.getBoolean(VR_MODE_BOOT, false); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
package com.google.vr.platform; | ||
|
||
/** | ||
* Class to load the dvr api. | ||
* @hide | ||
*/ | ||
public class Dvr { | ||
/** | ||
* Opens a shared library containing the dvr api and returns the handle to it. | ||
* | ||
* @return A Long object describing the handle returned by dlopen. | ||
*/ | ||
public static Long loadLibrary() { | ||
// Load a thin JNI library that runs dlopen on request. | ||
System.loadLibrary("dvr_loader"); | ||
|
||
// Performs dlopen on the library and returns the handle. | ||
return nativeLoadLibrary("libdvr.so"); | ||
} | ||
|
||
private static native long nativeLoadLibrary(String library); | ||
} |