Merge "Fix storage page slow loading issue"
diff --git a/res/values/strings.xml b/res/values/strings.xml
index 29f89c5..94eb5bf 100644
--- a/res/values/strings.xml
+++ b/res/values/strings.xml
@@ -7437,6 +7437,9 @@
     <!-- Battery Saver: Search terms for battery saver schedule preference. Feel free to add additional terms when translating if appropriate [CHAR_LIMIT=NONE] -->
     <string name="keywords_battery_saver_schedule">routine, schedule, battery saver, power saver, battery, automatic, percent</string>
 
+    <!-- List of synonyms for the enhance 4G LTE titles, used to match in settings search [CHAR LIMIT=NONE] -->
+    <string name="keywords_enhance_4g_lte">volte, advanced calling, 4g calling</string>
+
     <!-- Option title for the default sound, context based on screen -->
     <string name="default_sound">Default sound</string>
 
diff --git a/res/xml/adaptive_sleep_detail.xml b/res/xml/adaptive_sleep_detail.xml
index 568e694..4b46fae 100644
--- a/res/xml/adaptive_sleep_detail.xml
+++ b/res/xml/adaptive_sleep_detail.xml
@@ -45,4 +45,11 @@
         settings:useAdminDisabledSummary="true"
         settings:allowDividerAbove="true" />
 
+    <com.android.settingslib.widget.FooterPreference
+        android:key="adaptive_sleep_footer"
+        android:title="@string/adaptive_sleep_privacy"
+        android:icon="@drawable/ic_privacy_shield_24dp"
+        android:selectable="false"
+        settings:searchable="false" />
+
 </PreferenceScreen>
\ No newline at end of file
diff --git a/res/xml/add_account_settings.xml b/res/xml/add_account_settings.xml
index 2ea3326..1bc9149 100644
--- a/res/xml/add_account_settings.xml
+++ b/res/xml/add_account_settings.xml
@@ -19,4 +19,11 @@
     xmlns:settings="http://schemas.android.com/apk/res-auto"
     android:key="add_account_screen"
     android:title="@string/header_add_an_account"
-    settings:controller="com.android.settings.accounts.ChooseAccountPreferenceController"/>
+    settings:controller="com.android.settings.accounts.ChooseAccountPreferenceController">
+
+    <com.android.settingslib.widget.FooterPreference
+        android:key="add_account_enterprise_disclosure_footer"
+        android:selectable="false"
+        settings:searchable="false"
+        settings:controller="com.android.settings.accounts.EnterpriseDisclosurePreferenceController"/>
+</PreferenceScreen>
diff --git a/res/xml/billing_cycle.xml b/res/xml/billing_cycle.xml
index 3720240..e9a34f1 100644
--- a/res/xml/billing_cycle.xml
+++ b/res/xml/billing_cycle.xml
@@ -16,6 +16,7 @@
 
 <PreferenceScreen
     xmlns:android="http://schemas.android.com/apk/res/android"
+    xmlns:settings="http://schemas.android.com/apk/res-auto"
     android:key="billing_cycle_settings"
     android:title="@string/billing_cycle">
 
@@ -39,4 +40,10 @@
         android:key="data_limit"
         android:title="@string/data_limit" />
 
+    <com.android.settingslib.widget.FooterPreference
+        android:key="billing_cycle_footer"
+        android:title="@string/data_warning_footnote"
+        android:selectable="false"
+        settings:searchable="false"/>
+
 </PreferenceScreen>
diff --git a/res/xml/bluetooth_device_details_fragment.xml b/res/xml/bluetooth_device_details_fragment.xml
index f485c6a..94052b6 100644
--- a/res/xml/bluetooth_device_details_fragment.xml
+++ b/res/xml/bluetooth_device_details_fragment.xml
@@ -47,4 +47,10 @@
     <PreferenceCategory
         android:key="bluetooth_profiles"/>
 
+    <com.android.settingslib.widget.FooterPreference
+        android:key="device_details_footer"
+        android:selectable="false"
+        settings:searchable="false"
+        settings:controller="com.android.settings.bluetooth.BluetoothDetailsMacAddressController"/>
+
 </PreferenceScreen>
\ No newline at end of file
diff --git a/res/xml/feature_flags_settings.xml b/res/xml/feature_flags_settings.xml
index 8dc5ab3..0e509a8 100644
--- a/res/xml/feature_flags_settings.xml
+++ b/res/xml/feature_flags_settings.xml
@@ -25,4 +25,10 @@
         android:layout="@layout/preference_category_no_label"
         android:title="@string/summary_placeholder"
         settings:controller="com.android.settings.development.featureflags.FeatureFlagsPreferenceController" />
+
+    <com.android.settingslib.widget.FooterPreference
+        android:key="feature_flag_footer"
+        android:title="@string/experimental_category_title"
+        android:selectable="false"
+        settings:searchable="false"/>
 </PreferenceScreen>
diff --git a/res/xml/mobile_network_settings.xml b/res/xml/mobile_network_settings.xml
index 488761f..ae7c903 100644
--- a/res/xml/mobile_network_settings.xml
+++ b/res/xml/mobile_network_settings.xml
@@ -50,6 +50,7 @@
         android:title="@string/enhanced_4g_lte_mode_title"
         android:persistent="false"
         android:summary="@string/enhanced_4g_lte_mode_summary"
+        settings:keywords="@string/keywords_enhance_4g_lte"
         settings:controller="com.android.settings.network.telephony.Enhanced4gLtePreferenceController"/>
 
     <ListPreference
diff --git a/res/xml/mobile_network_settings_v2.xml b/res/xml/mobile_network_settings_v2.xml
index e77bf2d..a22826f 100644
--- a/res/xml/mobile_network_settings_v2.xml
+++ b/res/xml/mobile_network_settings_v2.xml
@@ -21,6 +21,7 @@
 
     <com.android.settingslib.widget.LayoutPreference
         android:key="use_sim_switch"
+        android:title="@string/summary_placeholder"
         android:layout="@layout/styled_switch_bar"
         settings:controller="com.android.settings.network.telephony.MobileNetworkSwitchController"/>
 
@@ -96,6 +97,7 @@
             android:title="@string/enhanced_4g_lte_mode_title"
             android:persistent="false"
             android:summary="@string/enhanced_4g_lte_mode_summary"
+            settings:keywords="@string/keywords_enhance_4g_lte"
             settings:controller="com.android.settings.network.telephony.Enhanced4gLtePreferenceController"/>
 
         <ListPreference
diff --git a/src/com/android/settings/BugreportPreference.java b/src/com/android/settings/BugreportPreference.java
index f5b739a..ee551c1 100644
--- a/src/com/android/settings/BugreportPreference.java
+++ b/src/com/android/settings/BugreportPreference.java
@@ -114,8 +114,8 @@
             // untouched. To switch to the new workflow using Bugreport API run the following
             // commands on the terminal:
             // * adb root
