Skip to content

Commit 491451d

Browse files
Treehugger RobotAndroid (Google) Code Review
authored andcommitted
Merge "Add FeatureOverrides::toString()" into main
2 parents 04a3b4f + 0b6b81d commit 491451d

3 files changed

Lines changed: 55 additions & 0 deletions

File tree

libs/graphicsenv/Android.bp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ cc_library_shared {
4141
],
4242

4343
srcs: [
44+
"FeatureOverrides.cpp",
4445
"GpuStatsInfo.cpp",
4546
"GraphicsEnv.cpp",
4647
"IGpuService.cpp",
Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
/*
2+
* Copyright 2025 The Android Open Source Project
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
#include <graphicsenv/FeatureOverrides.h>
18+
19+
#include <android-base/stringprintf.h>
20+
21+
namespace android {
22+
23+
using base::StringAppendF;
24+
25+
std::string FeatureConfig::toString() const {
26+
std::string result;
27+
StringAppendF(&result, "Feature: %s\n", mFeatureName.c_str());
28+
StringAppendF(&result, " Status: %s\n", mEnabled ? "enabled" : "disabled");
29+
30+
return result;
31+
}
32+
33+
std::string FeatureOverrides::toString() const {
34+
std::string result;
35+
result.append("Global Features:\n");
36+
for (auto& cfg : mGlobalFeatures) {
37+
result.append(" " + cfg.toString());
38+
}
39+
result.append("\n");
40+
result.append("Package Features:\n");
41+
for (const auto& packageFeature : mPackageFeatures) {
42+
result.append(" Package:");
43+
StringAppendF(&result, " %s\n", packageFeature.first.c_str());
44+
for (auto& cfg : packageFeature.second) {
45+
result.append(" " + cfg.toString());
46+
}
47+
}
48+
49+
return result;
50+
}
51+
52+
} // namespace android

libs/graphicsenv/include/graphicsenv/FeatureOverrides.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ class FeatureConfig {
2727
FeatureConfig() = default;
2828
FeatureConfig(const FeatureConfig&) = default;
2929
virtual ~FeatureConfig() = default;
30+
std::string toString() const;
3031

3132
std::string mFeatureName;
3233
bool mEnabled;
@@ -41,6 +42,7 @@ class FeatureOverrides {
4142
FeatureOverrides() = default;
4243
FeatureOverrides(const FeatureOverrides&) = default;
4344
virtual ~FeatureOverrides() = default;
45+
std::string toString() const;
4446

4547
std::vector<FeatureConfig> mGlobalFeatures;
4648
/* Key: Package Name, Value: Package's Feature Configs */

0 commit comments

Comments
 (0)