From 2a83cc998419035e2376f7fe41d92c58c608d2a0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=ABl=20Stemmer?= Date: Fri, 26 Aug 2022 13:33:47 +0100 Subject: [PATCH] Re-enable secureSettingsBackedUpOrDenied test This test exists to make sure that every new setting that is introduced is either backed up or added to the deny list to indicate it shouldn't be backed up. Over 2 years ago this test was disabled because it appears to have been failing for some conditions, and unfortunately it was never re-enabled. While this test was disabled, many new settings have been introduced that are not being backed up but are also not present in the deny list. It will take some time to investigate whether each of these settings should be backed up or not, but we want to re-enable this test as soon as possible to avoid this problem with future settings. So I've created a temporary allowlist of settings that are neither backed up or deny listed. We should gradually remove the settings from this list as we figure out whether they should be backed up or not. New settings should not be added to this list. Additionally, there was one setting that appeared in both SETTINGS_TO_BACKUP and BACKUP_DENY_LIST_SECURE_SETTINGS. Since it's being backed up, I've removed it from the deny list. Bug: 243630515 Test: atest SettingsBackupTest.java Change-Id: I399c21ee03041eb0cf7e1c0695bd96edc5e8a08f --- .../android/provider/SettingsBackupTest.java | 63 ++++++++++++++++--- 1 file changed, 56 insertions(+), 7 deletions(-) diff --git a/packages/SettingsProvider/test/src/android/provider/SettingsBackupTest.java b/packages/SettingsProvider/test/src/android/provider/SettingsBackupTest.java index ba7a9bcc7cd79..1dfa96f55532e 100644 --- a/packages/SettingsProvider/test/src/android/provider/SettingsBackupTest.java +++ b/packages/SettingsProvider/test/src/android/provider/SettingsBackupTest.java @@ -31,7 +31,6 @@ import android.provider.settings.backup.SecureSettings; import android.provider.settings.backup.SystemSettings; import androidx.test.filters.SmallTest; -import androidx.test.filters.Suppress; import androidx.test.runner.AndroidJUnit4; import org.junit.Test; @@ -709,7 +708,6 @@ public class SettingsBackupTest { Settings.Secure.DOCKED_CLOCK_FACE, Settings.Secure.DOZE_PULSE_ON_LONG_PRESS, Settings.Secure.EMERGENCY_ASSISTANCE_APPLICATION, - Settings.Secure.ENABLED_ACCESSIBILITY_AUDIO_DESCRIPTION_BY_DEFAULT, Settings.Secure.ENABLED_INPUT_METHODS, // Intentionally removed in P Settings.Secure.ENABLED_NOTIFICATION_ASSISTANT, Settings.Secure.ENABLED_NOTIFICATION_LISTENERS, @@ -837,15 +835,66 @@ public class SettingsBackupTest { } @Test - @Suppress //("b/148236308") public void secureSettingsBackedUpOrDenied() { + // List of settings that were not added to either SETTINGS_TO_BACKUP or + // BACKUP_DENY_LIST_SECURE_SETTINGS while this test was suppressed in + // the last two years. Settings in this list are temporarily allowed to + // not be explicitly listed as backed up or denied so we can re-enable + // this test. + // + // DO NOT ADD NEW SETTINGS TO THIS LIST! + Set settingsNotBackedUpOrDeniedTemporaryAllowList = + newHashSet( + Settings.Secure.ACCESSIBILITY_ALLOW_DIAGONAL_SCROLLING, + Settings.Secure.AMBIENT_CONTEXT_CONSENT_COMPONENT, + Settings.Secure.AMBIENT_CONTEXT_EVENT_ARRAY_EXTRA_KEY, + Settings.Secure.AMBIENT_CONTEXT_PACKAGE_NAME_EXTRA_KEY, + Settings.Secure.ASSIST_LONG_PRESS_HOME_ENABLED, + Settings.Secure.ASSIST_TOUCH_GESTURE_ENABLED, + Settings.Secure.AUTO_REVOKE_DISABLED, + Settings.Secure.BIOMETRIC_APP_ENABLED, + Settings.Secure.BIOMETRIC_KEYGUARD_ENABLED, + Settings.Secure.BIOMETRIC_VIRTUAL_ENABLED, + Settings.Secure.BLUETOOTH_ADDR_VALID, + Settings.Secure.BLUETOOTH_ADDRESS, + Settings.Secure.BLUETOOTH_NAME, + Settings.Secure.BUBBLE_IMPORTANT_CONVERSATIONS, + Settings.Secure.CLIPBOARD_SHOW_ACCESS_NOTIFICATIONS, + Settings.Secure.COMMUNAL_MODE_ENABLED, + Settings.Secure.COMMUNAL_MODE_TRUSTED_NETWORKS, + Settings.Secure.DEFAULT_VOICE_INPUT_METHOD, + Settings.Secure.DOCK_SETUP_STATE, + Settings.Secure.EXTRA_AUTOMATIC_POWER_SAVE_MODE, + Settings.Secure.GAME_DASHBOARD_ALWAYS_ON, + Settings.Secure.HDMI_CEC_SET_MENU_LANGUAGE_DENYLIST, + Settings.Secure.LAUNCHER_TASKBAR_EDUCATION_SHOWING, + Settings.Secure.LOCATION_COARSE_ACCURACY_M, + Settings.Secure.LOCATION_SHOW_SYSTEM_OPS, + Settings.Secure.NAS_SETTINGS_UPDATED, + Settings.Secure.NAV_BAR_FORCE_VISIBLE, + Settings.Secure.NAV_BAR_KIDS_MODE, + Settings.Secure.NEARBY_FAST_PAIR_SETTINGS_DEVICES_COMPONENT, + Settings.Secure.NEARBY_SHARING_SLICE_URI, + Settings.Secure.NOTIFIED_NON_ACCESSIBILITY_CATEGORY_SERVICES, + Settings.Secure.ONE_HANDED_TUTORIAL_SHOW_COUNT, + Settings.Secure.RELEASE_COMPRESS_BLOCKS_ON_INSTALL, + Settings.Secure.SCREENSAVER_COMPLICATIONS_ENABLED, + Settings.Secure.SHOW_QR_CODE_SCANNER_SETTING, + Settings.Secure.SKIP_ACCESSIBILITY_SHORTCUT_DIALOG_TIMEOUT_RESTRICTION, + Settings.Secure.SPATIAL_AUDIO_ENABLED, + Settings.Secure.TIMEOUT_TO_USER_ZERO, + Settings.Secure.UI_NIGHT_MODE_LAST_COMPUTED, + Settings.Secure.UI_NIGHT_MODE_OVERRIDE_OFF, + Settings.Secure.UI_NIGHT_MODE_OVERRIDE_ON); + HashSet keys = new HashSet(); Collections.addAll(keys, SecureSettings.SETTINGS_TO_BACKUP); Collections.addAll(keys, DEVICE_SPECIFIC_SETTINGS_TO_BACKUP); - checkSettingsBackedUpOrDenied( - getCandidateSettings(Settings.Secure.class), - keys, - BACKUP_DENY_LIST_SECURE_SETTINGS); + + Set allSettings = getCandidateSettings(Settings.Secure.class); + allSettings.removeAll(settingsNotBackedUpOrDeniedTemporaryAllowList); + + checkSettingsBackedUpOrDenied(allSettings, keys, BACKUP_DENY_LIST_SECURE_SETTINGS); } private static void checkSettingsBackedUpOrDenied(