summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Simon Wingrove <simonjw@google.com> 2023-02-02 13:52:17 +0000
committer Simon Wingrove <simonjw@google.com> 2023-02-04 13:37:46 +0000
commit560f402a6e93eb7eaf087f6266eda4e8b719172c (patch)
tree753121903e2f5a3a4403848b153e48b94758b820
parentf706cf54294c9a8299ac84df7f4c718a3ac6cf2c (diff)
Apply ktfmt to SafetyCenter code
Hoping now is a reasonable time when people won't have large in-progress changes on these particular files, so OK to make some reformattings here. Test: builds Relnote: N/A Bug: 261033020 Change-Id: Id248a1c1b0d5e3aebe4c9b44819f6db38930d6b8
-rw-r--r--SafetyCenter/Config/tests/java/com/android/safetycenter/config/Coroutines.kt8
-rw-r--r--SafetyCenter/Config/tests/java/com/android/safetycenter/config/ParserConfigInvalidTest.kt778
-rw-r--r--SafetyCenter/Config/tests/java/com/android/safetycenter/config/ParserConfigOverlayTest.kt3
-rw-r--r--SafetyCenter/Config/tests/java/com/android/safetycenter/config/ParserConfigValidTest.kt99
-rw-r--r--SafetyCenter/ConfigLintChecker/java/android/safetycenter/lint/ConfigLintCheckerIssueRegistry.kt16
-rw-r--r--SafetyCenter/ConfigLintChecker/java/android/safetycenter/lint/ConfigSchemaDetector.kt12
-rw-r--r--SafetyCenter/ConfigLintChecker/java/android/safetycenter/lint/ParserExceptionDetector.kt24
-rw-r--r--SafetyCenter/ConfigLintChecker/tests/java/android/safetycenter/lint/test/ConfigSchemaDetectorTest.kt21
-rw-r--r--SafetyCenter/ConfigLintChecker/tests/java/android/safetycenter/lint/test/ParserExceptionDetectorTest.kt21
-rw-r--r--SafetyCenter/Persistence/tests/java/com/android/safetycenter/persistence/PersistedSafetyCenterIssueTest.kt15
-rw-r--r--SafetyCenter/Persistence/tests/java/com/android/safetycenter/persistence/SafetyCenterIssuesPersistenceInvalidTest.kt52
-rw-r--r--SafetyCenter/Persistence/tests/java/com/android/safetycenter/persistence/SafetyCenterIssuesPersistenceValidTest.kt4
-rw-r--r--SafetyCenter/Persistence/tests/java/com/android/safetycenter/persistence/SafetyCenterIssuesPersistenceWriteTest.kt5
-rw-r--r--SafetyCenter/ResourcesLib/tests/java/com/android/safetycenter/resources/SafetyCenterResourcesContextTest.kt12
-rw-r--r--ktfmt_includes.txt1
15 files changed, 617 insertions, 454 deletions
diff --git a/SafetyCenter/Config/tests/java/com/android/safetycenter/config/Coroutines.kt b/SafetyCenter/Config/tests/java/com/android/safetycenter/config/Coroutines.kt
index 9b1d4c5f9..814303a67 100644
--- a/SafetyCenter/Config/tests/java/com/android/safetycenter/config/Coroutines.kt
+++ b/SafetyCenter/Config/tests/java/com/android/safetycenter/config/Coroutines.kt
@@ -17,14 +17,14 @@
package com.android.safetycenter.config
import android.util.Log
+import java.time.Duration
import kotlinx.coroutines.delay
import kotlinx.coroutines.runBlocking
import kotlinx.coroutines.withTimeout
-import java.time.Duration
/**
- * A class that facilitates interacting with coroutines.
- * TODO(b/228823159) Consolidate with other Coroutines helper functions
+ * A class that facilitates interacting with coroutines. TODO(b/228823159) Consolidate with other
+ * Coroutines helper functions
*/
object Coroutines {
@@ -74,4 +74,4 @@ object Coroutines {
/** A long timeout, to be used for actions that are expected to complete. */
private val TIMEOUT_LONG: Duration = Duration.ofSeconds(5)
-} \ No newline at end of file
+}
diff --git a/SafetyCenter/Config/tests/java/com/android/safetycenter/config/ParserConfigInvalidTest.kt b/SafetyCenter/Config/tests/java/com/android/safetycenter/config/ParserConfigInvalidTest.kt
index fe189dc7a..64775d7fe 100644
--- a/SafetyCenter/Config/tests/java/com/android/safetycenter/config/ParserConfigInvalidTest.kt
+++ b/SafetyCenter/Config/tests/java/com/android/safetycenter/config/ParserConfigInvalidTest.kt
@@ -62,360 +62,430 @@ class ParserConfigInvalidTest {
@Parameterized.Parameters(name = "{0}")
fun parameters() =
arrayOf(
- Params(
- "ConfigDynamicSafetySourceAllDisabledNoWork",
- R.raw.config_dynamic_safety_source_all_disabled_no_work,
- "Element dynamic-safety-source invalid",
- "Required attribute titleForWork missing"),
- Params(
- "ConfigDynamicSafetySourceAllHiddenWithSearchNoWork",
- R.raw.config_dynamic_safety_source_all_hidden_with_search_no_work,
- "Element dynamic-safety-source invalid",
- "Required attribute titleForWork missing"),
- Params(
- "ConfigDynamicSafetySourceAllNoWork",
- R.raw.config_dynamic_safety_source_all_no_work,
- "Element dynamic-safety-source invalid",
- "Required attribute titleForWork missing"),
- Params(
- "ConfigDynamicSafetySourceDisabledNoSummary",
- R.raw.config_dynamic_safety_source_disabled_no_summary,
- "Element dynamic-safety-source invalid",
- "Required attribute summary missing"),
- Params(
- "ConfigDynamicSafetySourceDisabledNoTitle",
- R.raw.config_dynamic_safety_source_disabled_no_title,
- "Element dynamic-safety-source invalid",
- "Required attribute title missing"),
- Params(
- "ConfigDynamicSafetySourceDuplicateKey",
- R.raw.config_dynamic_safety_source_duplicate_key,
- "Element safety-sources-config invalid",
- "Duplicate id id among safety sources"),
- Params(
- "ConfigDynamicSafetySourceHiddenWithSearchNoTitle",
- R.raw.config_dynamic_safety_source_hidden_with_search_no_title,
- "Element dynamic-safety-source invalid",
- "Required attribute title missing"),
- Params(
- "ConfigDynamicSafetySourceInvalidDisplay",
- R.raw.config_dynamic_safety_source_invalid_display,
- "Attribute value \"invalid\" in dynamic-safety-source.initialDisplayState " +
- "invalid",
- null),
- Params(
- "ConfigDynamicSafetySourceInvalidId",
- R.raw.config_dynamic_safety_source_invalid_id,
- "Element dynamic-safety-source invalid",
- "Attribute id invalid"),
- Params(
- "ConfigDynamicSafetySourceInvalidProfile",
- R.raw.config_dynamic_safety_source_invalid_profile,
- "Attribute value \"invalid\" in dynamic-safety-source.profile invalid",
- null),
- Params(
- "ConfigDynamicSafetySourceNoId",
- R.raw.config_dynamic_safety_source_no_id,
- "Element dynamic-safety-source invalid",
- "Required attribute id missing"),
- Params(
- "ConfigDynamicSafetySourceNoIntent",
- R.raw.config_dynamic_safety_source_no_intent,
- "Element dynamic-safety-source invalid",
- "Required attribute intentAction missing"),
- Params(
- "ConfigDynamicSafetySourceNoPackage",
- R.raw.config_dynamic_safety_source_no_package,
- "Element dynamic-safety-source invalid",
- "Required attribute packageName missing"),
- Params(
- "ConfigDynamicSafetySourceNoProfile",
- R.raw.config_dynamic_safety_source_no_profile,
- "Element dynamic-safety-source invalid",
- "Required attribute profile missing"),
- Params(
- "ConfigDynamicSafetySourceNoSummary",
- R.raw.config_dynamic_safety_source_no_summary,
- "Element dynamic-safety-source invalid",
- "Required attribute summary missing"),
- Params(
- "ConfigDynamicSafetySourceNoTitle",
- R.raw.config_dynamic_safety_source_no_title,
- "Element dynamic-safety-source invalid",
- "Required attribute title missing"),
- Params(
- "ConfigDynamicSafetySourcePrimaryHiddenWithWork",
- R.raw.config_dynamic_safety_source_primary_hidden_with_work,
- "Element dynamic-safety-source invalid",
- "Prohibited attribute titleForWork present"),
- Params(
- "ConfigDynamicSafetySourcePrimaryWithWork",
- R.raw.config_dynamic_safety_source_primary_with_work,
- "Element dynamic-safety-source invalid",
- "Prohibited attribute titleForWork present"),
- Params(
- "ConfigFileCorrupted",
- R.raw.config_file_corrupted,
- "Exception while parsing the XML resource",
- null),
- Params(
- "ConfigIssueOnlySafetySourceDuplicateKey",
- R.raw.config_issue_only_safety_source_duplicate_key,
- "Element safety-sources-config invalid",
- "Duplicate id id among safety sources"),
- Params(
- "ConfigIssueOnlySafetySourceInvalidId",
- R.raw.config_issue_only_safety_source_invalid_id,
- "Element issue-only-safety-source invalid",
- "Attribute id invalid"),
- Params(
- "ConfigIssueOnlySafetySourceInvalidProfile",
- R.raw.config_issue_only_safety_source_invalid_profile,
- "Attribute value \"invalid\" in issue-only-safety-source.profile invalid",
- null),
- Params(
- "ConfigIssueOnlySafetySourceNoId",
- R.raw.config_issue_only_safety_source_no_id,
- "Element issue-only-safety-source invalid",
- "Required attribute id missing"),
- Params(
- "ConfigIssueOnlySafetySourceNoPackage",
- R.raw.config_issue_only_safety_source_no_package,
- "Element issue-only-safety-source invalid",
- "Required attribute packageName missing"),
- Params(
- "ConfigIssueOnlySafetySourceNoProfile",
- R.raw.config_issue_only_safety_source_no_profile,
- "Element issue-only-safety-source invalid",
- "Required attribute profile missing"),
- Params(
- "ConfigIssueOnlySafetySourceWithDisplay",
- R.raw.config_issue_only_safety_source_with_display,
- "Element issue-only-safety-source invalid",
- "Prohibited attribute initialDisplayState present"),
- Params(
- "ConfigIssueOnlySafetySourceWithIntent",
- R.raw.config_issue_only_safety_source_with_intent,
- "Element issue-only-safety-source invalid",
- "Prohibited attribute intentAction present"),
- Params(
- "ConfigIssueOnlySafetySourceWithSearch",
- R.raw.config_issue_only_safety_source_with_search,
- "Element issue-only-safety-source invalid",
- "Prohibited attribute searchTerms present"),
- Params(
- "ConfigIssueOnlySafetySourceWithSummary",
- R.raw.config_issue_only_safety_source_with_summary,
- "Element issue-only-safety-source invalid",
- "Prohibited attribute summary present"),
- Params(
- "ConfigIssueOnlySafetySourceWithTitle",
- R.raw.config_issue_only_safety_source_with_title,
- "Element issue-only-safety-source invalid",
- "Prohibited attribute title present"),
- Params(
- "ConfigIssueOnlySafetySourceWithWork",
- R.raw.config_issue_only_safety_source_with_work,
- "Element issue-only-safety-source invalid",
- "Prohibited attribute titleForWork present"),
- Params(
- "ConfigMixedSafetySourceDuplicateKey",
- R.raw.config_mixed_safety_source_duplicate_key,
- "Element safety-sources-config invalid",
- "Duplicate id id among safety sources"),
- Params(
- "ConfigSafetyCenterConfigMissing",
- R.raw.config_safety_center_config_missing,
- "Element safety-center-config missing",
- null),
- Params(
- "ConfigSafetySourcesConfigEmpty",
- R.raw.config_safety_sources_config_empty,
- "Element safety-sources-config invalid",
- "No safety sources groups present"),
- Params(
- "ConfigSafetySourcesConfigMissing",
- R.raw.config_safety_sources_config_missing,
- "Element safety-sources-config missing",
- null),
- Params(
- "ConfigSafetySourcesGroupDuplicateId",
- R.raw.config_safety_sources_group_duplicate_id,
- "Element safety-sources-config invalid",
- "Duplicate id id among safety sources groups"),
- Params(
- "ConfigSafetySourcesGroupEmpty",
- R.raw.config_safety_sources_group_empty,
- "Element safety-sources-group invalid",
- "Safety sources group empty"),
- Params(
- "ConfigSafetySourcesGroupHiddenWithOnlyDynamic",
- R.raw.config_safety_sources_group_hidden_with_only_dynamic,
- "Element safety-sources-group invalid",
- "Safety sources groups of type hidden can only contain sources of type " +
- "issue-only",
- SdkLevel.isAtLeastU()),
- Params(
- "ConfigSafetySourcesGroupHiddenWithOnlyStatic",
- R.raw.config_safety_sources_group_hidden_with_only_static,
- "Element safety-sources-group invalid",
- "Safety sources groups of type hidden can only contain sources of type " +
- "issue-only",
- SdkLevel.isAtLeastU()),
- Params(
- "ConfigSafetySourcesGroupInvalidIcon",
- R.raw.config_safety_sources_group_invalid_icon,
- "Attribute value \"invalid\" in safety-sources-group.statelessIconType invalid",
- null),
- Params(
- "ConfigSafetySourcesGroupInvalidId",
- R.raw.config_safety_sources_group_invalid_id,
- "Element safety-sources-group invalid",
- "Attribute id invalid"),
- Params(
- "ConfigSafetySourcesGroupNoId",
- R.raw.config_safety_sources_group_no_id,
- "Element safety-sources-group invalid",
- "Required attribute id missing"),
- Params(
- "ConfigSafetySourcesGroupNoTitle",
- R.raw.config_safety_sources_group_no_title,
- "Element safety-sources-group invalid",
- "Required attribute title missing"),
- Params(
- "ConfigSafetySourcesGroupStatefulWithOnlyIssueOnly",
- R.raw.config_safety_sources_group_stateful_with_only_issue_only,
- "Element safety-sources-group invalid",
- "Safety sources groups containing only sources of type issue-only must be of " +
- "type hidden",
- SdkLevel.isAtLeastU()),
- Params(
- "ConfigSafetySourcesGroupStatelessWithOnlyIssueOnly",
- R.raw.config_safety_sources_group_stateless_with_only_issue_only,
- "Element safety-sources-group invalid",
- "Safety sources groups containing only sources of type issue-only must be of " +
- "type hidden",
- SdkLevel.isAtLeastU()),
- Params(
- "ConfigStaticSafetySourceDuplicateKey",
- R.raw.config_static_safety_source_duplicate_key,
- "Element safety-sources-config invalid",
- "Duplicate id id among safety sources"),
- Params(
- "ConfigStaticSafetySourceInvalidId",
- R.raw.config_static_safety_source_invalid_id,
- "Element static-safety-source invalid",
- "Attribute id invalid"),
- Params(
- "ConfigStaticSafetySourceInvalidProfile",
- R.raw.config_static_safety_source_invalid_profile,
- "Attribute value \"invalid\" in static-safety-source.profile invalid",
- null),
- Params(
- "ConfigStaticSafetySourceNoId",
- R.raw.config_static_safety_source_no_id,
- "Element static-safety-source invalid",
- "Required attribute id missing"),
- Params(
- "ConfigStaticSafetySourceNoIntent",
- R.raw.config_static_safety_source_no_intent,
- "Element static-safety-source invalid",
- "Required attribute intentAction missing"),
- Params(
- "ConfigStaticSafetySourceNoProfile",
- R.raw.config_static_safety_source_no_profile,
- "Element static-safety-source invalid",
- "Required attribute profile missing"),
- Params(
- "ConfigStaticSafetySourceNoTitle",
- R.raw.config_static_safety_source_no_title,
- "Element static-safety-source invalid",
- "Required attribute title missing"),
- Params(
- "ConfigStaticSafetySourceWithDeduplicationGroups",
- R.raw.config_static_safety_source_with_deduplication_groups,
- "Element static-safety-source invalid",
- "Prohibited attribute deduplicationGroup present",
- SdkLevel.isAtLeastU()),
- Params(
- "ConfigStaticSafetySourceWithDisplay",
- R.raw.config_static_safety_source_with_display,
- "Element static-safety-source invalid",
- "Prohibited attribute initialDisplayState present"),
- Params(
- "ConfigStaticSafetySourceWithLogging",
- R.raw.config_static_safety_source_with_logging,
- "Element static-safety-source invalid",
- "Prohibited attribute loggingAllowed present"),
- Params(
- "ConfigStaticSafetySourceWithNotifications",
- R.raw.config_static_safety_source_with_notifications,
- "Element static-safety-source invalid",
- "Prohibited attribute notificationsAllowed present",
- SdkLevel.isAtLeastU()),
- Params(
- "ConfigStaticSafetySourceWithPackage",
- R.raw.config_static_safety_source_with_package,
- "Element static-safety-source invalid",
- "Prohibited attribute packageName present",
- !SdkLevel.isAtLeastU()),
- Params(
- "ConfigStaticSafetySourceWithPackageCertficates",
- R.raw.config_static_safety_source_with_package_certs,
- "Element static-safety-source invalid",
- "Prohibited attribute packageCertificateHashes present",
- SdkLevel.isAtLeastU()),
- Params(
- "ConfigStaticSafetySourceWithPrimaryAndWork",
- R.raw.config_static_safety_source_with_primary_and_work,
- "Element static-safety-source invalid",
- "Prohibited attribute titleForWork present"),
- Params(
- "ConfigStaticSafetySourceWithRefresh",
- R.raw.config_static_safety_source_with_refresh,
- "Element static-safety-source invalid",
- "Prohibited attribute refreshOnPageOpenAllowed present"),
- Params(
- "ConfigStaticSafetySourceWithSeverity",
- R.raw.config_static_safety_source_with_severity,
- "Element static-safety-source invalid",
- "Prohibited attribute maxSeverityLevel present"),
- Params(
- "ConfigStringResourceNameInvalidEmpty",
- R.raw.config_string_resource_name_empty,
- "Resource name in safety-sources-group.title cannot be empty",
- null),
- Params(
- "ConfigStringResourceNameInvalidNoAt",
- R.raw.config_string_resource_name_invalid_no_at,
- "Resource name \"com.android.safetycenter.config.tests:string/reference\" in " +
- "safety-sources-group.title does not start with @",
- null),
- Params(
- "ConfigStringResourceNameInvalidNoPackage",
- R.raw.config_string_resource_name_invalid_no_package,
- "Resource name \"@string/reference\" in safety-sources-group.title does not " +
- "specify a package",
- null),
- Params(
- "ConfigStringResourceNameInvalidNoType",
- R.raw.config_string_resource_name_invalid_no_type,
- "Resource name \"@com.android.safetycenter.config.tests:reference\" in " +
- "safety-sources-group.title does not specify a type",
- null),
- Params(
- "ConfigStringResourceNameInvalidWrongType",
- R.raw.config_string_resource_name_invalid_wrong_type,
- "Resource name \"@com.android.safetycenter.config.tests:raw/" +
- "config_string_resource_name_invalid_wrong_type\" in " +
- "safety-sources-group.title is not a string",
- null),
- Params(
- "ConfigStringResourceNameMissing",
- R.raw.config_string_resource_name_missing,
- "Resource name \"@com.android.safetycenter.config.tests:string/missing\" in " +
- "safety-sources-group.title missing or invalid",
- null))
+ Params(
+ "ConfigDynamicSafetySourceAllDisabledNoWork",
+ R.raw.config_dynamic_safety_source_all_disabled_no_work,
+ "Element dynamic-safety-source invalid",
+ "Required attribute titleForWork missing"
+ ),
+ Params(
+ "ConfigDynamicSafetySourceAllHiddenWithSearchNoWork",
+ R.raw.config_dynamic_safety_source_all_hidden_with_search_no_work,
+ "Element dynamic-safety-source invalid",
+ "Required attribute titleForWork missing"
+ ),
+ Params(
+ "ConfigDynamicSafetySourceAllNoWork",
+ R.raw.config_dynamic_safety_source_all_no_work,
+ "Element dynamic-safety-source invalid",
+ "Required attribute titleForWork missing"
+ ),
+ Params(
+ "ConfigDynamicSafetySourceDisabledNoSummary",
+ R.raw.config_dynamic_safety_source_disabled_no_summary,
+ "Element dynamic-safety-source invalid",
+ "Required attribute summary missing"
+ ),
+ Params(
+ "ConfigDynamicSafetySourceDisabledNoTitle",
+ R.raw.config_dynamic_safety_source_disabled_no_title,
+ "Element dynamic-safety-source invalid",
+ "Required attribute title missing"
+ ),
+ Params(
+ "ConfigDynamicSafetySourceDuplicateKey",
+ R.raw.config_dynamic_safety_source_duplicate_key,
+ "Element safety-sources-config invalid",
+ "Duplicate id id among safety sources"
+ ),
+ Params(
+ "ConfigDynamicSafetySourceHiddenWithSearchNoTitle",
+ R.raw.config_dynamic_safety_source_hidden_with_search_no_title,
+ "Element dynamic-safety-source invalid",
+ "Required attribute title missing"
+ ),
+ Params(
+ "ConfigDynamicSafetySourceInvalidDisplay",
+ R.raw.config_dynamic_safety_source_invalid_display,
+ "Attribute value \"invalid\" in " +
+ "dynamic-safety-source.initialDisplayState invalid",
+ null
+ ),
+ Params(
+ "ConfigDynamicSafetySourceInvalidId",
+ R.raw.config_dynamic_safety_source_invalid_id,
+ "Element dynamic-safety-source invalid",
+ "Attribute id invalid"
+ ),
+ Params(
+ "ConfigDynamicSafetySourceInvalidProfile",
+ R.raw.config_dynamic_safety_source_invalid_profile,
+ "Attribute value \"invalid\" in dynamic-safety-source.profile invalid",
+ null
+ ),
+ Params(
+ "ConfigDynamicSafetySourceNoId",
+ R.raw.config_dynamic_safety_source_no_id,
+ "Element dynamic-safety-source invalid",
+ "Required attribute id missing"
+ ),
+ Params(
+ "ConfigDynamicSafetySourceNoIntent",
+ R.raw.config_dynamic_safety_source_no_intent,
+ "Element dynamic-safety-source invalid",
+ "Required attribute intentAction missing"
+ ),
+ Params(
+ "ConfigDynamicSafetySourceNoPackage",
+ R.raw.config_dynamic_safety_source_no_package,
+ "Element dynamic-safety-source invalid",
+ "Required attribute packageName missing"
+ ),
+ Params(
+ "ConfigDynamicSafetySourceNoProfile",
+ R.raw.config_dynamic_safety_source_no_profile,
+ "Element dynamic-safety-source invalid",
+ "Required attribute profile missing"
+ ),
+ Params(
+ "ConfigDynamicSafetySourceNoSummary",
+ R.raw.config_dynamic_safety_source_no_summary,
+ "Element dynamic-safety-source invalid",
+ "Required attribute summary missing"
+ ),
+ Params(
+ "ConfigDynamicSafetySourceNoTitle",
+ R.raw.config_dynamic_safety_source_no_title,
+ "Element dynamic-safety-source invalid",
+ "Required attribute title missing"
+ ),
+ Params(
+ "ConfigDynamicSafetySourcePrimaryHiddenWithWork",
+ R.raw.config_dynamic_safety_source_primary_hidden_with_work,
+ "Element dynamic-safety-source invalid",
+ "Prohibited attribute titleForWork present"
+ ),
+ Params(
+ "ConfigDynamicSafetySourcePrimaryWithWork",
+ R.raw.config_dynamic_safety_source_primary_with_work,
+ "Element dynamic-safety-source invalid",
+ "Prohibited attribute titleForWork present"
+ ),
+ Params(
+ "ConfigFileCorrupted",
+ R.raw.config_file_corrupted,
+ "Exception while parsing the XML resource",
+ null
+ ),
+ Params(
+ "ConfigIssueOnlySafetySourceDuplicateKey",
+ R.raw.config_issue_only_safety_source_duplicate_key,
+ "Element safety-sources-config invalid",
+ "Duplicate id id among safety sources"
+ ),
+ Params(
+ "ConfigIssueOnlySafetySourceInvalidId",
+ R.raw.config_issue_only_safety_source_invalid_id,
+ "Element issue-only-safety-source invalid",
+ "Attribute id invalid"
+ ),
+ Params(
+ "ConfigIssueOnlySafetySourceInvalidProfile",
+ R.raw.config_issue_only_safety_source_invalid_profile,
+ "Attribute value \"invalid\" in issue-only-safety-source.profile invalid",
+ null
+ ),
+ Params(
+ "ConfigIssueOnlySafetySourceNoId",
+ R.raw.config_issue_only_safety_source_no_id,
+ "Element issue-only-safety-source invalid",
+ "Required attribute id missing"
+ ),
+ Params(
+ "ConfigIssueOnlySafetySourceNoPackage",
+ R.raw.config_issue_only_safety_source_no_package,
+ "Element issue-only-safety-source invalid",
+ "Required attribute packageName missing"
+ ),
+ Params(
+ "ConfigIssueOnlySafetySourceNoProfile",
+ R.raw.config_issue_only_safety_source_no_profile,
+ "Element issue-only-safety-source invalid",
+ "Required attribute profile missing"
+ ),
+ Params(
+ "ConfigIssueOnlySafetySourceWithDisplay",
+ R.raw.config_issue_only_safety_source_with_display,
+ "Element issue-only-safety-source invalid",
+ "Prohibited attribute initialDisplayState present"
+ ),
+ Params(
+ "ConfigIssueOnlySafetySourceWithIntent",
+ R.raw.config_issue_only_safety_source_with_intent,
+ "Element issue-only-safety-source invalid",
+ "Prohibited attribute intentAction present"
+ ),
+ Params(
+ "ConfigIssueOnlySafetySourceWithSearch",
+ R.raw.config_issue_only_safety_source_with_search,
+ "Element issue-only-safety-source invalid",
+ "Prohibited attribute searchTerms present"
+ ),
+ Params(
+ "ConfigIssueOnlySafetySourceWithSummary",
+ R.raw.config_issue_only_safety_source_with_summary,
+ "Element issue-only-safety-source invalid",
+ "Prohibited attribute summary present"
+ ),
+ Params(
+ "ConfigIssueOnlySafetySourceWithTitle",
+ R.raw.config_issue_only_safety_source_with_title,
+ "Element issue-only-safety-source invalid",
+ "Prohibited attribute title present"
+ ),
+ Params(
+ "ConfigIssueOnlySafetySourceWithWork",
+ R.raw.config_issue_only_safety_source_with_work,
+ "Element issue-only-safety-source invalid",
+ "Prohibited attribute titleForWork present"
+ ),
+ Params(
+ "ConfigMixedSafetySourceDuplicateKey",
+ R.raw.config_mixed_safety_source_duplicate_key,
+ "Element safety-sources-config invalid",
+ "Duplicate id id among safety sources"
+ ),
+ Params(
+ "ConfigSafetyCenterConfigMissing",
+ R.raw.config_safety_center_config_missing,
+ "Element safety-center-config missing",
+ null
+ ),
+ Params(
+ "ConfigSafetySourcesConfigEmpty",
+ R.raw.config_safety_sources_config_empty,
+ "Element safety-sources-config invalid",
+ "No safety sources groups present"
+ ),
+ Params(
+ "ConfigSafetySourcesConfigMissing",
+ R.raw.config_safety_sources_config_missing,
+ "Element safety-sources-config missing",
+ null
+ ),
+ Params(
+ "ConfigSafetySourcesGroupDuplicateId",
+ R.raw.config_safety_sources_group_duplicate_id,
+ "Element safety-sources-config invalid",
+ "Duplicate id id among safety sources groups"
+ ),
+ Params(
+ "ConfigSafetySourcesGroupEmpty",
+ R.raw.config_safety_sources_group_empty,
+ "Element safety-sources-group invalid",
+ "Safety sources group empty"
+ ),
+ Params(
+ "ConfigSafetySourcesGroupHiddenWithOnlyDynamic",
+ R.raw.config_safety_sources_group_hidden_with_only_dynamic,
+ "Element safety-sources-group invalid",
+ "Safety sources groups of type hidden can only contain sources of type " +
+ "issue-only",
+ SdkLevel.isAtLeastU()
+ ),
+ Params(
+ "ConfigSafetySourcesGroupHiddenWithOnlyStatic",
+ R.raw.config_safety_sources_group_hidden_with_only_static,
+ "Element safety-sources-group invalid",
+ "Safety sources groups of type hidden can only contain sources of type " +
+ "issue-only",
+ SdkLevel.isAtLeastU()
+ ),
+ Params(
+ "ConfigSafetySourcesGroupInvalidIcon",
+ R.raw.config_safety_sources_group_invalid_icon,
+ "Attribute value \"invalid\" in safety-sources-group.statelessIconType " +
+ "invalid",
+ null
+ ),
+ Params(
+ "ConfigSafetySourcesGroupInvalidId",
+ R.raw.config_safety_sources_group_invalid_id,
+ "Element safety-sources-group invalid",
+ "Attribute id invalid"
+ ),
+ Params(
+ "ConfigSafetySourcesGroupNoId",
+ R.raw.config_safety_sources_group_no_id,
+ "Element safety-sources-group invalid",
+ "Required attribute id missing"
+ ),
+ Params(
+ "ConfigSafetySourcesGroupNoTitle",
+ R.raw.config_safety_sources_group_no_title,
+ "Element safety-sources-group invalid",
+ "Required attribute title missing"
+ ),
+ Params(
+ "ConfigSafetySourcesGroupStatefulWithOnlyIssueOnly",
+ R.raw.config_safety_sources_group_stateful_with_only_issue_only,
+ "Element safety-sources-group invalid",
+ "Safety sources groups containing only sources of type issue-only must " +
+ "be of type hidden",
+ SdkLevel.isAtLeastU()
+ ),
+ Params(
+ "ConfigSafetySourcesGroupStatelessWithOnlyIssueOnly",
+ R.raw.config_safety_sources_group_stateless_with_only_issue_only,
+ "Element safety-sources-group invalid",
+ "Safety sources groups containing only sources of type issue-only must " +
+ "be of type hidden",
+ SdkLevel.isAtLeastU()
+ ),
+ Params(
+ "ConfigStaticSafetySourceDuplicateKey",
+ R.raw.config_static_safety_source_duplicate_key,
+ "Element safety-sources-config invalid",
+ "Duplicate id id among safety sources"
+ ),
+ Params(
+ "ConfigStaticSafetySourceInvalidId",
+ R.raw.config_static_safety_source_invalid_id,
+ "Element static-safety-source invalid",
+ "Attribute id invalid"
+ ),
+ Params(
+ "ConfigStaticSafetySourceInvalidProfile",
+ R.raw.config_static_safety_source_invalid_profile,
+ "Attribute value \"invalid\" in static-safety-source.profile invalid",
+ null
+ ),
+ Params(
+ "ConfigStaticSafetySourceNoId",
+ R.raw.config_static_safety_source_no_id,
+ "Element static-safety-source invalid",
+ "Required attribute id missing"
+ ),
+ Params(
+ "ConfigStaticSafetySourceNoIntent",
+ R.raw.config_static_safety_source_no_intent,
+ "Element static-safety-source invalid",
+ "Required attribute intentAction missing"
+ ),
+ Params(
+ "ConfigStaticSafetySourceNoProfile",
+ R.raw.config_static_safety_source_no_profile,
+ "Element static-safety-source invalid",
+ "Required attribute profile missing"
+ ),
+ Params(
+ "ConfigStaticSafetySourceNoTitle",
+ R.raw.config_static_safety_source_no_title,
+ "Element static-safety-source invalid",
+ "Required attribute title missing"
+ ),
+ Params(
+ "ConfigStaticSafetySourceWithDeduplicationGroups",
+ R.raw.config_static_safety_source_with_deduplication_groups,
+ "Element static-safety-source invalid",
+ "Prohibited attribute deduplicationGroup present",
+ SdkLevel.isAtLeastU()
+ ),
+ Params(
+ "ConfigStaticSafetySourceWithDisplay",
+ R.raw.config_static_safety_source_with_display,
+ "Element static-safety-source invalid",
+ "Prohibited attribute initialDisplayState present"
+ ),
+ Params(
+ "ConfigStaticSafetySourceWithLogging",
+ R.raw.config_static_safety_source_with_logging,
+ "Element static-safety-source invalid",
+ "Prohibited attribute loggingAllowed present"
+ ),
+ Params(
+ "ConfigStaticSafetySourceWithNotifications",
+ R.raw.config_static_safety_source_with_notifications,
+ "Element static-safety-source invalid",
+ "Prohibited attribute notificationsAllowed present",
+ SdkLevel.isAtLeastU()
+ ),
+ Params(
+ "ConfigStaticSafetySourceWithPackage",
+ R.raw.config_static_safety_source_with_package,
+ "Element static-safety-source invalid",
+ "Prohibited attribute packageName present",
+ !SdkLevel.isAtLeastU()
+ ),
+ Params(
+ "ConfigStaticSafetySourceWithPackageCertficates",
+ R.raw.config_static_safety_source_with_package_certs,
+ "Element static-safety-source invalid",
+ "Prohibited attribute packageCertificateHashes present",
+ SdkLevel.isAtLeastU()
+ ),
+ Params(
+ "ConfigStaticSafetySourceWithPrimaryAndWork",
+ R.raw.config_static_safety_source_with_primary_and_work,
+ "Element static-safety-source invalid",
+ "Prohibited attribute titleForWork present"
+ ),
+ Params(
+ "ConfigStaticSafetySourceWithRefresh",
+ R.raw.config_static_safety_source_with_refresh,
+ "Element static-safety-source invalid",
+ "Prohibited attribute refreshOnPageOpenAllowed present"
+ ),
+ Params(
+ "ConfigStaticSafetySourceWithSeverity",
+ R.raw.config_static_safety_source_with_severity,
+ "Element static-safety-source invalid",
+ "Prohibited attribute maxSeverityLevel present"
+ ),
+ Params(
+ "ConfigStringResourceNameInvalidEmpty",
+ R.raw.config_string_resource_name_empty,
+ "Resource name in safety-sources-group.title cannot be empty",
+ null
+ ),
+ Params(
+ "ConfigStringResourceNameInvalidNoAt",
+ R.raw.config_string_resource_name_invalid_no_at,
+ "Resource name " +
+ "\"com.android.safetycenter.config.tests:string/reference\" in " +
+ "safety-sources-group.title does not start with @",
+ null
+ ),
+ Params(
+ "ConfigStringResourceNameInvalidNoPackage",
+ R.raw.config_string_resource_name_invalid_no_package,
+ "Resource name \"@string/reference\" in safety-sources-group.title does " +
+ "not specify a package",
+ null
+ ),
+ Params(
+ "ConfigStringResourceNameInvalidNoType",
+ R.raw.config_string_resource_name_invalid_no_type,
+ "Resource name \"@com.android.safetycenter.config.tests:reference\" in " +
+ "safety-sources-group.title does not specify a type",
+ null
+ ),
+ Params(
+ "ConfigStringResourceNameInvalidWrongType",
+ R.raw.config_string_resource_name_invalid_wrong_type,
+ "Resource name \"@com.android.safetycenter.config.tests:raw/" +
+ "config_string_resource_name_invalid_wrong_type\" in " +
+ "safety-sources-group.title is not a string",
+ null
+ ),
+ Params(
+ "ConfigStringResourceNameMissing",
+ R.raw.config_string_resource_name_missing,
+ "Resource name \"@com.android.safetycenter.config.tests:string/missing\" " +
+ "in safety-sources-group.title missing or invalid",
+ null
+ )
+ )
.filter { it.includeCondition }
}
}
diff --git a/SafetyCenter/Config/tests/java/com/android/safetycenter/config/ParserConfigOverlayTest.kt b/SafetyCenter/Config/tests/java/com/android/safetycenter/config/ParserConfigOverlayTest.kt
index cd0643371..e8d7fc87e 100644
--- a/SafetyCenter/Config/tests/java/com/android/safetycenter/config/ParserConfigOverlayTest.kt
+++ b/SafetyCenter/Config/tests/java/com/android/safetycenter/config/ParserConfigOverlayTest.kt
@@ -113,7 +113,8 @@ class ParserConfigOverlayTest {
.hasMessageThat()
.isEqualTo(
"Resource name \"@com.android.safetycenter.config.tests:string/reference_overlay" +
- "\" in static-safety-source.summary missing or invalid")
+ "\" in static-safety-source.summary missing or invalid"
+ )
}
companion object {
diff --git a/SafetyCenter/Config/tests/java/com/android/safetycenter/config/ParserConfigValidTest.kt b/SafetyCenter/Config/tests/java/com/android/safetycenter/config/ParserConfigValidTest.kt
index 8bf445b38..b63ccead7 100644
--- a/SafetyCenter/Config/tests/java/com/android/safetycenter/config/ParserConfigValidTest.kt
+++ b/SafetyCenter/Config/tests/java/com/android/safetycenter/config/ParserConfigValidTest.kt
@@ -54,7 +54,8 @@ class ParserConfigValidTest {
.setSummaryResId(R.string.reference)
.setIntentAction("intent")
.setProfile(SafetySource.PROFILE_PRIMARY)
- .build())
+ .build()
+ )
.addSafetySource(
SafetySource.Builder(SafetySource.SAFETY_SOURCE_TYPE_DYNAMIC)
.setId("dynamic_all_optional")
@@ -77,7 +78,8 @@ class ParserConfigValidTest {
addPackageCertificateHash("feed2")
}
}
- .build())
+ .build()
+ )
.addSafetySource(
SafetySource.Builder(SafetySource.SAFETY_SOURCE_TYPE_DYNAMIC)
.setId("dynamic_all_references")
@@ -100,7 +102,8 @@ class ParserConfigValidTest {
addPackageCertificateHash("feed2")
}
}
- .build())
+ .build()
+ )
.addSafetySource(
SafetySource.Builder(SafetySource.SAFETY_SOURCE_TYPE_DYNAMIC)
.setId("dynamic_disabled")
@@ -109,14 +112,16 @@ class ParserConfigValidTest {
.setSummaryResId(R.string.reference)
.setProfile(SafetySource.PROFILE_PRIMARY)
.setInitialDisplayState(SafetySource.INITIAL_DISPLAY_STATE_DISABLED)
- .build())
+ .build()
+ )
.addSafetySource(
SafetySource.Builder(SafetySource.SAFETY_SOURCE_TYPE_DYNAMIC)
.setId("dynamic_hidden")
.setPackageName("package")
.setProfile(SafetySource.PROFILE_ALL)
.setInitialDisplayState(SafetySource.INITIAL_DISPLAY_STATE_HIDDEN)
- .build())
+ .build()
+ )
.addSafetySource(
SafetySource.Builder(SafetySource.SAFETY_SOURCE_TYPE_DYNAMIC)
.setId("dynamic_hidden_with_search")
@@ -128,8 +133,10 @@ class ParserConfigValidTest {
.setProfile(SafetySource.PROFILE_ALL)
.setInitialDisplayState(SafetySource.INITIAL_DISPLAY_STATE_HIDDEN)
.setSearchTermsResId(R.string.reference)
- .build())
- .build())
+ .build()
+ )
+ .build()
+ )
.addSafetySourcesGroup(
SafetySourcesGroup.Builder()
.setId("static")
@@ -140,7 +147,8 @@ class ParserConfigValidTest {
.setTitleResId(R.string.reference)
.setIntentAction("intent")
.setProfile(SafetySource.PROFILE_PRIMARY)
- .build())
+ .build()
+ )
.addSafetySource(
SafetySource.Builder(SafetySource.SAFETY_SOURCE_TYPE_STATIC)
.setId("static_all_optional")
@@ -151,8 +159,10 @@ class ParserConfigValidTest {
.setIntentAction("intent")
.setProfile(SafetySource.PROFILE_ALL)
.setSearchTermsResId(R.string.reference)
- .build())
- .build())
+ .build()
+ )
+ .build()
+ )
.addSafetySourcesGroup(
SafetySourcesGroup.Builder()
.setId("issue_only")
@@ -161,7 +171,8 @@ class ParserConfigValidTest {
.setId("issue_only_barebone")
.setPackageName("package")
.setProfile(SafetySource.PROFILE_PRIMARY)
- .build())
+ .build()
+ )
.addSafetySource(
SafetySource.Builder(SafetySource.SAFETY_SOURCE_TYPE_ISSUE_ONLY)
.setId("issue_only_all_optional")
@@ -178,14 +189,17 @@ class ParserConfigValidTest {
addPackageCertificateHash("feed2")
}
}
- .build())
+ .build()
+ )
.addSafetySource(
SafetySource.Builder(SafetySource.SAFETY_SOURCE_TYPE_ISSUE_ONLY)
.setId("id_test_abcxyz_ABCXYZ_012789")
.setPackageName("package")
.setProfile(SafetySource.PROFILE_PRIMARY)
- .build())
- .build())
+ .build()
+ )
+ .build()
+ )
.addSafetySourcesGroup(
SafetySourcesGroup.Builder()
.setId("mixed")
@@ -198,21 +212,25 @@ class ParserConfigValidTest {
.setSummaryResId(R.string.reference)
.setIntentAction("intent")
.setProfile(SafetySource.PROFILE_PRIMARY)
- .build())
+ .build()
+ )
.addSafetySource(
SafetySource.Builder(SafetySource.SAFETY_SOURCE_TYPE_ISSUE_ONLY)
.setId("mixed_issue_only_barebone")
.setPackageName("package")
.setProfile(SafetySource.PROFILE_PRIMARY)
- .build())
+ .build()
+ )
.addSafetySource(
SafetySource.Builder(SafetySource.SAFETY_SOURCE_TYPE_STATIC)
.setId("mixed_static_barebone")
.setTitleResId(R.string.reference)
.setIntentAction("intent")
.setProfile(SafetySource.PROFILE_PRIMARY)
- .build())
- .build())
+ .build()
+ )
+ .build()
+ )
.apply {
if (SdkLevel.isAtLeastU()) {
addSafetySourcesGroup(
@@ -226,8 +244,10 @@ class ParserConfigValidTest {
.setTitleResId(R.string.reference)
.setIntentAction("intent")
.setProfile(SafetySource.PROFILE_PRIMARY)
- .build())
- .build())
+ .build()
+ )
+ .build()
+ )
addSafetySourcesGroup(
SafetySourcesGroup.Builder()
.setType(SafetySourcesGroup.SAFETY_SOURCES_GROUP_TYPE_STATEFUL)
@@ -235,15 +255,18 @@ class ParserConfigValidTest {
.setTitleResId(R.string.reference)
.setSummaryResId(R.string.reference)
.setStatelessIconType(
- SafetySourcesGroup.STATELESS_ICON_TYPE_PRIVACY)
+ SafetySourcesGroup.STATELESS_ICON_TYPE_PRIVACY
+ )
.addSafetySource(
SafetySource.Builder(SafetySource.SAFETY_SOURCE_TYPE_STATIC)
.setId("stateful_all_optional_source")
.setTitleResId(R.string.reference)
.setIntentAction("intent")
.setProfile(SafetySource.PROFILE_PRIMARY)
- .build())
- .build())
+ .build()
+ )
+ .build()
+ )
addSafetySourcesGroup(
SafetySourcesGroup.Builder()
.setType(SafetySourcesGroup.SAFETY_SOURCES_GROUP_TYPE_STATELESS)
@@ -255,8 +278,10 @@ class ParserConfigValidTest {
.setTitleResId(R.string.reference)
.setIntentAction("intent")
.setProfile(SafetySource.PROFILE_PRIMARY)
- .build())
- .build())
+ .build()
+ )
+ .build()
+ )
addSafetySourcesGroup(
SafetySourcesGroup.Builder()
.setType(SafetySourcesGroup.SAFETY_SOURCES_GROUP_TYPE_STATELESS)
@@ -264,15 +289,18 @@ class ParserConfigValidTest {
.setTitleResId(R.string.reference)
.setSummaryResId(R.string.reference)
.setStatelessIconType(
- SafetySourcesGroup.STATELESS_ICON_TYPE_PRIVACY)
+ SafetySourcesGroup.STATELESS_ICON_TYPE_PRIVACY
+ )
.addSafetySource(
SafetySource.Builder(SafetySource.SAFETY_SOURCE_TYPE_STATIC)
.setId("stateless_all_optional_source")
.setTitleResId(R.string.reference)
.setIntentAction("intent")
.setProfile(SafetySource.PROFILE_PRIMARY)
- .build())
- .build())
+ .build()
+ )
+ .build()
+ )
addSafetySourcesGroup(
SafetySourcesGroup.Builder()
.setType(SafetySourcesGroup.SAFETY_SOURCES_GROUP_TYPE_HIDDEN)
@@ -282,8 +310,10 @@ class ParserConfigValidTest {
.setId("hidden_barebone_source")
.setPackageName("package")
.setProfile(SafetySource.PROFILE_PRIMARY)
- .build())
- .build())
+ .build()
+ )
+ .build()
+ )
addSafetySourcesGroup(
SafetySourcesGroup.Builder()
.setType(SafetySourcesGroup.SAFETY_SOURCES_GROUP_TYPE_HIDDEN)
@@ -291,14 +321,17 @@ class ParserConfigValidTest {
.setTitleResId(R.string.reference)
.setSummaryResId(R.string.reference)
.setStatelessIconType(
- SafetySourcesGroup.STATELESS_ICON_TYPE_PRIVACY)
+ SafetySourcesGroup.STATELESS_ICON_TYPE_PRIVACY
+ )
.addSafetySource(
SafetySource.Builder(SafetySource.SAFETY_SOURCE_TYPE_ISSUE_ONLY)
.setId("hidden_all_optional_source")
.setPackageName("package")
.setProfile(SafetySource.PROFILE_PRIMARY)
- .build())
- .build())
+ .build()
+ )
+ .build()
+ )
}
}
.build()
diff --git a/SafetyCenter/ConfigLintChecker/java/android/safetycenter/lint/ConfigLintCheckerIssueRegistry.kt b/SafetyCenter/ConfigLintChecker/java/android/safetycenter/lint/ConfigLintCheckerIssueRegistry.kt
index 8b9148dfb..205809957 100644
--- a/SafetyCenter/ConfigLintChecker/java/android/safetycenter/lint/ConfigLintCheckerIssueRegistry.kt
+++ b/SafetyCenter/ConfigLintChecker/java/android/safetycenter/lint/ConfigLintCheckerIssueRegistry.kt
@@ -24,10 +24,7 @@ import com.google.auto.service.AutoService
@AutoService(IssueRegistry::class)
@Suppress("UnstableApiUsage")
class ConfigLintCheckerIssueRegistry : IssueRegistry() {
- override val issues = listOf(
- ConfigSchemaDetector.ISSUE,
- ParserExceptionDetector.ISSUE
- )
+ override val issues = listOf(ConfigSchemaDetector.ISSUE, ParserExceptionDetector.ISSUE)
override val api: Int
get() = CURRENT_API
@@ -35,9 +32,10 @@ class ConfigLintCheckerIssueRegistry : IssueRegistry() {
override val minApi: Int
get() = 11
- override val vendor = Vendor(
- vendorName = "Android",
- feedbackUrl = "http://b/issues/new?component=1026964",
- contact = "fiscella@google.com"
- )
+ override val vendor =
+ Vendor(
+ vendorName = "Android",
+ feedbackUrl = "http://b/issues/new?component=1026964",
+ contact = "fiscella@google.com"
+ )
}
diff --git a/SafetyCenter/ConfigLintChecker/java/android/safetycenter/lint/ConfigSchemaDetector.kt b/SafetyCenter/ConfigLintChecker/java/android/safetycenter/lint/ConfigSchemaDetector.kt
index 0b00805c2..456ef1171 100644
--- a/SafetyCenter/ConfigLintChecker/java/android/safetycenter/lint/ConfigSchemaDetector.kt
+++ b/SafetyCenter/ConfigLintChecker/java/android/safetycenter/lint/ConfigSchemaDetector.kt
@@ -49,7 +49,8 @@ class ConfigSchemaDetector : Detector(), OtherFileScanner {
severity = Severity.ERROR,
implementation =
Implementation(ConfigSchemaDetector::class.java, Scope.OTHER_SCOPE),
- androidSpecific = true)
+ androidSpecific = true
+ )
}
override fun appliesTo(folderType: ResourceFolderType): Boolean {
@@ -74,7 +75,8 @@ class ConfigSchemaDetector : Detector(), OtherFileScanner {
context.report(
ISSUE,
Location.create(context.file),
- "No schema found for SDK level: $fileSdk, was it deleted?")
+ "No schema found for SDK level: $fileSdk, was it deleted?"
+ )
}
// Test new schemas for backward compatibility.
for (sdk in fileSdk + 1..FileSdk.getMaxSdkVersion()) {
@@ -95,12 +97,14 @@ class ConfigSchemaDetector : Detector(), OtherFileScanner {
context.report(
ISSUE,
Location.create(context.file),
- "SAXException exception at sdk=$sdk: \"${e.message}\"")
+ "SAXException exception at sdk=$sdk: \"${e.message}\""
+ )
} catch (e: IOException) {
context.report(
ISSUE,
Location.create(context.file),
- "IOException exception at sdk=$sdk: \"${e.message}\"")
+ "IOException exception at sdk=$sdk: \"${e.message}\""
+ )
}
return true
}
diff --git a/SafetyCenter/ConfigLintChecker/java/android/safetycenter/lint/ParserExceptionDetector.kt b/SafetyCenter/ConfigLintChecker/java/android/safetycenter/lint/ParserExceptionDetector.kt
index 09f074818..d8656f889 100644
--- a/SafetyCenter/ConfigLintChecker/java/android/safetycenter/lint/ParserExceptionDetector.kt
+++ b/SafetyCenter/ConfigLintChecker/java/android/safetycenter/lint/ParserExceptionDetector.kt
@@ -55,8 +55,10 @@ class ParserExceptionDetector : Detector(), OtherFileScanner, XmlScanner {
implementation =
Implementation(
ParserExceptionDetector::class.java,
- EnumSet.of(Scope.RESOURCE_FILE, Scope.OTHER)),
- androidSpecific = true)
+ EnumSet.of(Scope.RESOURCE_FILE, Scope.OTHER)
+ ),
+ androidSpecific = true
+ )
val STRING_MAP_BUILD_PHASE = 1
val CONFIG_PARSE_PHASE = 2
@@ -80,8 +82,10 @@ class ParserExceptionDetector : Detector(), OtherFileScanner, XmlScanner {
}
override fun visitElement(context: XmlContext, element: Element) {
- if (context.driver.phase != STRING_MAP_BUILD_PHASE ||
- context.resourceFolderType != ResourceFolderType.VALUES) {
+ if (
+ context.driver.phase != STRING_MAP_BUILD_PHASE ||
+ context.resourceFolderType != ResourceFolderType.VALUES
+ ) {
return
}
val name = element.getAttribute(ATTR_NAME)
@@ -100,8 +104,10 @@ class ParserExceptionDetector : Detector(), OtherFileScanner, XmlScanner {
/** Implements OtherFileScanner and parses the XML config in the second phase */
override fun run(context: Context) {
- if (context.driver.phase != CONFIG_PARSE_PHASE ||
- context.file.name != "safety_center_config.xml") {
+ if (
+ context.driver.phase != CONFIG_PARSE_PHASE ||
+ context.file.name != "safety_center_config.xml"
+ ) {
return
}
val minSdk = FileSdk.getSdkQualifier(context.file)
@@ -123,13 +129,15 @@ class ParserExceptionDetector : Detector(), OtherFileScanner, XmlScanner {
// the target package or on packages that refer to Android global resources.
// However, we cannot use a custom linter with the default soong overlay
// build rule regardless.
- Resources(context.project.`package`, mNameToIndex, mIndexToValue))
+ Resources(context.project.`package`, mNameToIndex, mIndexToValue)
+ )
} catch (e: ParseException) {
context.report(
ISSUE,
Location.create(context.file),
"Parser exception at sdk=$sdk: \"${e.message}\", cause: " +
- "\"${e.cause?.message}\"")
+ "\"${e.cause?.message}\""
+ )
}
}
}
diff --git a/SafetyCenter/ConfigLintChecker/tests/java/android/safetycenter/lint/test/ConfigSchemaDetectorTest.kt b/SafetyCenter/ConfigLintChecker/tests/java/android/safetycenter/lint/test/ConfigSchemaDetectorTest.kt
index 754d1a71f..0931c479b 100644
--- a/SafetyCenter/ConfigLintChecker/tests/java/android/safetycenter/lint/test/ConfigSchemaDetectorTest.kt
+++ b/SafetyCenter/ConfigLintChecker/tests/java/android/safetycenter/lint/test/ConfigSchemaDetectorTest.kt
@@ -64,7 +64,9 @@ class ConfigSchemaDetectorTest : LintDetectorTest() {
</safety-sources-group>
</safety-sources-config>
</safety-center-config>
- """)))
+ """
+ ))
+ )
.run()
.expectClean()
}
@@ -91,7 +93,9 @@ class ConfigSchemaDetectorTest : LintDetectorTest() {
</safety-sources-group>
</safety-sources-config>
</safety-center-config>
- """)))
+ """
+ ))
+ )
.run()
.expectClean()
}
@@ -105,7 +109,8 @@ class ConfigSchemaDetectorTest : LintDetectorTest() {
.expect(
"res/raw-v34/safety_center_config.xml: Error: SAXException exception at sdk=34: " +
"\"cvc-elt.1.a: Cannot find the declaration of element 'invalid-root'.\" " +
- "[InvalidSafetyCenterConfigSchema]\n1 errors, 0 warnings")
+ "[InvalidSafetyCenterConfigSchema]\n1 errors, 0 warnings"
+ )
}
@Test
@@ -120,7 +125,8 @@ class ConfigSchemaDetectorTest : LintDetectorTest() {
"[InvalidSafetyCenterConfigSchema]\nres/raw/safety_center_config.xml: " +
"Error: SAXException exception at sdk=34: \"cvc-elt.1.a: Cannot find the " +
"declaration of element 'invalid-root'.\" " +
- "[InvalidSafetyCenterConfigSchema]\n2 errors, 0 warnings")
+ "[InvalidSafetyCenterConfigSchema]\n2 errors, 0 warnings"
+ )
}
@Test
@@ -148,13 +154,16 @@ class ConfigSchemaDetectorTest : LintDetectorTest() {
</safety-sources-group>
</safety-sources-config>
</safety-center-config>
- """)))
+ """
+ ))
+ )
.run()
.expect(
"res/raw/safety_center_config.xml: Error: SAXException exception at sdk=33: " +
"\"cvc-complex-type.3.2.2: Attribute 'notificationsAllowed' is not allowed " +
"to appear in element 'dynamic-safety-source'.\" " +
- "[InvalidSafetyCenterConfigSchema]\n1 errors, 0 warnings")
+ "[InvalidSafetyCenterConfigSchema]\n1 errors, 0 warnings"
+ )
}
@Test
diff --git a/SafetyCenter/ConfigLintChecker/tests/java/android/safetycenter/lint/test/ParserExceptionDetectorTest.kt b/SafetyCenter/ConfigLintChecker/tests/java/android/safetycenter/lint/test/ParserExceptionDetectorTest.kt
index a3030554e..869780eea 100644
--- a/SafetyCenter/ConfigLintChecker/tests/java/android/safetycenter/lint/test/ParserExceptionDetectorTest.kt
+++ b/SafetyCenter/ConfigLintChecker/tests/java/android/safetycenter/lint/test/ParserExceptionDetectorTest.kt
@@ -48,7 +48,8 @@ class ParserExceptionDetectorTest : LintDetectorTest() {
lint()
.files(
xml("res/raw/safety_center_config.xml", VALID_TIRAMISU_CONFIG),
- STRINGS_WITH_REFERENCE_XML)
+ STRINGS_WITH_REFERENCE_XML
+ )
.run()
.expectClean()
}
@@ -58,7 +59,8 @@ class ParserExceptionDetectorTest : LintDetectorTest() {
lint()
.files(
xml("res/raw-99/safety_center_config.xml", VALID_TIRAMISU_CONFIG),
- STRINGS_WITH_REFERENCE_XML)
+ STRINGS_WITH_REFERENCE_XML
+ )
.run()
.expectClean()
}
@@ -72,7 +74,8 @@ class ParserExceptionDetectorTest : LintDetectorTest() {
.expect(
"res/raw-v34/safety_center_config.xml: Error: Parser exception at sdk=34: " +
"\"Element safety-center-config missing\", cause: \"null\" " +
- "[InvalidSafetyCenterConfig]\n1 errors, 0 warnings")
+ "[InvalidSafetyCenterConfig]\n1 errors, 0 warnings"
+ )
}
@Test
@@ -87,7 +90,8 @@ class ParserExceptionDetectorTest : LintDetectorTest() {
"[InvalidSafetyCenterConfig]\nres/raw/safety_center_config.xml: " +
"Error: Parser exception at sdk=34: " +
"\"Element safety-center-config missing\", cause: \"null\" " +
- "[InvalidSafetyCenterConfig]\n2 errors, 0 warnings")
+ "[InvalidSafetyCenterConfig]\n2 errors, 0 warnings"
+ )
}
@Test
@@ -96,12 +100,14 @@ class ParserExceptionDetectorTest : LintDetectorTest() {
lint()
.files(
xml("res/raw/safety_center_config.xml", VALID_UDC_CONFIG),
- STRINGS_WITH_REFERENCE_XML)
+ STRINGS_WITH_REFERENCE_XML
+ )
.run()
.expect(
"res/raw/safety_center_config.xml: Error: Parser exception at sdk=33: " +
"\"Unexpected attribute dynamic-safety-source.notificationsAllowed\", cause: " +
- "\"null\" [InvalidSafetyCenterConfig]\n1 errors, 0 warnings")
+ "\"null\" [InvalidSafetyCenterConfig]\n1 errors, 0 warnings"
+ )
}
@Test
@@ -122,7 +128,8 @@ class ParserExceptionDetectorTest : LintDetectorTest() {
<resources xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">
<string name="reference" translatable="false">Reference</string>
</resources>
- """)
+ """
+ )
const val VALID_TIRAMISU_CONFIG =
"""
diff --git a/SafetyCenter/Persistence/tests/java/com/android/safetycenter/persistence/PersistedSafetyCenterIssueTest.kt b/SafetyCenter/Persistence/tests/java/com/android/safetycenter/persistence/PersistedSafetyCenterIssueTest.kt
index 541d26c74..d88100382 100644
--- a/SafetyCenter/Persistence/tests/java/com/android/safetycenter/persistence/PersistedSafetyCenterIssueTest.kt
+++ b/SafetyCenter/Persistence/tests/java/com/android/safetycenter/persistence/PersistedSafetyCenterIssueTest.kt
@@ -65,7 +65,8 @@ class PersistedSafetyCenterIssueTest {
PersistedSafetyCenterIssue.Builder()
.setKey(ACTIVE_ISSUE_KEY)
.setFirstSeenAt(INSTANT)
- .build())
+ .build()
+ )
.addEqualityGroup(DISMISSED_ISSUE)
.addEqualityGroup(
PersistedSafetyCenterIssue.Builder()
@@ -73,28 +74,32 @@ class PersistedSafetyCenterIssueTest {
.setFirstSeenAt(INSTANT)
.setDismissedAt(INSTANT)
.setDismissCount(1)
- .build())
+ .build()
+ )
.addEqualityGroup(
PersistedSafetyCenterIssue.Builder()
.setKey(DISMISSED_ISSUE_KEY)
.setFirstSeenAt(Instant.ofEpochMilli(0))
.setDismissedAt(INSTANT)
.setDismissCount(1)
- .build())
+ .build()
+ )
.addEqualityGroup(
PersistedSafetyCenterIssue.Builder()
.setKey(DISMISSED_ISSUE_KEY)
.setFirstSeenAt(INSTANT)
.setDismissedAt(Instant.ofEpochMilli(0))
.setDismissCount(1)
- .build())
+ .build()
+ )
.addEqualityGroup(
PersistedSafetyCenterIssue.Builder()
.setKey(DISMISSED_ISSUE_KEY)
.setFirstSeenAt(INSTANT)
.setDismissedAt(INSTANT)
.setDismissCount(99)
- .build())
+ .build()
+ )
.test()
}
diff --git a/SafetyCenter/Persistence/tests/java/com/android/safetycenter/persistence/SafetyCenterIssuesPersistenceInvalidTest.kt b/SafetyCenter/Persistence/tests/java/com/android/safetycenter/persistence/SafetyCenterIssuesPersistenceInvalidTest.kt
index 48af9c0ba..766f38fac 100644
--- a/SafetyCenter/Persistence/tests/java/com/android/safetycenter/persistence/SafetyCenterIssuesPersistenceInvalidTest.kt
+++ b/SafetyCenter/Persistence/tests/java/com/android/safetycenter/persistence/SafetyCenterIssuesPersistenceInvalidTest.kt
@@ -62,79 +62,99 @@ class SafetyCenterIssuesPersistenceInvalidTest {
"Corrupted",
"invalid_file_corrupted.txt",
"Failed to read file: ${PATH}invalid_file_corrupted.txt",
- null),
+ null
+ ),
Params(
"ExtraAttribute",
"invalid_file_extra_attribute.xml",
"Unexpected attribute extra",
- null),
+ null
+ ),
Params(
"ExtraElement",
"invalid_file_extra_element.xml",
"Element issue not closed",
- null),
+ null
+ ),
Params(
"ExtraRoot",
"invalid_file_extra_root.txt",
"Unexpected extra root element",
- null),
+ null
+ ),
Params(
"InconsistentDismissCount",
"invalid_file_inconsistent_dismiss_count.xml",
"Element issue invalid",
- "dismissCount cannot be 0 if dismissedAt is present"),
+ "dismissCount cannot be 0 if dismissedAt is present"
+ ),
Params(
"InconsistentDismissedAt",
"invalid_file_inconsistent_dismissed_at.xml",
"Element issue invalid",
- "dismissedAt must be present if dismissCount is greater than 0"),
+ "dismissedAt must be present if dismissCount is greater than 0"
+ ),
Params(
"InvalidDismissCount",
"invalid_file_invalid_dismiss_count.xml",
"Attribute value \"NaN\" for dismiss_count invalid",
- null),
+ null
+ ),
Params(
"InvalidDismissedAt",
"invalid_file_invalid_dismissed_at.xml",
"Attribute value \"NaN\" for dismissed_at_epoch_millis invalid",
- null),
+ null
+ ),
Params(
"InvalidFirstSeenAt",
"invalid_file_invalid_first_seen_at.xml",
"Attribute value \"NaN\" for first_seen_at_epoch_millis invalid",
- null),
+ null
+ ),
Params(
"InvalidNotificationDismissedAt",
"invalid_file_invalid_notification_dismissed_at.xml",
"Attribute value \"NaN\" for notification_dismissed_at_epoch_millis invalid",
- null),
+ null
+ ),
Params(
"InvalidVersion",
"invalid_file_invalid_version.xml",
"Attribute value \"NaN\" for version invalid",
- null),
+ null
+ ),
Params(
"MissingFirstSeenAt",
"invalid_file_missing_first_seen_at.xml",
"Element issue invalid",
- "Required attribute firstSeenAt missing"),
+ "Required attribute firstSeenAt missing"
+ ),
Params(
"MissingKey",
"invalid_file_missing_key.xml",
"Element issue invalid",
- "Required attribute key missing"),
+ "Required attribute key missing"
+ ),
Params(
- "MissingVersion", "invalid_file_missing_version.xml", "Missing version", null),
+ "MissingVersion",
+ "invalid_file_missing_version.xml",
+ "Missing version",
+ null
+ ),
Params(
"NegativeDismissCount",
"invalid_file_negative_dismiss_count.xml",
"Attribute value \"-1\" for dismiss_count invalid",
- null),
+ null
+ ),
Params("WrongRoot", "invalid_file_wrong_root.xml", "Element issues missing", null),
Params(
"WrongVersion",
"invalid_file_wrong_version.xml",
"Unsupported version: 99",
- null))
+ null
+ )
+ )
}
}
diff --git a/SafetyCenter/Persistence/tests/java/com/android/safetycenter/persistence/SafetyCenterIssuesPersistenceValidTest.kt b/SafetyCenter/Persistence/tests/java/com/android/safetycenter/persistence/SafetyCenterIssuesPersistenceValidTest.kt
index dd37a6837..7a3d7e102 100644
--- a/SafetyCenter/Persistence/tests/java/com/android/safetycenter/persistence/SafetyCenterIssuesPersistenceValidTest.kt
+++ b/SafetyCenter/Persistence/tests/java/com/android/safetycenter/persistence/SafetyCenterIssuesPersistenceValidTest.kt
@@ -56,7 +56,9 @@ class SafetyCenterIssuesPersistenceValidTest {
Params(
"ValidV2",
"valid_file_v2.xml",
- listOf(ISSUE_0, ISSUE_1, ISSUE_2, ISSUE_3, ISSUE_4, ISSUE_5)))
+ listOf(ISSUE_0, ISSUE_1, ISSUE_2, ISSUE_3, ISSUE_4, ISSUE_5)
+ )
+ )
private val ISSUE_0 =
PersistedSafetyCenterIssue.Builder()
diff --git a/SafetyCenter/Persistence/tests/java/com/android/safetycenter/persistence/SafetyCenterIssuesPersistenceWriteTest.kt b/SafetyCenter/Persistence/tests/java/com/android/safetycenter/persistence/SafetyCenterIssuesPersistenceWriteTest.kt
index c5db135f0..b5c6d238a 100644
--- a/SafetyCenter/Persistence/tests/java/com/android/safetycenter/persistence/SafetyCenterIssuesPersistenceWriteTest.kt
+++ b/SafetyCenter/Persistence/tests/java/com/android/safetycenter/persistence/SafetyCenterIssuesPersistenceWriteTest.kt
@@ -83,6 +83,9 @@ class SafetyCenterIssuesPersistenceWriteTest {
.setKey("key5")
.setFirstSeenAt(Instant.ofEpochMilli(1654128000000))
.setNotificationDismissedAt(Instant.ofEpochMilli(1654214400000))
- .build())))
+ .build()
+ )
+ )
+ )
}
}
diff --git a/SafetyCenter/ResourcesLib/tests/java/com/android/safetycenter/resources/SafetyCenterResourcesContextTest.kt b/SafetyCenter/ResourcesLib/tests/java/com/android/safetycenter/resources/SafetyCenterResourcesContextTest.kt
index 8dc258df4..0294adec7 100644
--- a/SafetyCenter/ResourcesLib/tests/java/com/android/safetycenter/resources/SafetyCenterResourcesContextTest.kt
+++ b/SafetyCenter/ResourcesLib/tests/java/com/android/safetycenter/resources/SafetyCenterResourcesContextTest.kt
@@ -65,7 +65,8 @@ class SafetyCenterResourcesContextTest {
"/apex/com.android.permission",
CONFIG_NAME,
0,
- false)
+ false
+ )
assertThat(safetyCenterResourcesContext.resourcesApkPkgName).isNull()
assertThat(safetyCenterResourcesContext.safetyCenterConfig).isNull()
assertThat(safetyCenterResourcesContext.assets).isNull()
@@ -82,7 +83,8 @@ class SafetyCenterResourcesContextTest {
null,
CONFIG_NAME,
PackageManager.MATCH_SYSTEM_ONLY,
- false)
+ false
+ )
assertThat(safetyCenterResourcesContext.resourcesApkPkgName).isNull()
assertThat(safetyCenterResourcesContext.safetyCenterConfig).isNull()
assertThat(safetyCenterResourcesContext.assets).isNull()
@@ -126,9 +128,9 @@ class SafetyCenterResourcesContextTest {
val safetyCenterResourcesContext =
SafetyCenterResourcesContext(context, RESOURCES_APK_ACTION, null, CONFIG_NAME, 0, true)
assertThat(safetyCenterResourcesContext.getDrawableByName("valid_drawable", theme))
- .isNotNull()
+ .isNotNull()
assertThat(safetyCenterResourcesContext.getDrawableByName("invalid_drawable", theme))
- .isNull()
+ .isNull()
}
@Test
@@ -136,7 +138,7 @@ class SafetyCenterResourcesContextTest {
val safetyCenterResourcesContext =
SafetyCenterResourcesContext(context, RESOURCES_APK_ACTION, null, CONFIG_NAME, 0, false)
assertThat(safetyCenterResourcesContext.getDrawableByName("valid_drawable", theme))
- .isNotNull()
+ .isNotNull()
assertFailsWith(Resources.NotFoundException::class) {
safetyCenterResourcesContext.getDrawableByName("invalid_drawable", theme)
}
diff --git a/ktfmt_includes.txt b/ktfmt_includes.txt
index b929b68e7..40d8f07d9 100644
--- a/ktfmt_includes.txt
+++ b/ktfmt_includes.txt
@@ -1 +1,2 @@
++SafetyCenter
+tests