-            // * adb shell setprop settings_call_bugreport_api true
-            if (FeatureFlagUtils.isEnabled(context, FeatureFlags.USE_BUGREPORT_API)) {
+            // * adb shell setprop settings_use_bugreport_api true
+            if (FeatureFlagUtils.isEnabled(context, FeatureFlagUtils.USE_BUGREPORT_API)) {
                 Intent triggerShellBugreport = new Intent();
                 triggerShellBugreport.setAction(INTENT_BUGREPORT_REQUESTED);
                 triggerShellBugreport.setPackage(SHELL_APP_PACKAGE);
diff --git a/src/com/android/settings/Utils.java b/src/com/android/settings/Utils.java
index 75db3e1..00542ca 100644
--- a/src/com/android/settings/Utils.java
+++ b/src/com/android/settings/Utils.java
@@ -92,6 +92,7 @@
 import android.widget.TabWidget;
 
 import androidx.annotation.StringRes;
+import androidx.annotation.NonNull;
 import androidx.core.graphics.drawable.IconCompat;
 import androidx.fragment.app.Fragment;
 import androidx.lifecycle.Lifecycle;
@@ -105,6 +106,7 @@
 import com.android.settings.development.featureflags.FeatureFlagPersistent;
 import com.android.settings.password.ChooseLockSettingsHelper;
 import com.android.settingslib.widget.ActionBarShadowController;
+import com.android.settingslib.widget.FooterPreference;
 
 import java.net.InetAddress;
 import java.util.Iterator;
@@ -139,16 +141,16 @@
      * Finds a matching activity for a preference's intent. If a matching
      * activity is not found, it will remove the preference.
      *
-     * @param context The context.
+     * @param context               The context.
      * @param parentPreferenceGroup The preference group that contains the
-     *            preference whose intent is being resolved.
-     * @param preferenceKey The key of the preference whose intent is being
-     *            resolved.
-     * @param flags 0 or one or more of
-     *            {@link #UPDATE_PREFERENCE_FLAG_SET_TITLE_TO_MATCHING_ACTIVITY}
-     *            .
+     *                              preference whose intent is being resolved.
+     * @param preferenceKey         The key of the preference whose intent is being
+     *                              resolved.
+     * @param flags                 0 or one or more of
+     *                              {@link #UPDATE_PREFERENCE_FLAG_SET_TITLE_TO_MATCHING_ACTIVITY}
+     *                              .
      * @return Whether an activity was found. If false, the preference was
-     *         removed.
+     * removed.
      */
     public static boolean updatePreferenceToSpecificActivityOrRemove(Context context,
             PreferenceGroup parentPreferenceGroup, String preferenceKey, int flags) {
@@ -221,6 +223,7 @@
 
     /**
      * Returns the WIFI IP Addresses, if any, taking into account IPv4 and IPv6 style addresses.
+     *
      * @param context the application context
      * @return the formatted and newline-separated IP addresses, or null if none.
      */
@@ -229,7 +232,7 @@
         Network currentNetwork = wifiManager.getCurrentNetwork();
         if (currentNetwork != null) {
             ConnectivityManager cm = (ConnectivityManager)
-                context.getSystemService(Context.CONNECTIVITY_SERVICE);
+                    context.getSystemService(Context.CONNECTIVITY_SERVICE);
             LinkProperties prop = cm.getLinkProperties(currentNetwork);
             return formatIpAddresses(prop);
         }
@@ -257,8 +260,9 @@
         // many cases, because the constructor takes the only string as the language
         // code. So : new Locale("en", "US").toString() => "en_US"
         // And : new Locale("en_US").toString() => "en_us"
-        if (null == localeStr)
+        if (null == localeStr) {
             return Locale.getDefault();
+        }
         String[] brokenDownLocale = localeStr.split("_", 3);
         // split may not return a 0-length array.
         if (1 == brokenDownLocale.length) {
@@ -329,7 +333,7 @@
         final long localRowProfileId;
         final Cursor localRawProfile = cr.query(
                 Profile.CONTENT_RAW_CONTACTS_URI,
-                new String[] {RawContacts._ID},
+                new String[]{RawContacts._ID},
                 RawContacts.ACCOUNT_TYPE + " IS NULL AND " +
                         RawContacts.ACCOUNT_NAME + " IS NULL",
                 null, null);
@@ -347,8 +351,8 @@
         // Find the structured name for the raw contact.
         final Cursor structuredName = cr.query(
                 Profile.CONTENT_URI.buildUpon().appendPath(Contacts.Data.CONTENT_DIRECTORY).build(),
-                new String[] {CommonDataKinds.StructuredName.GIVEN_NAME,
-                    CommonDataKinds.StructuredName.FAMILY_NAME},
+                new String[]{CommonDataKinds.StructuredName.GIVEN_NAME,
+                        CommonDataKinds.StructuredName.FAMILY_NAME},
                 Data.RAW_CONTACT_ID + "=" + localRowProfileId,
                 null, null);
         if (structuredName == null) return null;
@@ -370,7 +374,7 @@
     private static final String getProfileDisplayName(Context context) {
         final ContentResolver cr = context.getContentResolver();
         final Cursor profile = cr.query(Profile.CONTENT_URI,
-                new String[] {Profile.DISPLAY_NAME}, null, null, null);
+                new String[]{Profile.DISPLAY_NAME}, null, null, null);
         if (profile == null) return null;
 
         try {
@@ -451,7 +455,7 @@
      * <ul>
      * <li> If this activity is launched from other user, return that user id.
      * <li> If this is launched from the Settings app in same user, return the user contained as an
-     *      extra in the arguments or intent extras.
+     * extra in the arguments or intent extras.
      * <li> Otherwise, return UserHandle.myUserId().
      * </ul>
      * <p>
@@ -500,7 +504,8 @@
      * Lookup both {@link Intent#EXTRA_USER} and {@link Intent#EXTRA_USER_ID} in the bundle
      * and return the {@link UserHandle} object. Return {@code null} if nothing is found.
      */
-    private static @Nullable UserHandle getUserHandleFromBundle(Bundle bundle) {
+    private static @Nullable
+    UserHandle getUserHandleFromBundle(Bundle bundle) {
         if (bundle == null) {
             return null;
         }
@@ -515,14 +520,14 @@
         return null;
     }
 
-   /**
-    * Returns true if the user provided is in the same profiles group as the current user.
-    */
-   private static boolean isProfileOf(UserManager um, UserHandle otherUser) {
-       if (um == null || otherUser == null) return false;
-       return (UserHandle.myUserId() == otherUser.getIdentifier())
-               || um.getUserProfiles().contains(otherUser);
-   }
+    /**
+     * Returns true if the user provided is in the same profiles group as the current user.
+     */
+    private static boolean isProfileOf(UserManager um, UserHandle otherUser) {
+        if (um == null || otherUser == null) return false;
+        return (UserHandle.myUserId() == otherUser.getIdentifier())
+                || um.getUserProfiles().contains(otherUser);
+    }
 
     /**
      * Return whether or not the user should have a SIM Cards option in Settings.
@@ -541,8 +546,9 @@
 
     /**
      * Queries for the UserInfo of a user. Returns null if the user doesn't exist (was removed).
+     *
      * @param userManager Instance of UserManager
-     * @param checkUser The user to check the existence of.
+     * @param checkUser   The user to check the existence of.
      * @return UserInfo of the user or null for non-existent user.
      */
     public static UserInfo getExistingUser(UserManager userManager, UserHandle checkUser) {
@@ -582,7 +588,7 @@
             for (IntentFilter filter : filters) {
                 if (filter.hasCategory(Intent.CATEGORY_BROWSABLE)
                         && (filter.hasDataScheme(IntentFilter.SCHEME_HTTP) ||
-                                filter.hasDataScheme(IntentFilter.SCHEME_HTTPS))) {
+                        filter.hasDataScheme(IntentFilter.SCHEME_HTTPS))) {
                     result.addAll(filter.getHostsList());
                 }
             }
@@ -625,7 +631,8 @@
 
     /**
      * Returns an accessible SpannableString.
-     * @param displayText the text to display
+     *
+     * @param displayText     the text to display
      * @param accessibileText the text text-to-speech engines should read
      */
     public static SpannableString createAccessibleSequence(CharSequence displayText,
@@ -642,7 +649,7 @@
      * {@link Intent#EXTRA_USER_ID} if it belongs to the current user.
      *
      * @throws SecurityException if the given userId does not belong to the
-     *             current user group.
+     *                           current user group.
      */
     public static int getUserIdFromBundle(Context context, Bundle bundle) {
         return getUserIdFromBundle(context, bundle, false);
@@ -653,10 +660,10 @@
      * {@link Intent#EXTRA_USER_ID} if it belongs to the current user.
      *
      * @param isInternal indicating if the caller is "internal" to the system,
-     *            meaning we're willing to trust extras like
-     *            {@link ChooseLockSettingsHelper#EXTRA_ALLOW_ANY_USER}.
+     *                   meaning we're willing to trust extras like
+     *                   {@link ChooseLockSettingsHelper#EXTRA_ALLOW_ANY_USER}.
      * @throws SecurityException if the given userId does not belong to the
-     *             current user group.
+     *                           current user group.
      */
     public static int getUserIdFromBundle(Context context, Bundle bundle, boolean isInternal) {
         if (bundle == null) {
@@ -776,7 +783,7 @@
             final ApplicationInfo appInfo = context.getPackageManager().getApplicationInfo(
                     packageName,
                     PackageManager.MATCH_DISABLED_COMPONENTS
-                    | PackageManager.MATCH_ANY_USER);
+                            | PackageManager.MATCH_ANY_USER);
             return appInfo.loadLabel(context.getPackageManager());
         } catch (PackageManager.NameNotFoundException e) {
             Log.w(TAG, "Unable to find info for package: " + packageName);
@@ -835,8 +842,9 @@
 
     /**
      * Launches an intent which may optionally have a user id defined.
+     *
      * @param fragment Fragment to use to launch the activity.
-     * @param intent Intent to launch.
+     * @param intent   Intent to launch.
      */
     public static void launchIntent(Fragment fragment, Intent intent) {
         try {
@@ -864,7 +872,8 @@
 
     /**
      * Returns if a given user is a profile of another user.
-     * @param user The user whose profiles wibe checked.
+     *
+     * @param user    The user whose profiles wibe checked.
      * @param profile The (potential) profile.
      * @return if the profile is actually a profile
      */
@@ -889,9 +898,10 @@
     /**
      * Return {@code true} if the supplied package is device owner or profile owner of at
      * least one user.
-     * @param userManager used to get profile owner app for each user
+     *
+     * @param userManager         used to get profile owner app for each user
      * @param devicePolicyManager used to check whether it is device owner app
-     * @param packageName package to check about
+     * @param packageName         package to check about
      */
     public static boolean isProfileOrDeviceOwner(UserManager userManager,
             DevicePolicyManager devicePolicyManager, String packageName) {
@@ -943,8 +953,8 @@
     /**
      * Gets a drawable with a limited size to avoid crashing Settings if it's too big.
      *
-     * @param original original drawable, typically an app icon.
-     * @param maxWidth maximum width, in pixels.
+     * @param original  original drawable, typically an app icon.
+     * @param maxWidth  maximum width, in pixels.
      * @param maxHeight maximum height, in pixels.
      */
     public static Drawable getSafeDrawable(Drawable original, int maxWidth, int maxHeight) {
@@ -977,7 +987,7 @@
     public static IconCompat createIconWithDrawable(Drawable drawable) {
         Bitmap bitmap;
         if (drawable instanceof BitmapDrawable) {
-            bitmap = ((BitmapDrawable)drawable).getBitmap();
+            bitmap = ((BitmapDrawable) drawable).getBitmap();
         } else {
             final int width = drawable.getIntrinsicWidth();
             final int height = drawable.getIntrinsicHeight();
@@ -1065,4 +1075,24 @@
             ActionBarShadowController.attachToView(activity, lifecycle, scrollView);
         }
     }
+
+    /**
+     * Add a footer preference into preference group.
+     *
+     * @param group The parent {@link PreferenceGroup} of the footer preference.
+     * @param key   The key value of the footer preference.
+     * @param title The title of the footer preference.
+     */
+    public static void addFooterPreference(@NonNull Context context, @NonNull PreferenceGroup group,
+            String key, CharSequence title) {
+        final FooterPreference footerPreference = new FooterPreference(context);
+        footerPreference.setSelectable(false);
+        if (!TextUtils.isEmpty(key)) {
+            footerPreference.setKey(key);
+        }
+        if (!TextUtils.isEmpty(title)) {
+            footerPreference.setTitle(title);
+        }
+        group.addPreference(footerPreference);
+    }
 }
diff --git a/src/com/android/settings/accounts/AccountSyncSettings.java b/src/com/android/settings/accounts/AccountSyncSettings.java
index ec74cd8..a652056 100644
--- a/src/com/android/settings/accounts/AccountSyncSettings.java
+++ b/src/com/android/settings/accounts/AccountSyncSettings.java
@@ -42,12 +42,14 @@
 import android.view.MenuInflater;
 import android.view.MenuItem;
 
+import androidx.annotation.VisibleForTesting;
 import androidx.appcompat.app.AlertDialog;
 import androidx.preference.Preference;
 
 import com.android.settings.R;
 import com.android.settings.Utils;
 import com.android.settings.widget.EntityHeaderController;
+import com.android.settingslib.widget.FooterPreference;
 
 import com.google.android.collect.Lists;
 
@@ -458,8 +460,7 @@
             syncPref.setChecked(oneTimeSyncMode || syncEnabled);
         }
         if (syncIsFailing) {
-            mFooterPreferenceMixin.createFooterPreference()
-                    .setTitle(R.string.sync_is_failing);
+            createFooterPreference();
         }
     }
 
@@ -552,4 +553,11 @@
                         | DateUtils.FORMAT_SHOW_YEAR
                         | DateUtils.FORMAT_SHOW_TIME);
     }
+
+    @VisibleForTesting
+    void createFooterPreference() {
+        final FooterPreference footerPreference = new FooterPreference(getActivity());
+        footerPreference.setTitle(R.string.sync_is_failing);
+        getPreferenceScreen().addPreference(footerPreference);
+    }
 }
diff --git a/src/com/android/settings/accounts/ChooseAccountFragment.java b/src/com/android/settings/accounts/ChooseAccountFragment.java
index 448da6b..8f3318e 100644
--- a/src/com/android/settings/accounts/ChooseAccountFragment.java
+++ b/src/com/android/settings/accounts/ChooseAccountFragment.java
@@ -24,10 +24,6 @@
 import com.android.settings.R;
 import com.android.settings.Utils;
 import com.android.settings.dashboard.DashboardFragment;
-import com.android.settingslib.core.AbstractPreferenceController;
-
-import java.util.ArrayList;
-import java.util.List;
 
 /**
  * Activity asking a user to select an account to be set up.
@@ -55,8 +51,6 @@
 
         use(ChooseAccountPreferenceController.class).initialize(authorities, accountTypesFilter,
                 userHandle, getActivity());
-        use(EnterpriseDisclosurePreferenceController.class).setFooterPreferenceMixin(
-                mFooterPreferenceMixin);
     }
 
     @Override
@@ -68,15 +62,4 @@
     protected String getLogTag() {
         return TAG;
     }
-
-    @Override
-    protected List<AbstractPreferenceController> createPreferenceControllers(Context context) {
-        return buildControllers(context);
-    }
-
-    private static List<AbstractPreferenceController> buildControllers(Context context) {
-        final List<AbstractPreferenceController> controllers = new ArrayList<>();
-        controllers.add(new EnterpriseDisclosurePreferenceController(context));
-        return controllers;
-    }
 }
diff --git a/src/com/android/settings/accounts/EnterpriseDisclosurePreferenceController.java b/src/com/android/settings/accounts/EnterpriseDisclosurePreferenceController.java
index 7a6e5fa..b4dbf3d 100644
--- a/src/com/android/settings/accounts/EnterpriseDisclosurePreferenceController.java
+++ b/src/com/android/settings/accounts/EnterpriseDisclosurePreferenceController.java
@@ -19,32 +19,23 @@
 import android.content.Context;
 
 import androidx.annotation.VisibleForTesting;
-import androidx.preference.PreferenceScreen;
+import androidx.preference.Preference;
 
 import com.android.settings.core.BasePreferenceController;
 import com.android.settings.enterprise.EnterprisePrivacyFeatureProvider;
 import com.android.settings.overlay.FeatureFactory;
-import com.android.settingslib.widget.FooterPreference;
-import com.android.settingslib.widget.FooterPreferenceMixinCompat;
 
 public class EnterpriseDisclosurePreferenceController extends BasePreferenceController {
 
     private final EnterprisePrivacyFeatureProvider mFeatureProvider;
-    private FooterPreferenceMixinCompat mFooterPreferenceMixin;
-    private PreferenceScreen mScreen;
 
-    public EnterpriseDisclosurePreferenceController(Context context) {
+    public EnterpriseDisclosurePreferenceController(Context context, String key) {
         // Preference key doesn't matter as we are creating the preference in code.
-        super(context, "add_account_enterprise_disclosure_footer");
-
+        super(context, key);
         mFeatureProvider = FeatureFactory.getFactory(mContext)
                 .getEnterprisePrivacyFeatureProvider(mContext);
     }
 
-    public void setFooterPreferenceMixin(FooterPreferenceMixinCompat footerPreferenceMixin) {
-        mFooterPreferenceMixin = footerPreferenceMixin;
-    }
-
     @Override
     public int getAvailabilityStatus() {
         if (getDisclosure() == null) {
@@ -53,27 +44,17 @@
         return AVAILABLE;
     }
 
-    @Override
-    public void displayPreference(PreferenceScreen screen) {
-        super.displayPreference(screen);
-        mScreen = screen;
-        addEnterpriseDisclosure();
-    }
-
     @VisibleForTesting
     CharSequence getDisclosure() {
         return mFeatureProvider.getDeviceOwnerDisclosure();
     }
 
-    private void addEnterpriseDisclosure() {
+    @Override
+    public void updateState(Preference preference) {
         final CharSequence disclosure = getDisclosure();
         if (disclosure == null) {
             return;
         }
-        final FooterPreference enterpriseDisclosurePreference =
-                mFooterPreferenceMixin.createFooterPreference();
-        enterpriseDisclosurePreference.setSelectable(false);
-        enterpriseDisclosurePreference.setTitle(disclosure);
-        mScreen.addPreference(enterpriseDisclosurePreference);
+        preference.setTitle(disclosure);
     }
 }
diff --git a/src/com/android/settings/applications/ApplicationFeatureProviderImpl.java b/src/com/android/settings/applications/ApplicationFeatureProviderImpl.java
index 1fd7997..c647b8d 100644
--- a/src/com/android/settings/applications/ApplicationFeatureProviderImpl.java
+++ b/src/com/android/settings/applications/ApplicationFeatureProviderImpl.java
@@ -33,6 +33,7 @@
 import android.util.ArraySet;
 
 import com.android.internal.telephony.SmsApplication;
+import com.android.internal.telephony.euicc.EuiccConnector;
 import com.android.settings.R;
 
 import java.util.ArrayList;
@@ -141,6 +142,12 @@
             keepEnabledPackages.add(defaultSms.getPackageName());
         }
 
+        // Keep Euicc Service enabled.
+        final ComponentInfo euicc = EuiccConnector.findBestComponent(mPm);
+        if (euicc != null) {
+            keepEnabledPackages.add(euicc.packageName);
+        }
+
         keepEnabledPackages.addAll(getEnabledPackageWhitelist());
 
         final LocationManager locationManager =
diff --git a/src/com/android/settings/applications/appinfo/AppInfoDashboardFragment.java b/src/com/android/settings/applications/appinfo/AppInfoDashboardFragment.java
index 07925f6..8274634 100755
--- a/src/com/android/settings/applications/appinfo/AppInfoDashboardFragment.java
+++ b/src/com/android/settings/applications/appinfo/AppInfoDashboardFragment.java
@@ -19,7 +19,6 @@
 import static com.android.settingslib.RestrictedLockUtils.EnforcedAdmin;
 
 import android.app.Activity;
-import android.app.ActivityManager;
 import android.app.admin.DevicePolicyManager;
 import android.app.settings.SettingsEnums;
 import android.content.BroadcastReceiver;
@@ -183,10 +182,6 @@
         super.onCreate(icicle);
         mFinishing = false;
         final Activity activity = getActivity();
-        if (isLockTaskModePinned(activity)) {
-            finishActivity(activity);
-            return;
-        }
         mDpm = (DevicePolicyManager) activity.getSystemService(Context.DEVICE_POLICY_SERVICE);
         mUserManager = (UserManager) activity.getSystemService(Context.USER_SERVICE);
         mPm = activity.getPackageManager();
@@ -197,6 +192,7 @@
             return;
         }
         startListeningToPackageRemove();
+
         setHasOptionsMenu(true);
     }
 
@@ -318,8 +314,9 @@
     @VisibleForTesting
     boolean ensurePackageInfoAvailable(Activity activity) {
         if (mPackageInfo == null) {
+            mFinishing = true;
             Log.w(TAG, "Package info not available. Is this package already uninstalled?");
-            finishActivity(activity);
+            activity.finishAndRemoveTask();
             return false;
         }
         return true;
@@ -334,28 +331,14 @@
     @VisibleForTesting
     boolean ensureDisplayableModule(Activity activity) {
         if (AppUtils.isHiddenSystemModule(activity.getApplicationContext(), mPackageName)) {
+            mFinishing = true;
             Log.w(TAG, "Package is hidden module, exiting: " + mPackageName);
-            finishActivity(activity);
+            activity.finishAndRemoveTask();
             return false;
         }
         return true;
     }
 
-    /**
-     * Check the state of device lock task mode.
-     *
-     * @return true if the device lock task mode pinned.
-     */
-    @VisibleForTesting
-    boolean isLockTaskModePinned(Activity activity) {
-        ActivityManager activityManager = activity.getSystemService(ActivityManager.class);
-        if (activityManager.getLockTaskModeState() == ActivityManager.LOCK_TASK_MODE_PINNED) {
-            Log.w(TAG, "Device lock task mode pinned.");
-            return true;
-        }
-        return false;
-    }
-
     @Override
     public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
         super.onCreateOptionsMenu(menu, inflater);
@@ -654,11 +637,6 @@
         getContext().unregisterReceiver(mPackageRemovedReceiver);
     }
 
-    private void finishActivity(Activity activity) {
-        mFinishing = true;
-        activity.finishAndRemoveTask();
-    }
-
     @VisibleForTesting
     final BroadcastReceiver mPackageRemovedReceiver = new BroadcastReceiver() {
         @Override
diff --git a/src/com/android/settings/biometrics/fingerprint/FingerprintSettings.java b/src/com/android/settings/biometrics/fingerprint/FingerprintSettings.java
index 3fbcfd4..c90a0de 100644
--- a/src/com/android/settings/biometrics/fingerprint/FingerprintSettings.java
+++ b/src/com/android/settings/biometrics/fingerprint/FingerprintSettings.java
@@ -132,6 +132,7 @@
         private boolean mLaunchedConfirm;
         private Drawable mHighlightDrawable;
         private int mUserId;
+        private CharSequence mFooterTitle;
 
         private static final String TAG_AUTHENTICATE_SIDECAR = "authenticate_sidecar";
         private static final String TAG_REMOVAL_SIDECAR = "removal_sidecar";
@@ -323,7 +324,6 @@
                 launchChooseOrConfirmLock();
             }
 
-            final FooterPreference pref = mFooterPreferenceMixin.createFooterPreference();
             final EnforcedAdmin admin = RestrictedLockUtilsInternal.checkIfKeyguardFeaturesDisabled(
                     activity, DevicePolicyManager.KEYGUARD_DISABLE_FINGERPRINT, mUserId);
             final AnnotationSpan.LinkInfo adminLinkInfo = new AnnotationSpan.LinkInfo(
@@ -334,11 +334,11 @@
                     activity, getString(getHelpResource()), activity.getClass().getName());
             final AnnotationSpan.LinkInfo linkInfo = new AnnotationSpan.LinkInfo(
                     activity, ANNOTATION_URL, helpIntent);
-            pref.setTitle(AnnotationSpan.linkify(getText(admin != null
+            mFooterTitle = AnnotationSpan.linkify(getText(admin != null
                             ? R.string
                             .security_settings_fingerprint_enroll_disclaimer_lockscreen_disabled
                             : R.string.security_settings_fingerprint_enroll_disclaimer),
-                    linkInfo, adminLinkInfo));
+                    linkInfo, adminLinkInfo);
         }
 
         protected void removeFingerprintPreference(int fingerprintId) {
@@ -400,6 +400,7 @@
             root.addPreference(addPreference);
             addPreference.setOnPreferenceChangeListener(this);
             updateAddPreference();
+            createFooterPreference(root);
         }
 
         private void updateAddPreference() {
@@ -419,6 +420,18 @@
             addPreference.setEnabled(!tooMany && !removalInProgress);
         }
 
+        private void createFooterPreference(PreferenceGroup root) {
+            final Context context = getActivity();
+            if (context == null) {
+                return;
+            }
+
+            final FooterPreference footerPreference = new FooterPreference(context);
+            footerPreference.setTitle(mFooterTitle);
+            footerPreference.setSelectable(false);
+            root.addPreference(footerPreference);
+        }
+
         private static String genKey(int id) {
             return KEY_FINGERPRINT_ITEM_PREFIX + "_" + id;
         }
diff --git a/src/com/android/settings/bluetooth/BluetoothDetailsMacAddressController.java b/src/com/android/settings/bluetooth/BluetoothDetailsMacAddressController.java
index 835961d..86c45bb 100644
--- a/src/com/android/settings/bluetooth/BluetoothDetailsMacAddressController.java
+++ b/src/com/android/settings/bluetooth/BluetoothDetailsMacAddressController.java
@@ -25,13 +25,13 @@
 import com.android.settingslib.bluetooth.CachedBluetoothDevice;
 import com.android.settingslib.core.lifecycle.Lifecycle;
 import com.android.settingslib.widget.FooterPreference;
-import com.android.settingslib.widget.FooterPreferenceMixinCompat;
 
 /**
  * This class adds the device MAC address to a footer.
  */
 public class BluetoothDetailsMacAddressController extends BluetoothDetailsController {
-    FooterPreferenceMixinCompat mFooterPreferenceMixin;
+    public static final String KEY_DEVICE_DETAILS_FOOTER = "device_details_footer";
+
     FooterPreference mFooterPreference;
 
     public BluetoothDetailsMacAddressController(Context context,
@@ -39,12 +39,11 @@
             CachedBluetoothDevice device,
             Lifecycle lifecycle) {
         super(context, fragment, device, lifecycle);
-        mFooterPreferenceMixin = new FooterPreferenceMixinCompat(fragment, lifecycle);
     }
 
     @Override
     protected void init(PreferenceScreen screen) {
-        mFooterPreference = mFooterPreferenceMixin.createFooterPreference();
+        mFooterPreference = screen.findPreference(KEY_DEVICE_DETAILS_FOOTER);
         mFooterPreference.setTitle(mContext.getString(
                 R.string.bluetooth_device_mac_address, mCachedDevice.getAddress()));
     }
@@ -57,9 +56,6 @@
 
     @Override
     public String getPreferenceKey() {
-        if (mFooterPreference == null) {
-            return null;
-        }
-        return mFooterPreference.getKey();
+        return KEY_DEVICE_DETAILS_FOOTER;
     }
 }
\ No newline at end of file
diff --git a/src/com/android/settings/core/FeatureFlags.java b/src/com/android/settings/core/FeatureFlags.java
index b13d712..fee9c42 100644
--- a/src/com/android/settings/core/FeatureFlags.java
+++ b/src/com/android/settings/core/FeatureFlags.java
@@ -21,7 +21,6 @@
  */
 public class FeatureFlags {
     public static final String AUDIO_SWITCHER_SETTINGS = "settings_audio_switcher";
-    public static final String USE_BUGREPORT_API = "settings_call_bugreport_api";
     public static final String DYNAMIC_SYSTEM = "settings_dynamic_system";
     public static final String HEARING_AID_SETTINGS = "settings_bluetooth_hearing_aid";
     public static final String MOBILE_NETWORK_V2 = "settings_mobile_network_v2";
diff --git a/src/com/android/settings/datausage/BillingCycleSettings.java b/src/com/android/settings/datausage/BillingCycleSettings.java
index 87b8198..9c46d39 100644
--- a/src/com/android/settings/datausage/BillingCycleSettings.java
+++ b/src/com/android/settings/datausage/BillingCycleSettings.java
@@ -118,8 +118,6 @@
         mEnableDataLimit = (SwitchPreference) findPreference(KEY_SET_DATA_LIMIT);
         mEnableDataLimit.setOnPreferenceChangeListener(this);
         mDataLimit = findPreference(KEY_DATA_LIMIT);
-
-        mFooterPreferenceMixin.createFooterPreference().setTitle(R.string.data_warning_footnote);
     }
 
     @Override
diff --git a/src/com/android/settings/development/featureflags/FeatureFlagFooterPreferenceController.java b/src/com/android/settings/development/featureflags/FeatureFlagFooterPreferenceController.java
deleted file mode 100644
index a0d7036..0000000
--- a/src/com/android/settings/development/featureflags/FeatureFlagFooterPreferenceController.java
+++ /dev/null
@@ -1,50 +0,0 @@
-/*
- * Copyright (C) 2018 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.development.featureflags;
-
-import android.content.Context;
-
-import com.android.settings.R;
-import com.android.settings.core.BasePreferenceController;
-import com.android.settingslib.core.lifecycle.LifecycleObserver;
-import com.android.settingslib.core.lifecycle.events.OnStart;
-import com.android.settingslib.widget.FooterPreferenceMixinCompat;
-
-public class FeatureFlagFooterPreferenceController extends BasePreferenceController
-        implements LifecycleObserver, OnStart {
-
-    private FooterPreferenceMixinCompat mFooterMixin;
-
-    public FeatureFlagFooterPreferenceController(Context context) {
-        super(context, "feature_flag_footer_pref");
-    }
-
-    public void setFooterMixin(FooterPreferenceMixinCompat mixin) {
-        mFooterMixin = mixin;
-    }
-
-    @Override
-    public int getAvailabilityStatus() {
-        return AVAILABLE;
-    }
-
-    @Override
-    public void onStart() {
-        mFooterMixin.createFooterPreference()
-                .setTitle(R.string.experimental_category_title);
-    }
-}
diff --git a/src/com/android/settings/development/featureflags/FeatureFlagsDashboard.java b/src/com/android/settings/development/featureflags/FeatureFlagsDashboard.java
index 613fb17..f0d7f1c 100644
--- a/src/com/android/settings/development/featureflags/FeatureFlagsDashboard.java
+++ b/src/com/android/settings/development/featureflags/FeatureFlagsDashboard.java
@@ -24,8 +24,6 @@
 import com.android.settings.dashboard.DashboardFragment;
 import com.android.settings.search.BaseSearchIndexProvider;
 import com.android.settings.search.Indexable;
-import com.android.settingslib.core.AbstractPreferenceController;
-import com.android.settingslib.core.lifecycle.Lifecycle;
 import com.android.settingslib.development.DevelopmentSettingsEnabler;
 import com.android.settingslib.search.SearchIndexable;
 
@@ -55,7 +53,6 @@
     @Override
     public void onAttach(Context context) {
         super.onAttach(context);
-        use(FeatureFlagFooterPreferenceController.class).setFooterMixin(mFooterPreferenceMixin);
     }
 
     @Override
@@ -63,23 +60,6 @@
         return 0;
     }
 
-    @Override
-    protected List<AbstractPreferenceController> createPreferenceControllers(Context context) {
-        return buildPrefControllers(context, getSettingsLifecycle());
-    }
-
-    private static List<AbstractPreferenceController> buildPrefControllers(Context context,
-            Lifecycle lifecycle) {
-        final List<AbstractPreferenceController> controllers = new ArrayList<>();
-        final FeatureFlagFooterPreferenceController footerController =
-                new FeatureFlagFooterPreferenceController(context);
-        if (lifecycle != null) {
-            lifecycle.addObserver(footerController);
-        }
-        controllers.add(footerController);
-        return controllers;
-    }
-
     public static final Indexable.SearchIndexProvider SEARCH_INDEX_DATA_PROVIDER =
             new BaseSearchIndexProvider() {
                 @Override
@@ -97,11 +77,5 @@
                 protected boolean isPageSearchEnabled(Context context) {
                     return DevelopmentSettingsEnabler.isDevelopmentSettingsEnabled(context);
                 }
-
-                @Override
-                public List<AbstractPreferenceController> createPreferenceControllers(
-                        Context context) {
-                    return buildPrefControllers(context, null /* lifecycle */);
-                }
             };
 }
diff --git a/src/com/android/settings/display/AdaptiveSleepSettings.java b/src/com/android/settings/display/AdaptiveSleepSettings.java
index 66e20b4..09e558b 100644
--- a/src/com/android/settings/display/AdaptiveSleepSettings.java
+++ b/src/com/android/settings/display/AdaptiveSleepSettings.java
@@ -44,13 +44,7 @@
     @Override
     public void onCreate(Bundle icicle) {
         super.onCreate(icicle);
-        final FooterPreference footerPreference =
-                mFooterPreferenceMixin.createFooterPreference();
         mContext = getContext();
-
-        footerPreference.setIcon(R.drawable.ic_privacy_shield_24dp);
-        footerPreference.setTitle(R.string.adaptive_sleep_privacy);
-
         Preference permissionPreference = findPreference(
                 AdaptiveSleepPermissionPreferenceController.PREF_NAME);
         if (permissionPreference != null) {
diff --git a/src/com/android/settings/network/telephony/Enhanced4gLtePreferenceController.java b/src/com/android/settings/network/telephony/Enhanced4gLtePreferenceController.java
index ca45a32..9069c35 100644
--- a/src/com/android/settings/network/telephony/Enhanced4gLtePreferenceController.java
+++ b/src/com/android/settings/network/telephony/Enhanced4gLtePreferenceController.java
@@ -72,6 +72,7 @@
 
     @Override
     public int getAvailabilityStatus(int subId) {
+        init(subId);
         final PersistableBundle carrierConfig = mCarrierConfigManager.getConfigForSubId(subId);
         final boolean isVisible = subId != SubscriptionManager.INVALID_SUBSCRIPTION_ID
                 && mImsManager != null && carrierConfig != null
@@ -105,9 +106,9 @@
         super.updateState(preference);
         final SwitchPreference switchPreference = (SwitchPreference) preference;
         final boolean show4GForLTE = mCarrierConfig.getBoolean(
-            CarrierConfigManager.KEY_SHOW_4G_FOR_LTE_DATA_ICON_BOOL);
+                CarrierConfigManager.KEY_SHOW_4G_FOR_LTE_DATA_ICON_BOOL);
         int variant4glteTitleIndex = mCarrierConfig.getInt(
-            CarrierConfigManager.KEY_ENHANCED_4G_LTE_TITLE_VARIANT_INT);
+                CarrierConfigManager.KEY_ENHANCED_4G_LTE_TITLE_VARIANT_INT);
 
         if (variant4glteTitleIndex != VARIANT_TITLE_ADVANCED_CALL) {
             variant4glteTitleIndex = show4GForLTE ? VARIANT_TITLE_4G_CALLING : VARIANT_TITLE_VOLTE;
@@ -135,6 +136,9 @@
     }
 
     public Enhanced4gLtePreferenceController init(int subId) {
+        if (mSubId == subId) {
+            return this;
+        }
         mSubId = subId;
         mTelephonyManager = TelephonyManager.from(mContext).createForSubscriptionId(mSubId);
         mCarrierConfig = mCarrierConfigManager.getConfigForSubId(mSubId);
diff --git a/src/com/android/settings/network/telephony/MobileNetworkSettings.java b/src/com/android/settings/network/telephony/MobileNetworkSettings.java
index 8d83ef2..0a63e73 100644
--- a/src/com/android/settings/network/telephony/MobileNetworkSettings.java
+++ b/src/com/android/settings/network/telephony/MobileNetworkSettings.java
@@ -119,7 +119,7 @@
                 MobileNetworkUtils.getSearchableSubscriptionId(context));
 
         if (FeatureFlagPersistent.isEnabled(getContext(), FeatureFlags.NETWORK_INTERNET_V2) &&
-            mSubId != SubscriptionManager.INVALID_SUBSCRIPTION_ID) {
+                mSubId != SubscriptionManager.INVALID_SUBSCRIPTION_ID) {
             return Arrays.asList(
                     new DataUsageSummaryPreferenceController(getActivity(), getSettingsLifecycle(),
                             this, mSubId));
@@ -275,7 +275,10 @@
                     final ArrayList<SearchIndexableResource> result = new ArrayList<>();
 
                     final SearchIndexableResource sir = new SearchIndexableResource(context);
-                    sir.xmlResId = R.xml.mobile_network_settings;
+                    sir.xmlResId = FeatureFlagPersistent.isEnabled(context,
+                            FeatureFlags.NETWORK_INTERNET_V2)
+                            ? R.xml.mobile_network_settings_v2
+                            : R.xml.mobile_network_settings;
                     result.add(sir);
                     return result;
                 }
diff --git a/tests/robotests/src/com/android/settings/accounts/AccountHeaderPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/accounts/AccountHeaderPreferenceControllerTest.java
index 50814ee..8fb40bf 100644
--- a/tests/robotests/src/com/android/settings/accounts/AccountHeaderPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/accounts/AccountHeaderPreferenceControllerTest.java
@@ -36,7 +36,7 @@
 
 import com.android.settings.R;
 import com.android.settings.testutils.FakeFeatureFactory;
-import com.android.settingslib.accounts.AuthenticatorHelper;
+import com.android.settings.testutils.shadow.ShadowAuthenticationHelper;
 import com.android.settingslib.core.lifecycle.Lifecycle;
 import com.android.settingslib.widget.LayoutPreference;
 
@@ -48,11 +48,9 @@
 import org.robolectric.RobolectricTestRunner;
 import org.robolectric.RuntimeEnvironment;
 import org.robolectric.annotation.Config;
-import org.robolectric.annotation.Implementation;
-import org.robolectric.annotation.Implements;
 
 @RunWith(RobolectricTestRunner.class)
-@Config(shadows = AccountHeaderPreferenceControllerTest.ShadowAuthenticatorHelper.class)
+@Config(shadows = ShadowAuthenticationHelper.class)
 public class AccountHeaderPreferenceControllerTest {
 
     @Mock
@@ -109,12 +107,4 @@
 
         assertThat(label).isEqualTo(account.name);
     }
-
-    @Implements(AuthenticatorHelper.class)
-    public static class ShadowAuthenticatorHelper {
-        @Implementation
-        protected void onAccountsUpdated(Account[] accounts) {
-
-        }
-    }
 }
diff --git a/tests/robotests/src/com/android/settings/accounts/AccountSyncSettingsTest.java b/tests/robotests/src/com/android/settings/accounts/AccountSyncSettingsTest.java
index dd1778f..59d1f60 100644
--- a/tests/robotests/src/com/android/settings/accounts/AccountSyncSettingsTest.java
+++ b/tests/robotests/src/com/android/settings/accounts/AccountSyncSettingsTest.java
@@ -15,6 +15,8 @@
  */
 package com.android.settings.accounts;
 
+import static com.google.common.truth.Truth.assertThat;
+
 import static org.mockito.Mockito.mock;
 import static org.mockito.Mockito.spy;
 import static org.mockito.Mockito.when;
@@ -24,7 +26,9 @@
 import android.os.UserHandle;
 
 import androidx.fragment.app.FragmentActivity;
+import androidx.preference.Preference;
 
+import com.android.settings.testutils.shadow.ShadowAuthenticationHelper;
 import com.android.settings.testutils.shadow.ShadowContentResolver;
 
 import org.junit.After;
@@ -33,6 +37,7 @@
 import org.robolectric.RobolectricTestRunner;
 import org.robolectric.RuntimeEnvironment;
 import org.robolectric.annotation.Config;
+import org.robolectric.shadows.androidx.fragment.FragmentController;
 import org.robolectric.util.ReflectionHelpers;
 
 @RunWith(RobolectricTestRunner.class)
@@ -57,4 +62,18 @@
         settings.onPreferenceTreeClick(preference);
         // no crash
     }
+
+    @Test
+    @Config(shadows = {ShadowAuthenticationHelper.class})
+    public void createFooterPreference_shouldReturnFooter() {
+        final AccountSyncSettings settings = FragmentController.of(new AccountSyncSettings())
+                .create()
+                .get();
+
+        settings.createFooterPreference();
+
+        final Preference footer = settings.getPreferenceScreen().findPreference(
+                "footer_preference");
+        assertThat(footer).isNotNull();
+    }
 }
diff --git a/tests/robotests/src/com/android/settings/accounts/EnterpriseDisclosurePreferenceControllerTest.java b/tests/robotests/src/com/android/settings/accounts/EnterpriseDisclosurePreferenceControllerTest.java
index b9c62c2..b10a729 100644
--- a/tests/robotests/src/com/android/settings/accounts/EnterpriseDisclosurePreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/accounts/EnterpriseDisclosurePreferenceControllerTest.java
@@ -18,46 +18,37 @@
 
 import static com.google.common.truth.Truth.assertThat;
 
+import static org.mockito.ArgumentMatchers.any;
 import static org.mockito.Mockito.doReturn;
+import static org.mockito.Mockito.never;
 import static org.mockito.Mockito.spy;
+import static org.mockito.Mockito.verify;
 
 import android.content.Context;
 
-import androidx.preference.PreferenceManager;
-import androidx.preference.PreferenceScreen;
+import androidx.preference.Preference;
 
 import com.android.settings.core.BasePreferenceController;
-import com.android.settingslib.widget.FooterPreferenceMixinCompat;
 
 import org.junit.Before;
 import org.junit.Test;
 import org.junit.runner.RunWith;
-import org.mockito.MockitoAnnotations;
 import org.robolectric.RobolectricTestRunner;
 import org.robolectric.RuntimeEnvironment;
 
 @RunWith(RobolectricTestRunner.class)
 public class EnterpriseDisclosurePreferenceControllerTest {
-
     private static final String TEST_DISCLOSURE = "This is a test disclosure.";
 
-    private ChooseAccountFragment mFragment;
     private Context mContext;
     private EnterpriseDisclosurePreferenceController mController;
-    private FooterPreferenceMixinCompat mFooterPreferenceMixin;
-    private PreferenceManager mPreferenceManager;
-    private PreferenceScreen mPreferenceScreen;
+    private Preference mPreference;
 
     @Before
     public void setUp() {
-        MockitoAnnotations.initMocks(this);
         mContext = RuntimeEnvironment.application;
-        mController = spy(new EnterpriseDisclosurePreferenceController(mContext));
-        mFragment = spy(new ChooseAccountFragment());
-        mFooterPreferenceMixin = new FooterPreferenceMixinCompat(mFragment,
-                mFragment.getSettingsLifecycle());
-        mPreferenceManager = new PreferenceManager(mContext);
-        mPreferenceScreen = mPreferenceManager.createPreferenceScreen(mContext);
+        mController = spy(new EnterpriseDisclosurePreferenceController(mContext, "my_key"));
+        mPreference = spy(new Preference(mContext));
     }
 
     @Test
@@ -77,24 +68,20 @@
     }
 
     @Test
-    public void displayPreference_hasDisclosure_shouldSetTitle() {
+    public void updateState_hasDisclosure_shouldSetTitle() {
         doReturn(TEST_DISCLOSURE).when(mController).getDisclosure();
-        doReturn(mPreferenceScreen).when(mFragment).getPreferenceScreen();
-        doReturn(mPreferenceManager).when(mFragment).getPreferenceManager();
 
-        mController.setFooterPreferenceMixin(mFooterPreferenceMixin);
-        mController.displayPreference(mPreferenceScreen);
+        mController.updateState(mPreference);
 
-        assertThat(mPreferenceScreen.getPreferenceCount()).isEqualTo(1);
-        assertThat(mPreferenceScreen.getPreference(0).getTitle()).isEqualTo(TEST_DISCLOSURE);
+        assertThat(mPreference.getTitle()).isEqualTo(TEST_DISCLOSURE);
     }
 
     @Test
-    public void displayPreference_noDisclosure_shouldBeInvisible() {
+    public void updateState_noDisclosure_shouldBeInvisible() {
         doReturn(null).when(mController).getDisclosure();
 
-        mController.displayPreference(mPreferenceScreen);
+        mController.updateState(mPreference);
 
-        assertThat(mPreferenceScreen.getPreferenceCount()).isEqualTo(0);
+        verify(mPreference, never()).setTitle(any());
     }
 }
diff --git a/tests/robotests/src/com/android/settings/accounts/TopLevelAccountEntryPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/accounts/TopLevelAccountEntryPreferenceControllerTest.java
index ced3db1..8fe8e19 100644
--- a/tests/robotests/src/com/android/settings/accounts/TopLevelAccountEntryPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/accounts/TopLevelAccountEntryPreferenceControllerTest.java
@@ -16,19 +16,12 @@
 
 package com.android.settings.accounts;
 
-import static com.android.settings.accounts.TopLevelAccountEntryPreferenceControllerTest
-        .ShadowAuthenticationHelper.LABELS;
-import static com.android.settings.accounts.TopLevelAccountEntryPreferenceControllerTest
-        .ShadowAuthenticationHelper.TYPES;
-
 import static com.google.common.truth.Truth.assertThat;
 
 import android.content.Context;
-import android.os.UserHandle;
-import android.text.TextUtils;
 
 import com.android.settings.R;
-import com.android.settingslib.accounts.AuthenticatorHelper;
+import com.android.settings.testutils.shadow.ShadowAuthenticationHelper;
 
 import org.junit.After;
 import org.junit.Before;
@@ -37,21 +30,22 @@
 import org.robolectric.RobolectricTestRunner;
 import org.robolectric.RuntimeEnvironment;
 import org.robolectric.annotation.Config;
-import org.robolectric.annotation.Implementation;
-import org.robolectric.annotation.Implements;
-import org.robolectric.annotation.Resetter;
 
 @RunWith(RobolectricTestRunner.class)
-@Config(shadows = {TopLevelAccountEntryPreferenceControllerTest.ShadowAuthenticationHelper.class})
+@Config(shadows = {ShadowAuthenticationHelper.class})
 public class TopLevelAccountEntryPreferenceControllerTest {
 
     private TopLevelAccountEntryPreferenceController mController;
     private Context mContext;
+    private String[] LABELS;
+    private String[] TYPES;
 
     @Before
     public void setUp() {
         mContext = RuntimeEnvironment.application;
         mController = new TopLevelAccountEntryPreferenceController(mContext, "test_key");
+        LABELS = ShadowAuthenticationHelper.getLabels();
+        TYPES = ShadowAuthenticationHelper.getTypes();
     }
 
     @After
@@ -60,7 +54,6 @@
     }
 
     @Test
-
     public void updateSummary_hasAccount_shouldDisplayUpTo3AccountTypes() {
         assertThat(mController.getSummary())
                 .isEqualTo(LABELS[0] + ", " + LABELS[1] + ", and " + LABELS[2]);
@@ -83,44 +76,4 @@
         // should only show the 2 accounts with labels
         assertThat(mController.getSummary()).isEqualTo(LABELS[0] + " and " + LABELS[1]);
     }
-
-    @Implements(AuthenticatorHelper.class)
-    public static class ShadowAuthenticationHelper {
-
-        static final String[] TYPES = {"type1", "type2", "type3", "type4"};
-        static final String[] LABELS = {"LABEL1", "LABEL2", "LABEL3", "LABEL4"};
-        private static String[] sEnabledAccount = TYPES;
-
-        protected void __constructor__(Context context, UserHandle userHandle,
-                AuthenticatorHelper.OnAccountsUpdateListener listener) {
-        }
-
-        private static void setEnabledAccount(String[] enabledAccount) {
-            sEnabledAccount = enabledAccount;
-        }
-
-        @Resetter
-        public static void reset() {
-            sEnabledAccount = TYPES;
-        }
-
-        @Implementation
-        protected String[] getEnabledAccountTypes() {
-            return sEnabledAccount;
-        }
-
-        @Implementation
-        protected CharSequence getLabelForType(Context context, final String accountType) {
-            if (TextUtils.equals(accountType, TYPES[0])) {
-                return LABELS[0];
-            } else if (TextUtils.equals(accountType, TYPES[1])) {
-                return LABELS[1];
-            } else if (TextUtils.equals(accountType, TYPES[2])) {
-                return LABELS[2];
-            } else if (TextUtils.equals(accountType, TYPES[3])) {
-                return LABELS[3];
-            }
-            return null;
-        }
-    }
 }
diff --git a/tests/robotests/src/com/android/settings/applications/ApplicationFeatureProviderImplTest.java b/tests/robotests/src/com/android/settings/applications/ApplicationFeatureProviderImplTest.java
index fcb7518..12b93cd 100644
--- a/tests/robotests/src/com/android/settings/applications/ApplicationFeatureProviderImplTest.java
+++ b/tests/robotests/src/com/android/settings/applications/ApplicationFeatureProviderImplTest.java
@@ -27,6 +27,7 @@
 import android.content.Intent;
 import android.content.pm.ActivityInfo;
 import android.content.pm.ApplicationInfo;
+import android.content.pm.ComponentInfo;
 import android.content.pm.IPackageManager;
 import android.content.pm.PackageManager;
 import android.content.pm.ResolveInfo;
@@ -36,11 +37,12 @@
 import android.os.UserHandle;
 import android.os.UserManager;
 
-import com.android.settings.R;
+import com.android.internal.telephony.euicc.EuiccConnector;
 import com.android.settings.testutils.ApplicationTestUtils;
 import com.android.settingslib.testutils.shadow.ShadowDefaultDialerManager;
 import com.android.settingslib.testutils.shadow.ShadowSmsApplication;
 
+import org.junit.After;
 import org.junit.Before;
 import org.junit.Test;
 import org.junit.runner.RunWith;
@@ -49,6 +51,8 @@
 import org.robolectric.RobolectricTestRunner;
 import org.robolectric.RuntimeEnvironment;
 import org.robolectric.annotation.Config;
+import org.robolectric.annotation.Implementation;
+import org.robolectric.annotation.Implements;
 import org.robolectric.shadows.ShadowApplication;
 import org.robolectric.util.ReflectionHelpers;
 
@@ -105,6 +109,12 @@
                 mPackageManagerService, mDevicePolicyManager);
     }
 
+    @After
+    @Config(shadows = {ShadowEuiccConnector.class})
+    public void tearDown() {
+        ShadowEuiccConnector.reset();
+    }
+
     private void verifyCalculateNumberOfPolicyInstalledApps(boolean async) {
         setUpUsersAndInstalledApps();
 
@@ -165,7 +175,7 @@
                 .thenReturn(PackageManager.INSTALL_REASON_POLICY);
 
         mAppCount = -1;
-        mProvider.calculateNumberOfAppsWithAdminGrantedPermissions(new String[] {PERMISSION}, async,
+        mProvider.calculateNumberOfAppsWithAdminGrantedPermissions(new String[]{PERMISSION}, async,
                 (num) -> mAppCount = num);
         if (async) {
             ShadowApplication.runBackgroundTasks();
@@ -202,7 +212,7 @@
                 .thenReturn(PackageManager.INSTALL_REASON_POLICY);
 
         mAppList = null;
-        mProvider.listAppsWithAdminGrantedPermissions(new String[] {PERMISSION},
+        mProvider.listAppsWithAdminGrantedPermissions(new String[]{PERMISSION},
                 (list) -> mAppList = list);
         assertThat(mAppList).isNotNull();
         assertThat(mAppList.size()).isEqualTo(2);
@@ -251,10 +261,10 @@
                 new ApplicationInfo(app2.activityInfo.applicationInfo)));
 
         assertThat(mProvider.findPersistentPreferredActivities(MAIN_USER_ID,
-                new Intent[] {viewIntent, editIntent, sendIntent}))
+                new Intent[]{viewIntent, editIntent, sendIntent}))
                 .isEqualTo(expectedMainUserActivities);
         assertThat(mProvider.findPersistentPreferredActivities(MANAGED_PROFILE_ID,
-                new Intent[] {viewIntent, editIntent, sendIntent}))
+                new Intent[]{viewIntent, editIntent, sendIntent}))
                 .isEqualTo(expectedManagedUserActivities);
     }
 
@@ -283,6 +293,33 @@
     }
 
     @Test
+    @Config(shadows = {ShadowSmsApplication.class, ShadowDefaultDialerManager.class,
+            ShadowEuiccConnector.class})
+    public void getKeepEnabledPackages_hasEuiccComponent_shouldContainEuiccPackage() {
+        final String testDialer = "com.android.test.defaultdialer";
+        final String testSms = "com.android.test.defaultsms";
+        final String testLocationHistory = "com.android.test.location.history";
+        final String testEuicc = "com.android.test.euicc";
+
+        ShadowSmsApplication.setDefaultSmsApplication(new ComponentName(testSms, "receiver"));
+        ShadowDefaultDialerManager.setDefaultDialerApplication(testDialer);
+        final ComponentInfo componentInfo = new ComponentInfo();
+        componentInfo.packageName = testEuicc;
+        ShadowEuiccConnector.setBestComponent(componentInfo);
+
+        // Spy the real context to mock LocationManager.
+        Context spyContext = spy(RuntimeEnvironment.application);
+        when(mLocationManager.getExtraLocationControllerPackage()).thenReturn(testLocationHistory);
+        when(spyContext.getSystemService(Context.LOCATION_SERVICE)).thenReturn(mLocationManager);
+
+        ReflectionHelpers.setField(mProvider, "mContext", spyContext);
+
+        final Set<String> keepEnabledPackages = mProvider.getKeepEnabledPackages();
+
+        assertThat(keepEnabledPackages).contains(testEuicc);
+    }
+
+    @Test
     @Config(shadows = {ShadowSmsApplication.class, ShadowDefaultDialerManager.class})
     public void getKeepEnabledPackages_shouldContainSettingsIntelligence() {
         final String testDialer = "com.android.test.defaultdialer";
@@ -354,4 +391,23 @@
         resolveInfo.activityInfo = activityInfo;
         return resolveInfo;
     }
+
+    @Implements(EuiccConnector.class)
+    public static class ShadowEuiccConnector {
+
+        private static ComponentInfo sBestComponent;
+
+        @Implementation
+        protected static ComponentInfo findBestComponent(PackageManager packageManager) {
+            return sBestComponent;
+        }
+
+        public static void setBestComponent(ComponentInfo componentInfo) {
+            sBestComponent = componentInfo;
+        }
+
+        public static void reset() {
+            sBestComponent = null;
+        }
+    }
 }
