Revert "Support highlightable Settings homepage menu for 2-pane"

This reverts commit 9037ceabd314f8d2b55144acffa780e7ba92291f.

Reason for revert: Presumed cause of b/202510128

Change-Id: I0daaab95d9bc57229c0c8c916cbe3ada7aafb6fa
diff --git a/src/com/android/settings/Settings.java b/src/com/android/settings/Settings.java
index a892b97..cc9542b 100644
--- a/src/com/android/settings/Settings.java
+++ b/src/com/android/settings/Settings.java
@@ -83,8 +83,7 @@
     }
 
     public static class VpnSettingsActivity extends SettingsActivity { /* empty */ }
-    /** Activity for Data saver settings. */
-    public static class DataSaverSummaryActivity extends SettingsActivity { /* empty */ }
+    public static class DataSaverSummaryActivity extends SettingsActivity{ /* empty */ }
     public static class DateTimeSettingsActivity extends SettingsActivity { /* empty */ }
     public static class PrivateVolumeForgetActivity extends SettingsActivity { /* empty */ }
     public static class PublicVolumeSettingsActivity extends SettingsActivity { /* empty */ }
@@ -122,9 +121,13 @@
     public static class AccessibilityInversionSettingsActivity extends SettingsActivity { /* empty */ }
     public static class AccessibilityContrastSettingsActivity extends SettingsActivity { /* empty */ }
     public static class AccessibilityDaltonizerSettingsActivity extends SettingsActivity { /* empty */ }
-    /** Activity for lockscreen settings. */
+    /**
+     * Activity for lockscreen settings.
+     */
     public static class LockScreenSettingsActivity extends SettingsActivity { /* empty */ }
-    /** Activity for Reduce Bright Colors. */
+    /**
+     * Activity for Reduce Bright Colors.
+     */
     public static class ReduceBrightColorsSettingsActivity extends SettingsActivity { /* empty */ }
     /** Activity for the security dashboard. */
     public static class SecurityDashboardActivity extends SettingsActivity {
diff --git a/src/com/android/settings/SettingsActivity.java b/src/com/android/settings/SettingsActivity.java
index c105238..634a646 100644
--- a/src/com/android/settings/SettingsActivity.java
+++ b/src/com/android/settings/SettingsActivity.java
@@ -149,13 +149,9 @@
     public static final String META_DATA_KEY_FRAGMENT_CLASS =
             "com.android.settings.FRAGMENT_CLASS";
 
-    public static final String META_DATA_KEY_HIGHLIGHT_MENU_KEY =
-            "com.android.settings.HIGHLIGHT_MENU_KEY";
-
     private static final String EXTRA_UI_OPTIONS = "settings:ui_options";
 
     private String mFragmentClass;
-    private String mHighlightMenuKey;
 
     private CharSequence mInitialTitle;
     private int mInitialTitleResId;
@@ -238,19 +234,21 @@
         super.onCreate(savedState);
         Log.d(LOG_TAG, "Starting onCreate");
 
-        long startTime = System.currentTimeMillis();
-
-        // Should happen before any call to getIntent()
-        getMetaData();
-        final Intent intent = getIntent();
-        if (launchHomepageForTwoPaneDeepLink(intent)) {
+        if (launchHomepageForTwonPaneDeepLink()) {
             finish();
             return;
         }
 
+        long startTime = System.currentTimeMillis();
+
         final FeatureFactory factory = FeatureFactory.getFactory(this);
+
         mDashboardFeatureProvider = factory.getDashboardFeatureProvider(this);
 
+        // Should happen before any call to getIntent()
+        getMetaData();
+
+        final Intent intent = getIntent();
         if (intent.hasExtra(EXTRA_UI_OPTIONS)) {
             getWindow().setUiOptions(intent.getIntExtra(EXTRA_UI_OPTIONS, 0));
         }
@@ -357,7 +355,8 @@
     }
 
     /** Returns true if the Activity is started by a deep link intent for large screen devices. */
-    private boolean launchHomepageForTwoPaneDeepLink(Intent intent) {
+    private boolean launchHomepageForTwonPaneDeepLink() {
+        final Intent intent = getIntent();
         if (!shouldShowTwoPaneDeepLink(intent)) {
             return false;
         }
@@ -369,9 +368,6 @@
         trampolineIntent.putExtra(
                 android.provider.Settings.EXTRA_SETTINGS_LARGE_SCREEN_DEEP_LINK_INTENT_URI,
                 intent.toUri(Intent.URI_INTENT_SCHEME));
-        trampolineIntent.putExtra(
-                android.provider.Settings.EXTRA_SETTINGS_LARGE_SCREEN_HIGHLIGHT_MENU_KEY,
-                mHighlightMenuKey);
         trampolineIntent.addFlags(Intent.FLAG_ACTIVITY_FORWARD_RESULT);
         startActivity(trampolineIntent);
 
@@ -780,7 +776,6 @@
                     PackageManager.GET_META_DATA);
             if (ai == null || ai.metaData == null) return;
             mFragmentClass = ai.metaData.getString(META_DATA_KEY_FRAGMENT_CLASS);
-            mHighlightMenuKey = ai.metaData.getString(META_DATA_KEY_HIGHLIGHT_MENU_KEY);
         } catch (NameNotFoundException nnfe) {
             // No recovery
             Log.d(LOG_TAG, "Cannot get Metadata for: " + getComponentName().toString());
diff --git a/src/com/android/settings/SettingsPreferenceFragment.java b/src/com/android/settings/SettingsPreferenceFragment.java
index 1d6a48d..b8ff60c 100644
--- a/src/com/android/settings/SettingsPreferenceFragment.java
+++ b/src/com/android/settings/SettingsPreferenceFragment.java
@@ -119,7 +119,8 @@
 
     @VisibleForTesting
     public HighlightablePreferenceGroupAdapter mAdapter;
-    private boolean mPreferenceHighlighted = false;
+    @VisibleForTesting
+    public boolean mPreferenceHighlighted = false;
 
     @Override
     public void onCreate(Bundle icicle) {
diff --git a/src/com/android/settings/Utils.java b/src/com/android/settings/Utils.java
index 6886154..72bfa11 100644
--- a/src/com/android/settings/Utils.java
+++ b/src/com/android/settings/Utils.java
@@ -1223,14 +1223,6 @@
         return getColorAttrDefaultColor(context, android.R.attr.textColorSecondary);
     }
 
-    /**
-     * Returns the highlight color of homepage preference icons.
-     */
-    @ColorInt
-    public static int getHomepageIconColorHighlight(Context context) {
-        return getColorAttrDefaultColor(context, android.R.attr.textColorSecondaryInverse);
-    }
-
     public static boolean isProviderModelEnabled(Context context) {
         return FeatureFlagUtils.isEnabled(context, FeatureFlagUtils.SETTINGS_PROVIDER_MODEL);
     }
diff --git a/src/com/android/settings/activityembedding/ActivityEmbeddingUtils.java b/src/com/android/settings/activityembedding/ActivityEmbeddingUtils.java
index 7ecacde..ab999ed 100644
--- a/src/com/android/settings/activityembedding/ActivityEmbeddingUtils.java
+++ b/src/com/android/settings/activityembedding/ActivityEmbeddingUtils.java
@@ -62,12 +62,4 @@
 
         return isFlagEnabled && isSplitSupported;
     }
-
-    /** Whether the screen meets two-pane resolution. */
-    public static boolean isTwoPaneResolution(Context context) {
-        final Context appContext = context.getApplicationContext();
-        final DisplayMetrics dm = appContext.getResources().getDisplayMetrics();
-        return dm.widthPixels >= getMinCurrentScreenSplitWidthPx(appContext)
-                && dm.heightPixels >= getMinSmallestScreenSplitWidthPx(appContext);
-    }
 }
