Merge "Logging for the feature "Text and reading options" in Android T." into tm-dev
diff --git a/res/xml/accessibility_settings.xml b/res/xml/accessibility_settings.xml
index 509aed6..0287fc6 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"/>
 
         <Preference
             android:fragment="com.android.settings.accessibility.ColorAndMotionFragment"
diff --git a/res/xml/accessibility_settings_for_setup_wizard.xml b/res/xml/accessibility_settings_for_setup_wizard.xml
index a50e7dd..6929d54 100644
--- a/res/xml/accessibility_settings_for_setup_wizard.xml
+++ b/res/xml/accessibility_settings_for_setup_wizard.xml
@@ -26,7 +26,8 @@
         android:key="text_reading_options"
         android:persistent="false"
         android:title="@string/accessibility_text_reading_options_title"
-        settings:keywords="text_reading_options" />
+        settings:keywords="text_reading_options"
+        settings:controller="com.android.settings.accessibility.TextReadingFragmentForSuwController"/>
 
     <Preference
         android:fragment="com.android.settings.accessibility.ToggleScreenMagnificationPreferenceFragmentForSetupWizard"
diff --git a/res/xml/display_settings.xml b/res/xml/display_settings.xml
index 03d073b..2336c15 100644
--- a/res/xml/display_settings.xml
+++ b/res/xml/display_settings.xml
@@ -72,7 +72,8 @@
             android:fragment="com.android.settings.accessibility.TextReadingPreferenceFragment"
             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.TextReadingFragmentForDisplaySettingsController"/>
     </PreferenceCategory>
 
     <PreferenceCategory
diff --git a/src/com/android/settings/accessibility/AccessibilityStatsLogUtils.java b/src/com/android/settings/accessibility/AccessibilityStatsLogUtils.java
index 434157d..d8a887d 100644
--- a/src/com/android/settings/accessibility/AccessibilityStatsLogUtils.java
+++ b/src/com/android/settings/accessibility/AccessibilityStatsLogUtils.java
@@ -16,6 +16,16 @@
 
 package com.android.settings.accessibility;
 
+import static com.android.settings.accessibility.TextReadingPreferenceFragment.BOLD_TEXT_KEY;
+import static com.android.settings.accessibility.TextReadingPreferenceFragment.DISPLAY_SIZE_KEY;
+import static com.android.settings.accessibility.TextReadingPreferenceFragment.EntryPoint.ACCESSIBILITY_SETTINGS;
+import static com.android.settings.accessibility.TextReadingPreferenceFragment.EntryPoint.DISPLAY_SETTINGS;
+import static com.android.settings.accessibility.TextReadingPreferenceFragment.EntryPoint.SUW_ANYTHING_ELSE;
+import static com.android.settings.accessibility.TextReadingPreferenceFragment.EntryPoint.SUW_VISION_SETTINGS;
+import static com.android.settings.accessibility.TextReadingPreferenceFragment.FONT_SIZE_KEY;
+import static com.android.settings.accessibility.TextReadingPreferenceFragment.HIGH_TEXT_CONTRAST_KEY;
+import static com.android.settings.accessibility.TextReadingPreferenceFragment.RESET_KEY;
+
 import android.content.ComponentName;
 
 import com.android.settings.core.instrumentation.SettingsStatsLog;
@@ -58,4 +68,48 @@
                                 .ACCESSIBILITY_PRIVACY_WARNING_STATUS_SERVICE_DISABLED,
                         durationMills);
     }