diff --git a/tests/robotests/src/com/android/settings/applications/appinfo/AppInfoDashboardFragmentTest.java b/tests/robotests/src/com/android/settings/applications/appinfo/AppInfoDashboardFragmentTest.java
index 01304ea..e46cd06 100644
--- a/tests/robotests/src/com/android/settings/applications/appinfo/AppInfoDashboardFragmentTest.java
+++ b/tests/robotests/src/com/android/settings/applications/appinfo/AppInfoDashboardFragmentTest.java
@@ -33,7 +33,6 @@
 import static org.mockito.Mockito.verify;
 import static org.mockito.Mockito.when;
 
-import android.app.ActivityManager;
 import android.app.admin.DevicePolicyManager;
 import android.content.Context;
 import android.content.Intent;
@@ -87,8 +86,6 @@
     private DevicePolicyManager mDevicePolicyManager;
     @Mock
     private PackageManager mPackageManager;
-    @Mock
-    private ActivityManager mActivityManager;
 
     private AppInfoDashboardFragment mFragment;
     private Context mShadowContext;
@@ -96,13 +93,11 @@
     @Before
     public void setUp() {
         MockitoAnnotations.initMocks(this);
-        mShadowContext = spy(RuntimeEnvironment.application);
+        mShadowContext = RuntimeEnvironment.application;
         mFragment = spy(new AppInfoDashboardFragment());
         doReturn(mActivity).when(mFragment).getActivity();
         doReturn(mShadowContext).when(mFragment).getContext();
         doReturn(mPackageManager).when(mActivity).getPackageManager();
-        doReturn(mShadowContext).when(mActivity).getApplicationContext();
-        doReturn(mActivityManager).when(mActivity).getSystemService(ActivityManager.class);
         when(mUserManager.isAdminUser()).thenReturn(true);
 
         ReflectionHelpers.setField(mFragment, "mUserManager", mUserManager);
@@ -207,6 +202,7 @@
         ShadowAppUtils.addHiddenModule(PACKAGE_NAME);
         ReflectionHelpers.setField(mFragment, "mPackageName", PACKAGE_NAME);
 
+
         assertThat(mFragment.ensureDisplayableModule(mActivity)).isFalse();
     }
 
