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

Commit ca70b7ba authored by Fan Xu's avatar Fan Xu
Browse files

Implement IBufferClient hwbinder interface

Some boiler plate code for future use.

Test: "atest BufferHubBuffer_test" passed.
Bug: b/116681016

Change-Id: I12854ac6f553777451584e86a81f2e6064a12696
parent e64d79e3
Loading
Loading
Loading
Loading
+11 −4
Original line number Diff line number Diff line
@@ -16,6 +16,7 @@

#define LOG_TAG "BufferHubBufferTest"

#include <android/frameworks/bufferhub/1.0/IBufferClient.h>
#include <android/frameworks/bufferhub/1.0/IBufferHub.h>
#include <gtest/gtest.h>
#include <hidl/ServiceManagement.h>
@@ -33,11 +34,11 @@ const int kFormat = HAL_PIXEL_FORMAT_RGBA_8888;
const int kUsage = 0;
const size_t kUserMetadataSize = 0;

} // namespace

using dvr::BufferHubDefs::IsBufferGained;
using dvr::BufferHubDefs::kFirstClientBitMask;
using dvr::BufferHubDefs::kMetadataHeaderSize;
using frameworks::bufferhub::V1_0::BufferHubStatus;
using frameworks::bufferhub::V1_0::IBufferClient;
using frameworks::bufferhub::V1_0::IBufferHub;
using hardware::hidl_handle;
using hidl::base::V1_0::IBase;
@@ -129,8 +130,14 @@ TEST_F(BufferHubBufferTest, ConnectHidlServer) {

    // 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());
    EXPECT_TRUE(bufferhub
                        ->importBuffer(handle,
                                       [](const auto& client, const auto& ret) {
                                           EXPECT_EQ(client, nullptr);
                                           EXPECT_EQ(ret, BufferHubStatus::NO_ERROR);
                                       })
                        .isOk());
}

} // namespace
} // namespace android
+1 −0
Original line number Diff line number Diff line
@@ -22,6 +22,7 @@ cc_library_shared {
        "-Wextra",
    ],
    srcs: [
        "BufferClient.cpp",
        "BufferHubService.cpp",
        "BufferNode.cpp",
    ],
+39 −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/BufferClient.h>
#include <hidl/HidlSupport.h>

namespace android {
namespace frameworks {
namespace bufferhub {
namespace V1_0 {
namespace implementation {

using hardware::hidl_handle;
using hardware::Void;

Return<void> BufferClient::duplicate(duplicate_cb _hidl_cb) {
    // TODO(b/118614157): implement token generation and registration
    _hidl_cb(/*token=*/hidl_handle(), /*status=*/BufferHubStatus::NO_ERROR);
    return Void();
}

} // namespace implementation
} // namespace V1_0
} // namespace bufferhub
} // namespace frameworks
} // namespace android
 No newline at end of file
+10 −5
Original line number Diff line number Diff line
@@ -22,16 +22,21 @@ namespace bufferhub {
namespace V1_0 {
namespace implementation {

using ::android::status_t;
using ::android::hardware::Void;
using hardware::Void;

Return<void> BufferHubService::allocateBuffer(const HardwareBufferDescription& /*description*/,
                                              allocateBuffer_cb /*hidl_cb*/) {
                                              const uint32_t /*userMetadataSize*/,
                                              allocateBuffer_cb _hidl_cb) {
    // TODO(b/118614333): implement buffer allocation
    _hidl_cb(/*bufferClient=*/nullptr, /*status=*/BufferHubStatus::NO_ERROR);
    return Void();
}

Return<sp<IBase>> BufferHubService::importBuffer(const hidl_handle& /*nativeHandle*/) {
    return nullptr;
Return<void> BufferHubService::importBuffer(const hidl_handle& /*nativeHandle*/,
                                            importBuffer_cb _hidl_cb) {
    // TODO(b/118614157): implement buffer import
    _hidl_cb(/*bufferClient=*/nullptr, /*status=*/BufferHubStatus::NO_ERROR);
    return Void();
}

} // namespace implementation
+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.
 */

#ifndef ANDROID_FRAMEWORKS_BUFFERHUB_V1_0_BUFFER_CLIENT_H
#define ANDROID_FRAMEWORKS_BUFFERHUB_V1_0_BUFFER_CLIENT_H

#include <android/frameworks/bufferhub/1.0/IBufferClient.h>

namespace android {
namespace frameworks {
namespace bufferhub {
namespace V1_0 {
namespace implementation {

using hardware::Return;

class BufferClient : public IBufferClient {
public:
    Return<void> duplicate(duplicate_cb _hidl_cb) override;
};

} // namespace implementation
} // namespace V1_0
} // namespace bufferhub
} // namespace frameworks
} // namespace android

#endif
 No newline at end of file
Loading