+
+    /**
+     * Converts to the key name for logging.
+     *
+     * @param prefKey the preference key
+     * @return the int value which maps to the key name
+     */
+    static int convertToItemKeyName(String prefKey) {
+        switch (prefKey) {
+            case FONT_SIZE_KEY:
+                return SettingsStatsLog.ACCESSIBILITY_TEXT_READING_OPTIONS_CHANGED__NAME__TEXT_READING_FONT_SIZE;
+            case DISPLAY_SIZE_KEY:
+                return SettingsStatsLog.ACCESSIBILITY_TEXT_READING_OPTIONS_CHANGED__NAME__TEXT_READING_DISPLAY_SIZE;
+            case BOLD_TEXT_KEY:
+                return SettingsStatsLog.ACCESSIBILITY_TEXT_READING_OPTIONS_CHANGED__NAME__TEXT_READING_BOLD_TEXT;
+            case HIGH_TEXT_CONTRAST_KEY:
+                return SettingsStatsLog.ACCESSIBILITY_TEXT_READING_OPTIONS_CHANGED__NAME__TEXT_READING_HIGH_CONTRAST_TEXT;
+            case RESET_KEY:
+                return SettingsStatsLog.ACCESSIBILITY_TEXT_READING_OPTIONS_CHANGED__NAME__TEXT_READING_RESET;
+            default:
+                return SettingsStatsLog.ACCESSIBILITY_TEXT_READING_OPTIONS_CHANGED__NAME__TEXT_READING_UNKNOWN_ITEM;
+        }
+    }
+
+    /**
+     * Converts to the entry point for logging.
+     *
+     * @param entryPoint the entry point
+     * @return the int value which maps to the entry point
+     */
+    static int convertToEntryPoint(int entryPoint) {
+        switch (entryPoint) {
+            case SUW_VISION_SETTINGS:
+                return SettingsStatsLog.ACCESSIBILITY_TEXT_READING_OPTIONS_CHANGED__ENTRY_POINT__TEXT_READING_SUW_VISION_SETTINGS;
+            case SUW_ANYTHING_ELSE:
+                return SettingsStatsLog.ACCESSIBILITY_TEXT_READING_OPTIONS_CHANGED__ENTRY_POINT__TEXT_READING_SUW_ANYTHING_ELSE;
+            case DISPLAY_SETTINGS:
+                return SettingsStatsLog.ACCESSIBILITY_TEXT_READING_OPTIONS_CHANGED__ENTRY_POINT__TEXT_READING_DISPLAY_SETTINGS;
+            case ACCESSIBILITY_SETTINGS:
+                return SettingsStatsLog.ACCESSIBILITY_TEXT_READING_OPTIONS_CHANGED__ENTRY_POINT__TEXT_READING_ACCESSIBILITY_SETTINGS;
+            default:
+                return SettingsStatsLog.ACCESSIBILITY_TEXT_READING_OPTIONS_CHANGED__ENTRY_POINT__TEXT_READING_UNKNOWN_ENTRY;
+        }
+    }
 }
diff --git a/src/com/android/settings/accessibility/FontWeightAdjustmentPreferenceController.java b/src/com/android/settings/accessibility/FontWeightAdjustmentPreferenceController.java
index e3c1b9e..923e880 100644
--- a/src/com/android/settings/accessibility/FontWeightAdjustmentPreferenceController.java
+++ b/src/com/android/settings/accessibility/FontWeightAdjustmentPreferenceController.java
@@ -21,7 +21,9 @@
 import android.provider.Settings;
 
 import com.android.settings.R;
+import com.android.settings.accessibility.TextReadingPreferenceFragment.EntryPoint;
 import com.android.settings.core.TogglePreferenceController;
+import com.android.settings.core.instrumentation.SettingsStatsLog;
 
 /** PreferenceController for displaying all text in bold. */
 public class FontWeightAdjustmentPreferenceController extends TogglePreferenceController implements
@@ -29,6 +31,9 @@
     static final int BOLD_TEXT_ADJUSTMENT =
             FontStyle.FONT_WEIGHT_BOLD - FontStyle.FONT_WEIGHT_NORMAL;
 
+    @EntryPoint
+    private int mEntryPoint;
+
     public FontWeightAdjustmentPreferenceController(Context context, String preferenceKey) {
         super(context, preferenceKey);
     }
@@ -46,6 +51,12 @@
 
     @Override
     public boolean setChecked(boolean isChecked) {
+        SettingsStatsLog.write(
+                SettingsStatsLog.ACCESSIBILITY_TEXT_READING_OPTIONS_CHANGED,
+                AccessibilityStatsLogUtils.convertToItemKeyName(getPreferenceKey()),
+                isChecked ? 1 : 0,
+                AccessibilityStatsLogUtils.convertToEntryPoint(mEntryPoint));
+
         return Settings.Secure.putInt(mContext.getContentResolver(),
                 Settings.Secure.FONT_WEIGHT_ADJUSTMENT, (isChecked ? BOLD_TEXT_ADJUSTMENT : 0));
     }