diff --git a/src/com/android/settings/dashboard/CategoryManager.java b/src/com/android/settings/dashboard/CategoryManager.java
index 1559a42..2a82abe 100644
--- a/src/com/android/settings/dashboard/CategoryManager.java
+++ b/src/com/android/settings/dashboard/CategoryManager.java
@@ -17,7 +17,6 @@
 
 import android.content.ComponentName;
 import android.content.Context;
-import android.text.TextUtils;
 import android.util.ArrayMap;
 import android.util.ArraySet;
 import android.util.Log;
@@ -25,7 +24,6 @@
 
 import androidx.annotation.VisibleForTesting;
 
-import com.android.settings.homepage.HighlightableMenu;
 import com.android.settingslib.applications.InterestingConfigChanges;
 import com.android.settingslib.drawer.CategoryKey;
 import com.android.settingslib.drawer.DashboardCategory;
@@ -155,14 +153,6 @@
             filterDuplicateTiles(mCategoryByKeyMap);
             if (firstLoading) {
                 logTiles(context);
-                for (Tile tile : mCategoryByKeyMap.get(CategoryKey.CATEGORY_HOMEPAGE).getTiles()) {
-                    final String key = tile.getKey(context);
-                    if (TextUtils.isEmpty(key)) {
-                        Log.w(TAG, "Key hint missing for homepage tile: " + tile.getTitle(context));
-                        continue;
-                    }
-                    HighlightableMenu.addMenuKey(key);
-                }
             }
         }
     }
diff --git a/src/com/android/settings/dashboard/DashboardFeatureProvider.java b/src/com/android/settings/dashboard/DashboardFeatureProvider.java
index b88ecd4..8c872f0 100644
--- a/src/com/android/settings/dashboard/DashboardFeatureProvider.java
+++ b/src/com/android/settings/dashboard/DashboardFeatureProvider.java
@@ -47,9 +47,9 @@
      * Binds preference to data provided by tile and gets dynamic data observers.
      *
      * @param activity If tile contains intent to launch, it will be launched from this activity
-     * @param fragment The fragment that the preference will be bound to
      * @param forceRoundedIcon Whether or not injected tiles from other packages should be forced to
      * rounded icon.
+     * @param sourceMetricsCategory The context (source) from which an action is performed
      * @param pref The preference to bind data
      * @param tile The binding data
      * @param key They key for preference. If null, we will generate one from tile data
