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

Commit 6e822dfb authored by Ram Indani's avatar Ram Indani Committed by ramindani
Browse files

Add invalid config const to the AIDL interface.

Test: atest VtsHalGraphicsComposer3_TargetTest but tests don't just work yet. as we don't have service implementation.
BUG: 202053621
Change-Id: I96fc1f6bcb4ce4907342b3a73994f80b9347ea9f
parents 657d9db9 1cb794eb
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -85,4 +85,5 @@ interface IComposerClient {
  const int EX_UNSUPPORTED = 8;
  const int EX_SEAMLESS_NOT_ALLOWED = 9;
  const int EX_SEAMLESS_NOT_POSSIBLE = 10;
  const int INVALID_CONFIGURATION = 2147483647;
}
+7 −0
Original line number Diff line number Diff line
@@ -89,6 +89,12 @@ interface IComposerClient {
     */
    const int EX_SEAMLESS_NOT_POSSIBLE = 10;

    /**
     * Integer.MAX_VALUE is reserved for the invalid configuration.
     * This should not be returned as a valid configuration.
     */
    const int INVALID_CONFIGURATION = 0x7fffffff;

    /**
     * Creates a new layer on the given display.
     *
@@ -282,6 +288,7 @@ interface IComposerClient {
    /**
     * Returns handles for all of the valid display configurations on this
     * display.
     * This should never return INVALID_CONFIGURATION as a valid value.
     *
     * @param display is the display to query.
     *
+5 −1
Original line number Diff line number Diff line
@@ -29,7 +29,10 @@ cc_test {
        "VtsHalTargetTestDefaults",
        "use_libaidlvintf_gtest_helper_static",
    ],
    srcs: ["VtsHalGraphicsComposer3_TargetTest.cpp"],
    srcs: [
        "VtsHalGraphicsComposer3_TargetTest.cpp",
        "composer-vts/GraphicsComposerCallback.cpp",
    ],

    // TODO(b/64437680): Assume these libs are always available on the device.
    shared_libs: [
@@ -42,6 +45,7 @@ cc_test {
        "android.hardware.graphics.common@1.2",
        "android.hardware.common-V2-ndk",
        "android.hardware.common.fmq-V1-ndk",
        "android.hardware.graphics.composer@3-vts",
    ],

    test_suites: [
+50 −6
Original line number Diff line number Diff line
@@ -6,22 +6,28 @@
#include <android/binder_manager.h>
#include <android/binder_process.h>
#include <binder/ProcessState.h>
#include <composer-vts/include/GraphicsComposerCallback.h>
#include <gtest/gtest.h>
#include <string>
#include <thread>

#pragma push_macro("LOG_TAG")
#undef LOG_TAG
#define LOG_TAG "VtsHalGraphicsComposer3_TargetTest"

typedef int32_t Config;

namespace aidl::android::hardware::graphics::composer3::vts {
namespace {

using namespace std::chrono_literals;

class VtsDisplay {
  public:
    VtsDisplay(uint64_t displayId, int32_t displayWidth, int32_t displayHeight)
    VtsDisplay(int64_t displayId, int32_t displayWidth, int32_t displayHeight)
        : mDisplayId(displayId), mDisplayWidth(displayWidth), mDisplayHeight(displayHeight) {}

    uint64_t get() const { return mDisplayId; }
    int64_t get() const { return mDisplayId; }

    void setDimensions(int32_t displayWidth, int32_t displayHeight) {
        mDisplayWidth = displayWidth;
@@ -29,7 +35,7 @@ class VtsDisplay {
    }

  private:
    const uint64_t mDisplayId;
    const int64_t mDisplayId;
    int32_t mDisplayWidth;
    int32_t mDisplayHeight;
};
@@ -44,6 +50,12 @@ class GraphicsComposerAidlTest : public ::testing::TestWithParam<std::string> {
        ASSERT_NE(mComposer, nullptr);
        ASSERT_NO_FATAL_FAILURE(mComposer->createClient(&mComposerClient));
        mInvalidDisplayId = GetInvalidDisplayId();

        mComposerCallback = ::ndk::SharedRefBase::make<GraphicsComposerCallback>();
        EXPECT_TRUE(mComposerClient->registerCallback(mComposerCallback).isOk());

        // assume the first displays are built-in and are never removed
        mDisplays = waitForDisplays();
    }

    // returns an invalid display id (one that has not been registered to a
@@ -62,11 +74,43 @@ class GraphicsComposerAidlTest : public ::testing::TestWithParam<std::string> {
        return 0;
    }

    std::vector<VtsDisplay> waitForDisplays() {
        while (true) {
            // Sleep for a small period of time to allow all built-in displays
            // to post hotplug events
            std::this_thread::sleep_for(5ms);
            std::vector<int64_t> displays = mComposerCallback->getDisplays();
            if (displays.empty()) {
                continue;
            }

            std::vector<VtsDisplay> vtsDisplays;
            vtsDisplays.reserve(displays.size());
            for (int64_t display : displays) {
                Config activeConfig;
                EXPECT_TRUE(mComposerClient->getActiveConfig(display, &activeConfig).isOk());
                int32_t displayWidth;
                EXPECT_TRUE(mComposerClient
                                    ->getDisplayAttribute(display, activeConfig,
                                                          DisplayAttribute::WIDTH, &displayWidth)
                                    .isOk());
                int32_t displayHeight;
                EXPECT_TRUE(mComposerClient
                                    ->getDisplayAttribute(display, activeConfig,
                                                          DisplayAttribute::HEIGHT, &displayHeight)
                                    .isOk());
                vtsDisplays.emplace_back(VtsDisplay{display, displayWidth, displayHeight});
            }

            return vtsDisplays;
        }
    }

    std::shared_ptr<IComposer> mComposer;
    std::shared_ptr<IComposerClient> mComposerClient;
    uint64_t mInvalidDisplayId;
    std::vector<VtsDisplay>
            mDisplays;  // TODO(b/202401906) populate all the displays available for test.
    int64_t mInvalidDisplayId;
    std::vector<VtsDisplay> mDisplays;
    std::shared_ptr<GraphicsComposerCallback> mComposerCallback;
};

TEST_P(GraphicsComposerAidlTest, getDisplayCapabilitiesBadDisplay) {
+44 −0
Original line number Diff line number Diff line
/**
 * Copyright (c) 2021, 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 {
    // See: http://go/android-license-faq
    // A large-scale-change added 'default_applicable_licenses' to import
    // all of the 'license_kinds' from "hardware_interfaces_license"
    // to get the below license kinds:
    //   SPDX-license-identifier-Apache-2.0
    default_applicable_licenses: ["hardware_interfaces_license"],
}

cc_library_static {
    name: "android.hardware.graphics.composer@3-vts",
    defaults: ["hidl_defaults"],
    srcs: [
        "GraphicsComposerCallback.cpp",
    ],
    static_libs: [
        "android.hardware.graphics.composer3-V1-ndk",
        "android.hardware.graphics.common-V3-ndk",
        "libgtest",
        "libbase",
    ],
    cflags: [
        "-O0",
        "-g",
        "-DLOG_TAG=\"ComposerVts\"",
    ],
    export_include_dirs: ["include"],
}
Loading