@@ -59,4 +70,13 @@
     public void resetState() {
         setChecked(false);
     }
+
+    /**
+     * The entry point is used for logging.
+     *
+     * @param entryPoint from which settings page
+     */
+    void setEntryPoint(@EntryPoint int entryPoint) {
+        mEntryPoint = entryPoint;
+    }
 }
diff --git a/src/com/android/settings/accessibility/HighTextContrastPreferenceController.java b/src/com/android/settings/accessibility/HighTextContrastPreferenceController.java
index 8c9d234..9f645f1 100644
--- a/src/com/android/settings/accessibility/HighTextContrastPreferenceController.java
+++ b/src/com/android/settings/accessibility/HighTextContrastPreferenceController.java
@@ -23,7 +23,9 @@
 import androidx.preference.SwitchPreference;
 
 import com.android.settings.R;
+import com.android.settings.accessibility.TextReadingPreferenceFragment.EntryPoint;
 import com.android.settings.core.TogglePreferenceController;
+import com.android.settings.core.instrumentation.SettingsStatsLog;
 
 /**
  * PreferenceController for displaying all text in high contrast style.
@@ -32,6 +34,9 @@
         TextReadingResetController.ResetStateListener {
     private SwitchPreference mSwitchPreference;
 
+    @EntryPoint
+    private int mEntryPoint;
+
     public HighTextContrastPreferenceController(Context context, String preferenceKey) {
         super(context, preferenceKey);
     }
@@ -49,6 +54,12 @@
 
     @Override
     public boolean setChecked(boolean isChecked) {
+        SettingsStatsLog.write(
+                SettingsStatsLog.ACCESSIBILITY_TEXT_READING_OPTIONS_CHANGED,
+                AccessibilityStatsLogUtils.convertToItemKeyName(getPreferenceKey()),
+                isChecked ? 1 : 0,
+                AccessibilityStatsLogUtils.convertToEntryPoint(mEntryPoint));
+
         return Settings.Secure.putInt(mContext.getContentResolver(),
                 Settings.Secure.ACCESSIBILITY_HIGH_TEXT_CONTRAST_ENABLED, (isChecked ? 1 : 0));
     }
@@ -69,4 +80,13 @@
         setChecked(false);
         updateState(mSwitchPreference);
     }
+
+    /**
+     * The entry point is used for logging.
+     *
+     * @param entryPoint from which settings page
+     */
+    void setEntryPoint(@EntryPoint int entryPoint) {
+        mEntryPoint = entryPoint;
+    }
 }
diff --git a/src/com/android/settings/accessibility/PreviewSizeSeekBarController.java b/src/com/android/settings/accessibility/PreviewSizeSeekBarController.java
index c7dfd61..711eb0f 100644
--- a/src/com/android/settings/accessibility/PreviewSizeSeekBarController.java
+++ b/src/com/android/settings/accessibility/PreviewSizeSeekBarController.java
@@ -22,7 +22,9 @@
 import androidx.annotation.NonNull;
 import androidx.preference.PreferenceScreen;
 
+import com.android.settings.accessibility.TextReadingPreferenceFragment.EntryPoint;
 import com.android.settings.core.BasePreferenceController;
