Merge "Revert "Fix Network request test fail in CTS-Verifier""
diff --git a/Settings/AndroidManifest.xml b/Settings/AndroidManifest.xml
index 96c3df5..095fa37 100644
--- a/Settings/AndroidManifest.xml
+++ b/Settings/AndroidManifest.xml
@@ -100,21 +100,6 @@
             </intent-filter>
             -->
         </activity>
-
-        <activity
-            android:name=".connectivity.NetworkRequestDialogActivity"
-            android:theme="@style/Transparent"
-            android:excludeFromRecents="true"
-            android:launchMode="singleTop"
-            android:taskAffinity=".connectivity.NetworkRequestDialogActivity"
-            android:exported="true"
-            android:permission="android.permission.NETWORK_SETTINGS">
-            <intent-filter>
-                <action android:name="com.android.settings.wifi.action.NETWORK_REQUEST" />
-                <category android:name="android.intent.category.DEFAULT" />
-            </intent-filter>
-        </activity>
-
         <activity
             android:name=".connectivity.WifiConnectionActivity"
             android:clearTaskOnLaunch="true"
diff --git a/Settings/res/layout/network_request_dialog_title.xml b/Settings/res/layout/network_request_dialog_title.xml
deleted file mode 100644
index 1a44f2d..0000000
--- a/Settings/res/layout/network_request_dialog_title.xml
+++ /dev/null
@@ -1,44 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!-- 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.
--->
-
-<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
-    android:layout_width="match_parent"
-    android:layout_height="wrap_content"
-    android:paddingEnd="?android:attr/dialogPreferredPadding"
-    android:orientation="horizontal"
-    android:background="?android:attr/selectableItemBackground"
-    android:minHeight="?android:attr/listPreferredItemHeightSmall">
-
-  <TextView
-      android:id="@+id/network_request_title_text"
-      android:layout_width="0dp"
-      android:layout_height="wrap_content"
-      android:paddingLeft="24dp"
-      android:paddingTop="18dp"
-      android:layout_weight="1"
-      android:textSize="18sp"
-      android:gravity="center_vertical"
-      />
-
-  <ProgressBar
-      android:id="@+id/network_request_title_progress"
-      android:layout_width="wrap_content"
-      android:layout_height="wrap_content"
-      android:layout_gravity="center_vertical"
-      android:layout_marginStart="16dip"
-      android:minWidth="32dp"
-      android:text="@string/progress_scanning"/>
-</LinearLayout>
diff --git a/Settings/res/values/colors.xml b/Settings/res/values/colors.xml
index adbd47a..94742f3 100644
--- a/Settings/res/values/colors.xml
+++ b/Settings/res/values/colors.xml
@@ -159,7 +159,4 @@
     <color name="setup_primary_text_color">#FFEEEEEE</color>
 
     <color name="activity_progress_text">#FFEEEEEE</color>
-
-    <!-- Dialog background color -->
-    <color name="dialog_background">@*android:color/background_device_default_light</color>
 </resources>
diff --git a/Settings/res/values/strings.xml b/Settings/res/values/strings.xml
index 2fe5264..21ad12e 100644
--- a/Settings/res/values/strings.xml
+++ b/Settings/res/values/strings.xml
@@ -1645,19 +1645,4 @@
 
     <!-- concat two strings, e.g. "Android Keyboard, My Pass" [CHAR LIMIT=NONE] -->
     <string name="string_concat"><xliff:g id="part1">%1$s</xliff:g>, <xliff:g id="part2">%2$s</xliff:g></string>
-
-    <!-- Title for Network connection request Dialog [CHAR LIMIT=60] -->
-    <string name="network_connection_request_dialog_title">Device to use with <xliff:g id="appName" example="ThirdPartyAppName">%1$s</xliff:g></string>
-    <!-- Message for Network connection timeout Dialog [CHAR LIMIT=NONE] -->
-    <string name="network_connection_timeout_dialog_message">No devices found. Make sure devices are turned on and available to connect.</string>
-    <!-- OK button for Network connection timeout Dialog [CHAR LIMIT=30] -->
-    <string name="network_connection_timeout_dialog_ok">Try again</string>
-    <!-- Message for Network connection error state Dialog [CHAR LIMIT=NONE] -->
-    <string name="network_connection_errorstate_dialog_message">Something came up. The application has cancelled the request to choose a device.</string>
-    <!-- Toast message when connection is successful [CHAR LIMIT=30] -->
-    <string name="network_connection_connect_successful">Connection successful</string>
-    <!-- Neutral button for Network connection request Dialog [CHAR LIMIT=30] -->
-    <string name="network_connection_request_dialog_showall">Show all</string>
-    <!--Bluetooth settings screen, text that appears in heading bar when scanning for devices -->
-    <string name="progress_scanning">Searching</string>
 </resources>
