Merge "Merge work profile storage data together"
diff --git a/res/layout/wifi_dialog.xml b/res/layout/wifi_dialog.xml
index c995c3e..a3ad4207 100644
--- a/res/layout/wifi_dialog.xml
+++ b/res/layout/wifi_dialog.xml
@@ -341,25 +341,6 @@
                         style="@style/wifi_item_content"
                         android:text="@string/wifi_show_password" />
             </LinearLayout>
-
-            <LinearLayout android:id="@+id/sae_password_id_layout"
-                    android:layout_width="match_parent"
-                    android:layout_height="wrap_content"
-                    style="@style/wifi_item"
-                    android:visibility="gone">
-                <TextView
-                        android:layout_width="wrap_content"
-                        android:layout_height="wrap_content"
-                        style="@style/wifi_item_label"
-                        android:text="@string/wifi_sae_password_id" />
-
-                <EditText android:id="@+id/sae_password_id"
-                          android:layout_width="match_parent"
-                          android:layout_height="wrap_content"
-                          style="@style/wifi_item_edit_content"
-                          android:singleLine="true"
-                          android:inputType="textNoSuggestions" />
-            </LinearLayout>
         </LinearLayout>
 
         <LinearLayout android:id="@+id/wifi_advanced_toggle"
diff --git a/res/values/arrays.xml b/res/values/arrays.xml
index e302905..8ff85e2 100644
--- a/res/values/arrays.xml
+++ b/res/values/arrays.xml
@@ -1492,4 +1492,17 @@
         <item>@color/palette_list_color_purple</item>
         <item>@color/palette_list_color_pink</item>
     </array>
-</resources>
\ No newline at end of file
+
+    <!--String arrays for showing the rtt settings options -->
+    <string-array name="rtt_setting_mode">
+        <!-- 0: Invalid value -->
+        <item></item>
+        <!-- 1:  Not visible -->
+        <item>@string/rtt_settings_no_visible</item>
+        <!-- 2:  Visible during call -->
+        <item>@string/rtt_settings_visible_during_call</item>
+        <!-- 3:  Always visible -->
+        <item>@string/rtt_settings_always_visible</item>
+    </string-array>
+
+</resources>
diff --git a/res/values/config.xml b/res/values/config.xml
index a4d0e47..fc2ca1f 100755
--- a/res/values/config.xml
+++ b/res/values/config.xml
@@ -431,4 +431,7 @@
 
     <!-- RTT setting intent action -->
     <string name="config_rtt_setting_intent_action" translatable="false"></string>
+
+    <!-- Package name of dialer supports RTT setting-->
+    <string name="config_rtt_setting_package_name" translatable="false"></string>
 </resources>
diff --git a/res/values/strings.xml b/res/values/strings.xml
index e68feb8..d3648cf 100644
--- a/res/values/strings.xml
+++ b/res/values/strings.xml
@@ -2003,8 +2003,6 @@
     <string name="wifi_eap_anonymous">Anonymous identity</string>
     <!-- Label for the password of the secured network -->
     <string name="wifi_password">Password</string>
-    <!-- Label for the sae password id of the secured network [CHAR LIMIT=32] -->
-    <string name="wifi_sae_password_id">SAE password identifier</string>
     <!-- Label for the check box to show password -->
     <string name="wifi_show_password">Show password</string>
     <!-- Label for the RadioGroup to choose wifi ap band -->
@@ -2824,7 +2822,7 @@
     <!-- Display settings screen, summary of Dark UI when on and will turn off automatically at sunrise. [CHAR LIMIT=NONE] -->
     <string name="dark_ui_summary_on_auto_mode_auto">Will turn off automatically at sunrise</string>
     <!-- Dark theme screen, description of Dark theme feature. [CHAR LIMIT=NONE] -->
-    <string name="dark_ui_text">Dark theme uses true black to help keep your battery alive longer. Dark theme schedules wait to turn on until your screen is off.</string>
+    <string name="dark_ui_text">Dark theme uses a black background to help keep battery alive longer on some screens. Dark theme schedules wait to turn on until your screen is off.</string>
 
     <!-- Sound & display settings screen, setting option name to change screen timeout -->
     <string name="screen_timeout">Screen timeout</string>
diff --git a/res/xml/accessibility_settings.xml b/res/xml/accessibility_settings.xml
index d83fa59..be644d4 100644
--- a/res/xml/accessibility_settings.xml
+++ b/res/xml/accessibility_settings.xml
@@ -182,6 +182,12 @@
             settings:controller="com.android.settings.accessibility.AccessibilityHearingAidPreferenceController"/>
 
         <Preference
+            android:key="rtt_setting"
+            android:summary="@string/summary_placeholder"
+            android:title="@string/rtt_settings_title"
+            settings:controller="com.android.settings.accessibility.RTTSettingPreferenceController"/>
+
+        <Preference
             android:fragment="com.android.settings.accessibility.CaptionPropertiesFragment"
             android:key="captioning_preference_screen"
             android:persistent="false"
diff --git a/src/com/android/settings/Utils.java b/src/com/android/settings/Utils.java
index 2f198cf..9b257b6 100644
--- a/src/com/android/settings/Utils.java
+++ b/src/com/android/settings/Utils.java
@@ -372,7 +372,7 @@
     }
 
     public static boolean hasMultipleUsers(Context context) {
-        return ((UserManager) context.getSystemService(Context.USER_SERVICE))
+        return context.getSystemService(UserManager.class)
                 .getUsers().size() > 1;
     }
 
