blob: f1d3a5093af5882eaf534e2c01d3e5fe90140a9d [file] [log] [blame]
Dominik Laskowskicd2e9f52018-03-12 19:41:03 -07001/*
2 * Copyright (C) 2018 The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17#include <composer-vts/2.3/ComposerVts.h>
18
19#include <VtsHalHidlTargetTestBase.h>
20
21namespace android {
22namespace hardware {
23namespace graphics {
24namespace composer {
25namespace V2_3 {
26namespace vts {
27
28using V2_1::Error;
29
30Composer::Composer() : Composer(::testing::VtsHalHidlTargetTestBase::getService<IComposer>()) {}
31
32Composer::Composer(const std::string& name)
33 : Composer(::testing::VtsHalHidlTargetTestBase::getService<IComposer>(name)) {}
34
35Composer::Composer(const sp<IComposer>& composer)
36 : V2_2::vts::Composer(composer), mComposer(composer) {}
37
38std::unique_ptr<ComposerClient> Composer::createClient() {
39 std::unique_ptr<ComposerClient> client;
40 mComposer->createClient_2_3([&client](const auto& tmpError, const auto& tmpClient) {
41 ASSERT_EQ(Error::NONE, tmpError) << "failed to create client";
42 client = std::make_unique<ComposerClient>(tmpClient);
43 });
44
45 return client;
46}
47
48bool ComposerClient::getDisplayIdentificationData(Display display, uint8_t* outPort,
49 std::vector<uint8_t>* outData) {
50 bool supported = true;
51 mClient->getDisplayIdentificationData(
52 display, [&](const auto& tmpError, const auto& tmpPort, const auto& tmpData) {
53 if (tmpError == Error::UNSUPPORTED) {
54 supported = false;
55 return;
56 }
57 ASSERT_EQ(Error::NONE, tmpError) << "failed to get display identification data";
58
59 *outPort = tmpPort;
60 *outData = tmpData;
61 ASSERT_FALSE(outData->empty()) << "data is empty";
62 });
63
64 return supported;
65}
66
67} // namespace vts
68} // namespace V2_3
69} // namespace composer
70} // namespace graphics
71} // namespace hardware
72} // namespace android