diff --git a/Settings/res/values/styles.xml b/Settings/res/values/styles.xml
index cea6f93..cc4c0ac 100644
--- a/Settings/res/values/styles.xml
+++ b/Settings/res/values/styles.xml
@@ -287,9 +287,4 @@
     <style name="Setup.GuidedActionItemIcon" parent="@style/Widget.Leanback.GuidedActionItemIconStyle">
         <item name="android:layout_marginEnd">16dp</item>
     </style>
-
-    <style name="TextAppearance.DialogMessage"
-           parent="@*android:style/TextAppearance.DeviceDefault.Body1">
-        <item name="android:textSize">16sp</item>
-    </style>
 </resources>
diff --git a/Settings/res/values/themes.xml b/Settings/res/values/themes.xml
index 929e470..98ae810 100644
--- a/Settings/res/values/themes.xml
+++ b/Settings/res/values/themes.xml
@@ -15,33 +15,6 @@
 -->
 
 <resources>
-    <style name="Transparent">
-        <item name="alertDialogTheme">@style/Theme.AlertDialog</item>
-        <item name="android:windowBackground">@android:color/transparent</item>
-        <item name="android:windowNoTitle">true</item>
-        <item name="android:windowIsFloating">true</item>
-    </style>
-
-    <style name="Theme.AlertDialog.Base" parent="@style/Theme.AppCompat.DayNight.Dialog.Alert">
-        <item name="colorAccent">@*android:color/accent_device_default_light</item>
-        <item name="android:colorBackground">@color/dialog_background</item>
-    </style>
-
-    <style name="Theme.AlertDialog" parent="Theme.AlertDialog.Base">
-        <item name="android:windowSoftInputMode">adjustResize</item>
-        <item name="android:clipToPadding">true</item>
-        <item name="android:clipChildren">true</item>
-
-        <!-- Redefine the ActionBar style for contentInsetStart -->
-        <!-- <item name="android:actionBarStyle">@style/Widget.ActionBar</item> -->
-
-        <!-- copied from Theme.DeviceDefault.Dialog.Alert -->
-        <item name="dialogCornerRadius">@*android:dimen/config_dialogCornerRadius</item>
-        <item name="android:windowTitleStyle">@*android:style/DialogWindowTitle.DeviceDefault</item>
-        <item name="android:textAppearanceMedium">@style/TextAppearance.DialogMessage</item>
-        <item name="buttonBarButtonStyle">@*android:style/Widget.DeviceDefault.Button.ButtonBar.AlertDialog</item>
-    </style>
-
     <style name="FallbackHome" parent="@android:style/Theme.Material.Wallpaper.NoTitleBar">
         <item name="android:windowTranslucentStatus">true</item>
         <item name="android:windowTranslucentNavigation">true</item>
