Loading libs/ui/DebugUtils.cpp +36 −11 Original line number Diff line number Diff line Loading @@ -15,12 +15,14 @@ */ #include <ui/DebugUtils.h> #include <ui/DeviceProductInfo.h> #include <ui/PixelFormat.h> #include <ui/Rect.h> #include <android-base/stringprintf.h> #include <string> using android::base::StringAppendF; using android::base::StringPrintf; using android::ui::ColorMode; using android::ui::RenderIntent; Loading Loading @@ -85,12 +87,11 @@ std::string decodeStandard(android_dataspace dataspace) { case HAL_DATASPACE_UNKNOWN: // Fallthrough default: return android::base::StringPrintf("Unknown deprecated dataspace code %d", dataspace); return StringPrintf("Unknown deprecated dataspace code %d", dataspace); } } return android::base::StringPrintf("Unknown dataspace code %d", dataspaceSelect); return StringPrintf("Unknown dataspace code %d", dataspaceSelect); } std::string decodeTransfer(android_dataspace dataspace) { Loading Loading @@ -147,7 +148,7 @@ std::string decodeTransfer(android_dataspace dataspace) { return std::string("STD-B67"); } return android::base::StringPrintf("Unknown dataspace transfer %d", dataspaceTransfer); return StringPrintf("Unknown dataspace transfer %d", dataspaceTransfer); } std::string decodeRange(android_dataspace dataspace) { Loading Loading @@ -187,16 +188,15 @@ std::string decodeRange(android_dataspace dataspace) { return std::string("Extended range"); } return android::base::StringPrintf("Unknown dataspace range %d", dataspaceRange); return StringPrintf("Unknown dataspace range %d", dataspaceRange); } std::string dataspaceDetails(android_dataspace dataspace) { if (dataspace == 0) { return "Default"; } return android::base::StringPrintf("%s %s %s", decodeStandard(dataspace).c_str(), decodeTransfer(dataspace).c_str(), decodeRange(dataspace).c_str()); return StringPrintf("%s %s %s", decodeStandard(dataspace).c_str(), decodeTransfer(dataspace).c_str(), decodeRange(dataspace).c_str()); } std::string decodeColorMode(ColorMode colorMode) { Loading Loading @@ -244,7 +244,7 @@ std::string decodeColorMode(ColorMode colorMode) { return std::string("ColorMode::BT2100_HLG"); } return android::base::StringPrintf("Unknown color mode %d", colorMode); return StringPrintf("Unknown color mode %d", colorMode); } std::string decodeColorTransform(android_color_transform colorTransform) { Loading @@ -271,7 +271,7 @@ std::string decodeColorTransform(android_color_transform colorTransform) { return std::string("Correct tritanopia"); } return android::base::StringPrintf("Unknown color transform %d", colorTransform); return StringPrintf("Unknown color transform %d", colorTransform); } // Converts a PixelFormat to a human-readable string. Max 11 chars. Loading Loading @@ -303,7 +303,7 @@ std::string decodePixelFormat(android::PixelFormat format) { case android::PIXEL_FORMAT_BGRA_8888: return std::string("BGRA_8888"); default: return android::base::StringPrintf("Unknown %#08x", format); return StringPrintf("Unknown %#08x", format); } } Loading @@ -324,3 +324,28 @@ std::string decodeRenderIntent(RenderIntent renderIntent) { std::string to_string(const android::Rect& rect) { return StringPrintf("(%4d,%4d,%4d,%4d)", rect.left, rect.top, rect.right, rect.bottom); } std::string toString(const android::DeviceProductInfo::ManufactureOrModelDate& date) { using ModelYear = android::DeviceProductInfo::ModelYear; using ManufactureYear = android::DeviceProductInfo::ManufactureYear; using ManufactureWeekAndYear = android::DeviceProductInfo::ManufactureWeekAndYear; if (const auto* model = std::get_if<ModelYear>(&date)) { return StringPrintf("ModelYear{%d}", model->year); } else if (const auto* manufacture = std::get_if<ManufactureYear>(&date)) { return StringPrintf("ManufactureDate{year=%d}", manufacture->year); } else if (const auto* manufacture = std::get_if<ManufactureWeekAndYear>(&date)) { return StringPrintf("ManufactureDate{week=%d, year=%d}", manufacture->week, manufacture->year); } else { LOG_FATAL("Unknown alternative for variant DeviceProductInfo::ManufactureOrModelDate"); return {}; } } std::string toString(const android::DeviceProductInfo& info) { return StringPrintf("DeviceProductInfo{name=%s, productId=%s, manufacturerPnpId=%s, " "manufactureOrModelDate=%s}", info.name.data(), info.productId.data(), info.manufacturerPnpId.data(), toString(info.manufactureOrModelDate).c_str()); } libs/ui/include/ui/DebugUtils.h +2 −0 Original line number Diff line number Diff line Loading @@ -23,6 +23,7 @@ namespace android { class Rect; struct DeviceProductInfo; } std::string decodeStandard(android_dataspace dataspace); Loading @@ -34,3 +35,4 @@ std::string decodeColorTransform(android_color_transform colorTransform); std::string decodePixelFormat(android::PixelFormat format); std::string decodeRenderIntent(android::ui::RenderIntent renderIntent); std::string to_string(const android::Rect& rect); std::string toString(const android::DeviceProductInfo&); libs/ui/include/ui/DeviceProductInfo.h 0 → 100644 +59 −0 Original line number Diff line number Diff line /* * Copyright 2020 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. */ #pragma once #include <array> #include <cstdint> #include <optional> #include <variant> namespace android { // NUL-terminated plug and play ID. using PnpId = std::array<char, 4>; // Product-specific information about the display or the directly connected device on the // display chain. For example, if the display is transitively connected, this field may contain // product information about the intermediate device. struct DeviceProductInfo { static constexpr size_t TEXT_BUFFER_SIZE = 20; struct ModelYear { uint32_t year; }; struct ManufactureYear : ModelYear {}; struct ManufactureWeekAndYear : ManufactureYear { // 1-base week number. Week numbering may not be consistent between manufacturers. uint8_t week; }; // Display name. std::array<char, TEXT_BUFFER_SIZE> name; // Manufacturer Plug and Play ID. PnpId manufacturerPnpId; // Manufacturer product ID. std::array<char, TEXT_BUFFER_SIZE> productId; using ManufactureOrModelDate = std::variant<ModelYear, ManufactureYear, ManufactureWeekAndYear>; ManufactureOrModelDate manufactureOrModelDate; }; } // namespace android libs/ui/include/ui/DisplayInfo.h +4 −0 Original line number Diff line number Diff line Loading @@ -16,8 +16,11 @@ #pragma once #include <optional> #include <type_traits> #include <ui/DeviceProductInfo.h> namespace android { enum class DisplayConnectionType { Internal, External }; Loading @@ -27,6 +30,7 @@ struct DisplayInfo { DisplayConnectionType connectionType = DisplayConnectionType::Internal; float density = 0.f; bool secure = false; std::optional<DeviceProductInfo> deviceProductInfo; }; static_assert(std::is_trivially_copyable_v<DisplayInfo>); Loading libs/ui/include_vndk/ui/DeviceProductInfo.h 0 → 120000 +1 −0 Original line number Diff line number Diff line ../../include/ui/DeviceProductInfo.h No newline at end of file Loading
libs/ui/DebugUtils.cpp +36 −11 Original line number Diff line number Diff line Loading @@ -15,12 +15,14 @@ */ #include <ui/DebugUtils.h> #include <ui/DeviceProductInfo.h> #include <ui/PixelFormat.h> #include <ui/Rect.h> #include <android-base/stringprintf.h> #include <string> using android::base::StringAppendF; using android::base::StringPrintf; using android::ui::ColorMode; using android::ui::RenderIntent; Loading Loading @@ -85,12 +87,11 @@ std::string decodeStandard(android_dataspace dataspace) { case HAL_DATASPACE_UNKNOWN: // Fallthrough default: return android::base::StringPrintf("Unknown deprecated dataspace code %d", dataspace); return StringPrintf("Unknown deprecated dataspace code %d", dataspace); } } return android::base::StringPrintf("Unknown dataspace code %d", dataspaceSelect); return StringPrintf("Unknown dataspace code %d", dataspaceSelect); } std::string decodeTransfer(android_dataspace dataspace) { Loading Loading @@ -147,7 +148,7 @@ std::string decodeTransfer(android_dataspace dataspace) { return std::string("STD-B67"); } return android::base::StringPrintf("Unknown dataspace transfer %d", dataspaceTransfer); return StringPrintf("Unknown dataspace transfer %d", dataspaceTransfer); } std::string decodeRange(android_dataspace dataspace) { Loading Loading @@ -187,16 +188,15 @@ std::string decodeRange(android_dataspace dataspace) { return std::string("Extended range"); } return android::base::StringPrintf("Unknown dataspace range %d", dataspaceRange); return StringPrintf("Unknown dataspace range %d", dataspaceRange); } std::string dataspaceDetails(android_dataspace dataspace) { if (dataspace == 0) { return "Default"; } return android::base::StringPrintf("%s %s %s", decodeStandard(dataspace).c_str(), decodeTransfer(dataspace).c_str(), decodeRange(dataspace).c_str()); return StringPrintf("%s %s %s", decodeStandard(dataspace).c_str(), decodeTransfer(dataspace).c_str(), decodeRange(dataspace).c_str()); } std::string decodeColorMode(ColorMode colorMode) { Loading Loading @@ -244,7 +244,7 @@ std::string decodeColorMode(ColorMode colorMode) { return std::string("ColorMode::BT2100_HLG"); } return android::base::StringPrintf("Unknown color mode %d", colorMode); return StringPrintf("Unknown color mode %d", colorMode); } std::string decodeColorTransform(android_color_transform colorTransform) { Loading @@ -271,7 +271,7 @@ std::string decodeColorTransform(android_color_transform colorTransform) { return std::string("Correct tritanopia"); } return android::base::StringPrintf("Unknown color transform %d", colorTransform); return StringPrintf("Unknown color transform %d", colorTransform); } // Converts a PixelFormat to a human-readable string. Max 11 chars. Loading Loading @@ -303,7 +303,7 @@ std::string decodePixelFormat(android::PixelFormat format) { case android::PIXEL_FORMAT_BGRA_8888: return std::string("BGRA_8888"); default: return android::base::StringPrintf("Unknown %#08x", format); return StringPrintf("Unknown %#08x", format); } } Loading @@ -324,3 +324,28 @@ std::string decodeRenderIntent(RenderIntent renderIntent) { std::string to_string(const android::Rect& rect) { return StringPrintf("(%4d,%4d,%4d,%4d)", rect.left, rect.top, rect.right, rect.bottom); } std::string toString(const android::DeviceProductInfo::ManufactureOrModelDate& date) { using ModelYear = android::DeviceProductInfo::ModelYear; using ManufactureYear = android::DeviceProductInfo::ManufactureYear; using ManufactureWeekAndYear = android::DeviceProductInfo::ManufactureWeekAndYear; if (const auto* model = std::get_if<ModelYear>(&date)) { return StringPrintf("ModelYear{%d}", model->year); } else if (const auto* manufacture = std::get_if<ManufactureYear>(&date)) { return StringPrintf("ManufactureDate{year=%d}", manufacture->year); } else if (const auto* manufacture = std::get_if<ManufactureWeekAndYear>(&date)) { return StringPrintf("ManufactureDate{week=%d, year=%d}", manufacture->week, manufacture->year); } else { LOG_FATAL("Unknown alternative for variant DeviceProductInfo::ManufactureOrModelDate"); return {}; } } std::string toString(const android::DeviceProductInfo& info) { return StringPrintf("DeviceProductInfo{name=%s, productId=%s, manufacturerPnpId=%s, " "manufactureOrModelDate=%s}", info.name.data(), info.productId.data(), info.manufacturerPnpId.data(), toString(info.manufactureOrModelDate).c_str()); }
libs/ui/include/ui/DebugUtils.h +2 −0 Original line number Diff line number Diff line Loading @@ -23,6 +23,7 @@ namespace android { class Rect; struct DeviceProductInfo; } std::string decodeStandard(android_dataspace dataspace); Loading @@ -34,3 +35,4 @@ std::string decodeColorTransform(android_color_transform colorTransform); std::string decodePixelFormat(android::PixelFormat format); std::string decodeRenderIntent(android::ui::RenderIntent renderIntent); std::string to_string(const android::Rect& rect); std::string toString(const android::DeviceProductInfo&);
libs/ui/include/ui/DeviceProductInfo.h 0 → 100644 +59 −0 Original line number Diff line number Diff line /* * Copyright 2020 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. */ #pragma once #include <array> #include <cstdint> #include <optional> #include <variant> namespace android { // NUL-terminated plug and play ID. using PnpId = std::array<char, 4>; // Product-specific information about the display or the directly connected device on the // display chain. For example, if the display is transitively connected, this field may contain // product information about the intermediate device. struct DeviceProductInfo { static constexpr size_t TEXT_BUFFER_SIZE = 20; struct ModelYear { uint32_t year; }; struct ManufactureYear : ModelYear {}; struct ManufactureWeekAndYear : ManufactureYear { // 1-base week number. Week numbering may not be consistent between manufacturers. uint8_t week; }; // Display name. std::array<char, TEXT_BUFFER_SIZE> name; // Manufacturer Plug and Play ID. PnpId manufacturerPnpId; // Manufacturer product ID. std::array<char, TEXT_BUFFER_SIZE> productId; using ManufactureOrModelDate = std::variant<ModelYear, ManufactureYear, ManufactureWeekAndYear>; ManufactureOrModelDate manufactureOrModelDate; }; } // namespace android
libs/ui/include/ui/DisplayInfo.h +4 −0 Original line number Diff line number Diff line Loading @@ -16,8 +16,11 @@ #pragma once #include <optional> #include <type_traits> #include <ui/DeviceProductInfo.h> namespace android { enum class DisplayConnectionType { Internal, External }; Loading @@ -27,6 +30,7 @@ struct DisplayInfo { DisplayConnectionType connectionType = DisplayConnectionType::Internal; float density = 0.f; bool secure = false; std::optional<DeviceProductInfo> deviceProductInfo; }; static_assert(std::is_trivially_copyable_v<DisplayInfo>); Loading
libs/ui/include_vndk/ui/DeviceProductInfo.h 0 → 120000 +1 −0 Original line number Diff line number Diff line ../../include/ui/DeviceProductInfo.h No newline at end of file