Revert "[cts] tests for settings readable fields"

Revert submission 13355582-settings_readable

Reason for revert: b/178340718
Reverted Changes:
Id1f133d52:[cts] tests for settings readable fields
I8a2733580:[SettingsProvider] @Readable annotation to restric...

Change-Id: I9770bab89d39c52424fb5ad8f99524a27de13e8f
(cherry picked from commit 1ca518c1ec75b8307126991ae2d253911b2be10c)
diff --git a/hostsidetests/appsecurity/src/android/appsecurity/cts/ReadableSettingsFieldsTest.java b/hostsidetests/appsecurity/src/android/appsecurity/cts/ReadableSettingsFieldsTest.java
deleted file mode 100644
index 17a23a8..0000000
--- a/hostsidetests/appsecurity/src/android/appsecurity/cts/ReadableSettingsFieldsTest.java
+++ /dev/null
@@ -1,89 +0,0 @@
-/*
- * Copyright (C) 2021 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 android.appsecurity.cts;
-
-
-import static org.junit.Assert.assertTrue;
-
-import com.android.tradefed.device.DeviceNotAvailableException;
-import com.android.tradefed.testtype.DeviceJUnit4ClassRunner;
-import com.android.tradefed.testtype.junit4.BaseHostJUnit4Test;
-
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-
-import java.io.File;
-
-/**
- * Test that:
- * 1) all the public fields annotated with @Readable in Settings.Secure, Settings.System,
- * Settings.Global classes are readable.
- * 2) hidden fields added before S are also readable, via their raw Settings key String values.
- * 3) public fields without the @Readable annotation will not be readable.
- *
- * Run with:
- * atest android.appsecurity.cts.ReadableSettingsFieldsTest
- */
-@RunWith(DeviceJUnit4ClassRunner.class)
-public class ReadableSettingsFieldsTest extends BaseAppSecurityTest {
-    private static final String TEST_PACKAGE = "com.android.cts.readsettingsfieldsapp";
-    private static final String TEST_CLASS = TEST_PACKAGE + ".ReadSettingsFieldsTest";
-    private static final String TEST_APK = "CtsReadSettingsFieldsApp.apk";
-
-    @Before
-    public void setUp() throws Exception {
-        new InstallMultiple().addFile(TEST_APK).run();
-        assertTrue(getDevice().isPackageInstalled(TEST_PACKAGE));
-    }
-
-    @After
-    public void tearDown() throws Exception {
-        getDevice().uninstallPackage(TEST_PACKAGE);
-    }
-
-    @Test
-    public void testSecurePublicSettingsKeysAreReadable() throws DeviceNotAvailableException {
-        runDeviceTests(TEST_PACKAGE, TEST_CLASS, "testSecurePublicSettingsKeysAreReadable");
-    }
-
-    @Test
-    public void testSystemPublicSettingsKeysAreReadable() throws DeviceNotAvailableException {
-        runDeviceTests(TEST_PACKAGE, TEST_CLASS, "testSystemPublicSettingsKeysAreReadable");
-    }
-
-    @Test
-    public void testGlobalPublicSettingsKeysAreReadable() throws DeviceNotAvailableException {
-        runDeviceTests(TEST_PACKAGE, TEST_CLASS, "testGlobalPublicSettingsKeysAreReadable");
-    }
-
-    @Test
-    public void testSecureSomeHiddenSettingsKeysAreReadable() throws DeviceNotAvailableException {
-        runDeviceTests(TEST_PACKAGE, TEST_CLASS, "testSecureSomeHiddenSettingsKeysAreReadable");
-    }
-
-    @Test
-    public void testSystemSomeHiddenSettingsKeysAreReadable() throws DeviceNotAvailableException {
-        runDeviceTests(TEST_PACKAGE, TEST_CLASS, "testSystemSomeHiddenSettingsKeysAreReadable");
-    }
-
-    @Test
-    public void testGlobalSomeHiddenSettingsKeysAreReadable() throws DeviceNotAvailableException {
-        runDeviceTests(TEST_PACKAGE, TEST_CLASS, "testGlobalSomeHiddenSettingsKeysAreReadable");
-    }
-}
diff --git a/hostsidetests/appsecurity/test-apps/ReadSettingsFieldsApp/Android.bp b/hostsidetests/appsecurity/test-apps/ReadSettingsFieldsApp/Android.bp
deleted file mode 100644
index e8824a7..0000000
--- a/hostsidetests/appsecurity/test-apps/ReadSettingsFieldsApp/Android.bp
+++ /dev/null
@@ -1,33 +0,0 @@
-// Copyright (C) 2021 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.
-
-android_test_helper_app {
-    name: "CtsReadSettingsFieldsApp",
-    defaults: ["cts_support_defaults"],
-    static_libs: [
-        "androidx.test.rules",
-    ],
-    libs: [
-        "android.test.runner",
-        "android.test.base",
-    ],
-    srcs: [
-        "src/**/*.java",
-    ],
-    // tag this module as a cts test artifact
-    test_suites: [
-        "cts",
-        "general-tests",
-    ],
-}
diff --git a/hostsidetests/appsecurity/test-apps/ReadSettingsFieldsApp/AndroidManifest.xml b/hostsidetests/appsecurity/test-apps/ReadSettingsFieldsApp/AndroidManifest.xml
deleted file mode 100644
index 9a33237..0000000
--- a/hostsidetests/appsecurity/test-apps/ReadSettingsFieldsApp/AndroidManifest.xml
+++ /dev/null
@@ -1,27 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!--
-  ~ Copyright (C) 2021 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.
-  -->
-<manifest xmlns:android="http://schemas.android.com/apk/res/android"
-          package="com.android.cts.readsettingsfieldsapp">
-
-    <application android:label="CtsReadSettingsFieldsApp">
-        <uses-library android:name="android.test.runner" />
-    </application>
-
-    <instrumentation android:name="androidx.test.runner.AndroidJUnitRunner"
-                     android:targetPackage="com.android.cts.readsettingsfieldsapp" />
-
-</manifest>
diff --git a/hostsidetests/appsecurity/test-apps/ReadSettingsFieldsApp/OWNERS b/hostsidetests/appsecurity/test-apps/ReadSettingsFieldsApp/OWNERS
deleted file mode 100644
index 7d65382..0000000
--- a/hostsidetests/appsecurity/test-apps/ReadSettingsFieldsApp/OWNERS
+++ /dev/null
@@ -1,4 +0,0 @@
-# Bug component: 856262
-svetoslavganov@google.com
-toddke@google.com
-schfan@google.com
diff --git a/hostsidetests/appsecurity/test-apps/ReadSettingsFieldsApp/src/com/android/cts/readsettingsfieldsapp/ReadSettingsFieldsTest.java b/hostsidetests/appsecurity/test-apps/ReadSettingsFieldsApp/src/com/android/cts/readsettingsfieldsapp/ReadSettingsFieldsTest.java
deleted file mode 100644
index 326eb15..0000000
--- a/hostsidetests/appsecurity/test-apps/ReadSettingsFieldsApp/src/com/android/cts/readsettingsfieldsapp/ReadSettingsFieldsTest.java
+++ /dev/null
@@ -1,128 +0,0 @@
-/*
- * Copyright (C) 2021 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.cts.readsettingsfieldsapp;
-
-import android.provider.Settings;
-import android.test.AndroidTestCase;
-import android.util.ArraySet;
-
-import java.lang.reflect.Field;
-
-public class ReadSettingsFieldsTest extends AndroidTestCase {
-
-    public void testSecurePublicSettingsKeysAreReadable() {
-        for (String key : getPublicSettingsKeys(Settings.Secure.class)) {
-            try {
-                Settings.Secure.getString(getContext().getContentResolver(), key);
-            } catch (SecurityException ex) {
-                fail("Reading public Secure settings key <" + key + "> should not raise exception! "
-                        + "Did you forget to add @Readable annotation?\n" + ex.getMessage());
-            }
-        }
-    }
-
-    public void testSystemPublicSettingsKeysAreReadable() {
-        for (String key : getPublicSettingsKeys(Settings.System.class)) {
-            try {
-                Settings.System.getString(getContext().getContentResolver(), key);
-            } catch (SecurityException ex) {
-                fail("Reading public System settings key <" + key + "> should not raise exception! "
-                        + "Did you forget to add @Readable annotation?\n" + ex.getMessage());
-            }
-        }
-    }
-
-    public void testGlobalPublicSettingsKeysAreReadable() {
-        for (String key : getPublicSettingsKeys(Settings.Global.class)) {
-            try {
-                Settings.Global.getString(getContext().getContentResolver(), key);
-            } catch (SecurityException ex) {
-                fail("Reading public Global settings key <" + key + "> should not raise exception! "
-                        + "Did you forget to add @Readable annotation?\n" + ex.getMessage());
-            }
-        }
-    }
-
-    private <T> ArraySet<String> getPublicSettingsKeys(Class<T> settingsClass) {
-        final ArraySet<String> publicSettingsKeys = new ArraySet<>();
-        final Field[] allFields = settingsClass.getDeclaredFields();
-        try {
-            for (int i = 0; i < allFields.length; i++) {
-                final Field field = allFields[i];
-                if (field.getType().equals(String.class)) {
-                    final Object value = field.get(settingsClass);
-                    if (value.getClass().equals(String.class)) {
-                        publicSettingsKeys.add((String) value);
-                    }
-                }
-            }
-        } catch (IllegalAccessException ignored) {
-        }
-        return publicSettingsKeys;
-    }
-
-    public void testSecureSomeHiddenSettingsKeysAreReadable() {
-        final ArraySet<String> publicSettingsKeys = getPublicSettingsKeys(Settings.Secure.class);
-        final String[] hiddenSettingsKeys = {"adaptive_sleep", "bugreport_in_power_menu",
-                "input_methods_subtype_history"};
-        for (String key : hiddenSettingsKeys) {
-            try {
-                // Verify that the hidden keys are not visible to the test app
-                assertFalse("Settings key <" + key + "> should not be visible",
-                        publicSettingsKeys.contains(key));
-                // Verify that the hidden keys can still be read
-                Settings.Secure.getString(getContext().getContentResolver(), key);
-            } catch (SecurityException ex) {
-                fail("Reading hidden Secure settings key <" + key + "> should not raise!");
-            }
-        }
-    }
-
-    public void testSystemSomeHiddenSettingsKeysAreReadable() {
-        final ArraySet<String> publicSettingsKeys = getPublicSettingsKeys(Settings.System.class);
-        final String[] hiddenSettingsKeys = {"advanced_settings", "system_locales",
-                "display_color_mode", "min_refresh_rate"};
-        for (String key : hiddenSettingsKeys) {
-            try {
-                // Verify that the hidden keys are not visible to the test app
-                assertFalse("Settings key <" + key + "> should not be visible",
-                        publicSettingsKeys.contains(key));
-                // Verify that the hidden keys can still be read
-                Settings.System.getString(getContext().getContentResolver(), key);
-            } catch (SecurityException ex) {
-                fail("Reading hidden System settings key <" + key + "> should not raise!");
-            }
-        }
-    }
-
-    public void testGlobalSomeHiddenSettingsKeysAreReadable() {
-        final ArraySet<String> publicSettingsKeys = getPublicSettingsKeys(Settings.Secure.class);
-        final String[] hiddenSettingsKeys = {"notification_bubbles", "add_users_when_locked",
-                "enable_accessibility_global_gesture_enabled"};
-        for (String key : hiddenSettingsKeys) {
-            try {
-                // Verify that the hidden keys are not visible to the test app
-                assertFalse("Settings key <" + key + "> should not be visible",
-                        publicSettingsKeys.contains(key));
-                // Verify that the hidden keys can still be read
-                Settings.Global.getString(getContext().getContentResolver(), key);
-            } catch (SecurityException ex) {
-                fail("Reading hidden Global settings key <" + key + "> should not raise!");
-            }
-        }
-    }
-}