diff --git a/Settings/src/com/android/tv/settings/connectivity/NetworkRequestDialogActivity.java b/Settings/src/com/android/tv/settings/connectivity/NetworkRequestDialogActivity.java
deleted file mode 100644
index 63a123d..0000000
--- a/Settings/src/com/android/tv/settings/connectivity/NetworkRequestDialogActivity.java
+++ /dev/null
@@ -1,38 +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.tv.settings.connectivity;
-
-import android.os.Bundle;
-
-import androidx.annotation.Nullable;
-import androidx.fragment.app.FragmentActivity;
-
-/**
- * When other applications request to have a wifi connection, framework will bring up this activity
- * to let user select which wifi ap wanna to connect. This activity is just a door for framework
- * call, and main functional process is at {@code NetworkRequestDialogFragment}.
- */
-public class NetworkRequestDialogActivity extends FragmentActivity {
-
-    @Override
-    protected void onCreate(@Nullable Bundle savedInstanceState) {
-        super.onCreate(savedInstanceState);
-
-        final NetworkRequestDialogFragment fragment = NetworkRequestDialogFragment.newInstance();
-        fragment.show(getSupportFragmentManager(), "NetworkRequestDialogFragment");
-    }
-}
diff --git a/Settings/src/com/android/tv/settings/connectivity/NetworkRequestDialogFragment.java b/Settings/src/com/android/tv/settings/connectivity/NetworkRequestDialogFragment.java
deleted file mode 100644
index 752abbc..0000000
--- a/Settings/src/com/android/tv/settings/connectivity/NetworkRequestDialogFragment.java
+++ /dev/null
@@ -1,569 +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.tv.settings.connectivity;
-
-import android.app.Activity;
-import android.app.Dialog;
-import android.app.settings.SettingsEnums;
-import android.content.Context;
-import android.content.DialogInterface;
-import android.content.Intent;
-import android.graphics.drawable.Drawable;
-import android.net.wifi.ScanResult;
-import android.net.wifi.WifiConfiguration;
-import android.net.wifi.WifiManager;
-import android.net.wifi.WifiManager.NetworkRequestMatchCallback;
-import android.net.wifi.WifiManager.NetworkRequestUserSelectionCallback;
-import android.os.Bundle;
-import android.os.Handler;
-import android.os.Message;
-import android.text.TextUtils;
-import android.view.LayoutInflater;
-import android.view.View;
-import android.view.ViewGroup;
-import android.widget.ArrayAdapter;
-import android.widget.BaseAdapter;
-import android.widget.Button;
-import android.widget.ProgressBar;
-import android.widget.TextView;
-import android.widget.Toast;
-import android.widget.ImageView;
-
-import androidx.annotation.NonNull;
-import androidx.annotation.VisibleForTesting;
-import androidx.appcompat.app.AlertDialog;
-import androidx.preference.internal.PreferenceImageView;
-
-import com.android.tv.settings.R;
-import com.android.tv.settings.connectivity.NetworkRequestErrorDialogFragment.ERROR_DIALOG_TYPE;
-import com.android.tv.settings.SettingsPreferenceFragment;
-import com.android.settingslib.core.lifecycle.ObservableDialogFragment;
-import com.android.settingslib.Utils;
-import com.android.settingslib.core.lifecycle.Lifecycle;
-import com.android.settingslib.wifi.AccessPoint;
-import com.android.settingslib.wifi.WifiTracker;
-import com.android.settingslib.wifi.WifiTrackerFactory;
-
-import java.util.ArrayList;
-import java.util.List;
-
-/**
- * The Fragment sets up callback {@link NetworkRequestMatchCallback} with framework. To handle most
- * behaviors of the callback when requesting wifi network, except for error message. When error
- * happens, {@link NetworkRequestErrorDialogFragment} will be called to display error message.
- */
-public class NetworkRequestDialogFragment extends ObservableDialogFragment implements
-        DialogInterface.OnClickListener, NetworkRequestMatchCallback {
-
-    /** Message sent to us to stop scanning wifi and pop up timeout dialog. */
-    private static final int MESSAGE_STOP_SCAN_WIFI_LIST = 0;
-
-    /**
-     * Spec defines there should be 5 wifi ap on the list at most or just show all if {@code
-     * mShowLimitedItem} is false.
-     */
-    private static final int MAX_NUMBER_LIST_ITEM = 5;
-    private boolean mShowLimitedItem = true;
-
-    /** Delayed time to stop scanning wifi. */
-    private static final int DELAY_TIME_STOP_SCAN_MS = 30 * 1000;
-
-    @VisibleForTesting
-    final static String EXTRA_APP_NAME = "com.android.settings.wifi.extra.APP_NAME";
-    final static String EXTRA_IS_SPECIFIED_SSID =
-            "com.android.settings.wifi.extra.REQUEST_IS_FOR_SINGLE_NETWORK";
-
-    private List<AccessPoint> mAccessPointList;
-    private FilterWifiTracker mFilterWifiTracker;
-    private AccessPointAdapter mDialogAdapter;
-    private NetworkRequestUserSelectionCallback mUserSelectionCallback;
-    private boolean mIsSpecifiedSsid;
-    private boolean mWaitingConnectCallback;
-
-    public static NetworkRequestDialogFragment newInstance() {
-        NetworkRequestDialogFragment dialogFragment = new NetworkRequestDialogFragment();
-        return dialogFragment;
-    }
-
-    @Override
-    public Dialog onCreateDialog(Bundle savedInstanceState) {
-        final Context context = getContext();
-
-        // Prepares title.
-        final LayoutInflater inflater = LayoutInflater.from(context);
-        final View customTitle = inflater.inflate(R.layout.network_request_dialog_title, null);
-
-        final TextView title = customTitle.findViewById(R.id.network_request_title_text);
-        title.setText(getTitle());
-
-        final Intent intent = getActivity().getIntent();
-        if (intent != null) {
-            mIsSpecifiedSsid = intent.getBooleanExtra(EXTRA_IS_SPECIFIED_SSID, false);
-        }
-
-        // Prepares adapter.
-        mDialogAdapter = new AccessPointAdapter(context,
-                R.layout.preference_access_point, getAccessPointList());
-
-        final AlertDialog.Builder builder = new AlertDialog.Builder(context)
-                .setCustomTitle(customTitle)
-                .setAdapter(mDialogAdapter, this)
-                .setNegativeButton(R.string.cancel, (dialog, which) -> onCancel(dialog))
-                // Do nothings, will replace the onClickListener to avoid auto closing dialog.
-                .setNeutralButton(R.string.network_connection_request_dialog_showall,
-                        null /* OnClickListener */);
-        if (mIsSpecifiedSsid) {
-            builder.setPositiveButton(R.string.wifi_connect, null /* OnClickListener */);
-        }
-
-        // Clicking list item is to connect wifi ap.
-        final AlertDialog dialog = builder.create();
-        dialog.getListView()
-                .setOnItemClickListener(
-                        (parent, view, position, id) -> this.onClick(dialog, position));
-
-        // Don't dismiss dialog when touching outside. User reports it is easy to touch outside.
-        // This causes dialog to close.
-        setCancelable(false);
-
-        dialog.setOnShowListener((dialogInterface) -> {
-            // Replace NeutralButton onClickListener to avoid closing dialog
-            final Button neutralBtn = dialog.getButton(AlertDialog.BUTTON_NEUTRAL);
-            neutralBtn.setVisibility(View.GONE);
-            neutralBtn.setOnClickListener(v -> {
-                mShowLimitedItem = false;
-                renewAccessPointList(null /* List<ScanResult> */);
-                notifyAdapterRefresh();
-                neutralBtn.setVisibility(View.GONE);
-            });
-
-            // Replace Positive onClickListener to avoid closing dialog
-            if (mIsSpecifiedSsid) {
-                final Button positiveBtn = dialog.getButton(AlertDialog.BUTTON_POSITIVE);
-                positiveBtn.setOnClickListener(v -> {
-                    // When clicking connect button, should connect to the first and the only one
-                    // list item.
-                    this.onClick(dialog, 0 /* position */);
-                });
-                // Disable button in first, and enable it after there are some accesspoints in list.
-                positiveBtn.setEnabled(false);
-            }
-        });
-        return dialog;
-    }
-
-    private String getTitle() {
-        final Intent intent = getActivity().getIntent();
-        String appName = "";
-        if (intent != null) {
-            appName = intent.getStringExtra(EXTRA_APP_NAME);
-        }
-
-        return getString(R.string.network_connection_request_dialog_title, appName);
-    }
-
-    @NonNull
-    List<AccessPoint> getAccessPointList() {
-        // Initials list for adapter, in case of display crashing.
-        if (mAccessPointList == null) {
-            mAccessPointList = new ArrayList<>();
-        }
-        return mAccessPointList;
-    }
-
-    private BaseAdapter getDialogAdapter() {
-        return mDialogAdapter;
-    }
-
-    @Override
-    public void onClick(DialogInterface dialog, int which) {
-        final List<AccessPoint> accessPointList = getAccessPointList();
-        if (accessPointList.size() == 0) {
-            return;  // Invalid values.
-        }
-        if (mUserSelectionCallback == null) {
-            return; // Callback is missing or not ready.
-        }
-
-        if (which < accessPointList.size()) {
-            final AccessPoint selectedAccessPoint = accessPointList.get(which);
-            WifiConfiguration wifiConfig = selectedAccessPoint.getConfig();
-            if (wifiConfig == null) {
-                wifiConfig = WifiUtils.getWifiConfig(selectedAccessPoint, /* scanResult */
-                        null, /* password */ null);
-            }
-
-            if (wifiConfig != null) {
-                mUserSelectionCallback.select(wifiConfig);
-
-                mWaitingConnectCallback = true;
-                updateConnectButton(false);
-            }
-        }
-    }
-
-    @Override
-    public void onCancel(@NonNull DialogInterface dialog) {
-        super.onCancel(dialog);
-        // Finishes the activity when user clicks back key or outside of the dialog.
-        if (getActivity() != null) {
-            getActivity().finish();
-        }
-        if (mUserSelectionCallback != null) {
-            mUserSelectionCallback.reject();
-        }
-    }
-
-    @Override
-    public void onPause() {
-        super.onPause();
-
-        mHandler.removeMessages(MESSAGE_STOP_SCAN_WIFI_LIST);
-        final WifiManager wifiManager = getContext().getApplicationContext()
-                .getSystemService(WifiManager.class);
-        if (wifiManager != null) {
-            wifiManager.unregisterNetworkRequestMatchCallback(this);
-        }
-
-        if (mFilterWifiTracker != null) {
-            mFilterWifiTracker.onPause();
-        }
-    }
-
-    @Override
-    public void onDestroy() {
-        super.onDestroy();
-
-        if (mFilterWifiTracker != null) {
-            mFilterWifiTracker.onDestroy();
-            mFilterWifiTracker = null;
-        }
-    }
-
-    private void showAllButton() {
-        final AlertDialog alertDialog = (AlertDialog) getDialog();
-        if (alertDialog == null) {
-            return;
-        }
-
-        final Button neutralBtn = alertDialog.getButton(AlertDialog.BUTTON_NEUTRAL);
-        if (neutralBtn != null) {
-            neutralBtn.setVisibility(View.VISIBLE);
-        }
-    }
-
-    private void updateConnectButton(boolean enabled) {
-        // The button is only showed in single SSID mode.
-        if (!mIsSpecifiedSsid) {
-            return;
-        }
-
-        final AlertDialog alertDialog = (AlertDialog) getDialog();
-        if (alertDialog == null) {
-            return;
-        }
-
-        final Button positiveBtn = alertDialog.getButton(AlertDialog.BUTTON_POSITIVE);
-        if (positiveBtn != null) {
-            positiveBtn.setEnabled(enabled);
-        }
-    }
-
-    private void hideProgressIcon() {
-        final AlertDialog alertDialog = (AlertDialog) getDialog();
-        if (alertDialog == null) {
-            return;
-        }
-
-        final View progress = alertDialog.findViewById(R.id.network_request_title_progress);
-        if (progress != null) {
-            progress.setVisibility(View.GONE);
-        }
-    }
-
-    @Override
-    public void onResume() {
-        super.onResume();
-
-        final WifiManager wifiManager = getContext().getApplicationContext()
-                .getSystemService(WifiManager.class);
-        if (wifiManager != null) {
-            wifiManager.registerNetworkRequestMatchCallback(this, mHandler);
-        }
-        // Sets time-out to stop scanning.
-        mHandler.sendEmptyMessageDelayed(MESSAGE_STOP_SCAN_WIFI_LIST, DELAY_TIME_STOP_SCAN_MS);
-
-        if (mFilterWifiTracker == null) {
-            mFilterWifiTracker = new FilterWifiTracker(getActivity(), getSettingsLifecycle());
-        }
-        mFilterWifiTracker.onResume();
-    }
-
-    private final Handler mHandler = new Handler() {
-        @Override
-        public void handleMessage(Message msg) {
-            switch (msg.what) {
-                case MESSAGE_STOP_SCAN_WIFI_LIST:
-                    removeMessages(MESSAGE_STOP_SCAN_WIFI_LIST);
-                    stopScanningAndPopErrorDialog(ERROR_DIALOG_TYPE.TIME_OUT);
-                    break;
-                default:
-                    // Do nothing.
-                    break;
-            }
-        }
-    };
-
-    protected void stopScanningAndPopErrorDialog(ERROR_DIALOG_TYPE type) {
-        // Dismisses current dialog.
-        final Dialog dialog =  getDialog();
-        if (dialog != null && dialog.isShowing()) {
-            dismiss();
-        }
-
-        // Throws error dialog.
-        final NetworkRequestErrorDialogFragment fragment = NetworkRequestErrorDialogFragment
-                .newInstance();
-        final Bundle bundle = new Bundle();
-        bundle.putSerializable(NetworkRequestErrorDialogFragment.DIALOG_TYPE, type);
-        fragment.setArguments(bundle);
-        fragment.show(getActivity().getSupportFragmentManager(),
-                NetworkRequestDialogFragment.class.getSimpleName());
-    }
-
-    private class AccessPointAdapter extends ArrayAdapter<AccessPoint> {
-
-        private final int mResourceId;
-        private final LayoutInflater mInflater;
-
-        public AccessPointAdapter(Context context, int resourceId, List<AccessPoint> objects) {
-            super(context, resourceId, objects);
-            mResourceId = resourceId;
-            mInflater = LayoutInflater.from(context);
-        }
-
-        @Override
-        public View getView(int position, View view, ViewGroup parent) {
-            if (view == null) {
-                view = mInflater.inflate(mResourceId, parent, false);
-
-                final View divider = view.findViewById(
-                        com.android.settingslib.R.id.two_target_divider);
-                divider.setVisibility(View.GONE);
-            }
-
-            final AccessPoint accessPoint = getItem(position);
-
-            final TextView titleView = view.findViewById(android.R.id.title);
-            if (titleView != null) {
-                // Shows whole SSID for better UX.
-                titleView.setSingleLine(false);
-                titleView.setText(accessPoint.getTitle());
-            }
-
-            final TextView summary = view.findViewById(android.R.id.summary);
-            if (summary != null) {
-                final String summaryString = accessPoint.getSettingsSummary();
-                if (TextUtils.isEmpty(summaryString)) {
-                    summary.setVisibility(View.GONE);
-                } else {
-                    summary.setVisibility(View.VISIBLE);
-                    summary.setText(summaryString);
-                }
-            }
-
-            final ImageView imageView = view.findViewById(android.R.id.icon);
-            final int level = accessPoint.getLevel();
-            if (imageView != null) {
-                final Drawable drawable = getContext().getDrawable(
-                        Utils.getWifiIconResource(level));
-                drawable.setTintList(
-                        Utils.getColorAttr(getContext(), android.R.attr.colorControlNormal));
-                imageView.setImageDrawable(drawable);
-            }
-
-            return view;
-        }
-    }
-
-    @Override
-    public void onAbort() {
-        stopScanningAndPopErrorDialog(ERROR_DIALOG_TYPE.ABORT);
-    }
-
-    @Override
-    public void onUserSelectionCallbackRegistration(
-            NetworkRequestUserSelectionCallback userSelectionCallback) {
-        mUserSelectionCallback = userSelectionCallback;
-    }
-
-    @Override
-    public void onMatch(List<ScanResult> scanResults) {
-        // Shouldn't need to renew cached list, since input result is empty.
-        if (scanResults != null && scanResults.size() > 0) {
-            mHandler.removeMessages(MESSAGE_STOP_SCAN_WIFI_LIST);
-            renewAccessPointList(scanResults);
-
-            notifyAdapterRefresh();
-        }
-    }
-
-    // Updates internal AccessPoint list from WifiTracker. scanResults are used to update key list
-    // of AccessPoint, and could be null if there is no necessary to update key list.
-    private void renewAccessPointList(List<ScanResult> scanResults) {
-        if (mFilterWifiTracker == null) {
-            return;
-        }
-
-        // TODO(b/119846365): Checks if we could escalate the converting effort.
-        // Updates keys of scanResults into FilterWifiTracker for updating matched AccessPoints.
-        if (scanResults != null) {
-            mFilterWifiTracker.updateKeys(scanResults);
-        }
-
-        // Re-gets matched AccessPoints from WifiTracker.
-        final List<AccessPoint> list = getAccessPointList();
-        list.clear();
-        list.addAll(mFilterWifiTracker.getAccessPoints());
-    }
-
-    @VisibleForTesting
-    void notifyAdapterRefresh() {
-        if (getDialogAdapter() != null) {
-            getDialogAdapter().notifyDataSetChanged();
-        }
-    }
-
-    @Override
-    public void onUserSelectionConnectSuccess(WifiConfiguration wificonfiguration) {
-        final Activity activity = getActivity();
-        if (activity != null) {
-            Toast.makeText(activity, R.string.network_connection_connect_successful,
-                    Toast.LENGTH_SHORT).show();
-            activity.finish();
-        }
-    }
-
-    @Override
-    public void onUserSelectionConnectFailure(WifiConfiguration wificonfiguration) {
-        // Do nothing when selection is failed, let user could try again easily.
-        mWaitingConnectCallback = false;
-        updateConnectButton(true);
-    }
-
-    private final class FilterWifiTracker {
-        private final List<String> mAccessPointKeys;
-        private final WifiTracker mWifiTracker;
-
-        public FilterWifiTracker(Context context, Lifecycle lifecycle) {
-            mWifiTracker = WifiTrackerFactory.create(context, mWifiListener,
-                    lifecycle, /* includeSaved */ true, /* includeScans */ true);
-            mAccessPointKeys = new ArrayList<>();
-        }
-
-        /**
-         * Updates key list from input. {@code onMatch()} may be called in multi-times according
-         * wifi scanning result, so needs patchwork here.
-         */
-        public void updateKeys(List<ScanResult> scanResults) {
-            for (ScanResult scanResult : scanResults) {
-                final String key = AccessPoint.getKey(scanResult);
-                if (!mAccessPointKeys.contains(key)) {
-                    mAccessPointKeys.add(key);
-                }
-            }
-        }
-
-        /**
-         * Returns only AccessPoints whose key is in {@code mAccessPointKeys}.
-         *
-         * @return List of matched AccessPoints.
-         */
-        public List<AccessPoint> getAccessPoints() {
-            final List<AccessPoint> allAccessPoints = mWifiTracker.getAccessPoints();
-            final List<AccessPoint> result = new ArrayList<>();
-
-            // The order should be kept, because order means wifi score (sorting in WifiTracker).
-            int count = 0;
-            for (AccessPoint accessPoint : allAccessPoints) {
-                final String key = accessPoint.getKey();
-                if (mAccessPointKeys.contains(key)) {
-                    result.add(accessPoint);
-
-                    count++;
-                    // Limits how many count of items could show.
-                    if (mShowLimitedItem && count >= MAX_NUMBER_LIST_ITEM) {
-                        break;
-                    }
-                }
-            }
-
-            // Update related UI buttons
-            if (mShowLimitedItem && (count >= MAX_NUMBER_LIST_ITEM)) {
-                showAllButton();
-            }
-            if (count > 0) {
-                hideProgressIcon();
-            }
-            // Enable connect button if there is Accesspoint item, except for the situation that
-            // user click but connected status doesn't come back yet.
-            if (count < 0) {
-                updateConnectButton(false);
-            } else if (!mWaitingConnectCallback) {
-                updateConnectButton(true);
-            }
-
-            return result;
-        }
-
-        private WifiTracker.WifiListener mWifiListener = new WifiTracker.WifiListener() {
-
-            @Override
-            public void onWifiStateChanged(int state) {
-                notifyAdapterRefresh();
-            }
-
-            @Override
-            public void onConnectedChanged() {
-                notifyAdapterRefresh();
-            }
-
-            @Override
-            public void onAccessPointsChanged() {
-                notifyAdapterRefresh();
-            }
-        };
-
-        public void onDestroy() {
-            if (mWifiTracker != null) {
-                mWifiTracker.onDestroy();
-            }
-        }
-
-        public void onResume() {
-            if (mWifiTracker != null) {
-                mWifiTracker.onStart();
-            }
-        }
-
-        public void onPause() {
-            if (mWifiTracker != null) {
-                mWifiTracker.onStop();
-            }
-        }
-    }
-}
diff --git a/Settings/src/com/android/tv/settings/connectivity/NetworkRequestErrorDialogFragment.java b/Settings/src/com/android/tv/settings/connectivity/NetworkRequestErrorDialogFragment.java
deleted file mode 100644
index 401e91d..0000000
--- a/Settings/src/com/android/tv/settings/connectivity/NetworkRequestErrorDialogFragment.java
+++ /dev/null
@@ -1,82 +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.tv.settings.connectivity;
-
-import android.app.Dialog;
-import android.app.settings.SettingsEnums;
-import android.content.DialogInterface;
-import android.os.Bundle;
-
-import androidx.annotation.NonNull;
-import androidx.appcompat.app.AlertDialog;
-
-import com.android.settingslib.core.lifecycle.ObservableDialogFragment;
-import com.android.tv.settings.R;
-import com.android.tv.settings.SettingsPreferenceFragment;
-
-/**
- * The dialog shows an error message when requesting network {@link NetworkRequestDialogFragment}.
- * Contains multi-error types in {@code ERROR_DIALOG_TYPE}.
- */
-public class NetworkRequestErrorDialogFragment extends ObservableDialogFragment {
-
-    public static final String DIALOG_TYPE = "DIALOG_ERROR_TYPE";
-
-    public enum ERROR_DIALOG_TYPE {TIME_OUT, ABORT}
-
-    public static NetworkRequestErrorDialogFragment newInstance() {
-        return new NetworkRequestErrorDialogFragment();
-    }
-
-    private NetworkRequestErrorDialogFragment() {
-        super();
-    }
-
-    @Override
-    public void onCancel(@NonNull DialogInterface dialog) {
-        super.onCancel(dialog);
-        // Wants to finish the activity when user clicks back key or outside of the dialog.
-        getActivity().finish();
-    }
-
-    @Override
-    public Dialog onCreateDialog(Bundle savedInstanceState) {
-        // Gets error type to construct dialog. Default is TIME_OUT dialog.
-        ERROR_DIALOG_TYPE msgType = ERROR_DIALOG_TYPE.TIME_OUT;
-        if (getArguments() != null) {
-            msgType = (ERROR_DIALOG_TYPE) getArguments().getSerializable(DIALOG_TYPE);
-        }
-
-        final AlertDialog.Builder builder = new AlertDialog.Builder(getContext());
-        if (msgType == ERROR_DIALOG_TYPE.TIME_OUT) {
-            builder.setMessage(R.string.network_connection_timeout_dialog_message)
-                    .setPositiveButton(R.string.network_connection_timeout_dialog_ok,
-                            (dialog, which) -> startScanningDialog())
-                    .setNegativeButton(R.string.cancel, (dialog, which) -> getActivity().finish());
-        } else {
-            builder.setMessage(R.string.network_connection_errorstate_dialog_message)
-                    .setPositiveButton(R.string.okay, (dialog, which) -> getActivity().finish());
-        }
-        return builder.create();
-    }
-
-    protected void startScanningDialog() {
-        final NetworkRequestDialogFragment fragment = NetworkRequestDialogFragment.newInstance();
-        fragment.show(getActivity().getSupportFragmentManager(),
-                NetworkRequestErrorDialogFragment.class.getSimpleName());
-    }
-}
diff --git a/Settings/src/com/android/tv/settings/connectivity/WifiUtils.java b/Settings/src/com/android/tv/settings/connectivity/WifiUtils.java
deleted file mode 100644
index 6632c8b..0000000
--- a/Settings/src/com/android/tv/settings/connectivity/WifiUtils.java
+++ /dev/null
@@ -1,153 +0,0 @@
-package com.android.tv.settings.connectivity;
-
-import android.app.admin.DevicePolicyManager;
-import android.content.ComponentName;
-import android.content.ContentResolver;
-import android.content.Context;
-import android.content.pm.PackageManager;
-import android.net.NetworkCapabilities;
-import android.net.wifi.ScanResult;
-import android.net.wifi.WifiConfiguration;
-import android.provider.Settings;
-import android.text.TextUtils;
-
-import com.android.settingslib.wifi.AccessPoint;
-
-public class WifiUtils {
-    /**
-     * Gets security value from ScanResult.
-     *
-     * Duplicated method from {@link AccessPoint#getSecurity(ScanResult)}.
-     * TODO(b/120827021): Should be removed if the there is have a common one in shared place (e.g.
-     * SettingsLib).
-     *
-     * @param result ScanResult
-     * @return Related security value based on {@link AccessPoint}.
-     */
-    public static int getAccessPointSecurity(ScanResult result) {
-        if (result.capabilities.contains("WEP")) {
-            return AccessPoint.SECURITY_WEP;
-        } else if (result.capabilities.contains("SAE")) {
-            return AccessPoint.SECURITY_SAE;
-        } else if (result.capabilities.contains("PSK")) {
-            return AccessPoint.SECURITY_PSK;
-        } else if (result.capabilities.contains("EAP_SUITE_B_192")) {
-            return AccessPoint.SECURITY_EAP_SUITE_B;
-        } else if (result.capabilities.contains("EAP")) {
-            return AccessPoint.SECURITY_EAP;
-        } else if (result.capabilities.contains("OWE")) {
-            return AccessPoint.SECURITY_OWE;
-        }
-
-        return AccessPoint.SECURITY_NONE;
-    }
-
-    /**
-     * Provides a simple way to generate a new {@link WifiConfiguration} obj from
-     * {@link ScanResult} or {@link AccessPoint}. Either {@code accessPoint} or {@code scanResult
-     * } input should be not null for retrieving information, otherwise will throw
-     * IllegalArgumentException.
-     * This method prefers to take {@link AccessPoint} input in priority. Therefore this method
-     * will take {@link AccessPoint} input as preferred data extraction source when you input
-     * both {@link AccessPoint} and {@link ScanResult}, and ignore {@link ScanResult} input.
-     *
-     * Duplicated and simplified method from {@link WifiConfigController#getConfig()}.
-     * TODO(b/120827021): Should be removed if the there is have a common one in shared place (e.g.
-     * SettingsLib).
-     *
-     * @param accessPoint Input data for retrieving WifiConfiguration.
-     * @param scanResult  Input data for retrieving WifiConfiguration.
-     * @return WifiConfiguration obj based on input.
-     */
-    public static WifiConfiguration getWifiConfig(AccessPoint accessPoint, ScanResult scanResult,
-            String password) {
-        if (accessPoint == null && scanResult == null) {
-            throw new IllegalArgumentException(
-                    "At least one of AccessPoint and ScanResult input is required.");
-        }
-
-        final WifiConfiguration config = new WifiConfiguration();
-        final int security;
-
-        if (accessPoint == null) {
-            config.SSID = AccessPoint.convertToQuotedString(scanResult.SSID);
-            security = getAccessPointSecurity(scanResult);
-        } else {
-            if (!accessPoint.isSaved()) {
-                config.SSID = AccessPoint.convertToQuotedString(
-                        accessPoint.getSsidStr());
-            } else {
-                config.networkId = accessPoint.getConfig().networkId;
-                config.hiddenSSID = accessPoint.getConfig().hiddenSSID;
-            }
-            security = accessPoint.getSecurity();
-        }
-
-        switch (security) {
-            case AccessPoint.SECURITY_NONE:
-                config.setSecurityParams(WifiConfiguration.SECURITY_TYPE_OPEN);
-                break;
-
-            case AccessPoint.SECURITY_WEP:
-                config.setSecurityParams(WifiConfiguration.SECURITY_TYPE_WEP);
-                if (!TextUtils.isEmpty(password)) {
-                    int length = password.length();
-                    // WEP-40, WEP-104, and 256-bit WEP (WEP-232?)
-                    if ((length == 10 || length == 26 || length == 58)
-                            && password.matches("[0-9A-Fa-f]*")) {
-                        config.wepKeys[0] = password;
-                    } else {
-                        config.wepKeys[0] = '"' + password + '"';
-                    }
-                }
-                break;
-
-            case AccessPoint.SECURITY_PSK:
-                config.allowedKeyManagement.set(WifiConfiguration.KeyMgmt.WPA_PSK);
-                if (!TextUtils.isEmpty(password)) {
-                    if (password.matches("[0-9A-Fa-f]{64}")) {
-                        config.preSharedKey = password;
-                    } else {
-                        config.preSharedKey = '"' + password + '"';
-                    }
-                }
-                break;
-
-            case AccessPoint.SECURITY_EAP:
-            case AccessPoint.SECURITY_EAP_SUITE_B:
-                config.allowedKeyManagement.set(WifiConfiguration.KeyMgmt.WPA_EAP);
-                config.allowedKeyManagement.set(WifiConfiguration.KeyMgmt.IEEE8021X);
-                if (security == AccessPoint.SECURITY_EAP_SUITE_B) {
-                    config.allowedKeyManagement.set(WifiConfiguration.KeyMgmt.SUITE_B_192);
-                    config.requirePMF = true;
-                    config.allowedPairwiseCiphers.set(WifiConfiguration.PairwiseCipher.GCMP_256);
-                    config.allowedGroupCiphers.set(WifiConfiguration.GroupCipher.GCMP_256);
-                    config.allowedGroupManagementCiphers.set(WifiConfiguration.GroupMgmtCipher
-                            .BIP_GMAC_256);
-                    // allowedSuiteBCiphers will be set according to certificate type
-                }
-
-                if (!TextUtils.isEmpty(password)) {
-                    config.enterpriseConfig.setPassword(password);
-                }
-                break;
-            case AccessPoint.SECURITY_SAE:
-                config.allowedKeyManagement.set(WifiConfiguration.KeyMgmt.SAE);
-                config.requirePMF = true;
-                if (!TextUtils.isEmpty(password)) {
-                    config.preSharedKey = '"' + password + '"';
-                }
-                break;
-
-            case AccessPoint.SECURITY_OWE:
-                config.allowedKeyManagement.set(WifiConfiguration.KeyMgmt.OWE);
-                config.requirePMF = true;
-                break;
-
-            default:
-                break;
-        }
-
-        return config;
-    }
-}
\ No newline at end of file