Skip to content

Commit ad5ae5b

Browse files
stagadishAndroid (Google) Code Review
authored andcommitted
Merge changes from topic "make-displayid-opaque" into main
* changes: libs/ui: Remove getManufacturerId() from DisplayId libs/ui: Remove isStable() flag from DisplayId
2 parents ca8bfa3 + ba6afd8 commit ad5ae5b

5 files changed

Lines changed: 3 additions & 50 deletions

File tree

libs/ui/DisplayIdentification.cpp

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -392,10 +392,6 @@ std::optional<PnpId> getPnpId(uint16_t manufacturerId) {
392392
return a && b && c ? std::make_optional(PnpId{a, b, c}) : std::nullopt;
393393
}
394394

395-
std::optional<PnpId> getPnpId(PhysicalDisplayId displayId) {
396-
return getPnpId(displayId.getManufacturerId());
397-
}
398-
399395
std::optional<DisplayIdentificationInfo> parseDisplayIdentificationData(
400396
uint8_t port, const DisplayIdentificationData& data) {
401397
if (data.empty()) {

libs/ui/include/ui/DisplayId.h

Lines changed: 3 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@
2020
#include <ostream>
2121
#include <string>
2222

23-
#include <ftl/hash.h>
2423
#include <ftl/optional.h>
2524

2625
namespace android {
@@ -31,16 +30,12 @@ struct DisplayId {
3130
// Flag indicating that the display is virtual.
3231
static constexpr uint64_t FLAG_VIRTUAL = 1ULL << 63;
3332

34-
// Flag indicating that the ID is stable across reboots.
35-
static constexpr uint64_t FLAG_STABLE = 1ULL << 62;
36-
3733
// TODO(b/162612135) Remove default constructor
3834
DisplayId() = default;
3935
constexpr DisplayId(const DisplayId&) = default;
4036
DisplayId& operator=(const DisplayId&) = default;
4137

4238
constexpr bool isVirtual() const { return value & FLAG_VIRTUAL; }
43-
constexpr bool isStable() const { return value & FLAG_STABLE; }
4439

4540
uint64_t value;
4641

@@ -102,10 +97,12 @@ struct PhysicalDisplayId : DisplayId {
10297
// TODO(b/162612135) Remove default constructor
10398
PhysicalDisplayId() = default;
10499

105-
constexpr uint16_t getManufacturerId() const { return static_cast<uint16_t>(value >> 40); }
106100
constexpr uint8_t getPort() const { return static_cast<uint8_t>(value); }
107101

108102
private:
103+
// Flag indicating that the ID is stable across reboots.
104+
static constexpr uint64_t FLAG_STABLE = 1ULL << 62;
105+
109106
constexpr PhysicalDisplayId(uint64_t flags, uint8_t port, uint16_t manufacturerId,
110107
uint32_t modelHash)
111108
: DisplayId(flags | (static_cast<uint64_t>(manufacturerId) << 40) |
@@ -149,13 +146,6 @@ struct HalVirtualDisplayId : VirtualDisplayId {
149146
struct GpuVirtualDisplayId : VirtualDisplayId {
150147
explicit constexpr GpuVirtualDisplayId(BaseId baseId) : VirtualDisplayId(FLAG_GPU | baseId) {}
151148

152-
static constexpr std::optional<GpuVirtualDisplayId> fromUniqueId(const std::string& uniqueId) {
153-
if (const auto hashOpt = ftl::stable_hash(uniqueId)) {
154-
return GpuVirtualDisplayId(HashTag{}, *hashOpt);
155-
}
156-
return {};
157-
}
158-
159149
static constexpr std::optional<GpuVirtualDisplayId> tryCast(DisplayId id) {
160150
if (id.isVirtual() && (id.value & FLAG_GPU)) {
161151
return GpuVirtualDisplayId(id);
@@ -164,10 +154,6 @@ struct GpuVirtualDisplayId : VirtualDisplayId {
164154
}
165155

166156
private:
167-
struct HashTag {}; // Disambiguate with BaseId constructor.
168-
constexpr GpuVirtualDisplayId(HashTag, uint64_t hash)
169-
: VirtualDisplayId(FLAG_STABLE | FLAG_GPU | hash) {}
170-
171157
explicit constexpr GpuVirtualDisplayId(DisplayId other) : VirtualDisplayId(other) {}
172158
};
173159

libs/ui/include/ui/DisplayIdentification.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,6 @@ struct Edid {
8585
bool isEdid(const DisplayIdentificationData&);
8686
std::optional<Edid> parseEdid(const DisplayIdentificationData&);
8787
std::optional<PnpId> getPnpId(uint16_t manufacturerId);
88-
std::optional<PnpId> getPnpId(PhysicalDisplayId);
8988

9089
std::optional<DisplayIdentificationInfo> parseDisplayIdentificationData(
9190
uint8_t port, const DisplayIdentificationData&);

libs/ui/tests/DisplayId_test.cpp

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@ TEST(DisplayIdTest, createPhysicalIdFromEdid) {
2626
constexpr uint32_t modelHash = 42;
2727
const PhysicalDisplayId id = PhysicalDisplayId::fromEdid(port, manufacturerId, modelHash);
2828
EXPECT_EQ(port, id.getPort());
29-
EXPECT_EQ(manufacturerId, id.getManufacturerId());
3029
EXPECT_FALSE(VirtualDisplayId::tryCast(id));
3130
EXPECT_FALSE(HalVirtualDisplayId::tryCast(id));
3231
EXPECT_FALSE(GpuVirtualDisplayId::tryCast(id));
@@ -75,21 +74,6 @@ TEST(DisplayIdTest, createVirtualIdFromGpuVirtualId) {
7574
EXPECT_EQ((id.isVirtual() && isGpuVirtualId), GpuVirtualDisplayId::tryCast(id).has_value());
7675
}
7776

78-
TEST(DisplayIdTest, createGpuVirtualIdFromUniqueId) {
79-
static const std::string kUniqueId("virtual:ui:DisplayId_test");
80-
const auto idOpt = GpuVirtualDisplayId::fromUniqueId(kUniqueId);
81-
ASSERT_TRUE(idOpt.has_value());
82-
const GpuVirtualDisplayId id = idOpt.value();
83-
EXPECT_TRUE(VirtualDisplayId::tryCast(id));
84-
EXPECT_TRUE(GpuVirtualDisplayId::tryCast(id));
85-
EXPECT_FALSE(HalVirtualDisplayId::tryCast(id));
86-
EXPECT_FALSE(PhysicalDisplayId::tryCast(id));
87-
EXPECT_FALSE(HalDisplayId::tryCast(id));
88-
89-
EXPECT_EQ(id, DisplayId::fromValue(id.value));
90-
EXPECT_EQ(id, DisplayId::fromValue<GpuVirtualDisplayId>(id.value));
91-
}
92-
9377
TEST(DisplayIdTest, createHalVirtualId) {
9478
const HalVirtualDisplayId id(42);
9579
EXPECT_TRUE(VirtualDisplayId::tryCast(id));

libs/ui/tests/DisplayIdentification_test.cpp

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -462,18 +462,6 @@ TEST(DisplayIdentificationTest, deviceProductInfo) {
462462
}
463463
}
464464

465-
TEST(DisplayIdentificationTest, fromPort) {
466-
// Manufacturer ID should be invalid.
467-
ASSERT_FALSE(getPnpId(PhysicalDisplayId::fromPort(0)));
468-
ASSERT_FALSE(getPnpId(PhysicalDisplayId::fromPort(0xffu)));
469-
}
470-
471-
TEST(DisplayIdentificationTest, getVirtualDisplayId) {
472-
// Manufacturer ID should be invalid.
473-
ASSERT_FALSE(getPnpId(getVirtualDisplayId(0)));
474-
ASSERT_FALSE(getPnpId(getVirtualDisplayId(0xffff'ffffu)));
475-
}
476-
477465
} // namespace android
478466

479467
// TODO(b/129481165): remove the #pragma below and fix conversion issues

0 commit comments

Comments
 (0)