Fix the complie error of network migration

1. Fix the error in import part
2. Remove broken code and add TODO

Future CL will fix TODO and add tests

Bug: 114749736
Test: Build
Change-Id: I4fda0708959e299015ecb10ac17c9c2dadc6f852
diff --git a/res/values/config.xml b/res/values/config.xml
index 0129768..8e60505 100755
--- a/res/values/config.xml
+++ b/res/values/config.xml
@@ -137,7 +137,12 @@
     <!-- Whether or not TopLevelSettings should force rounded icon for injected tiles -->
     <bool name="config_force_rounded_icon_TopLevelSettings">true</bool>
 
-    <!-- TODO(b/114749736): migrate override for config value -->
+    <!-- TODO(b/115429501): move those 3 configs to framework-->
     <!-- Show enabled lte option for lte device -->
     <bool name="config_enabled_lte" translatable="false">false</bool>
+    <!-- Show enabled tdscdma option for device -->
+    <bool name="config_support_tdscdma" translatable="false">false</bool>
+    <!-- Show enabled tdscdma option for device when connect roaming network -->
+    <string-array name="config_support_tdscdma_roaming_on_networks"
+                  translatable="false"></string-array>
 </resources>
diff --git a/res/values/strings.xml b/res/values/strings.xml
index 0060202..41d024d 100644
--- a/res/values/strings.xml
+++ b/res/values/strings.xml
@@ -10186,23 +10186,10 @@
     <!-- Configuration setting for world mode Format is <true;GID if any to be checked> [CHAR LIMIT=NONE] -->
     <string translatable="false" name="config_world_mode"/>
 
-    <!-- Available networks screen, text when no networks connected [CHAR LIMIT=NONE] -->
-    <string name="network_disconnected">Disconnected</string>
-    <!-- Available networks screen, text when network connected [CHAR LIMIT=NONE] -->
-    <string name="network_connected">Connected</string>
-    <!-- Available networks screen, text when a network is connecting [CHAR LIMIT=NONE] -->
-    <string name="network_connecting">Connecting\u2026</string>
-    <!-- Available networks screen, text when a network cannot be connected [CHAR LIMIT=NONE] -->
-    <string name="network_could_not_connect">Couldn’t connect</string>
-
     <!-- Available networks screen title/heading [CHAR LIMIT=NONE] -->
     <string name="label_available">Available networks</string>
     <!-- Mobile network settings screen, toast when searching for available networks [CHAR LIMIT=NONE] -->
     <string name="load_networks_progress">Searching\u2026</string>
-    <!-- Available networks screen, text when no networks are found [CHAR LIMIT=NONE] -->
-    <string name="empty_networks_list">No networks found.</string>
-    <!-- Available networks screen, toast when an error is encountered when searching for networks [CHAR LIMIT=NONE] -->
-    <string name="network_query_error">Couldn\u2019t find networks. Try again.</string>
     <!-- Available networks screen, toast when registering on a specific network [CHAR LIMIT=NONE] -->
     <string name="register_on_network">Registering on <xliff:g id="network" example="Verizon">%s</xliff:g>\u2026</string>
     <!-- Available networks screen, toast when SIM card isn't allowed on a network [CHAR LIMIT=NONE] -->
@@ -10215,8 +10202,6 @@
     <!-- Available networks screen, name of switch button for whether to select network automatically [CHAR LIMIT=NONE] -->
     <string name="select_automatically">Automatically select network</string>
 
-    <!-- Available networks screen, name of button when user wants to select network manually [CHAR LIMIT=NONE] -->
-    <string name="choose_network_title">Choose network</string>
     <!-- A menu item in "Mobile network settings" that allows the user to update the phone
      with mobile operator specific settings. [CHAR LIMIT=25] -->
     <string name="carrier_settings_title">Carrier settings</string>
@@ -10259,4 +10244,16 @@
     <string name="cdma_subscription_summary">Change between RUIM/SIM and NV</string>
     <!-- Dialog title for CDMA subscription [CHAR LIMIT=30] -->
     <string name="cdma_subscription_dialogtitle">subscription</string>
+
+    <!-- Mobile network settings screen, Advanced button to show more items when clicked [CHAR LIMIT=50] -->
+    <string name="advanced_options_title">Advanced</string>
+    <!-- Title to register automatically [CHAR LIMIT=NONE] -->
+    <string name="register_automatically">Automatic registration\u2026</string>
+    <!-- Mobile network settings screen, dialog message title when user selects the Data roaming check box [CHAR LIMIT=120] -->
+    <string name="roaming_alert_title">Allow data roaming?</string>
+    <!-- Mobile network settings screen, message asking the user to check their pricing with their Carrier, when enabling Data roaming. [CHAR LIMIT=NONE] -->
+    <string name="roaming_check_price_warning">Check with your network provider for pricing.</string>
+
+    <!-- Available networks screen, summary when button disallowed due to permanent automatic mode [CHAR LIMIT=NONE] -->
+    <string name="manual_mode_disallowed_summary">Unavailable when connected to <xliff:g id="carrier" example="verizon">%1$s</xliff:g></string>
 </resources>
diff --git a/res/xml/cdma_options.xml b/res/xml/cdma_options.xml
index f6ef97a..046d16f 100644
--- a/res/xml/cdma_options.xml
+++ b/res/xml/cdma_options.xml
@@ -1,22 +1,23 @@
 <?xml version="1.0" encoding="utf-8"?>
-<!-- Copyright (C) 2008 The Android Open Source Project
+<!--
+    Copyright (C) 2008 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
+    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
+         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.
+    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.
 -->
 
 <PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android">
 
-    <com.android.phone.CdmaSystemSelectListPreference
+    <com.android.settings.mobilenetwork.CdmaSystemSelectListPreference
         android:key="cdma_system_select_key"
         android:title="@string/cdma_system_select_title"
         android:summary="@string/cdma_system_select_summary"
@@ -24,7 +25,7 @@
         android:entryValues="@array/cdma_system_select_values"
         android:dialogTitle="@string/cdma_system_select_dialogtitle" />
 
-    <com.android.phone.CdmaSubscriptionListPreference
+    <com.android.settings.mobilenetwork.CdmaSubscriptionListPreference
         android:key="cdma_subscription_key"
         android:title="@string/cdma_subscription_title"
         android:summary="@string/cdma_subscription_summary"
@@ -37,7 +38,7 @@
     <PreferenceCategory
         android:key="category_cdma_apn_key">
         <!-- The launching Intent will be defined thru code as we need to pass some Extra -->
-        <com.android.phone.RestrictedPreference
+        <com.android.settingslib.RestrictedPreference
             android:key="button_cdma_apn_key"
             android:title="@string/apn_settings"
             android:persistent="false"/>
@@ -46,9 +47,7 @@
     <Preference
         android:key="carrier_settings_key"
         android:title="@string/carrier_settings_title">
-        <intent android:action="android.intent.action.MAIN"
-                android:targetPackage="@string/carrier_settings"
-                android:targetClass="@string/carrier_settings_menu" />
+        <!-- b/114749736, create a preference controller to build intent -->
     </Preference>
 
 </PreferenceScreen>
diff --git a/res/xml/gsm_umts_options.xml b/res/xml/gsm_umts_options.xml
index 81b2deb..6ca9ad6 100644
--- a/res/xml/gsm_umts_options.xml
+++ b/res/xml/gsm_umts_options.xml
@@ -1,22 +1,23 @@
 <?xml version="1.0" encoding="utf-8"?>
-<!-- Copyright (C) 2008 The Android Open Source Project
+<!--
+    Copyright (C) 2008 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
+    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
+         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.
+    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.
 -->
 
 <PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android">
 
-    <com.android.phone.NetworkOperators
+    <com.android.settings.mobilenetwork.NetworkOperators
         android:key="network_operators_category_key"
         android:title="@string/network_operator_category"
         android:persistent="false">
@@ -26,7 +27,7 @@
             android:title="@string/select_automatically"
             android:persistent="false"/>
 
-        <com.android.phone.NetworkSelectListPreference
+        <com.android.settings.mobilenetwork.NetworkSelectListPreference
             android:key="button_network_select_key"
             android:title="@string/network_select_title"
             android:persistent="false"/>
@@ -35,7 +36,7 @@
             android:key="button_choose_network_key"
             android:title="@string/choose_network_title"
             android:fragment="com.android.phone.NetworkSelectSetting" />
-    </com.android.phone.NetworkOperators>
+    </com.android.settings.mobilenetwork.NetworkOperators>
 
     <!--We want separate APN setting from reset of settings because-->
     <!--we want user to change it with caution.-->
@@ -43,7 +44,7 @@
         android:key="category_gsm_apn_key"
         android:layout="@layout/preference_category_no_label">
 
-        <com.android.phone.RestrictedPreference
+        <com.android.settingslib.RestrictedPreference
             android:key="button_gsm_apn_key"
             android:title="@string/apn_settings"
             android:persistent="false" />
@@ -52,9 +53,7 @@
     <PreferenceScreen
         android:key="carrier_settings_key"
         android:title="@string/carrier_settings_title">
-        <intent android:action="android.intent.action.MAIN"
-                android:targetPackage="@string/carrier_settings"
-                android:targetClass="@string/carrier_settings_menu" />
+        <!-- b/114749736, create a preference controller to build intent -->
     </PreferenceScreen>
 
 </PreferenceScreen>
diff --git a/res/xml/network_setting_fragment.xml b/res/xml/network_setting_fragment.xml
index d334861..b1b7854 100644
--- a/res/xml/network_setting_fragment.xml
+++ b/res/xml/network_setting_fragment.xml
@@ -20,23 +20,23 @@
         android:title="@string/cdma_lte_data_service">
     </PreferenceScreen>
 
-    <com.android.phone.MobileDataPreference
+    <com.android.settings.mobilenetwork.MobileDataPreference
         android:key="mobile_data_enable"
         android:title="@string/mobile_data_settings_title"
         android:summary="@string/mobile_data_settings_summary"/>
 