@@ -58,7 +58,7 @@
      * @return The list of dynamic data observers
      */
     List<DynamicDataObserver> bindPreferenceToTileAndGetObservers(FragmentActivity activity,
-            DashboardFragment fragment, boolean forceRoundedIcon, Preference pref, Tile tile,
+            boolean forceRoundedIcon, int sourceMetricsCategory, Preference pref, Tile tile,
             String key, int baseOrder);
 
     /**
diff --git a/src/com/android/settings/dashboard/DashboardFeatureProviderImpl.java b/src/com/android/settings/dashboard/DashboardFeatureProviderImpl.java
index 4efe03d..4581f6c 100644
--- a/src/com/android/settings/dashboard/DashboardFeatureProviderImpl.java
+++ b/src/com/android/settings/dashboard/DashboardFeatureProviderImpl.java
@@ -36,7 +36,6 @@
 import android.app.settings.SettingsEnums;
 import android.content.ComponentName;
 import android.content.Context;
-import android.content.DialogInterface.OnCancelListener;
 import android.content.IContentProvider;
 import android.content.Intent;
 import android.content.pm.PackageManager;
@@ -61,7 +60,6 @@
 import com.android.settings.SettingsActivity;
 import com.android.settings.Utils;
 import com.android.settings.dashboard.profileselector.ProfileSelectDialog;
-import com.android.settings.homepage.TopLevelSettings;
 import com.android.settings.overlay.FeatureFactory;
 import com.android.settings.widget.PrimarySwitchPreference;
 import com.android.settingslib.core.instrumentation.MetricsFeatureProvider;
@@ -125,7 +123,7 @@
 
     @Override
     public List<DynamicDataObserver> bindPreferenceToTileAndGetObservers(FragmentActivity activity,
-            DashboardFragment fragment, boolean forceRoundedIcon, Preference pref, Tile tile,
+            boolean forceRoundedIcon, int sourceMetricsCategory, Preference pref, Tile tile,
             String key, int baseOrder) {
         if (pref == null) {
             return null;
@@ -151,7 +149,6 @@
         bindIcon(pref, tile, forceRoundedIcon);
 
         if (tile instanceof ActivityTile) {
-            final int sourceMetricsCategory = fragment.getMetricsCategory();
             final Bundle metadata = tile.getMetaData();
             String clsName = null;
             String action = null;
@@ -169,17 +166,7 @@
                     intent.setAction(action);
                 }
                 pref.setOnPreferenceClickListener(preference -> {
-                    OnCancelListener listener = null;
-                    if (fragment instanceof TopLevelSettings) {
-                        final TopLevelSettings topLevelSettings = (TopLevelSettings) fragment;
-                        // Highlight the tile immediately whenever it's clicked
-                        topLevelSettings.setHighlightPreferenceKey(key);
-                        // If the tile allows users to select profile, the pop-op dialog may be
-                        // cancelled and then the previous highlight entry should be restored.
-                        listener = dialog -> topLevelSettings.restorePreviousHighlight();
-                    }
-                    launchIntentOrSelectProfile(activity, tile, intent, sourceMetricsCategory,
-                            listener);
+                    launchIntentOrSelectProfile(activity, tile, intent, sourceMetricsCategory);
                     return true;
                 });
             }
@@ -211,8 +198,7 @@
                 .putExtra(MetricsFeatureProvider.EXTRA_SOURCE_METRICS_CATEGORY,
                         SettingsEnums.DASHBOARD_SUMMARY)
                 .addFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK);
-        launchIntentOrSelectProfile(activity, tile, intent, SettingsEnums.DASHBOARD_SUMMARY,
-                /* listener= */ null);
+        launchIntentOrSelectProfile(activity, tile, intent, SettingsEnums.DASHBOARD_SUMMARY);
     }
 
     private DynamicDataObserver createDynamicDataObserver(String method, Uri uri, Preference pref) {
@@ -427,7 +413,7 @@
     }
 
     private void launchIntentOrSelectProfile(FragmentActivity activity, Tile tile, Intent intent,
-            int sourceMetricCategory, OnCancelListener listener) {
+            int sourceMetricCategory) {
         if (!isIntentResolvable(intent)) {
             Log.w(TAG, "Cannot resolve intent, skipping. " + intent);
             return;
@@ -453,7 +439,7 @@
             }
 
             ProfileSelectDialog.show(activity.getSupportFragmentManager(), tile,
-                    sourceMetricCategory, listener);
+                    sourceMetricCategory);
         }
     }
 