@@ -666,7 +666,7 @@
      * @throws SecurityException if the given userId does not belong to the current user group.
      */
     public static int enforceSameOwner(Context context, int userId) {
-        final UserManager um = UserManager.get(context);
+        final UserManager um = context.getSystemService(UserManager.class);
         final int[] profileIds = um.getProfileIdsWithDisabled(UserHandle.myUserId());
         if (ArrayUtils.contains(profileIds, userId)) {
             return userId;
@@ -686,7 +686,7 @@
      * Returns the user id of the credential owner of the given user id.
      */
     public static int getCredentialOwnerUserId(Context context, int userId) {
-        final UserManager um = UserManager.get(context);
+        final UserManager um = context.getSystemService(UserManager.class);
         return um.getCredentialOwnerProfile(userId);
     }
 
@@ -823,7 +823,8 @@
     }
 
     public static boolean isDemoUser(Context context) {
-        return UserManager.isDeviceInDemoMode(context) && UserManager.get(context).isDemoUser();
+        return UserManager.isDeviceInDemoMode(context)
+                && context.getSystemService(UserManager.class).isDemoUser();
     }
 
     public static ComponentName getDeviceOwnerComponent(Context context) {
@@ -1051,7 +1052,7 @@
         final boolean isWork = args != null ? args.getInt(ProfileSelectFragment.EXTRA_PROFILE)
                 == ProfileSelectFragment.ProfileType.WORK : false;
         if (FeatureFlagUtils.isEnabled(activity, FeatureFlags.PERSONAL_WORK_PROFILE)
-                && UserManager.get(activity).getUserProfiles().size() > 1
+                && activity.getSystemService(UserManager.class).getUserProfiles().size() > 1
                 && ProfileFragmentBridge.FRAGMENT_MAP.get(fragmentName) != null
                 && !isWork && !isPersonal) {
             f = Fragment.instantiate(activity, ProfileFragmentBridge.FRAGMENT_MAP.get(fragmentName),
diff --git a/src/com/android/settings/accessibility/RTTSettingPreferenceController.java b/src/com/android/settings/accessibility/RTTSettingPreferenceController.java
new file mode 100644
index 0000000..3b5915d
--- /dev/null
+++ b/src/com/android/settings/accessibility/RTTSettingPreferenceController.java
@@ -0,0 +1,88 @@
+/*
+ * Copyright (C) 2020 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.accessibility;
+
+import android.content.Context;
+import android.content.Intent;
+import android.content.pm.PackageManager;
+import android.content.pm.ResolveInfo;
+import android.provider.Settings;
+import android.telecom.TelecomManager;
+import android.text.TextUtils;
+
+import androidx.annotation.VisibleForTesting;
+import androidx.preference.Preference;
+import androidx.preference.PreferenceScreen;
+
+import com.android.settings.R;
+import com.android.settings.core.BasePreferenceController;
+
+import java.util.List;
+
+/** A controller to control the status for RTT setting in Accessibility screen.*/
+public class RTTSettingPreferenceController extends BasePreferenceController {
+
+    private static final String DIALER_RTT_CONFIGURATION = "dialer_rtt_configuration";
+
+    private final Context mContext;
+    private final PackageManager mPackageManager;
+    private final TelecomManager mTelecomManager;
+    private final CharSequence[] mModes;
+    private final String mDialerPackage;
+
+    @VisibleForTesting
+    Intent mRTTIntent;
+
+    public RTTSettingPreferenceController(Context context, String preferenceKey) {
+        super(context, preferenceKey);
+        mContext = context;
+        mModes = mContext.getResources().getTextArray(R.array.rtt_setting_mode);
+        mDialerPackage = mContext.getString(R.string.config_rtt_setting_package_name);
+        mPackageManager = context.getPackageManager();
+        mTelecomManager = context.getSystemService(TelecomManager.class);
+        mRTTIntent = new Intent(context.getString(R.string.config_rtt_setting_intent_action));
+
+    }
+
+    @Override
+    public int getAvailabilityStatus() {
+        final List<ResolveInfo> resolved =
+                mPackageManager.queryIntentActivities(mRTTIntent, 0 /* flags */);
+        return resolved != null && !resolved.isEmpty() && isDialerSupportRTTSetting()
+                ? AVAILABLE
+                : UNSUPPORTED_ON_DEVICE;
+    }
+
+    @Override
+    public void displayPreference(PreferenceScreen screen) {
+        super.displayPreference(screen);
+        final Preference pref = screen.findPreference(getPreferenceKey());
+        pref.setIntent(mRTTIntent);
+    }
+
+    @Override
+    public CharSequence getSummary() {
+        final int option = Settings.Secure.getInt(mContext.getContentResolver(),
+                DIALER_RTT_CONFIGURATION, 1 /* not visible */);
+        return mModes[option];
+    }
+
+    @VisibleForTesting
+    boolean isDialerSupportRTTSetting() {
+        return TextUtils.equals(mTelecomManager.getDefaultDialerPackage(), mDialerPackage);
+    }
+}
diff --git a/src/com/android/settings/biometrics/BiometricsEnrollEnrolling.java b/src/com/android/settings/biometrics/BiometricsEnrollEnrolling.java
index 17a933b..f131e35 100644
--- a/src/com/android/settings/biometrics/BiometricsEnrollEnrolling.java
+++ b/src/com/android/settings/biometrics/BiometricsEnrollEnrolling.java
@@ -60,6 +60,8 @@
 
     @Override
     protected void onStop() {
+        super.onStop();
+
         if (mSidecar != null) {
             mSidecar.setListener(null);
         }
@@ -78,6 +80,12 @@
     }
 
     @Override
+    protected boolean shouldFinishWhenBackgrounded() {
+        // Prevent super.onStop() from finishing, since we handle this in our onStop().
+        return false;
+    }
+
+    @Override
     public void onBackPressed() {
         if (mSidecar != null) {
             mSidecar.setListener(null);
diff --git a/src/com/android/settings/biometrics/fingerprint/FingerprintEnrollEnrolling.java b/src/com/android/settings/biometrics/fingerprint/FingerprintEnrollEnrolling.java
index 8194878..3831b07 100644
--- a/src/com/android/settings/biometrics/fingerprint/FingerprintEnrollEnrolling.java
+++ b/src/com/android/settings/biometrics/fingerprint/FingerprintEnrollEnrolling.java
@@ -217,13 +217,15 @@
 
     private void stopIconAnimation() {
         mAnimationCancelled = true;
-        mIconAnimationDrawable.stop();
+        if (mIconAnimationDrawable != null) {
+            mIconAnimationDrawable.stop();
+        }
     }
 
     @Override
     protected void onStop() {
-        stopIconAnimation();
         super.onStop();
+        stopIconAnimation();
     }
 
     private void animateProgress(int progress) {
diff --git a/src/com/android/settings/biometrics/fingerprint/FingerprintEnrollFindSensor.java b/src/com/android/settings/biometrics/fingerprint/FingerprintEnrollFindSensor.java
index 9508268..dbedb4a 100644
--- a/src/com/android/settings/biometrics/fingerprint/FingerprintEnrollFindSensor.java
+++ b/src/com/android/settings/biometrics/fingerprint/FingerprintEnrollFindSensor.java
@@ -115,10 +115,10 @@
 
     @Override
     protected void onStop() {
+        super.onStop();
         if (mAnimation != null) {
             mAnimation.pauseAnimation();
         }
-        super.onStop();
     }
 
     @Override
diff --git a/src/com/android/settings/network/telephony/CellInfoUtil.java b/src/com/android/settings/network/telephony/CellInfoUtil.java
index 3129694..ab172c8 100644
--- a/src/com/android/settings/network/telephony/CellInfoUtil.java
+++ b/src/com/android/settings/network/telephony/CellInfoUtil.java
@@ -52,7 +52,7 @@
     /**
      * Returns the title of the network obtained in the manual search.
      *
-     * @param cellId contains the information of the network.
+     * @param cellId contains the identity of the network.
      * @param networkMccMnc contains the MCCMNC string of the network
      * @return Long Name if not null/empty, otherwise Short Name if not null/empty,
      * else MCCMNC string.
diff --git a/src/com/android/settings/wifi/WifiConfigController.java b/src/com/android/settings/wifi/WifiConfigController.java
index e228a14..a8b3250 100644
--- a/src/com/android/settings/wifi/WifiConfigController.java
+++ b/src/com/android/settings/wifi/WifiConfigController.java
@@ -142,7 +142,6 @@
     @VisibleForTesting
     int mAccessPointSecurity;
     private TextView mPasswordView;
-    private TextView mSaePasswordIdView;
     private ImageButton mSsidScanButton;
 
     private String mUnspecifiedCertString;
@@ -811,11 +810,6 @@
                     String password = mPasswordView.getText().toString();
                     config.preSharedKey = '"' + password + '"';
                 }
-                if (mSaePasswordIdView.length() != 0) {
-                    config.saePasswordId = mSaePasswordIdView.getText().toString();
-                } else {
-                    config.saePasswordId = null;
-                }
                 break;
 
             case AccessPoint.SECURITY_OWE:
@@ -1002,23 +996,6 @@
             }
         }
 
-        if (mSaePasswordIdView == null) {
-            mSaePasswordIdView = (TextView) mView.findViewById(R.id.sae_password_id);
-            mSaePasswordIdView.setOnEditorActionListener(this);
-            mSaePasswordIdView.setOnKeyListener(this);
-        }
-
-        if (mAccessPointSecurity == AccessPoint.SECURITY_SAE) {
-            mView.findViewById(R.id.sae_password_id_layout).setVisibility(View.VISIBLE);
-            if (mAccessPoint != null && mAccessPoint.isSaved()) {
-                if (!TextUtils.isEmpty(mAccessPoint.getConfig().saePasswordId)) {
-                    mSaePasswordIdView.setText(mAccessPoint.getConfig().saePasswordId);
-                }
-            }
-        } else {
-            setSaePasswordIdInvisible();
-        }
-
         if (mAccessPointSecurity != AccessPoint.SECURITY_EAP &&
                 mAccessPointSecurity != AccessPoint.SECURITY_EAP_SUITE_B) {
             mView.findViewById(R.id.eap).setVisibility(View.GONE);
@@ -1326,11 +1303,6 @@
         mView.findViewById(R.id.show_password_layout).setVisibility(View.GONE);
     }
 
-    private void setSaePasswordIdInvisible() {
-        mSaePasswordIdView.setText("");
-        mView.findViewById(R.id.sae_password_id_layout).setVisibility(View.GONE);
-    }
-
     private void setEapMethodInvisible() {
         mView.findViewById(R.id.eap).setVisibility(View.GONE);
     }
diff --git a/src/com/android/settings/wifi/WifiConfigController2.java b/src/com/android/settings/wifi/WifiConfigController2.java
index 90f1397..ecf20fd 100644
--- a/src/com/android/settings/wifi/WifiConfigController2.java
+++ b/src/com/android/settings/wifi/WifiConfigController2.java
@@ -142,7 +142,6 @@
     @VisibleForTesting
     int mWifiEntrySecurity;
     private TextView mPasswordView;
-    private TextView mSaePasswordIdView;
     private ImageButton mSsidScanButton;
 
     private String mUnspecifiedCertString;
@@ -805,11 +804,6 @@
                     String password = mPasswordView.getText().toString();
                     config.preSharedKey = '"' + password + '"';
                 }
-                if (mSaePasswordIdView.length() != 0) {
-                    config.saePasswordId = mSaePasswordIdView.getText().toString();
-                } else {
-                    config.saePasswordId = null;
-                }
                 break;
 
             case WifiEntry.SECURITY_OWE:
@@ -996,23 +990,6 @@
             }
         }
 
-        if (mSaePasswordIdView == null) {
-            mSaePasswordIdView = (TextView) mView.findViewById(R.id.sae_password_id);
-            mSaePasswordIdView.setOnEditorActionListener(this);
-            mSaePasswordIdView.setOnKeyListener(this);
-        }
-
-        if (mWifiEntrySecurity == WifiEntry.SECURITY_SAE) {
-            mView.findViewById(R.id.sae_password_id_layout).setVisibility(View.VISIBLE);
-            if (mWifiEntry != null && mWifiEntry.isSaved()) {
-                if (!TextUtils.isEmpty(mWifiEntry.getWifiConfiguration().saePasswordId)) {
-                    mSaePasswordIdView.setText(mWifiEntry.getWifiConfiguration().saePasswordId);
-                }
-            }
-        } else {
-            setSaePasswordIdInvisible();
-        }
-
         if (mWifiEntrySecurity != WifiEntry.SECURITY_EAP
                 && mWifiEntrySecurity != WifiEntry.SECURITY_EAP_SUITE_B) {
             mView.findViewById(R.id.eap).setVisibility(View.GONE);
@@ -1322,11 +1299,6 @@
         mView.findViewById(R.id.show_password_layout).setVisibility(View.GONE);
     }
 
-    private void setSaePasswordIdInvisible() {
-        mSaePasswordIdView.setText("");
-        mView.findViewById(R.id.sae_password_id_layout).setVisibility(View.GONE);
-    }
-
     private void setEapMethodInvisible() {
         mView.findViewById(R.id.eap).setVisibility(View.GONE);
     }
diff --git a/src/com/android/settings/wifi/WifiSettings2.java b/src/com/android/settings/wifi/WifiSettings2.java
index a1f1ad9..4dd51ed 100644
--- a/src/com/android/settings/wifi/WifiSettings2.java
+++ b/src/com/android/settings/wifi/WifiSettings2.java
@@ -326,18 +326,6 @@
         if (savedInstanceState != null) {
             mDialogMode = savedInstanceState.getInt(SAVE_DIALOG_MODE);
             mDialogWifiEntryKey = savedInstanceState.getString(SAVE_DIALOG_WIFIENTRY_KEY);
-
-            if (!TextUtils.isEmpty(mDialogWifiEntryKey)) {
-                List<WifiEntry> wifiEntries = mWifiPickerTracker.getWifiEntries();
-                Optional<WifiEntry> matchedWifiEntry = wifiEntries.stream().filter(wifiEntry ->
-                        TextUtils.equals(wifiEntry.getKey(), mDialogWifiEntryKey)).findAny();
-                if (matchedWifiEntry.isPresent()) {
-                    mDialogWifiEntry = matchedWifiEntry.get();
-                } else {
-                    throw new IllegalStateException("Failed to restore WifiEntry of key: "
-                            + mDialogWifiEntryKey);
-                }
-            }
         }
 
         // If we're supposed to enable/disable the Next button based on our current connection
@@ -564,6 +552,15 @@
         if (preference instanceof LongPressWifiEntryPreference) {
             final WifiEntry selectedEntry =
                     ((LongPressWifiEntryPreference) preference).getWifiEntry();
+
+            if (selectedEntry.isSaved()) {
+                if (!selectedEntry.getWifiConfiguration().getNetworkSelectionStatus()
+                        .getHasEverConnected()) {
+                    launchConfigNewNetworkFragment(selectedEntry);
+                    return true;
+                }
+            }
+
             connect(selectedEntry, true /* editIfNoConfig */, true /* fullScreenEdit */);
         } else if (preference == mAddWifiNetworkPreference) {
             onAddNetworkPressed();
diff --git a/src/com/android/settings/wifi/dpp/WifiDppUtils.java b/src/com/android/settings/wifi/dpp/WifiDppUtils.java
index 8862830..93a3530 100644
--- a/src/com/android/settings/wifi/dpp/WifiDppUtils.java
+++ b/src/com/android/settings/wifi/dpp/WifiDppUtils.java
@@ -349,7 +349,7 @@
         // When the value of this key is read, the actual key is not returned, just a "*".
         // Call privileged system API to obtain actual key.
         final String preSharedKey = removeFirstAndLastDoubleQuotes(
-                softApConfiguration.getWpa2Passphrase());
+                softApConfiguration.getPassphrase());
 
         if (!TextUtils.isEmpty(ssid)) {
             intent.putExtra(EXTRA_WIFI_SSID, ssid);
diff --git a/src/com/android/settings/wifi/tether/WifiTetherPasswordPreferenceController.java b/src/com/android/settings/wifi/tether/WifiTetherPasswordPreferenceController.java
index 690e283..1563e61 100644
--- a/src/com/android/settings/wifi/tether/WifiTetherPasswordPreferenceController.java
+++ b/src/com/android/settings/wifi/tether/WifiTetherPasswordPreferenceController.java
@@ -51,10 +51,10 @@
         final SoftApConfiguration config = mWifiManager.getSoftApConfiguration();
         if (config == null
                 || (config.getSecurityType() == SoftApConfiguration.SECURITY_TYPE_WPA2_PSK
-                && TextUtils.isEmpty(config.getWpa2Passphrase()))) {
+                && TextUtils.isEmpty(config.getPassphrase()))) {
             mPassword = generateRandomPassword();
         } else {
-            mPassword = config.getWpa2Passphrase();
+            mPassword = config.getPassphrase();
         }
         ((ValidatedEditTextPreference) mPreference).setValidator(this);
         ((ValidatedEditTextPreference) mPreference).setIsPassword(true);
diff --git a/src/com/android/settings/wifi/tether/WifiTetherSettings.java b/src/com/android/settings/wifi/tether/WifiTetherSettings.java
index 8b2f05c..3c4a001 100644
--- a/src/com/android/settings/wifi/tether/WifiTetherSettings.java
+++ b/src/com/android/settings/wifi/tether/WifiTetherSettings.java
@@ -214,8 +214,9 @@
         final int securityType = mSecurityPreferenceController.getSecurityType();
         configBuilder.setSsid(mSSIDPreferenceController.getSSID());
         if (securityType == SoftApConfiguration.SECURITY_TYPE_WPA2_PSK) {
-            configBuilder.setWpa2Passphrase(
-                    mPasswordPreferenceController.getPasswordValidated(securityType));
+            configBuilder.setPassphrase(
+                    mPasswordPreferenceController.getPasswordValidated(securityType),
+                    SoftApConfiguration.SECURITY_TYPE_WPA2_PSK);
         }
         configBuilder.setBand(mApBandPreferenceController.getBandIndex());
         return configBuilder.build();
diff --git a/tests/robotests/src/com/android/settings/accessibility/RTTSettingPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/accessibility/RTTSettingPreferenceControllerTest.java
new file mode 100644
index 0000000..6f3f77d
--- /dev/null
+++ b/tests/robotests/src/com/android/settings/accessibility/RTTSettingPreferenceControllerTest.java
@@ -0,0 +1,91 @@
+/*
+ * Copyright (C) 2020 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.accessibility;
+
+import static com.google.common.truth.Truth.assertThat;
+
+import static org.mockito.Mockito.doReturn;
+import static org.mockito.Mockito.spy;
+import static org.robolectric.Shadows.shadowOf;
+
+import android.content.Context;
+import android.content.Intent;
+import android.content.pm.ResolveInfo;
+
+import com.android.settings.core.BasePreferenceController;
+import com.android.settings.testutils.ResolveInfoBuilder;
+
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.robolectric.RobolectricTestRunner;
+import org.robolectric.RuntimeEnvironment;
+import org.robolectric.shadows.ShadowPackageManager;
+
+@RunWith(RobolectricTestRunner.class)
+public class RTTSettingPreferenceControllerTest {
+
+    private Context mContext;
+    private ShadowPackageManager mShadowPackageManager;
+    private RTTSettingPreferenceController mController;
+
+    @Before
+    public void setUp() {
+        mContext = RuntimeEnvironment.application;
+        mShadowPackageManager = shadowOf(mContext.getPackageManager());
+        mController = spy(new RTTSettingPreferenceController(mContext, "rtt_setting"));
+        mController.mRTTIntent = new Intent("com.android.test.action.example");
+    }
+
+    @Test
+    public void getAvailabilityStatus_defaultDialerIsExpected_intentCanBeHandled_returnAVAILABLE() {
+        // Default dialer is expected.
+        doReturn(true).when(mController).isDialerSupportRTTSetting();
+        // Intent can be handled.
+        final ResolveInfo info = new ResolveInfoBuilder("pkg")
+                .setActivity("pkg", "class").build();
+        final Intent intent = new Intent("com.android.test.action.example");
+        mShadowPackageManager.addResolveInfoForIntent(intent, info);
+
+        assertThat(mController.getAvailabilityStatus())
+                .isEqualTo(BasePreferenceController.AVAILABLE);
+    }
+
+    @Test
+    public void getAvailabilityStatus_intentCanNotBeHandled_shouldReturnUNSUPPORTED_ON_DEVICE() {
+        // Default dialer is expected.
+        doReturn(true).when(mController).isDialerSupportRTTSetting();
+        // Intent can not be handled.
+
+        assertThat(mController.getAvailabilityStatus())
+                .isEqualTo(BasePreferenceController.UNSUPPORTED_ON_DEVICE);
+    }
+
+    @Test
+    public void getAvailabilityStatus_defaultDialerIsNotExpected_returnUNSUPPORTED_ON_DEVICE() {
+        // Default dialer is not expected.
+        doReturn(false).when(mController).isDialerSupportRTTSetting();
+        // Intent can be handled.
+        final ResolveInfo info = new ResolveInfoBuilder("pkg")
+                .setActivity("pkg", "class").build();
+        final Intent intent = new Intent("com.android.test.action.example");
+        mShadowPackageManager.addResolveInfoForIntent(intent, info);
+
+        assertThat(mController.getAvailabilityStatus())
+                .isEqualTo(BasePreferenceController.UNSUPPORTED_ON_DEVICE);
+    }
+}
diff --git a/tests/robotests/src/com/android/settings/datausage/BillingCycleSettingsTest.java b/tests/robotests/src/com/android/settings/datausage/BillingCycleSettingsTest.java
index eea6388..3fdb7b4 100644
--- a/tests/robotests/src/com/android/settings/datausage/BillingCycleSettingsTest.java
+++ b/tests/robotests/src/com/android/settings/datausage/BillingCycleSettingsTest.java
@@ -16,6 +16,7 @@
 package com.android.settings.datausage;
 
 import static android.net.NetworkPolicy.CYCLE_NONE;
+
 import static com.google.common.truth.Truth.assertThat;
 
 import static org.mockito.ArgumentMatchers.any;
@@ -49,6 +50,7 @@
 import com.android.settingslib.NetworkPolicyEditor;
 
 import org.junit.Before;
+import org.junit.Ignore;
 import org.junit.Test;
 import org.junit.runner.RunWith;
 import org.mockito.Mock;
@@ -142,6 +144,7 @@
 
     @Test
     @Config(shadows = ShadowFragment.class)
+    @Ignore
     public void onCreate_emptyArguments_shouldSetDefaultNetworkTemplate() {
         final BillingCycleSettings billingCycleSettings = spy(new BillingCycleSettings());
         when(billingCycleSettings.getContext()).thenReturn(mContext);
@@ -164,4 +167,4 @@
 
         assertThat(billingCycleSettings.mNetworkTemplate).isNotNull();
     }
-}
\ No newline at end of file
+}
diff --git a/tests/robotests/src/com/android/settings/datausage/DataUsageSummaryTest.java b/tests/robotests/src/com/android/settings/datausage/DataUsageSummaryTest.java
index d8dde39..d5eaa9a 100644
--- a/tests/robotests/src/com/android/settings/datausage/DataUsageSummaryTest.java
+++ b/tests/robotests/src/com/android/settings/datausage/DataUsageSummaryTest.java
@@ -40,6 +40,7 @@
 import com.android.settings.testutils.shadow.ShadowUtils;
 
 import org.junit.Before;
+import org.junit.Ignore;
 import org.junit.Test;
 import org.junit.runner.RunWith;
 import org.mockito.Mock;
@@ -103,6 +104,7 @@
 
     @Test
     @Config(shadows = ShadowSubscriptionManager.class)
+    @Ignore
     public void configuration_withSim_shouldShowMobileAndWifi() {
         ShadowDataUsageUtils.IS_MOBILE_DATA_SUPPORTED = true;
         ShadowDataUsageUtils.IS_WIFI_SUPPORTED = true;
diff --git a/tests/robotests/src/com/android/settings/network/MobileNetworkPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/network/MobileNetworkPreferenceControllerTest.java
index 702d689..e2410c1 100644
--- a/tests/robotests/src/com/android/settings/network/MobileNetworkPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/network/MobileNetworkPreferenceControllerTest.java
@@ -46,6 +46,7 @@
 import com.android.settingslib.core.lifecycle.Lifecycle;
 
 import org.junit.Before;
+import org.junit.Ignore;
 import org.junit.Test;
 import org.junit.runner.RunWith;
 import org.mockito.Mock;
@@ -120,6 +121,7 @@
     }
 
     @Test
+    @Ignore
     public void serviceStateChange_shouldUpdatePrefSummary() {
         final String testCarrierName = "test";
         final Preference mPreference = mock(Preference.class);
@@ -145,6 +147,7 @@
     }
 
     @Test
+    @Ignore
     public void airplaneModeTurnedOn_shouldDisablePreference() {
         Settings.Global.putInt(mContext.getContentResolver(),
                 Global.AIRPLANE_MODE_ON, 1);
@@ -155,6 +158,7 @@
     }
 
     @Test
+    @Ignore
     public void airplaneModeTurnedOffAndNoUserRestriction_shouldEnablePreference() {
         Settings.Global.putInt(mContext.getContentResolver(),
                 Global.AIRPLANE_MODE_ON, 0);
@@ -166,6 +170,7 @@
     }
 
     @Test
+    @Ignore
     public void airplaneModeTurnedOffAndHasUserRestriction_shouldDisablePreference() {
         Settings.Global.putInt(mContext.getContentResolver(),
                 Global.AIRPLANE_MODE_ON, 0);
diff --git a/tests/robotests/src/com/android/settings/network/telephony/MobileNetworkSettingsTest.java b/tests/robotests/src/com/android/settings/network/telephony/MobileNetworkSettingsTest.java
index 7ff3ab3..9bf8370 100644
--- a/tests/robotests/src/com/android/settings/network/telephony/MobileNetworkSettingsTest.java
+++ b/tests/robotests/src/com/android/settings/network/telephony/MobileNetworkSettingsTest.java
@@ -43,6 +43,7 @@
 import com.android.settingslib.core.AbstractPreferenceController;
 
 import org.junit.Before;
+import org.junit.Ignore;
 import org.junit.Test;
 import org.junit.runner.RunWith;
 import org.mockito.Mock;
@@ -90,6 +91,7 @@
     }
 
     @Test
+    @Ignore
     public void onAttach_noCrash() {
         mFragment.onAttach(mContext);
     }
diff --git a/tests/robotests/src/com/android/settings/network/telephony/NetworkScanHelperTest.java b/tests/robotests/src/com/android/settings/network/telephony/NetworkScanHelperTest.java
index 1f8c16d..f87a459 100644
--- a/tests/robotests/src/com/android/settings/network/telephony/NetworkScanHelperTest.java
+++ b/tests/robotests/src/com/android/settings/network/telephony/NetworkScanHelperTest.java
@@ -17,7 +17,7 @@
 package com.android.settings.network.telephony;
 
 import static com.google.common.truth.Truth.assertThat;
-import static org.junit.Assert.assertTrue;
+
 import static org.mockito.ArgumentMatchers.any;
 import static org.mockito.ArgumentMatchers.anyInt;
 import static org.mockito.Mockito.doAnswer;
@@ -32,16 +32,12 @@
 import android.telephony.NetworkScanRequest;
 import android.telephony.TelephonyManager;
 import android.telephony.TelephonyScanManager;
+
 import com.android.internal.telephony.CellNetworkScanResult;
 import com.android.internal.telephony.OperatorInfo;
-import java.util.ArrayList;
-import java.util.List;
-import java.util.concurrent.Executor;
-import java.util.concurrent.ExecutorService;
-import java.util.concurrent.Executors;
-import java.util.concurrent.TimeUnit;
-import org.junit.After;
+
 import org.junit.Before;
+import org.junit.Ignore;
 import org.junit.Test;
 import org.junit.runner.RunWith;
 import org.mockito.ArgumentCaptor;
@@ -51,6 +47,13 @@
 import org.mockito.stubbing.Answer;
 import org.robolectric.RobolectricTestRunner;
 
+import java.util.ArrayList;
+import java.util.List;
+import java.util.concurrent.Executor;
+import java.util.concurrent.ExecutorService;
+import java.util.concurrent.Executors;
+import java.util.concurrent.TimeUnit;
+
 @RunWith(RobolectricTestRunner.class)
 public class NetworkScanHelperTest {
 
@@ -197,6 +200,7 @@
     }
 
     @Test
+    @Ignore
     public void startNetworkScan_incrementalAndAbort_doStop() {
         doReturn(mNetworkScan).when(mTelephonyManager).requestNetworkScan(
                 any(NetworkScanRequest.class), any(Executor.class),
diff --git a/tests/robotests/src/com/android/settings/network/telephony/WifiCallingPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/network/telephony/WifiCallingPreferenceControllerTest.java
index 1c79266..ffd0eb8 100644
--- a/tests/robotests/src/com/android/settings/network/telephony/WifiCallingPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/network/telephony/WifiCallingPreferenceControllerTest.java
@@ -40,6 +40,7 @@
 import com.android.settings.core.BasePreferenceController;
 
 import org.junit.Before;
+import org.junit.Ignore;
 import org.junit.Test;
 import org.junit.runner.RunWith;
 import org.mockito.Mock;
@@ -174,6 +175,7 @@
     }
 
     @Test
+    @Ignore
     public void displayPreference_available_setsSubscriptionIdOnIntent() {
         final Intent intent = new Intent();
         mPreference.setIntent(intent);
diff --git a/tests/robotests/src/com/android/settings/testutils/ResolveInfoBuilder.java b/tests/robotests/src/com/android/settings/testutils/ResolveInfoBuilder.java
new file mode 100644
index 0000000..5eaf2a4
--- /dev/null
+++ b/tests/robotests/src/com/android/settings/testutils/ResolveInfoBuilder.java
@@ -0,0 +1,71 @@
+/*
+ * Copyright (C) 2020 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.android.settings.testutils;
+
+import android.content.pm.ActivityInfo;
+import android.content.pm.ApplicationInfo;
+import android.content.pm.PackageInfo;
+import android.content.pm.ProviderInfo;
+import android.content.pm.ResolveInfo;
+
+import com.google.common.base.Preconditions;
+
+/**
+ * Helper for building {@link ResolveInfo}s to be used in Robolectric tests.
+ *
+ * <p>The resulting {@link PackageInfo}s should typically be added to {@link
+ * org.robolectric.shadows.ShadowPackageManager#addResolveInfoForIntent(Intent, ResolveInfo)}.
+ */
+public final class ResolveInfoBuilder {
+
+    private final String mPackageName;
+    private ActivityInfo mActivityInfo;
+    private ProviderInfo mProviderInfo;
+
+    public ResolveInfoBuilder(String packageName) {
+        this.mPackageName = Preconditions.checkNotNull(packageName);
+    }
+
+    public ResolveInfoBuilder setActivity(String packageName, String className) {
+        mActivityInfo = new ActivityInfo();
+        mActivityInfo.packageName = packageName;
+        mActivityInfo.name = className;
+        return this;
+    }
+
+    public ResolveInfoBuilder setProvider(
+            String packageName, String className, String authority, boolean isSystemApp) {
+        mProviderInfo = new ProviderInfo();
+        mProviderInfo.authority = authority;
+        mProviderInfo.applicationInfo = new ApplicationInfo();
+        if (isSystemApp) {
+            mProviderInfo.applicationInfo.flags |= ApplicationInfo.FLAG_SYSTEM;
+        }
+        mProviderInfo.packageName = mPackageName;
+        mProviderInfo.applicationInfo.packageName  = mPackageName;
+        mProviderInfo.name = className;
+        return this;
+    }
+
+    public ResolveInfo build() {
+        ResolveInfo info = new ResolveInfo();
+        info.activityInfo = mActivityInfo;
+        info.resolvePackageName = mPackageName;
+        info.providerInfo = mProviderInfo;
+        return info;
+    }
+}
diff --git a/tests/robotests/src/com/android/settings/wifi/ConfigureWifiSettingsTest.java b/tests/robotests/src/com/android/settings/wifi/ConfigureWifiSettingsTest.java
index d1d7885..77ef219 100644
--- a/tests/robotests/src/com/android/settings/wifi/ConfigureWifiSettingsTest.java
+++ b/tests/robotests/src/com/android/settings/wifi/ConfigureWifiSettingsTest.java
@@ -9,6 +9,7 @@
 import com.android.settings.testutils.XmlTestUtils;
 
 import org.junit.Before;
+import org.junit.Ignore;
 import org.junit.Test;
 import org.junit.runner.RunWith;
 import org.robolectric.RobolectricTestRunner;
@@ -28,6 +29,7 @@
     }
 
     @Test
+    @Ignore
     public void testNonIndexableKeys_existInXmlLayout() {
         final List<String> niks =
             ConfigureWifiSettings.SEARCH_INDEX_DATA_PROVIDER.getNonIndexableKeys(mContext);
diff --git a/tests/robotests/src/com/android/settings/wifi/tether/TetherServiceTest.java b/tests/robotests/src/com/android/settings/wifi/tether/TetherServiceTest.java
index f6fd660..1bdfed0 100644
--- a/tests/robotests/src/com/android/settings/wifi/tether/TetherServiceTest.java
+++ b/tests/robotests/src/com/android/settings/wifi/tether/TetherServiceTest.java
@@ -30,6 +30,7 @@
 import android.net.wifi.WifiManager;
 
 import org.junit.Before;
+import org.junit.Ignore;
 import org.junit.Test;
 import org.junit.runner.RunWith;
 import org.mockito.Mock;
@@ -61,6 +62,7 @@
     }
 
     @Test
+    @Ignore
     public void scheduleAlarm_shouldRegisterReceiver() {
         mService.setHotspotOffReceiver(new HotspotOffReceiver(mAppContext));
 
@@ -78,6 +80,7 @@
     }
 
     @Test
+    @Ignore
     public void cancelAlarmIfNecessary_hasActiveTethers_shouldNotUnregisterReceiver() {
         mService.scheduleAlarm();
         final ArrayList<Integer> tethers = new ArrayList<>();
@@ -89,6 +92,7 @@
     }
 
     @Test
+    @Ignore
     public void cancelAlarmIfNecessary_noActiveTethers_shouldUnregisterReceiver() {
         final ArrayList<Integer> tethers = new ArrayList<>();
         ReflectionHelpers.setField(mService, "mCurrentTethers", tethers);
diff --git a/tests/robotests/src/com/android/settings/wifi/tether/WifiTetherPasswordPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/wifi/tether/WifiTetherPasswordPreferenceControllerTest.java
index 902249e..bf2261a 100644
--- a/tests/robotests/src/com/android/settings/wifi/tether/WifiTetherPasswordPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/wifi/tether/WifiTetherPasswordPreferenceControllerTest.java
@@ -66,7 +66,7 @@
         MockitoAnnotations.initMocks(this);
         mPreference = new ValidatedEditTextPreference(RuntimeEnvironment.application);
         mConfig = new SoftApConfiguration.Builder().setSsid("test_1234")
-                .setWpa2Passphrase("test_password").build();
+                .setPassphrase("test_password", SoftApConfiguration.SECURITY_TYPE_WPA2_PSK).build();
 
         when(mContext.getSystemService(Context.WIFI_SERVICE)).thenReturn(mWifiManager);
         when(mWifiManager.getSoftApConfiguration()).thenReturn(mConfig);
@@ -83,8 +83,8 @@
     public void displayPreference_shouldStylePreference() {
         mController.displayPreference(mScreen);
 
-        assertThat(mPreference.getText()).isEqualTo(mConfig.getWpa2Passphrase());
-        assertThat(mPreference.getSummary()).isEqualTo(mConfig.getWpa2Passphrase());
+        assertThat(mPreference.getText()).isEqualTo(mConfig.getPassphrase());
+        assertThat(mPreference.getSummary()).isEqualTo(mConfig.getPassphrase());
     }
 
     @Test
@@ -111,14 +111,14 @@
 
         // Create a new config using different password
         final SoftApConfiguration config = new SoftApConfiguration.Builder()
-                .setWpa2Passphrase(VALID_PASS2).build();
+                .setPassphrase(VALID_PASS2, SoftApConfiguration.SECURITY_TYPE_WPA2_PSK).build();
         when(mWifiManager.getSoftApConfiguration()).thenReturn(config);
 
         // Call updateDisplay and verify it's changed.
         mController.updateDisplay();
         assertThat(mController.getPasswordValidated(SoftApConfiguration.SECURITY_TYPE_WPA2_PSK))
-                .isEqualTo(config.getWpa2Passphrase());
-        assertThat(mPreference.getSummary()).isEqualTo(config.getWpa2Passphrase());
+                .isEqualTo(config.getPassphrase());
+        assertThat(mPreference.getSummary()).isEqualTo(config.getPassphrase());
     }
 
     @Test
@@ -131,7 +131,7 @@
 
         // Create a new config using different password
         final SoftApConfiguration config = new SoftApConfiguration.Builder()
-                .setWpa2Passphrase(VALID_PASS2).build();
+                .setPassphrase(VALID_PASS2, SoftApConfiguration.SECURITY_TYPE_WPA2_PSK).build();
         when(mWifiManager.getSoftApConfiguration()).thenReturn(config);
 
         // Call updateDisplay and verify it's changed.
diff --git a/tests/robotests/src/com/android/settings/wifi/tether/WifiTetherSSIDPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/wifi/tether/WifiTetherSSIDPreferenceControllerTest.java
index c0c1dde..fc38088 100644
--- a/tests/robotests/src/com/android/settings/wifi/tether/WifiTetherSSIDPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/wifi/tether/WifiTetherSSIDPreferenceControllerTest.java
@@ -124,7 +124,8 @@
     public void displayPreference_wifiApDisabled_shouldHideQrCodeIcon() {
         when(mWifiManager.isWifiApEnabled()).thenReturn(false);
         final SoftApConfiguration config = new SoftApConfiguration.Builder()
-                .setSsid("test_1234").setWpa2Passphrase("test_password").build();
+                .setSsid("test_1234").setPassphrase("test_password",
+                SoftApConfiguration.SECURITY_TYPE_WPA2_PSK).build();
         when(mWifiManager.getSoftApConfiguration()).thenReturn(config);
 
         mController.displayPreference(mScreen);
@@ -135,7 +136,8 @@
     public void displayPreference_wifiApEnabled_shouldShowQrCodeIcon() {
         when(mWifiManager.isWifiApEnabled()).thenReturn(true);
         final SoftApConfiguration config = new SoftApConfiguration.Builder()
-                .setSsid("test_1234").setWpa2Passphrase("test_password").build();
+                .setSsid("test_1234").setPassphrase("test_password",
+                SoftApConfiguration.SECURITY_TYPE_WPA2_PSK).build();
         when(mWifiManager.getSoftApConfiguration()).thenReturn(config);
 
         mController.displayPreference(mScreen);
diff --git a/tests/robotests/src/com/android/settings/wifi/tether/WifiTetherSecurityPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/wifi/tether/WifiTetherSecurityPreferenceControllerTest.java
index 5ad94cb..0b066cd 100644
--- a/tests/robotests/src/com/android/settings/wifi/tether/WifiTetherSecurityPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/wifi/tether/WifiTetherSecurityPreferenceControllerTest.java
@@ -15,6 +15,7 @@
 import androidx.preference.PreferenceScreen;
 
 import org.junit.Before;
+import org.junit.Ignore;
 import org.junit.Test;
 import org.junit.runner.RunWith;
 import org.mockito.Mock;
@@ -45,7 +46,8 @@
     public void setUp() {
         MockitoAnnotations.initMocks(this);
         mConfig = new SoftApConfiguration.Builder().setSsid("test_1234")
-                .setWpa2Passphrase("test_password").build();
+                .setPassphrase("test_password",
+                SoftApConfiguration.SECURITY_TYPE_WPA2_PSK).build();
         mContext = spy(RuntimeEnvironment.application);
 
         when(mContext.getSystemService(Context.WIFI_SERVICE)).thenReturn(mWifiManager);
@@ -74,6 +76,7 @@
     }
 
     @Test
+    @Ignore
     public void updateDisplay_preferenceUpdated() {
         // test defaulting to WPA2-Personal on new config
         when(mWifiManager.getSoftApConfiguration()).thenReturn(null);
@@ -84,7 +87,7 @@
 
         // test open tether network
         SoftApConfiguration config = new SoftApConfiguration.Builder(mConfig)
-                .setWpa2Passphrase(null).build();
+                .setPassphrase(null, SoftApConfiguration.SECURITY_TYPE_WPA2_PSK).build();
         when(mWifiManager.getSoftApConfiguration()).thenReturn(config);
         mController.updateDisplay();
         assertThat(mController.getSecurityType()).isEqualTo(
@@ -93,7 +96,8 @@
 
         // test WPA2-Personal tether network
         SoftApConfiguration config2 = new SoftApConfiguration.Builder(mConfig)
-                .setWpa2Passphrase("test_password").build();
+                .setPassphrase("test_password",
+                SoftApConfiguration.SECURITY_TYPE_WPA2_PSK).build();
         when(mWifiManager.getSoftApConfiguration()).thenReturn(config2);
         mController.updateDisplay();
         assertThat(mController.getSecurityType()).isEqualTo(