Add more information to manifest warning message
Change-Id: If937bc27bd1b392022a23f942c50a84ed12d2268
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/100890
Commit-Queue: Keerti Parthasarathy <keertip@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
diff --git a/pkg/analyzer/lib/src/manifest/manifest_validator.dart b/pkg/analyzer/lib/src/manifest/manifest_validator.dart
index c3f7c29..a79c84e 100644
--- a/pkg/analyzer/lib/src/manifest/manifest_validator.dart
+++ b/pkg/analyzer/lib/src/manifest/manifest_validator.dart
@@ -61,11 +61,19 @@
orElse: () => null);
if (feature != null) {
if (!feature.attributes.containsKey(ANDROID_REQUIRED)) {
- _reportErrorForNode(reporter, feature, ANDROID_NAME,
- ManifestWarningCode.UNSUPPORTED_CHROME_OS_HARDWARE);
+ _reportErrorForNode(
+ reporter,
+ feature,
+ ANDROID_NAME,
+ ManifestWarningCode.UNSUPPORTED_CHROME_OS_HARDWARE,
+ [HARDWARE_FEATURE_TOUCHSCREEN]);
} else if (feature.attributes[ANDROID_REQUIRED] == 'true') {
- _reportErrorForNode(reporter, feature, ANDROID_NAME,
- ManifestWarningCode.UNSUPPORTED_CHROME_OS_FEATURE);
+ _reportErrorForNode(
+ reporter,
+ feature,
+ ANDROID_NAME,
+ ManifestWarningCode.UNSUPPORTED_CHROME_OS_FEATURE,
+ [HARDWARE_FEATURE_TOUCHSCREEN]);
}
} else {
_reportErrorForNode(
@@ -83,11 +91,19 @@
.toList();
unsupported.forEach((element) {
if (!element.attributes.containsKey(ANDROID_REQUIRED)) {
- _reportErrorForNode(reporter, element, ANDROID_NAME,
- ManifestWarningCode.UNSUPPORTED_CHROME_OS_HARDWARE);
+ _reportErrorForNode(
+ reporter,
+ element,
+ ANDROID_NAME,
+ ManifestWarningCode.UNSUPPORTED_CHROME_OS_HARDWARE,
+ [element.attributes[ANDROID_NAME]]);
} else if (element.attributes[ANDROID_REQUIRED] == 'true') {
- _reportErrorForNode(reporter, element, ANDROID_NAME,
- ManifestWarningCode.UNSUPPORTED_CHROME_OS_FEATURE);
+ _reportErrorForNode(
+ reporter,
+ element,
+ ANDROID_NAME,
+ ManifestWarningCode.UNSUPPORTED_CHROME_OS_FEATURE,
+ [element.attributes[ANDROID_NAME]]);
}
});
}
diff --git a/pkg/analyzer/lib/src/manifest/manifest_warning_code.dart b/pkg/analyzer/lib/src/manifest/manifest_warning_code.dart
index cd9761d..cfecf97 100644
--- a/pkg/analyzer/lib/src/manifest/manifest_warning_code.dart
+++ b/pkg/analyzer/lib/src/manifest/manifest_warning_code.dart
@@ -16,7 +16,7 @@
*/
static const ManifestWarningCode UNSUPPORTED_CHROME_OS_HARDWARE =
const ManifestWarningCode('UNSUPPORTED_CHROME_OS_HARDWARE',
- "This feature is not supported on Chrome OS, consider making it optional.",
+ "The feature {0} is not supported on Chrome OS, consider making it optional.",
correction:
"Try adding `android:required=\"false\"` for this " + "feature.");
@@ -25,7 +25,7 @@
*/
static const ManifestWarningCode UNSUPPORTED_CHROME_OS_FEATURE =
const ManifestWarningCode('UNSUPPORTED_CHROME_OS_FEATURE',
- "This feature is not supported on Chrome OS, consider making it optional.",
+ 'The feature {0} is not supported on Chrome OS, consider making it optional.',
correction: "Try changing to `android:required=\"false\"` for this " +
"feature.");
diff --git a/pkg/analyzer_cli/test/driver_test.dart b/pkg/analyzer_cli/test/driver_test.dart
index fa1cd22..8903b6a 100644
--- a/pkg/analyzer_cli/test/driver_test.dart
+++ b/pkg/analyzer_cli/test/driver_test.dart
@@ -803,12 +803,15 @@
new File(manifestPath).writeAsStringSync('''
<manifest
xmlns:android="http://schemas.android.com/apk/res/android">
+ <uses-feature android:name="android.hardware.touchscreen" android:required="false" />
<uses-feature android:name="android.software.home_screen" />
</manifest>
''');
await drive(manifestPath, options: filePath);
- expect(bulletToDash(outSink),
- contains("warning - This feature is not supported on Chrome OS"));
+ expect(
+ bulletToDash(outSink),
+ contains(
+ "warning - The feature android.software.home_screen is not supported on Chrome OS"));
expect(exitCode, 0);
});
}