/* * Copyright (C) 2023 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. */ #define private public #include #include #include "../includes/common.h" using namespace android; int main() { constexpr int32_t val = 0; constexpr int32_t width = 100; constexpr int32_t height = 100; std::string layerName = "layerName"; constexpr int32_t createFlags = ISurfaceComposerClient::eCursorWindow | ISurfaceComposerClient::eOpaque; constexpr PixelFormat formats[] = {PIXEL_FORMAT_RGBA_1010102, PIXEL_FORMAT_RGBA_FP16, PIXEL_FORMAT_RGBA_4444}; sp surfaceComposerClient = new SurfaceComposerClient(); for (PixelFormat format : formats) { sp surfaceControl = new SurfaceControl(surfaceComposerClient, nullptr, val, layerName, width, height, format, val, createFlags); sp newSurfaceControl = new SurfaceControl(surfaceControl); FAIL_CHECK(newSurfaceControl->mWidth == width); FAIL_CHECK(newSurfaceControl->mHeight == height); FAIL_CHECK(newSurfaceControl->mCreateFlags == createFlags); if (newSurfaceControl->mFormat == format) { return EXIT_SUCCESS; } } return EXIT_VULNERABLE; }