@@ -219,14 +215,6 @@
     }
 
     @Test
-    public void isLockTaskModePinned_pinned_shouldReturnTrue() {
-        doReturn(ActivityManager.LOCK_TASK_MODE_PINNED).when(
-                mActivityManager).getLockTaskModeState();
-
-        assertThat(mFragment.isLockTaskModePinned(mActivity)).isTrue();
-    }
-
-    @Test
     public void createPreference_hasNoPackageInfo_shouldSkip() {
         ReflectionHelpers.setField(mFragment, "mPackageInfo", null);
 
@@ -279,8 +267,9 @@
     public void onActivityResult_uninstalledUpdates_shouldInvalidateOptionsMenu() {
         doReturn(true).when(mFragment).refreshUi();
 
-        mFragment.onActivityResult(AppInfoDashboardFragment.REQUEST_UNINSTALL, 0,
-                mock(Intent.class));
+        mFragment
+                .onActivityResult(AppInfoDashboardFragment.REQUEST_UNINSTALL, 0,
+                        mock(Intent.class));
 
         verify(mActivity).invalidateOptionsMenu();
     }
diff --git a/tests/robotests/src/com/android/settings/bluetooth/BluetoothDetailsMacAddressControllerTest.java b/tests/robotests/src/com/android/settings/bluetooth/BluetoothDetailsMacAddressControllerTest.java
index 9798745..ec1549f 100644
--- a/tests/robotests/src/com/android/settings/bluetooth/BluetoothDetailsMacAddressControllerTest.java
+++ b/tests/robotests/src/com/android/settings/bluetooth/BluetoothDetailsMacAddressControllerTest.java
@@ -15,8 +15,11 @@
  */
 package com.android.settings.bluetooth;
 
+import static com.android.settings.bluetooth.BluetoothDetailsMacAddressController.KEY_DEVICE_DETAILS_FOOTER;
+
 import static com.google.common.truth.Truth.assertThat;
 
+import com.android.settings.Utils;
 import com.android.settingslib.widget.FooterPreference;
 
 import org.junit.Test;
@@ -25,7 +28,6 @@
 
 @RunWith(RobolectricTestRunner.class)
 public class BluetoothDetailsMacAddressControllerTest extends BluetoothDetailsControllerTestBase {
-
   private BluetoothDetailsMacAddressController mController;
 
   @Override
@@ -34,6 +36,7 @@
     mController =
         new BluetoothDetailsMacAddressController(mContext, mFragment, mCachedDevice, mLifecycle);
     setupDevice(mDeviceConfig);
+    Utils.addFooterPreference(mContext, mScreen, KEY_DEVICE_DETAILS_FOOTER, null /* title */);
   }
 
   @Test
diff --git a/tests/robotests/src/com/android/settings/datausage/BillingCycleSettingsTest.java b/tests/robotests/src/com/android/settings/datausage/BillingCycleSettingsTest.java
index 2c0155f..eea6388 100644
--- a/tests/robotests/src/com/android/settings/datausage/BillingCycleSettingsTest.java
+++ b/tests/robotests/src/com/android/settings/datausage/BillingCycleSettingsTest.java
@@ -47,8 +47,6 @@
 
 import com.android.settings.testutils.shadow.ShadowFragment;
 import com.android.settingslib.NetworkPolicyEditor;
-import com.android.settingslib.widget.FooterPreference;
-import com.android.settingslib.widget.FooterPreferenceMixinCompat;
 
 import org.junit.Before;
 import org.junit.Test;
@@ -58,7 +56,6 @@
 import org.robolectric.RobolectricTestRunner;
 import org.robolectric.RuntimeEnvironment;
 import org.robolectric.annotation.Config;
-import org.robolectric.util.ReflectionHelpers;
 
 @RunWith(RobolectricTestRunner.class)
 public class BillingCycleSettingsTest {
@@ -162,9 +159,6 @@
         when(mConnectivityManager.isNetworkSupported(anyInt())).thenReturn(true);
         final SwitchPreference preference = mock(SwitchPreference.class);
         when(billingCycleSettings.findPreference(anyString())).thenReturn(preference);
-        final FooterPreferenceMixinCompat footer = mock(FooterPreferenceMixinCompat.class);
-        ReflectionHelpers.setField(billingCycleSettings, "mFooterPreferenceMixin", footer);
-        when(footer.createFooterPreference()).thenReturn(mock(FooterPreference.class));
 
         billingCycleSettings.onCreate(Bundle.EMPTY);
 
diff --git a/tests/robotests/src/com/android/settings/testutils/shadow/ShadowAuthenticationHelper.java b/tests/robotests/src/com/android/settings/testutils/shadow/ShadowAuthenticationHelper.java
new file mode 100644
index 0000000..cb7da56
--- /dev/null
+++ b/tests/robotests/src/com/android/settings/testutils/shadow/ShadowAuthenticationHelper.java
@@ -0,0 +1,80 @@
+/*
+ * Copyright (C) 2019 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.testutils.shadow;
+
+import android.content.Context;
+import android.graphics.drawable.Drawable;
+import android.os.UserHandle;
+import android.text.TextUtils;
+
+import com.android.settingslib.accounts.AuthenticatorHelper;
+
+import org.robolectric.annotation.Implementation;
+import org.robolectric.annotation.Implements;
+import org.robolectric.annotation.Resetter;
+
+@Implements(AuthenticatorHelper.class)
+public class ShadowAuthenticationHelper {
+    static final String[] TYPES = {"type1", "type2", "type3", "type4"};
+    static final String[] LABELS = {"LABEL1", "LABEL2", "LABEL3", "LABEL4"};
+    private static String[] sEnabledAccount = TYPES;
+
+    protected void __constructor__(Context context, UserHandle userHandle,
+            AuthenticatorHelper.OnAccountsUpdateListener listener) {
+    }
+
+    public static void setEnabledAccount(String[] enabledAccount) {
+        sEnabledAccount = enabledAccount;
+    }
+
+    @Resetter
+    public static void reset() {
+        sEnabledAccount = TYPES;
+    }
+
+    @Implementation
+    protected String[] getEnabledAccountTypes() {
+        return sEnabledAccount;
+    }
+
+    @Implementation
+    protected CharSequence getLabelForType(Context context, final String accountType) {
+        if (TextUtils.equals(accountType, TYPES[0])) {
+            return LABELS[0];
+        } else if (TextUtils.equals(accountType, TYPES[1])) {
+            return LABELS[1];
+        } else if (TextUtils.equals(accountType, TYPES[2])) {
+            return LABELS[2];
+        } else if (TextUtils.equals(accountType, TYPES[3])) {
+            return LABELS[3];
+        }
+        return null;
+    }
+
+    @Implementation
+    protected Drawable getDrawableForType(Context context, final String accountType) {
+        return context.getPackageManager().getDefaultActivityIcon();
+    }
+
+    public static String[] getTypes() {
+        return TYPES;
+    }
+
+    public static String[] getLabels() {
+        return LABELS;
+    }
+}