Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit eb3e8440 authored by Jiwen Cai's avatar Jiwen Cai Committed by Android (Google) Code Review
Browse files

Merge "Basic implementation for bufferhub HIDL service"

parents 0a33671e d9f2abe6
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -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/

+12 −2
Original line number Diff line number Diff line
@@ -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"],
}
+20 −2
Original line number Diff line number Diff line
@@ -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 −0
Original line number Diff line number Diff line
//
// 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 −0
Original line number Diff line number Diff line
/*
 * 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
Loading