Basic implementation for bufferhub HIDL service
Bug: 118124442 Test: device can boot with android.frameworks.bufferhub@1.0-service running Test: BufferHubBuffer_test Change-Id: I6d1013d9be8268e3776f8fdbdd2eb79e3d73a74e
This commit is contained in:
parent
27631c9c42
commit
d9f2abe6e2
9 changed files with 237 additions and 4 deletions
|
@ -9,6 +9,7 @@ clang_format = --commit ${PREUPLOAD_COMMIT} --style file --extensions c,h,cc,cpp
|
|||
libs/renderengine/
|
||||
libs/ui/
|
||||
libs/vr/
|
||||
services/bufferhub/
|
||||
services/surfaceflinger/
|
||||
services/vr/
|
||||
|
||||
|
|
|
@ -37,8 +37,18 @@ cc_test {
|
|||
|
||||
cc_test {
|
||||
name: "BufferHubBuffer_test",
|
||||
header_libs: ["libbufferhub_headers", "libdvr_headers"],
|
||||
shared_libs: ["libpdx_default_transport", "libui", "libutils"],
|
||||
header_libs: [
|
||||
"libbufferhub_headers",
|
||||
"libdvr_headers"
|
||||
],
|
||||
shared_libs: [
|
||||
"android.frameworks.bufferhub@1.0",
|
||||
"libhidlbase",
|
||||
"libhwbinder",
|
||||
"libpdx_default_transport",
|
||||
"libui",
|
||||
"libutils"
|
||||
],
|
||||
srcs: ["BufferHubBuffer_test.cpp"],
|
||||
cflags: ["-Wall", "-Werror"],
|
||||
}
|
||||
|
|
|
@ -16,7 +16,10 @@
|
|||
|
||||
#define LOG_TAG "BufferHubBufferTest"
|
||||
|
||||
#include <android/frameworks/bufferhub/1.0/IBufferHub.h>
|
||||
#include <gtest/gtest.h>
|
||||
#include <hidl/ServiceManagement.h>
|
||||
#include <hwbinder/IPCThreadState.h>
|
||||
#include <ui/BufferHubBuffer.h>
|
||||
|
||||
namespace android {
|
||||
|
@ -32,13 +35,18 @@ const size_t kUserMetadataSize = 0;
|
|||
|
||||
} // namespace
|
||||
|
||||
using BufferHubBufferTest = ::testing::Test;
|
||||
|
||||
using dvr::BufferHubDefs::IsBufferGained;
|
||||
using dvr::BufferHubDefs::kMetadataHeaderSize;
|
||||
using dvr::BufferHubDefs::kProducerStateBit;
|
||||
using frameworks::bufferhub::V1_0::IBufferHub;
|
||||
using hardware::hidl_handle;
|
||||
using hidl::base::V1_0::IBase;
|
||||
using pdx::LocalChannelHandle;
|
||||
|
||||
class BufferHubBufferTest : public ::testing::Test {
|
||||
void SetUp() override { android::hardware::ProcessState::self()->startThreadPool(); }
|
||||
};
|
||||
|
||||
TEST_F(BufferHubBufferTest, CreateBufferHubBufferFails) {
|
||||
// Buffer Creation will fail: BLOB format requires height to be 1.
|
||||
auto b1 = BufferHubBuffer::Create(kWidth, /*height=*/2, kLayerCount,
|
||||
|
@ -115,4 +123,14 @@ TEST_F(BufferHubBufferTest, DuplicateBufferHubBuffer) {
|
|||
return;
|
||||
}
|
||||
|
||||
TEST_F(BufferHubBufferTest, ConnectHidlServer) {
|
||||
sp<IBufferHub> bufferhub = IBufferHub::getService();
|
||||
ASSERT_NE(nullptr, bufferhub.get());
|
||||
|
||||
// TODO(b/116681016): Fill in real test once the interface gets implemented..
|
||||
hidl_handle handle;
|
||||
sp<IBase> interface = bufferhub->importBuffer(handle);
|
||||
EXPECT_EQ(nullptr, interface.get());
|
||||
}
|
||||
|
||||
} // namespace android
|
||||
|
|
61
services/bufferhub/Android.bp
Normal file
61
services/bufferhub/Android.bp
Normal file
|
@ -0,0 +1,61 @@
|
|||
//
|
||||
// Copyright (C) 2018 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_library_shared {
|
||||
name: "libbufferhubservice",
|
||||
cflags: [
|
||||
"-Wall",
|
||||
"-Werror",
|
||||
"-Wextra",
|
||||
],
|
||||
srcs: [
|
||||
"BufferHubService.cpp",
|
||||
],
|
||||
shared_libs: [
|
||||
"android.frameworks.bufferhub@1.0",
|
||||
"libhidlbase",
|
||||
"libhidltransport",
|
||||
"libhwbinder",
|
||||
"liblog",
|
||||
"libutils",
|
||||
],
|
||||
export_include_dirs: [
|
||||
"include"
|
||||
],
|
||||
}
|
||||
|
||||
cc_binary {
|
||||
name: "android.frameworks.bufferhub@1.0-service",
|
||||
relative_install_path: "hw",
|
||||
srcs: [
|
||||
"main_bufferhub.cpp"
|
||||
],
|
||||
shared_libs: [
|
||||
"android.frameworks.bufferhub@1.0",
|
||||
"libbufferhubservice",
|
||||
"libhidltransport",
|
||||
"libhwbinder",
|
||||
"liblog",
|
||||
"libutils",
|
||||
],
|
||||
cflags: [
|
||||
"-Wall",
|
||||
"-Werror",
|
||||
"-Wextra",
|
||||
],
|
||||
init_rc: ["android.frameworks.bufferhub@1.0-service.rc"],
|
||||
vintf_fragments: ["android.frameworks.bufferhub@1.0-service.xml"],
|
||||
}
|
41
services/bufferhub/BufferHubService.cpp
Normal file
41
services/bufferhub/BufferHubService.cpp
Normal file
|
@ -0,0 +1,41 @@
|
|||
/*
|
||||
* Copyright (C) 2018 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.
|
||||
*/
|
||||
|
||||
#include <bufferhub/BufferHubService.h>
|
||||
|
||||
namespace android {
|
||||
namespace frameworks {
|
||||
namespace bufferhub {
|
||||
namespace V1_0 {
|
||||
namespace implementation {
|
||||
|
||||
using ::android::status_t;
|
||||
using ::android::hardware::Void;
|
||||
|
||||
Return<void> BufferHubService::allocateBuffer(const HardwareBufferDescription& /*description*/,
|
||||
allocateBuffer_cb /*hidl_cb*/) {
|
||||
return Void();
|
||||
}
|
||||
|
||||
Return<sp<IBase>> BufferHubService::importBuffer(const hidl_handle& /*nativeHandle*/) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
} // namespace implementation
|
||||
} // namespace V1_0
|
||||
} // namespace bufferhub
|
||||
} // namespace frameworks
|
||||
} // namespace android
|
|
@ -0,0 +1,6 @@
|
|||
service system_bufferhub /system/bin/hw/android.frameworks.bufferhub@1.0-service
|
||||
class hal animation
|
||||
user system
|
||||
group system graphics
|
||||
onrestart restart surfaceflinger
|
||||
writepid /dev/cpuset/system-background/tasks
|
|
@ -0,0 +1,11 @@
|
|||
<manifest version="1.0" type="framework">
|
||||
<hal>
|
||||
<name>android.frameworks.bufferhub</name>
|
||||
<transport>hwbinder</transport>
|
||||
<version>1.0</version>
|
||||
<interface>
|
||||
<name>IBufferHub</name>
|
||||
<instance>default</instance>
|
||||
</interface>
|
||||
</hal>
|
||||
</manifest>
|
48
services/bufferhub/include/bufferhub/BufferHubService.h
Normal file
48
services/bufferhub/include/bufferhub/BufferHubService.h
Normal file
|
@ -0,0 +1,48 @@
|
|||
/*
|
||||
* Copyright (C) 2018 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_FRAMEWORKS_BUFFERHUB_V1_0_BUFFER_HUB_SERVICE_H
|
||||
#define ANDROID_FRAMEWORKS_BUFFERHUB_V1_0_BUFFER_HUB_SERVICE_H
|
||||
|
||||
#include <android/frameworks/bufferhub/1.0/IBufferHub.h>
|
||||
#include <android/hardware/graphics/common/1.2/types.h>
|
||||
|
||||
namespace android {
|
||||
namespace frameworks {
|
||||
namespace bufferhub {
|
||||
namespace V1_0 {
|
||||
namespace implementation {
|
||||
|
||||
using ::android::sp;
|
||||
using ::android::hardware::hidl_handle;
|
||||
using ::android::hardware::Return;
|
||||
using ::android::hardware::graphics::common::V1_2::HardwareBufferDescription;
|
||||
using ::android::hidl::base::V1_0::IBase;
|
||||
|
||||
class BufferHubService : public IBufferHub {
|
||||
public:
|
||||
Return<void> allocateBuffer(const HardwareBufferDescription& /*description*/,
|
||||
allocateBuffer_cb /*hidl_cb*/) override;
|
||||
Return<sp<IBase>> importBuffer(const hidl_handle& /*nativeHandle*/) override;
|
||||
};
|
||||
|
||||
} // namespace implementation
|
||||
} // namespace V1_0
|
||||
} // namespace bufferhub
|
||||
} // namespace frameworks
|
||||
} // namespace android
|
||||
|
||||
#endif // ANDROID_FRAMEWORKS_BUFFERHUB_V1_0_BUFFER_HUB_SERVICE_H
|
37
services/bufferhub/main_bufferhub.cpp
Normal file
37
services/bufferhub/main_bufferhub.cpp
Normal file
|
@ -0,0 +1,37 @@
|
|||
/*
|
||||
* Copyright (C) 2018 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.
|
||||
*/
|
||||
|
||||
#include <bufferhub/BufferHubService.h>
|
||||
#include <hidl/HidlTransportSupport.h>
|
||||
#include <hwbinder/IPCThreadState.h>
|
||||
#include <log/log.h>
|
||||
|
||||
using android::sp;
|
||||
using android::frameworks::bufferhub::V1_0::IBufferHub;
|
||||
using android::frameworks::bufferhub::V1_0::implementation::BufferHubService;
|
||||
|
||||
int main(int /*argc*/, char** /*argv*/) {
|
||||
ALOGI("Bootstrap bufferhub HIDL service.");
|
||||
|
||||
android::hardware::configureRpcThreadpool(/*numThreads=*/1, /*willJoin=*/true);
|
||||
|
||||
sp<IBufferHub> service = new BufferHubService();
|
||||
LOG_ALWAYS_FATAL_IF(service->registerAsService() != android::OK, "Failed to register service");
|
||||
|
||||
android::hardware::joinRpcThreadpool();
|
||||
|
||||
return 0;
|
||||
}
|
Loading…
Reference in a new issue