From 2a7084f906021cf5b53d1b6fec762db6ce9ebac8 Mon Sep 17 00:00:00 2001 From: Max Loh <mloh@google.com> Date: Thu, 28 Mar 2024 08:00:16 -0700 Subject: [PATCH] aslgen unit tests Bug: 329902686 Test: Unit tests. Change-Id: I443353c88c18808a4a4491b617bdb8a7f990c908 --- tools/app_metadata_bundles/Android.bp | 3 + .../java/com/android/asllib/AslConverter.java | 3 + .../com/android/asllib/DataTypeConstants.java | 156 ------------- .../AndroidSafetyLabel.java | 4 +- .../AndroidSafetyLabelFactory.java | 3 +- .../asllib/{ => marshallable}/AppInfo.java | 4 +- .../{ => marshallable}/AppInfoFactory.java | 33 +-- .../{ => marshallable}/AslMarshallable.java | 2 +- .../AslMarshallableFactory.java | 2 +- .../{ => marshallable}/DataCategory.java | 6 +- .../DataCategoryFactory.java | 18 +- .../asllib/{ => marshallable}/DataLabels.java | 18 +- .../{ => marshallable}/DataLabelsFactory.java | 4 +- .../asllib/{ => marshallable}/DataType.java | 4 +- .../{ => marshallable}/DataTypeFactory.java | 26 ++- .../{ => marshallable}/DeveloperInfo.java | 4 +- .../DeveloperInfoFactory.java | 3 +- .../{ => marshallable}/SafetyLabels.java | 4 +- .../SafetyLabelsFactory.java | 7 +- .../SystemAppSafetyLabel.java | 4 +- .../SystemAppSafetyLabelFactory.java | 3 +- .../{ => marshallable}/TransparencyInfo.java | 4 +- .../TransparencyInfoFactory.java | 3 +- .../{ => util}/DataCategoryConstants.java | 5 +- .../asllib/util/DataTypeConstants.java | 197 ++++++++++++++++ .../android/asllib/{ => util}/XmlUtils.java | 35 ++- .../android/{aslgen => asllib}/AllTests.java | 11 +- .../{aslgen => asllib}/AslgenTests.java | 47 +--- .../marshallable/AndroidSafetyLabelTest.java | 97 ++++++++ .../asllib/marshallable/AppInfoTest.java | 107 +++++++++ .../asllib/marshallable/DataCategoryTest.java | 216 ++++++++++++++++++ .../asllib/marshallable/DataLabelsTest.java | 102 +++++++++ .../marshallable/DeveloperInfoTest.java | 100 ++++++++ .../asllib/marshallable/SafetyLabelsTest.java | 77 +++++++ .../SystemAppSafetyLabelTest.java | 75 ++++++ .../marshallable/TransparencyInfoTest.java | 75 ++++++ .../android/asllib/testutils/TestUtils.java | 152 ++++++++++++ .../androidsafetylabel/hr/missing-version.xml | 3 + .../androidsafetylabel/hr/valid-empty.xml | 1 + .../hr/with-safety-labels.xml | 4 + .../hr/with-system-app-safety-label.xml | 4 + .../hr/with-transparency-info.xml | 4 + .../androidsafetylabel/od/valid-empty.xml | 3 + .../od/with-safety-labels.xml | 6 + .../od/with-system-app-safety-label.xml | 6 + .../od/with-transparency-info.xml | 4 + .../asllib/appinfo/hr/all-fields-valid.xml | 14 ++ .../asllib/appinfo/od/all-fields-valid.xml | 25 ++ .../hr/data-category-actions-in-app.xml | 17 ++ .../hr/data-category-app-performance.xml | 11 + .../datacategory/hr/data-category-audio.xml | 11 + .../hr/data-category-calendar.xml | 5 + .../hr/data-category-contacts.xml | 5 + .../hr/data-category-email-text-message.xml | 11 + .../hr/data-category-financial.xml | 14 ++ .../hr/data-category-health-fitness.xml | 8 + .../hr/data-category-identifiers.xml | 5 + .../hr/data-category-location.xml | 8 + .../data-category-personal-empty-purpose.xml | 5 + ...data-category-personal-missing-purpose.xml | 4 + .../hr/data-category-personal-partial.xml | 8 + ...ta-category-personal-unrecognized-type.xml | 5 + .../hr/data-category-personal.xml | 31 +++ .../hr/data-category-photo-video.xml | 8 + .../hr/data-category-search-and-browsing.xml | 5 + .../datacategory/hr/data-category-storage.xml | 5 + .../hr/data-category-unrecognized.xml | 5 + .../od/data-category-actions-in-app.xml | 27 +++ .../od/data-category-app-performance.xml | 17 ++ .../datacategory/od/data-category-audio.xml | 17 ++ .../od/data-category-calendar.xml | 7 + .../od/data-category-contacts.xml | 7 + .../od/data-category-email-text-message.xml | 17 ++ .../od/data-category-financial.xml | 22 ++ .../od/data-category-health-fitness.xml | 12 + .../od/data-category-identifiers.xml | 7 + .../od/data-category-location.xml | 12 + .../od/data-category-personal-partial.xml | 13 ++ .../od/data-category-personal.xml | 50 ++++ .../od/data-category-photo-video.xml | 12 + .../od/data-category-search-and-browsing.xml | 7 + .../datacategory/od/data-category-storage.xml | 7 + .../hr/data-labels-accessed-invalid-bool.xml | 7 + .../hr/data-labels-accessed-valid-bool.xml | 6 + .../hr/data-labels-collected-invalid-bool.xml | 7 + .../hr/data-labels-collected-valid-bool.xml | 7 + .../hr/data-labels-shared-invalid-bool.xml | 7 + .../hr/data-labels-shared-valid-bool.xml | 7 + .../od/data-labels-accessed-valid-bool.xml | 12 + .../od/data-labels-collected-valid-bool.xml | 13 ++ .../od/data-labels-shared-valid-bool.xml | 13 ++ .../developerinfo/hr/all-fields-valid.xml | 8 + .../developerinfo/od/all-fields-valid.xml | 9 + .../safetylabels/hr/missing-version.xml | 2 + .../asllib/safetylabels/hr/valid-empty.xml | 1 + .../safetylabels/hr/with-data-labels.xml | 9 + .../asllib/safetylabels/od/valid-empty.xml | 3 + .../safetylabels/od/with-data-labels.xml | 16 ++ .../systemappsafetylabel/hr/missing-url.xml | 1 + .../asllib/systemappsafetylabel/hr/valid.xml | 1 + .../asllib/systemappsafetylabel/od/valid.xml | 3 + .../transparencyinfo/hr/valid-empty.xml | 4 + .../transparencyinfo/hr/with-app-info.xml | 4 + .../hr/with-developer-info.xml | 11 + .../transparencyinfo/od/valid-empty.xml | 1 + .../transparencyinfo/od/with-app-info.xml | 26 +++ .../od/with-developer-info.xml | 11 + .../validmappings/contacts/hr.xml | 0 .../validmappings/contacts/od.xml | 0 .../validmappings/location/hr.xml | 0 .../validmappings/location/od.xml | 0 111 files changed, 2017 insertions(+), 265 deletions(-) delete mode 100644 tools/app_metadata_bundles/src/lib/java/com/android/asllib/DataTypeConstants.java rename tools/app_metadata_bundles/src/lib/java/com/android/asllib/{ => marshallable}/AndroidSafetyLabel.java (96%) rename tools/app_metadata_bundles/src/lib/java/com/android/asllib/{ => marshallable}/AndroidSafetyLabelFactory.java (96%) rename tools/app_metadata_bundles/src/lib/java/com/android/asllib/{ => marshallable}/AppInfo.java (98%) rename tools/app_metadata_bundles/src/lib/java/com/android/asllib/{ => marshallable}/AppInfoFactory.java (74%) rename tools/app_metadata_bundles/src/lib/java/com/android/asllib/{ => marshallable}/AslMarshallable.java (95%) rename tools/app_metadata_bundles/src/lib/java/com/android/asllib/{ => marshallable}/AslMarshallableFactory.java (95%) rename tools/app_metadata_bundles/src/lib/java/com/android/asllib/{ => marshallable}/DataCategory.java (91%) rename tools/app_metadata_bundles/src/lib/java/com/android/asllib/{ => marshallable}/DataCategoryFactory.java (62%) rename tools/app_metadata_bundles/src/lib/java/com/android/asllib/{ => marshallable}/DataLabels.java (85%) rename tools/app_metadata_bundles/src/lib/java/com/android/asllib/{ => marshallable}/DataLabelsFactory.java (97%) rename tools/app_metadata_bundles/src/lib/java/com/android/asllib/{ => marshallable}/DataType.java (98%) rename tools/app_metadata_bundles/src/lib/java/com/android/asllib/{ => marshallable}/DataTypeFactory.java (67%) rename tools/app_metadata_bundles/src/lib/java/com/android/asllib/{ => marshallable}/DeveloperInfo.java (98%) rename tools/app_metadata_bundles/src/lib/java/com/android/asllib/{ => marshallable}/DeveloperInfoFactory.java (96%) rename tools/app_metadata_bundles/src/lib/java/com/android/asllib/{ => marshallable}/SafetyLabels.java (95%) rename tools/app_metadata_bundles/src/lib/java/com/android/asllib/{ => marshallable}/SafetyLabelsFactory.java (88%) rename tools/app_metadata_bundles/src/lib/java/com/android/asllib/{ => marshallable}/SystemAppSafetyLabel.java (94%) rename tools/app_metadata_bundles/src/lib/java/com/android/asllib/{ => marshallable}/SystemAppSafetyLabelFactory.java (94%) rename tools/app_metadata_bundles/src/lib/java/com/android/asllib/{ => marshallable}/TransparencyInfo.java (96%) rename tools/app_metadata_bundles/src/lib/java/com/android/asllib/{ => marshallable}/TransparencyInfoFactory.java (95%) rename tools/app_metadata_bundles/src/lib/java/com/android/asllib/{ => util}/DataCategoryConstants.java (94%) create mode 100644 tools/app_metadata_bundles/src/lib/java/com/android/asllib/util/DataTypeConstants.java rename tools/app_metadata_bundles/src/lib/java/com/android/asllib/{ => util}/XmlUtils.java (92%) rename tools/app_metadata_bundles/src/test/java/com/android/{aslgen => asllib}/AllTests.java (67%) rename tools/app_metadata_bundles/src/test/java/com/android/{aslgen => asllib}/AslgenTests.java (58%) create mode 100644 tools/app_metadata_bundles/src/test/java/com/android/asllib/marshallable/AndroidSafetyLabelTest.java create mode 100644 tools/app_metadata_bundles/src/test/java/com/android/asllib/marshallable/AppInfoTest.java create mode 100644 tools/app_metadata_bundles/src/test/java/com/android/asllib/marshallable/DataCategoryTest.java create mode 100644 tools/app_metadata_bundles/src/test/java/com/android/asllib/marshallable/DataLabelsTest.java create mode 100644 tools/app_metadata_bundles/src/test/java/com/android/asllib/marshallable/DeveloperInfoTest.java create mode 100644 tools/app_metadata_bundles/src/test/java/com/android/asllib/marshallable/SafetyLabelsTest.java create mode 100644 tools/app_metadata_bundles/src/test/java/com/android/asllib/marshallable/SystemAppSafetyLabelTest.java create mode 100644 tools/app_metadata_bundles/src/test/java/com/android/asllib/marshallable/TransparencyInfoTest.java create mode 100644 tools/app_metadata_bundles/src/test/java/com/android/asllib/testutils/TestUtils.java create mode 100644 tools/app_metadata_bundles/src/test/resources/com/android/asllib/androidsafetylabel/hr/missing-version.xml create mode 100644 tools/app_metadata_bundles/src/test/resources/com/android/asllib/androidsafetylabel/hr/valid-empty.xml create mode 100644 tools/app_metadata_bundles/src/test/resources/com/android/asllib/androidsafetylabel/hr/with-safety-labels.xml create mode 100644 tools/app_metadata_bundles/src/test/resources/com/android/asllib/androidsafetylabel/hr/with-system-app-safety-label.xml create mode 100644 tools/app_metadata_bundles/src/test/resources/com/android/asllib/androidsafetylabel/hr/with-transparency-info.xml create mode 100644 tools/app_metadata_bundles/src/test/resources/com/android/asllib/androidsafetylabel/od/valid-empty.xml create mode 100644 tools/app_metadata_bundles/src/test/resources/com/android/asllib/androidsafetylabel/od/with-safety-labels.xml create mode 100644 tools/app_metadata_bundles/src/test/resources/com/android/asllib/androidsafetylabel/od/with-system-app-safety-label.xml create mode 100644 tools/app_metadata_bundles/src/test/resources/com/android/asllib/androidsafetylabel/od/with-transparency-info.xml create mode 100644 tools/app_metadata_bundles/src/test/resources/com/android/asllib/appinfo/hr/all-fields-valid.xml create mode 100644 tools/app_metadata_bundles/src/test/resources/com/android/asllib/appinfo/od/all-fields-valid.xml create mode 100644 tools/app_metadata_bundles/src/test/resources/com/android/asllib/datacategory/hr/data-category-actions-in-app.xml create mode 100644 tools/app_metadata_bundles/src/test/resources/com/android/asllib/datacategory/hr/data-category-app-performance.xml create mode 100644 tools/app_metadata_bundles/src/test/resources/com/android/asllib/datacategory/hr/data-category-audio.xml create mode 100644 tools/app_metadata_bundles/src/test/resources/com/android/asllib/datacategory/hr/data-category-calendar.xml create mode 100644 tools/app_metadata_bundles/src/test/resources/com/android/asllib/datacategory/hr/data-category-contacts.xml create mode 100644 tools/app_metadata_bundles/src/test/resources/com/android/asllib/datacategory/hr/data-category-email-text-message.xml create mode 100644 tools/app_metadata_bundles/src/test/resources/com/android/asllib/datacategory/hr/data-category-financial.xml create mode 100644 tools/app_metadata_bundles/src/test/resources/com/android/asllib/datacategory/hr/data-category-health-fitness.xml create mode 100644 tools/app_metadata_bundles/src/test/resources/com/android/asllib/datacategory/hr/data-category-identifiers.xml create mode 100644 tools/app_metadata_bundles/src/test/resources/com/android/asllib/datacategory/hr/data-category-location.xml create mode 100644 tools/app_metadata_bundles/src/test/resources/com/android/asllib/datacategory/hr/data-category-personal-empty-purpose.xml create mode 100644 tools/app_metadata_bundles/src/test/resources/com/android/asllib/datacategory/hr/data-category-personal-missing-purpose.xml create mode 100644 tools/app_metadata_bundles/src/test/resources/com/android/asllib/datacategory/hr/data-category-personal-partial.xml create mode 100644 tools/app_metadata_bundles/src/test/resources/com/android/asllib/datacategory/hr/data-category-personal-unrecognized-type.xml create mode 100644 tools/app_metadata_bundles/src/test/resources/com/android/asllib/datacategory/hr/data-category-personal.xml create mode 100644 tools/app_metadata_bundles/src/test/resources/com/android/asllib/datacategory/hr/data-category-photo-video.xml create mode 100644 tools/app_metadata_bundles/src/test/resources/com/android/asllib/datacategory/hr/data-category-search-and-browsing.xml create mode 100644 tools/app_metadata_bundles/src/test/resources/com/android/asllib/datacategory/hr/data-category-storage.xml create mode 100644 tools/app_metadata_bundles/src/test/resources/com/android/asllib/datacategory/hr/data-category-unrecognized.xml create mode 100644 tools/app_metadata_bundles/src/test/resources/com/android/asllib/datacategory/od/data-category-actions-in-app.xml create mode 100644 tools/app_metadata_bundles/src/test/resources/com/android/asllib/datacategory/od/data-category-app-performance.xml create mode 100644 tools/app_metadata_bundles/src/test/resources/com/android/asllib/datacategory/od/data-category-audio.xml create mode 100644 tools/app_metadata_bundles/src/test/resources/com/android/asllib/datacategory/od/data-category-calendar.xml create mode 100644 tools/app_metadata_bundles/src/test/resources/com/android/asllib/datacategory/od/data-category-contacts.xml create mode 100644 tools/app_metadata_bundles/src/test/resources/com/android/asllib/datacategory/od/data-category-email-text-message.xml create mode 100644 tools/app_metadata_bundles/src/test/resources/com/android/asllib/datacategory/od/data-category-financial.xml create mode 100644 tools/app_metadata_bundles/src/test/resources/com/android/asllib/datacategory/od/data-category-health-fitness.xml create mode 100644 tools/app_metadata_bundles/src/test/resources/com/android/asllib/datacategory/od/data-category-identifiers.xml create mode 100644 tools/app_metadata_bundles/src/test/resources/com/android/asllib/datacategory/od/data-category-location.xml create mode 100644 tools/app_metadata_bundles/src/test/resources/com/android/asllib/datacategory/od/data-category-personal-partial.xml create mode 100644 tools/app_metadata_bundles/src/test/resources/com/android/asllib/datacategory/od/data-category-personal.xml create mode 100644 tools/app_metadata_bundles/src/test/resources/com/android/asllib/datacategory/od/data-category-photo-video.xml create mode 100644 tools/app_metadata_bundles/src/test/resources/com/android/asllib/datacategory/od/data-category-search-and-browsing.xml create mode 100644 tools/app_metadata_bundles/src/test/resources/com/android/asllib/datacategory/od/data-category-storage.xml create mode 100644 tools/app_metadata_bundles/src/test/resources/com/android/asllib/datalabels/hr/data-labels-accessed-invalid-bool.xml create mode 100644 tools/app_metadata_bundles/src/test/resources/com/android/asllib/datalabels/hr/data-labels-accessed-valid-bool.xml create mode 100644 tools/app_metadata_bundles/src/test/resources/com/android/asllib/datalabels/hr/data-labels-collected-invalid-bool.xml create mode 100644 tools/app_metadata_bundles/src/test/resources/com/android/asllib/datalabels/hr/data-labels-collected-valid-bool.xml create mode 100644 tools/app_metadata_bundles/src/test/resources/com/android/asllib/datalabels/hr/data-labels-shared-invalid-bool.xml create mode 100644 tools/app_metadata_bundles/src/test/resources/com/android/asllib/datalabels/hr/data-labels-shared-valid-bool.xml create mode 100644 tools/app_metadata_bundles/src/test/resources/com/android/asllib/datalabels/od/data-labels-accessed-valid-bool.xml create mode 100644 tools/app_metadata_bundles/src/test/resources/com/android/asllib/datalabels/od/data-labels-collected-valid-bool.xml create mode 100644 tools/app_metadata_bundles/src/test/resources/com/android/asllib/datalabels/od/data-labels-shared-valid-bool.xml create mode 100644 tools/app_metadata_bundles/src/test/resources/com/android/asllib/developerinfo/hr/all-fields-valid.xml create mode 100644 tools/app_metadata_bundles/src/test/resources/com/android/asllib/developerinfo/od/all-fields-valid.xml create mode 100644 tools/app_metadata_bundles/src/test/resources/com/android/asllib/safetylabels/hr/missing-version.xml create mode 100644 tools/app_metadata_bundles/src/test/resources/com/android/asllib/safetylabels/hr/valid-empty.xml create mode 100644 tools/app_metadata_bundles/src/test/resources/com/android/asllib/safetylabels/hr/with-data-labels.xml create mode 100644 tools/app_metadata_bundles/src/test/resources/com/android/asllib/safetylabels/od/valid-empty.xml create mode 100644 tools/app_metadata_bundles/src/test/resources/com/android/asllib/safetylabels/od/with-data-labels.xml create mode 100644 tools/app_metadata_bundles/src/test/resources/com/android/asllib/systemappsafetylabel/hr/missing-url.xml create mode 100644 tools/app_metadata_bundles/src/test/resources/com/android/asllib/systemappsafetylabel/hr/valid.xml create mode 100644 tools/app_metadata_bundles/src/test/resources/com/android/asllib/systemappsafetylabel/od/valid.xml create mode 100644 tools/app_metadata_bundles/src/test/resources/com/android/asllib/transparencyinfo/hr/valid-empty.xml create mode 100644 tools/app_metadata_bundles/src/test/resources/com/android/asllib/transparencyinfo/hr/with-app-info.xml create mode 100644 tools/app_metadata_bundles/src/test/resources/com/android/asllib/transparencyinfo/hr/with-developer-info.xml create mode 100644 tools/app_metadata_bundles/src/test/resources/com/android/asllib/transparencyinfo/od/valid-empty.xml create mode 100644 tools/app_metadata_bundles/src/test/resources/com/android/asllib/transparencyinfo/od/with-app-info.xml create mode 100644 tools/app_metadata_bundles/src/test/resources/com/android/asllib/transparencyinfo/od/with-developer-info.xml rename tools/app_metadata_bundles/src/test/resources/com/android/{aslgen => asllib}/validmappings/contacts/hr.xml (100%) rename tools/app_metadata_bundles/src/test/resources/com/android/{aslgen => asllib}/validmappings/contacts/od.xml (100%) rename tools/app_metadata_bundles/src/test/resources/com/android/{aslgen => asllib}/validmappings/location/hr.xml (100%) rename tools/app_metadata_bundles/src/test/resources/com/android/{aslgen => asllib}/validmappings/location/od.xml (100%) diff --git a/tools/app_metadata_bundles/Android.bp b/tools/app_metadata_bundles/Android.bp index a012dca19904..dced50d7ee3b 100644 --- a/tools/app_metadata_bundles/Android.bp +++ b/tools/app_metadata_bundles/Android.bp @@ -13,6 +13,9 @@ java_library_host { srcs: [ "src/lib/java/**/*.java", ], + static_libs: [ + "guava", + ], } java_binary_host { diff --git a/tools/app_metadata_bundles/src/lib/java/com/android/asllib/AslConverter.java b/tools/app_metadata_bundles/src/lib/java/com/android/asllib/AslConverter.java index 9dd55314e844..c1c520e99cac 100644 --- a/tools/app_metadata_bundles/src/lib/java/com/android/asllib/AslConverter.java +++ b/tools/app_metadata_bundles/src/lib/java/com/android/asllib/AslConverter.java @@ -16,7 +16,10 @@ package com.android.asllib; +import com.android.asllib.marshallable.AndroidSafetyLabel; +import com.android.asllib.marshallable.AndroidSafetyLabelFactory; import com.android.asllib.util.MalformedXmlException; +import com.android.asllib.util.XmlUtils; import org.w3c.dom.Document; import org.w3c.dom.Element; diff --git a/tools/app_metadata_bundles/src/lib/java/com/android/asllib/DataTypeConstants.java b/tools/app_metadata_bundles/src/lib/java/com/android/asllib/DataTypeConstants.java deleted file mode 100644 index a0a75377e988..000000000000 --- a/tools/app_metadata_bundles/src/lib/java/com/android/asllib/DataTypeConstants.java +++ /dev/null @@ -1,156 +0,0 @@ -/* - * Copyright (C) 2024 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.android.asllib; - -import java.util.Arrays; -import java.util.Collections; -import java.util.HashSet; -import java.util.Set; - -/** - * Constants for determining valid {@link String} data types for usage within {@link SafetyLabels}, - * {@link DataCategory}, and {@link DataType} - */ -public class DataTypeConstants { - /** Data types for {@link DataCategoryConstants.CATEGORY_PERSONAL} */ - public static final String TYPE_NAME = "name"; - - public static final String TYPE_EMAIL_ADDRESS = "email_address"; - public static final String TYPE_PHONE_NUMBER = "phone_number"; - public static final String TYPE_RACE_ETHNICITY = "race_ethnicity"; - public static final String TYPE_POLITICAL_OR_RELIGIOUS_BELIEFS = - "political_or_religious_beliefs"; - public static final String TYPE_SEXUAL_ORIENTATION_OR_GENDER_IDENTITY = - "sexual_orientation_or_gender_identity"; - public static final String TYPE_PERSONAL_IDENTIFIERS = "personal_identifiers"; - public static final String TYPE_OTHER = "other"; - - /** Data types for {@link DataCategoryConstants.CATEGORY_FINANCIAL} */ - public static final String TYPE_CARD_BANK_ACCOUNT = "card_bank_account"; - - public static final String TYPE_PURCHASE_HISTORY = "purchase_history"; - public static final String TYPE_CREDIT_SCORE = "credit_score"; - public static final String TYPE_FINANCIAL_OTHER = "other"; - - /** Data types for {@link DataCategoryConstants.CATEGORY_LOCATION} */ - public static final String TYPE_APPROX_LOCATION = "approx_location"; - - public static final String TYPE_PRECISE_LOCATION = "precise_location"; - - /** Data types for {@link DataCategoryConstants.CATEGORY_EMAIL_TEXT_MESSAGE} */ - public static final String TYPE_EMAILS = "emails"; - - public static final String TYPE_TEXT_MESSAGES = "text_messages"; - public static final String TYPE_EMAIL_TEXT_MESSAGE_OTHER = "other"; - - /** Data types for {@link DataCategoryConstants.CATEGORY_PHOTO_VIDEO} */ - public static final String TYPE_PHOTOS = "photos"; - - public static final String TYPE_VIDEOS = "videos"; - - /** Data types for {@link DataCategoryConstants.CATEGORY_AUDIO} */ - public static final String TYPE_SOUND_RECORDINGS = "sound_recordings"; - - public static final String TYPE_MUSIC_FILES = "music_files"; - public static final String TYPE_AUDIO_OTHER = "other"; - - /** Data types for {@link DataCategoryConstants.CATEGORY_STORAGE} */ - public static final String TYPE_FILES_DOCS = "files_docs"; - - /** Data types for {@link DataCategoryConstants.CATEGORY_HEALTH_FITNESS} */ - public static final String TYPE_HEALTH = "health"; - - public static final String TYPE_FITNESS = "fitness"; - - /** Data types for {@link DataCategoryConstants.CATEGORY_CONTACTS} */ - public static final String TYPE_CONTACTS = "contacts"; - - /** Data types for {@link DataCategoryConstants.CATEGORY_CALENDAR} */ - public static final String TYPE_CALENDAR = "calendar"; - - /** Data types for {@link DataCategoryConstants.CATEGORY_IDENTIFIERS} */ - public static final String TYPE_IDENTIFIERS_OTHER = "other"; - - /** Data types for {@link DataCategoryConstants.CATEGORY_APP_PERFORMANCE} */ - public static final String TYPE_CRASH_LOGS = "crash_logs"; - - public static final String TYPE_PERFORMANCE_DIAGNOSTICS = "performance_diagnostics"; - public static final String TYPE_APP_PERFORMANCE_OTHER = "other"; - - /** Data types for {@link DataCategoryConstants.CATEGORY_ACTIONS_IN_APP} */ - public static final String TYPE_USER_INTERACTION = "user_interaction"; - - public static final String TYPE_IN_APP_SEARCH_HISTORY = "in_app_search_history"; - public static final String TYPE_INSTALLED_APPS = "installed_apps"; - public static final String TYPE_USER_GENERATED_CONTENT = "user_generated_content"; - public static final String TYPE_ACTIONS_IN_APP_OTHER = "other"; - - /** Data types for {@link DataCategoryConstants.CATEGORY_SEARCH_AND_BROWSING} */ - public static final String TYPE_WEB_BROWSING_HISTORY = "web_browsing_history"; - - /** Set of valid categories */ - public static final Set<String> VALID_TYPES = - Collections.unmodifiableSet( - new HashSet<>( - Arrays.asList( - TYPE_NAME, - TYPE_EMAIL_ADDRESS, - TYPE_PHONE_NUMBER, - TYPE_RACE_ETHNICITY, - TYPE_POLITICAL_OR_RELIGIOUS_BELIEFS, - TYPE_SEXUAL_ORIENTATION_OR_GENDER_IDENTITY, - TYPE_PERSONAL_IDENTIFIERS, - TYPE_OTHER, - TYPE_CARD_BANK_ACCOUNT, - TYPE_PURCHASE_HISTORY, - TYPE_CREDIT_SCORE, - TYPE_FINANCIAL_OTHER, - TYPE_APPROX_LOCATION, - TYPE_PRECISE_LOCATION, - TYPE_EMAILS, - TYPE_TEXT_MESSAGES, - TYPE_EMAIL_TEXT_MESSAGE_OTHER, - TYPE_PHOTOS, - TYPE_VIDEOS, - TYPE_SOUND_RECORDINGS, - TYPE_MUSIC_FILES, - TYPE_AUDIO_OTHER, - TYPE_FILES_DOCS, - TYPE_HEALTH, - TYPE_FITNESS, - TYPE_CONTACTS, - TYPE_CALENDAR, - TYPE_IDENTIFIERS_OTHER, - TYPE_CRASH_LOGS, - TYPE_PERFORMANCE_DIAGNOSTICS, - TYPE_APP_PERFORMANCE_OTHER, - TYPE_USER_INTERACTION, - TYPE_IN_APP_SEARCH_HISTORY, - TYPE_INSTALLED_APPS, - TYPE_USER_GENERATED_CONTENT, - TYPE_ACTIONS_IN_APP_OTHER, - TYPE_WEB_BROWSING_HISTORY))); - - /** Returns {@link Set} of valid {@link String} category keys */ - public static Set<String> getValidDataTypes() { - return VALID_TYPES; - } - - private DataTypeConstants() { - /* do nothing - hide constructor */ - } -} diff --git a/tools/app_metadata_bundles/src/lib/java/com/android/asllib/AndroidSafetyLabel.java b/tools/app_metadata_bundles/src/lib/java/com/android/asllib/marshallable/AndroidSafetyLabel.java similarity index 96% rename from tools/app_metadata_bundles/src/lib/java/com/android/asllib/AndroidSafetyLabel.java rename to tools/app_metadata_bundles/src/lib/java/com/android/asllib/marshallable/AndroidSafetyLabel.java index cdb559b52c0e..112b92c9aebb 100644 --- a/tools/app_metadata_bundles/src/lib/java/com/android/asllib/AndroidSafetyLabel.java +++ b/tools/app_metadata_bundles/src/lib/java/com/android/asllib/marshallable/AndroidSafetyLabel.java @@ -14,7 +14,9 @@ * limitations under the License. */ -package com.android.asllib; +package com.android.asllib.marshallable; + +import com.android.asllib.util.XmlUtils; import org.w3c.dom.Document; import org.w3c.dom.Element; diff --git a/tools/app_metadata_bundles/src/lib/java/com/android/asllib/AndroidSafetyLabelFactory.java b/tools/app_metadata_bundles/src/lib/java/com/android/asllib/marshallable/AndroidSafetyLabelFactory.java similarity index 96% rename from tools/app_metadata_bundles/src/lib/java/com/android/asllib/AndroidSafetyLabelFactory.java rename to tools/app_metadata_bundles/src/lib/java/com/android/asllib/marshallable/AndroidSafetyLabelFactory.java index 3dc725b5452b..b69c30f7f522 100644 --- a/tools/app_metadata_bundles/src/lib/java/com/android/asllib/AndroidSafetyLabelFactory.java +++ b/tools/app_metadata_bundles/src/lib/java/com/android/asllib/marshallable/AndroidSafetyLabelFactory.java @@ -14,9 +14,10 @@ * limitations under the License. */ -package com.android.asllib; +package com.android.asllib.marshallable; import com.android.asllib.util.MalformedXmlException; +import com.android.asllib.util.XmlUtils; import org.w3c.dom.Element; diff --git a/tools/app_metadata_bundles/src/lib/java/com/android/asllib/AppInfo.java b/tools/app_metadata_bundles/src/lib/java/com/android/asllib/marshallable/AppInfo.java similarity index 98% rename from tools/app_metadata_bundles/src/lib/java/com/android/asllib/AppInfo.java rename to tools/app_metadata_bundles/src/lib/java/com/android/asllib/marshallable/AppInfo.java index f94b6591cd10..3f1ddebefe99 100644 --- a/tools/app_metadata_bundles/src/lib/java/com/android/asllib/AppInfo.java +++ b/tools/app_metadata_bundles/src/lib/java/com/android/asllib/marshallable/AppInfo.java @@ -14,7 +14,9 @@ * limitations under the License. */ -package com.android.asllib; +package com.android.asllib.marshallable; + +import com.android.asllib.util.XmlUtils; import org.w3c.dom.Document; import org.w3c.dom.Element; diff --git a/tools/app_metadata_bundles/src/lib/java/com/android/asllib/AppInfoFactory.java b/tools/app_metadata_bundles/src/lib/java/com/android/asllib/marshallable/AppInfoFactory.java similarity index 74% rename from tools/app_metadata_bundles/src/lib/java/com/android/asllib/AppInfoFactory.java rename to tools/app_metadata_bundles/src/lib/java/com/android/asllib/marshallable/AppInfoFactory.java index 26d94c16c7f0..59a437d7ece5 100644 --- a/tools/app_metadata_bundles/src/lib/java/com/android/asllib/AppInfoFactory.java +++ b/tools/app_metadata_bundles/src/lib/java/com/android/asllib/marshallable/AppInfoFactory.java @@ -14,14 +14,14 @@ * limitations under the License. */ -package com.android.asllib; +package com.android.asllib.marshallable; import com.android.asllib.util.AslgenUtil; import com.android.asllib.util.MalformedXmlException; +import com.android.asllib.util.XmlUtils; import org.w3c.dom.Element; -import java.util.Arrays; import java.util.List; public class AppInfoFactory implements AslMarshallableFactory<AppInfo> { @@ -37,31 +37,22 @@ public class AppInfoFactory implements AslMarshallableFactory<AppInfo> { String title = XmlUtils.getStringAttr(appInfoEle, XmlUtils.HR_ATTR_TITLE); String description = XmlUtils.getStringAttr(appInfoEle, XmlUtils.HR_ATTR_DESCRIPTION); - Boolean containsAds = XmlUtils.getBoolAttr(appInfoEle, XmlUtils.HR_ATTR_CONTAINS_ADS); - Boolean obeyAps = XmlUtils.getBoolAttr(appInfoEle, XmlUtils.HR_ATTR_OBEY_APS); + Boolean containsAds = XmlUtils.getBoolAttr(appInfoEle, XmlUtils.HR_ATTR_CONTAINS_ADS, true); + Boolean obeyAps = XmlUtils.getBoolAttr(appInfoEle, XmlUtils.HR_ATTR_OBEY_APS, true); Boolean adsFingerprinting = - XmlUtils.getBoolAttr(appInfoEle, XmlUtils.HR_ATTR_ADS_FINGERPRINTING); + XmlUtils.getBoolAttr(appInfoEle, XmlUtils.HR_ATTR_ADS_FINGERPRINTING, true); Boolean securityFingerprinting = - XmlUtils.getBoolAttr(appInfoEle, XmlUtils.HR_ATTR_SECURITY_FINGERPRINTING); + XmlUtils.getBoolAttr(appInfoEle, XmlUtils.HR_ATTR_SECURITY_FINGERPRINTING, true); String privacyPolicy = XmlUtils.getStringAttr(appInfoEle, XmlUtils.HR_ATTR_PRIVACY_POLICY); List<String> securityEndpoints = - Arrays.stream( - appInfoEle - .getAttribute(XmlUtils.HR_ATTR_SECURITY_ENDPOINTS) - .split("\\|")) - .toList(); + XmlUtils.getPipelineSplitAttr( + appInfoEle, XmlUtils.HR_ATTR_SECURITY_ENDPOINTS, true); List<String> firstPartyEndpoints = - Arrays.stream( - appInfoEle - .getAttribute(XmlUtils.HR_ATTR_FIRST_PARTY_ENDPOINTS) - .split("\\|")) - .toList(); + XmlUtils.getPipelineSplitAttr( + appInfoEle, XmlUtils.HR_ATTR_FIRST_PARTY_ENDPOINTS, true); List<String> serviceProviderEndpoints = - Arrays.stream( - appInfoEle - .getAttribute(XmlUtils.HR_ATTR_SERVICE_PROVIDER_ENDPOINTS) - .split("\\|")) - .toList(); + XmlUtils.getPipelineSplitAttr( + appInfoEle, XmlUtils.HR_ATTR_SERVICE_PROVIDER_ENDPOINTS, true); String category = XmlUtils.getStringAttr(appInfoEle, XmlUtils.HR_ATTR_CATEGORY); String email = XmlUtils.getStringAttr(appInfoEle, XmlUtils.HR_ATTR_EMAIL); String website = XmlUtils.getStringAttr(appInfoEle, XmlUtils.HR_ATTR_WEBSITE, false); diff --git a/tools/app_metadata_bundles/src/lib/java/com/android/asllib/AslMarshallable.java b/tools/app_metadata_bundles/src/lib/java/com/android/asllib/marshallable/AslMarshallable.java similarity index 95% rename from tools/app_metadata_bundles/src/lib/java/com/android/asllib/AslMarshallable.java rename to tools/app_metadata_bundles/src/lib/java/com/android/asllib/marshallable/AslMarshallable.java index 4e64ab0c53c1..48747ccbcff6 100644 --- a/tools/app_metadata_bundles/src/lib/java/com/android/asllib/AslMarshallable.java +++ b/tools/app_metadata_bundles/src/lib/java/com/android/asllib/marshallable/AslMarshallable.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package com.android.asllib; +package com.android.asllib.marshallable; import org.w3c.dom.Document; import org.w3c.dom.Element; diff --git a/tools/app_metadata_bundles/src/lib/java/com/android/asllib/AslMarshallableFactory.java b/tools/app_metadata_bundles/src/lib/java/com/android/asllib/marshallable/AslMarshallableFactory.java similarity index 95% rename from tools/app_metadata_bundles/src/lib/java/com/android/asllib/AslMarshallableFactory.java rename to tools/app_metadata_bundles/src/lib/java/com/android/asllib/marshallable/AslMarshallableFactory.java index b8f9f0ef6235..a49b3e77155b 100644 --- a/tools/app_metadata_bundles/src/lib/java/com/android/asllib/AslMarshallableFactory.java +++ b/tools/app_metadata_bundles/src/lib/java/com/android/asllib/marshallable/AslMarshallableFactory.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package com.android.asllib; +package com.android.asllib.marshallable; import com.android.asllib.util.MalformedXmlException; diff --git a/tools/app_metadata_bundles/src/lib/java/com/android/asllib/DataCategory.java b/tools/app_metadata_bundles/src/lib/java/com/android/asllib/marshallable/DataCategory.java similarity index 91% rename from tools/app_metadata_bundles/src/lib/java/com/android/asllib/DataCategory.java rename to tools/app_metadata_bundles/src/lib/java/com/android/asllib/marshallable/DataCategory.java index b9e06fbdfc7e..4d67162b442d 100644 --- a/tools/app_metadata_bundles/src/lib/java/com/android/asllib/DataCategory.java +++ b/tools/app_metadata_bundles/src/lib/java/com/android/asllib/marshallable/DataCategory.java @@ -14,7 +14,11 @@ * limitations under the License. */ -package com.android.asllib; +package com.android.asllib.marshallable; + +import com.android.asllib.util.DataCategoryConstants; +import com.android.asllib.util.DataTypeConstants; +import com.android.asllib.util.XmlUtils; import org.w3c.dom.Document; import org.w3c.dom.Element; diff --git a/tools/app_metadata_bundles/src/lib/java/com/android/asllib/DataCategoryFactory.java b/tools/app_metadata_bundles/src/lib/java/com/android/asllib/marshallable/DataCategoryFactory.java similarity index 62% rename from tools/app_metadata_bundles/src/lib/java/com/android/asllib/DataCategoryFactory.java rename to tools/app_metadata_bundles/src/lib/java/com/android/asllib/marshallable/DataCategoryFactory.java index d2b671271561..37d99e7ef85e 100644 --- a/tools/app_metadata_bundles/src/lib/java/com/android/asllib/DataCategoryFactory.java +++ b/tools/app_metadata_bundles/src/lib/java/com/android/asllib/marshallable/DataCategoryFactory.java @@ -14,9 +14,11 @@ * limitations under the License. */ -package com.android.asllib; +package com.android.asllib.marshallable; +import com.android.asllib.util.DataTypeConstants; import com.android.asllib.util.MalformedXmlException; +import com.android.asllib.util.XmlUtils; import org.w3c.dom.Element; @@ -30,11 +32,17 @@ public class DataCategoryFactory implements AslMarshallableFactory<DataCategory> String categoryName = null; Map<String, DataType> dataTypeMap = new LinkedHashMap<String, DataType>(); for (Element ele : elements) { - categoryName = ele.getAttribute(XmlUtils.HR_ATTR_DATA_CATEGORY); - String dataTypeName = ele.getAttribute(XmlUtils.HR_ATTR_DATA_TYPE); - if (!DataTypeConstants.getValidDataTypes().contains(dataTypeName)) { + categoryName = XmlUtils.getStringAttr(ele, XmlUtils.HR_ATTR_DATA_CATEGORY, true); + String dataTypeName = XmlUtils.getStringAttr(ele, XmlUtils.HR_ATTR_DATA_TYPE, true); + if (!DataTypeConstants.getValidDataTypes().containsKey(categoryName)) { throw new MalformedXmlException( - String.format("Unrecognized data type name: %s", dataTypeName)); + String.format("Unrecognized data category %s", categoryName)); + } + if (!DataTypeConstants.getValidDataTypes().get(categoryName).contains(dataTypeName)) { + throw new MalformedXmlException( + String.format( + "Unrecognized data type name %s for category %s", + dataTypeName, categoryName)); } dataTypeMap.put( dataTypeName, new DataTypeFactory().createFromHrElements(XmlUtils.listOf(ele))); diff --git a/tools/app_metadata_bundles/src/lib/java/com/android/asllib/DataLabels.java b/tools/app_metadata_bundles/src/lib/java/com/android/asllib/marshallable/DataLabels.java similarity index 85% rename from tools/app_metadata_bundles/src/lib/java/com/android/asllib/DataLabels.java rename to tools/app_metadata_bundles/src/lib/java/com/android/asllib/marshallable/DataLabels.java index 96ec93c28c87..7516faf9f77a 100644 --- a/tools/app_metadata_bundles/src/lib/java/com/android/asllib/DataLabels.java +++ b/tools/app_metadata_bundles/src/lib/java/com/android/asllib/marshallable/DataLabels.java @@ -14,7 +14,10 @@ * limitations under the License. */ -package com.android.asllib; +package com.android.asllib.marshallable; + +import com.android.asllib.util.DataCategoryConstants; +import com.android.asllib.util.XmlUtils; import org.w3c.dom.Document; import org.w3c.dom.Element; @@ -41,24 +44,23 @@ public class DataLabels implements AslMarshallable { } /** - * Returns the data accessed {@link Map} of {@link com.android.asllib.DataCategoryConstants} to - * {@link DataCategory} + * Returns the data accessed {@link Map} of {@link DataCategoryConstants} to {@link + * DataCategory} */ public Map<String, DataCategory> getDataAccessed() { return mDataAccessed; } /** - * Returns the data collected {@link Map} of {@link com.android.asllib.DataCategoryConstants} to - * {@link DataCategory} + * Returns the data collected {@link Map} of {@link DataCategoryConstants} to {@link + * DataCategory} */ public Map<String, DataCategory> getDataCollected() { return mDataCollected; } /** - * Returns the data shared {@link Map} of {@link com.android.asllib.DataCategoryConstants} to - * {@link DataCategory} + * Returns the data shared {@link Map} of {@link DataCategoryConstants} to {@link DataCategory} */ public Map<String, DataCategory> getDataShared() { return mDataShared; @@ -70,7 +72,7 @@ public class DataLabels implements AslMarshallable { Element dataLabelsEle = XmlUtils.createPbundleEleWithName(doc, XmlUtils.OD_NAME_DATA_LABELS); - maybeAppendDataUsages(doc, dataLabelsEle, mDataCollected, XmlUtils.OD_NAME_DATA_ACCESSED); + maybeAppendDataUsages(doc, dataLabelsEle, mDataAccessed, XmlUtils.OD_NAME_DATA_ACCESSED); maybeAppendDataUsages(doc, dataLabelsEle, mDataCollected, XmlUtils.OD_NAME_DATA_COLLECTED); maybeAppendDataUsages(doc, dataLabelsEle, mDataShared, XmlUtils.OD_NAME_DATA_SHARED); diff --git a/tools/app_metadata_bundles/src/lib/java/com/android/asllib/DataLabelsFactory.java b/tools/app_metadata_bundles/src/lib/java/com/android/asllib/marshallable/DataLabelsFactory.java similarity index 97% rename from tools/app_metadata_bundles/src/lib/java/com/android/asllib/DataLabelsFactory.java rename to tools/app_metadata_bundles/src/lib/java/com/android/asllib/marshallable/DataLabelsFactory.java index 79edab7631f0..dc77fd08aa53 100644 --- a/tools/app_metadata_bundles/src/lib/java/com/android/asllib/DataLabelsFactory.java +++ b/tools/app_metadata_bundles/src/lib/java/com/android/asllib/marshallable/DataLabelsFactory.java @@ -14,10 +14,12 @@ * limitations under the License. */ -package com.android.asllib; +package com.android.asllib.marshallable; import com.android.asllib.util.AslgenUtil; +import com.android.asllib.util.DataCategoryConstants; import com.android.asllib.util.MalformedXmlException; +import com.android.asllib.util.XmlUtils; import org.w3c.dom.Element; import org.w3c.dom.NodeList; diff --git a/tools/app_metadata_bundles/src/lib/java/com/android/asllib/DataType.java b/tools/app_metadata_bundles/src/lib/java/com/android/asllib/marshallable/DataType.java similarity index 98% rename from tools/app_metadata_bundles/src/lib/java/com/android/asllib/DataType.java rename to tools/app_metadata_bundles/src/lib/java/com/android/asllib/marshallable/DataType.java index d011cfeef363..347136237966 100644 --- a/tools/app_metadata_bundles/src/lib/java/com/android/asllib/DataType.java +++ b/tools/app_metadata_bundles/src/lib/java/com/android/asllib/marshallable/DataType.java @@ -14,7 +14,9 @@ * limitations under the License. */ -package com.android.asllib; +package com.android.asllib.marshallable; + +import com.android.asllib.util.XmlUtils; import org.w3c.dom.Document; import org.w3c.dom.Element; diff --git a/tools/app_metadata_bundles/src/lib/java/com/android/asllib/DataTypeFactory.java b/tools/app_metadata_bundles/src/lib/java/com/android/asllib/marshallable/DataTypeFactory.java similarity index 67% rename from tools/app_metadata_bundles/src/lib/java/com/android/asllib/DataTypeFactory.java rename to tools/app_metadata_bundles/src/lib/java/com/android/asllib/marshallable/DataTypeFactory.java index 27c1b599fec7..ed434cda0823 100644 --- a/tools/app_metadata_bundles/src/lib/java/com/android/asllib/DataTypeFactory.java +++ b/tools/app_metadata_bundles/src/lib/java/com/android/asllib/marshallable/DataTypeFactory.java @@ -14,30 +14,40 @@ * limitations under the License. */ -package com.android.asllib; +package com.android.asllib.marshallable; + +import com.android.asllib.util.MalformedXmlException; +import com.android.asllib.util.XmlUtils; import org.w3c.dom.Element; -import java.util.Arrays; +import java.util.HashSet; import java.util.List; -import java.util.Set; import java.util.stream.Collectors; public class DataTypeFactory implements AslMarshallableFactory<DataType> { /** Creates a {@link DataType} from the human-readable DOM element. */ @Override - public DataType createFromHrElements(List<Element> elements) { + public DataType createFromHrElements(List<Element> elements) throws MalformedXmlException { Element hrDataTypeEle = XmlUtils.getSingleElement(elements); String dataTypeName = hrDataTypeEle.getAttribute(XmlUtils.HR_ATTR_DATA_TYPE); List<DataType.Purpose> purposes = - Arrays.stream(hrDataTypeEle.getAttribute(XmlUtils.HR_ATTR_PURPOSES).split("\\|")) + XmlUtils.getPipelineSplitAttr(hrDataTypeEle, XmlUtils.HR_ATTR_PURPOSES, true) + .stream() .map(DataType.Purpose::forString) .collect(Collectors.toList()); + if (purposes.isEmpty()) { + throw new MalformedXmlException(String.format("Found no purpose in: %s", dataTypeName)); + } + if (new HashSet<>(purposes).size() != purposes.size()) { + throw new MalformedXmlException( + String.format("Found non-unique purposes in: %s", dataTypeName)); + } Boolean isCollectionOptional = - XmlUtils.getBoolAttr(hrDataTypeEle, XmlUtils.HR_ATTR_IS_COLLECTION_OPTIONAL); + XmlUtils.getBoolAttr(hrDataTypeEle, XmlUtils.HR_ATTR_IS_COLLECTION_OPTIONAL, false); Boolean isSharingOptional = - XmlUtils.getBoolAttr(hrDataTypeEle, XmlUtils.HR_ATTR_IS_SHARING_OPTIONAL); - Boolean ephemeral = XmlUtils.getBoolAttr(hrDataTypeEle, XmlUtils.HR_ATTR_EPHEMERAL); + XmlUtils.getBoolAttr(hrDataTypeEle, XmlUtils.HR_ATTR_IS_SHARING_OPTIONAL, false); + Boolean ephemeral = XmlUtils.getBoolAttr(hrDataTypeEle, XmlUtils.HR_ATTR_EPHEMERAL, false); return new DataType( dataTypeName, purposes, isCollectionOptional, isSharingOptional, ephemeral); } diff --git a/tools/app_metadata_bundles/src/lib/java/com/android/asllib/DeveloperInfo.java b/tools/app_metadata_bundles/src/lib/java/com/android/asllib/marshallable/DeveloperInfo.java similarity index 98% rename from tools/app_metadata_bundles/src/lib/java/com/android/asllib/DeveloperInfo.java rename to tools/app_metadata_bundles/src/lib/java/com/android/asllib/marshallable/DeveloperInfo.java index 44a5b129e428..382a1f0d0eca 100644 --- a/tools/app_metadata_bundles/src/lib/java/com/android/asllib/DeveloperInfo.java +++ b/tools/app_metadata_bundles/src/lib/java/com/android/asllib/marshallable/DeveloperInfo.java @@ -14,7 +14,9 @@ * limitations under the License. */ -package com.android.asllib; +package com.android.asllib.marshallable; + +import com.android.asllib.util.XmlUtils; import org.w3c.dom.Document; import org.w3c.dom.Element; diff --git a/tools/app_metadata_bundles/src/lib/java/com/android/asllib/DeveloperInfoFactory.java b/tools/app_metadata_bundles/src/lib/java/com/android/asllib/marshallable/DeveloperInfoFactory.java similarity index 96% rename from tools/app_metadata_bundles/src/lib/java/com/android/asllib/DeveloperInfoFactory.java rename to tools/app_metadata_bundles/src/lib/java/com/android/asllib/marshallable/DeveloperInfoFactory.java index 4961892b10c3..b5310bac232a 100644 --- a/tools/app_metadata_bundles/src/lib/java/com/android/asllib/DeveloperInfoFactory.java +++ b/tools/app_metadata_bundles/src/lib/java/com/android/asllib/marshallable/DeveloperInfoFactory.java @@ -14,10 +14,11 @@ * limitations under the License. */ -package com.android.asllib; +package com.android.asllib.marshallable; import com.android.asllib.util.AslgenUtil; import com.android.asllib.util.MalformedXmlException; +import com.android.asllib.util.XmlUtils; import org.w3c.dom.Element; diff --git a/tools/app_metadata_bundles/src/lib/java/com/android/asllib/SafetyLabels.java b/tools/app_metadata_bundles/src/lib/java/com/android/asllib/marshallable/SafetyLabels.java similarity index 95% rename from tools/app_metadata_bundles/src/lib/java/com/android/asllib/SafetyLabels.java rename to tools/app_metadata_bundles/src/lib/java/com/android/asllib/marshallable/SafetyLabels.java index 40ef48dc5334..22c3fd8f2a1c 100644 --- a/tools/app_metadata_bundles/src/lib/java/com/android/asllib/SafetyLabels.java +++ b/tools/app_metadata_bundles/src/lib/java/com/android/asllib/marshallable/SafetyLabels.java @@ -14,7 +14,9 @@ * limitations under the License. */ -package com.android.asllib; +package com.android.asllib.marshallable; + +import com.android.asllib.util.XmlUtils; import org.w3c.dom.Document; import org.w3c.dom.Element; diff --git a/tools/app_metadata_bundles/src/lib/java/com/android/asllib/SafetyLabelsFactory.java b/tools/app_metadata_bundles/src/lib/java/com/android/asllib/marshallable/SafetyLabelsFactory.java similarity index 88% rename from tools/app_metadata_bundles/src/lib/java/com/android/asllib/SafetyLabelsFactory.java rename to tools/app_metadata_bundles/src/lib/java/com/android/asllib/marshallable/SafetyLabelsFactory.java index ab81b1d56033..6bf8ef3df32d 100644 --- a/tools/app_metadata_bundles/src/lib/java/com/android/asllib/SafetyLabelsFactory.java +++ b/tools/app_metadata_bundles/src/lib/java/com/android/asllib/marshallable/SafetyLabelsFactory.java @@ -14,10 +14,11 @@ * limitations under the License. */ -package com.android.asllib; +package com.android.asllib.marshallable; import com.android.asllib.util.AslgenUtil; import com.android.asllib.util.MalformedXmlException; +import com.android.asllib.util.XmlUtils; import org.w3c.dom.Element; @@ -40,7 +41,9 @@ public class SafetyLabelsFactory implements AslMarshallableFactory<SafetyLabels> .createFromHrElements( XmlUtils.listOf( XmlUtils.getSingleChildElement( - safetyLabelsEle, XmlUtils.HR_TAG_DATA_LABELS))); + safetyLabelsEle, + XmlUtils.HR_TAG_DATA_LABELS, + false))); return new SafetyLabels(version, dataLabels); } } diff --git a/tools/app_metadata_bundles/src/lib/java/com/android/asllib/SystemAppSafetyLabel.java b/tools/app_metadata_bundles/src/lib/java/com/android/asllib/marshallable/SystemAppSafetyLabel.java similarity index 94% rename from tools/app_metadata_bundles/src/lib/java/com/android/asllib/SystemAppSafetyLabel.java rename to tools/app_metadata_bundles/src/lib/java/com/android/asllib/marshallable/SystemAppSafetyLabel.java index 93d9c2b080c5..595d748b59af 100644 --- a/tools/app_metadata_bundles/src/lib/java/com/android/asllib/SystemAppSafetyLabel.java +++ b/tools/app_metadata_bundles/src/lib/java/com/android/asllib/marshallable/SystemAppSafetyLabel.java @@ -14,7 +14,9 @@ * limitations under the License. */ -package com.android.asllib; +package com.android.asllib.marshallable; + +import com.android.asllib.util.XmlUtils; import org.w3c.dom.Document; import org.w3c.dom.Element; diff --git a/tools/app_metadata_bundles/src/lib/java/com/android/asllib/SystemAppSafetyLabelFactory.java b/tools/app_metadata_bundles/src/lib/java/com/android/asllib/marshallable/SystemAppSafetyLabelFactory.java similarity index 94% rename from tools/app_metadata_bundles/src/lib/java/com/android/asllib/SystemAppSafetyLabelFactory.java rename to tools/app_metadata_bundles/src/lib/java/com/android/asllib/marshallable/SystemAppSafetyLabelFactory.java index c8c1c7beba24..f99955993d6c 100644 --- a/tools/app_metadata_bundles/src/lib/java/com/android/asllib/SystemAppSafetyLabelFactory.java +++ b/tools/app_metadata_bundles/src/lib/java/com/android/asllib/marshallable/SystemAppSafetyLabelFactory.java @@ -14,10 +14,11 @@ * limitations under the License. */ -package com.android.asllib; +package com.android.asllib.marshallable; import com.android.asllib.util.AslgenUtil; import com.android.asllib.util.MalformedXmlException; +import com.android.asllib.util.XmlUtils; import org.w3c.dom.Element; diff --git a/tools/app_metadata_bundles/src/lib/java/com/android/asllib/TransparencyInfo.java b/tools/app_metadata_bundles/src/lib/java/com/android/asllib/marshallable/TransparencyInfo.java similarity index 96% rename from tools/app_metadata_bundles/src/lib/java/com/android/asllib/TransparencyInfo.java rename to tools/app_metadata_bundles/src/lib/java/com/android/asllib/marshallable/TransparencyInfo.java index 88717b9568b8..ddd3557616ca 100644 --- a/tools/app_metadata_bundles/src/lib/java/com/android/asllib/TransparencyInfo.java +++ b/tools/app_metadata_bundles/src/lib/java/com/android/asllib/marshallable/TransparencyInfo.java @@ -14,7 +14,9 @@ * limitations under the License. */ -package com.android.asllib; +package com.android.asllib.marshallable; + +import com.android.asllib.util.XmlUtils; import org.w3c.dom.Document; import org.w3c.dom.Element; diff --git a/tools/app_metadata_bundles/src/lib/java/com/android/asllib/TransparencyInfoFactory.java b/tools/app_metadata_bundles/src/lib/java/com/android/asllib/marshallable/TransparencyInfoFactory.java similarity index 95% rename from tools/app_metadata_bundles/src/lib/java/com/android/asllib/TransparencyInfoFactory.java rename to tools/app_metadata_bundles/src/lib/java/com/android/asllib/marshallable/TransparencyInfoFactory.java index 13a7eb62fedd..d9c2af41fcac 100644 --- a/tools/app_metadata_bundles/src/lib/java/com/android/asllib/TransparencyInfoFactory.java +++ b/tools/app_metadata_bundles/src/lib/java/com/android/asllib/marshallable/TransparencyInfoFactory.java @@ -14,10 +14,11 @@ * limitations under the License. */ -package com.android.asllib; +package com.android.asllib.marshallable; import com.android.asllib.util.AslgenUtil; import com.android.asllib.util.MalformedXmlException; +import com.android.asllib.util.XmlUtils; import org.w3c.dom.Element; diff --git a/tools/app_metadata_bundles/src/lib/java/com/android/asllib/DataCategoryConstants.java b/tools/app_metadata_bundles/src/lib/java/com/android/asllib/util/DataCategoryConstants.java similarity index 94% rename from tools/app_metadata_bundles/src/lib/java/com/android/asllib/DataCategoryConstants.java rename to tools/app_metadata_bundles/src/lib/java/com/android/asllib/util/DataCategoryConstants.java index b364c8b37194..b5ae54c5bc00 100644 --- a/tools/app_metadata_bundles/src/lib/java/com/android/asllib/DataCategoryConstants.java +++ b/tools/app_metadata_bundles/src/lib/java/com/android/asllib/util/DataCategoryConstants.java @@ -14,8 +14,11 @@ * limitations under the License. */ -package com.android.asllib; +package com.android.asllib.util; +import com.android.asllib.marshallable.DataCategory; +import com.android.asllib.marshallable.DataType; +import com.android.asllib.marshallable.SafetyLabels; import java.util.Arrays; import java.util.Collections; diff --git a/tools/app_metadata_bundles/src/lib/java/com/android/asllib/util/DataTypeConstants.java b/tools/app_metadata_bundles/src/lib/java/com/android/asllib/util/DataTypeConstants.java new file mode 100644 index 000000000000..358d575c1d56 --- /dev/null +++ b/tools/app_metadata_bundles/src/lib/java/com/android/asllib/util/DataTypeConstants.java @@ -0,0 +1,197 @@ +/* + * Copyright (C) 2024 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.android.asllib.util; + +import com.android.asllib.marshallable.DataCategory; +import com.android.asllib.marshallable.DataType; +import com.android.asllib.marshallable.SafetyLabels; + +import com.google.common.collect.ImmutableMap; +import com.google.common.collect.ImmutableSet; + +import java.util.Map; +import java.util.Set; + +/** + * Constants for determining valid {@link String} data types for usage within {@link SafetyLabels}, + * {@link DataCategory}, and {@link DataType} + */ +public class DataTypeConstants { + /** Data types for {@link DataCategoryConstants.CATEGORY_PERSONAL} */ + public static final String TYPE_NAME = "name"; + + public static final String TYPE_EMAIL_ADDRESS = "email_address"; + public static final String TYPE_PHYSICAL_ADDRESS = "physical_address"; + public static final String TYPE_PHONE_NUMBER = "phone_number"; + public static final String TYPE_RACE_ETHNICITY = "race_ethnicity"; + public static final String TYPE_POLITICAL_OR_RELIGIOUS_BELIEFS = + "political_or_religious_beliefs"; + public static final String TYPE_SEXUAL_ORIENTATION_OR_GENDER_IDENTITY = + "sexual_orientation_or_gender_identity"; + public static final String TYPE_PERSONAL_IDENTIFIERS = "personal_identifiers"; + public static final String TYPE_OTHER = "other"; + + /** Data types for {@link DataCategoryConstants.CATEGORY_FINANCIAL} */ + public static final String TYPE_CARD_BANK_ACCOUNT = "card_bank_account"; + + public static final String TYPE_PURCHASE_HISTORY = "purchase_history"; + public static final String TYPE_CREDIT_SCORE = "credit_score"; + public static final String TYPE_FINANCIAL_OTHER = "other"; + + /** Data types for {@link DataCategoryConstants.CATEGORY_LOCATION} */ + public static final String TYPE_APPROX_LOCATION = "approx_location"; + + public static final String TYPE_PRECISE_LOCATION = "precise_location"; + + /** Data types for {@link DataCategoryConstants.CATEGORY_EMAIL_TEXT_MESSAGE} */ + public static final String TYPE_EMAILS = "emails"; + + public static final String TYPE_TEXT_MESSAGES = "text_messages"; + public static final String TYPE_EMAIL_TEXT_MESSAGE_OTHER = "other"; + + /** Data types for {@link DataCategoryConstants.CATEGORY_PHOTO_VIDEO} */ + public static final String TYPE_PHOTOS = "photos"; + + public static final String TYPE_VIDEOS = "videos"; + + /** Data types for {@link DataCategoryConstants.CATEGORY_AUDIO} */ + public static final String TYPE_SOUND_RECORDINGS = "sound_recordings"; + + public static final String TYPE_MUSIC_FILES = "music_files"; + public static final String TYPE_AUDIO_OTHER = "other"; + + /** Data types for {@link DataCategoryConstants.CATEGORY_STORAGE} */ + public static final String TYPE_FILES_DOCS = "files_docs"; + + /** Data types for {@link DataCategoryConstants.CATEGORY_HEALTH_FITNESS} */ + public static final String TYPE_HEALTH = "health"; + + public static final String TYPE_FITNESS = "fitness"; + + /** Data types for {@link DataCategoryConstants.CATEGORY_CONTACTS} */ + public static final String TYPE_CONTACTS = "contacts"; + + /** Data types for {@link DataCategoryConstants.CATEGORY_CALENDAR} */ + public static final String TYPE_CALENDAR = "calendar"; + + /** Data types for {@link DataCategoryConstants.CATEGORY_IDENTIFIERS} */ + public static final String TYPE_IDENTIFIERS_OTHER = "other"; + + /** Data types for {@link DataCategoryConstants.CATEGORY_APP_PERFORMANCE} */ + public static final String TYPE_CRASH_LOGS = "crash_logs"; + + public static final String TYPE_PERFORMANCE_DIAGNOSTICS = "performance_diagnostics"; + public static final String TYPE_APP_PERFORMANCE_OTHER = "other"; + + /** Data types for {@link DataCategoryConstants.CATEGORY_ACTIONS_IN_APP} */ + public static final String TYPE_USER_INTERACTION = "user_interaction"; + + public static final String TYPE_IN_APP_SEARCH_HISTORY = "in_app_search_history"; + public static final String TYPE_INSTALLED_APPS = "installed_apps"; + public static final String TYPE_USER_GENERATED_CONTENT = "user_generated_content"; + public static final String TYPE_ACTIONS_IN_APP_OTHER = "other"; + + /** Data types for {@link DataCategoryConstants.CATEGORY_SEARCH_AND_BROWSING} */ + public static final String TYPE_WEB_BROWSING_HISTORY = "web_browsing_history"; + + /** Set of valid categories */ + private static final Map<String, Set<String>> VALID_DATA_TYPES = + new ImmutableMap.Builder<String, Set<String>>() + .put( + DataCategoryConstants.CATEGORY_PERSONAL, + ImmutableSet.of( + DataTypeConstants.TYPE_NAME, + DataTypeConstants.TYPE_EMAIL_ADDRESS, + DataTypeConstants.TYPE_PHYSICAL_ADDRESS, + DataTypeConstants.TYPE_PHONE_NUMBER, + DataTypeConstants.TYPE_RACE_ETHNICITY, + DataTypeConstants.TYPE_POLITICAL_OR_RELIGIOUS_BELIEFS, + DataTypeConstants.TYPE_SEXUAL_ORIENTATION_OR_GENDER_IDENTITY, + DataTypeConstants.TYPE_PERSONAL_IDENTIFIERS, + DataTypeConstants.TYPE_OTHER)) + .put( + DataCategoryConstants.CATEGORY_FINANCIAL, + ImmutableSet.of( + DataTypeConstants.TYPE_CARD_BANK_ACCOUNT, + DataTypeConstants.TYPE_PURCHASE_HISTORY, + DataTypeConstants.TYPE_CREDIT_SCORE, + DataTypeConstants.TYPE_OTHER)) + .put( + DataCategoryConstants.CATEGORY_LOCATION, + ImmutableSet.of( + DataTypeConstants.TYPE_APPROX_LOCATION, + DataTypeConstants.TYPE_PRECISE_LOCATION)) + .put( + DataCategoryConstants.CATEGORY_EMAIL_TEXT_MESSAGE, + ImmutableSet.of( + DataTypeConstants.TYPE_EMAILS, + DataTypeConstants.TYPE_TEXT_MESSAGES, + DataTypeConstants.TYPE_OTHER)) + .put( + DataCategoryConstants.CATEGORY_PHOTO_VIDEO, + ImmutableSet.of( + DataTypeConstants.TYPE_PHOTOS, DataTypeConstants.TYPE_VIDEOS)) + .put( + DataCategoryConstants.CATEGORY_AUDIO, + ImmutableSet.of( + DataTypeConstants.TYPE_SOUND_RECORDINGS, + DataTypeConstants.TYPE_MUSIC_FILES, + DataTypeConstants.TYPE_OTHER)) + .put( + DataCategoryConstants.CATEGORY_STORAGE, + ImmutableSet.of(DataTypeConstants.TYPE_FILES_DOCS)) + .put( + DataCategoryConstants.CATEGORY_HEALTH_FITNESS, + ImmutableSet.of( + DataTypeConstants.TYPE_HEALTH, DataTypeConstants.TYPE_FITNESS)) + .put( + DataCategoryConstants.CATEGORY_CONTACTS, + ImmutableSet.of(DataTypeConstants.TYPE_CONTACTS)) + .put( + DataCategoryConstants.CATEGORY_CALENDAR, + ImmutableSet.of(DataTypeConstants.TYPE_CALENDAR)) + .put( + DataCategoryConstants.CATEGORY_IDENTIFIERS, + ImmutableSet.of(DataTypeConstants.TYPE_OTHER)) + .put( + DataCategoryConstants.CATEGORY_APP_PERFORMANCE, + ImmutableSet.of( + DataTypeConstants.TYPE_CRASH_LOGS, + DataTypeConstants.TYPE_PERFORMANCE_DIAGNOSTICS, + DataTypeConstants.TYPE_OTHER)) + .put( + DataCategoryConstants.CATEGORY_ACTIONS_IN_APP, + ImmutableSet.of( + DataTypeConstants.TYPE_USER_INTERACTION, + DataTypeConstants.TYPE_IN_APP_SEARCH_HISTORY, + DataTypeConstants.TYPE_INSTALLED_APPS, + DataTypeConstants.TYPE_USER_GENERATED_CONTENT, + DataTypeConstants.TYPE_OTHER)) + .put( + DataCategoryConstants.CATEGORY_SEARCH_AND_BROWSING, + ImmutableSet.of(DataTypeConstants.TYPE_WEB_BROWSING_HISTORY)) + .buildOrThrow(); + + /** Returns {@link Set} of valid {@link String} category keys */ + public static Map<String, Set<String>> getValidDataTypes() { + return VALID_DATA_TYPES; + } + + private DataTypeConstants() { + /* do nothing - hide constructor */ + } +} diff --git a/tools/app_metadata_bundles/src/lib/java/com/android/asllib/XmlUtils.java b/tools/app_metadata_bundles/src/lib/java/com/android/asllib/util/XmlUtils.java similarity index 92% rename from tools/app_metadata_bundles/src/lib/java/com/android/asllib/XmlUtils.java rename to tools/app_metadata_bundles/src/lib/java/com/android/asllib/util/XmlUtils.java index cc8fe79cb579..691f92fca54b 100644 --- a/tools/app_metadata_bundles/src/lib/java/com/android/asllib/XmlUtils.java +++ b/tools/app_metadata_bundles/src/lib/java/com/android/asllib/util/XmlUtils.java @@ -14,9 +14,7 @@ * limitations under the License. */ -package com.android.asllib; - -import com.android.asllib.util.MalformedXmlException; +package com.android.asllib.util; import org.w3c.dom.Document; import org.w3c.dom.Element; @@ -259,21 +257,42 @@ public class XmlUtils { } /** Tries getting required version attribute and throws exception if it doesn't exist */ - public static Long tryGetVersion(Element ele) { + public static Long tryGetVersion(Element ele) throws MalformedXmlException { long version; try { version = Long.parseLong(ele.getAttribute(XmlUtils.HR_ATTR_VERSION)); } catch (Exception e) { - throw new IllegalArgumentException( + throw new MalformedXmlException( String.format( "Malformed or missing required version in: %s", ele.getTagName())); } return version; } - /** Gets an optional Boolean attribute. */ - public static Boolean getBoolAttr(Element ele, String attrName) { - return XmlUtils.fromString(ele.getAttribute(attrName)); + /** Gets a pipeline-split attribute. */ + public static List<String> getPipelineSplitAttr(Element ele, String attrName, boolean required) + throws MalformedXmlException { + List<String> list = Arrays.stream(ele.getAttribute(attrName).split("\\|")).toList(); + if ((list.isEmpty() || list.get(0).isEmpty()) && required) { + throw new MalformedXmlException( + String.format( + "Delimited string %s was required but missing, in %s.", + attrName, ele.getTagName())); + } + return list; + } + + /** Gets a Boolean attribute. */ + public static Boolean getBoolAttr(Element ele, String attrName, boolean required) + throws MalformedXmlException { + Boolean b = XmlUtils.fromString(ele.getAttribute(attrName)); + if (b == null && required) { + throw new MalformedXmlException( + String.format( + "Boolean %s was required but missing, in %s.", + attrName, ele.getTagName())); + } + return b; } /** Gets a required String attribute. */ diff --git a/tools/app_metadata_bundles/src/test/java/com/android/aslgen/AllTests.java b/tools/app_metadata_bundles/src/test/java/com/android/asllib/AllTests.java similarity index 67% rename from tools/app_metadata_bundles/src/test/java/com/android/aslgen/AllTests.java rename to tools/app_metadata_bundles/src/test/java/com/android/asllib/AllTests.java index 7ebb7a1c44bf..03e8ac6d11c0 100644 --- a/tools/app_metadata_bundles/src/test/java/com/android/aslgen/AllTests.java +++ b/tools/app_metadata_bundles/src/test/java/com/android/asllib/AllTests.java @@ -14,7 +14,12 @@ * limitations under the License. */ -package com.android.aslgen; +package com.android.asllib; + +import com.android.asllib.marshallable.AndroidSafetyLabelTest; +import com.android.asllib.marshallable.DataCategoryTest; +import com.android.asllib.marshallable.DataLabelsTest; +import com.android.asllib.marshallable.DeveloperInfoTest; import org.junit.runner.RunWith; import org.junit.runners.Suite; @@ -22,5 +27,9 @@ import org.junit.runners.Suite; @RunWith(Suite.class) @Suite.SuiteClasses({ AslgenTests.class, + AndroidSafetyLabelTest.class, + DeveloperInfoTest.class, + DataCategoryTest.class, + DataLabelsTest.class, }) public class AllTests {} diff --git a/tools/app_metadata_bundles/src/test/java/com/android/aslgen/AslgenTests.java b/tools/app_metadata_bundles/src/test/java/com/android/asllib/AslgenTests.java similarity index 58% rename from tools/app_metadata_bundles/src/test/java/com/android/aslgen/AslgenTests.java rename to tools/app_metadata_bundles/src/test/java/com/android/asllib/AslgenTests.java index 3026f8bec2ed..5f43008d3dc6 100644 --- a/tools/app_metadata_bundles/src/test/java/com/android/aslgen/AslgenTests.java +++ b/tools/app_metadata_bundles/src/test/java/com/android/asllib/AslgenTests.java @@ -14,40 +14,26 @@ * limitations under the License. */ -package com.android.aslgen; +package com.android.asllib; import static org.junit.Assert.assertEquals; -import com.android.asllib.AndroidSafetyLabel; -import com.android.asllib.AslConverter; +import com.android.asllib.marshallable.AndroidSafetyLabel; +import com.android.asllib.testutils.TestUtils; import org.junit.Test; import org.junit.runner.RunWith; import org.junit.runners.JUnit4; -import org.w3c.dom.Document; -import org.xml.sax.SAXException; -import java.io.ByteArrayInputStream; -import java.io.ByteArrayOutputStream; -import java.io.IOException; import java.io.InputStream; import java.nio.charset.StandardCharsets; import java.nio.file.Path; import java.nio.file.Paths; import java.util.List; -import javax.xml.parsers.DocumentBuilderFactory; -import javax.xml.parsers.ParserConfigurationException; -import javax.xml.transform.OutputKeys; -import javax.xml.transform.Transformer; -import javax.xml.transform.TransformerException; -import javax.xml.transform.TransformerFactory; -import javax.xml.transform.dom.DOMSource; -import javax.xml.transform.stream.StreamResult; - @RunWith(JUnit4.class) public class AslgenTests { - private static final String VALID_MAPPINGS_PATH = "com/android/aslgen/validmappings"; + private static final String VALID_MAPPINGS_PATH = "com/android/asllib/validmappings"; private static final List<String> VALID_MAPPINGS_SUBDIRS = List.of("location", "contacts"); private static final String HR_XML_FILENAME = "hr.xml"; private static final String OD_XML_FILENAME = "od.xml"; @@ -78,28 +64,9 @@ public class AslgenTests { String out = AslConverter.getXmlAsString(asl, AslConverter.Format.ON_DEVICE); System.out.println("out: " + out); - assertEquals(getFormattedXml(out), getFormattedXml(odContents)); + assertEquals( + TestUtils.getFormattedXml(out, false), + TestUtils.getFormattedXml(odContents, false)); } } - - private static String getFormattedXml(String xmlStr) - throws ParserConfigurationException, IOException, SAXException, TransformerException { - InputStream stream = new ByteArrayInputStream(xmlStr.getBytes(StandardCharsets.UTF_8)); - DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance(); - factory.setNamespaceAware(true); - Document document = factory.newDocumentBuilder().parse(stream); - - TransformerFactory transformerFactory = TransformerFactory.newInstance(); - Transformer transformer = transformerFactory.newTransformer(); - transformer.setOutputProperty(OutputKeys.INDENT, "yes"); - transformer.setOutputProperty(OutputKeys.ENCODING, "UTF-8"); - transformer.setOutputProperty(OutputKeys.OMIT_XML_DECLARATION, "no"); - - ByteArrayOutputStream outStream = new ByteArrayOutputStream(); - StreamResult streamResult = new StreamResult(outStream); // out - DOMSource domSource = new DOMSource(document); - transformer.transform(domSource, streamResult); - - return outStream.toString(StandardCharsets.UTF_8); - } } diff --git a/tools/app_metadata_bundles/src/test/java/com/android/asllib/marshallable/AndroidSafetyLabelTest.java b/tools/app_metadata_bundles/src/test/java/com/android/asllib/marshallable/AndroidSafetyLabelTest.java new file mode 100644 index 000000000000..013700728e50 --- /dev/null +++ b/tools/app_metadata_bundles/src/test/java/com/android/asllib/marshallable/AndroidSafetyLabelTest.java @@ -0,0 +1,97 @@ +/* + * Copyright (C) 2017 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.android.asllib.marshallable; + +import com.android.asllib.testutils.TestUtils; + +import org.junit.Before; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; +import org.w3c.dom.Document; + +@RunWith(JUnit4.class) +public class AndroidSafetyLabelTest { + private static final String ANDROID_SAFETY_LABEL_HR_PATH = + "com/android/asllib/androidsafetylabel/hr"; + private static final String ANDROID_SAFETY_LABEL_OD_PATH = + "com/android/asllib/androidsafetylabel/od"; + + private static final String MISSING_VERSION_FILE_NAME = "missing-version.xml"; + private static final String VALID_EMPTY_FILE_NAME = "valid-empty.xml"; + private static final String WITH_SAFETY_LABELS_FILE_NAME = "with-safety-labels.xml"; + private static final String WITH_SYSTEM_APP_SAFETY_LABEL_FILE_NAME = + "with-system-app-safety-label.xml"; + private static final String WITH_TRANSPARENCY_INFO_FILE_NAME = "with-transparency-info.xml"; + + private Document mDoc = null; + + @Before + public void setUp() throws Exception { + System.out.println("set up."); + mDoc = TestUtils.document(); + } + + /** Test for android safety label missing version. */ + @Test + public void testAndroidSafetyLabelMissingVersion() throws Exception { + System.out.println("starting testAndroidSafetyLabelMissingVersion."); + hrToOdExpectException(MISSING_VERSION_FILE_NAME); + } + + /** Test for android safety label valid empty. */ + @Test + public void testAndroidSafetyLabelValidEmptyFile() throws Exception { + System.out.println("starting testAndroidSafetyLabelValidEmptyFile."); + testHrToOdAndroidSafetyLabel(VALID_EMPTY_FILE_NAME); + } + + /** Test for android safety label with safety labels. */ + @Test + public void testAndroidSafetyLabelWithSafetyLabels() throws Exception { + System.out.println("starting testAndroidSafetyLabelWithSafetyLabels."); + testHrToOdAndroidSafetyLabel(WITH_SAFETY_LABELS_FILE_NAME); + } + + /** Test for android safety label with system app safety label. */ + @Test + public void testAndroidSafetyLabelWithSystemAppSafetyLabel() throws Exception { + System.out.println("starting testAndroidSafetyLabelWithSystemAppSafetyLabel."); + testHrToOdAndroidSafetyLabel(WITH_SYSTEM_APP_SAFETY_LABEL_FILE_NAME); + } + + /** Test for android safety label with transparency info. */ + @Test + public void testAndroidSafetyLabelWithTransparencyInfo() throws Exception { + System.out.println("starting testAndroidSafetyLabelWithTransparencyInfo."); + testHrToOdAndroidSafetyLabel(WITH_TRANSPARENCY_INFO_FILE_NAME); + } + + private void hrToOdExpectException(String fileName) { + TestUtils.hrToOdExpectException( + new AndroidSafetyLabelFactory(), ANDROID_SAFETY_LABEL_HR_PATH, fileName); + } + + private void testHrToOdAndroidSafetyLabel(String fileName) throws Exception { + TestUtils.testHrToOd( + mDoc, + new AndroidSafetyLabelFactory(), + ANDROID_SAFETY_LABEL_HR_PATH, + ANDROID_SAFETY_LABEL_OD_PATH, + fileName); + } +} diff --git a/tools/app_metadata_bundles/src/test/java/com/android/asllib/marshallable/AppInfoTest.java b/tools/app_metadata_bundles/src/test/java/com/android/asllib/marshallable/AppInfoTest.java new file mode 100644 index 000000000000..a015e2eacac5 --- /dev/null +++ b/tools/app_metadata_bundles/src/test/java/com/android/asllib/marshallable/AppInfoTest.java @@ -0,0 +1,107 @@ +/* + * Copyright (C) 2017 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.android.asllib.marshallable; + +import static org.junit.Assert.assertThrows; + +import com.android.asllib.testutils.TestUtils; +import com.android.asllib.util.MalformedXmlException; + +import org.junit.Before; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; +import org.w3c.dom.Document; + +import java.nio.file.Paths; +import java.util.List; + +@RunWith(JUnit4.class) +public class AppInfoTest { + private static final String APP_INFO_HR_PATH = "com/android/asllib/appinfo/hr"; + private static final String APP_INFO_OD_PATH = "com/android/asllib/appinfo/od"; + public static final List<String> REQUIRED_FIELD_NAMES = + List.of( + "title", + "description", + "containsAds", + "obeyAps", + "adsFingerprinting", + "securityFingerprinting", + "privacyPolicy", + "securityEndpoints", + "firstPartyEndpoints", + "serviceProviderEndpoints", + "category", + "email"); + public static final List<String> OPTIONAL_FIELD_NAMES = List.of("website"); + + private static final String ALL_FIELDS_VALID_FILE_NAME = "all-fields-valid.xml"; + + private Document mDoc = null; + + /** Logic for setting up tests (empty if not yet needed). */ + public static void main(String[] params) throws Exception {} + + @Before + public void setUp() throws Exception { + System.out.println("set up."); + mDoc = TestUtils.document(); + } + + /** Test for all fields valid. */ + @Test + public void testAllFieldsValid() throws Exception { + System.out.println("starting testAllFieldsValid."); + testHrToOdAppInfo(ALL_FIELDS_VALID_FILE_NAME); + } + + /** Tests missing required fields fails. */ + @Test + public void testMissingRequiredFields() throws Exception { + System.out.println("Starting testMissingRequiredFields"); + for (String reqField : REQUIRED_FIELD_NAMES) { + System.out.println("testing missing required field: " + reqField); + var appInfoEle = + TestUtils.getElementsFromResource( + Paths.get(APP_INFO_HR_PATH, ALL_FIELDS_VALID_FILE_NAME)); + appInfoEle.get(0).removeAttribute(reqField); + + assertThrows( + MalformedXmlException.class, + () -> new AppInfoFactory().createFromHrElements(appInfoEle)); + } + } + + /** Tests missing optional fields passes. */ + @Test + public void testMissingOptionalFields() throws Exception { + for (String optField : OPTIONAL_FIELD_NAMES) { + var ele = + TestUtils.getElementsFromResource( + Paths.get(APP_INFO_HR_PATH, ALL_FIELDS_VALID_FILE_NAME)); + ele.get(0).removeAttribute(optField); + AppInfo appInfo = new AppInfoFactory().createFromHrElements(ele); + appInfo.toOdDomElements(mDoc); + } + } + + private void testHrToOdAppInfo(String fileName) throws Exception { + TestUtils.testHrToOd( + mDoc, new AppInfoFactory(), APP_INFO_HR_PATH, APP_INFO_OD_PATH, fileName); + } +} diff --git a/tools/app_metadata_bundles/src/test/java/com/android/asllib/marshallable/DataCategoryTest.java b/tools/app_metadata_bundles/src/test/java/com/android/asllib/marshallable/DataCategoryTest.java new file mode 100644 index 000000000000..822f1753f662 --- /dev/null +++ b/tools/app_metadata_bundles/src/test/java/com/android/asllib/marshallable/DataCategoryTest.java @@ -0,0 +1,216 @@ +/* + * Copyright (C) 2017 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.android.asllib.marshallable; + +import com.android.asllib.testutils.TestUtils; + +import org.junit.Before; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; +import org.w3c.dom.Document; + +@RunWith(JUnit4.class) +public class DataCategoryTest { + private static final String DATA_CATEGORY_HR_PATH = "com/android/asllib/datacategory/hr"; + private static final String DATA_CATEGORY_OD_PATH = "com/android/asllib/datacategory/od"; + + private static final String VALID_PERSONAL_FILE_NAME = "data-category-personal.xml"; + private static final String VALID_PARTIAL_PERSONAL_FILE_NAME = + "data-category-personal-partial.xml"; + private static final String VALID_FINANCIAL_FILE_NAME = "data-category-financial.xml"; + private static final String VALID_LOCATION_FILE_NAME = "data-category-location.xml"; + private static final String VALID_EMAIL_TEXT_MESSAGE_FILE_NAME = + "data-category-email-text-message.xml"; + private static final String VALID_PHOTO_VIDEO_FILE_NAME = "data-category-photo-video.xml"; + private static final String VALID_AUDIO_FILE_NAME = "data-category-audio.xml"; + private static final String VALID_STORAGE_FILE_NAME = "data-category-storage.xml"; + private static final String VALID_HEALTH_FITNESS_FILE_NAME = "data-category-health-fitness.xml"; + private static final String VALID_CONTACTS_FILE_NAME = "data-category-contacts.xml"; + private static final String VALID_CALENDAR_FILE_NAME = "data-category-calendar.xml"; + private static final String VALID_IDENTIFIERS_FILE_NAME = "data-category-identifiers.xml"; + private static final String VALID_APP_PERFORMANCE_FILE_NAME = + "data-category-app-performance.xml"; + private static final String VALID_ACTIONS_IN_APP_FILE_NAME = "data-category-actions-in-app.xml"; + private static final String VALID_SEARCH_AND_BROWSING_FILE_NAME = + "data-category-search-and-browsing.xml"; + + private static final String EMPTY_PURPOSE_PERSONAL_FILE_NAME = + "data-category-personal-empty-purpose.xml"; + private static final String MISSING_PURPOSE_PERSONAL_FILE_NAME = + "data-category-personal-missing-purpose.xml"; + private static final String UNRECOGNIZED_TYPE_PERSONAL_FILE_NAME = + "data-category-personal-unrecognized-type.xml"; + private static final String UNRECOGNIZED_CATEGORY_FILE_NAME = "data-category-unrecognized.xml"; + + private Document mDoc = null; + + /** Logic for setting up tests (empty if not yet needed). */ + public static void main(String[] params) throws Exception {} + + @Before + public void setUp() throws Exception { + System.out.println("set up."); + mDoc = TestUtils.document(); + } + + /** Test for data category personal. */ + @Test + public void testDataCategoryPersonal() throws Exception { + System.out.println("starting testDataCategoryPersonal."); + testHrToOdDataCategory(VALID_PERSONAL_FILE_NAME); + } + + /** Test for data category financial. */ + @Test + public void testDataCategoryFinancial() throws Exception { + System.out.println("starting testDataCategoryFinancial."); + testHrToOdDataCategory(VALID_FINANCIAL_FILE_NAME); + } + + /** Test for data category location. */ + @Test + public void testDataCategoryLocation() throws Exception { + System.out.println("starting testDataCategoryLocation."); + testHrToOdDataCategory(VALID_LOCATION_FILE_NAME); + } + + /** Test for data category email text message. */ + @Test + public void testDataCategoryEmailTextMessage() throws Exception { + System.out.println("starting testDataCategoryEmailTextMessage."); + testHrToOdDataCategory(VALID_EMAIL_TEXT_MESSAGE_FILE_NAME); + } + + /** Test for data category photo video. */ + @Test + public void testDataCategoryPhotoVideo() throws Exception { + System.out.println("starting testDataCategoryPhotoVideo."); + testHrToOdDataCategory(VALID_PHOTO_VIDEO_FILE_NAME); + } + + /** Test for data category audio. */ + @Test + public void testDataCategoryAudio() throws Exception { + System.out.println("starting testDataCategoryAudio."); + testHrToOdDataCategory(VALID_AUDIO_FILE_NAME); + } + + /** Test for data category storage. */ + @Test + public void testDataCategoryStorage() throws Exception { + System.out.println("starting testDataCategoryStorage."); + testHrToOdDataCategory(VALID_STORAGE_FILE_NAME); + } + + /** Test for data category health fitness. */ + @Test + public void testDataCategoryHealthFitness() throws Exception { + System.out.println("starting testDataCategoryHealthFitness."); + testHrToOdDataCategory(VALID_HEALTH_FITNESS_FILE_NAME); + } + + /** Test for data category contacts. */ + @Test + public void testDataCategoryContacts() throws Exception { + System.out.println("starting testDataCategoryContacts."); + testHrToOdDataCategory(VALID_CONTACTS_FILE_NAME); + } + + /** Test for data category calendar. */ + @Test + public void testDataCategoryCalendar() throws Exception { + System.out.println("starting testDataCategoryCalendar."); + testHrToOdDataCategory(VALID_CALENDAR_FILE_NAME); + } + + /** Test for data category identifiers. */ + @Test + public void testDataCategoryIdentifiers() throws Exception { + System.out.println("starting testDataCategoryIdentifiers."); + testHrToOdDataCategory(VALID_IDENTIFIERS_FILE_NAME); + } + + /** Test for data category app performance. */ + @Test + public void testDataCategoryAppPerformance() throws Exception { + System.out.println("starting testDataCategoryAppPerformance."); + testHrToOdDataCategory(VALID_APP_PERFORMANCE_FILE_NAME); + } + + /** Test for data category actions in app. */ + @Test + public void testDataCategoryActionsInApp() throws Exception { + System.out.println("starting testDataCategoryActionsInApp."); + testHrToOdDataCategory(VALID_ACTIONS_IN_APP_FILE_NAME); + } + + /** Test for data category search and browsing. */ + @Test + public void testDataCategorySearchAndBrowsing() throws Exception { + System.out.println("starting testDataCategorySearchAndBrowsing."); + testHrToOdDataCategory(VALID_SEARCH_AND_BROWSING_FILE_NAME); + } + + /** Test for data category search and browsing. */ + @Test + public void testMissingOptionalsAllowed() throws Exception { + System.out.println("starting testMissingOptionalsAllowed."); + testHrToOdDataCategory(VALID_PARTIAL_PERSONAL_FILE_NAME); + } + + /** Test for empty purposes. */ + @Test + public void testEmptyPurposesNotAllowed() throws Exception { + System.out.println("starting testEmptyPurposesNotAllowed."); + hrToOdExpectException(EMPTY_PURPOSE_PERSONAL_FILE_NAME); + } + + /** Test for missing purposes. */ + @Test + public void testMissingPurposesNotAllowed() throws Exception { + System.out.println("starting testMissingPurposesNotAllowed."); + hrToOdExpectException(MISSING_PURPOSE_PERSONAL_FILE_NAME); + } + + /** Test for unrecognized type. */ + @Test + public void testUnrecognizedTypeNotAllowed() throws Exception { + System.out.println("starting testUnrecognizedTypeNotAllowed."); + hrToOdExpectException(UNRECOGNIZED_TYPE_PERSONAL_FILE_NAME); + } + + /** Test for unrecognized category. */ + @Test + public void testUnrecognizedCategoryNotAllowed() throws Exception { + System.out.println("starting testUnrecognizedCategoryNotAllowed."); + hrToOdExpectException(UNRECOGNIZED_CATEGORY_FILE_NAME); + } + + private void hrToOdExpectException(String fileName) { + TestUtils.hrToOdExpectException(new DataCategoryFactory(), DATA_CATEGORY_HR_PATH, fileName); + } + + private void testHrToOdDataCategory(String fileName) throws Exception { + TestUtils.testHrToOd( + mDoc, + new DataCategoryFactory(), + DATA_CATEGORY_HR_PATH, + DATA_CATEGORY_OD_PATH, + fileName); + } +} diff --git a/tools/app_metadata_bundles/src/test/java/com/android/asllib/marshallable/DataLabelsTest.java b/tools/app_metadata_bundles/src/test/java/com/android/asllib/marshallable/DataLabelsTest.java new file mode 100644 index 000000000000..2be447e182b2 --- /dev/null +++ b/tools/app_metadata_bundles/src/test/java/com/android/asllib/marshallable/DataLabelsTest.java @@ -0,0 +1,102 @@ +/* + * Copyright (C) 2017 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.android.asllib.marshallable; + +import com.android.asllib.testutils.TestUtils; + +import org.junit.Before; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; +import org.w3c.dom.Document; + +@RunWith(JUnit4.class) +public class DataLabelsTest { + private static final String DATA_LABELS_HR_PATH = "com/android/asllib/datalabels/hr"; + private static final String DATA_LABELS_OD_PATH = "com/android/asllib/datalabels/od"; + + private static final String ACCESSED_VALID_BOOL_FILE_NAME = + "data-labels-accessed-valid-bool.xml"; + private static final String ACCESSED_INVALID_BOOL_FILE_NAME = + "data-labels-accessed-invalid-bool.xml"; + private static final String COLLECTED_VALID_BOOL_FILE_NAME = + "data-labels-collected-valid-bool.xml"; + private static final String COLLECTED_INVALID_BOOL_FILE_NAME = + "data-labels-collected-invalid-bool.xml"; + private static final String SHARED_VALID_BOOL_FILE_NAME = "data-labels-shared-valid-bool.xml"; + private static final String SHARED_INVALID_BOOL_FILE_NAME = + "data-labels-shared-invalid-bool.xml"; + + private Document mDoc = null; + + @Before + public void setUp() throws Exception { + System.out.println("set up."); + mDoc = TestUtils.document(); + } + + /** Test for data labels accessed valid bool. */ + @Test + public void testDataLabelsAccessedValidBool() throws Exception { + System.out.println("starting testDataLabelsAccessedValidBool."); + testHrToOdDataLabels(ACCESSED_VALID_BOOL_FILE_NAME); + } + + /** Test for data labels accessed invalid bool. */ + @Test + public void testDataLabelsAccessedInvalidBool() throws Exception { + System.out.println("starting testDataLabelsAccessedInvalidBool."); + hrToOdExpectException(ACCESSED_INVALID_BOOL_FILE_NAME); + } + + /** Test for data labels collected valid bool. */ + @Test + public void testDataLabelsCollectedValidBool() throws Exception { + System.out.println("starting testDataLabelsCollectedValidBool."); + testHrToOdDataLabels(COLLECTED_VALID_BOOL_FILE_NAME); + } + + /** Test for data labels collected invalid bool. */ + @Test + public void testDataLabelsCollectedInvalidBool() throws Exception { + System.out.println("starting testDataLabelsCollectedInvalidBool."); + hrToOdExpectException(COLLECTED_INVALID_BOOL_FILE_NAME); + } + + /** Test for data labels shared valid bool. */ + @Test + public void testDataLabelsSharedValidBool() throws Exception { + System.out.println("starting testDataLabelsSharedValidBool."); + testHrToOdDataLabels(SHARED_VALID_BOOL_FILE_NAME); + } + + /** Test for data labels shared invalid bool. */ + @Test + public void testDataLabelsSharedInvalidBool() throws Exception { + System.out.println("starting testDataLabelsSharedInvalidBool."); + hrToOdExpectException(SHARED_INVALID_BOOL_FILE_NAME); + } + + private void hrToOdExpectException(String fileName) { + TestUtils.hrToOdExpectException(new DataLabelsFactory(), DATA_LABELS_HR_PATH, fileName); + } + + private void testHrToOdDataLabels(String fileName) throws Exception { + TestUtils.testHrToOd( + mDoc, new DataLabelsFactory(), DATA_LABELS_HR_PATH, DATA_LABELS_OD_PATH, fileName); + } +} diff --git a/tools/app_metadata_bundles/src/test/java/com/android/asllib/marshallable/DeveloperInfoTest.java b/tools/app_metadata_bundles/src/test/java/com/android/asllib/marshallable/DeveloperInfoTest.java new file mode 100644 index 000000000000..ff8346a526ad --- /dev/null +++ b/tools/app_metadata_bundles/src/test/java/com/android/asllib/marshallable/DeveloperInfoTest.java @@ -0,0 +1,100 @@ +/* + * Copyright (C) 2017 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.android.asllib.marshallable; + +import static org.junit.Assert.assertThrows; + +import com.android.asllib.testutils.TestUtils; +import com.android.asllib.util.MalformedXmlException; + +import org.junit.Before; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; +import org.w3c.dom.Document; + +import java.nio.file.Paths; +import java.util.List; + +@RunWith(JUnit4.class) +public class DeveloperInfoTest { + private static final String DEVELOPER_INFO_HR_PATH = "com/android/asllib/developerinfo/hr"; + private static final String DEVELOPER_INFO_OD_PATH = "com/android/asllib/developerinfo/od"; + public static final List<String> REQUIRED_FIELD_NAMES = + List.of("address", "countryRegion", "email", "name", "relationship"); + public static final List<String> OPTIONAL_FIELD_NAMES = List.of("website", "registryId"); + + private static final String ALL_FIELDS_VALID_FILE_NAME = "all-fields-valid.xml"; + + private Document mDoc = null; + + /** Logic for setting up tests (empty if not yet needed). */ + public static void main(String[] params) throws Exception {} + + @Before + public void setUp() throws Exception { + System.out.println("set up."); + mDoc = TestUtils.document(); + } + + /** Test for all fields valid. */ + @Test + public void testAllFieldsValid() throws Exception { + System.out.println("starting testAllFieldsValid."); + testHrToOdDeveloperInfo(ALL_FIELDS_VALID_FILE_NAME); + } + + /** Tests missing required fields fails. */ + @Test + public void testMissingRequiredFields() throws Exception { + System.out.println("Starting testMissingRequiredFields"); + for (String reqField : REQUIRED_FIELD_NAMES) { + System.out.println("testing missing required field: " + reqField); + var developerInfoEle = + TestUtils.getElementsFromResource( + Paths.get(DEVELOPER_INFO_HR_PATH, ALL_FIELDS_VALID_FILE_NAME)); + developerInfoEle.get(0).removeAttribute(reqField); + + assertThrows( + MalformedXmlException.class, + () -> new DeveloperInfoFactory().createFromHrElements(developerInfoEle)); + } + } + + /** Tests missing optional fields passes. */ + @Test + public void testMissingOptionalFields() throws Exception { + for (String optField : OPTIONAL_FIELD_NAMES) { + var developerInfoEle = + TestUtils.getElementsFromResource( + Paths.get(DEVELOPER_INFO_HR_PATH, ALL_FIELDS_VALID_FILE_NAME)); + developerInfoEle.get(0).removeAttribute(optField); + DeveloperInfo developerInfo = + new DeveloperInfoFactory().createFromHrElements(developerInfoEle); + developerInfo.toOdDomElements(mDoc); + } + } + + private void testHrToOdDeveloperInfo(String fileName) throws Exception { + TestUtils.testHrToOd( + mDoc, + new DeveloperInfoFactory(), + DEVELOPER_INFO_HR_PATH, + DEVELOPER_INFO_OD_PATH, + fileName); + } +} diff --git a/tools/app_metadata_bundles/src/test/java/com/android/asllib/marshallable/SafetyLabelsTest.java b/tools/app_metadata_bundles/src/test/java/com/android/asllib/marshallable/SafetyLabelsTest.java new file mode 100644 index 000000000000..b62620ef417e --- /dev/null +++ b/tools/app_metadata_bundles/src/test/java/com/android/asllib/marshallable/SafetyLabelsTest.java @@ -0,0 +1,77 @@ +/* + * Copyright (C) 2017 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.android.asllib.marshallable; + +import com.android.asllib.testutils.TestUtils; + +import org.junit.Before; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; +import org.w3c.dom.Document; + +@RunWith(JUnit4.class) +public class SafetyLabelsTest { + private static final String SAFETY_LABELS_HR_PATH = "com/android/asllib/safetylabels/hr"; + private static final String SAFETY_LABELS_OD_PATH = "com/android/asllib/safetylabels/od"; + + private static final String MISSING_VERSION_FILE_NAME = "missing-version.xml"; + private static final String VALID_EMPTY_FILE_NAME = "valid-empty.xml"; + private static final String WITH_DATA_LABELS_FILE_NAME = "with-data-labels.xml"; + + private Document mDoc = null; + + @Before + public void setUp() throws Exception { + System.out.println("set up."); + mDoc = TestUtils.document(); + } + + /** Test for safety labels missing version. */ + @Test + public void testSafetyLabelsMissingVersion() throws Exception { + System.out.println("starting testSafetyLabelsMissingVersion."); + hrToOdExpectException(MISSING_VERSION_FILE_NAME); + } + + /** Test for safety labels valid empty. */ + @Test + public void testSafetyLabelsValidEmptyFile() throws Exception { + System.out.println("starting testSafetyLabelsValidEmptyFile."); + testHrToOdSafetyLabels(VALID_EMPTY_FILE_NAME); + } + + /** Test for safety labels with data labels. */ + @Test + public void testSafetyLabelsWithDataLabels() throws Exception { + System.out.println("starting testSafetyLabelsWithDataLabels."); + testHrToOdSafetyLabels(WITH_DATA_LABELS_FILE_NAME); + } + + private void hrToOdExpectException(String fileName) { + TestUtils.hrToOdExpectException(new SafetyLabelsFactory(), SAFETY_LABELS_HR_PATH, fileName); + } + + private void testHrToOdSafetyLabels(String fileName) throws Exception { + TestUtils.testHrToOd( + mDoc, + new SafetyLabelsFactory(), + SAFETY_LABELS_HR_PATH, + SAFETY_LABELS_OD_PATH, + fileName); + } +} diff --git a/tools/app_metadata_bundles/src/test/java/com/android/asllib/marshallable/SystemAppSafetyLabelTest.java b/tools/app_metadata_bundles/src/test/java/com/android/asllib/marshallable/SystemAppSafetyLabelTest.java new file mode 100644 index 000000000000..191091a9e187 --- /dev/null +++ b/tools/app_metadata_bundles/src/test/java/com/android/asllib/marshallable/SystemAppSafetyLabelTest.java @@ -0,0 +1,75 @@ +/* + * Copyright (C) 2017 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.android.asllib.marshallable; + +import com.android.asllib.testutils.TestUtils; + +import org.junit.Before; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; +import org.w3c.dom.Document; + +@RunWith(JUnit4.class) +public class SystemAppSafetyLabelTest { + private static final String SYSTEM_APP_SAFETY_LABEL_HR_PATH = + "com/android/asllib/systemappsafetylabel/hr"; + private static final String SYSTEM_APP_SAFETY_LABEL_OD_PATH = + "com/android/asllib/systemappsafetylabel/od"; + + private static final String VALID_FILE_NAME = "valid.xml"; + private static final String MISSING_URL_FILE_NAME = "missing-url.xml"; + + private Document mDoc = null; + + /** Logic for setting up tests (empty if not yet needed). */ + public static void main(String[] params) throws Exception {} + + @Before + public void setUp() throws Exception { + System.out.println("set up."); + mDoc = TestUtils.document(); + } + + /** Test for valid. */ + @Test + public void testValid() throws Exception { + System.out.println("starting testValid."); + testHrToOdSystemAppSafetyLabel(VALID_FILE_NAME); + } + + /** Tests missing url. */ + @Test + public void testMissingUrl() throws Exception { + System.out.println("starting testMissingUrl."); + hrToOdExpectException(MISSING_URL_FILE_NAME); + } + + private void hrToOdExpectException(String fileName) { + TestUtils.hrToOdExpectException( + new SystemAppSafetyLabelFactory(), SYSTEM_APP_SAFETY_LABEL_HR_PATH, fileName); + } + + private void testHrToOdSystemAppSafetyLabel(String fileName) throws Exception { + TestUtils.testHrToOd( + mDoc, + new SystemAppSafetyLabelFactory(), + SYSTEM_APP_SAFETY_LABEL_HR_PATH, + SYSTEM_APP_SAFETY_LABEL_OD_PATH, + fileName); + } +} diff --git a/tools/app_metadata_bundles/src/test/java/com/android/asllib/marshallable/TransparencyInfoTest.java b/tools/app_metadata_bundles/src/test/java/com/android/asllib/marshallable/TransparencyInfoTest.java new file mode 100644 index 000000000000..56503f7d6c6b --- /dev/null +++ b/tools/app_metadata_bundles/src/test/java/com/android/asllib/marshallable/TransparencyInfoTest.java @@ -0,0 +1,75 @@ +/* + * Copyright (C) 2017 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.android.asllib.marshallable; + +import com.android.asllib.testutils.TestUtils; + +import org.junit.Before; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; +import org.w3c.dom.Document; + +@RunWith(JUnit4.class) +public class TransparencyInfoTest { + private static final String TRANSPARENCY_INFO_HR_PATH = + "com/android/asllib/transparencyinfo/hr"; + private static final String TRANSPARENCY_INFO_OD_PATH = + "com/android/asllib/transparencyinfo/od"; + + private static final String VALID_EMPTY_FILE_NAME = "valid-empty.xml"; + private static final String WITH_DEVELOPER_INFO_FILE_NAME = "with-developer-info.xml"; + private static final String WITH_APP_INFO_FILE_NAME = "with-app-info.xml"; + + private Document mDoc = null; + + @Before + public void setUp() throws Exception { + System.out.println("set up."); + mDoc = TestUtils.document(); + } + + /** Test for transparency info valid empty. */ + @Test + public void testTransparencyInfoValidEmptyFile() throws Exception { + System.out.println("starting testTransparencyInfoValidEmptyFile."); + testHrToOdTransparencyInfo(VALID_EMPTY_FILE_NAME); + } + + /** Test for transparency info with developer info. */ + @Test + public void testTransparencyInfoWithDeveloperInfo() throws Exception { + System.out.println("starting testTransparencyInfoWithDeveloperInfo."); + testHrToOdTransparencyInfo(WITH_DEVELOPER_INFO_FILE_NAME); + } + + /** Test for transparency info with app info. */ + @Test + public void testTransparencyInfoWithAppInfo() throws Exception { + System.out.println("starting testTransparencyInfoWithAppInfo."); + testHrToOdTransparencyInfo(WITH_APP_INFO_FILE_NAME); + } + + private void testHrToOdTransparencyInfo(String fileName) throws Exception { + TestUtils.testHrToOd( + mDoc, + new TransparencyInfoFactory(), + TRANSPARENCY_INFO_HR_PATH, + TRANSPARENCY_INFO_OD_PATH, + fileName); + } +} diff --git a/tools/app_metadata_bundles/src/test/java/com/android/asllib/testutils/TestUtils.java b/tools/app_metadata_bundles/src/test/java/com/android/asllib/testutils/TestUtils.java new file mode 100644 index 000000000000..faea340ae7bd --- /dev/null +++ b/tools/app_metadata_bundles/src/test/java/com/android/asllib/testutils/TestUtils.java @@ -0,0 +1,152 @@ +/* + * Copyright (C) 2017 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.android.asllib.testutils; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertThrows; + +import com.android.asllib.marshallable.AslMarshallable; +import com.android.asllib.marshallable.AslMarshallableFactory; +import com.android.asllib.util.MalformedXmlException; +import com.android.asllib.util.XmlUtils; + +import org.w3c.dom.Document; +import org.w3c.dom.Element; +import org.xml.sax.SAXException; + +import java.io.ByteArrayInputStream; +import java.io.ByteArrayOutputStream; +import java.io.IOException; +import java.io.InputStream; +import java.nio.charset.StandardCharsets; +import java.nio.file.Path; +import java.nio.file.Paths; +import java.util.List; + +import javax.xml.parsers.DocumentBuilderFactory; +import javax.xml.parsers.ParserConfigurationException; +import javax.xml.transform.OutputKeys; +import javax.xml.transform.Transformer; +import javax.xml.transform.TransformerException; +import javax.xml.transform.TransformerFactory; +import javax.xml.transform.dom.DOMSource; +import javax.xml.transform.stream.StreamResult; + +public class TestUtils { + public static final String HOLDER_TAG_NAME = "holder_of_flattened_for_testing"; + + /** Reads a Resource file into a String. */ + public static String readStrFromResource(Path filePath) throws IOException { + InputStream hrStream = + TestUtils.class.getClassLoader().getResourceAsStream(filePath.toString()); + return new String(hrStream.readAllBytes(), StandardCharsets.UTF_8); + } + + /** Gets List of Element from a path to an existing Resource. */ + public static List<Element> getElementsFromResource(Path filePath) + throws ParserConfigurationException, IOException, SAXException { + String str = readStrFromResource(filePath); + InputStream stream = new ByteArrayInputStream(str.getBytes(StandardCharsets.UTF_8)); + + DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance(); + factory.setNamespaceAware(true); + Document document = factory.newDocumentBuilder().parse(stream); + Element root = document.getDocumentElement(); + if (root.getTagName().equals(HOLDER_TAG_NAME)) { + String tagName = + XmlUtils.asElementList(root.getChildNodes()).stream() + .findFirst() + .get() + .getTagName(); + return XmlUtils.asElementList(root.getElementsByTagName(tagName)); + } else { + return List.of(root); + } + } + + /** Reads a Document into a String. */ + public static String docToStr(Document doc, boolean omitXmlDeclaration) + throws TransformerException { + TransformerFactory transformerFactory = TransformerFactory.newInstance(); + Transformer transformer = transformerFactory.newTransformer(); + transformer.setOutputProperty(OutputKeys.INDENT, "yes"); + transformer.setOutputProperty(OutputKeys.ENCODING, "UTF-8"); + transformer.setOutputProperty( + OutputKeys.OMIT_XML_DECLARATION, omitXmlDeclaration ? "yes" : "no"); + + ByteArrayOutputStream outStream = new ByteArrayOutputStream(); + StreamResult streamResult = new StreamResult(outStream); // out + DOMSource domSource = new DOMSource(doc); + transformer.transform(domSource, streamResult); + + return outStream.toString(StandardCharsets.UTF_8); + } + + /** + * Gets formatted XML for slightly more robust comparison checking than naive string comparison. + */ + public static String getFormattedXml(String xmlStr, boolean omitXmlDeclaration) + throws ParserConfigurationException, IOException, SAXException, TransformerException { + InputStream stream = new ByteArrayInputStream(xmlStr.getBytes(StandardCharsets.UTF_8)); + DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance(); + factory.setNamespaceAware(true); + Document document = factory.newDocumentBuilder().parse(stream); + + return docToStr(document, omitXmlDeclaration); + } + + /** Helper for getting a new Document */ + public static Document document() throws ParserConfigurationException { + return DocumentBuilderFactory.newInstance().newDocumentBuilder().newDocument(); + } + + /** Helper for testing human-readable to on-device conversion expecting exception */ + public static <T extends AslMarshallable> void hrToOdExpectException( + AslMarshallableFactory<T> factory, String hrFolderPath, String fileName) { + assertThrows( + MalformedXmlException.class, + () -> { + factory.createFromHrElements( + TestUtils.getElementsFromResource(Paths.get(hrFolderPath, fileName))); + }); + } + + /** Helper for testing human-readable to on-device conversion */ + public static <T extends AslMarshallable> void testHrToOd( + Document doc, + AslMarshallableFactory<T> factory, + String hrFolderPath, + String odFolderPath, + String fileName) + throws Exception { + AslMarshallable marshallable = + factory.createFromHrElements( + TestUtils.getElementsFromResource(Paths.get(hrFolderPath, fileName))); + + for (var child : marshallable.toOdDomElements(doc)) { + doc.appendChild(child); + } + String converted = TestUtils.docToStr(doc, true); + System.out.println("converted: " + converted); + + String expectedOdContents = + TestUtils.readStrFromResource(Paths.get(odFolderPath, fileName)); + assertEquals( + TestUtils.getFormattedXml(expectedOdContents, true), + TestUtils.getFormattedXml(converted, true)); + } +} diff --git a/tools/app_metadata_bundles/src/test/resources/com/android/asllib/androidsafetylabel/hr/missing-version.xml b/tools/app_metadata_bundles/src/test/resources/com/android/asllib/androidsafetylabel/hr/missing-version.xml new file mode 100644 index 000000000000..ec0cd702fd43 --- /dev/null +++ b/tools/app_metadata_bundles/src/test/resources/com/android/asllib/androidsafetylabel/hr/missing-version.xml @@ -0,0 +1,3 @@ +<app-metadata-bundles> + +</app-metadata-bundles> \ No newline at end of file diff --git a/tools/app_metadata_bundles/src/test/resources/com/android/asllib/androidsafetylabel/hr/valid-empty.xml b/tools/app_metadata_bundles/src/test/resources/com/android/asllib/androidsafetylabel/hr/valid-empty.xml new file mode 100644 index 000000000000..19bfd826f770 --- /dev/null +++ b/tools/app_metadata_bundles/src/test/resources/com/android/asllib/androidsafetylabel/hr/valid-empty.xml @@ -0,0 +1 @@ +<app-metadata-bundles version="123456"></app-metadata-bundles> \ No newline at end of file diff --git a/tools/app_metadata_bundles/src/test/resources/com/android/asllib/androidsafetylabel/hr/with-safety-labels.xml b/tools/app_metadata_bundles/src/test/resources/com/android/asllib/androidsafetylabel/hr/with-safety-labels.xml new file mode 100644 index 000000000000..53794a1d1c80 --- /dev/null +++ b/tools/app_metadata_bundles/src/test/resources/com/android/asllib/androidsafetylabel/hr/with-safety-labels.xml @@ -0,0 +1,4 @@ +<app-metadata-bundles version="123456"> + <safety-labels version="12345"> + </safety-labels> +</app-metadata-bundles> \ No newline at end of file diff --git a/tools/app_metadata_bundles/src/test/resources/com/android/asllib/androidsafetylabel/hr/with-system-app-safety-label.xml b/tools/app_metadata_bundles/src/test/resources/com/android/asllib/androidsafetylabel/hr/with-system-app-safety-label.xml new file mode 100644 index 000000000000..7bcde4547933 --- /dev/null +++ b/tools/app_metadata_bundles/src/test/resources/com/android/asllib/androidsafetylabel/hr/with-system-app-safety-label.xml @@ -0,0 +1,4 @@ +<app-metadata-bundles version="123456"> +<system-app-safety-label url="www.example.com"> +</system-app-safety-label> +</app-metadata-bundles> \ No newline at end of file diff --git a/tools/app_metadata_bundles/src/test/resources/com/android/asllib/androidsafetylabel/hr/with-transparency-info.xml b/tools/app_metadata_bundles/src/test/resources/com/android/asllib/androidsafetylabel/hr/with-transparency-info.xml new file mode 100644 index 000000000000..00bcfa80e9b1 --- /dev/null +++ b/tools/app_metadata_bundles/src/test/resources/com/android/asllib/androidsafetylabel/hr/with-transparency-info.xml @@ -0,0 +1,4 @@ +<app-metadata-bundles version="123456"> +<transparency-info> +</transparency-info> +</app-metadata-bundles> \ No newline at end of file diff --git a/tools/app_metadata_bundles/src/test/resources/com/android/asllib/androidsafetylabel/od/valid-empty.xml b/tools/app_metadata_bundles/src/test/resources/com/android/asllib/androidsafetylabel/od/valid-empty.xml new file mode 100644 index 000000000000..37bdfad4065f --- /dev/null +++ b/tools/app_metadata_bundles/src/test/resources/com/android/asllib/androidsafetylabel/od/valid-empty.xml @@ -0,0 +1,3 @@ +<bundle> + <long name="version" value="123456"/> +</bundle> \ No newline at end of file diff --git a/tools/app_metadata_bundles/src/test/resources/com/android/asllib/androidsafetylabel/od/with-safety-labels.xml b/tools/app_metadata_bundles/src/test/resources/com/android/asllib/androidsafetylabel/od/with-safety-labels.xml new file mode 100644 index 000000000000..74644ed0413c --- /dev/null +++ b/tools/app_metadata_bundles/src/test/resources/com/android/asllib/androidsafetylabel/od/with-safety-labels.xml @@ -0,0 +1,6 @@ +<bundle> + <long name="version" value="123456"/> + <pbundle_as_map name="safety_labels"> + <long name="version" value="12345"/> + </pbundle_as_map> +</bundle> diff --git a/tools/app_metadata_bundles/src/test/resources/com/android/asllib/androidsafetylabel/od/with-system-app-safety-label.xml b/tools/app_metadata_bundles/src/test/resources/com/android/asllib/androidsafetylabel/od/with-system-app-safety-label.xml new file mode 100644 index 000000000000..ef0f549fc46b --- /dev/null +++ b/tools/app_metadata_bundles/src/test/resources/com/android/asllib/androidsafetylabel/od/with-system-app-safety-label.xml @@ -0,0 +1,6 @@ +<bundle> + <long name="version" value="123456"/> + <pbundle_as_map name="system_app_safety_label"> + <string name="url" value="www.example.com"/> + </pbundle_as_map> +</bundle> \ No newline at end of file diff --git a/tools/app_metadata_bundles/src/test/resources/com/android/asllib/androidsafetylabel/od/with-transparency-info.xml b/tools/app_metadata_bundles/src/test/resources/com/android/asllib/androidsafetylabel/od/with-transparency-info.xml new file mode 100644 index 000000000000..63c5094333cc --- /dev/null +++ b/tools/app_metadata_bundles/src/test/resources/com/android/asllib/androidsafetylabel/od/with-transparency-info.xml @@ -0,0 +1,4 @@ +<bundle> + <long name="version" value="123456"/> + <pbundle_as_map name="transparency_info"/> +</bundle> \ No newline at end of file diff --git a/tools/app_metadata_bundles/src/test/resources/com/android/asllib/appinfo/hr/all-fields-valid.xml b/tools/app_metadata_bundles/src/test/resources/com/android/asllib/appinfo/hr/all-fields-valid.xml new file mode 100644 index 000000000000..883170a2d36f --- /dev/null +++ b/tools/app_metadata_bundles/src/test/resources/com/android/asllib/appinfo/hr/all-fields-valid.xml @@ -0,0 +1,14 @@ +<app-info + title="beervision" + description="a beer app" + containsAds="true" + obeyAps="false" + adsFingerprinting="false" + securityFingerprinting="false" + privacyPolicy="www.example.com" + securityEndpoints="url1|url2|url3" + firstPartyEndpoints="url1" + serviceProviderEndpoints="url55|url56" + category="Food and drink" + email="max@maxloh.com" + website="www.example.com" /> \ No newline at end of file diff --git a/tools/app_metadata_bundles/src/test/resources/com/android/asllib/appinfo/od/all-fields-valid.xml b/tools/app_metadata_bundles/src/test/resources/com/android/asllib/appinfo/od/all-fields-valid.xml new file mode 100644 index 000000000000..6e976a3278de --- /dev/null +++ b/tools/app_metadata_bundles/src/test/resources/com/android/asllib/appinfo/od/all-fields-valid.xml @@ -0,0 +1,25 @@ + +<pbundle_as_map name="app_info"> + <string name="title" value="beervision"/> + <string name="description" value="a beer app"/> + <boolean name="contains_ads" value="true"/> + <boolean name="obey_aps" value="false"/> + <boolean name="ads_fingerprinting" value="false"/> + <boolean name="security_fingerprinting" value="false"/> + <string name="privacy_policy" value="www.example.com"/> + <string-array name="security_endpoint" num="3"> + <item value="url1"/> + <item value="url2"/> + <item value="url3"/> + </string-array> + <string-array name="first_party_endpoint" num="1"> + <item value="url1"/> + </string-array> + <string-array name="service_provider_endpoint" num="2"> + <item value="url55"/> + <item value="url56"/> + </string-array> + <string name="category" value="Food and drink"/> + <string name="email" value="max@maxloh.com"/> + <string name="website" value="www.example.com"/> +</pbundle_as_map> \ No newline at end of file diff --git a/tools/app_metadata_bundles/src/test/resources/com/android/asllib/datacategory/hr/data-category-actions-in-app.xml b/tools/app_metadata_bundles/src/test/resources/com/android/asllib/datacategory/hr/data-category-actions-in-app.xml new file mode 100644 index 000000000000..520e525679b8 --- /dev/null +++ b/tools/app_metadata_bundles/src/test/resources/com/android/asllib/datacategory/hr/data-category-actions-in-app.xml @@ -0,0 +1,17 @@ +<holder_of_flattened_for_testing> + <data-shared dataCategory="actions_in_app" + dataType="user_interaction" + purposes="analytics" /> + <data-shared dataCategory="actions_in_app" + dataType="in_app_search_history" + purposes="analytics" /> + <data-shared dataCategory="actions_in_app" + dataType="installed_apps" + purposes="analytics" /> + <data-shared dataCategory="actions_in_app" + dataType="user_generated_content" + purposes="analytics" /> + <data-shared dataCategory="actions_in_app" + dataType="other" + purposes="analytics" /> +</holder_of_flattened_for_testing> \ No newline at end of file diff --git a/tools/app_metadata_bundles/src/test/resources/com/android/asllib/datacategory/hr/data-category-app-performance.xml b/tools/app_metadata_bundles/src/test/resources/com/android/asllib/datacategory/hr/data-category-app-performance.xml new file mode 100644 index 000000000000..0d08e5b5ae4d --- /dev/null +++ b/tools/app_metadata_bundles/src/test/resources/com/android/asllib/datacategory/hr/data-category-app-performance.xml @@ -0,0 +1,11 @@ +<holder_of_flattened_for_testing> + <data-shared dataCategory="app_performance" + dataType="crash_logs" + purposes="analytics" /> + <data-shared dataCategory="app_performance" + dataType="performance_diagnostics" + purposes="analytics" /> + <data-shared dataCategory="app_performance" + dataType="other" + purposes="analytics" /> +</holder_of_flattened_for_testing> \ No newline at end of file diff --git a/tools/app_metadata_bundles/src/test/resources/com/android/asllib/datacategory/hr/data-category-audio.xml b/tools/app_metadata_bundles/src/test/resources/com/android/asllib/datacategory/hr/data-category-audio.xml new file mode 100644 index 000000000000..b1cf3b44fd4a --- /dev/null +++ b/tools/app_metadata_bundles/src/test/resources/com/android/asllib/datacategory/hr/data-category-audio.xml @@ -0,0 +1,11 @@ +<holder_of_flattened_for_testing> + <data-shared dataCategory="audio" + dataType="sound_recordings" + purposes="analytics" /> + <data-shared dataCategory="audio" + dataType="music_files" + purposes="analytics" /> + <data-shared dataCategory="audio" + dataType="other" + purposes="analytics" /> +</holder_of_flattened_for_testing> \ No newline at end of file diff --git a/tools/app_metadata_bundles/src/test/resources/com/android/asllib/datacategory/hr/data-category-calendar.xml b/tools/app_metadata_bundles/src/test/resources/com/android/asllib/datacategory/hr/data-category-calendar.xml new file mode 100644 index 000000000000..a723070c43b7 --- /dev/null +++ b/tools/app_metadata_bundles/src/test/resources/com/android/asllib/datacategory/hr/data-category-calendar.xml @@ -0,0 +1,5 @@ +<holder_of_flattened_for_testing> + <data-shared dataCategory="calendar" + dataType="calendar" + purposes="analytics" /> +</holder_of_flattened_for_testing> \ No newline at end of file diff --git a/tools/app_metadata_bundles/src/test/resources/com/android/asllib/datacategory/hr/data-category-contacts.xml b/tools/app_metadata_bundles/src/test/resources/com/android/asllib/datacategory/hr/data-category-contacts.xml new file mode 100644 index 000000000000..2fe28ffe4940 --- /dev/null +++ b/tools/app_metadata_bundles/src/test/resources/com/android/asllib/datacategory/hr/data-category-contacts.xml @@ -0,0 +1,5 @@ +<holder_of_flattened_for_testing> + <data-shared dataCategory="contacts" + dataType="contacts" + purposes="analytics" /> +</holder_of_flattened_for_testing> \ No newline at end of file diff --git a/tools/app_metadata_bundles/src/test/resources/com/android/asllib/datacategory/hr/data-category-email-text-message.xml b/tools/app_metadata_bundles/src/test/resources/com/android/asllib/datacategory/hr/data-category-email-text-message.xml new file mode 100644 index 000000000000..49a326fc43e5 --- /dev/null +++ b/tools/app_metadata_bundles/src/test/resources/com/android/asllib/datacategory/hr/data-category-email-text-message.xml @@ -0,0 +1,11 @@ +<holder_of_flattened_for_testing> + <data-shared dataCategory="email_text_message" + dataType="emails" + purposes="analytics" /> + <data-shared dataCategory="email_text_message" + dataType="text_messages" + purposes="analytics" /> + <data-shared dataCategory="email_text_message" + dataType="other" + purposes="analytics" /> +</holder_of_flattened_for_testing> \ No newline at end of file diff --git a/tools/app_metadata_bundles/src/test/resources/com/android/asllib/datacategory/hr/data-category-financial.xml b/tools/app_metadata_bundles/src/test/resources/com/android/asllib/datacategory/hr/data-category-financial.xml new file mode 100644 index 000000000000..f5de3707ef8a --- /dev/null +++ b/tools/app_metadata_bundles/src/test/resources/com/android/asllib/datacategory/hr/data-category-financial.xml @@ -0,0 +1,14 @@ +<holder_of_flattened_for_testing> + <data-shared dataCategory="financial" + dataType="card_bank_account" + purposes="analytics" /> + <data-shared dataCategory="financial" + dataType="purchase_history" + purposes="analytics" /> + <data-shared dataCategory="financial" + dataType="credit_score" + purposes="analytics" /> + <data-shared dataCategory="financial" + dataType="other" + purposes="analytics" /> +</holder_of_flattened_for_testing> \ No newline at end of file diff --git a/tools/app_metadata_bundles/src/test/resources/com/android/asllib/datacategory/hr/data-category-health-fitness.xml b/tools/app_metadata_bundles/src/test/resources/com/android/asllib/datacategory/hr/data-category-health-fitness.xml new file mode 100644 index 000000000000..9891f8170bd7 --- /dev/null +++ b/tools/app_metadata_bundles/src/test/resources/com/android/asllib/datacategory/hr/data-category-health-fitness.xml @@ -0,0 +1,8 @@ +<holder_of_flattened_for_testing> + <data-shared dataCategory="health_fitness" + dataType="health" + purposes="analytics" /> + <data-shared dataCategory="health_fitness" + dataType="fitness" + purposes="analytics" /> +</holder_of_flattened_for_testing> \ No newline at end of file diff --git a/tools/app_metadata_bundles/src/test/resources/com/android/asllib/datacategory/hr/data-category-identifiers.xml b/tools/app_metadata_bundles/src/test/resources/com/android/asllib/datacategory/hr/data-category-identifiers.xml new file mode 100644 index 000000000000..3e74da1ad527 --- /dev/null +++ b/tools/app_metadata_bundles/src/test/resources/com/android/asllib/datacategory/hr/data-category-identifiers.xml @@ -0,0 +1,5 @@ +<holder_of_flattened_for_testing> + <data-shared dataCategory="identifiers" + dataType="other" + purposes="analytics" /> +</holder_of_flattened_for_testing> \ No newline at end of file diff --git a/tools/app_metadata_bundles/src/test/resources/com/android/asllib/datacategory/hr/data-category-location.xml b/tools/app_metadata_bundles/src/test/resources/com/android/asllib/datacategory/hr/data-category-location.xml new file mode 100644 index 000000000000..4762f16d64db --- /dev/null +++ b/tools/app_metadata_bundles/src/test/resources/com/android/asllib/datacategory/hr/data-category-location.xml @@ -0,0 +1,8 @@ +<holder_of_flattened_for_testing> + <data-shared dataCategory="location" + dataType="approx_location" + purposes="analytics" /> + <data-shared dataCategory="location" + dataType="precise_location" + purposes="analytics" /> +</holder_of_flattened_for_testing> \ No newline at end of file diff --git a/tools/app_metadata_bundles/src/test/resources/com/android/asllib/datacategory/hr/data-category-personal-empty-purpose.xml b/tools/app_metadata_bundles/src/test/resources/com/android/asllib/datacategory/hr/data-category-personal-empty-purpose.xml new file mode 100644 index 000000000000..964e178e4dbd --- /dev/null +++ b/tools/app_metadata_bundles/src/test/resources/com/android/asllib/datacategory/hr/data-category-personal-empty-purpose.xml @@ -0,0 +1,5 @@ +<holder_of_flattened_for_testing> + <data-shared dataCategory="personal" + dataType="email_address" + purposes="" /> +</holder_of_flattened_for_testing> \ No newline at end of file diff --git a/tools/app_metadata_bundles/src/test/resources/com/android/asllib/datacategory/hr/data-category-personal-missing-purpose.xml b/tools/app_metadata_bundles/src/test/resources/com/android/asllib/datacategory/hr/data-category-personal-missing-purpose.xml new file mode 100644 index 000000000000..3ce1288fb2c3 --- /dev/null +++ b/tools/app_metadata_bundles/src/test/resources/com/android/asllib/datacategory/hr/data-category-personal-missing-purpose.xml @@ -0,0 +1,4 @@ +<holder_of_flattened_for_testing> + <data-shared dataCategory="personal" + dataType="email_address" /> +</holder_of_flattened_for_testing> \ No newline at end of file diff --git a/tools/app_metadata_bundles/src/test/resources/com/android/asllib/datacategory/hr/data-category-personal-partial.xml b/tools/app_metadata_bundles/src/test/resources/com/android/asllib/datacategory/hr/data-category-personal-partial.xml new file mode 100644 index 000000000000..68baae30ef4f --- /dev/null +++ b/tools/app_metadata_bundles/src/test/resources/com/android/asllib/datacategory/hr/data-category-personal-partial.xml @@ -0,0 +1,8 @@ +<holder_of_flattened_for_testing> + <data-shared dataCategory="personal" + dataType="name" + purposes="analytics|developer_communications" /> + <data-shared dataCategory="personal" + dataType="email_address" + purposes="analytics" /> +</holder_of_flattened_for_testing> \ No newline at end of file diff --git a/tools/app_metadata_bundles/src/test/resources/com/android/asllib/datacategory/hr/data-category-personal-unrecognized-type.xml b/tools/app_metadata_bundles/src/test/resources/com/android/asllib/datacategory/hr/data-category-personal-unrecognized-type.xml new file mode 100644 index 000000000000..921a90a3fde7 --- /dev/null +++ b/tools/app_metadata_bundles/src/test/resources/com/android/asllib/datacategory/hr/data-category-personal-unrecognized-type.xml @@ -0,0 +1,5 @@ +<holder_of_flattened_for_testing> + <data-shared dataCategory="personal" + dataType="unrecognized" + purposes="analytics" /> +</holder_of_flattened_for_testing> \ No newline at end of file diff --git a/tools/app_metadata_bundles/src/test/resources/com/android/asllib/datacategory/hr/data-category-personal.xml b/tools/app_metadata_bundles/src/test/resources/com/android/asllib/datacategory/hr/data-category-personal.xml new file mode 100644 index 000000000000..4533773ec9c1 --- /dev/null +++ b/tools/app_metadata_bundles/src/test/resources/com/android/asllib/datacategory/hr/data-category-personal.xml @@ -0,0 +1,31 @@ +<holder_of_flattened_for_testing> + <data-shared dataCategory="personal" + dataType="name" + ephemeral="true" + isCollectionOptional="true" + purposes="analytics|developer_communications" /> + <data-shared dataCategory="personal" + dataType="email_address" + purposes="analytics" /> + <data-shared dataCategory="personal" + dataType="physical_address" + purposes="analytics" /> + <data-shared dataCategory="personal" + dataType="phone_number" + purposes="analytics" /> + <data-shared dataCategory="personal" + dataType="race_ethnicity" + purposes="analytics" /> + <data-shared dataCategory="personal" + dataType="political_or_religious_beliefs" + purposes="analytics" /> + <data-shared dataCategory="personal" + dataType="sexual_orientation_or_gender_identity" + purposes="analytics" /> + <data-shared dataCategory="personal" + dataType="personal_identifiers" + purposes="analytics" /> + <data-shared dataCategory="personal" + dataType="other" + purposes="analytics" /> +</holder_of_flattened_for_testing> \ No newline at end of file diff --git a/tools/app_metadata_bundles/src/test/resources/com/android/asllib/datacategory/hr/data-category-photo-video.xml b/tools/app_metadata_bundles/src/test/resources/com/android/asllib/datacategory/hr/data-category-photo-video.xml new file mode 100644 index 000000000000..234fb265ae55 --- /dev/null +++ b/tools/app_metadata_bundles/src/test/resources/com/android/asllib/datacategory/hr/data-category-photo-video.xml @@ -0,0 +1,8 @@ +<holder_of_flattened_for_testing> + <data-shared dataCategory="photo_video" + dataType="photos" + purposes="analytics" /> + <data-shared dataCategory="photo_video" + dataType="videos" + purposes="analytics" /> +</holder_of_flattened_for_testing> \ No newline at end of file diff --git a/tools/app_metadata_bundles/src/test/resources/com/android/asllib/datacategory/hr/data-category-search-and-browsing.xml b/tools/app_metadata_bundles/src/test/resources/com/android/asllib/datacategory/hr/data-category-search-and-browsing.xml new file mode 100644 index 000000000000..db851633aec5 --- /dev/null +++ b/tools/app_metadata_bundles/src/test/resources/com/android/asllib/datacategory/hr/data-category-search-and-browsing.xml @@ -0,0 +1,5 @@ +<holder_of_flattened_for_testing> + <data-shared dataCategory="search_and_browsing" + dataType="web_browsing_history" + purposes="analytics" /> +</holder_of_flattened_for_testing> \ No newline at end of file diff --git a/tools/app_metadata_bundles/src/test/resources/com/android/asllib/datacategory/hr/data-category-storage.xml b/tools/app_metadata_bundles/src/test/resources/com/android/asllib/datacategory/hr/data-category-storage.xml new file mode 100644 index 000000000000..9aad02de8877 --- /dev/null +++ b/tools/app_metadata_bundles/src/test/resources/com/android/asllib/datacategory/hr/data-category-storage.xml @@ -0,0 +1,5 @@ +<holder_of_flattened_for_testing> + <data-shared dataCategory="storage" + dataType="files_docs" + purposes="analytics" /> +</holder_of_flattened_for_testing> \ No newline at end of file diff --git a/tools/app_metadata_bundles/src/test/resources/com/android/asllib/datacategory/hr/data-category-unrecognized.xml b/tools/app_metadata_bundles/src/test/resources/com/android/asllib/datacategory/hr/data-category-unrecognized.xml new file mode 100644 index 000000000000..64b9ea72e05b --- /dev/null +++ b/tools/app_metadata_bundles/src/test/resources/com/android/asllib/datacategory/hr/data-category-unrecognized.xml @@ -0,0 +1,5 @@ +<holder_of_flattened_for_testing> + <data-shared dataCategory="unrecognized" + dataType="email_address" + purposes="analytics" /> +</holder_of_flattened_for_testing> \ No newline at end of file diff --git a/tools/app_metadata_bundles/src/test/resources/com/android/asllib/datacategory/od/data-category-actions-in-app.xml b/tools/app_metadata_bundles/src/test/resources/com/android/asllib/datacategory/od/data-category-actions-in-app.xml new file mode 100644 index 000000000000..5b99900b5a8a --- /dev/null +++ b/tools/app_metadata_bundles/src/test/resources/com/android/asllib/datacategory/od/data-category-actions-in-app.xml @@ -0,0 +1,27 @@ +<pbundle_as_map name="actions_in_app"> + <pbundle_as_map name="user_interaction"> + <int-array name="purposes" num="1"> + <item value="2" /> + </int-array> + </pbundle_as_map> + <pbundle_as_map name="in_app_search_history"> + <int-array name="purposes" num="1"> + <item value="2" /> + </int-array> + </pbundle_as_map> + <pbundle_as_map name="installed_apps"> + <int-array name="purposes" num="1"> + <item value="2" /> + </int-array> + </pbundle_as_map> + <pbundle_as_map name="user_generated_content"> + <int-array name="purposes" num="1"> + <item value="2" /> + </int-array> + </pbundle_as_map> + <pbundle_as_map name="other"> + <int-array name="purposes" num="1"> + <item value="2" /> + </int-array> + </pbundle_as_map> +</pbundle_as_map> \ No newline at end of file diff --git a/tools/app_metadata_bundles/src/test/resources/com/android/asllib/datacategory/od/data-category-app-performance.xml b/tools/app_metadata_bundles/src/test/resources/com/android/asllib/datacategory/od/data-category-app-performance.xml new file mode 100644 index 000000000000..0fe102202be5 --- /dev/null +++ b/tools/app_metadata_bundles/src/test/resources/com/android/asllib/datacategory/od/data-category-app-performance.xml @@ -0,0 +1,17 @@ +<pbundle_as_map name="app_performance"> + <pbundle_as_map name="crash_logs"> + <int-array name="purposes" num="1"> + <item value="2" /> + </int-array> + </pbundle_as_map> + <pbundle_as_map name="performance_diagnostics"> + <int-array name="purposes" num="1"> + <item value="2" /> + </int-array> + </pbundle_as_map> + <pbundle_as_map name="other"> + <int-array name="purposes" num="1"> + <item value="2" /> + </int-array> + </pbundle_as_map> +</pbundle_as_map> \ No newline at end of file diff --git a/tools/app_metadata_bundles/src/test/resources/com/android/asllib/datacategory/od/data-category-audio.xml b/tools/app_metadata_bundles/src/test/resources/com/android/asllib/datacategory/od/data-category-audio.xml new file mode 100644 index 000000000000..51f1dfd6d823 --- /dev/null +++ b/tools/app_metadata_bundles/src/test/resources/com/android/asllib/datacategory/od/data-category-audio.xml @@ -0,0 +1,17 @@ +<pbundle_as_map name="audio"> + <pbundle_as_map name="sound_recordings"> + <int-array name="purposes" num="1"> + <item value="2" /> + </int-array> + </pbundle_as_map> + <pbundle_as_map name="music_files"> + <int-array name="purposes" num="1"> + <item value="2" /> + </int-array> + </pbundle_as_map> + <pbundle_as_map name="other"> + <int-array name="purposes" num="1"> + <item value="2" /> + </int-array> + </pbundle_as_map> +</pbundle_as_map> \ No newline at end of file diff --git a/tools/app_metadata_bundles/src/test/resources/com/android/asllib/datacategory/od/data-category-calendar.xml b/tools/app_metadata_bundles/src/test/resources/com/android/asllib/datacategory/od/data-category-calendar.xml new file mode 100644 index 000000000000..326da47a1cb9 --- /dev/null +++ b/tools/app_metadata_bundles/src/test/resources/com/android/asllib/datacategory/od/data-category-calendar.xml @@ -0,0 +1,7 @@ +<pbundle_as_map name="calendar"> + <pbundle_as_map name="calendar"> + <int-array name="purposes" num="1"> + <item value="2" /> + </int-array> + </pbundle_as_map> +</pbundle_as_map> \ No newline at end of file diff --git a/tools/app_metadata_bundles/src/test/resources/com/android/asllib/datacategory/od/data-category-contacts.xml b/tools/app_metadata_bundles/src/test/resources/com/android/asllib/datacategory/od/data-category-contacts.xml new file mode 100644 index 000000000000..5d4387d2f906 --- /dev/null +++ b/tools/app_metadata_bundles/src/test/resources/com/android/asllib/datacategory/od/data-category-contacts.xml @@ -0,0 +1,7 @@ +<pbundle_as_map name="contacts"> + <pbundle_as_map name="contacts"> + <int-array name="purposes" num="1"> + <item value="2" /> + </int-array> + </pbundle_as_map> +</pbundle_as_map> \ No newline at end of file diff --git a/tools/app_metadata_bundles/src/test/resources/com/android/asllib/datacategory/od/data-category-email-text-message.xml b/tools/app_metadata_bundles/src/test/resources/com/android/asllib/datacategory/od/data-category-email-text-message.xml new file mode 100644 index 000000000000..5ac98f56ace6 --- /dev/null +++ b/tools/app_metadata_bundles/src/test/resources/com/android/asllib/datacategory/od/data-category-email-text-message.xml @@ -0,0 +1,17 @@ +<pbundle_as_map name="email_text_message"> + <pbundle_as_map name="emails"> + <int-array name="purposes" num="1"> + <item value="2" /> + </int-array> + </pbundle_as_map> + <pbundle_as_map name="text_messages"> + <int-array name="purposes" num="1"> + <item value="2" /> + </int-array> + </pbundle_as_map> + <pbundle_as_map name="other"> + <int-array name="purposes" num="1"> + <item value="2" /> + </int-array> + </pbundle_as_map> +</pbundle_as_map> \ No newline at end of file diff --git a/tools/app_metadata_bundles/src/test/resources/com/android/asllib/datacategory/od/data-category-financial.xml b/tools/app_metadata_bundles/src/test/resources/com/android/asllib/datacategory/od/data-category-financial.xml new file mode 100644 index 000000000000..a66f1a44dcb3 --- /dev/null +++ b/tools/app_metadata_bundles/src/test/resources/com/android/asllib/datacategory/od/data-category-financial.xml @@ -0,0 +1,22 @@ +<pbundle_as_map name="financial"> + <pbundle_as_map name="card_bank_account"> + <int-array name="purposes" num="1"> + <item value="2" /> + </int-array> + </pbundle_as_map> + <pbundle_as_map name="purchase_history"> + <int-array name="purposes" num="1"> + <item value="2" /> + </int-array> + </pbundle_as_map> + <pbundle_as_map name="credit_score"> + <int-array name="purposes" num="1"> + <item value="2" /> + </int-array> + </pbundle_as_map> + <pbundle_as_map name="other"> + <int-array name="purposes" num="1"> + <item value="2" /> + </int-array> + </pbundle_as_map> +</pbundle_as_map> \ No newline at end of file diff --git a/tools/app_metadata_bundles/src/test/resources/com/android/asllib/datacategory/od/data-category-health-fitness.xml b/tools/app_metadata_bundles/src/test/resources/com/android/asllib/datacategory/od/data-category-health-fitness.xml new file mode 100644 index 000000000000..8e697b47364c --- /dev/null +++ b/tools/app_metadata_bundles/src/test/resources/com/android/asllib/datacategory/od/data-category-health-fitness.xml @@ -0,0 +1,12 @@ +<pbundle_as_map name="health_fitness"> + <pbundle_as_map name="health"> + <int-array name="purposes" num="1"> + <item value="2" /> + </int-array> + </pbundle_as_map> + <pbundle_as_map name="fitness"> + <int-array name="purposes" num="1"> + <item value="2" /> + </int-array> + </pbundle_as_map> +</pbundle_as_map> \ No newline at end of file diff --git a/tools/app_metadata_bundles/src/test/resources/com/android/asllib/datacategory/od/data-category-identifiers.xml b/tools/app_metadata_bundles/src/test/resources/com/android/asllib/datacategory/od/data-category-identifiers.xml new file mode 100644 index 000000000000..34b4016e1364 --- /dev/null +++ b/tools/app_metadata_bundles/src/test/resources/com/android/asllib/datacategory/od/data-category-identifiers.xml @@ -0,0 +1,7 @@ +<pbundle_as_map name="identifiers"> + <pbundle_as_map name="other"> + <int-array name="purposes" num="1"> + <item value="2" /> + </int-array> + </pbundle_as_map> +</pbundle_as_map> \ No newline at end of file diff --git a/tools/app_metadata_bundles/src/test/resources/com/android/asllib/datacategory/od/data-category-location.xml b/tools/app_metadata_bundles/src/test/resources/com/android/asllib/datacategory/od/data-category-location.xml new file mode 100644 index 000000000000..db2e6965ff2a --- /dev/null +++ b/tools/app_metadata_bundles/src/test/resources/com/android/asllib/datacategory/od/data-category-location.xml @@ -0,0 +1,12 @@ +<pbundle_as_map name="location"> + <pbundle_as_map name="approx_location"> + <int-array name="purposes" num="1"> + <item value="2" /> + </int-array> + </pbundle_as_map> + <pbundle_as_map name="precise_location"> + <int-array name="purposes" num="1"> + <item value="2" /> + </int-array> + </pbundle_as_map> +</pbundle_as_map> \ No newline at end of file diff --git a/tools/app_metadata_bundles/src/test/resources/com/android/asllib/datacategory/od/data-category-personal-partial.xml b/tools/app_metadata_bundles/src/test/resources/com/android/asllib/datacategory/od/data-category-personal-partial.xml new file mode 100644 index 000000000000..839922a8bec6 --- /dev/null +++ b/tools/app_metadata_bundles/src/test/resources/com/android/asllib/datacategory/od/data-category-personal-partial.xml @@ -0,0 +1,13 @@ +<pbundle_as_map name="personal"> + <pbundle_as_map name="name"> + <int-array name="purposes" num="2"> + <item value="2" /> + <item value="3" /> + </int-array> + </pbundle_as_map> + <pbundle_as_map name="email_address"> + <int-array name="purposes" num="1"> + <item value="2" /> + </int-array> + </pbundle_as_map> +</pbundle_as_map> \ No newline at end of file diff --git a/tools/app_metadata_bundles/src/test/resources/com/android/asllib/datacategory/od/data-category-personal.xml b/tools/app_metadata_bundles/src/test/resources/com/android/asllib/datacategory/od/data-category-personal.xml new file mode 100644 index 000000000000..43650b6a77fe --- /dev/null +++ b/tools/app_metadata_bundles/src/test/resources/com/android/asllib/datacategory/od/data-category-personal.xml @@ -0,0 +1,50 @@ +<pbundle_as_map name="personal"> + <pbundle_as_map name="name"> + <int-array name="purposes" num="2"> + <item value="2" /> + <item value="3" /> + </int-array> + <boolean name="is_collection_optional" value="true" /> + <boolean name="ephemeral" value="true" /> + </pbundle_as_map> + <pbundle_as_map name="email_address"> + <int-array name="purposes" num="1"> + <item value="2" /> + </int-array> + </pbundle_as_map> + <pbundle_as_map name="physical_address"> + <int-array name="purposes" num="1"> + <item value="2" /> + </int-array> + </pbundle_as_map> + <pbundle_as_map name="phone_number"> + <int-array name="purposes" num="1"> + <item value="2" /> + </int-array> + </pbundle_as_map> + <pbundle_as_map name="race_ethnicity"> + <int-array name="purposes" num="1"> + <item value="2" /> + </int-array> + </pbundle_as_map> + <pbundle_as_map name="political_or_religious_beliefs"> + <int-array name="purposes" num="1"> + <item value="2" /> + </int-array> + </pbundle_as_map> + <pbundle_as_map name="sexual_orientation_or_gender_identity"> + <int-array name="purposes" num="1"> + <item value="2" /> + </int-array> + </pbundle_as_map> + <pbundle_as_map name="personal_identifiers"> + <int-array name="purposes" num="1"> + <item value="2" /> + </int-array> + </pbundle_as_map> + <pbundle_as_map name="other"> + <int-array name="purposes" num="1"> + <item value="2" /> + </int-array> + </pbundle_as_map> +</pbundle_as_map> \ No newline at end of file diff --git a/tools/app_metadata_bundles/src/test/resources/com/android/asllib/datacategory/od/data-category-photo-video.xml b/tools/app_metadata_bundles/src/test/resources/com/android/asllib/datacategory/od/data-category-photo-video.xml new file mode 100644 index 000000000000..2a3178005df3 --- /dev/null +++ b/tools/app_metadata_bundles/src/test/resources/com/android/asllib/datacategory/od/data-category-photo-video.xml @@ -0,0 +1,12 @@ +<pbundle_as_map name="photo_video"> + <pbundle_as_map name="photos"> + <int-array name="purposes" num="1"> + <item value="2" /> + </int-array> + </pbundle_as_map> + <pbundle_as_map name="videos"> + <int-array name="purposes" num="1"> + <item value="2" /> + </int-array> + </pbundle_as_map> +</pbundle_as_map> \ No newline at end of file diff --git a/tools/app_metadata_bundles/src/test/resources/com/android/asllib/datacategory/od/data-category-search-and-browsing.xml b/tools/app_metadata_bundles/src/test/resources/com/android/asllib/datacategory/od/data-category-search-and-browsing.xml new file mode 100644 index 000000000000..9e654efcc5ab --- /dev/null +++ b/tools/app_metadata_bundles/src/test/resources/com/android/asllib/datacategory/od/data-category-search-and-browsing.xml @@ -0,0 +1,7 @@ +<pbundle_as_map name="search_and_browsing"> + <pbundle_as_map name="web_browsing_history"> + <int-array name="purposes" num="1"> + <item value="2" /> + </int-array> + </pbundle_as_map> +</pbundle_as_map> \ No newline at end of file diff --git a/tools/app_metadata_bundles/src/test/resources/com/android/asllib/datacategory/od/data-category-storage.xml b/tools/app_metadata_bundles/src/test/resources/com/android/asllib/datacategory/od/data-category-storage.xml new file mode 100644 index 000000000000..9abc37fdb2b9 --- /dev/null +++ b/tools/app_metadata_bundles/src/test/resources/com/android/asllib/datacategory/od/data-category-storage.xml @@ -0,0 +1,7 @@ +<pbundle_as_map name="storage"> + <pbundle_as_map name="files_docs"> + <int-array name="purposes" num="1"> + <item value="2" /> + </int-array> + </pbundle_as_map> +</pbundle_as_map> \ No newline at end of file diff --git a/tools/app_metadata_bundles/src/test/resources/com/android/asllib/datalabels/hr/data-labels-accessed-invalid-bool.xml b/tools/app_metadata_bundles/src/test/resources/com/android/asllib/datalabels/hr/data-labels-accessed-invalid-bool.xml new file mode 100644 index 000000000000..bb45f426e083 --- /dev/null +++ b/tools/app_metadata_bundles/src/test/resources/com/android/asllib/datalabels/hr/data-labels-accessed-invalid-bool.xml @@ -0,0 +1,7 @@ +<data-labels> + <data-accessed dataCategory="location" + dataType="approx_location" + ephemeral="false" + isSharingOptional="false" + purposes="app_functionality" /> +</data-labels> \ No newline at end of file diff --git a/tools/app_metadata_bundles/src/test/resources/com/android/asllib/datalabels/hr/data-labels-accessed-valid-bool.xml b/tools/app_metadata_bundles/src/test/resources/com/android/asllib/datalabels/hr/data-labels-accessed-valid-bool.xml new file mode 100644 index 000000000000..f927bba838fd --- /dev/null +++ b/tools/app_metadata_bundles/src/test/resources/com/android/asllib/datalabels/hr/data-labels-accessed-valid-bool.xml @@ -0,0 +1,6 @@ +<data-labels> + <data-accessed dataCategory="location" + dataType="approx_location" + ephemeral="false" + purposes="app_functionality" /> +</data-labels> \ No newline at end of file diff --git a/tools/app_metadata_bundles/src/test/resources/com/android/asllib/datalabels/hr/data-labels-collected-invalid-bool.xml b/tools/app_metadata_bundles/src/test/resources/com/android/asllib/datalabels/hr/data-labels-collected-invalid-bool.xml new file mode 100644 index 000000000000..ba11afbdce5f --- /dev/null +++ b/tools/app_metadata_bundles/src/test/resources/com/android/asllib/datalabels/hr/data-labels-collected-invalid-bool.xml @@ -0,0 +1,7 @@ +<data-labels> + <data-collected dataCategory="location" + dataType="approx_location" + ephemeral="false" + isSharingOptional="false" + purposes="app_functionality" /> +</data-labels> \ No newline at end of file diff --git a/tools/app_metadata_bundles/src/test/resources/com/android/asllib/datalabels/hr/data-labels-collected-valid-bool.xml b/tools/app_metadata_bundles/src/test/resources/com/android/asllib/datalabels/hr/data-labels-collected-valid-bool.xml new file mode 100644 index 000000000000..4b6d39776aeb --- /dev/null +++ b/tools/app_metadata_bundles/src/test/resources/com/android/asllib/datalabels/hr/data-labels-collected-valid-bool.xml @@ -0,0 +1,7 @@ +<data-labels> + <data-collected dataCategory="location" + dataType="approx_location" + ephemeral="false" + isCollectionOptional="false" + purposes="app_functionality" /> +</data-labels> \ No newline at end of file diff --git a/tools/app_metadata_bundles/src/test/resources/com/android/asllib/datalabels/hr/data-labels-shared-invalid-bool.xml b/tools/app_metadata_bundles/src/test/resources/com/android/asllib/datalabels/hr/data-labels-shared-invalid-bool.xml new file mode 100644 index 000000000000..7840b9876ad8 --- /dev/null +++ b/tools/app_metadata_bundles/src/test/resources/com/android/asllib/datalabels/hr/data-labels-shared-invalid-bool.xml @@ -0,0 +1,7 @@ +<data-labels> + <data-shared dataCategory="location" + dataType="approx_location" + ephemeral="false" + isCollectionOptional="false" + purposes="app_functionality" /> +</data-labels> \ No newline at end of file diff --git a/tools/app_metadata_bundles/src/test/resources/com/android/asllib/datalabels/hr/data-labels-shared-valid-bool.xml b/tools/app_metadata_bundles/src/test/resources/com/android/asllib/datalabels/hr/data-labels-shared-valid-bool.xml new file mode 100644 index 000000000000..ccf77b0e03be --- /dev/null +++ b/tools/app_metadata_bundles/src/test/resources/com/android/asllib/datalabels/hr/data-labels-shared-valid-bool.xml @@ -0,0 +1,7 @@ +<data-labels> + <data-shared dataCategory="location" + dataType="approx_location" + ephemeral="false" + isSharingOptional="false" + purposes="app_functionality" /> +</data-labels> \ No newline at end of file diff --git a/tools/app_metadata_bundles/src/test/resources/com/android/asllib/datalabels/od/data-labels-accessed-valid-bool.xml b/tools/app_metadata_bundles/src/test/resources/com/android/asllib/datalabels/od/data-labels-accessed-valid-bool.xml new file mode 100644 index 000000000000..ddefc18f62e3 --- /dev/null +++ b/tools/app_metadata_bundles/src/test/resources/com/android/asllib/datalabels/od/data-labels-accessed-valid-bool.xml @@ -0,0 +1,12 @@ +<pbundle_as_map name="data_labels"> + <pbundle_as_map name="data_accessed"> + <pbundle_as_map name="location"> + <pbundle_as_map name="approx_location"> + <int-array name="purposes" num="1"> + <item value="1"/> + </int-array> + <boolean name="ephemeral" value="false"/> + </pbundle_as_map> + </pbundle_as_map> + </pbundle_as_map> +</pbundle_as_map> \ No newline at end of file diff --git a/tools/app_metadata_bundles/src/test/resources/com/android/asllib/datalabels/od/data-labels-collected-valid-bool.xml b/tools/app_metadata_bundles/src/test/resources/com/android/asllib/datalabels/od/data-labels-collected-valid-bool.xml new file mode 100644 index 000000000000..252c7282da20 --- /dev/null +++ b/tools/app_metadata_bundles/src/test/resources/com/android/asllib/datalabels/od/data-labels-collected-valid-bool.xml @@ -0,0 +1,13 @@ +<pbundle_as_map name="data_labels"> + <pbundle_as_map name="data_collected"> + <pbundle_as_map name="location"> + <pbundle_as_map name="approx_location"> + <int-array name="purposes" num="1"> + <item value="1"/> + </int-array> + <boolean name="is_collection_optional" value="false"/> + <boolean name="ephemeral" value="false"/> + </pbundle_as_map> + </pbundle_as_map> + </pbundle_as_map> +</pbundle_as_map> \ No newline at end of file diff --git a/tools/app_metadata_bundles/src/test/resources/com/android/asllib/datalabels/od/data-labels-shared-valid-bool.xml b/tools/app_metadata_bundles/src/test/resources/com/android/asllib/datalabels/od/data-labels-shared-valid-bool.xml new file mode 100644 index 000000000000..d1d4e33e855a --- /dev/null +++ b/tools/app_metadata_bundles/src/test/resources/com/android/asllib/datalabels/od/data-labels-shared-valid-bool.xml @@ -0,0 +1,13 @@ +<pbundle_as_map name="data_labels"> + <pbundle_as_map name="data_shared"> + <pbundle_as_map name="location"> + <pbundle_as_map name="approx_location"> + <int-array name="purposes" num="1"> + <item value="1"/> + </int-array> + <boolean name="is_sharing_optional" value="false"/> + <boolean name="ephemeral" value="false"/> + </pbundle_as_map> + </pbundle_as_map> + </pbundle_as_map> +</pbundle_as_map> \ No newline at end of file diff --git a/tools/app_metadata_bundles/src/test/resources/com/android/asllib/developerinfo/hr/all-fields-valid.xml b/tools/app_metadata_bundles/src/test/resources/com/android/asllib/developerinfo/hr/all-fields-valid.xml new file mode 100644 index 000000000000..908d8ea2f53e --- /dev/null +++ b/tools/app_metadata_bundles/src/test/resources/com/android/asllib/developerinfo/hr/all-fields-valid.xml @@ -0,0 +1,8 @@ +<developer-info + name="max" + email="max@example.com" + address="111 blah lane" + countryRegion="US" + relationship="aosp" + website="example.com" + registryId="registry_id" /> \ No newline at end of file diff --git a/tools/app_metadata_bundles/src/test/resources/com/android/asllib/developerinfo/od/all-fields-valid.xml b/tools/app_metadata_bundles/src/test/resources/com/android/asllib/developerinfo/od/all-fields-valid.xml new file mode 100644 index 000000000000..784ec6156c1d --- /dev/null +++ b/tools/app_metadata_bundles/src/test/resources/com/android/asllib/developerinfo/od/all-fields-valid.xml @@ -0,0 +1,9 @@ +<pbundle_as_map name="developer_info"> + <string name="name" value="max"/> + <string name="email" value="max@example.com"/> + <string name="address" value="111 blah lane"/> + <string name="country_region" value="US"/> + <long name="relationship" value="5"/> + <string name="website" value="example.com"/> + <string name="app_developer_registry_id" value="registry_id"/> +</pbundle_as_map> \ No newline at end of file diff --git a/tools/app_metadata_bundles/src/test/resources/com/android/asllib/safetylabels/hr/missing-version.xml b/tools/app_metadata_bundles/src/test/resources/com/android/asllib/safetylabels/hr/missing-version.xml new file mode 100644 index 000000000000..762f3bdf7875 --- /dev/null +++ b/tools/app_metadata_bundles/src/test/resources/com/android/asllib/safetylabels/hr/missing-version.xml @@ -0,0 +1,2 @@ +<safety-labels> +</safety-labels> \ No newline at end of file diff --git a/tools/app_metadata_bundles/src/test/resources/com/android/asllib/safetylabels/hr/valid-empty.xml b/tools/app_metadata_bundles/src/test/resources/com/android/asllib/safetylabels/hr/valid-empty.xml new file mode 100644 index 000000000000..7decfd4865b1 --- /dev/null +++ b/tools/app_metadata_bundles/src/test/resources/com/android/asllib/safetylabels/hr/valid-empty.xml @@ -0,0 +1 @@ +<safety-labels version="12345"></safety-labels> \ No newline at end of file diff --git a/tools/app_metadata_bundles/src/test/resources/com/android/asllib/safetylabels/hr/with-data-labels.xml b/tools/app_metadata_bundles/src/test/resources/com/android/asllib/safetylabels/hr/with-data-labels.xml new file mode 100644 index 000000000000..8997f4f30c33 --- /dev/null +++ b/tools/app_metadata_bundles/src/test/resources/com/android/asllib/safetylabels/hr/with-data-labels.xml @@ -0,0 +1,9 @@ +<safety-labels version="12345"> + <data-labels> + <data-shared dataCategory="location" + dataType="approx_location" + isSharingOptional="false" + ephemeral="false" + purposes="app_functionality" /> + </data-labels> +</safety-labels> \ No newline at end of file diff --git a/tools/app_metadata_bundles/src/test/resources/com/android/asllib/safetylabels/od/valid-empty.xml b/tools/app_metadata_bundles/src/test/resources/com/android/asllib/safetylabels/od/valid-empty.xml new file mode 100644 index 000000000000..4f03d88a3bd2 --- /dev/null +++ b/tools/app_metadata_bundles/src/test/resources/com/android/asllib/safetylabels/od/valid-empty.xml @@ -0,0 +1,3 @@ +<pbundle_as_map name="safety_labels"> + <long name="version" value="12345"/> +</pbundle_as_map> \ No newline at end of file diff --git a/tools/app_metadata_bundles/src/test/resources/com/android/asllib/safetylabels/od/with-data-labels.xml b/tools/app_metadata_bundles/src/test/resources/com/android/asllib/safetylabels/od/with-data-labels.xml new file mode 100644 index 000000000000..a966fdaf9fe0 --- /dev/null +++ b/tools/app_metadata_bundles/src/test/resources/com/android/asllib/safetylabels/od/with-data-labels.xml @@ -0,0 +1,16 @@ +<pbundle_as_map name="safety_labels"> + <long name="version" value="12345"/> + <pbundle_as_map name="data_labels"> + <pbundle_as_map name="data_shared"> + <pbundle_as_map name="location"> + <pbundle_as_map name="approx_location"> + <int-array name="purposes" num="1"> + <item value="1"/> + </int-array> + <boolean name="is_sharing_optional" value="false"/> + <boolean name="ephemeral" value="false"/> + </pbundle_as_map> + </pbundle_as_map> + </pbundle_as_map> + </pbundle_as_map> +</pbundle_as_map> \ No newline at end of file diff --git a/tools/app_metadata_bundles/src/test/resources/com/android/asllib/systemappsafetylabel/hr/missing-url.xml b/tools/app_metadata_bundles/src/test/resources/com/android/asllib/systemappsafetylabel/hr/missing-url.xml new file mode 100644 index 000000000000..ff26c05abdb0 --- /dev/null +++ b/tools/app_metadata_bundles/src/test/resources/com/android/asllib/systemappsafetylabel/hr/missing-url.xml @@ -0,0 +1 @@ +<system-app-safety-label></system-app-safety-label> \ No newline at end of file diff --git a/tools/app_metadata_bundles/src/test/resources/com/android/asllib/systemappsafetylabel/hr/valid.xml b/tools/app_metadata_bundles/src/test/resources/com/android/asllib/systemappsafetylabel/hr/valid.xml new file mode 100644 index 000000000000..6fe86c33523b --- /dev/null +++ b/tools/app_metadata_bundles/src/test/resources/com/android/asllib/systemappsafetylabel/hr/valid.xml @@ -0,0 +1 @@ +<system-app-safety-label url="www.example.com"></system-app-safety-label> \ No newline at end of file diff --git a/tools/app_metadata_bundles/src/test/resources/com/android/asllib/systemappsafetylabel/od/valid.xml b/tools/app_metadata_bundles/src/test/resources/com/android/asllib/systemappsafetylabel/od/valid.xml new file mode 100644 index 000000000000..f96535b4b49b --- /dev/null +++ b/tools/app_metadata_bundles/src/test/resources/com/android/asllib/systemappsafetylabel/od/valid.xml @@ -0,0 +1,3 @@ +<pbundle_as_map name="system_app_safety_label"> + <string name="url" value="www.example.com"/> +</pbundle_as_map> \ No newline at end of file diff --git a/tools/app_metadata_bundles/src/test/resources/com/android/asllib/transparencyinfo/hr/valid-empty.xml b/tools/app_metadata_bundles/src/test/resources/com/android/asllib/transparencyinfo/hr/valid-empty.xml new file mode 100644 index 000000000000..254a37fb99e8 --- /dev/null +++ b/tools/app_metadata_bundles/src/test/resources/com/android/asllib/transparencyinfo/hr/valid-empty.xml @@ -0,0 +1,4 @@ + +<transparency-info> + +</transparency-info> \ No newline at end of file diff --git a/tools/app_metadata_bundles/src/test/resources/com/android/asllib/transparencyinfo/hr/with-app-info.xml b/tools/app_metadata_bundles/src/test/resources/com/android/asllib/transparencyinfo/hr/with-app-info.xml new file mode 100644 index 000000000000..a7c48fc68cf1 --- /dev/null +++ b/tools/app_metadata_bundles/src/test/resources/com/android/asllib/transparencyinfo/hr/with-app-info.xml @@ -0,0 +1,4 @@ + +<transparency-info> + <app-info title="beervision" description="a beer app" containsAds="true" obeyAps="false" adsFingerprinting="false" securityFingerprinting="false" privacyPolicy="www.example.com" securityEndpoints="url1|url2|url3" firstPartyEndpoints="url1" serviceProviderEndpoints="url55|url56" category="Food and drink" email="max@maxloh.com" /> +</transparency-info> \ No newline at end of file diff --git a/tools/app_metadata_bundles/src/test/resources/com/android/asllib/transparencyinfo/hr/with-developer-info.xml b/tools/app_metadata_bundles/src/test/resources/com/android/asllib/transparencyinfo/hr/with-developer-info.xml new file mode 100644 index 000000000000..862bda465b25 --- /dev/null +++ b/tools/app_metadata_bundles/src/test/resources/com/android/asllib/transparencyinfo/hr/with-developer-info.xml @@ -0,0 +1,11 @@ + +<transparency-info> + <developer-info + name="max" + email="max@example.com" + address="111 blah lane" + countryRegion="US" + relationship="aosp" + website="example.com" + appDeveloperRegistryId="registry_id" /> +</transparency-info> \ No newline at end of file diff --git a/tools/app_metadata_bundles/src/test/resources/com/android/asllib/transparencyinfo/od/valid-empty.xml b/tools/app_metadata_bundles/src/test/resources/com/android/asllib/transparencyinfo/od/valid-empty.xml new file mode 100644 index 000000000000..af574cf92b3a --- /dev/null +++ b/tools/app_metadata_bundles/src/test/resources/com/android/asllib/transparencyinfo/od/valid-empty.xml @@ -0,0 +1 @@ +<pbundle_as_map name="transparency_info"/> \ No newline at end of file diff --git a/tools/app_metadata_bundles/src/test/resources/com/android/asllib/transparencyinfo/od/with-app-info.xml b/tools/app_metadata_bundles/src/test/resources/com/android/asllib/transparencyinfo/od/with-app-info.xml new file mode 100644 index 000000000000..b813641f74f8 --- /dev/null +++ b/tools/app_metadata_bundles/src/test/resources/com/android/asllib/transparencyinfo/od/with-app-info.xml @@ -0,0 +1,26 @@ + +<pbundle_as_map name="transparency_info"> + <pbundle_as_map name="app_info"> + <string name="title" value="beervision"/> + <string name="description" value="a beer app"/> + <boolean name="contains_ads" value="true"/> + <boolean name="obey_aps" value="false"/> + <boolean name="ads_fingerprinting" value="false"/> + <boolean name="security_fingerprinting" value="false"/> + <string name="privacy_policy" value="www.example.com"/> + <string-array name="security_endpoint" num="3"> + <item value="url1"/> + <item value="url2"/> + <item value="url3"/> + </string-array> + <string-array name="first_party_endpoint" num="1"> + <item value="url1"/> + </string-array> + <string-array name="service_provider_endpoint" num="2"> + <item value="url55"/> + <item value="url56"/> + </string-array> + <string name="category" value="Food and drink"/> + <string name="email" value="max@maxloh.com"/> + </pbundle_as_map> +</pbundle_as_map> \ No newline at end of file diff --git a/tools/app_metadata_bundles/src/test/resources/com/android/asllib/transparencyinfo/od/with-developer-info.xml b/tools/app_metadata_bundles/src/test/resources/com/android/asllib/transparencyinfo/od/with-developer-info.xml new file mode 100644 index 000000000000..101c98bd8e60 --- /dev/null +++ b/tools/app_metadata_bundles/src/test/resources/com/android/asllib/transparencyinfo/od/with-developer-info.xml @@ -0,0 +1,11 @@ + +<pbundle_as_map name="transparency_info"> + <pbundle_as_map name="developer_info"> + <string name="name" value="max"/> + <string name="email" value="max@example.com"/> + <string name="address" value="111 blah lane"/> + <string name="country_region" value="US"/> + <long name="relationship" value="5"/> + <string name="website" value="example.com"/> + </pbundle_as_map> +</pbundle_as_map> \ No newline at end of file diff --git a/tools/app_metadata_bundles/src/test/resources/com/android/aslgen/validmappings/contacts/hr.xml b/tools/app_metadata_bundles/src/test/resources/com/android/asllib/validmappings/contacts/hr.xml similarity index 100% rename from tools/app_metadata_bundles/src/test/resources/com/android/aslgen/validmappings/contacts/hr.xml rename to tools/app_metadata_bundles/src/test/resources/com/android/asllib/validmappings/contacts/hr.xml diff --git a/tools/app_metadata_bundles/src/test/resources/com/android/aslgen/validmappings/contacts/od.xml b/tools/app_metadata_bundles/src/test/resources/com/android/asllib/validmappings/contacts/od.xml similarity index 100% rename from tools/app_metadata_bundles/src/test/resources/com/android/aslgen/validmappings/contacts/od.xml rename to tools/app_metadata_bundles/src/test/resources/com/android/asllib/validmappings/contacts/od.xml diff --git a/tools/app_metadata_bundles/src/test/resources/com/android/aslgen/validmappings/location/hr.xml b/tools/app_metadata_bundles/src/test/resources/com/android/asllib/validmappings/location/hr.xml similarity index 100% rename from tools/app_metadata_bundles/src/test/resources/com/android/aslgen/validmappings/location/hr.xml rename to tools/app_metadata_bundles/src/test/resources/com/android/asllib/validmappings/location/hr.xml diff --git a/tools/app_metadata_bundles/src/test/resources/com/android/aslgen/validmappings/location/od.xml b/tools/app_metadata_bundles/src/test/resources/com/android/asllib/validmappings/location/od.xml similarity index 100% rename from tools/app_metadata_bundles/src/test/resources/com/android/aslgen/validmappings/location/od.xml rename to tools/app_metadata_bundles/src/test/resources/com/android/asllib/validmappings/location/od.xml -- GitLab