+import com.android.settings.core.instrumentation.SettingsStatsLog;
 import com.android.settings.widget.LabeledSeekBarPreference;
 
 /**
@@ -36,6 +38,9 @@
     private ProgressInteractionListener mInteractionListener;
     private LabeledSeekBarPreference mSeekBarPreference;
 
+    @EntryPoint
+    private int mEntryPoint;
+
     private final SeekBar.OnSeekBarChangeListener mSeekBarChangeListener =
             new SeekBar.OnSeekBarChangeListener() {
                 @Override
@@ -45,6 +50,12 @@
                     if (!mSeekByTouch && mInteractionListener != null) {
                         mInteractionListener.onProgressChanged();
                     }
+
+                    SettingsStatsLog.write(
+                            SettingsStatsLog.ACCESSIBILITY_TEXT_READING_OPTIONS_CHANGED,
+                            AccessibilityStatsLogUtils.convertToItemKeyName(getPreferenceKey()),
+                            progress,
+                            AccessibilityStatsLogUtils.convertToEntryPoint(mEntryPoint));
                 }
 
                 @Override
@@ -97,6 +108,15 @@
     }
 
     /**
+     * The entry point is used for logging.
+     *
+     * @param entryPoint from which settings page
+     */
+    void setEntryPoint(@EntryPoint int entryPoint) {
+        mEntryPoint = entryPoint;
+    }
+
+    /**
      * Interface for callbacks when users interact with the seek bar.
      */
     interface ProgressInteractionListener {
diff --git a/src/com/android/settings/accessibility/TextReadingFragmentBaseController.java b/src/com/android/settings/accessibility/TextReadingFragmentBaseController.java
new file mode 100644
index 0000000..f26ca96
--- /dev/null
+++ b/src/com/android/settings/accessibility/TextReadingFragmentBaseController.java
@@ -0,0 +1,60 @@
+/*
+ * 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 android.content.Context;
+import android.os.Bundle;
+
+import androidx.preference.Preference;
+
+import com.android.settings.accessibility.TextReadingPreferenceFragment.EntryPoint;
+import com.android.settings.core.BasePreferenceController;
+
+/**
+ * The base controller for the fragment{@link TextReadingPreferenceFragment}.
+ */
+public class TextReadingFragmentBaseController extends BasePreferenceController {
+    @EntryPoint
+    private int mEntryPoint;
+
+    private TextReadingFragmentBaseController(Context context, String preferenceKey) {
+        super(context, preferenceKey);
+    }
+
+    TextReadingFragmentBaseController(Context context, String preferenceKey,
+            @EntryPoint int entryPoint) {
+        this(context, preferenceKey);
+        mEntryPoint = entryPoint;
+    }
+
+    @Override
+    public int getAvailabilityStatus() {
+        return AVAILABLE;
+    }
+
+    @Override
+    public boolean handlePreferenceTreeClick(Preference preference) {
+        if (getPreferenceKey().equals(preference.getKey())) {
+            final Bundle extras = preference.getExtras();
+            extras.putInt(EXTRA_LAUNCHED_FROM, mEntryPoint);
+        }
+
+        return super.handlePreferenceTreeClick(preference);
+    }
+}
diff --git a/src/com/android/settings/accessibility/TextReadingFragmentForA11ySettingsController.java b/src/com/android/settings/accessibility/TextReadingFragmentForA11ySettingsController.java
new file mode 100644
index 0000000..434877c
--- /dev/null
+++ b/src/com/android/settings/accessibility/TextReadingFragmentForA11ySettingsController.java
@@ -0,0 +1,32 @@
+/*
+ * 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.EntryPoint.ACCESSIBILITY_SETTINGS;
+
+import android.content.Context;
+
+/**
+ * The controller for the {@link TextReadingPreferenceFragment} from the accessibility settings.
+ */
+public class TextReadingFragmentForA11ySettingsController extends
+        TextReadingFragmentBaseController {
+    public TextReadingFragmentForA11ySettingsController(Context context, String preferenceKey) {
+        // Pass the fixed entry point to the parent controller for logging.
+        super(context, preferenceKey, ACCESSIBILITY_SETTINGS);
+    }
+}
diff --git a/src/com/android/settings/accessibility/TextReadingFragmentForDisplaySettingsController.java b/src/com/android/settings/accessibility/TextReadingFragmentForDisplaySettingsController.java
new file mode 100644
index 0000000..4d603f9
--- /dev/null
+++ b/src/com/android/settings/accessibility/TextReadingFragmentForDisplaySettingsController.java
@@ -0,0 +1,32 @@
+/*
+ * 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.EntryPoint.DISPLAY_SETTINGS;
+
+import android.content.Context;
+
+/**
+ * The controller for the {@link TextReadingPreferenceFragment} from the display settings.
+ */
+public class TextReadingFragmentForDisplaySettingsController extends
+        TextReadingFragmentBaseController {
+    public TextReadingFragmentForDisplaySettingsController(Context context, String preferenceKey) {
+        // Pass the fixed entry point to the parent controller for logging.
+        super(context, preferenceKey, DISPLAY_SETTINGS);
+    }
+}
diff --git a/src/com/android/settings/accessibility/TextReadingFragmentForSuwController.java b/src/com/android/settings/accessibility/TextReadingFragmentForSuwController.java
new file mode 100644
index 0000000..332d9c5
--- /dev/null
+++ b/src/com/android/settings/accessibility/TextReadingFragmentForSuwController.java
@@ -0,0 +1,31 @@
+/*
+ * 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.EntryPoint.SUW_VISION_SETTINGS;
+
+import android.content.Context;
+
+/**
+ * The controller for the {@link TextReadingPreferenceFragment} during the SetupWizard.
+ */
+public class TextReadingFragmentForSuwController extends TextReadingFragmentBaseController {
+    public TextReadingFragmentForSuwController(Context context, String preferenceKey) {
+        // Pass the fixed entry point to the parent controller for logging.
+        super(context, preferenceKey, SUW_VISION_SETTINGS);
+    }
+}
diff --git a/src/com/android/settings/accessibility/TextReadingPreferenceFragment.java b/src/com/android/settings/accessibility/TextReadingPreferenceFragment.java
index a4ee961c..104be26 100644
--- a/src/com/android/settings/accessibility/TextReadingPreferenceFragment.java
+++ b/src/com/android/settings/accessibility/TextReadingPreferenceFragment.java
@@ -22,9 +22,11 @@
 import android.app.settings.SettingsEnums;
 import android.content.Context;
 import android.content.DialogInterface;
+import android.content.Intent;
 import android.os.Bundle;
 import android.widget.Toast;
 
+import androidx.annotation.IntDef;
 import androidx.appcompat.app.AlertDialog;
 
 import com.android.settings.R;
@@ -36,8 +38,11 @@
 
 import com.google.common.annotations.VisibleForTesting;
 
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
 import java.util.ArrayList;
 import java.util.List;
+import java.util.Set;
 import java.util.stream.Collectors;
 
 /**
@@ -46,15 +51,40 @@
  */
 @SearchIndexable(forTarget = SearchIndexable.ALL & ~SearchIndexable.ARC)
 public class TextReadingPreferenceFragment extends DashboardFragment {
+    public static final String EXTRA_LAUNCHED_FROM = "launched_from";
     private static final String TAG = "TextReadingPreferenceFragment";
-    private static final String FONT_SIZE_KEY = "font_size";
-    private static final String DISPLAY_SIZE_KEY = "display_size";
+    private static final String CATEGORY_FOR_ANYTHING_ELSE =
+            "com.android.settings.suggested.category.DISPLAY_SETTINGS";
+    static final String FONT_SIZE_KEY = "font_size";
+    static final String DISPLAY_SIZE_KEY = "display_size";
+    static final String BOLD_TEXT_KEY = "toggle_force_bold_text";
+    static final String HIGH_TEXT_CONTRAST_KEY = "toggle_high_text_contrast_preference";
+    static final String RESET_KEY = "reset";
     private static final String PREVIEW_KEY = "preview";
-    private static final String RESET_KEY = "reset";
-    private static final String BOLD_TEXT_KEY = "toggle_force_bold_text";
-    private static final String HIGHT_TEXT_CONTRAST_KEY = "toggle_high_text_contrast_preference";
     private static final String NEED_RESET_SETTINGS = "need_reset_settings";
     private FontWeightAdjustmentPreferenceController mFontWeightAdjustmentController;
+    private int mEntryPoint = EntryPoint.UNKNOWN_ENTRY;
+
+    /**
+     * The entry point which launches the {@link TextReadingPreferenceFragment}.
+     *
+     * <p>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<ResetStateListener> mResetStateListeners;
@@ -91,6 +121,8 @@
 
     @Override
     protected List<AbstractPreferenceController> createPreferenceControllers(Context context) {
+        updateEntryPoint();
+
         final List<AbstractPreferenceController> controllers = new ArrayList<>();
         final FontSizeData fontSizeData = new FontSizeData(context);
         final DisplaySizeData displaySizeData = createDisplaySizeData(context);
@@ -102,24 +134,29 @@
         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 @@
         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<String> 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 152ad5f..30a94c2 100644
--- a/src/com/android/settings/accessibility/TextReadingResetController.java
+++ b/src/com/android/settings/accessibility/TextReadingResetController.java
@@ -23,7 +23,9 @@
 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 @@
 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,11 +57,26 @@
         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.
      */
     interface ResetStateListener {
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 0000000..ad6a895
--- /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);
+    }
+}