upload android base code part4
This commit is contained in:
parent
b9e30e05b1
commit
78ea2404cd
23455 changed files with 5250148 additions and 0 deletions
62
android/hardware/interfaces/vr/1.0/Android.bp
Normal file
62
android/hardware/interfaces/vr/1.0/Android.bp
Normal file
|
@ -0,0 +1,62 @@
|
|||
// This file is autogenerated by hidl-gen. Do not edit manually.
|
||||
|
||||
filegroup {
|
||||
name: "android.hardware.vr@1.0_hal",
|
||||
srcs: [
|
||||
"IVr.hal",
|
||||
],
|
||||
}
|
||||
|
||||
genrule {
|
||||
name: "android.hardware.vr@1.0_genc++",
|
||||
tools: ["hidl-gen"],
|
||||
cmd: "$(location hidl-gen) -o $(genDir) -Lc++-sources -randroid.hardware:hardware/interfaces -randroid.hidl:system/libhidl/transport android.hardware.vr@1.0",
|
||||
srcs: [
|
||||
":android.hardware.vr@1.0_hal",
|
||||
],
|
||||
out: [
|
||||
"android/hardware/vr/1.0/VrAll.cpp",
|
||||
],
|
||||
}
|
||||
|
||||
genrule {
|
||||
name: "android.hardware.vr@1.0_genc++_headers",
|
||||
tools: ["hidl-gen"],
|
||||
cmd: "$(location hidl-gen) -o $(genDir) -Lc++-headers -randroid.hardware:hardware/interfaces -randroid.hidl:system/libhidl/transport android.hardware.vr@1.0",
|
||||
srcs: [
|
||||
":android.hardware.vr@1.0_hal",
|
||||
],
|
||||
out: [
|
||||
"android/hardware/vr/1.0/IVr.h",
|
||||
"android/hardware/vr/1.0/IHwVr.h",
|
||||
"android/hardware/vr/1.0/BnHwVr.h",
|
||||
"android/hardware/vr/1.0/BpHwVr.h",
|
||||
"android/hardware/vr/1.0/BsVr.h",
|
||||
],
|
||||
}
|
||||
|
||||
cc_library {
|
||||
name: "android.hardware.vr@1.0",
|
||||
defaults: ["hidl-module-defaults"],
|
||||
generated_sources: ["android.hardware.vr@1.0_genc++"],
|
||||
generated_headers: ["android.hardware.vr@1.0_genc++_headers"],
|
||||
export_generated_headers: ["android.hardware.vr@1.0_genc++_headers"],
|
||||
vendor_available: true,
|
||||
vndk: {
|
||||
enabled: true,
|
||||
},
|
||||
shared_libs: [
|
||||
"libhidlbase",
|
||||
"libhidltransport",
|
||||
"libhwbinder",
|
||||
"liblog",
|
||||
"libutils",
|
||||
"libcutils",
|
||||
],
|
||||
export_shared_lib_headers: [
|
||||
"libhidlbase",
|
||||
"libhidltransport",
|
||||
"libhwbinder",
|
||||
"libutils",
|
||||
],
|
||||
}
|
76
android/hardware/interfaces/vr/1.0/Android.mk
Normal file
76
android/hardware/interfaces/vr/1.0/Android.mk
Normal file
|
@ -0,0 +1,76 @@
|
|||
# This file is autogenerated by hidl-gen. Do not edit manually.
|
||||
|
||||
LOCAL_PATH := $(call my-dir)
|
||||
|
||||
################################################################################
|
||||
|
||||
include $(CLEAR_VARS)
|
||||
LOCAL_MODULE := android.hardware.vr-V1.0-java
|
||||
LOCAL_MODULE_CLASS := JAVA_LIBRARIES
|
||||
|
||||
intermediates := $(call local-generated-sources-dir, COMMON)
|
||||
|
||||
HIDL := $(HOST_OUT_EXECUTABLES)/hidl-gen$(HOST_EXECUTABLE_SUFFIX)
|
||||
|
||||
LOCAL_JAVA_LIBRARIES := \
|
||||
android.hidl.base-V1.0-java \
|
||||
|
||||
|
||||
#
|
||||
# Build IVr.hal
|
||||
#
|
||||
GEN := $(intermediates)/android/hardware/vr/V1_0/IVr.java
|
||||
$(GEN): $(HIDL)
|
||||
$(GEN): PRIVATE_HIDL := $(HIDL)
|
||||
$(GEN): PRIVATE_DEPS := $(LOCAL_PATH)/IVr.hal
|
||||
$(GEN): PRIVATE_OUTPUT_DIR := $(intermediates)
|
||||
$(GEN): PRIVATE_CUSTOM_TOOL = \
|
||||
$(PRIVATE_HIDL) -o $(PRIVATE_OUTPUT_DIR) \
|
||||
-Ljava \
|
||||
-randroid.hardware:hardware/interfaces \
|
||||
-randroid.hidl:system/libhidl/transport \
|
||||
android.hardware.vr@1.0::IVr
|
||||
|
||||
$(GEN): $(LOCAL_PATH)/IVr.hal
|
||||
$(transform-generated-source)
|
||||
LOCAL_GENERATED_SOURCES += $(GEN)
|
||||
include $(BUILD_JAVA_LIBRARY)
|
||||
|
||||
|
||||
################################################################################
|
||||
|
||||
include $(CLEAR_VARS)
|
||||
LOCAL_MODULE := android.hardware.vr-V1.0-java-static
|
||||
LOCAL_MODULE_CLASS := JAVA_LIBRARIES
|
||||
|
||||
intermediates := $(call local-generated-sources-dir, COMMON)
|
||||
|
||||
HIDL := $(HOST_OUT_EXECUTABLES)/hidl-gen$(HOST_EXECUTABLE_SUFFIX)
|
||||
|
||||
LOCAL_STATIC_JAVA_LIBRARIES := \
|
||||
android.hidl.base-V1.0-java-static \
|
||||
|
||||
|
||||
#
|
||||
# Build IVr.hal
|
||||
#
|
||||
GEN := $(intermediates)/android/hardware/vr/V1_0/IVr.java
|
||||
$(GEN): $(HIDL)
|
||||
$(GEN): PRIVATE_HIDL := $(HIDL)
|
||||
$(GEN): PRIVATE_DEPS := $(LOCAL_PATH)/IVr.hal
|
||||
$(GEN): PRIVATE_OUTPUT_DIR := $(intermediates)
|
||||
$(GEN): PRIVATE_CUSTOM_TOOL = \
|
||||
$(PRIVATE_HIDL) -o $(PRIVATE_OUTPUT_DIR) \
|
||||
-Ljava \
|
||||
-randroid.hardware:hardware/interfaces \
|
||||
-randroid.hidl:system/libhidl/transport \
|
||||
android.hardware.vr@1.0::IVr
|
||||
|
||||
$(GEN): $(LOCAL_PATH)/IVr.hal
|
||||
$(transform-generated-source)
|
||||
LOCAL_GENERATED_SOURCES += $(GEN)
|
||||
include $(BUILD_STATIC_JAVA_LIBRARY)
|
||||
|
||||
|
||||
|
||||
include $(call all-makefiles-under,$(LOCAL_PATH))
|
41
android/hardware/interfaces/vr/1.0/IVr.hal
Normal file
41
android/hardware/interfaces/vr/1.0/IVr.hal
Normal file
|
@ -0,0 +1,41 @@
|
|||
/*
|
||||
* Copyright (C) 2016 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.
|
||||
*/
|
||||
|
||||
package android.hardware.vr@1.0;
|
||||
|
||||
interface IVr {
|
||||
/**
|
||||
* Convenience method to set up any state needed at runtime startup. This is
|
||||
* called once from the VrManagerService during its boot phase.
|
||||
*/
|
||||
@callflow(next={"*"})
|
||||
@entry
|
||||
@exit
|
||||
init();
|
||||
|
||||
/**
|
||||
* Set the VR mode state. Possible states of the enabled parameter are:
|
||||
* false - VR mode is disabled, turn off all VR-specific settings.
|
||||
* true - VR mode is enabled, turn on all VR-specific settings.
|
||||
*
|
||||
* This must be called whenever the the Android system enters or leaves VR
|
||||
* mode. This will typically occur when the user switches to or from a VR
|
||||
* application that is doing stereoscopic rendering.
|
||||
*/
|
||||
@callflow(next={"*"})
|
||||
@exit
|
||||
setVrMode(bool enabled);
|
||||
};
|
36
android/hardware/interfaces/vr/1.0/default/Android.bp
Normal file
36
android/hardware/interfaces/vr/1.0/default/Android.bp
Normal file
|
@ -0,0 +1,36 @@
|
|||
cc_library_shared {
|
||||
name: "android.hardware.vr@1.0-impl",
|
||||
defaults: ["hidl_defaults"],
|
||||
proprietary: true,
|
||||
relative_install_path: "hw",
|
||||
srcs: ["Vr.cpp"],
|
||||
shared_libs: [
|
||||
"liblog",
|
||||
"libcutils",
|
||||
"libhardware",
|
||||
"libbase",
|
||||
"libcutils",
|
||||
"libutils",
|
||||
"libhidlbase",
|
||||
"libhidltransport",
|
||||
"android.hardware.vr@1.0",
|
||||
],
|
||||
}
|
||||
|
||||
cc_binary {
|
||||
relative_install_path: "hw",
|
||||
defaults: ["hidl_defaults"],
|
||||
proprietary: true,
|
||||
name: "android.hardware.vr@1.0-service",
|
||||
init_rc: ["android.hardware.vr@1.0-service.rc"],
|
||||
srcs: ["service.cpp"],
|
||||
shared_libs: [
|
||||
"liblog",
|
||||
"libdl",
|
||||
"libutils",
|
||||
"libhardware",
|
||||
"libhidlbase",
|
||||
"libhidltransport",
|
||||
"android.hardware.vr@1.0",
|
||||
],
|
||||
}
|
62
android/hardware/interfaces/vr/1.0/default/Vr.cpp
Normal file
62
android/hardware/interfaces/vr/1.0/default/Vr.cpp
Normal file
|
@ -0,0 +1,62 @@
|
|||
/*
|
||||
* Copyright (C) 2016 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.
|
||||
*/
|
||||
|
||||
#define LOG_TAG "VrService"
|
||||
|
||||
#include <log/log.h>
|
||||
|
||||
#include <hardware/hardware.h>
|
||||
#include <hardware/vr.h>
|
||||
|
||||
#include "Vr.h"
|
||||
|
||||
namespace android {
|
||||
namespace hardware {
|
||||
namespace vr {
|
||||
namespace V1_0 {
|
||||
namespace implementation {
|
||||
|
||||
Vr::Vr(vr_module_t *device) : mDevice(device) {}
|
||||
|
||||
// Methods from ::android::hardware::vr::V1_0::IVr follow.
|
||||
Return<void> Vr::init() {
|
||||
mDevice->init(mDevice);
|
||||
return Void();
|
||||
}
|
||||
|
||||
Return<void> Vr::setVrMode(bool enabled) {
|
||||
mDevice->set_vr_mode(mDevice, enabled);
|
||||
return Void();
|
||||
}
|
||||
|
||||
IVr* HIDL_FETCH_IVr(const char * /*name*/) {
|
||||
const hw_module_t *hw_module = NULL;
|
||||
|
||||
int ret = hw_get_module(VR_HARDWARE_MODULE_ID, &hw_module);
|
||||
if (ret == 0) {
|
||||
return new Vr(reinterpret_cast<vr_module_t*>(
|
||||
const_cast<hw_module_t*>(hw_module)));
|
||||
} else {
|
||||
ALOGE("hw_get_module %s failed: %d", VR_HARDWARE_MODULE_ID, ret);
|
||||
return nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace implementation
|
||||
} // namespace V1_0
|
||||
} // namespace vr
|
||||
} // namespace hardware
|
||||
} // namespace android
|
51
android/hardware/interfaces/vr/1.0/default/Vr.h
Normal file
51
android/hardware/interfaces/vr/1.0/default/Vr.h
Normal file
|
@ -0,0 +1,51 @@
|
|||
/*
|
||||
* Copyright (C) 2016 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.
|
||||
*/
|
||||
#ifndef ANDROID_HARDWARE_VR_V1_0_VR_H
|
||||
#define ANDROID_HARDWARE_VR_V1_0_VR_H
|
||||
|
||||
#include <android/hardware/vr/1.0/IVr.h>
|
||||
#include <hardware/vr.h>
|
||||
#include <hidl/MQDescriptor.h>
|
||||
|
||||
namespace android {
|
||||
namespace hardware {
|
||||
namespace vr {
|
||||
namespace V1_0 {
|
||||
namespace implementation {
|
||||
|
||||
using ::android::hardware::vr::V1_0::IVr;
|
||||
using ::android::hardware::Return;
|
||||
|
||||
struct Vr : public IVr {
|
||||
Vr(vr_module_t *device);
|
||||
|
||||
// Methods from ::android::hardware::vr::V1_0::IVr follow.
|
||||
Return<void> init() override;
|
||||
Return<void> setVrMode(bool enabled) override;
|
||||
|
||||
private:
|
||||
vr_module_t *mDevice;
|
||||
};
|
||||
|
||||
extern "C" IVr* HIDL_FETCH_IVr(const char* name);
|
||||
|
||||
} // namespace implementation
|
||||
} // namespace V1_0
|
||||
} // namespace vr
|
||||
} // namespace hardware
|
||||
} // namespace android
|
||||
|
||||
#endif // ANDROID_HARDWARE_VR_V1_0_VR_H
|
|
@ -0,0 +1,4 @@
|
|||
service vr-1-0 /vendor/bin/hw/android.hardware.vr@1.0-service
|
||||
class hal
|
||||
user system
|
||||
group system
|
27
android/hardware/interfaces/vr/1.0/default/service.cpp
Normal file
27
android/hardware/interfaces/vr/1.0/default/service.cpp
Normal file
|
@ -0,0 +1,27 @@
|
|||
/*
|
||||
* Copyright (C) 2016 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.
|
||||
*/
|
||||
#define LOG_TAG "android.hardware.vr@1.0-service"
|
||||
|
||||
#include <android/hardware/vr/1.0/IVr.h>
|
||||
#include <hidl/LegacySupport.h>
|
||||
|
||||
// Generated HIDL files
|
||||
using android::hardware::vr::V1_0::IVr;
|
||||
using android::hardware::defaultPassthroughServiceImplementation;
|
||||
|
||||
int main() {
|
||||
return defaultPassthroughServiceImplementation<IVr>();
|
||||
}
|
22
android/hardware/interfaces/vr/1.0/vts/functional/Android.bp
Normal file
22
android/hardware/interfaces/vr/1.0/vts/functional/Android.bp
Normal file
|
@ -0,0 +1,22 @@
|
|||
//
|
||||
// Copyright (C) 2016 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.
|
||||
//
|
||||
|
||||
cc_test {
|
||||
name: "VtsHalVrV1_0TargetTest",
|
||||
defaults: ["VtsHalTargetTestDefaults"],
|
||||
srcs: ["VtsHalVrV1_0TargetTest.cpp"],
|
||||
static_libs: ["android.hardware.vr@1.0"],
|
||||
}
|
|
@ -0,0 +1,80 @@
|
|||
/*
|
||||
* Copyright (C) 2016 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.
|
||||
*/
|
||||
|
||||
#define LOG_TAG "vr_hidl_hal_test"
|
||||
#include <VtsHalHidlTargetTestBase.h>
|
||||
#include <android-base/logging.h>
|
||||
#include <android/hardware/vr/1.0/IVr.h>
|
||||
#include <hardware/vr.h>
|
||||
#include <log/log.h>
|
||||
|
||||
using ::android::hardware::vr::V1_0::IVr;
|
||||
using ::android::hardware::Return;
|
||||
using ::android::hardware::Void;
|
||||
using ::android::sp;
|
||||
|
||||
// The main test class for VR HIDL HAL.
|
||||
class VrHidlTest : public ::testing::VtsHalHidlTargetTestBase {
|
||||
public:
|
||||
void SetUp() override {
|
||||
vr = ::testing::VtsHalHidlTargetTestBase::getService<IVr>();
|
||||
ASSERT_NE(vr, nullptr);
|
||||
}
|
||||
|
||||
void TearDown() override {}
|
||||
|
||||
sp<IVr> vr;
|
||||
};
|
||||
|
||||
|
||||
// A class for test environment setup (kept since this file is a template).
|
||||
class VrHidlEnvironment : public ::testing::Environment {
|
||||
public:
|
||||
void SetUp() {}
|
||||
void TearDown() {}
|
||||
|
||||
private:
|
||||
};
|
||||
|
||||
// Sanity check that Vr::init does not crash.
|
||||
TEST_F(VrHidlTest, Init) {
|
||||
EXPECT_TRUE(vr->init().isOk());
|
||||
}
|
||||
|
||||
// Sanity check Vr::setVrMode is able to enable and disable VR mode.
|
||||
TEST_F(VrHidlTest, SetVrMode) {
|
||||
EXPECT_TRUE(vr->init().isOk());
|
||||
EXPECT_TRUE(vr->setVrMode(true).isOk());
|
||||
EXPECT_TRUE(vr->setVrMode(false).isOk());
|
||||
}
|
||||
|
||||
// Sanity check that Vr::init and Vr::setVrMode can be used in any order.
|
||||
TEST_F(VrHidlTest, ReInit) {
|
||||
EXPECT_TRUE(vr->init().isOk());
|
||||
EXPECT_TRUE(vr->setVrMode(true).isOk());
|
||||
EXPECT_TRUE(vr->init().isOk());
|
||||
EXPECT_TRUE(vr->setVrMode(false).isOk());
|
||||
EXPECT_TRUE(vr->init().isOk());
|
||||
EXPECT_TRUE(vr->setVrMode(false).isOk());
|
||||
}
|
||||
|
||||
int main(int argc, char **argv) {
|
||||
::testing::AddGlobalTestEnvironment(new VrHidlEnvironment);
|
||||
::testing::InitGoogleTest(&argc, argv);
|
||||
int status = RUN_ALL_TESTS();
|
||||
ALOGI("Test result = %d", status);
|
||||
return status;
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue