Merge "Revert "Back up the smooth display setting"" into udc-dev
diff --git a/res/values/strings.xml b/res/values/strings.xml
index 72f7176..4f67a35 100644
--- a/res/values/strings.xml
+++ b/res/values/strings.xml
@@ -9139,13 +9139,13 @@
     <string name="filter_manage_external_storage">Can access all files</string>
 
     <!-- Manage full screen intent permission title [CHAR LIMIT=40] -->
-    <string name="full_screen_intent_title">Show full screen notifications</string>
+    <string name="full_screen_intent_title">Full screen notifications</string>
 
     <!-- Label for setting that allows apps to send full screen intents. [CHAR LIMIT=NONE] -->
-    <string name="permit_full_screen_intent">Allow app to show full screen notifications when the device is locked</string>
+    <string name="permit_full_screen_intent">Allow full screen notifications from this app</string>
 
     <!-- Description for setting that allows apps to send full screen intents. [CHAR LIMIT=NONE] -->
-    <string name="footer_description_full_screen_intent">Allow the app to show notifications that take up the full screen when the device is locked. Apps may use these to highlight alarms, incoming calls, or other urgent notifications.</string>
+    <string name="footer_description_full_screen_intent">Allow this app to show notifications that take up the full screen when the device is locked. Apps may use these to highlight alarms, incoming calls, or other urgent notifications.</string>
 
     <!-- Media management apps settings title [CHAR LIMIT=40] -->
     <string name="media_management_apps_title">Media management apps</string>
diff --git a/src/com/android/settings/applications/credentials/CredentialManagerPreferenceController.java b/src/com/android/settings/applications/credentials/CredentialManagerPreferenceController.java
index c627df3..f19fb91 100644
--- a/src/com/android/settings/applications/credentials/CredentialManagerPreferenceController.java
+++ b/src/com/android/settings/applications/credentials/CredentialManagerPreferenceController.java
@@ -23,6 +23,7 @@
 import android.app.Activity;
 import android.app.Dialog;
 import android.content.ComponentName;
+import android.content.ContentResolver;
 import android.content.Context;
 import android.content.DialogInterface;
 import android.content.Intent;
@@ -33,9 +34,11 @@
 import android.credentials.CredentialManager;
 import android.credentials.CredentialProviderInfo;
 import android.credentials.SetEnabledProvidersException;
+import android.database.ContentObserver;
 import android.graphics.drawable.Drawable;
 import android.net.Uri;
 import android.os.Bundle;
+import android.os.Handler;
 import android.os.OutcomeReceiver;
 import android.os.UserHandle;
 import android.provider.DeviceConfig;
@@ -59,10 +62,12 @@
 import androidx.preference.SwitchPreference;
 
 import com.android.internal.annotations.VisibleForTesting;
+import com.android.internal.content.PackageMonitor;
 import com.android.settings.R;
 import com.android.settings.Utils;
 import com.android.settings.core.BasePreferenceController;
 import com.android.settings.dashboard.DashboardFragment;
+import com.android.settingslib.utils.ThreadUtils;
 
 import java.util.ArrayList;
 import java.util.HashMap;
@@ -89,10 +94,12 @@
     private final Executor mExecutor;
     private final Map<String, SwitchPreference> mPrefs = new HashMap<>(); // key is package name
     private final List<ServiceInfo> mPendingServiceInfos = new ArrayList<>();
+    private final Handler mHandler = new Handler();
 
     private @Nullable FragmentManager mFragmentManager = null;
     private @Nullable Delegate mDelegate = null;
     private @Nullable String mFlagOverrideForTest = null;
+    private @Nullable PreferenceScreen mPreferenceScreen = null;
 
     public CredentialManagerPreferenceController(Context context, String preferenceKey) {
         super(context, preferenceKey);
@@ -103,6 +110,7 @@
         mExecutor = ContextCompat.getMainExecutor(mContext);
         mCredentialManager =
                 getCredentialManager(context, preferenceKey.equals("credentials_test"));
+        new SettingContentObserver(mHandler).register(context.getContentResolver());
     }
 
     private @Nullable CredentialManager getCredentialManager(Context context, boolean isTest) {
@@ -241,6 +249,25 @@
         update();
     }
 
+    private void update() {
+        if (mCredentialManager == null) {
+            return;
+        }
+
+        setAvailableServices(
+                mCredentialManager.getCredentialProviderServices(
+                        getUser(), CredentialManager.PROVIDER_FILTER_USER_PROVIDERS_ONLY),
+                null);
+    }
+
+    private void updateFromExternal() {
+        update();
+
+        if (mPreferenceScreen != null) {
+            displayPreference(mPreferenceScreen);
+        }
+    }
+
     @VisibleForTesting
     void setAvailableServices(
             List<CredentialProviderInfo> availableServices,
@@ -276,6 +303,7 @@
         // Since the UI is being cleared, clear any refs.
         mPrefs.clear();
 
+        mPreferenceScreen = screen;
         PreferenceGroup group = screen.findPreference(getPreferenceKey());
         Context context = screen.getContext();
         mPrefs.putAll(buildPreferenceList(context, group));
@@ -348,6 +376,10 @@
         Map<String, List<CredentialProviderInfo>> groupedInfos = new HashMap<>();
         for (CredentialProviderInfo cpi : mServices) {
             String packageName = cpi.getServiceInfo().packageName;
+            if (isProviderHiddenBecauseOfAutofill(packageName)) {
+                continue;
+            }
+
             if (!groupedInfos.containsKey(packageName)) {
                 groupedInfos.put(packageName, new ArrayList<>());
             }
@@ -551,6 +583,23 @@
         return new NewProviderConfirmationDialogFragment(host, packageName, appName);
     }
 
+    /** If the provider is also the autofill provider then hide it. */
+    @VisibleForTesting
+    public boolean isProviderHiddenBecauseOfAutofill(String packageName) {
+        final String autofillService = Settings.Secure.getStringForUser(
+                mContext.getContentResolver(),
+                Settings.Secure.AUTOFILL_SERVICE,
+                getUser());
+        if (autofillService == null || TextUtils.isEmpty(autofillService)) {
+            return false;
+        }
+        if (packageName == null || TextUtils.isEmpty(packageName)) {
+            return false;
+        }
+
+        return autofillService.startsWith(packageName);
+    }
+
     @VisibleForTesting
     void completeEnableProviderDialogBox(
             int whichButton, String packageName, boolean setActivityResult) {
@@ -655,20 +704,6 @@
         }
     };
 
-    /**
-     * Update the data in this UI.
-     */
-    private void update() {
-        if (mCredentialManager == null) {
-            return;
-        }
-
-        setAvailableServices(
-                mCredentialManager.getCredentialProviderServices(
-                        getUser(), CredentialManager.PROVIDER_FILTER_USER_PROVIDERS_ONLY),
-                null);
-    }
-
     /** Dialog fragment parent class. */
     private abstract static class CredentialManagerDialogFragment extends DialogFragment
             implements DialogInterface.OnClickListener {
@@ -790,4 +825,28 @@
             getDialogHost().onDialogClick(which);
         }
     }
+
+    /** Updates the list if setting content changes. */
+    private final class SettingContentObserver extends ContentObserver {
+
+        private final Uri mAutofillService =
+                Settings.Secure.getUriFor(Settings.Secure.AUTOFILL_SERVICE);
+
+        private final Uri mCredentialService =
+                Settings.Secure.getUriFor(Settings.Secure.CREDENTIAL_SERVICE);
+
+        public SettingContentObserver(Handler handler) {
+            super(handler);
+        }
+
+        public void register(ContentResolver contentResolver) {
+            contentResolver.registerContentObserver(mAutofillService, false, this, getUser());
+            contentResolver.registerContentObserver(mCredentialService, false, this, getUser());
+        }
+
+        @Override
+        public void onChange(boolean selfChange, Uri uri) {
+            updateFromExternal();
+        }
+    }
 }
