Skip to content

Commit 1c8b16b

Browse files
timvpGoogleAndroid (Google) Code Review
authored andcommitted
Merge "FeatureConfig: Add GPU vendor ID support" into main
2 parents 9fd5fdd + 4b98bde commit 1c8b16b

2 files changed

Lines changed: 43 additions & 2 deletions

File tree

libs/graphicsenv/FeatureOverrides.cpp

Lines changed: 42 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,18 @@ status_t FeatureConfig::writeToParcel(Parcel* parcel) const {
3535
if (status != OK) {
3636
return status;
3737
}
38+
// Number of GPU vendor IDs.
39+
status = parcel->writeVectorSize(mGpuVendorIDs);
40+
if (status != OK) {
41+
return status;
42+
}
43+
// GPU vendor IDs.
44+
for (const auto& vendorID : mGpuVendorIDs) {
45+
status = parcel->writeUint32(vendorID);
46+
if (status != OK) {
47+
return status;
48+
}
49+
}
3850

3951
return OK;
4052
}
@@ -50,6 +62,21 @@ status_t FeatureConfig::readFromParcel(const Parcel* parcel) {
5062
if (status != OK) {
5163
return status;
5264
}
65+
// Number of GPU vendor IDs.
66+
int numGpuVendorIDs;
67+
status = parcel->readInt32(&numGpuVendorIDs);
68+
if (status != OK) {
69+
return status;
70+
}
71+
// GPU vendor IDs.
72+
for (int i = 0; i < numGpuVendorIDs; i++) {
73+
uint32_t gpuVendorIdUint;
74+
status = parcel->readUint32(&gpuVendorIdUint);
75+
if (status != OK) {
76+
return status;
77+
}
78+
mGpuVendorIDs.emplace_back(gpuVendorIdUint);
79+
}
5380

5481
return OK;
5582
}
@@ -58,6 +85,10 @@ std::string FeatureConfig::toString() const {
5885
std::string result;
5986
StringAppendF(&result, "Feature: %s\n", mFeatureName.c_str());
6087
StringAppendF(&result, " Status: %s\n", mEnabled ? "enabled" : "disabled");
88+
for (const auto& vendorID : mGpuVendorIDs) {
89+
// vkjson outputs decimal, so print both formats.
90+
StringAppendF(&result, " GPU Vendor ID: 0x%04X (%d)\n", vendorID, vendorID);
91+
}
6192

6293
return result;
6394
}
@@ -121,7 +152,12 @@ status_t FeatureOverrides::readFromParcel(const Parcel* parcel) {
121152
}
122153

123154
// Number of package feature overrides.
124-
int numPkgOverrides = parcel->readInt32();
155+
int numPkgOverrides;
156+
status = parcel->readInt32(&numPkgOverrides);
157+
if (status != OK) {
158+
return status;
159+
}
160+
// Package feature overrides.
125161
for (int i = 0; i < numPkgOverrides; i++) {
126162
// Package name.
127163
std::string name;
@@ -131,7 +167,11 @@ status_t FeatureOverrides::readFromParcel(const Parcel* parcel) {
131167
}
132168
std::vector<FeatureConfig> cfgs;
133169
// Number of package feature configs.
134-
int numCfgs = parcel->readInt32();
170+
int numCfgs;
171+
status = parcel->readInt32(&numCfgs);
172+
if (status != OK) {
173+
return status;
174+
}
135175
// Package feature configs.
136176
for (int j = 0; j < numCfgs; j++) {
137177
FeatureConfig cfg;

libs/graphicsenv/include/graphicsenv/FeatureOverrides.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ class FeatureConfig : public Parcelable {
3535

3636
std::string mFeatureName;
3737
bool mEnabled;
38+
std::vector<uint32_t> mGpuVendorIDs;
3839
};
3940

4041
/*

0 commit comments

Comments
 (0)