diff --git a/src/com/android/settings/dashboard/DashboardFragment.java b/src/com/android/settings/dashboard/DashboardFragment.java
index 4317fc6..dfd931d 100644
--- a/src/com/android/settings/dashboard/DashboardFragment.java
+++ b/src/com/android/settings/dashboard/DashboardFragment.java
@@ -496,15 +496,15 @@
             if (mDashboardTilePrefKeys.containsKey(key)) {
                 // Have the key already, will rebind.
                 final Preference preference = screen.findPreference(key);
-                mDashboardFeatureProvider.bindPreferenceToTileAndGetObservers(getActivity(), this,
-                        forceRoundedIcons, preference, tile, key,
+                mDashboardFeatureProvider.bindPreferenceToTileAndGetObservers(getActivity(),
+                        forceRoundedIcons, getMetricsCategory(), preference, tile, key,
                         mPlaceholderPreferenceController.getOrder());
             } else {
                 // Don't have this key, add it.
                 final Preference pref = createPreference(tile);
                 final List<DynamicDataObserver> observers =
                         mDashboardFeatureProvider.bindPreferenceToTileAndGetObservers(getActivity(),
-                                this, forceRoundedIcons, pref, tile, key,
+                                forceRoundedIcons, getMetricsCategory(), pref, tile, key,
                                 mPlaceholderPreferenceController.getOrder());
                 screen.addPreference(pref);
                 registerDynamicDataObservers(observers);
diff --git a/src/com/android/settings/dashboard/profileselector/ProfileSelectDialog.java b/src/com/android/settings/dashboard/profileselector/ProfileSelectDialog.java
index b05f23b..36cdd42 100644
--- a/src/com/android/settings/dashboard/profileselector/ProfileSelectDialog.java
+++ b/src/com/android/settings/dashboard/profileselector/ProfileSelectDialog.java
@@ -19,7 +19,6 @@
 import android.app.Dialog;
 import android.content.Context;
 import android.content.DialogInterface;
-import android.content.DialogInterface.OnCancelListener;
 import android.content.DialogInterface.OnClickListener;
 import android.content.Intent;
 import android.os.Bundle;
@@ -45,23 +44,19 @@
 
     private int mSourceMetricCategory;
     private Tile mSelectedTile;
-    private OnCancelListener mOnCancelListener;
 
     /**
      * Display the profile select dialog, adding the fragment to the given FragmentManager.
      * @param manager The FragmentManager this fragment will be added to.
      * @param tile The tile for this fragment.
      * @param sourceMetricCategory The source metric category.
-     * @param listener The listener listens to the dialog cancelling event.
      */
-    public static void show(FragmentManager manager, Tile tile, int sourceMetricCategory,
-            OnCancelListener listener) {
+    public static void show(FragmentManager manager, Tile tile, int sourceMetricCategory) {
         final ProfileSelectDialog dialog = new ProfileSelectDialog();
         final Bundle args = new Bundle();
         args.putParcelable(ARG_SELECTED_TILE, tile);
         args.putInt(ARG_SOURCE_METRIC_CATEGORY, sourceMetricCategory);
         dialog.setArguments(args);
-        dialog.mOnCancelListener = listener;
         dialog.show(manager, "select_profile");
     }
 
@@ -96,13 +91,6 @@
         getActivity().startActivityAsUser(intent, user);
     }
 
-    @Override
-    public void onCancel(DialogInterface dialog) {
-        if (mOnCancelListener != null) {
-            mOnCancelListener.onCancel(dialog);
-        }
-    }
-
     public static void updateUserHandlesIfNeeded(Context context, Tile tile) {
         final List<UserHandle> userHandles = tile.userHandle;
         if (tile.userHandle == null || tile.userHandle.size() <= 1) {
diff --git a/src/com/android/settings/homepage/HighlightableMenu.java b/src/com/android/settings/homepage/HighlightableMenu.java
deleted file mode 100644
index 6a10e66..0000000
--- a/src/com/android/settings/homepage/HighlightableMenu.java
+++ /dev/null
@@ -1,117 +0,0 @@
-/*
- * Copyright (C) 2021 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.homepage;
-
-import static com.android.settings.core.PreferenceXmlParserUtils.METADATA_HIGHLIGHTABLE_MENU_KEY;
-import static com.android.settings.core.PreferenceXmlParserUtils.METADATA_KEY;
-
-import android.annotation.XmlRes;
-import android.content.Context;
-import android.os.Bundle;
-import android.text.TextUtils;
-import android.util.ArrayMap;
-import android.util.Log;
-
-import com.android.settings.core.PreferenceXmlParserUtils;
-import com.android.settings.core.PreferenceXmlParserUtils.MetadataFlag;
-
-import org.xmlpull.v1.XmlPullParserException;
-
-import java.io.IOException;
-import java.util.List;
-import java.util.Map;
-
-/**
- *  Class for mapping highlightable menu keys and preference keys
- */
-public class HighlightableMenu {
-    private static final String TAG = "HighlightableMenu";
-
-    /**
-     * Map from highlightable menu key to preference key.
-     */
-    private static final Map<String, String> MENU_TO_PREFERENCE_KEY_MAP;
-
-    /**
-     * Map from old menu key to current key string id.
-     */
-    private static final Map<String, Integer> MENU_KEY_COMPAT_MAP;
-
-    private static boolean sXmlParsed;
-
-    static {
-        MENU_TO_PREFERENCE_KEY_MAP = new ArrayMap<>();
-        MENU_KEY_COMPAT_MAP = new ArrayMap<>();
-
-        // Manual mapping for platform compatibility, e.g.
-        //  MENU_KEY_COMPAT_MAP.put("top_level_apps_and_notifs", R.string.menu_key_apps);
-    }
-
-    /** Parses the highlightable menu keys from xml */
-    public static synchronized void fromXml(Context context, @XmlRes int xmlResId) {
-        if (sXmlParsed) {
-            return;
-        }
-
-        Log.d(TAG, "parsing highlightable menu from xml");
-        final List<Bundle> preferenceMetadata;
-        try {
-            preferenceMetadata = PreferenceXmlParserUtils.extractMetadata(context, xmlResId,
-                    MetadataFlag.FLAG_NEED_KEY | MetadataFlag.FLAG_NEED_HIGHLIGHTABLE_MENU_KEY);
-        } catch (IOException | XmlPullParserException e) {
-            Log.e(TAG, "Failed to parse preference xml for getting highlightable menu keys", e);
-            return;
-        }
-
-        for (Bundle metadata : preferenceMetadata) {
-            final String menuKey = metadata.getString(METADATA_HIGHLIGHTABLE_MENU_KEY);
-            if (TextUtils.isEmpty(menuKey)) {
-                continue;
-            }
-            final String prefKey = metadata.getString(METADATA_KEY);
-            if (TextUtils.isEmpty(prefKey)) {
-                Log.w(TAG, "Highlightable menu requires android:key but it's missing in xml: "
-                        + menuKey);
-                continue;
-            }
-            MENU_TO_PREFERENCE_KEY_MAP.put(menuKey, prefKey);
-        }
-
-        if (MENU_TO_PREFERENCE_KEY_MAP.isEmpty()) {
-            return;
-        }
-
-        sXmlParsed = true;
-        MENU_KEY_COMPAT_MAP.forEach((compatMenuKey, keyId) -> {
-            final String prefKey = lookupPreferenceKey(context.getString(keyId));
-            if (prefKey != null) {
-                MENU_TO_PREFERENCE_KEY_MAP.put(compatMenuKey, prefKey);
-            }
-        });
-    }
-
-    /** Manually adds a preference as the menu key for Injection */
-    public static synchronized void addMenuKey(String key) {
-        Log.d(TAG, "add menu key: " + key);
-        MENU_TO_PREFERENCE_KEY_MAP.put(key, key);
-    }
-
-    /** Looks up the preference key by a specified menu key */
-    public static String lookupPreferenceKey(String menuKey) {
-        return MENU_TO_PREFERENCE_KEY_MAP.get(menuKey);
-    }
-}
diff --git a/src/com/android/settings/homepage/SettingsHomepageActivity.java b/src/com/android/settings/homepage/SettingsHomepageActivity.java
index e48c82f..d6a8a92 100644
--- a/src/com/android/settings/homepage/SettingsHomepageActivity.java
+++ b/src/com/android/settings/homepage/SettingsHomepageActivity.java
@@ -16,15 +16,13 @@
 
 package com.android.settings.homepage;
 
-import static android.provider.Settings.ACTION_SETTINGS_LARGE_SCREEN_DEEP_LINK;
-import static android.provider.Settings.EXTRA_SETTINGS_LARGE_SCREEN_DEEP_LINK_INTENT_URI;
-import static android.provider.Settings.EXTRA_SETTINGS_LARGE_SCREEN_HIGHLIGHT_MENU_KEY;
-
 import android.animation.LayoutTransition;
 import android.app.ActivityManager;
+import android.app.PendingIntent;
 import android.app.settings.SettingsEnums;
 import android.content.ComponentName;
 import android.content.Intent;
+import android.content.pm.PackageManager;
 import android.os.Bundle;
 import android.text.TextUtils;
 import android.util.FeatureFlagUtils;
@@ -38,16 +36,16 @@
 import androidx.fragment.app.FragmentActivity;
 import androidx.fragment.app.FragmentManager;
 import androidx.fragment.app.FragmentTransaction;
+import androidx.window.embedding.SplitController;
 
 import com.android.settings.R;
 import com.android.settings.Settings;
-import com.android.settings.SettingsActivity;
 import com.android.settings.Utils;
 import com.android.settings.accounts.AvatarViewMixin;
-import com.android.settings.activityembedding.ActivityEmbeddingRulesController;
-import com.android.settings.activityembedding.ActivityEmbeddingUtils;
 import com.android.settings.core.CategoryMixin;
 import com.android.settings.core.FeatureFlags;
+import com.android.settings.activityembedding.ActivityEmbeddingRulesController;
+import com.android.settings.activityembedding.ActivityEmbeddingUtils;
 import com.android.settings.homepage.contextualcards.ContextualCardsFragment;
 import com.android.settings.overlay.FeatureFactory;
 import com.android.settingslib.core.lifecycle.HideNonSystemOverlayMixin;
@@ -66,7 +64,6 @@
     // An alias class name of SettingsHomepageActivity.
     public static final String ALIAS_DEEP_LINK = "com.android.settings.DeepLinkHomepageActivity";
 
-    private static final int DEFAULT_HIGHLIGHT_MENU_KEY = R.string.menu_key_network;
     private static final long HOMEPAGE_LOADING_TIMEOUT_MS = 300;
 
     private View mHomepageView;
@@ -123,11 +120,7 @@
                 showFragment(new ContextualCardsFragment(), R.id.contextual_cards_content);
             }
         }
-        final Fragment fragment = new TopLevelSettings();
-        fragment.getArguments().putString(SettingsActivity.EXTRA_FRAGMENT_ARG_KEY,
-                getHighlightMenuKey());
-        showFragment(fragment, R.id.main_content);
-
+        showFragment(new TopLevelSettings(), R.id.main_content);
         ((FrameLayout) findViewById(R.id.main_content))
                 .getLayoutTransition().enableTransitionType(LayoutTransition.CHANGING);
 
@@ -139,13 +132,9 @@
     protected void onNewIntent(Intent intent) {
         super.onNewIntent(intent);
 
-        // When it's large screen 2-pane and Settings app is in the background, receiving an Intent
-        // will not recreate this activity. Update the intent for this case.
+        // When it's large screen 2-pane and Settings app is in background. Receiving a Intent
+        // in this Activity will not finish nor onCreate. setIntent here for this case.
         setIntent(intent);
-        reloadHighlightMenuKey();
-        if (isFinishing()) {
-            return;
-        }
         // Launch the intent from deep link for large screen devices.
         launchDeepLinkIntentToRight();
     }
@@ -191,12 +180,12 @@
 
         final Intent intent = getIntent();
         if (intent == null || !TextUtils.equals(intent.getAction(),
-                ACTION_SETTINGS_LARGE_SCREEN_DEEP_LINK)) {
+                android.provider.Settings.ACTION_SETTINGS_LARGE_SCREEN_DEEP_LINK)) {
             return;
         }
 
         final String intentUriString = intent.getStringExtra(
-                EXTRA_SETTINGS_LARGE_SCREEN_DEEP_LINK_INTENT_URI);
+                android.provider.Settings.EXTRA_SETTINGS_LARGE_SCREEN_DEEP_LINK_INTENT_URI);
         if (TextUtils.isEmpty(intentUriString)) {
             Log.e(TAG, "No EXTRA_SETTINGS_LARGE_SCREEN_DEEP_LINK_INTENT_URI to deep link");
             finish();
@@ -244,29 +233,6 @@
         startActivity(targetIntent);
     }
 