diff --git a/src/com/android/settings/localepicker/LocaleDialogFragment.java b/src/com/android/settings/localepicker/LocaleDialogFragment.java
index 2ee2e8b..9e274d6 100644
--- a/src/com/android/settings/localepicker/LocaleDialogFragment.java
+++ b/src/com/android/settings/localepicker/LocaleDialogFragment.java
@@ -37,6 +37,8 @@
 import com.android.settings.R;
 import com.android.settings.RestrictedSettingsFragment;
 import com.android.settings.core.instrumentation.InstrumentedDialogFragment;
+import com.android.settings.overlay.FeatureFactory;
+import com.android.settingslib.core.instrumentation.MetricsFeatureProvider;
 
 /**
  * Create a dialog for system locale events.
@@ -143,6 +145,7 @@
         private final int mDialogType;
         private final LocaleStore.LocaleInfo mLocaleInfo;
         private final ResultReceiver mResultReceiver;
+        private final MetricsFeatureProvider mMetricsFeatureProvider;
 
         LocaleDialogController(
                 @NonNull Context context, @NonNull LocaleDialogFragment dialogFragment) {
@@ -152,6 +155,8 @@
             mLocaleInfo = (LocaleStore.LocaleInfo) arguments.getSerializable(
                     ARG_TARGET_LOCALE);
             mResultReceiver = (ResultReceiver) arguments.getParcelable(ARG_RESULT_RECEIVER);
+            mMetricsFeatureProvider = FeatureFactory.getFactory(
+                    mContext).getMetricsFeatureProvider();
         }
 
         LocaleDialogController(@NonNull LocaleDialogFragment dialogFragment) {
@@ -163,11 +168,15 @@
             if (mResultReceiver != null && mDialogType == DIALOG_CONFIRM_SYSTEM_DEFAULT) {
                 Bundle bundle = new Bundle();
                 bundle.putInt(ARG_DIALOG_TYPE, DIALOG_CONFIRM_SYSTEM_DEFAULT);
+                boolean changed = false;
                 if (which == DialogInterface.BUTTON_POSITIVE) {
+                    changed = true;
                     mResultReceiver.send(Activity.RESULT_OK, bundle);
                 } else if (which == DialogInterface.BUTTON_NEGATIVE) {
                     mResultReceiver.send(Activity.RESULT_CANCELED, bundle);
                 }
+                mMetricsFeatureProvider.action(mContext,
+                        SettingsEnums.ACTION_CHANGE_LANGUAGE, changed);
             }
         }
 
diff --git a/src/com/android/settings/localepicker/LocaleHelperPreferenceController.java b/src/com/android/settings/localepicker/LocaleHelperPreferenceController.java
index a639c9d..1227683 100644
--- a/src/com/android/settings/localepicker/LocaleHelperPreferenceController.java
+++ b/src/com/android/settings/localepicker/LocaleHelperPreferenceController.java
@@ -16,6 +16,7 @@
 
 package com.android.settings.localepicker;
 
+import android.app.settings.SettingsEnums;
 import android.content.Context;
 import android.content.Intent;
 import android.util.Log;
@@ -24,8 +25,10 @@
 import androidx.preference.PreferenceScreen;
 
 import com.android.settings.R;
+import com.android.settings.overlay.FeatureFactory;
 import com.android.settingslib.HelpUtils;
 import com.android.settingslib.core.AbstractPreferenceController;
+import com.android.settingslib.core.instrumentation.MetricsFeatureProvider;
 import com.android.settingslib.widget.FooterPreference;
 
 /**
@@ -36,8 +39,11 @@
 
     private static final String KEY_FOOTER_LANGUAGE_PICKER = "footer_languages_picker";
 
+    private final MetricsFeatureProvider mMetricsFeatureProvider;
+
     public LocaleHelperPreferenceController(Context context) {
         super(context);
+        mMetricsFeatureProvider = FeatureFactory.getFactory(context).getMetricsFeatureProvider();
     }
 
     @Override
@@ -72,6 +78,7 @@
                 mContext.getString(R.string.link_locale_picker_footer_learn_more),
                 mContext.getClass().getName());
         if (intent != null) {
+            mMetricsFeatureProvider.action(mContext, SettingsEnums.ACTION_LANGUAGES_LEARN_MORE);
             mContext.startActivity(intent);
         } else {
             Log.w(TAG, "HelpIntent is null");
diff --git a/src/com/android/settings/wifi/tether/WifiTetherSettings.java b/src/com/android/settings/wifi/tether/WifiTetherSettings.java
index 2774be6..4ce59b9 100644
--- a/src/com/android/settings/wifi/tether/WifiTetherSettings.java
+++ b/src/com/android/settings/wifi/tether/WifiTetherSettings.java
@@ -80,11 +80,14 @@
     @VisibleForTesting
     SettingsMainSwitchBar mMainSwitchBar;
     private WifiTetherSwitchBarController mSwitchBarController;
-    private WifiTetherSSIDPreferenceController mSSIDPreferenceController;
-    private WifiTetherPasswordPreferenceController mPasswordPreferenceController;
+    @VisibleForTesting
+    WifiTetherSSIDPreferenceController mSSIDPreferenceController;
+    @VisibleForTesting
+    WifiTetherPasswordPreferenceController mPasswordPreferenceController;
     private WifiTetherSecurityPreferenceController mSecurityPreferenceController;
     private WifiTetherMaximizeCompatibilityPreferenceController mMaxCompatibilityPrefController;
-    private WifiTetherAutoOffPreferenceController mWifiTetherAutoOffPreferenceController;
+    @VisibleForTesting
+    WifiTetherAutoOffPreferenceController mWifiTetherAutoOffPreferenceController;
 
     private boolean mUnavailable;
     private WifiRestriction mWifiRestriction;
@@ -269,10 +272,12 @@
         setLoading(restarting, false);
     }
 
-    private SoftApConfiguration buildNewConfig() {
-        SoftApConfiguration.Builder configBuilder = new SoftApConfiguration.Builder();
+    @VisibleForTesting
+    SoftApConfiguration buildNewConfig() {
+        SoftApConfiguration currentConfig = mWifiTetherViewModel.getSoftApConfiguration();
+        SoftApConfiguration.Builder configBuilder = new SoftApConfiguration.Builder(currentConfig);
         int securityType = (mWifiTetherViewModel.isSpeedFeatureAvailable())
-                ? mWifiTetherViewModel.getSoftApConfiguration().getSecurityType()
+                ? currentConfig.getSecurityType()
                 : mSecurityPreferenceController.getSecurityType();
         configBuilder.setSsid(mSSIDPreferenceController.getSSID());
         if (securityType != SoftApConfiguration.SECURITY_TYPE_OPEN) {
diff --git a/tests/robotests/src/com/android/settings/development/qstile/WinscopeTraceTest.java b/tests/robotests/src/com/android/settings/development/qstile/WinscopeTraceTest.java
index 37bf54c..ad495c7 100644
--- a/tests/robotests/src/com/android/settings/development/qstile/WinscopeTraceTest.java
+++ b/tests/robotests/src/com/android/settings/development/qstile/WinscopeTraceTest.java
@@ -16,10 +16,8 @@
 
 package com.android.settings.development.qstile;
 
-import static com.android.settings.development.qstile.DevelopmentTiles.WinscopeTrace
-        .SURFACE_FLINGER_LAYER_TRACE_CONTROL_CODE;
-import static com.android.settings.development.qstile.DevelopmentTiles.WinscopeTrace
-        .SURFACE_FLINGER_LAYER_TRACE_STATUS_CODE;
+import static com.android.settings.development.qstile.DevelopmentTiles.WinscopeTrace.SURFACE_FLINGER_LAYER_TRACE_CONTROL_CODE;
+import static com.android.settings.development.qstile.DevelopmentTiles.WinscopeTrace.SURFACE_FLINGER_LAYER_TRACE_STATUS_CODE;
 
 import static com.google.common.truth.Truth.assertThat;
 
@@ -37,6 +35,8 @@
 import android.view.IWindowManager;
 import android.widget.Toast;
 
+import androidx.test.core.app.ApplicationProvider;
+
 import com.android.internal.inputmethod.ImeTracing;
 import com.android.settings.testutils.shadow.ShadowParcel;
 
@@ -68,6 +68,9 @@
     public void setUp() {
         MockitoAnnotations.initMocks(this);
         mWinscopeTrace = spy(new DevelopmentTiles.WinscopeTrace());
+        doReturn(ApplicationProvider.getApplicationContext()).when(
+                mWinscopeTrace).getApplicationContext();
+
         ReflectionHelpers.setField(mWinscopeTrace, "mWindowManager", mWindowManager);
         ReflectionHelpers.setField(mWinscopeTrace, "mImeTracing", mImeTracing);
         ReflectionHelpers.setField(mWinscopeTrace, "mSurfaceFlinger", mSurfaceFlinger);
@@ -118,7 +121,7 @@
         assertThat(mWinscopeTrace.isEnabled()).isFalse();
         verify(mSurfaceFlinger)
                 .transact(eq(SURFACE_FLINGER_LAYER_TRACE_STATUS_CODE), any(), any(),
-                eq(0 /* flags */));
+                        eq(0 /* flags */));
         verifyNoMoreInteractions(mSurfaceFlinger);
     }
 
