Merge "[Satellite] Add log for the bug analysis" into main
diff --git a/res/layout/accessibility_text_reading_preview.xml b/res/layout/accessibility_text_reading_preview.xml
index 2532a79..252736e 100644
--- a/res/layout/accessibility_text_reading_preview.xml
+++ b/res/layout/accessibility_text_reading_preview.xml
@@ -46,7 +46,6 @@
android:id="@+id/preview_pager"
android:layout_width="wrap_content"
android:layout_height="217dp"
- android:contentDescription="@string/preview_pager_content_description"
android:nestedScrollingEnabled="true" />
<LinearLayout
android:layout_width="match_parent"
diff --git a/res/layout/accessibility_text_reading_preview_app_grid.xml b/res/layout/accessibility_text_reading_preview_app_grid.xml
index 979c053..52fc574 100644
--- a/res/layout/accessibility_text_reading_preview_app_grid.xml
+++ b/res/layout/accessibility_text_reading_preview_app_grid.xml
@@ -14,14 +14,19 @@
See the License for the specific language governing permissions and
limitations under the License.
-->
-
-<com.android.settings.display.AppGridView
+<FrameLayout
xmlns:android="http://schemas.android.com/apk/res/android"
- xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
- android:numColumns="3"
- android:gravity="center"
- android:nestedScrollingEnabled="true"
- android:importantForAccessibility="noHideDescendants"
- app:appCount="6"/>
+ android:contentDescription="@string/preview_pager_home_content_description" >
+ <com.android.settings.display.AppGridView
+ xmlns:android="http://schemas.android.com/apk/res/android"
+ xmlns:app="http://schemas.android.com/apk/res-auto"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent"
+ android:numColumns="3"
+ android:gravity="center"
+ android:nestedScrollingEnabled="true"
+ android:importantForAccessibility="noHideDescendants"
+ app:appCount="6"/>
+</FrameLayout>
diff --git a/res/layout/accessibility_text_reading_preview_mail_content.xml b/res/layout/accessibility_text_reading_preview_mail_content.xml
index e55d389..db5ee7d 100644
--- a/res/layout/accessibility_text_reading_preview_mail_content.xml
+++ b/res/layout/accessibility_text_reading_preview_mail_content.xml
@@ -14,18 +14,18 @@
See the License for the specific language governing permissions and
limitations under the License.
-->
-
<androidx.core.widget.NestedScrollView
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fillViewport="true"
- android:importantForAccessibility="noHideDescendants">
+ android:contentDescription="@string/preview_pager_email_content_description">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
- android:orientation="vertical">
+ android:orientation="vertical"
+ android:importantForAccessibility="noHideDescendants">
<TextView
android:id="@+id/subject"
diff --git a/res/layout/screen_zoom_preview_1.xml b/res/layout/screen_zoom_preview_1.xml
index 97e0863..6e5bff9 100644
--- a/res/layout/screen_zoom_preview_1.xml
+++ b/res/layout/screen_zoom_preview_1.xml
@@ -19,12 +19,13 @@
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fillViewport="true"
- android:importantForAccessibility="noHideDescendants">
+ android:contentDescription="@string/preview_pager_message_content_description">
<view class="com.android.settings.TouchBlockingFrameLayout"
android:id="@+id/frame"
android:layout_width="match_parent"
- android:layout_height="wrap_content">
+ android:layout_height="wrap_content"
+ android:importantForAccessibility="noHideDescendants">
<LinearLayout
android:layout_width="match_parent"
diff --git a/res/values/config.xml b/res/values/config.xml
index ea16af4..4b38044 100644
--- a/res/values/config.xml
+++ b/res/values/config.xml
@@ -810,23 +810,13 @@
<!-- Allowed packages to show the confirmation dialog for a system locale suggestion -->
<string-array name="allowed_packages_for_locale_confirmation_diallog" translatable="false"/>
- <!-- Array of text reading preview layouts. Must contain at least 1 layout.
- Add content descriptions in the config_text_reading_preview_content_descriptions together
- if adding more sample layouts here -->
+ <!-- Array of text reading preview layouts. Must contain at least 1 layout -->
<array name="config_text_reading_preview_samples">
<item>@layout/accessibility_text_reading_preview_app_grid</item>
<item>@layout/screen_zoom_preview_1</item>
<item>@layout/accessibility_text_reading_preview_mail_content</item>
</array>
- <!-- Array of text reading preview layouts' content descriptions.
- The order should be the same as the layouts in config_text_reading_preview_samples -->
- <array name="config_text_reading_preview_content_descriptions">
- <item>@string/preview_pager_home_content_description</item>
- <item>@string/preview_pager_message_content_description</item>
- <item>@string/preview_pager_email_content_description</item>
- </array>
-
<!-- Package responsible for updating Mainline Modules -->
<string name="config_mainline_module_update_package" translatable="false">com.android.vending</string>
diff --git a/res/values/strings.xml b/res/values/strings.xml
index ac99f2d..6d865c2 100644
--- a/res/values/strings.xml
+++ b/res/values/strings.xml
@@ -14360,6 +14360,16 @@
<string name="supervision_web_content_filters_browser_block_explicit_sites_summary">No filter is perfect, but this should help hide sexually explicit sites</string>
<!-- Title for web content filters browser category allow all sites option [CHAR LIMIT=60] -->
<string name="supervision_web_content_filters_browser_allow_all_sites_title">Allow all sites</string>
+ <!-- Title for web content filters search category [CHAR LIMIT=60] -->
+ <string name="supervision_web_content_filters_search_title">Google Search</string>
+ <!-- Title for web content filters search category filter on option [CHAR LIMIT=60] -->
+ <string name="supervision_web_content_filters_search_filter_on_title">SafeSearch filtering ON</string>
+ <!-- Summary for web content filters search category filter on option [CHAR LIMIT=None] -->
+ <string name="supervision_web_content_filters_search_filter_on_summary">Helps filter out explicit images, text, and links from search results on this device</string>
+ <!-- Title for web content filters search category filter off option [CHAR LIMIT=60] -->
+ <string name="supervision_web_content_filters_search_filter_off_title">SafeSearch filtering OFF</string>
+ <!-- Summary for web content filters search category filter off option [CHAR LIMIT=None] -->
+ <string name="supervision_web_content_filters_search_filter_off_summary">Account settings may still filter or blur explicit results</string>
<!-- Generic content description that is attached to the preview illustration at the top of an Accessibility feature toggle page. [CHAR LIMIT=NONE] -->
<!-- Title for supervision PIN verification screen [CHAR LIMIT=60] -->
<string name="supervision_full_screen_pin_verification_title">Enter supervision PIN</string>
diff --git a/src/com/android/settings/accessibility/TextReadingPreviewController.java b/src/com/android/settings/accessibility/TextReadingPreviewController.java
index e268aaa..99f1f3f 100644
--- a/src/com/android/settings/accessibility/TextReadingPreviewController.java
+++ b/src/com/android/settings/accessibility/TextReadingPreviewController.java
@@ -104,13 +104,11 @@
final boolean isLayoutRtl =
origConfig.getLayoutDirection() == View.LAYOUT_DIRECTION_RTL;
final int[] previewSamples = getPreviewSampleLayouts(mContext);
- final int[] previewContentDescriptions = getPreviewSampleContentDescriptions(mContext);
final PreviewPagerAdapter pagerAdapter = new PreviewPagerAdapter(mContext, isLayoutRtl,
previewSamples, createConfig(origConfig));
mPreviewPreference.setPreviewAdapter(pagerAdapter);
mPreviewPreference.setCurrentItem(
isLayoutRtl ? previewSamples.length - 1 : FRAME_INITIAL_INDEX);
- mPreviewPreference.setContentDescription(previewContentDescriptions);
final int initialPagerIndex =
mLastFontProgress * mDisplaySizeData.getValues().size() + mLastDisplayProgress;
@@ -190,20 +188,6 @@
return previewSamples;
}
- @VisibleForTesting(otherwise = VisibleForTesting.PRIVATE)
- static int[] getPreviewSampleContentDescriptions(Context context) {
- TypedArray typedArray = context.getResources().obtainTypedArray(
- R.array.config_text_reading_preview_content_descriptions);
- int previewCount = typedArray.length();
- int[] previewContentDescriptions = new int[previewCount];
- for (int i = 0; i < previewCount; i++) {
- previewContentDescriptions[i] =
- typedArray.getResourceId(i, R.string.preview_pager_content_description);
- }
- typedArray.recycle();
- return previewContentDescriptions;
- }
-
private int getPagerIndex() {
final int displayDataSize = mDisplaySizeData.getValues().size();
final int fontSizeProgress = mFontSizePreference.getProgress();
diff --git a/src/com/android/settings/accessibility/TextReadingPreviewPreference.java b/src/com/android/settings/accessibility/TextReadingPreviewPreference.java
index a4676ba..6d60736 100644
--- a/src/com/android/settings/accessibility/TextReadingPreviewPreference.java
+++ b/src/com/android/settings/accessibility/TextReadingPreviewPreference.java
@@ -43,10 +43,26 @@
private int mCurrentItem;
private int mLastLayerIndex;
private PreviewPagerAdapter mPreviewAdapter;
- private int[] mContentDescriptions;
private int mLayoutMinHorizontalPadding = 0;
private int mBackgroundMinHorizontalPadding = 0;
+ private final ViewPager.OnPageChangeListener mPageChangeListener =
+ new ViewPager.OnPageChangeListener() {
+ @Override
+ public void onPageScrolled(int i, float v, int i1) {
+ // Do nothing
+ }
+
+ @Override
+ public void onPageSelected(int i) {
+ mCurrentItem = i;
+ }
+
+ @Override
+ public void onPageScrollStateChanged(int i) {
+ // Do nothing
+ }
+ };
TextReadingPreviewPreference(Context context) {
super(context);
@@ -78,23 +94,7 @@
adjustPaddings(previewLayout, backgroundView);
final ViewPager viewPager = (ViewPager) holder.findViewById(R.id.preview_pager);
- viewPager.addOnPageChangeListener(new ViewPager.OnPageChangeListener() {
- @Override
- public void onPageScrolled(int i, float v, int i1) {
- // Do nothing
- }
-
- @Override
- public void onPageSelected(int i) {
- mCurrentItem = i;
- viewPager.setContentDescription(getContext().getString(mContentDescriptions[i]));
- }
-
- @Override
- public void onPageScrollStateChanged(int i) {
- // Do nothing
- }
- });
+ viewPager.addOnPageChangeListener(mPageChangeListener);
final DotsPageIndicator pageIndicator =
(DotsPageIndicator) holder.findViewById(R.id.page_indicator);
updateAdapterIfNeeded(viewPager, pageIndicator, mPreviewAdapter);
@@ -121,10 +121,6 @@
viewPager.setCurrentItem(getCurrentItem() + 1));
nextButton.setContentDescription(getContext().getString(
R.string.preview_pager_next_button));
-
- // Initialize the content description since the OnPageChangeListener#onPageSelected won't
- // be called during setup.
- viewPager.setContentDescription(getContext().getString(mContentDescriptions[0]));
}
@Override
@@ -173,10 +169,6 @@
);
}
- void setContentDescription(int[] stringIds) {
- mContentDescriptions = stringIds;
- }
-
void setPreviewAdapter(PreviewPagerAdapter previewAdapter) {
if (previewAdapter != mPreviewAdapter) {
mPreviewAdapter = previewAdapter;
diff --git a/src/com/android/settings/supervision/SupervisionSafeSearchPreference.kt b/src/com/android/settings/supervision/SupervisionSafeSearchPreference.kt
new file mode 100644
index 0000000..617a345
--- /dev/null
+++ b/src/com/android/settings/supervision/SupervisionSafeSearchPreference.kt
@@ -0,0 +1,106 @@
+/*
+ * Copyright (C) 2025 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.settings.supervision
+
+import android.content.Context
+import androidx.preference.Preference
+import com.android.settings.R
+import com.android.settingslib.datastore.KeyValueStore
+import com.android.settingslib.datastore.Permissions
+import com.android.settingslib.datastore.SettingsSecureStore
+import com.android.settingslib.metadata.BooleanValuePreference
+import com.android.settingslib.metadata.PreferenceMetadata
+import com.android.settingslib.metadata.ReadWritePermit
+import com.android.settingslib.metadata.SensitivityLevel
+import com.android.settingslib.preference.PreferenceBinding
+import com.android.settingslib.preference.forEachRecursively
+import com.android.settingslib.widget.SelectorWithWidgetPreference
+
+/** Base class of web content filters SafeSearch preferences. */
+sealed class SupervisionSafeSearchPreference :
+ BooleanValuePreference, SelectorWithWidgetPreference.OnClickListener, PreferenceBinding {
+ override fun storage(context: Context): KeyValueStore = SettingsSecureStore.get(context)
+
+ override fun getReadPermissions(context: Context) = Permissions.EMPTY
+
+ override fun getWritePermissions(context: Context) = Permissions.EMPTY
+
+ override fun getReadPermit(context: Context, callingPid: Int, callingUid: Int) =
+ ReadWritePermit.ALLOW
+
+ override fun getWritePermit(
+ context: Context,
+ value: Boolean?,
+ callingPid: Int,
+ callingUid: Int,
+ ) = ReadWritePermit.DISALLOW
+
+ override val sensitivityLevel
+ get() = SensitivityLevel.NO_SENSITIVITY
+
+ override fun createWidget(context: Context) = SelectorWithWidgetPreference(context)
+
+ override fun onRadioButtonClicked(emiter: SelectorWithWidgetPreference) {
+ emiter.parent?.forEachRecursively {
+ if (it is SelectorWithWidgetPreference) {
+ it.isChecked = it == emiter
+ }
+ }
+ }
+
+ override fun bind(preference: Preference, metadata: PreferenceMetadata) {
+ super.bind(preference, metadata)
+ (preference as SelectorWithWidgetPreference).also {
+ // TODO(b/401568995): Set the isChecked value using stored values.
+ it.isChecked = (it.key == SupervisionSearchFilterOffPreference.KEY)
+ it.setOnClickListener(this)
+ }
+ }
+}
+
+/** The SafeSearch filter on preference. */
+class SupervisionSearchFilterOnPreference : SupervisionSafeSearchPreference() {
+
+ override val key
+ get() = KEY
+
+ override val title
+ get() = R.string.supervision_web_content_filters_search_filter_on_title
+
+ override val summary
+ get() = R.string.supervision_web_content_filters_search_filter_on_summary
+
+ companion object {
+ const val KEY = "web_content_filters_search_filter_on"
+ }
+}
+
+/** The SafeSearch filter off preference. */
+class SupervisionSearchFilterOffPreference : SupervisionSafeSearchPreference() {
+
+ override val key
+ get() = KEY
+
+ override val title
+ get() = R.string.supervision_web_content_filters_search_filter_off_title
+
+ override val summary
+ get() = R.string.supervision_web_content_filters_search_filter_off_summary
+
+ companion object {
+ const val KEY = "web_content_filters_search_filter_off"
+ }
+}
diff --git a/src/com/android/settings/supervision/SupervisionSafeSitesDataStore.kt b/src/com/android/settings/supervision/SupervisionSafeSitesDataStore.kt
new file mode 100644
index 0000000..4f283b8
--- /dev/null
+++ b/src/com/android/settings/supervision/SupervisionSafeSitesDataStore.kt
@@ -0,0 +1,75 @@
+/*
+ * Copyright (C) 2025 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.settings.supervision
+
+import android.content.Context
+import android.provider.Settings.Secure.BROWSER_CONTENT_FILTERS_ENABLED
+import com.android.settingslib.datastore.AbstractKeyedDataObservable
+import com.android.settingslib.datastore.HandlerExecutor
+import com.android.settingslib.datastore.KeyValueStore
+import com.android.settingslib.datastore.KeyedObserver
+import com.android.settingslib.datastore.SettingsSecureStore
+import com.android.settingslib.datastore.SettingsStore
+
+/** Datastore of the safe sites preference. */
+@Suppress("UNCHECKED_CAST")
+class SupervisionSafeSitesDataStore(
+ private val context: Context,
+ private val settingsStore: SettingsStore = SettingsSecureStore.get(context),
+) : AbstractKeyedDataObservable<String>(), KeyedObserver<String>, KeyValueStore {
+
+ override fun contains(key: String) =
+ key == SupervisionBlockExplicitSitesPreference.KEY ||
+ key == SupervisionAllowAllSitesPreference.KEY
+
+ override fun <T : Any> getValue(key: String, valueType: Class<T>): T? {
+ val settingValue = (settingsStore.getBoolean(BROWSER_CONTENT_FILTERS_ENABLED) == true)
+ return when (key) {
+ SupervisionAllowAllSitesPreference.KEY -> !settingValue
+
+ SupervisionBlockExplicitSitesPreference.KEY -> settingValue
+
+ else -> null
+ }
+ as T?
+ }
+
+ override fun <T : Any> setValue(key: String, valueType: Class<T>, value: T?) {
+ if (value !is Boolean) return
+ when (key) {
+ SupervisionAllowAllSitesPreference.KEY ->
+ settingsStore.setBoolean(BROWSER_CONTENT_FILTERS_ENABLED, !value)
+
+ SupervisionBlockExplicitSitesPreference.KEY ->
+ settingsStore.setBoolean(BROWSER_CONTENT_FILTERS_ENABLED, value)
+ }
+ }
+
+ override fun onFirstObserverAdded() {
+ // observe the underlying storage key
+ settingsStore.addObserver(BROWSER_CONTENT_FILTERS_ENABLED, this, HandlerExecutor.main)
+ }
+
+ override fun onKeyChanged(key: String, reason: Int) {
+ // forward data change to preference hierarchy key
+ notifyChange(SupervisionBlockExplicitSitesPreference.KEY, reason)
+ notifyChange(SupervisionAllowAllSitesPreference.KEY, reason)
+ }
+
+ override fun onLastObserverRemoved() {
+ settingsStore.removeObserver(BROWSER_CONTENT_FILTERS_ENABLED, this)
+ }
+}
diff --git a/src/com/android/settings/supervision/SupervisionSafeSitesPreference.kt b/src/com/android/settings/supervision/SupervisionSafeSitesPreference.kt
index aaa5a33..d78afb2 100644
--- a/src/com/android/settings/supervision/SupervisionSafeSitesPreference.kt
+++ b/src/com/android/settings/supervision/SupervisionSafeSitesPreference.kt
@@ -18,9 +18,7 @@
import android.content.Context
import androidx.preference.Preference
import com.android.settings.R
-import com.android.settingslib.datastore.KeyValueStore
import com.android.settingslib.datastore.Permissions
-import com.android.settingslib.datastore.SettingsSecureStore
import com.android.settingslib.metadata.BooleanValuePreference
import com.android.settingslib.metadata.PreferenceMetadata
import com.android.settingslib.metadata.ReadWritePermit
@@ -30,9 +28,10 @@
import com.android.settingslib.widget.SelectorWithWidgetPreference
/** Base class of web content filters Safe sites preferences. */
-sealed class SupervisionSafeSitesPreference :
- BooleanValuePreference, SelectorWithWidgetPreference.OnClickListener, PreferenceBinding {
- override fun storage(context: Context): KeyValueStore = SettingsSecureStore.get(context)
+sealed class SupervisionSafeSitesPreference(
+ protected val dataStore: SupervisionSafeSitesDataStore
+) : BooleanValuePreference, SelectorWithWidgetPreference.OnClickListener, PreferenceBinding {
+ override fun storage(context: Context) = dataStore
override fun getReadPermissions(context: Context) = Permissions.EMPTY
@@ -64,15 +63,15 @@
override fun bind(preference: Preference, metadata: PreferenceMetadata) {
super.bind(preference, metadata)
(preference as SelectorWithWidgetPreference).also {
- // TODO(b/401568468): Set the isChecked value using stored values.
- it.isChecked = (it.key == SupervisionAllowAllSitesPreference.KEY)
+ it.isChecked = (dataStore.getBoolean(it.key) == true)
it.setOnClickListener(this)
}
}
}
/** The "Try to block explicit sites" preference. */
-class SupervisionBlockExplicitSitesPreference : SupervisionSafeSitesPreference() {
+class SupervisionBlockExplicitSitesPreference(dataStore: SupervisionSafeSitesDataStore) :
+ SupervisionSafeSitesPreference(dataStore) {
override val key
get() = KEY
@@ -89,7 +88,8 @@
}
/** The "Allow all sites" preference. */
-class SupervisionAllowAllSitesPreference : SupervisionSafeSitesPreference() {
+class SupervisionAllowAllSitesPreference(dataStore: SupervisionSafeSitesDataStore) :
+ SupervisionSafeSitesPreference(dataStore) {
override val key
get() = KEY
diff --git a/src/com/android/settings/supervision/SupervisionWebContentFiltersScreen.kt b/src/com/android/settings/supervision/SupervisionWebContentFiltersScreen.kt
index 0a2891b..994165a 100644
--- a/src/com/android/settings/supervision/SupervisionWebContentFiltersScreen.kt
+++ b/src/com/android/settings/supervision/SupervisionWebContentFiltersScreen.kt
@@ -47,14 +47,23 @@
R.string.supervision_web_content_filters_browser_title,
) +=
{
- +SupervisionBlockExplicitSitesPreference()
- +SupervisionAllowAllSitesPreference()
+ val dataStore = SupervisionSafeSitesDataStore(context)
+ +SupervisionBlockExplicitSitesPreference(dataStore)
+ +SupervisionAllowAllSitesPreference(dataStore)
}
- // TODO(b/401569571) implement the SafeSearch group.
+ +PreferenceCategory(
+ SEARCH_RADIO_BUTTON_GROUP,
+ R.string.supervision_web_content_filters_search_title,
+ ) +=
+ {
+ +SupervisionSearchFilterOnPreference()
+ +SupervisionSearchFilterOffPreference()
+ }
}
companion object {
const val KEY = "supervision_web_content_filters"
internal const val BROWSER_RADIO_BUTTON_GROUP = "browser_radio_button_group"
+ internal const val SEARCH_RADIO_BUTTON_GROUP = "search_radio_button_group"
}
}
diff --git a/tests/robotests/src/com/android/settings/accessibility/TextReadingPreviewControllerTest.java b/tests/robotests/src/com/android/settings/accessibility/TextReadingPreviewControllerTest.java
index 81c869d..375952f 100644
--- a/tests/robotests/src/com/android/settings/accessibility/TextReadingPreviewControllerTest.java
+++ b/tests/robotests/src/com/android/settings/accessibility/TextReadingPreviewControllerTest.java
@@ -16,8 +16,6 @@
package com.android.settings.accessibility;
-import static com.google.common.truth.Truth.assertThat;
-
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.Mockito.spy;
import static org.mockito.Mockito.verify;
@@ -79,15 +77,6 @@
}
@Test
- public void numberOfPreviewSamples_numberOfPreviewContentDescription_isEqual() {
- int[] previewSamples = TextReadingPreviewController.getPreviewSampleLayouts(mContext);
- int[] previewContentDescriptions =
- TextReadingPreviewController.getPreviewSampleContentDescriptions(mContext);
-
- assertThat(previewSamples.length).isEqualTo(previewContentDescriptions.length);
- }
-
- @Test
public void initPreviewerAdapter_verifyAction() {
when(mPreferenceScreen.findPreference(PREVIEW_KEY)).thenReturn(mPreviewPreference);
when(mPreferenceScreen.findPreference(FONT_SIZE_KEY)).thenReturn(mFontSizePreference);
diff --git a/tests/robotests/src/com/android/settings/accessibility/TextReadingPreviewPreferenceTest.java b/tests/robotests/src/com/android/settings/accessibility/TextReadingPreviewPreferenceTest.java
index 9cd8fa2..ac503bd 100644
--- a/tests/robotests/src/com/android/settings/accessibility/TextReadingPreviewPreferenceTest.java
+++ b/tests/robotests/src/com/android/settings/accessibility/TextReadingPreviewPreferenceTest.java
@@ -49,48 +49,28 @@
*/
@RunWith(RobolectricTestRunner.class)
public class TextReadingPreviewPreferenceTest {
- private Context mContext;
private TextReadingPreviewPreference mTextReadingPreviewPreference;
private PreferenceViewHolder mHolder;
private ViewPager mViewPager;
private PreviewPagerAdapter mPreviewPagerAdapter;
private int mPreviewSampleCount;
- private int[] mPreviewContentDescriptions;
@Before
public void setUp() {
- mContext = ApplicationProvider.getApplicationContext();
- mPreviewContentDescriptions =
- TextReadingPreviewController.getPreviewSampleContentDescriptions(mContext);
- final int[] previewSamples = TextReadingPreviewController.getPreviewSampleLayouts(mContext);
+ final Context context = ApplicationProvider.getApplicationContext();
+ final int[] previewSamples = TextReadingPreviewController.getPreviewSampleLayouts(context);
mPreviewSampleCount = previewSamples.length;
final Configuration[] configurations = createConfigurations(mPreviewSampleCount);
- mTextReadingPreviewPreference = new TextReadingPreviewPreference(mContext);
+ mTextReadingPreviewPreference = new TextReadingPreviewPreference(context);
mPreviewPagerAdapter =
- spy(new PreviewPagerAdapter(mContext, /* isLayoutRtl= */ false,
+ spy(new PreviewPagerAdapter(context, /* isLayoutRtl= */ false,
previewSamples, configurations));
- final LayoutInflater inflater = LayoutInflater.from(mContext);
+ final LayoutInflater inflater = LayoutInflater.from(context);
final View view =
inflater.inflate(mTextReadingPreviewPreference.getLayoutResource(),
- new LinearLayout(mContext), false);
+ new LinearLayout(context), false);
mHolder = PreferenceViewHolder.createInstanceForTests(view);
mViewPager = view.findViewById(R.id.preview_pager);
- mTextReadingPreviewPreference.setContentDescription(mPreviewContentDescriptions);
- }
-
- @Test
- public void changePreviewPage_getExpectedContentDescription() {
- mTextReadingPreviewPreference.setPreviewAdapter(mPreviewPagerAdapter);
- mTextReadingPreviewPreference.onBindViewHolder(mHolder);
-
- // Verify the initial content description
- assertThat(mViewPager.getContentDescription().toString())
- .isEqualTo(mContext.getString(mPreviewContentDescriptions[0]));
-
- // Change the preview page
- mViewPager.setCurrentItem(1);
- assertThat(mViewPager.getContentDescription().toString())
- .isEqualTo(mContext.getString(mPreviewContentDescriptions[1]));
}
@Test
diff --git a/tests/robotests/src/com/android/settings/supervision/SupervisionSafeSearchPreferenceTest.kt b/tests/robotests/src/com/android/settings/supervision/SupervisionSafeSearchPreferenceTest.kt
new file mode 100644
index 0000000..371cca3
--- /dev/null
+++ b/tests/robotests/src/com/android/settings/supervision/SupervisionSafeSearchPreferenceTest.kt
@@ -0,0 +1,60 @@
+/*
+ * Copyright (C) 2025 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.settings.supervision
+
+import android.content.Context
+import androidx.test.core.app.ApplicationProvider
+import androidx.test.ext.junit.runners.AndroidJUnit4
+import com.android.settings.R
+import com.google.common.truth.Truth.assertThat
+import org.junit.Test
+import org.junit.runner.RunWith
+
+@RunWith(AndroidJUnit4::class)
+class SupervisionSafeSearchPreferenceTest {
+ private val context: Context = ApplicationProvider.getApplicationContext()
+
+ private val searchFilterOnPreference = SupervisionSearchFilterOnPreference()
+
+ private val searchFilterOffPreference = SupervisionSearchFilterOffPreference()
+
+ @Test
+ fun getTitle_filterOn() {
+ assertThat(searchFilterOnPreference.title)
+ .isEqualTo(R.string.supervision_web_content_filters_search_filter_on_title)
+ }
+
+
+ @Test
+ fun getSummary_filterOn() {
+ assertThat(searchFilterOnPreference.summary)
+ .isEqualTo(R.string.supervision_web_content_filters_search_filter_on_summary)
+ }
+
+ @Test
+ fun getTitle_filterOff() {
+ assertThat(searchFilterOffPreference.title)
+ .isEqualTo(R.string.supervision_web_content_filters_search_filter_off_title)
+ }
+
+ @Test
+ fun getSummary_filterOff() {
+ assertThat(searchFilterOffPreference.summary)
+ .isEqualTo(
+ R.string.supervision_web_content_filters_search_filter_off_summary
+ )
+ }
+}
diff --git a/tests/robotests/src/com/android/settings/supervision/SupervisionSafeSitesPreferenceTest.kt b/tests/robotests/src/com/android/settings/supervision/SupervisionSafeSitesPreferenceTest.kt
index 5be7a11..a3aca69 100644
--- a/tests/robotests/src/com/android/settings/supervision/SupervisionSafeSitesPreferenceTest.kt
+++ b/tests/robotests/src/com/android/settings/supervision/SupervisionSafeSitesPreferenceTest.kt
@@ -16,20 +16,33 @@
package com.android.settings.supervision
import android.content.Context
+import android.provider.Settings
+import android.provider.Settings.Secure.BROWSER_CONTENT_FILTERS_ENABLED
+import android.provider.Settings.SettingNotFoundException
import androidx.test.core.app.ApplicationProvider
import androidx.test.ext.junit.runners.AndroidJUnit4
import com.android.settings.R
+import com.android.settingslib.preference.createAndBindWidget
+import com.android.settingslib.widget.SelectorWithWidgetPreference
import com.google.common.truth.Truth.assertThat
+import org.junit.Assert.assertThrows
+import org.junit.Before
import org.junit.Test
import org.junit.runner.RunWith
@RunWith(AndroidJUnit4::class)
class SupervisionSafeSitesPreferenceTest {
private val context: Context = ApplicationProvider.getApplicationContext()
+ private lateinit var dataStore: SupervisionSafeSitesDataStore
+ private lateinit var allowAllSitesPreference: SupervisionAllowAllSitesPreference
+ private lateinit var blockExplicitSitesPreference: SupervisionBlockExplicitSitesPreference
- private val allowAllSitesPreference = SupervisionAllowAllSitesPreference()
-
- private val blockExplicitSitesPreference = SupervisionBlockExplicitSitesPreference()
+ @Before
+ fun setUp() {
+ dataStore = SupervisionSafeSitesDataStore(context)
+ allowAllSitesPreference = SupervisionAllowAllSitesPreference(dataStore)
+ blockExplicitSitesPreference = SupervisionBlockExplicitSitesPreference(dataStore)
+ }
@Test
fun getTitle_allowAllSites() {
@@ -50,4 +63,64 @@
R.string.supervision_web_content_filters_browser_block_explicit_sites_summary
)
}
+
+ @Test
+ fun allowAllSitesIsChecked_whenNoValueIsSet() {
+ assertThrows(SettingNotFoundException::class.java) {
+ Settings.Secure.getInt(context.getContentResolver(), BROWSER_CONTENT_FILTERS_ENABLED)
+ }
+ assertThat(getBlockExplicitSitesWidget().isChecked).isFalse()
+ assertThat(getAllowAllSitesWidget().isChecked).isTrue()
+ }
+
+ @Test
+ fun blockExplicitSitesIsChecked_whenPreviouslyEnabled() {
+ Settings.Secure.putInt(context.getContentResolver(), BROWSER_CONTENT_FILTERS_ENABLED, 1)
+ assertThat(getAllowAllSitesWidget().isChecked).isFalse()
+ assertThat(getBlockExplicitSitesWidget().isChecked).isTrue()
+ }
+
+ @Test
+ fun clickBlockExplicitSites_enablesFilter() {
+ Settings.Secure.putInt(context.getContentResolver(), BROWSER_CONTENT_FILTERS_ENABLED, 0)
+ val blockExplicitSitesWidget = getBlockExplicitSitesWidget()
+ assertThat(blockExplicitSitesWidget.isChecked).isFalse()
+
+ blockExplicitSitesWidget.performClick()
+
+ assertThat(
+ Settings.Secure.getInt(
+ context.getContentResolver(),
+ BROWSER_CONTENT_FILTERS_ENABLED,
+ )
+ )
+ .isEqualTo(1)
+ assertThat(blockExplicitSitesWidget.isChecked).isTrue()
+ }
+
+ @Test
+ fun clickAllowAllSites_disablesFilter() {
+ Settings.Secure.putInt(context.getContentResolver(), BROWSER_CONTENT_FILTERS_ENABLED, 1)
+ val allowAllSitesWidget = getAllowAllSitesWidget()
+ assertThat(allowAllSitesWidget.isChecked).isFalse()
+
+ allowAllSitesWidget.performClick()
+
+ assertThat(
+ Settings.Secure.getInt(
+ context.getContentResolver(),
+ BROWSER_CONTENT_FILTERS_ENABLED,
+ )
+ )
+ .isEqualTo(0)
+ assertThat(allowAllSitesWidget.isChecked).isTrue()
+ }
+
+ private fun getBlockExplicitSitesWidget(): SelectorWithWidgetPreference {
+ return blockExplicitSitesPreference.createAndBindWidget(context)
+ }
+
+ private fun getAllowAllSitesWidget(): SelectorWithWidgetPreference {
+ return allowAllSitesPreference.createAndBindWidget(context)
+ }
}
diff --git a/tests/robotests/src/com/android/settings/supervision/SupervisionWebContentFiltersScreenTest.kt b/tests/robotests/src/com/android/settings/supervision/SupervisionWebContentFiltersScreenTest.kt
index 351cbde..31bdbd2 100644
--- a/tests/robotests/src/com/android/settings/supervision/SupervisionWebContentFiltersScreenTest.kt
+++ b/tests/robotests/src/com/android/settings/supervision/SupervisionWebContentFiltersScreenTest.kt
@@ -15,18 +15,32 @@
*/
package com.android.settings.supervision
+import android.app.supervision.flags.Flags
import android.content.Context
+import android.platform.test.annotations.DisableFlags
+import android.platform.test.annotations.EnableFlags
+import android.platform.test.flag.junit.SetFlagsRule
+import androidx.fragment.app.testing.FragmentScenario
import androidx.test.core.app.ApplicationProvider
import androidx.test.ext.junit.runners.AndroidJUnit4
import com.android.settings.R
+import com.android.settingslib.widget.SelectorWithWidgetPreference
import com.google.common.truth.Truth.assertThat
+import org.junit.Before
+import org.junit.Rule
import org.junit.Test
import org.junit.runner.RunWith
@RunWith(AndroidJUnit4::class)
class SupervisionWebContentFiltersScreenTest {
+ @get:Rule val setFlagsRule = SetFlagsRule()
private val context: Context = ApplicationProvider.getApplicationContext()
- private val supervisionWebContentFiltersScreen = SupervisionWebContentFiltersScreen()
+ private lateinit var supervisionWebContentFiltersScreen: SupervisionWebContentFiltersScreen
+
+ @Before
+ fun setUp() {
+ supervisionWebContentFiltersScreen = SupervisionWebContentFiltersScreen()
+ }
@Test
fun key() {
@@ -39,4 +53,40 @@
assertThat(supervisionWebContentFiltersScreen.title)
.isEqualTo(R.string.supervision_web_content_filters_title)
}
+
+ @Test
+ @EnableFlags(Flags.FLAG_ENABLE_WEB_CONTENT_FILTERS_SCREEN)
+ fun flagEnabled() {
+ assertThat(supervisionWebContentFiltersScreen.isFlagEnabled(context)).isTrue()
+ }
+
+ @Test
+ @DisableFlags(Flags.FLAG_ENABLE_WEB_CONTENT_FILTERS_SCREEN)
+ fun flagDisabled() {
+ assertThat(supervisionWebContentFiltersScreen.isFlagEnabled(context)).isFalse()
+ }
+
+ @Test
+ @EnableFlags(Flags.FLAG_ENABLE_WEB_CONTENT_FILTERS_SCREEN)
+ fun switchSafeSitesPreferences() {
+ FragmentScenario.launchInContainer(supervisionWebContentFiltersScreen.fragmentClass())
+ .onFragment { fragment ->
+ val allowAllSitesPreference =
+ fragment.findPreference<SelectorWithWidgetPreference>(
+ SupervisionAllowAllSitesPreference.KEY
+ )!!
+ val blockExplicitSitesPreference =
+ fragment.findPreference<SelectorWithWidgetPreference>(
+ SupervisionBlockExplicitSitesPreference.KEY
+ )!!
+
+ assertThat(allowAllSitesPreference.isChecked).isTrue()
+ assertThat(blockExplicitSitesPreference.isChecked).isFalse()
+
+ blockExplicitSitesPreference.performClick()
+
+ assertThat(blockExplicitSitesPreference.isChecked).isTrue()
+ assertThat(allowAllSitesPreference.isChecked).isFalse()
+ }
+ }
}
diff --git a/tests/unit/src/com/android/settings/network/telephony/satellite/SatelliteSettingsPreferenceControllerTest.java b/tests/unit/src/com/android/settings/network/telephony/satellite/SatelliteSettingsPreferenceControllerTest.java
index c527d68..7cb85a5 100644
--- a/tests/unit/src/com/android/settings/network/telephony/satellite/SatelliteSettingsPreferenceControllerTest.java
+++ b/tests/unit/src/com/android/settings/network/telephony/satellite/SatelliteSettingsPreferenceControllerTest.java
@@ -19,7 +19,6 @@
import static android.telephony.CarrierConfigManager.CARRIER_ROAMING_NTN_CONNECT_AUTOMATIC;
import static android.telephony.CarrierConfigManager.CARRIER_ROAMING_NTN_CONNECT_MANUAL;
import static android.telephony.CarrierConfigManager.KEY_SATELLITE_ENTITLEMENT_SUPPORTED_BOOL;
-import static android.telephony.NetworkRegistrationInfo.SERVICE_TYPE_DATA;
import static android.telephony.NetworkRegistrationInfo.SERVICE_TYPE_SMS;
import static com.android.settings.core.BasePreferenceController.AVAILABLE;
@@ -183,40 +182,6 @@
@Test
@EnableFlags(com.android.settings.flags.Flags.FLAG_SATELLITE_OEM_SETTINGS_UX_MIGRATION)
- public void title_hasServiceDataType_showDataUi() {
- mController.initialize(TEST_SUB_ID);
- PreferenceManager preferenceManager = new PreferenceManager(mContext);
- PreferenceScreen preferenceScreen = preferenceManager.createPreferenceScreen(mContext);
- Preference preference = new Preference(mContext);
- preference.setKey(KEY);
- preference.setTitle("test title");
- preferenceScreen.addPreference(preference);
- mController.displayPreference(preferenceScreen);
- mController.mCarrierRoamingNtnModeCallback.onCarrierRoamingNtnAvailableServicesChanged(
- new int[]{SERVICE_TYPE_SMS, SERVICE_TYPE_DATA});
-
- assertThat(preference.getTitle()).isEqualTo("Satellite connectivity");
- }
-
- @Test
- @EnableFlags(com.android.settings.flags.Flags.FLAG_SATELLITE_OEM_SETTINGS_UX_MIGRATION)
- public void title_onlyHasServiceSmsType_showSmsUi() {
- mController.initialize(TEST_SUB_ID);
- PreferenceManager preferenceManager = new PreferenceManager(mContext);
- PreferenceScreen preferenceScreen = preferenceManager.createPreferenceScreen(mContext);
- Preference preference = new Preference(mContext);
- preference.setKey(KEY);
- preference.setTitle("test title");
- preferenceScreen.addPreference(preference);
- mController.displayPreference(preferenceScreen);
- mController.mCarrierRoamingNtnModeCallback.onCarrierRoamingNtnAvailableServicesChanged(
- new int[]{SERVICE_TYPE_SMS});
-
- assertThat(preference.getTitle()).isEqualTo("Satellite messaging");
- }
-
- @Test
- @EnableFlags(com.android.settings.flags.Flags.FLAG_SATELLITE_OEM_SETTINGS_UX_MIGRATION)
public void summary_noEntitlementAndTypeIsAuto_showSummaryWithoutEntitlement() {
mCarrierConfig.putInt(
CarrierConfigManager.KEY_CARRIER_ROAMING_NTN_CONNECT_TYPE_INT,