-    private String getHighlightMenuKey() {
-        final Intent intent = getIntent();
-        if (intent != null && TextUtils.equals(intent.getAction(),
-                ACTION_SETTINGS_LARGE_SCREEN_DEEP_LINK)) {
-            final String menuKey = intent.getStringExtra(
-                    EXTRA_SETTINGS_LARGE_SCREEN_HIGHLIGHT_MENU_KEY);
-            if (!TextUtils.isEmpty(menuKey)) {
-                return menuKey;
-            }
-        }
-        return getString(DEFAULT_HIGHLIGHT_MENU_KEY);
-    }
-
-    private void reloadHighlightMenuKey() {
-        final TopLevelSettings fragment =
-                (TopLevelSettings) getSupportFragmentManager().findFragmentById(R.id.main_content);
-        if (fragment != null) {
-            fragment.getArguments().putString(SettingsActivity.EXTRA_FRAGMENT_ARG_KEY,
-                    getHighlightMenuKey());
-            fragment.reloadHighlightMenuKey();
-        }
-    }
-
     private void initHomepageContainer() {
         final View view = findViewById(R.id.homepage_container);
         // Prevent inner RecyclerView gets focus and invokes scrolling.
diff --git a/src/com/android/settings/homepage/TopLevelSettings.java b/src/com/android/settings/homepage/TopLevelSettings.java
index a819b87..681ea51 100644
--- a/src/com/android/settings/homepage/TopLevelSettings.java
+++ b/src/com/android/settings/homepage/TopLevelSettings.java
@@ -21,27 +21,20 @@
 
 import android.app.settings.SettingsEnums;
 import android.content.Context;
-import android.content.res.Configuration;
 import android.graphics.drawable.Drawable;
 import android.os.Bundle;
-import android.text.TextUtils;
-import android.util.Log;
 
 import androidx.fragment.app.Fragment;
 import androidx.preference.Preference;
 import androidx.preference.PreferenceFragmentCompat;
 import androidx.preference.PreferenceScreen;
-import androidx.recyclerview.widget.RecyclerView;
 
 import com.android.settings.R;
-import com.android.settings.SettingsActivity;
 import com.android.settings.Utils;
-import com.android.settings.activityembedding.ActivityEmbeddingUtils;
 import com.android.settings.core.SubSettingLauncher;
 import com.android.settings.dashboard.DashboardFragment;
 import com.android.settings.search.BaseSearchIndexProvider;
 import com.android.settings.support.SupportPreferenceController;
-import com.android.settings.widget.HighlightableTopLevelPreferenceAdapter;
 import com.android.settingslib.core.instrumentation.Instrumentable;
 import com.android.settingslib.search.SearchIndexable;
 
@@ -50,11 +43,6 @@
         PreferenceFragmentCompat.OnPreferenceStartFragmentCallback {
 
     private static final String TAG = "TopLevelSettings";
-    private static final String SAVED_HIGHLIGHTED_PREF = "highlighted_pref";
-
-    private HighlightableTopLevelPreferenceAdapter mTopLevelAdapter;
-
-    private String mHighlightedPreferenceKey;
 
     public TopLevelSettings() {
         final Bundle args = new Bundle();
@@ -81,7 +69,6 @@
     @Override
     public void onAttach(Context context) {
         super.onAttach(context);
-        HighlightableMenu.fromXml(context, getPreferenceScreenResId());
         use(SupportPreferenceController.class).setActivity(getActivity());
     }
 
@@ -97,12 +84,6 @@
     }
 
     @Override
-    public boolean onPreferenceTreeClick(Preference preference) {
-        setHighlightPreferenceKey(preference.getKey());
-        return super.onPreferenceTreeClick(preference);
-    }
-
-    @Override
     public boolean onPreferenceStartFragment(PreferenceFragmentCompat caller, Preference pref) {
         new SubSettingLauncher(getActivity())
                 .setDestination(pref.getFragment())
@@ -116,20 +97,6 @@
     }
 
     @Override
-    public void onCreate(Bundle icicle) {
-        super.onCreate(icicle);
-        if (icicle != null) {
-            mHighlightedPreferenceKey = icicle.getString(SAVED_HIGHLIGHTED_PREF);
-        }
-    }
-
-    @Override
-    public void onSaveInstanceState(Bundle outState) {
-        super.onSaveInstanceState(outState);
-        outState.putString(SAVED_HIGHLIGHTED_PREF, mHighlightedPreferenceKey);
-    }
-
-    @Override
     public void onCreatePreferences(Bundle savedInstanceState, String rootKey) {
         super.onCreatePreferences(savedInstanceState, rootKey);
         final PreferenceScreen screen = getPreferenceScreen();
@@ -152,77 +119,11 @@
     }
 
     @Override
-    public void onConfigurationChanged(Configuration newConfig) {
-        super.onConfigurationChanged(newConfig);
-        highlightPreferenceIfNeeded();
-    }
-
-    @Override
-    public void highlightPreferenceIfNeeded() {
-        if (mTopLevelAdapter != null) {
-            mTopLevelAdapter.requestHighlight();
-        }
-    }
-
-    /** Highlight a preference with specified key */
-    public void setHighlightPreferenceKey(String prefKey) {
-        if (mTopLevelAdapter != null) {
-            mHighlightedPreferenceKey = prefKey;
-            mTopLevelAdapter.highlightPreference(prefKey, /* scrollNeeded= */ false);
-        }
-    }
-
-    /** Highlight the previous preference */
-    public void restorePreviousHighlight() {
-        if (mTopLevelAdapter != null) {
-            mTopLevelAdapter.restorePreviousHighlight();
-        }
-    }
-
-    @Override
     protected boolean shouldForceRoundedIcon() {
         return getContext().getResources()
                 .getBoolean(R.bool.config_force_rounded_icon_TopLevelSettings);
     }
 
-    @Override
-    protected RecyclerView.Adapter onCreateAdapter(PreferenceScreen preferenceScreen) {
-        if (!ActivityEmbeddingUtils.isEmbeddingActivityEnabled(getContext())) {
-            return super.onCreateAdapter(preferenceScreen);
-        }
-
-        if (TextUtils.isEmpty(mHighlightedPreferenceKey)) {
-            mHighlightedPreferenceKey = getHighlightPrefKeyFromArguments();
-        }
-
-        Log.d(TAG, "onCreateAdapter, pref key: " + mHighlightedPreferenceKey);
-        mTopLevelAdapter = new HighlightableTopLevelPreferenceAdapter(preferenceScreen,
-                getListView(), mHighlightedPreferenceKey);
-        return mTopLevelAdapter;
-    }
-
-    void reloadHighlightMenuKey() {
-        if (mTopLevelAdapter == null) {
-            return;
-        }
-
-        mHighlightedPreferenceKey = getHighlightPrefKeyFromArguments();
-        Log.d(TAG, "reloadHighlightMenuKey, pref key: " + mHighlightedPreferenceKey);
-        mTopLevelAdapter.highlightPreference(mHighlightedPreferenceKey, /* scrollNeeded= */ true);
-    }
-
-    private String getHighlightPrefKeyFromArguments() {
-        final Bundle arguments = getArguments();
-        final String menuKey = arguments.getString(SettingsActivity.EXTRA_FRAGMENT_ARG_KEY);
-        final String prefKey = HighlightableMenu.lookupPreferenceKey(menuKey);
-        if (TextUtils.isEmpty(prefKey)) {
-            Log.e(TAG, "Invalid highlight menu key: " + menuKey);
-        } else {
-            Log.d(TAG, "Menu key: " + menuKey);
-        }
-        return prefKey;
-    }
-
     public static final BaseSearchIndexProvider SEARCH_INDEX_DATA_PROVIDER =
             new BaseSearchIndexProvider(R.xml.top_level_settings) {
 
diff --git a/src/com/android/settings/search/SearchFeatureProviderImpl.java b/src/com/android/settings/search/SearchFeatureProviderImpl.java
index 6f90970..508d37d 100644
--- a/src/com/android/settings/search/SearchFeatureProviderImpl.java
+++ b/src/com/android/settings/search/SearchFeatureProviderImpl.java
@@ -50,7 +50,7 @@
         if (isSettingsPackage || isAllowlistedPackage) {
             return;
         }
-        throw new SecurityException("Search result intents must be called with from an "
+        throw new SecurityException("Search result intents must be called with from a "
                 + "allowlisted package.");
     }
 
diff --git a/src/com/android/settings/widget/HighlightableTopLevelPreferenceAdapter.java b/src/com/android/settings/widget/HighlightableTopLevelPreferenceAdapter.java
deleted file mode 100644
index eeaad21..0000000
--- a/src/com/android/settings/widget/HighlightableTopLevelPreferenceAdapter.java
+++ /dev/null
@@ -1,238 +0,0 @@
-/*
- * Copyright (C) 2021 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.widget;
-
-import android.content.Context;
-import android.graphics.drawable.Drawable;
-import android.text.TextUtils;
-import android.util.Log;
-import android.util.TypedValue;
-import android.view.View;
-import android.widget.ImageView;
-import android.widget.TextView;
-
-import androidx.annotation.VisibleForTesting;
-import androidx.preference.PreferenceGroup;
-import androidx.preference.PreferenceGroupAdapter;
-import androidx.preference.PreferenceViewHolder;
-import androidx.recyclerview.widget.RecyclerView;
-
-import com.android.settings.Utils;
-import com.android.settings.activityembedding.ActivityEmbeddingUtils;
-
-/**
- *  Adapter for highlighting top level preferences
- */
-public class HighlightableTopLevelPreferenceAdapter extends PreferenceGroupAdapter {
-
-    private static final String TAG = "HighlightableTopLevelAdapter";
-
-    static final long DELAY_HIGHLIGHT_DURATION_MILLIS = 100L;
-
-    @VisibleForTesting
-    final int mHighlightColor;
-    final int mTitleColorNormal;
-    final int mTitleColorHighlight;
-    final int mSummaryColorNormal;
-    final int mSummaryColorHighlight;
-    final int mIconColorNormal;
-    final int mIconColorHighlight;
-
-    private final Context mContext;
-    private final RecyclerView mRecyclerView;
-    private final int mNormalBackgroundRes;
-    private String mHighlightKey;
-    private String mPreviousHighlightKey;
-    private int mHighlightPosition = RecyclerView.NO_POSITION;
-    private boolean mHighlightNeeded;
-    private boolean mScrolled;
-
-    public HighlightableTopLevelPreferenceAdapter(PreferenceGroup preferenceGroup,
-            RecyclerView recyclerView, String key) {
-        super(preferenceGroup);
-        mRecyclerView = recyclerView;
-        mHighlightKey = key;
-        mContext = preferenceGroup.getContext();
-        final TypedValue outValue = new TypedValue();
-        mContext.getTheme().resolveAttribute(android.R.attr.selectableItemBackground,
-                outValue, true /* resolveRefs */);
-        mNormalBackgroundRes = outValue.resourceId;
-        mHighlightColor = Utils.getColorAttrDefaultColor(mContext,
-                com.android.internal.R.attr.colorAccentSecondaryVariant);
-        mTitleColorNormal = Utils.getColorAttrDefaultColor(mContext,
-                android.R.attr.textColorPrimary);
-        mTitleColorHighlight = Utils.getColorAttrDefaultColor(mContext,
-                android.R.attr.textColorPrimaryInverse);
-        mSummaryColorNormal = Utils.getColorAttrDefaultColor(mContext,
-                android.R.attr.textColorSecondary);
-        mSummaryColorHighlight = Utils.getColorAttrDefaultColor(mContext,
-                android.R.attr.textColorSecondaryInverse);
-        mIconColorNormal = Utils.getHomepageIconColor(mContext);
-        mIconColorHighlight = Utils.getHomepageIconColorHighlight(mContext);
-    }
-
-    @Override
-    public void onBindViewHolder(PreferenceViewHolder holder, int position) {
-        super.onBindViewHolder(holder, position);
-        updateBackground(holder, position);
-    }
-
-    @VisibleForTesting
-    void updateBackground(PreferenceViewHolder holder, int position) {
-        if (!isHighlightNeeded()) {
-            removeHighlightBackground(holder);
-            return;
-        }
-
-        if (position == mHighlightPosition
-                && mHighlightKey != null
-                && TextUtils.equals(mHighlightKey, getItem(position).getKey())) {
-            // This position should be highlighted.
-            addHighlightBackground(holder);
-        } else {
-            removeHighlightBackground(holder);
-        }
-    }
-
-    /**
-     * A function can highlight a specific setting in recycler view.
-     */
-    public void requestHighlight() {
-        if (mRecyclerView == null || TextUtils.isEmpty(mHighlightKey)) {
-            return;
-        }
-
-        if (TextUtils.isEmpty(mHighlightKey)) {
-            // De-highlight previous preference.
-            final int previousPosition = mHighlightPosition;
-            mHighlightPosition = RecyclerView.NO_POSITION;
-            mScrolled = true;
-            if (previousPosition >= 0) {
-                notifyItemChanged(previousPosition);
-            }
-            return;
-        }
-
-        final int position = getPreferenceAdapterPosition(mHighlightKey);
-        if (position < 0) {
-            return;
-        }
-
-        final boolean highlightNeeded = isHighlightNeeded();
-        if (highlightNeeded) {
-            scrollToPositionIfNeeded(position);
-        }
-
-        // Turn on/off highlight when screen split mode is changed.
-        if (highlightNeeded != mHighlightNeeded) {
-            Log.d(TAG, "Highlight change needed: " + highlightNeeded);
-            mHighlightNeeded = highlightNeeded;
-            mHighlightPosition = position;
-            notifyItemChanged(position);
-            return;
-        }
-
-        if (position == mHighlightPosition) {
-            return;
-        }
-
-        final int previousPosition = mHighlightPosition;
-        mHighlightPosition = position;
-        Log.d(TAG, "Request highlight position " + position);
-        Log.d(TAG, "Is highlight needed: " + highlightNeeded);
-        if (!highlightNeeded) {
-            return;
-        }
-
-        // Highlight preference.
-        notifyItemChanged(position);
-
-        // De-highlight previous preference.
-        if (previousPosition >= 0) {
-            notifyItemChanged(previousPosition);
-        }
-    }
-
-    /**
-     * A function that highlights a setting by specifying a preference key. Usually used whenever a
-     * preference is clicked.
-     */
-    public void highlightPreference(String key, boolean scrollNeeded) {
-        mPreviousHighlightKey = mHighlightKey;
-        mHighlightKey = key;
-        mScrolled = !scrollNeeded;
-        requestHighlight();
-    }
-
-    /**
-     * A function that restores the previous highlighted setting.
-     */
-    public void restorePreviousHighlight() {
-        mHighlightKey = mPreviousHighlightKey;
-        requestHighlight();
-    }
-
-    private void scrollToPositionIfNeeded(int position) {
-        if (mScrolled || position < 0) {
-            return;
-        }
-
-        // Only when the recyclerView is loaded, it can be scrolled
-        final View view = mRecyclerView.getChildAt(position);
-        if (view == null) {
-            mRecyclerView.postDelayed(() -> scrollToPositionIfNeeded(position),
-                    DELAY_HIGHLIGHT_DURATION_MILLIS);
-            return;
-        }
-
-        mScrolled = true;
-        Log.d(TAG, "Scroll to position " + position);
-        // Scroll to the top to reset the position.
-        mRecyclerView.nestedScrollBy(0, -mRecyclerView.getHeight());
-
-        final int scrollY = view.getTop();
-        if (scrollY > 0) {
-            mRecyclerView.nestedScrollBy(0, scrollY);
-        }
-    }
-
-    private void addHighlightBackground(PreferenceViewHolder holder) {
-        final View v = holder.itemView;
-        v.setBackgroundColor(mHighlightColor);
-        ((TextView) v.findViewById(android.R.id.title)).setTextColor(mTitleColorHighlight);
-        ((TextView) v.findViewById(android.R.id.summary)).setTextColor(mSummaryColorHighlight);
-        final Drawable drawable = ((ImageView) v.findViewById(android.R.id.icon)).getDrawable();
-        if (drawable != null) {
-            drawable.setTint(mIconColorHighlight);
-        }
-    }
-
-    private void removeHighlightBackground(PreferenceViewHolder holder) {
-        final View v = holder.itemView;
-        v.setBackgroundResource(mNormalBackgroundRes);
-        ((TextView) v.findViewById(android.R.id.title)).setTextColor(mTitleColorNormal);
-        ((TextView) v.findViewById(android.R.id.summary)).setTextColor(mSummaryColorNormal);
-        final Drawable drawable = ((ImageView) v.findViewById(android.R.id.icon)).getDrawable();
-        if (drawable != null) {
-            drawable.setTint(mIconColorNormal);
-        }
-    }
-
-    private boolean isHighlightNeeded() {
-        return ActivityEmbeddingUtils.isTwoPaneResolution(mContext);
-    }
-}