@@ -131,7 +134,7 @@
         assertThat(mWinscopeTrace.isEnabled()).isTrue();
         verify(mSurfaceFlinger)
                 .transact(eq(SURFACE_FLINGER_LAYER_TRACE_STATUS_CODE), any(), any(),
-                eq(0 /* flags */));
+                        eq(0 /* flags */));
         verifyNoMoreInteractions(mSurfaceFlinger);
     }
 
diff --git a/tests/robotests/src/com/android/settings/wifi/tether/WifiTetherSettingsTest.java b/tests/robotests/src/com/android/settings/wifi/tether/WifiTetherSettingsTest.java
index 0a54c88..fe663ab 100644
--- a/tests/robotests/src/com/android/settings/wifi/tether/WifiTetherSettingsTest.java
+++ b/tests/robotests/src/com/android/settings/wifi/tether/WifiTetherSettingsTest.java
@@ -16,10 +16,12 @@
 
 package com.android.settings.wifi.tether;
 
+import static android.net.wifi.SoftApConfiguration.SECURITY_TYPE_WPA3_SAE;
 import static android.view.View.INVISIBLE;
 import static android.view.View.VISIBLE;
 
 import static com.android.settings.wifi.WifiUtils.setCanShowWifiHotspotCached;
+import static com.android.settings.wifi.repository.WifiHotspotRepository.BAND_2GHZ_5GHZ_6GHZ;
 import static com.android.settings.wifi.tether.WifiTetherSettings.KEY_WIFI_HOTSPOT_SECURITY;
 import static com.android.settings.wifi.tether.WifiTetherSettings.KEY_WIFI_HOTSPOT_SPEED;
 
