diff --git a/tools/app_metadata_bundles/Android.bp b/tools/app_metadata_bundles/Android.bp index a012dca19904956d55b6d9dbae75c479962d9ce0..dced50d7ee3b06fe2280a1c76f9a95f8bfccd1ff 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 9dd55314e844a7fabe6ecfeb9871b49f03ed7c7c..c1c520e99cac8e17b070512f87dc7dfffa65149a 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 a0a75377e98879b1572490c4917042e3c2c641c8..0000000000000000000000000000000000000000 --- 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 cdb559b52c0e174e5644bf44762fb58a1670e877..112b92c9aebbe6c601a227bdec7310cc4b39cb75 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 3dc725b5452b548ea337754ec3c7a8258fba3261..b69c30f7f522d91c28eede564b08c5df884d2c92 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 f94b6591cd10d5d258ef4c7f0ea6417ac9d13537..3f1ddebefe9967216a068cd4038bc1831f535a87 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 26d94c16c7f0acbeb1b8e250fc5ec5bfe6f2b9db..59a437d7ece55c2f8e5c1bd1ef3b2c5536f512c2 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 4e64ab0c53c12b18af4047f94d8a59e52239af4c..48747ccbcff669760c8c9fc97f5f36d72ad653f2 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 b8f9f0ef6235e1bb8743bd4b99ebe520e171c2ed..a49b3e77155bc3bc5b439fb8a94b0d78138174c6 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 b9e06fbdfc7eeef2fa408cfe27e5a00240951785..4d67162b442d5d8f14df7fdcd09a7a3e2a461f1b 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 d2b671271561539fd95d6b05805ea25600276a3f..37d99e7ef85e4a586985bfd6b754b0539abf431b 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 96ec93c28c878bf1f55c73a4c1a51e779b064a2b..7516faf9f77a5c4fb05035491d968d600598f077 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 79edab7631f0987c8a604174f1eacd2cc08e384d..dc77fd08aa5300a1b9e735b2c2e605f3e4427eec 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 d011cfeef363a7cc98c6fc2a66f3cc3aa2b64123..34713623796633d6336580dd03187e826f726db3 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 27c1b599fec7c575c0ad3536912b3c7eb466f46a..ed434cda0823ada4ee61bfc0d01e2d3d357aad42 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 44a5b129e428736f8423071d187889079d4a9a87..382a1f0d0eca801f59114dea54f6b777f4ed3bca 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 4961892b10c3c6c512e89a0c88a351791d06f4ca..b5310bac232a2021525c627670598f881ed74b8f 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 40ef48dc53341769b026103cf6e3a44c06514ede..22c3fd8f2a1c74f38388a89cbb90dd6a7dcf33c5 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 ab81b1d56033fe4493061082ac76e860d15b5508..6bf8ef3df32d4034241be352c653009f626b0c95 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 93d9c2b080c56a2cd4ae3688b20969730fc94e19..595d748b59affea9d74c5d01b4ad81be67c06f4b 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 c8c1c7beba24be53e0380222d6bd71a32f9a62c6..f99955993d6c5c934780f31175241efa3b3288fc 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 88717b9568b88c417daa01cf0c808a99ccbcdfb8..ddd3557616ca5cb5be5bc1873a9937935c1f893d 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 13a7eb62feddf7194e77fb7ac613b385701b6ae8..d9c2af41fcacad881424bc46ee2b1415059253fe 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 b364c8b371947bd4a17790bd13986ac4751775ce..b5ae54c5bc007bedf3df585d793e7381b03fc36b 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 0000000000000000000000000000000000000000..358d575c1d560a78c611e9fbccaa302a3bec9625 --- /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 cc8fe79cb5791ac0fdd625776b190a45bd99bc38..691f92fca54b95a2a9db873c4e77123e6c9d0810 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 7ebb7a1c44bf500d440a057e91071e936d6a6839..03e8ac6d11c0969661fbfabc10381f22c3927633 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 3026f8bec2eddefa1ba73748a7b6454ea27610cb..5f43008d3dc6c80942eb8a0b6ac15b7cb754e497 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 0000000000000000000000000000000000000000..013700728e50cb4a44d72cfa23f1c9c8ca5470ff --- /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 0000000000000000000000000000000000000000..a015e2eacac539bc7412f0b3fa57fab8ff0495e9 --- /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 0000000000000000000000000000000000000000..822f1753f662c664786fcea6bd418a9299f8e5e5 --- /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 0000000000000000000000000000000000000000..2be447e182b29b67e7da5f215a78fd9164ca764e --- /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 0000000000000000000000000000000000000000..ff8346a526ad7972690635e40ab66680b4e7a500 --- /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 0000000000000000000000000000000000000000..b62620ef417e43299ecdde9c3c354ccd42662f00 --- /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 0000000000000000000000000000000000000000..191091a9e187ea8415bbcdfb443c92005c31f6ec --- /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 0000000000000000000000000000000000000000..56503f7d6c6baa4170fc41a035187c633e250dd4 --- /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 0000000000000000000000000000000000000000..faea340ae7bd36a18059556b68cad27fe5feb32a --- /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 0000000000000000000000000000000000000000..ec0cd702fd43e12e5408d2a290ebf824d9269669 --- /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 0000000000000000000000000000000000000000..19bfd826f770df5b7a083d4b791ea66fa1e910b4 --- /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 0000000000000000000000000000000000000000..53794a1d1c80229f77183cd241fff60e5562d2b5 --- /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 0000000000000000000000000000000000000000..7bcde4547933a9fa8e3f8a02640e47fedf5b5238 --- /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 0000000000000000000000000000000000000000..00bcfa80e9b1c615ac1e481f9c7e5c27a7669483 --- /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 0000000000000000000000000000000000000000..37bdfad4065fc73e60a0ba6a57c1ee53f10f5a13 --- /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 0000000000000000000000000000000000000000..74644ed0413c9574801962af1c99403249b3c06b --- /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 0000000000000000000000000000000000000000..ef0f549fc46b485dd0ff915e8671590a78047a8c --- /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 0000000000000000000000000000000000000000..63c5094333cc7decdf56913b2e6f9c9b9cad5857 --- /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 0000000000000000000000000000000000000000..883170a2d36f80e68da57d3569860ab876a4aeb8 --- /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 0000000000000000000000000000000000000000..6e976a3278dee0f0774103a2c86325d07d306499 --- /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 0000000000000000000000000000000000000000..520e525679b854c3073a0cbb6205a4a3be02d9b2 --- /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 0000000000000000000000000000000000000000..0d08e5b5ae4d56d54b101486ce4039288dce54f7 --- /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 0000000000000000000000000000000000000000..b1cf3b44fd4af8538943ac306380257a91a9c605 --- /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 0000000000000000000000000000000000000000..a723070c43b7bc4479f145804ea5e7dd6954a048 --- /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 0000000000000000000000000000000000000000..2fe28ffe49409101b427dc754bbdfd0371e0952b --- /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 0000000000000000000000000000000000000000..49a326fc43e5b52b3c493a06ea400efb57b8be5e --- /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 0000000000000000000000000000000000000000..f5de3707ef8a3c0b5da99cc9b349eb88245185e3 --- /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 0000000000000000000000000000000000000000..9891f8170bd7f1ec9d0c44b4acec9e0dcf9ab4a4 --- /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 0000000000000000000000000000000000000000..3e74da1ad5279c04a2a1e29667fd512a7024ddb0 --- /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 0000000000000000000000000000000000000000..4762f16d64dbf21c0b6dcd91e3500d4e47a8fb13 --- /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 0000000000000000000000000000000000000000..964e178e4dbdd8c3d25ba39303604e04f87c5583 --- /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 0000000000000000000000000000000000000000..3ce1288fb2c317ac717fcf680f076577c7046778 --- /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 0000000000000000000000000000000000000000..68baae30ef4f1277becb9d2b96d5bd5442f584f6 --- /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 0000000000000000000000000000000000000000..921a90a3fde728b8689067f9e3c00f978d992c49 --- /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 0000000000000000000000000000000000000000..4533773ec9c1ffb03edbbc5e93862a7c1e5d27e7 --- /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 0000000000000000000000000000000000000000..234fb265ae55cc6d28a3151acc5e3a36be158e7a --- /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 0000000000000000000000000000000000000000..db851633aec5559cfe8de0b431a15a291788ea92 --- /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 0000000000000000000000000000000000000000..9aad02de88772f96166f6fed2afed17be374cf8a --- /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 0000000000000000000000000000000000000000..64b9ea72e05b476b12e6194c732a61154fec88c2 --- /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 0000000000000000000000000000000000000000..5b99900b5a8a9a054ae9efca8907977c0df01190 --- /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 0000000000000000000000000000000000000000..0fe102202be543cb3a473db667b4bdfb074f4e2b --- /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 0000000000000000000000000000000000000000..51f1dfd6d82376436145d1cd4f63cd5eab6b7ede --- /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 0000000000000000000000000000000000000000..326da47a1cb957761c1b10082c8fc7c35559505c --- /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 0000000000000000000000000000000000000000..5d4387d2f90693476d73489b0c230e3da9a57e90 --- /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 0000000000000000000000000000000000000000..5ac98f56ace66dd6a8a027504b71e8584d7c9b37 --- /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 0000000000000000000000000000000000000000..a66f1a44dcb3d1795c79deec0c4ee7408b2f2996 --- /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 0000000000000000000000000000000000000000..8e697b47364cad3469385939250c952c077337dc --- /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 0000000000000000000000000000000000000000..34b4016e1364c7b9630af28f7a4fe59148d1b3ce --- /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 0000000000000000000000000000000000000000..db2e6965ff2a8d39f51f4903a60ae2c86706d488 --- /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 0000000000000000000000000000000000000000..839922a8bec674dfdae993fa15d2339a273f4d1f --- /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 0000000000000000000000000000000000000000..43650b6a77feda4986d97cd6fb83925067a3b187 --- /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 0000000000000000000000000000000000000000..2a3178005df3c9f73c84248d6e7e15d9efd6e3d4 --- /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 0000000000000000000000000000000000000000..9e654efcc5aba5bfe26b2106db375c229e4dce44 --- /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 0000000000000000000000000000000000000000..9abc37fdb2b96f6463b3bfbfb928a95a36f52afc --- /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 0000000000000000000000000000000000000000..bb45f426e0836569a6ca150b8addcb0bbfe17c6a --- /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 0000000000000000000000000000000000000000..f927bba838fdceb3bc2cbbdeab5637938765a044 --- /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 0000000000000000000000000000000000000000..ba11afbdce5f2cdda632867b2de092d8948ab2aa --- /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 0000000000000000000000000000000000000000..4b6d39776aebeb1f22db80cfca0379a83fea85b8 --- /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 0000000000000000000000000000000000000000..7840b9876ad83f2ec515fef049aa9bb9dfe9106d --- /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 0000000000000000000000000000000000000000..ccf77b0e03be21b34918bec3533c993be5ae147d --- /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 0000000000000000000000000000000000000000..ddefc18f62e3d7c578506feade7cd3cfe9d177ec --- /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 0000000000000000000000000000000000000000..252c7282da20e0f2e6b5af1d5c98c7f3b657ae86 --- /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 0000000000000000000000000000000000000000..d1d4e33e855af01af1618255bd70be8cd392e54a --- /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 0000000000000000000000000000000000000000..908d8ea2f53e83b1cff979157f2e06162330f557 --- /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 0000000000000000000000000000000000000000..784ec6156c1dfb22da546eacccd7ba51aac9fe98 --- /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 0000000000000000000000000000000000000000..762f3bdf787515971f96d6544c0bb51bed42cf70 --- /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 0000000000000000000000000000000000000000..7decfd4865b10dcfd0b80314e66c9b03538577e4 --- /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 0000000000000000000000000000000000000000..8997f4f30c336dfc4bdf8e8bad1e32cf35a991a2 --- /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 0000000000000000000000000000000000000000..4f03d88a3bd27e2501b4cb3bea69e16252b08e98 --- /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 0000000000000000000000000000000000000000..a966fdaf9fe0244610cf67c3906970015b387abc --- /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 0000000000000000000000000000000000000000..ff26c05abdb06032d6b89e6f003c3f339d1620f5 --- /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 0000000000000000000000000000000000000000..6fe86c33523bf571627dbf0fb08ecd330c35d9c5 --- /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 0000000000000000000000000000000000000000..f96535b4b49baab97bdddc4a481fc28e838ea7b4 --- /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 0000000000000000000000000000000000000000..254a37fb99e8802e751d1f2f3b99cc35c9574458 --- /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 0000000000000000000000000000000000000000..a7c48fc68cf146f969fa36cf7b7466088d415394 --- /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 0000000000000000000000000000000000000000..862bda465b2571a52df4d69dc316fccf15b8de84 --- /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 0000000000000000000000000000000000000000..af574cf92b3a1283532fddcd44d249277c5a6979 --- /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 0000000000000000000000000000000000000000..b813641f74f80124b5ed596a8b0c35453801ec56 --- /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 0000000000000000000000000000000000000000..101c98bd8e60ac406cc00eb3c44e48431f915865 --- /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