diff --git a/res/xml/accessibility_settings.xml b/res/xml/accessibility_settings.xml
index 509aed6c4d0..0287fc65d2d 100644
--- a/res/xml/accessibility_settings.xml
+++ b/res/xml/accessibility_settings.xml
@@ -41,7 +41,8 @@
android:icon="@drawable/ic_adaptive_font_download"
android:key="text_reading_options"
android:persistent="false"
- android:title="@string/accessibility_text_reading_options_title" />
+ android:title="@string/accessibility_text_reading_options_title"
+ settings:controller="com.android.settings.accessibility.TextReadingFragmentForA11ySettingsController"/>
+ settings:keywords="text_reading_options"
+ settings:controller="com.android.settings.accessibility.TextReadingFragmentForSuwController"/>
+ android:title="@string/accessibility_text_reading_options_title"
+ settings:controller="com.android.settings.accessibility.TextReadingFragmentForDisplaySettingsController"/>
This should only be used for logging.
+ */
+ @Retention(RetentionPolicy.SOURCE)
+ @IntDef({
+ EntryPoint.UNKNOWN_ENTRY,
+ EntryPoint.SUW_VISION_SETTINGS,
+ EntryPoint.SUW_ANYTHING_ELSE,
+ EntryPoint.DISPLAY_SETTINGS,
+ EntryPoint.ACCESSIBILITY_SETTINGS,
+ })
+ @interface EntryPoint {
+ int UNKNOWN_ENTRY = 0;
+ int SUW_VISION_SETTINGS = 1;
+ int SUW_ANYTHING_ELSE = 2;
+ int DISPLAY_SETTINGS = 3;
+ int ACCESSIBILITY_SETTINGS = 4;
+ }
@VisibleForTesting
List mResetStateListeners;
@@ -91,6 +121,8 @@ public class TextReadingPreferenceFragment extends DashboardFragment {
@Override
protected List createPreferenceControllers(Context context) {
+ updateEntryPoint();
+
final List controllers = new ArrayList<>();
final FontSizeData fontSizeData = new FontSizeData(context);
final DisplaySizeData displaySizeData = createDisplaySizeData(context);
@@ -102,24 +134,29 @@ public class TextReadingPreferenceFragment extends DashboardFragment {
final PreviewSizeSeekBarController fontSizeController = new PreviewSizeSeekBarController(
context, FONT_SIZE_KEY, fontSizeData);
fontSizeController.setInteractionListener(previewController);
+ fontSizeController.setEntryPoint(mEntryPoint);
controllers.add(fontSizeController);
final PreviewSizeSeekBarController displaySizeController = new PreviewSizeSeekBarController(
context, DISPLAY_SIZE_KEY, displaySizeData);
displaySizeController.setInteractionListener(previewController);
+ displaySizeController.setEntryPoint(mEntryPoint);
controllers.add(displaySizeController);
mFontWeightAdjustmentController =
new FontWeightAdjustmentPreferenceController(context, BOLD_TEXT_KEY);
+ mFontWeightAdjustmentController.setEntryPoint(mEntryPoint);
controllers.add(mFontWeightAdjustmentController);
final HighTextContrastPreferenceController highTextContrastController =
- new HighTextContrastPreferenceController(context, HIGHT_TEXT_CONTRAST_KEY);
+ new HighTextContrastPreferenceController(context, HIGH_TEXT_CONTRAST_KEY);
+ highTextContrastController.setEntryPoint(mEntryPoint);
controllers.add(highTextContrastController);
final TextReadingResetController resetController =
new TextReadingResetController(context, RESET_KEY,
v -> showDialog(DialogEnums.DIALOG_RESET_SETTINGS));
+ resetController.setEntryPoint(mEntryPoint);
controllers.add(resetController);
return controllers;
@@ -162,6 +199,24 @@ public class TextReadingPreferenceFragment extends DashboardFragment {
return new DisplaySizeData(context);
}
+ private void updateEntryPoint() {
+ final Bundle bundle = getArguments();
+ if (bundle != null && bundle.containsKey(EXTRA_LAUNCHED_FROM)) {
+ mEntryPoint = bundle.getInt(EXTRA_LAUNCHED_FROM, EntryPoint.UNKNOWN_ENTRY);
+ return;
+ }
+
+ final Intent intent = getIntent();
+ if (intent == null) {
+ mEntryPoint = EntryPoint.UNKNOWN_ENTRY;
+ return;
+ }
+
+ final Set categories = intent.getCategories();
+ mEntryPoint = categories != null && categories.contains(CATEGORY_FOR_ANYTHING_ELSE)
+ ? EntryPoint.SUW_ANYTHING_ELSE : EntryPoint.UNKNOWN_ENTRY;
+ }
+
private void onPositiveButtonClicked(DialogInterface dialog, int which) {
// To avoid showing the dialog again, probably the onDetach() of SettingsDialogFragment
// was interrupted by unexpectedly recreating the activity.
diff --git a/src/com/android/settings/accessibility/TextReadingResetController.java b/src/com/android/settings/accessibility/TextReadingResetController.java
index 152ad5fe4f1..30a94c2eadd 100644
--- a/src/com/android/settings/accessibility/TextReadingResetController.java
+++ b/src/com/android/settings/accessibility/TextReadingResetController.java
@@ -23,7 +23,9 @@ import androidx.annotation.Nullable;
import androidx.preference.PreferenceScreen;
import com.android.settings.R;
+import com.android.settings.accessibility.TextReadingPreferenceFragment.EntryPoint;
import com.android.settings.core.BasePreferenceController;
+import com.android.settings.core.instrumentation.SettingsStatsLog;
import com.android.settingslib.widget.LayoutPreference;
/**
@@ -32,6 +34,9 @@ import com.android.settingslib.widget.LayoutPreference;
class TextReadingResetController extends BasePreferenceController {
private final View.OnClickListener mOnResetClickListener;
+ @EntryPoint
+ private int mEntryPoint;
+
TextReadingResetController(Context context, String preferenceKey,
@Nullable View.OnClickListener listener) {
super(context, preferenceKey);
@@ -52,10 +57,25 @@ class TextReadingResetController extends BasePreferenceController {
view.setOnClickListener(v -> {
if (mOnResetClickListener != null) {
mOnResetClickListener.onClick(v);
+
+ SettingsStatsLog.write(
+ SettingsStatsLog.ACCESSIBILITY_TEXT_READING_OPTIONS_CHANGED,
+ AccessibilityStatsLogUtils.convertToItemKeyName(getPreferenceKey()),
+ /* reset */ -1,
+ AccessibilityStatsLogUtils.convertToEntryPoint(mEntryPoint));
}
});
}
+ /**
+ * The entry point is used for logging.
+ *
+ * @param entryPoint from which settings page
+ */
+ void setEntryPoint(@EntryPoint int entryPoint) {
+ mEntryPoint = entryPoint;
+ }
+
/**
* Interface for resetting to default state.
*/
diff --git a/tests/robotests/src/com/android/settings/accessibility/TextReadingFragmentBaseControllerTest.java b/tests/robotests/src/com/android/settings/accessibility/TextReadingFragmentBaseControllerTest.java
new file mode 100644
index 00000000000..ad6a895498a
--- /dev/null
+++ b/tests/robotests/src/com/android/settings/accessibility/TextReadingFragmentBaseControllerTest.java
@@ -0,0 +1,55 @@
+/*
+ * Copyright (C) 2022 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.accessibility;
+
+import static com.android.settings.accessibility.TextReadingPreferenceFragment.EXTRA_LAUNCHED_FROM;
+import static com.android.settings.accessibility.TextReadingPreferenceFragment.EntryPoint.ACCESSIBILITY_SETTINGS;
+import static com.android.settings.accessibility.TextReadingPreferenceFragment.EntryPoint.UNKNOWN_ENTRY;
+
+import static com.google.common.truth.Truth.assertThat;
+
+import android.content.Context;
+
+import androidx.preference.Preference;
+import androidx.test.core.app.ApplicationProvider;
+
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.robolectric.RobolectricTestRunner;
+
+/**
+ * Tests for {@link TextReadingFragmentBaseController}.
+ */
+@RunWith(RobolectricTestRunner.class)
+public class TextReadingFragmentBaseControllerTest {
+ private static final String FRAGMENT_PREF_KEY = "FRAGMENT_PREF_KEY";
+ private final Context mContext = ApplicationProvider.getApplicationContext();
+
+ @Test
+ public void handlePreferenceClick_getExtraWithA11ySettingsEntryPoint() {
+ final Preference a11ySettingsPreference = new Preference(mContext);
+ a11ySettingsPreference.setKey(FRAGMENT_PREF_KEY);
+ final TextReadingFragmentBaseController mA11ySettingsFragmentController =
+ new TextReadingFragmentBaseController(mContext, FRAGMENT_PREF_KEY,
+ ACCESSIBILITY_SETTINGS);
+
+ mA11ySettingsFragmentController.handlePreferenceTreeClick(a11ySettingsPreference);
+
+ assertThat(a11ySettingsPreference.getExtras().getInt(EXTRA_LAUNCHED_FROM,
+ UNKNOWN_ENTRY)).isEqualTo(ACCESSIBILITY_SETTINGS);
+ }
+}