@@ -41,6 +43,7 @@
 import android.content.res.Resources;
 import android.net.ConnectivityManager;
 import android.net.TetheringManager;
+import android.net.wifi.SoftApConfiguration;
 import android.net.wifi.WifiManager;
 import android.os.Bundle;
 import android.os.UserManager;
@@ -84,6 +87,8 @@
 
     private static final int XML_RES = R.xml.wifi_tether_settings;
     private static final String[] WIFI_REGEXS = {"wifi_regexs"};
+    private static final String SSID = "ssid";
+    private static final String PASSWORD = "password";
 
     @Rule
     public final MockitoRule mMockitoRule = MockitoJUnit.rule();
@@ -117,6 +122,12 @@
     private LiveData<Integer> mSpeedSummary;
     @Mock
     private SettingsMainSwitchBar mMainSwitchBar;
+    @Mock
+    private WifiTetherSSIDPreferenceController mSSIDPreferenceController;
+    @Mock
+    private WifiTetherPasswordPreferenceController mPasswordPreferenceController;
+    @Mock
+    private WifiTetherAutoOffPreferenceController mWifiTetherAutoOffPreferenceController;
 
     private WifiTetherSettings mSettings;
 
@@ -143,6 +154,12 @@
 
         mSettings = spy(new WifiTetherSettings(mWifiRestriction));
         mSettings.mMainSwitchBar = mMainSwitchBar;