-    <com.android.phone.RestrictedSwitchPreference
+    <com.android.settingslib.RestrictedSwitchPreference
         android:key="button_roaming_key"
         android:title="@string/roaming"
         android:persistent="false"
         android:summaryOn="@string/roaming_enable"
         android:summaryOff="@string/roaming_disable"/>
 
-    <com.android.phone.DataUsagePreference
+    <com.android.settings.mobilenetwork.DataUsagePreference
         android:key="data_usage_summary"
         android:title="@string/data_usage_title" />
 
-    <com.android.phone.AdvancedOptionsPreference
+    <com.android.settings.mobilenetwork.AdvancedOptionsPreference
         android:key="advanced_options"/>
 
     <SwitchPreference
diff --git a/src/com/android/settings/mobilenetwork/AdvancedOptionsPreference.java b/src/com/android/settings/mobilenetwork/AdvancedOptionsPreference.java
index 23e3cd4..c13c3e2 100644
--- a/src/com/android/settings/mobilenetwork/AdvancedOptionsPreference.java
+++ b/src/com/android/settings/mobilenetwork/AdvancedOptionsPreference.java
@@ -16,27 +16,31 @@
 package com.android.settings.mobilenetwork;
 
 import android.content.Context;
-import android.preference.Preference;
+import androidx.preference.Preference;
+import androidx.preference.PreferenceViewHolder;
+
 import android.util.AttributeSet;
-import android.view.View;
 import android.widget.TextView;
 
+import com.android.settings.R;
+
 /**
  * Customized preference class representing the "Advanced" button that expands to fields that
  * are hidden by default.
  */
+//TODO(b/114749736): Change it back to normal preference
 public class AdvancedOptionsPreference extends Preference {
     public AdvancedOptionsPreference(Context context, AttributeSet attrs) {
         super(context, attrs);
     }
 
     @Override
-    protected void onBindView(View view) {
-        super.onBindView(view);
+    public void onBindViewHolder(PreferenceViewHolder holder) {
+        super.onBindViewHolder(holder);
 
         setIcon(R.drawable.ic_expand_more);
         setTitle(R.string.advanced_options_title);
-        TextView summary = view.findViewById(android.R.id.summary);
+        TextView summary = (TextView) holder.findViewById(android.R.id.summary);
         summary.setMaxLines(1);
     }
-}
+}
\ No newline at end of file
diff --git a/src/com/android/settings/mobilenetwork/CdmaOptions.java b/src/com/android/settings/mobilenetwork/CdmaOptions.java
index 38c6ca3..fe50914 100644
--- a/src/com/android/settings/mobilenetwork/CdmaOptions.java
+++ b/src/com/android/settings/mobilenetwork/CdmaOptions.java
@@ -19,21 +19,22 @@
 import android.content.Intent;
 import android.os.PersistableBundle;
 import android.os.SystemProperties;
-import android.preference.Preference;
-import android.preference.PreferenceFragment;
-import android.preference.PreferenceScreen;
 import android.provider.Settings;
 import android.telephony.CarrierConfigManager;
 import android.telephony.TelephonyManager;
 import android.text.TextUtils;
 
+import androidx.preference.Preference;
+import androidx.preference.PreferenceFragmentCompat;
+import androidx.preference.PreferenceScreen;
+
 import com.android.internal.annotations.VisibleForTesting;
 import com.android.internal.logging.MetricsLogger;
 import com.android.internal.logging.nano.MetricsProto.MetricsEvent;
 import com.android.internal.telephony.PhoneConstants;
-import com.android.phone.MobileNetworkSettings;
-import com.android.phone.RestrictedPreference;
+import com.android.settings.R;
 import com.android.settingslib.RestrictedLockUtilsInternal;