+        mSettings.mSSIDPreferenceController = mSSIDPreferenceController;
+        when(mSSIDPreferenceController.getSSID()).thenReturn(SSID);
+        mSettings.mPasswordPreferenceController = mPasswordPreferenceController;
+        when(mPasswordPreferenceController.getPasswordValidated(anyInt())).thenReturn(PASSWORD);
+        mSettings.mWifiTetherAutoOffPreferenceController = mWifiTetherAutoOffPreferenceController;
+        when(mWifiTetherAutoOffPreferenceController.isEnabled()).thenReturn(true);
         mSettings.mWifiTetherViewModel = mWifiTetherViewModel;
         when(mSettings.findPreference(KEY_WIFI_HOTSPOT_SECURITY)).thenReturn(mWifiHotspotSecurity);
         when(mSettings.findPreference(KEY_WIFI_HOTSPOT_SPEED)).thenReturn(mWifiHotspotSpeed);
@@ -327,6 +344,22 @@
     }
 
     @Test
+    public void buildNewConfig_speedFeatureIsAvailableAndPasswordChanged_bandShouldNotBeLost() {
+        String newPassword = "new" + PASSWORD;
+        SoftApConfiguration currentConfig = new SoftApConfiguration.Builder()
+                .setPassphrase(PASSWORD, SECURITY_TYPE_WPA3_SAE)
+                .setBand(BAND_2GHZ_5GHZ_6GHZ)
+                .build();
+        when(mWifiTetherViewModel.getSoftApConfiguration()).thenReturn(currentConfig);
+        when(mWifiTetherViewModel.isSpeedFeatureAvailable()).thenReturn(true);
+        when(mPasswordPreferenceController.getPasswordValidated(anyInt())).thenReturn(newPassword);
+
+        SoftApConfiguration newConfig = mSettings.buildNewConfig();
+
+        assertThat(newConfig.getBand()).isEqualTo(currentConfig.getBand());
+    }
+
+    @Test
     public void onRestartingChanged_restartingFalse_setLoadingFalse() {
         doNothing().when(mSettings).setLoading(anyBoolean(), anyBoolean());
 
diff --git a/tests/unit/src/com/android/settings/applications/credentials/CredentialManagerPreferenceControllerTest.java b/tests/unit/src/com/android/settings/applications/credentials/CredentialManagerPreferenceControllerTest.java
index 2a2aaee..3145cce 100644
--- a/tests/unit/src/com/android/settings/applications/credentials/CredentialManagerPreferenceControllerTest.java
+++ b/tests/unit/src/com/android/settings/applications/credentials/CredentialManagerPreferenceControllerTest.java
@@ -123,6 +123,25 @@
     }
 
     @Test
+    public void verifyHiddenIfAutofillSelectedProvider() {
+        CredentialManagerPreferenceController controller =
+                createControllerWithServices(Collections.emptyList());
+
+        // Set the autofill provider.
+        Settings.Secure.putStringForUser(mContext.getContentResolver(),
+                Settings.Secure.AUTOFILL_SERVICE, "com.example.test/AutofillClass",
+                UserHandle.myUserId());
+
+        // Verify the error cases
+        assertThat(controller.isProviderHiddenBecauseOfAutofill(null)).isFalse();
+        assertThat(controller.isProviderHiddenBecauseOfAutofill("")).isFalse();
+        assertThat(controller.isProviderHiddenBecauseOfAutofill("test")).isFalse();
+
+        // Verify the example.
+        assertThat(controller.isProviderHiddenBecauseOfAutofill("com.example.test")).isTrue();
+    }
+
+    @Test
     public void displayPreference_noServices_noPreferencesAdded_useAutofillUri() {
         Settings.Secure.putStringForUser(
                 mContext.getContentResolver(),
diff --git a/tests/unit/src/com/android/settings/localepicker/LocaleDialogFragmentTest.java b/tests/unit/src/com/android/settings/localepicker/LocaleDialogFragmentTest.java
index 5b10adf..b0998c0 100644
--- a/tests/unit/src/com/android/settings/localepicker/LocaleDialogFragmentTest.java
+++ b/tests/unit/src/com/android/settings/localepicker/LocaleDialogFragmentTest.java
@@ -38,6 +38,7 @@
 import androidx.test.core.app.ApplicationProvider;
 
 import com.android.internal.app.LocaleStore;
+import com.android.settings.testutils.FakeFeatureFactory;
 import com.android.settings.testutils.ResourcesUtils;
 
 import org.junit.Before;
@@ -55,11 +56,13 @@
 
     private Context mContext;
     private LocaleDialogFragment mDialogFragment;
+    private FakeFeatureFactory mFeatureFactory;
 
     @Before
     public void setUp() throws Exception {
         mContext = ApplicationProvider.getApplicationContext();
         mDialogFragment = new LocaleDialogFragment();
+        mFeatureFactory = FakeFeatureFactory.setupForTest();
     }
 
     private void setArgument(
@@ -112,6 +115,8 @@
         controller.onClick(null, DialogInterface.BUTTON_POSITIVE);
 
         verify(resultReceiver).send(eq(Activity.RESULT_OK), any());
+        verify(mFeatureFactory.metricsFeatureProvider).action(
+                mContext, SettingsEnums.ACTION_CHANGE_LANGUAGE, true);
     }
 
     @Test
@@ -124,6 +129,8 @@
         controller.onClick(null, DialogInterface.BUTTON_NEGATIVE);
 
         verify(resultReceiver).send(eq(Activity.RESULT_CANCELED), any());
+        verify(mFeatureFactory.metricsFeatureProvider).action(
+                mContext, SettingsEnums.ACTION_CHANGE_LANGUAGE, false);
     }
 
     @Test
diff --git a/tests/unit/src/com/android/settings/localepicker/LocaleHelperPreferenceControllerTest.java b/tests/unit/src/com/android/settings/localepicker/LocaleHelperPreferenceControllerTest.java
index 31b8e79..5ac367e 100644
--- a/tests/unit/src/com/android/settings/localepicker/LocaleHelperPreferenceControllerTest.java
+++ b/tests/unit/src/com/android/settings/localepicker/LocaleHelperPreferenceControllerTest.java
@@ -19,12 +19,14 @@
 import static org.mockito.Mockito.anyString;
 import static org.mockito.Mockito.verify;
 
+import android.app.settings.SettingsEnums;
 import android.content.Context;
 import android.os.Looper;
 
 import androidx.test.core.app.ApplicationProvider;
 import androidx.test.ext.junit.runners.AndroidJUnit4;
 
+import com.android.settings.testutils.FakeFeatureFactory;
 import com.android.settingslib.widget.FooterPreference;
 
 import org.junit.Before;
@@ -37,6 +39,7 @@
 public class LocaleHelperPreferenceControllerTest {
     private Context mContext;
     private LocaleHelperPreferenceController mLocaleHelperPreferenceController;
+    private FakeFeatureFactory mFeatureFactory;
 
     @Mock
     private FooterPreference mMockFooterPreference;
@@ -49,11 +52,16 @@
         }
         mContext = ApplicationProvider.getApplicationContext();
         mLocaleHelperPreferenceController = new LocaleHelperPreferenceController(mContext);
+        mFeatureFactory = FakeFeatureFactory.setupForTest();
     }
 
     @Test
     public void updateFooterPreference_setFooterPreference_hasClickAction() {
         mLocaleHelperPreferenceController.updateFooterPreference(mMockFooterPreference);
         verify(mMockFooterPreference).setLearnMoreText(anyString());
+        mMockFooterPreference.setLearnMoreAction(v -> {
+            verify(mFeatureFactory.metricsFeatureProvider).action(
+                    mContext, SettingsEnums.ACTION_LANGUAGES_LEARN_MORE);
+        });
     }
 }