+import com.android.settingslib.RestrictedPreference;
 
 /**
  * List of Phone-specific settings screens.
@@ -54,11 +55,11 @@
     private static final String BUTTON_APN_EXPAND_KEY = "button_cdma_apn_key";
     private static final String CATEGORY_APN_EXPAND_KEY = "category_cdma_apn_key";
 
-    private PreferenceFragment mPrefFragment;
+    private PreferenceFragmentCompat mPrefFragment;
     private PreferenceScreen mPrefScreen;
     private int mSubId;
 
-    public CdmaOptions(PreferenceFragment prefFragment, PreferenceScreen prefScreen, int subId) {
+    public CdmaOptions(PreferenceFragmentCompat prefFragment, PreferenceScreen prefScreen, int subId) {
         mPrefFragment = prefFragment;
         mPrefScreen = prefScreen;
         mPrefFragment.addPreferencesFromResource(R.xml.cdma_options);
@@ -99,7 +100,7 @@
         if (addAPNExpand) {
             log("update: addAPNExpand");
             mButtonAPNExpand.setDisabledByAdmin(
-                    MobileNetworkSettings.isDpcApnEnforced(mButtonAPNExpand.getContext())
+                    MobileNetworkUtils.isDpcApnEnforced(mButtonAPNExpand.getContext())
                             ? RestrictedLockUtilsInternal.getDeviceOwner(
                                     mButtonAPNExpand.getContext())
                             : null);
diff --git a/src/com/android/settings/mobilenetwork/CdmaSubscriptionListPreference.java b/src/com/android/settings/mobilenetwork/CdmaSubscriptionListPreference.java
index 9752e99..4e3767a 100644
--- a/src/com/android/settings/mobilenetwork/CdmaSubscriptionListPreference.java
+++ b/src/com/android/settings/mobilenetwork/CdmaSubscriptionListPreference.java
@@ -18,7 +18,7 @@
 
 import android.content.Context;
 import android.os.Bundle;
-import android.preference.ListPreference;
+import androidx.preference.ListPreference;
 import android.provider.Settings;
 import android.telephony.TelephonyManager;
 import android.util.AttributeSet;
@@ -29,7 +29,7 @@
 
 public class CdmaSubscriptionListPreference extends ListPreference {
 
-    private static final String LOG_TAG = "CdmaSubscriptionListPreference";
+    private static final String LOG_TAG = "CdmaSubListPref";
 
     // Used for CDMA subscription mode
     private static final int CDMA_SUBSCRIPTION_RUIM_SIM = 0;
@@ -67,17 +67,13 @@
         mTelephonyManager = TelephonyManager.from(getContext()).createForSubscriptionId(subId);
     }
 
-    @Override
+    //TODO(b/114749736): move this logic to preference controller
     protected void showDialog(Bundle state) {
         setCurrentCdmaSubscriptionModeValue();
-
-        super.showDialog(state);
     }
 
-    @Override
+    //TODO(b/114749736): move this logic to preference controller
     protected void onDialogClosed(boolean positiveResult) {
-        super.onDialogClosed(positiveResult);
-
         if (!positiveResult) {
             //The button was dismissed - no need to set new value
             return;
diff --git a/src/com/android/settings/mobilenetwork/CdmaSystemSelectListPreference.java b/src/com/android/settings/mobilenetwork/CdmaSystemSelectListPreference.java
index ab62f88..3d3419f 100644
--- a/src/com/android/settings/mobilenetwork/CdmaSystemSelectListPreference.java
+++ b/src/com/android/settings/mobilenetwork/CdmaSystemSelectListPreference.java
@@ -20,7 +20,6 @@
 import android.os.Bundle;
 import android.os.Handler;
 import android.os.Message;
-import android.preference.ListPreference;
 import android.provider.Settings;
 import android.telephony.TelephonyManager;
 import android.util.AttributeSet;
@@ -28,9 +27,11 @@
 
 import com.android.settingslib.utils.ThreadUtils;
 
+import androidx.preference.ListPreference;
+
 public class CdmaSystemSelectListPreference extends ListPreference {
 
-    private static final String LOG_TAG = "CdmaRoamingListPreference";
+    private static final String LOG_TAG = "CdmaRoamingListPref";
     private static final boolean DBG = false;
 
     private TelephonyManager mTelephonyManager;
@@ -57,17 +58,15 @@
         queryCdmaRoamingMode();
     }
 
-    @Override
+    //TODO(b/114749736): Move this to preference controller
     protected void showDialog(Bundle state) {
         if (!mTelephonyManager.getEmergencyCallbackMode()) {
-            super.showDialog(state);
+            // show Dialog
         }
     }
 
-    @Override
+    //TODO(b/114749736): Move this to preference controller
     protected void onDialogClosed(boolean positiveResult) {
-        super.onDialogClosed(positiveResult);
-
         if (positiveResult && (getValue() != null)) {
             int buttonCdmaRoamingMode = Integer.parseInt(getValue());
             int settingsCdmaRoamingMode = Settings.Global.getInt(
diff --git a/src/com/android/settings/mobilenetwork/CellInfoUtil.java b/src/com/android/settings/mobilenetwork/CellInfoUtil.java
index 3d6cb28..bb5a8b4 100644
--- a/src/com/android/settings/mobilenetwork/CellInfoUtil.java
+++ b/src/com/android/settings/mobilenetwork/CellInfoUtil.java
@@ -127,6 +127,35 @@
         return oi;
     }
 
+    /**
+     * Creates a CellInfo object from OperatorInfo. GsmCellInfo is used here only because
+     * operatorInfo does not contain technology type while CellInfo is an abstract object that
+     * requires to specify technology type. It doesn't matter which CellInfo type to use here, since
+     * we only want to wrap the operator info and PLMN to a CellInfo object.
+     */
+    public static CellInfo convertOperatorInfoToCellInfo(OperatorInfo operatorInfo) {
+        String operatorNumeric = operatorInfo.getOperatorNumeric();
+        String mcc = null;
+        String mnc = null;
+        if (operatorNumeric != null && operatorNumeric.matches("^[0-9]{5,6}$")) {
+            mcc = operatorNumeric.substring(0, 3);
+            mnc = operatorNumeric.substring(3);
+        }
+        CellIdentityGsm cig = new CellIdentityGsm(
+                Integer.MAX_VALUE /* lac */,
+                Integer.MAX_VALUE /* cid */,
+                Integer.MAX_VALUE /* arfcn */,
+                Integer.MAX_VALUE /* bsic */,
+                mcc,
+                mnc,
+                operatorInfo.getOperatorAlphaLong(),
+                operatorInfo.getOperatorAlphaShort());
+
+        CellInfoGsm ci = new CellInfoGsm();
+        ci.setCellIdentity(cig);
+        return ci;
+    }
+
     /** Checks whether the network operator is forbidden. */
     public static boolean isForbidden(CellInfo cellInfo, List<String> forbiddenPlmns) {
         String plmn = CellInfoUtil.getOperatorInfoFromCellInfo(cellInfo).getOperatorNumeric();
diff --git a/src/com/android/settings/mobilenetwork/DataUsagePreference.java b/src/com/android/settings/mobilenetwork/DataUsagePreference.java
index 594f83b..c564e03 100644
--- a/src/com/android/settings/mobilenetwork/DataUsagePreference.java
+++ b/src/com/android/settings/mobilenetwork/DataUsagePreference.java
@@ -20,12 +20,13 @@
 import android.content.Context;
 import android.content.Intent;
 import android.net.NetworkTemplate;
-import android.preference.Preference;
+import androidx.preference.Preference;
 import android.provider.Settings;
 import android.telephony.TelephonyManager;
 import android.text.format.Formatter;
 import android.util.AttributeSet;
 
+import com.android.settings.R;
 import com.android.settingslib.net.DataUsageController;
 
 /**
diff --git a/src/com/android/settings/mobilenetwork/GsmUmtsOptions.java b/src/com/android/settings/mobilenetwork/GsmUmtsOptions.java
index 8400ec3..95f24fb 100644
--- a/src/com/android/settings/mobilenetwork/GsmUmtsOptions.java
+++ b/src/com/android/settings/mobilenetwork/GsmUmtsOptions.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2018 The Android Open Source Project
+ * Copyright (C) 2008 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.
@@ -19,22 +19,21 @@
 import android.content.Context;
 import android.content.Intent;
 import android.os.PersistableBundle;
-import android.preference.Preference;
-import android.preference.PreferenceFragment;
-import android.preference.PreferenceScreen;
 import android.provider.Settings;
 import android.telephony.CarrierConfigManager;
 import android.telephony.TelephonyManager;
 
+import androidx.preference.Preference;
+import androidx.preference.PreferenceFragmentCompat;
+import androidx.preference.PreferenceScreen;
+
 import com.android.internal.logging.MetricsLogger;
 import com.android.internal.logging.nano.MetricsProto.MetricsEvent;
 import com.android.internal.telephony.Phone;
 import com.android.internal.telephony.PhoneConstants;
-import com.android.phone.INetworkQueryService;
-import com.android.phone.MobileNetworkSettings;
-import com.android.phone.PhoneGlobals;
-import com.android.phone.RestrictedPreference;
+import com.android.settings.R;
 import com.android.settingslib.RestrictedLockUtilsInternal;
+import com.android.settingslib.RestrictedPreference;
 
 /**
  * List of Network-specific settings screens.
@@ -54,11 +53,11 @@
     private static final String BUTTON_CARRIER_SETTINGS_KEY = "carrier_settings_key";
 
     public static final String EXTRA_SUB_ID = "sub_id";
-    private PreferenceFragment mPrefFragment;
+    private PreferenceFragmentCompat mPrefFragment;
     private PreferenceScreen mPrefScreen;
 
-    public GsmUmtsOptions(PreferenceFragment prefFragment, PreferenceScreen prefScreen,
-            final int subId, INetworkQueryService queryService) {
+    public GsmUmtsOptions(PreferenceFragmentCompat prefFragment, PreferenceScreen prefScreen,
+            final int subId) {
         final Context context = prefFragment.getContext();
         mPrefFragment = prefFragment;
         mPrefScreen = prefScreen;
@@ -72,18 +71,19 @@
 
         mNetworkOperator.initialize();
 
-        update(subId, queryService);
+        update(subId);
     }
 
-    // Unlike mPrefFragment or mPrefScreen, subId or queryService may change during lifecycle of
-    // GsmUmtsOptions. When that happens, we update GsmUmtsOptions with new parameters.
-    protected void update(final int subId, INetworkQueryService queryService) {
+    // Unlike mPrefFragment or mPrefScreen, subId  may change during lifecycle of GsmUmtsOptions.
+    // When that happens, we update GsmUmtsOptions with new parameters.
+    protected void update(final int subId) {
         boolean addAPNExpand = true;
         boolean addNetworkOperatorsCategory = true;
         boolean addCarrierSettings = true;
         final TelephonyManager telephonyManager = TelephonyManager.from(mPrefFragment.getContext())
                 .createForSubscriptionId(subId);
-        Phone phone = PhoneGlobals.getPhone(subId);
+        //TODO(b/115429509): Get phone from subId
+        Phone phone = null;
         if (phone == null) return;
         if (telephonyManager.getPhoneType() != PhoneConstants.PHONE_TYPE_GSM) {
             log("Not a GSM phone");
@@ -128,9 +128,9 @@
         if (addAPNExpand) {
             log("update: addAPNExpand");
             mButtonAPNExpand.setDisabledByAdmin(
-                    MobileNetworkSettings.isDpcApnEnforced(mButtonAPNExpand.getContext())
+                    MobileNetworkUtils.isDpcApnEnforced(mButtonAPNExpand.getContext())
                             ? RestrictedLockUtilsInternal.getDeviceOwner(
-                                    mButtonAPNExpand.getContext())
+                            mButtonAPNExpand.getContext())
                             : null);
             mButtonAPNExpand.setOnPreferenceClickListener(
                     new Preference.OnPreferenceClickListener() {
@@ -156,7 +156,7 @@
 
         if (addNetworkOperatorsCategory) {
             mPrefScreen.addPreference(mNetworkOperator);
-            mNetworkOperator.update(subId, queryService);
+            mNetworkOperator.update(subId);
         } else {
             mPrefScreen.removePreference(mNetworkOperator);
         }
@@ -177,3 +177,4 @@
         android.util.Log.d(LOG_TAG, s);
     }
 }
+
diff --git a/src/com/android/settings/mobilenetwork/MobileDataPreference.java b/src/com/android/settings/mobilenetwork/MobileDataPreference.java
index 39f4d2c..37ce5a6 100644
--- a/src/com/android/settings/mobilenetwork/MobileDataPreference.java
+++ b/src/com/android/settings/mobilenetwork/MobileDataPreference.java
@@ -25,8 +25,6 @@
 import android.os.Looper;
 import android.os.Parcel;
 import android.os.Parcelable;
-import android.preference.DialogPreference;
-import android.preference.PreferenceScreen;
 import android.provider.Settings.Global;
 import android.telephony.SubscriptionInfo;
 import android.telephony.SubscriptionManager;
@@ -36,8 +34,13 @@
 import android.view.View;
 import android.widget.Checkable;
 
+import androidx.preference.DialogPreference;
+import androidx.preference.PreferenceScreen;
+import androidx.preference.PreferenceViewHolder;
+
 import com.android.internal.logging.MetricsLogger;
 import com.android.internal.logging.nano.MetricsProto.MetricsEvent;
+import com.android.settings.R;
 
 import java.util.List;
 
@@ -45,7 +48,8 @@
  * Customized Preference to enable / disable mobile data.
  * Basically copy of with com.android.settings.CellDataPreference.
  */
-public class MobileDataPreference extends DialogPreference {
+public class MobileDataPreference extends DialogPreference implements
+        DialogInterface.OnClickListener {
 
     private static final boolean DBG = false;
     private static final String TAG = "MobileDataPreference";
@@ -92,8 +96,8 @@
     }
 
     @Override
-    protected void onAttachedToActivity() {
-        super.onAttachedToActivity();
+    public void onAttached() {
+        super.onAttached();
         mListener.setListener(true, mSubId, getContext());
     }
 
@@ -124,7 +128,7 @@
     }
 
     @Override
-    public void performClick(PreferenceScreen preferenceScreen) {
+    public void performClick() {
         if (!isEnabled() || !SubscriptionManager.isValidSubscriptionId(mSubId)) {
             return;
         }
@@ -141,7 +145,7 @@
                 // disabling data; show confirmation dialog which eventually
                 // calls setMobileDataEnabled() once user confirms.
                 mMultiSimDialog = false;
-                super.performClick(preferenceScreen);
+                super.performClick();
             } else {
                 // Don't show any dialog.
                 setMobileDataEnabled(false /* enabled */, false /* disableOtherSubscriptions */);
@@ -151,7 +155,7 @@
                 // enabling data and setting to default; show confirmation dialog which eventually
                 // calls setMobileDataEnabled() once user confirms.
                 mMultiSimDialog = true;
-                super.performClick(preferenceScreen);
+                super.performClick();
             } else {
                 // Don't show any dialog.
                 setMobileDataEnabled(true /* enabled */, false /* disableOtherSubscriptions */);
@@ -181,14 +185,14 @@
     }
 
     @Override
-    protected void onBindView(View view) {
-        super.onBindView(view);
-        View checkableView = view.findViewById(com.android.internal.R.id.switch_widget);
+    public void onBindViewHolder(PreferenceViewHolder holder) {
+        super.onBindViewHolder(holder);
+        View checkableView = holder.findViewById(com.android.internal.R.id.switch_widget);
         checkableView.setClickable(false);
         ((Checkable) checkableView).setChecked(mChecked);
     }
 
-    @Override
+    //TODO(b/114749736): move it to preference controller
     protected void onPrepareDialogBuilder(AlertDialog.Builder builder) {
         if (mMultiSimDialog) {
             showMultiSimDialog(builder);
@@ -217,7 +221,7 @@
                 String.valueOf(currentSir != null ? currentSir.getDisplayName() : null),
                 previousName));
 
-        builder.setPositiveButton(R.string.ok, this);
+        builder.setPositiveButton(android.R.string.ok, this);
         builder.setNegativeButton(R.string.cancel, null);
     }
 
diff --git a/src/com/android/settings/mobilenetwork/MobileNetworkFragment.java b/src/com/android/settings/mobilenetwork/MobileNetworkFragment.java
index 03e7d79..511cd03 100644
--- a/src/com/android/settings/mobilenetwork/MobileNetworkFragment.java
+++ b/src/com/android/settings/mobilenetwork/MobileNetworkFragment.java
@@ -19,8 +19,6 @@
 import static android.provider.Telephony.Carriers.ENFORCE_MANAGED_URI;
 
 import android.app.ActionBar;
-import android.app.Activity;
-import android.app.DialogFragment;
 import android.content.BroadcastReceiver;
 import android.content.Context;
 import android.content.Intent;
@@ -36,12 +34,6 @@
 import android.os.PersistableBundle;
 import android.os.UserHandle;
 import android.os.UserManager;
-import android.preference.ListPreference;
-import android.preference.Preference;
-import android.preference.PreferenceCategory;
-import android.preference.PreferenceFragment;
-import android.preference.PreferenceScreen;
-import android.preference.SwitchPreference;
 import android.provider.Settings;
 import android.telecom.PhoneAccountHandle;
 import android.telecom.TelecomManager;
@@ -67,26 +59,29 @@
 import com.android.internal.telephony.Phone;
 import com.android.internal.telephony.PhoneConstants;
 import com.android.internal.telephony.TelephonyIntents;
-import com.android.phone.AdvancedOptionsPreference;
-import com.android.phone.CdmaOptions;
-import com.android.phone.CdmaSystemSelectListPreference;
-import com.android.phone.DataUsagePreference;
-import com.android.phone.EmergencyCallbackModeExitDialog;
-import com.android.phone.GsmUmtsOptions;
-import com.android.phone.MobileDataPreference;
-import com.android.phone.MobileNetworkSettings;
-import com.android.phone.NetworkOperators;
-import com.android.phone.NetworkSelectListPreference;
-import com.android.phone.RestrictedSwitchPreference;
-import com.android.phone.RoamingDialogFragment;
+import com.android.settings.R;
+import com.android.settings.dashboard.DashboardFragment;
+import com.android.settings.search.BaseSearchIndexProvider;
+import com.android.settings.search.Indexable;
 import com.android.settingslib.RestrictedLockUtilsInternal;
+import com.android.settingslib.RestrictedSwitchPreference;
+import com.android.settingslib.search.SearchIndexable;
 
 import java.util.ArrayList;
 import java.util.Iterator;
 import java.util.List;
 
-public static class MobileNetworkFragment extends PreferenceFragment implements
-        Preference.OnPreferenceChangeListener, com.android.phone.RoamingDialogFragment.RoamingDialogListener {
+import androidx.fragment.app.FragmentActivity;
+import androidx.preference.ListPreference;
+import androidx.preference.Preference;
+import androidx.preference.PreferenceCategory;
+import androidx.preference.PreferenceFragmentCompat;
+import androidx.preference.PreferenceScreen;
+import androidx.preference.SwitchPreference;
+
+@SearchIndexable(forTarget = SearchIndexable.ALL & ~SearchIndexable.ARC)
+public class MobileNetworkFragment extends DashboardFragment implements
+        Preference.OnPreferenceChangeListener, RoamingDialogFragment.RoamingDialogListener {
 
     // debug data
     private static final String LOG_TAG = "NetworkSettings";
@@ -125,10 +120,14 @@
     private static final String BUTTON_GSM_APN_EXPAND_KEY = "button_gsm_apn_key";
     private static final String BUTTON_CDMA_APN_EXPAND_KEY = "button_cdma_apn_key";
 
+    private static final String EXTRA_EXIT_ECM_RESULT = "exit_ecm_result";
+    private static final String LEGACY_ACTION_CONFIGURE_PHONE_ACCOUNT =
+            "android.telecom.action.CONNECTION_SERVICE_CONFIGURE";
+
     private final BroadcastReceiver
-            mPhoneChangeReceiver = new MobileNetworkSettings.MobileNetworkFragment.PhoneChangeReceiver();
+            mPhoneChangeReceiver = new PhoneChangeReceiver();
     private final ContentObserver
-            mDpcEnforcedContentObserver = new MobileNetworkSettings.MobileNetworkFragment.DpcApnEnforcedObserver();
+            mDpcEnforcedContentObserver = new DpcApnEnforcedObserver();
 
     static final int preferredNetworkMode = Phone.PREFERRED_NT_MODE;
 
@@ -142,13 +141,17 @@
     //Intent extra to indicate expand all fields.
     private static final String EXPAND_EXTRA = "expandable";
 
+    private enum TabState {
+        NO_TABS, UPDATE, DO_NOTHING
+    }
+
     private SubscriptionManager mSubscriptionManager;
     private TelephonyManager mTelephonyManager;
     private CarrierConfigManager mCarrierConfigManager;
     private int mSubId;
 
     //UI objects
-    private com.android.phone.AdvancedOptionsPreference mAdvancedOptions;
+    private AdvancedOptionsPreference mAdvancedOptions;
     private ListPreference mButtonPreferredNetworkMode;
     private ListPreference mButtonEnabledNetworks;
     private RestrictedSwitchPreference mButtonDataRoam;
@@ -159,15 +162,15 @@
     private Preference mWiFiCallingPref;
     private SwitchPreference mVideoCallingPref;
     private NetworkSelectListPreference mButtonNetworkSelect;
-    private com.android.phone.MobileDataPreference mMobileDataPref;
-    private com.android.phone.DataUsagePreference mDataUsagePref;
+    private MobileDataPreference mMobileDataPref;
+    private DataUsagePreference mDataUsagePref;
 
     private static final String iface = "rmnet0"; //TODO: this will go away
     private List<SubscriptionInfo> mActiveSubInfos;
 
     private UserManager mUm;
     private ImsManager mImsMgr;
-    private MobileNetworkSettings.MobileNetworkFragment.MyHandler mHandler;
+    private MyHandler mHandler;
     private boolean mOkClicked;
     private boolean mExpandAdvancedFields;
 
@@ -175,8 +178,8 @@
     private TabHost mTabHost;
 
     //GsmUmts options and Cdma options
-    com.android.phone.GsmUmtsOptions mGsmUmtsOptions;
-    com.android.phone.CdmaOptions mCdmaOptions;
+    GsmUmtsOptions mGsmUmtsOptions;
+    CdmaOptions mCdmaOptions;
 
     private Preference mClickedPreference;
     private boolean mShow4GForLTE;
@@ -205,11 +208,11 @@
          * Listen to different subId if it's changed.
          */
         protected void updateSubscriptionId(Integer subId) {
-            if (subId.equals(MobileNetworkSettings.MobileNetworkFragment.PhoneCallStateListener.this.mSubId)) {
+            if (subId.equals(PhoneCallStateListener.this.mSubId)) {
                 return;
             }
 
-            MobileNetworkSettings.MobileNetworkFragment.PhoneCallStateListener.this.mSubId = subId;
+            PhoneCallStateListener.this.mSubId = subId;
 
             mTelephonyManager.listen(this, PhoneStateListener.LISTEN_NONE);
 
@@ -220,11 +223,24 @@
         }
     }
 
-    private final MobileNetworkSettings.MobileNetworkFragment.PhoneCallStateListener
-            mPhoneStateListener = new MobileNetworkSettings.MobileNetworkFragment.PhoneCallStateListener();
+    private final PhoneCallStateListener
+            mPhoneStateListener = new PhoneCallStateListener();
+
+    //TODO(b/114749736): figure out a way to update this fragment from intent
+    public void onIntentUpdate(Intent intent) {
+        if (!mUnavailable) {
+            updateCurrentTab(intent);
+        }
+    }
 
     @Override
-    public void onPositiveButtonClick(DialogFragment dialog) {
+    public int getMetricsCategory() {
+        //TODO(b/114749736): add metrics id for it
+        return 0;
+    }
+
+    @Override
+    public void onPositiveButtonClick(androidx.fragment.app.DialogFragment dialog) {
         mTelephonyManager.setDataRoamingEnabled(true);
         mButtonDataRoam.setChecked(true);
         MetricsLogger.action(getContext(),
@@ -232,28 +248,14 @@
                 true);
     }
 
-    @Override
-    public void onViewCreated(View view, Bundle savedInstanceState) {
-        if (getListView() != null) {
-            getListView().setDivider(null);
-        }
-    }
-
-    public void onIntentUpdate(Intent intent) {
-        if (!mUnavailable) {
-            updateCurrentTab(intent);
-        }
-    }
-
     /**
      * Invoked on each preference click in this hierarchy, overrides
      * PreferenceActivity's implementation.  Used to make sure we track the
      * preference click events.
      */
     @Override
-    public boolean onPreferenceTreeClick(PreferenceScreen preferenceScreen,
-            Preference preference) {
-        sendMetricsEventPreferenceClicked(preferenceScreen, preference);
+    public boolean onPreferenceTreeClick(Preference preference) {
+        sendMetricsEventPreferenceClicked(getPreferenceScreen(), preference);
 
         /** TODO: Refactor and get rid of the if's using subclasses */
         if (preference.getKey().equals(BUTTON_4G_LTE_KEY)) {
@@ -283,7 +285,7 @@
             return true;
         } else if (preference == mLteDataServicePref) {
             String tmpl = android.provider.Settings.Global.getString(
-                    getActivity().getContentResolver(),
+                    getContext().getContentResolver(),
                     android.provider.Settings.Global.SETUP_PREPAID_DATA_SERVICE_URL);
             if (!TextUtils.isEmpty(tmpl)) {
                 String imsi = mTelephonyManager.getSubscriberId();
@@ -323,7 +325,7 @@
             // if the button is anything but the simple toggle preference,
             // we'll need to disable all preferences to reject all click
             // events until the sub-activity's UI comes up.
-            preferenceScreen.setEnabled(false);
+            getPreferenceScreen().setEnabled(false);
             // Let the intents be launched by the Preference manager
             return false;
         }
@@ -349,8 +351,8 @@
     }
 
     private void initializeSubscriptions() {
-        final Activity activity = getActivity();
-        if (activity == null || activity.isDestroyed()) {
+        final FragmentActivity activity = getActivity();
+        if (activity == null) {
             // Process preferences in activity only if its not destroyed
             return;
         }
@@ -360,7 +362,7 @@
         // Before updating the the active subscription list check
         // if tab updating is needed as the list is changing.
         List<SubscriptionInfo> sil = mSubscriptionManager.getActiveSubscriptionInfoList();
-        MobileNetworkSettings.TabState state = isUpdateTabsNeeded(sil);
+        TabState state = isUpdateTabsNeeded(sil);
 
         // Update to the active subscription list
         mActiveSubInfos.clear();
@@ -430,19 +432,19 @@
         if (DBG) log("initializeSubscriptions:-");
     }
 
-    private MobileNetworkSettings.TabState isUpdateTabsNeeded(List<SubscriptionInfo> newSil) {
-        MobileNetworkSettings.TabState state = MobileNetworkSettings.TabState.DO_NOTHING;
+    private TabState isUpdateTabsNeeded(List<SubscriptionInfo> newSil) {
+        TabState state = TabState.DO_NOTHING;
         if (newSil == null) {
             if (mActiveSubInfos.size() >= TAB_THRESHOLD) {
                 if (DBG) log("isUpdateTabsNeeded: NO_TABS, size unknown and was tabbed");
-                state = MobileNetworkSettings.TabState.NO_TABS;
+                state = TabState.NO_TABS;
             }
         } else if (newSil.size() < TAB_THRESHOLD && mActiveSubInfos.size() >= TAB_THRESHOLD) {
             if (DBG) log("isUpdateTabsNeeded: NO_TABS, size went to small");
-            state = MobileNetworkSettings.TabState.NO_TABS;
+            state = TabState.NO_TABS;
         } else if (newSil.size() >= TAB_THRESHOLD && mActiveSubInfos.size() < TAB_THRESHOLD) {
             if (DBG) log("isUpdateTabsNeeded: UPDATE, size changed");
-            state = MobileNetworkSettings.TabState.UPDATE;
+            state = TabState.UPDATE;
         } else if (newSil.size() >= TAB_THRESHOLD) {
             Iterator<SubscriptionInfo> siIterator = mActiveSubInfos.iterator();
             for(SubscriptionInfo newSi : newSil) {
@@ -450,7 +452,7 @@
                 if (!newSi.getDisplayName().equals(curSi.getDisplayName())) {
                     if (DBG) log("isUpdateTabsNeeded: UPDATE, new name="
                             + newSi.getDisplayName());
-                    state = MobileNetworkSettings.TabState.UPDATE;
+                    state = TabState.UPDATE;
                     break;
                 }
             }
@@ -530,28 +532,26 @@
     public void onCreate(Bundle icicle) {
         Log.i(LOG_TAG, "onCreate:+");
         super.onCreate(icicle);
+        final Context context = getContext();
 
-        final Activity activity = getActivity();
-        if (activity == null || activity.isDestroyed()) {
+        if (context == null) {
             Log.e(LOG_TAG, "onCreate:- with no valid activity.");
             return;
         }
 
-        mHandler = new MobileNetworkSettings.MobileNetworkFragment.MyHandler();
-        mUm = (UserManager) activity.getSystemService(Context.USER_SERVICE);
-        mSubscriptionManager = SubscriptionManager.from(activity);
-        mTelephonyManager = (TelephonyManager) activity.getSystemService(
+        mHandler = new MyHandler();
+        mUm = (UserManager) context.getSystemService(Context.USER_SERVICE);
+        mSubscriptionManager = SubscriptionManager.from(context);
+        mTelephonyManager = (TelephonyManager) context.getSystemService(
                 Context.TELEPHONY_SERVICE);
         mCarrierConfigManager = new CarrierConfigManager(getContext());
 
         if (icicle != null) {
             mExpandAdvancedFields = icicle.getBoolean(EXPAND_ADVANCED_FIELDS, false);
-        } else if (getActivity().getIntent().getBooleanExtra(EXPAND_EXTRA, false)) {
+        } else if (getIntent().getBooleanExtra(EXPAND_EXTRA, false)) {
             mExpandAdvancedFields = true;
         }
 
-        addPreferencesFromResource(R.xml.network_setting_fragment);
-
         mButton4glte = (SwitchPreference)findPreference(BUTTON_4G_LTE_KEY);
         mButton4glte.setOnPreferenceChangeListener(this);
 
@@ -562,7 +562,7 @@
         mDataUsagePref = (DataUsagePreference) findPreference(BUTTON_DATA_USAGE_KEY);
 
         try {
-            Context con = activity.createPackageContext("com.android.systemui", 0);
+            Context con = context.createPackageContext("com.android.systemui", 0);
             int id = con.getResources().getIdentifier("config_show4GForLTE",
                     "bool", "com.android.systemui");
             mShow4GForLTE = con.getResources().getBoolean(id);
@@ -614,7 +614,7 @@
         if (mUm.hasUserRestriction(UserManager.DISALLOW_CONFIG_MOBILE_NETWORKS)
                 || !mUm.isSystemUser()) {
             mUnavailable = true;
-            getActivity().setContentView(R.layout.telephony_disallowed_preference_screen);
+            //TODO(b/114749736): migrate telephony_disallowed_preference_screen.xml
         } else {
             initializeSubscriptions();
             updateCurrentTab(getActivity().getIntent());
@@ -692,7 +692,7 @@
 
         mSubscriptionManager.addOnSubscriptionsChangedListener(mOnSubscriptionsChangeListener);
 
-        final Context context = getActivity();
+        final Context context = getContext();
         IntentFilter intentFilter = new IntentFilter(
                 TelephonyIntents.ACTION_RADIO_TECHNOLOGY_CHANGED);
         context.registerReceiver(mPhoneChangeReceiver, intentFilter);
@@ -703,13 +703,23 @@
 
     }
 
+    @Override
+    protected int getPreferenceScreenResId() {
+        return R.xml.network_setting_fragment;
+    }
+
+    @Override
+    protected String getLogTag() {
+        return null;
+    }
+
     private boolean hasActiveSubscriptions() {
         return mActiveSubInfos.size() > 0;
     }
 
-    private void updateBodyBasicFields(Activity activity, PreferenceScreen prefSet,
+    private void updateBodyBasicFields(FragmentActivity activity, PreferenceScreen prefSet,
             int phoneSubId, boolean hasActiveSubscriptions) {
-        Context context = activity.getApplicationContext();
+        Context context = getContext();
 
         ActionBar actionBar = activity.getActionBar();
         if (actionBar != null) {
@@ -732,7 +742,6 @@
 
             // Initialize states of mButtonDataRoam.
             mButtonDataRoam.setChecked(mTelephonyManager.isDataRoamingEnabled());
-            mButtonDataRoam.setDisabledByAdmin(false);
             if (mButtonDataRoam.isEnabled()) {
                 if (RestrictedLockUtilsInternal.hasBaseUserRestriction(context,
                         UserManager.DISALLOW_DATA_ROAMING, UserHandle.myUserId())) {
@@ -746,11 +755,11 @@
     }
 
     private void updateBody() {
-        final Activity activity = getActivity();
+        final FragmentActivity activity = getActivity();
         final PreferenceScreen prefSet = getPreferenceScreen();
         final boolean hasActiveSubscriptions = hasActiveSubscriptions();
 
-        if (activity == null || activity.isDestroyed()) {
+        if (activity == null) {
             Log.e(LOG_TAG, "updateBody with no valid activity.");
             return;
         }
@@ -772,14 +781,14 @@
             }
         } else {
             // Shows the "Carrier" preference that allows user to add a e-sim profile.
-            if (showEuiccSettings(getContext())) {
+            if (MobileNetworkUtils.showEuiccSettings(getContext())) {
                 mEuiccSettingsPref.setSummary(null /* summary */);
                 prefSet.addPreference(mEuiccSettingsPref);
             }
         }
     }
 
-    private void updateBodyAdvancedFields(Activity activity, PreferenceScreen prefSet,
+    private void updateBodyAdvancedFields(FragmentActivity activity, PreferenceScreen prefSet,
             int phoneSubId, boolean hasActiveSubscriptions) {
         boolean isLteOnCdma = mTelephonyManager.getLteOnCdmaMode()
                 == PhoneConstants.LTE_ON_CDMA_TRUE;
@@ -792,7 +801,7 @@
         prefSet.addPreference(mButtonEnabledNetworks);
         prefSet.addPreference(mButton4glte);
 
-        if (showEuiccSettings(getActivity())) {
+        if (MobileNetworkUtils.showEuiccSettings(getContext())) {
             prefSet.addPreference(mEuiccSettingsPref);
             String spn = mTelephonyManager.getSimOperatorName();
             if (TextUtils.isEmpty(spn)) {
@@ -895,11 +904,11 @@
         UpdatePreferredNetworkModeSummary(settingsNetworkMode);
         UpdateEnabledNetworksValueAndSummary(settingsNetworkMode);
         // Display preferred network type based on what modem returns b/18676277
-        new MobileNetworkSettings.SetPreferredNetworkAsyncTask(
+        new SetPreferredNetworkAsyncTask(
                 mTelephonyManager,
                 mSubId,
                 settingsNetworkMode,
-                mHandler.obtainMessage(MobileNetworkSettings.MobileNetworkFragment.MyHandler.MESSAGE_SET_PREFERRED_NETWORK_TYPE))
+                mHandler.obtainMessage(MyHandler.MESSAGE_SET_PREFERRED_NETWORK_TYPE))
                 .executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
 
         /**
@@ -934,7 +943,7 @@
         if (ps != null) {
             ps.setEnabled(hasActiveSubscriptions);
         }
-        ps = findPreference(com.android.phone.NetworkOperators.CATEGORY_NETWORK_OPERATORS_KEY);
+        ps = findPreference(NetworkOperators.CATEGORY_NETWORK_OPERATORS_KEY);
         if (ps != null) {
             ps.setEnabled(hasActiveSubscriptions);
         }
@@ -950,7 +959,7 @@
         if (ps != null) {
             ps.setEnabled(hasActiveSubscriptions);
         }
-        ps = findPreference(com.android.phone.NetworkOperators.BUTTON_AUTO_SELECT_KEY);
+        ps = findPreference(NetworkOperators.BUTTON_AUTO_SELECT_KEY);
         if (ps != null) {
             ps.setSummary(null);
             if (mTelephonyManager.getServiceState().getRoaming()) {
@@ -1143,11 +1152,11 @@
                         android.provider.Settings.Global.PREFERRED_NETWORK_MODE + phoneSubId,
                         buttonNetworkMode );
                 //Set the modem network mode
-                new MobileNetworkSettings.SetPreferredNetworkAsyncTask(
+                new SetPreferredNetworkAsyncTask(
                         mTelephonyManager,
                         mSubId,
                         modemNetworkMode,
-                        mHandler.obtainMessage(MobileNetworkSettings.MobileNetworkFragment.MyHandler.MESSAGE_SET_PREFERRED_NETWORK_TYPE))
+                        mHandler.obtainMessage(MyHandler.MESSAGE_SET_PREFERRED_NETWORK_TYPE))
                         .executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
             }
         } else if (preference == mButtonEnabledNetworks) {
@@ -1195,11 +1204,11 @@
                         android.provider.Settings.Global.PREFERRED_NETWORK_MODE + phoneSubId,
                         buttonNetworkMode );
                 //Set the modem network mode
-                new MobileNetworkSettings.SetPreferredNetworkAsyncTask(
+                new SetPreferredNetworkAsyncTask(
                         mTelephonyManager,
                         mSubId,
                         modemNetworkMode,
-                        mHandler.obtainMessage(MobileNetworkSettings.MobileNetworkFragment.MyHandler.MESSAGE_SET_PREFERRED_NETWORK_TYPE))
+                        mHandler.obtainMessage(MyHandler.MESSAGE_SET_PREFERRED_NETWORK_TYPE))
                         .executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
             }
         } else if (preference == mButton4glte) {
@@ -1225,8 +1234,8 @@
                             getMetricsEventCategory(getPreferenceScreen(), mButtonDataRoam));
                     // First confirm with a warning dialog about charges
                     mOkClicked = false;
-                    com.android.phone.RoamingDialogFragment
-                            fragment = new com.android.phone.RoamingDialogFragment();
+                    RoamingDialogFragment
+                            fragment = new RoamingDialogFragment();
                     Bundle b = new Bundle();
                     b.putInt(RoamingDialogFragment.SUB_ID_KEY, mSubId);
                     fragment.setArguments(b);
@@ -1287,7 +1296,7 @@
         }
 
         private void handleSetPreferredNetworkTypeResponse(Message msg) {
-            final Activity activity = getActivity();
+            final FragmentActivity activity = getActivity();
             if (activity == null || activity.isDestroyed()) {
                 // Access preferences of activity only if it is not destroyed
                 // or if fragment is not attached to an activity.
@@ -1589,7 +1598,7 @@
         switch(requestCode) {
             case REQUEST_CODE_EXIT_ECM:
                 Boolean isChoiceYes = data.getBooleanExtra(
-                        EmergencyCallbackModeExitDialog.EXTRA_EXIT_ECM_RESULT, false);
+                        EXTRA_EXIT_ECM_RESULT, false);
                 if (isChoiceYes) {
                     // If the phone exits from ECM mode, show the CDMA Options
                     mCdmaOptions.showDialog(mClickedPreference);
@@ -1609,7 +1618,8 @@
         }
 
         // Removes the preference if the wifi calling is disabled.
-        if (!isWifiCallingEnabled(getContext(), SubscriptionManager.getPhoneId(mSubId))) {
+        if (!MobileNetworkUtils.isWifiCallingEnabled(getContext(),
+                SubscriptionManager.getPhoneId(mSubId))) {
             mCallingCategory.removePreference(mWiFiCallingPref);
             return;
         }
@@ -1618,8 +1628,7 @@
                 TelecomManager.from(getContext()).getSimCallManager();
 
         if (simCallManager != null) {
-            Intent intent = MobileNetworkSettings.buildPhoneAccountConfigureIntent(
-                    getContext(), simCallManager);
+            Intent intent = buildPhoneAccountConfigureIntent(getContext(), simCallManager);
             PackageManager pm = getContext().getPackageManager();
             List<ResolveInfo> resolutions = pm.queryIntentActivities(intent, 0);
             mWiFiCallingPref.setTitle(resolutions.get(0).loadLabel(pm));
@@ -1664,7 +1673,7 @@
         if ((mImsMgr == null
                 || !mImsMgr.isVolteEnabledByPlatform()
                 || !mImsMgr.isVolteProvisionedOnDevice()
-                || !isImsServiceStateReady(mImsMgr)
+                || !MobileNetworkUtils.isImsServiceStateReady(mImsMgr)
                 || carrierConfig.getBoolean(
                 CarrierConfigManager.KEY_HIDE_ENHANCED_4G_LTE_BOOL))) {
             getPreferenceScreen().removePreference(mButton4glte);
@@ -1687,7 +1696,7 @@
         if (mImsMgr != null
                 && mImsMgr.isVtEnabledByPlatform()
                 && mImsMgr.isVtProvisionedOnDevice()
-                && isImsServiceStateReady(mImsMgr)
+                && MobileNetworkUtils.isImsServiceStateReady(mImsMgr)
                 && (carrierConfig.getBoolean(
                 CarrierConfigManager.KEY_IGNORE_DATA_ENABLED_CHANGED_FOR_VIDEO_CALLS)
                 || mTelephonyManager.isDataEnabled())) {
@@ -1802,7 +1811,7 @@
 
         PreferenceCategory networkOperatorCategory =
                 (PreferenceCategory) prefSet.findPreference(
-                        com.android.phone.NetworkOperators.CATEGORY_NETWORK_OPERATORS_KEY);
+                        NetworkOperators.CATEGORY_NETWORK_OPERATORS_KEY);
         Preference carrierSettings = prefSet.findPreference(BUTTON_CARRIER_SETTINGS_KEY);
         if (networkOperatorCategory != null) {
             if (enable) {
@@ -1822,7 +1831,7 @@
             return;
         }
         updateCdmaOptions(this, prefSet, mSubId);
-        com.android.phone.CdmaSystemSelectListPreference systemSelect =
+        CdmaSystemSelectListPreference systemSelect =
                 (CdmaSystemSelectListPreference)prefSet.findPreference
                         (BUTTON_CDMA_SYSTEM_SELECT_KEY);
         systemSelect.setSubscriptionId(mSubId);
@@ -1929,7 +1938,7 @@
         } else if (preference == mVideoCallingPref) {
             return MetricsProto.MetricsEvent.ACTION_MOBILE_NETWORK_VIDEO_CALLING_TOGGLE;
         } else if (preference == preferenceScreen
-                .findPreference(com.android.phone.NetworkOperators.BUTTON_AUTO_SELECT_KEY)) {
+                .findPreference(NetworkOperators.BUTTON_AUTO_SELECT_KEY)) {
             return MetricsProto.MetricsEvent.ACTION_MOBILE_NETWORK_AUTO_SELECT_NETWORK_TOGGLE;
         } else if (preference == preferenceScreen
                 .findPreference(NetworkOperators.BUTTON_NETWORK_SELECT_KEY)) {
@@ -1950,7 +1959,7 @@
         }
     }
 
-    private void updateGsmUmtsOptions(PreferenceFragment prefFragment,
+    private void updateGsmUmtsOptions(PreferenceFragmentCompat prefFragment,
             PreferenceScreen prefScreen, final int subId) {
         // We don't want to re-create GsmUmtsOptions if already exists. Otherwise, the
         // preferences inside it will also be re-created which causes unexpected behavior.
@@ -1962,7 +1971,7 @@
         }
     }
 
-    private void updateCdmaOptions(PreferenceFragment prefFragment, PreferenceScreen prefScreen,
+    private void updateCdmaOptions(PreferenceFragmentCompat prefFragment, PreferenceScreen prefScreen,
             int subId) {
         // We don't want to re-create CdmaOptions if already exists. Otherwise, the preferences
         // inside it will also be re-created which causes unexpected behavior. For example,
@@ -1973,31 +1982,80 @@
             mCdmaOptions.updateSubscriptionId(subId);
         }
     }
+
+    private static Intent buildPhoneAccountConfigureIntent(
+            Context context, PhoneAccountHandle accountHandle) {
+        Intent intent = buildConfigureIntent(
+                context, accountHandle, TelecomManager.ACTION_CONFIGURE_PHONE_ACCOUNT);
+
+        if (intent == null) {
+            // If the new configuration didn't work, try the old configuration intent.
+            intent = buildConfigureIntent(
+                    context, accountHandle, LEGACY_ACTION_CONFIGURE_PHONE_ACCOUNT);
+            if (intent != null) {
+                Log.w(MobileNetworkFragment.LOG_TAG,
+                        "Phone account using old configuration intent: " + accountHandle);
+            }
+        }
+        return intent;
+    }
+
+    private static Intent buildConfigureIntent(
+            Context context, PhoneAccountHandle accountHandle, String actionStr) {
+        if (accountHandle == null || accountHandle.getComponentName() == null
+                || TextUtils.isEmpty(accountHandle.getComponentName().getPackageName())) {
+            return null;
+        }
+
+        // Build the settings intent.
+        Intent intent = new Intent(actionStr);
+        intent.setPackage(accountHandle.getComponentName().getPackageName());
+        intent.addCategory(Intent.CATEGORY_DEFAULT);
+        intent.putExtra(TelecomManager.EXTRA_PHONE_ACCOUNT_HANDLE, accountHandle);
+
+        // Check to see that the phone account package can handle the setting intent.
+        PackageManager pm = context.getPackageManager();
+        List<ResolveInfo> resolutions = pm.queryIntentActivities(intent, 0);
+        if (resolutions.size() == 0) {
+            intent = null;  // set no intent if the package cannot handle it.
+        }
+
+        return intent;
+    }
+
+    //TODO(b/114749736): update search provider
+    public static final Indexable.SearchIndexProvider SEARCH_INDEX_DATA_PROVIDER =
+            new BaseSearchIndexProvider() {
+                @Override
+                protected boolean isPageSearchEnabled(Context context) {
+                    return false;
+                }
+            };
+
+    private static final class SetPreferredNetworkAsyncTask extends AsyncTask<Void, Void, Boolean> {
+
+        private final TelephonyManager mTelephonyManager;
+        private final int mSubId;
+        private final int mNetworkType;
+        private final Message mCallback;
+
+        SetPreferredNetworkAsyncTask(
+                TelephonyManager tm, int subId, int networkType, Message callback) {
+            mTelephonyManager = tm;
+            mSubId = subId;
+            mNetworkType = networkType;
+            mCallback = callback;
+        }
+
+        @Override
+        protected Boolean doInBackground(Void... voids) {
+            return mTelephonyManager.setPreferredNetworkType(mSubId, mNetworkType);
+        }
+
+        @Override
+        protected void onPostExecute(Boolean isSuccessed) {
+            mCallback.obj = isSuccessed;
+            mCallback.sendToTarget();
+        }
+    }
 }
-
-private static final class SetPreferredNetworkAsyncTask extends AsyncTask<Void, Void, Boolean> {
-
-    private final TelephonyManager mTelephonyManager;
-    private final int mSubId;
-    private final int mNetworkType;
-    private final Message mCallback;
-
-    SetPreferredNetworkAsyncTask(
-            TelephonyManager tm, int subId, int networkType, Message callback) {
-        mTelephonyManager = tm;
-        mSubId = subId;
-        mNetworkType = networkType;
-        mCallback = callback;
-    }
-
-    @Override
-    protected Boolean doInBackground(Void... voids) {
-        return mTelephonyManager.setPreferredNetworkType(mSubId, mNetworkType);
-    }
-
-    @Override
-    protected void onPostExecute(Boolean isSuccessed) {
-        mCallback.obj = isSuccessed;
-        mCallback.sendToTarget();
-    }
-}
\ No newline at end of file
diff --git a/src/com/android/settings/mobilenetwork/MobileNetworkUtils.java b/src/com/android/settings/mobilenetwork/MobileNetworkUtils.java
new file mode 100644
index 0000000..2109375
--- /dev/null
+++ b/src/com/android/settings/mobilenetwork/MobileNetworkUtils.java
@@ -0,0 +1,173 @@
+/*
+ * 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.mobilenetwork;
+
+import static android.provider.Telephony.Carriers.ENFORCE_MANAGED_URI;
+
+import android.content.ContentResolver;
+import android.content.Context;
+import android.content.Intent;
+import android.content.pm.PackageManager;
+import android.content.pm.ResolveInfo;
+import android.database.Cursor;
+import android.os.PersistableBundle;
+import android.os.SystemProperties;
+import android.provider.Settings;
+import android.telecom.PhoneAccountHandle;
+import android.telecom.TelecomManager;
+import android.telephony.TelephonyManager;
+import android.telephony.euicc.EuiccManager;
+import android.telephony.ims.feature.ImsFeature;
+import android.text.TextUtils;
+import android.util.Log;
+
+import com.android.ims.ImsException;
+import com.android.ims.ImsManager;
+
+import java.util.Arrays;
+import java.util.List;
+
+public class MobileNetworkUtils {
+
+    private static final String TAG = "MobileNetworkUtils";
+
+    // CID of the device.
+    private static final String KEY_CID = "ro.boot.cid";
+    // CIDs of devices which should not show anything related to eSIM.
+    private static final String KEY_ESIM_CID_IGNORE = "ro.setupwizard.esim_cid_ignore";
+    // System Property which is used to decide whether the default eSIM UI will be shown,
+    // the default value is false.
+    private static final String KEY_ENABLE_ESIM_UI_BY_DEFAULT =
+            "esim.enable_esim_system_ui_by_default";
+
+    /**
+     * Returns if DPC APNs are enforced.
+     */
+    public static boolean isDpcApnEnforced(Context context) {
+        try (Cursor enforceCursor = context.getContentResolver().query(ENFORCE_MANAGED_URI,
+                null, null, null, null)) {
+            if (enforceCursor == null || enforceCursor.getCount() != 1) {
+                return false;
+            }
+            enforceCursor.moveToFirst();
+            return enforceCursor.getInt(0) > 0;
+        }
+    }
+
+    /**
+     * Returns true if Wifi calling is enabled for at least one phone.
+     */
+    public static boolean isWifiCallingEnabled(Context context) {
+        int phoneCount = TelephonyManager.from(context).getPhoneCount();
+        for (int i = 0; i < phoneCount; i++) {
+            if (isWifiCallingEnabled(context, i)) {
+                return true;
+            }
+        }
+        return false;
+    }
+
+    /**
+     * Returns true if Wifi calling is enabled for the specific phone with id {@code phoneId}.
+     */
+    public static boolean isWifiCallingEnabled(Context context, int phoneId) {
+        final PhoneAccountHandle simCallManager =
+                TelecomManager.from(context).getSimCallManager();
+
+        boolean isWifiCallingEnabled;
+        if (simCallManager != null) {
+            //TODO(b/114749736): build intent to query wifi calling feature
+            final Intent intent = null;
+            PackageManager pm = context.getPackageManager();
+            isWifiCallingEnabled = intent != null
+                    && !pm.queryIntentActivities(intent, 0 /* flags */).isEmpty();
+        } else {
+            ImsManager imsMgr = ImsManager.getInstance(context, phoneId);
+            isWifiCallingEnabled = imsMgr != null
+                    && imsMgr.isWfcEnabledByPlatform()
+                    && imsMgr.isWfcProvisionedOnDevice()
+                    && isImsServiceStateReady(imsMgr);
+        }
+
+        return isWifiCallingEnabled;
+    }
+
+    public static boolean isImsServiceStateReady(ImsManager imsMgr) {
+        boolean isImsServiceStateReady = false;
+
+        try {
+            if (imsMgr != null && imsMgr.getImsServiceState() == ImsFeature.STATE_READY) {
+                isImsServiceStateReady = true;
+            }
+        } catch (ImsException ex) {
+            Log.e(TAG, "Exception when trying to get ImsServiceStatus: " + ex);
+        }
+
+        Log.d(TAG, "isImsServiceStateReady=" + isImsServiceStateReady);
+        return isImsServiceStateReady;
+    }
+
+    /**
+     * Whether to show the entry point to eUICC settings.
+     *
+     * <p>We show the entry point on any device which supports eUICC as long as either the eUICC
+     * was ever provisioned (that is, at least one profile was ever downloaded onto it), or if
+     * the user has enabled development mode.
+     */
+    public static boolean showEuiccSettings(Context context) {
+        EuiccManager euiccManager =
+                (EuiccManager) context.getSystemService(Context.EUICC_SERVICE);
+        if (!euiccManager.isEnabled()) {
+            return false;
+        }
+
+        final ContentResolver cr = context.getContentResolver();
+
+        TelephonyManager tm =
+                (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE);
+        String currentCountry = tm.getNetworkCountryIso().toLowerCase();
+        String supportedCountries =
+                Settings.Global.getString(cr, Settings.Global.EUICC_SUPPORTED_COUNTRIES);
+        boolean inEsimSupportedCountries = false;
+        if (TextUtils.isEmpty(currentCountry)) {
+            inEsimSupportedCountries = true;
+        } else if (!TextUtils.isEmpty(supportedCountries)) {
+            List<String> supportedCountryList =
+                    Arrays.asList(TextUtils.split(supportedCountries.toLowerCase(), ","));
+            if (supportedCountryList.contains(currentCountry)) {
+                inEsimSupportedCountries = true;
+            }
+        }
+        final boolean esimIgnoredDevice =
+                Arrays.asList(TextUtils.split(SystemProperties.get(KEY_ESIM_CID_IGNORE, ""), ","))
+                        .contains(SystemProperties.get(KEY_CID, null));
+        final boolean enabledEsimUiByDefault =
+                SystemProperties.getBoolean(KEY_ENABLE_ESIM_UI_BY_DEFAULT, true);
+        final boolean euiccProvisioned =
+                Settings.Global.getInt(cr, Settings.Global.EUICC_PROVISIONED, 0) != 0;
+        final boolean inDeveloperMode =
+                Settings.Global.getInt(cr, Settings.Global.DEVELOPMENT_SETTINGS_ENABLED, 0) != 0;
+
+        return (inDeveloperMode || euiccProvisioned
+                || (!esimIgnoredDevice && enabledEsimUiByDefault && inEsimSupportedCountries));
+    }
+
+    public static PersistableBundle getCarrierConfigBySubId(int mSubId) {
+        //TODO(b/114749736): get carrier config from subId
+        return new PersistableBundle();
+    }
+}
\ No newline at end of file
diff --git a/src/com/android/settings/mobilenetwork/NetworkOperators.java b/src/com/android/settings/mobilenetwork/NetworkOperators.java
index b07a170..9f0de8a 100644
--- a/src/com/android/settings/mobilenetwork/NetworkOperators.java
+++ b/src/com/android/settings/mobilenetwork/NetworkOperators.java
@@ -21,9 +21,6 @@
 import android.content.Intent;
 import android.os.Handler;
 import android.os.Message;
-import android.preference.Preference;
-import android.preference.PreferenceCategory;
-import android.preference.TwoStatePreference;
 import android.telephony.ServiceState;
 import android.telephony.SubscriptionManager;
 import android.telephony.TelephonyManager;
@@ -31,9 +28,13 @@
 import android.util.Log;
 import android.widget.Toast;
 
+import androidx.preference.Preference;
+import androidx.preference.PreferenceCategory;
+import androidx.preference.TwoStatePreference;
+
 import com.android.internal.logging.MetricsLogger;
 import com.android.internal.logging.nano.MetricsProto.MetricsEvent;
-import com.android.phone.NetworkSelectSettingActivity;
+import com.android.settings.R;
 import com.android.settingslib.utils.ThreadUtils;
 
 /**
@@ -273,7 +274,8 @@
      * Open the Choose network page via {@alink NetworkSelectSettingActivity}
      */
     public void openChooseNetworkPage() {
-        Intent intent = NetworkSelectSettingActivity.getIntent(getContext(), mSubId);
+        //TODO(b/114749736): Build intent without calling static method
+        Intent intent = new Intent();
         getContext().startActivity(intent);
     }
 
diff --git a/src/com/android/settings/mobilenetwork/NetworkScanHelper.java b/src/com/android/settings/mobilenetwork/NetworkScanHelper.java
index 59908bc..234d3b3 100644
--- a/src/com/android/settings/mobilenetwork/NetworkScanHelper.java
+++ b/src/com/android/settings/mobilenetwork/NetworkScanHelper.java
@@ -27,7 +27,6 @@
 import android.util.Log;
 
 import com.android.internal.telephony.CellNetworkScanResult;
-import com.android.phone.CellInfoUtil;
 
 import com.google.common.util.concurrent.FutureCallback;
 import com.google.common.util.concurrent.Futures;
diff --git a/src/com/android/settings/mobilenetwork/NetworkSelectListPreference.java b/src/com/android/settings/mobilenetwork/NetworkSelectListPreference.java
index 95283dc..c4d0d77 100644
--- a/src/com/android/settings/mobilenetwork/NetworkSelectListPreference.java
+++ b/src/com/android/settings/mobilenetwork/NetworkSelectListPreference.java
@@ -14,7 +14,7 @@
  * limitations under the License.
  */
 
-package com.android.phone;
+package com.android.settings.mobilenetwork;
 
 import android.app.ProgressDialog;
 import android.content.Context;
@@ -24,8 +24,6 @@
 import android.os.Message;
 import android.os.Parcel;
 import android.os.Parcelable;
-import android.preference.ListPreference;
-import android.preference.Preference;
 import android.telephony.CellInfo;
 import android.telephony.CellInfoCdma;
 import android.telephony.CellInfoGsm;
@@ -43,7 +41,7 @@
 import com.android.internal.logging.MetricsLogger;
 import com.android.internal.logging.nano.MetricsProto.MetricsEvent;
 import com.android.internal.telephony.OperatorInfo;
-import com.android.phone.NetworkScanHelper.NetworkScanCallback;
+import com.android.settings.R;
 import com.android.settingslib.utils.ThreadUtils;
 
 import java.util.ArrayList;
@@ -52,6 +50,9 @@
 import java.util.concurrent.ExecutorService;
 import java.util.concurrent.Executors;
 
+import androidx.preference.ListPreference;
+import androidx.preference.Preference;
+
 
 /**
  * "Networks" preference in "Mobile network" settings UI for the Phone app.
@@ -159,25 +160,26 @@
         }
     };
 
-    private final NetworkScanHelper.NetworkScanCallback mCallback = new NetworkScanCallback() {
-        public void onResults(List<CellInfo> results) {
-            if (DBG) logd("get scan results: " + results.toString());
-            Message msg = mHandler.obtainMessage(EVENT_NETWORK_SCAN_RESULTS, results);
-            msg.sendToTarget();
-        }
+    private final NetworkScanHelper.NetworkScanCallback mCallback =
+            new NetworkScanHelper.NetworkScanCallback() {
+                public void onResults(List<CellInfo> results) {
+                    if (DBG) logd("get scan results: " + results.toString());
+                    Message msg = mHandler.obtainMessage(EVENT_NETWORK_SCAN_RESULTS, results);
+                    msg.sendToTarget();
+                }
 
-        public void onComplete() {
-            if (DBG) logd("network scan completed.");
-            Message msg = mHandler.obtainMessage(EVENT_NETWORK_SCAN_COMPLETED);
-            msg.sendToTarget();
-        }
+                public void onComplete() {
+                    if (DBG) logd("network scan completed.");
+                    Message msg = mHandler.obtainMessage(EVENT_NETWORK_SCAN_COMPLETED);
+                    msg.sendToTarget();
+                }
 
-        public void onError(int error) {
-            if (DBG) logd("network scan error.");
-            Message msg = mHandler.obtainMessage(EVENT_NETWORK_SCAN_ERROR);
-            msg.sendToTarget();
-        }
-    };
+                public void onError(int error) {
+                    if (DBG) logd("network scan error.");
+                    Message msg = mHandler.obtainMessage(EVENT_NETWORK_SCAN_ERROR);
+                    msg.sendToTarget();
+                }
+            };
 
     @Override
     //implemented for DialogInterface.OnCancelListener
@@ -189,9 +191,8 @@
         mNetworkOperators.getNetworkSelectionMode();
     }
 
-    @Override
+    //TODO(b/114749736): move this logic to preference controller
     protected void onDialogClosed(boolean positiveResult) {
-        super.onDialogClosed(positiveResult);
         // If dismissed, we query NetworkSelectMode and update states of AutoSelect button.
         if (!positiveResult) {
             mNetworkOperators.getNetworkSelectionMode();
diff --git a/src/com/android/settings/mobilenetwork/NetworkSelectSettings.java b/src/com/android/settings/mobilenetwork/NetworkSelectSettings.java
index f04eae7..20cc628 100644
--- a/src/com/android/settings/mobilenetwork/NetworkSelectSettings.java
+++ b/src/com/android/settings/mobilenetwork/NetworkSelectSettings.java
@@ -31,6 +31,10 @@
 import android.util.Log;
 import android.view.View;
 
+import androidx.preference.Preference;
+import androidx.preference.PreferenceCategory;
+import androidx.preference.PreferenceScreen;
+
 import com.android.internal.logging.MetricsLogger;
 import com.android.internal.logging.nano.MetricsProto.MetricsEvent;
 import com.android.internal.telephony.OperatorInfo;
@@ -47,10 +51,6 @@
 import java.util.List;
 import java.util.Map;
 
-import androidx.preference.Preference;
-import androidx.preference.PreferenceCategory;
-import androidx.preference.PreferenceScreen;
-
 /**
  * "Choose network" settings UI for the Phone app.
  */
diff --git a/src/com/android/settings/mobilenetwork/RoamingDialogFragment.java b/src/com/android/settings/mobilenetwork/RoamingDialogFragment.java
index 1b1091b..6f71d9c 100644
--- a/src/com/android/settings/mobilenetwork/RoamingDialogFragment.java
+++ b/src/com/android/settings/mobilenetwork/RoamingDialogFragment.java
@@ -17,9 +17,6 @@
 
 import android.app.AlertDialog;
 import android.app.Dialog;
-import android.app.DialogFragment;
-import android.app.Fragment;
-import android.app.FragmentManager;
 import android.content.Context;
 import android.content.DialogInterface;
 import android.content.DialogInterface.OnClickListener;
@@ -27,11 +24,19 @@
 import android.os.PersistableBundle;
 import android.telephony.CarrierConfigManager;
 
+import androidx.fragment.app.DialogFragment;
+import androidx.fragment.app.Fragment;
+import androidx.fragment.app.FragmentManager;
+
+
+import com.android.settings.R;
+import com.android.settings.core.instrumentation.InstrumentedDialogFragment;
+
 /**
  * A dialog fragment that asks the user if they are sure they want to turn on data roaming
  * to avoid accidental charges.
  */
-public class RoamingDialogFragment extends DialogFragment implements OnClickListener {
+public class RoamingDialogFragment extends InstrumentedDialogFragment implements OnClickListener {
 
     public static final String SUB_ID_KEY = "sub_id_key";
 
@@ -55,9 +60,8 @@
         mSubId = args.getInt(SUB_ID_KEY);
         mCarrierConfigManager = new CarrierConfigManager(context);
 
-        // Verify host activity implemented callback interface
-        FragmentManager fragmentManager = getFragmentManager();
-        Fragment fragment = fragmentManager.findFragmentById(R.id.network_setting_content);
+        //TODO(b/114749736): set target fragment in host fragment
+        Fragment fragment = getTargetFragment();
         try {
             mListener = (RoamingDialogListener) fragment;
         } catch (ClassCastException e) {
@@ -68,7 +72,7 @@
 
     @Override
     public Dialog onCreateDialog(Bundle savedInstanceState) {
-        AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
+        AlertDialog.Builder builder = new AlertDialog.Builder(getContext());
         int title = R.string.roaming_alert_title;
         PersistableBundle carrierConfig = mCarrierConfigManager.getConfigForSubId(mSubId);
         if (carrierConfig != null && carrierConfig.getBoolean(
@@ -84,6 +88,12 @@
     }
 
     @Override
+    public int getMetricsCategory() {
+        //TODO(b/114749736): add category for roaming dialog
+        return 0;
+    }
+
+    @Override
     public void onClick(DialogInterface dialog, int which) {
         // let the host know that the positive button has been clicked
         if (which == dialog.BUTTON_POSITIVE) {