Merge "Revert "Revert "Fix test case fail"""
diff --git a/AndroidManifest.xml b/AndroidManifest.xml
index 3933b9c..871f609 100644
--- a/AndroidManifest.xml
+++ b/AndroidManifest.xml
@@ -2973,11 +2973,16 @@
             android:label="@string/settings_panel_title"
             android:theme="@style/Theme.BottomDialog"
             android:excludeFromRecents="true"
-            android:launchMode="singleTask">
+            android:launchMode="singleTask"
+            android:exported="true">
                  <intent-filter>
-                     <action android:name="android.settings.SETTINGSPANEL" />
+                     <action android:name="android.settings.panel.action.INTERNET_CONNECTIVITY" />
                      <category android:name="android.intent.category.DEFAULT" />
                  </intent-filter>
+                <intent-filter>
+                    <action android:name="android.settings.panel.action.VOLUME" />
+                    <category android:name="android.intent.category.DEFAULT" />
+                </intent-filter>
         </activity>
 
         <provider android:name=".slices.SettingsSliceProvider"
diff --git a/res/layout/face_enroll_accessibility_toggle.xml b/res/layout/face_enroll_accessibility_toggle.xml
new file mode 100644
index 0000000..4dda2a7
--- /dev/null
+++ b/res/layout/face_enroll_accessibility_toggle.xml
@@ -0,0 +1,46 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Copyright (C) 2018 The Android Open Source Project
+
+     Licensed under the Apache License, Version 2.0 (the "License");
+     you may not use this file except in compliance with the License.
+     You may obtain a copy of the License at
+
+          http://www.apache.org/licenses/LICENSE-2.0
+
+     Unless required by applicable law or agreed to in writing, software
+     distributed under the License is distributed on an "AS IS" BASIS,
+     WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+     See the License for the specific language governing permissions and
+     limitations under the License.
+-->
+
+<LinearLayout
+    xmlns:android="http://schemas.android.com/apk/res/android"
+    android:orientation="horizontal"
+    android:layout_width="match_parent"
+    android:layout_height="match_parent"
+    android:paddingEnd="16dp"
+    android:paddingStart="16dp">
+
+    <TextView
+        android:layout_width="wrap_content"
+        android:layout_height="wrap_content"
+        android:id="@+id/title"/>
+
+    <Space
+        android:layout_width="0dp"
+        android:layout_height="0dp"
+        android:layout_weight="1"/>
+
+    <View
+        android:layout_width="1dp"
+        android:layout_height="match_parent"
+        android:background="?android:attr/listDivider" />
+
+    <Switch
+        android:layout_width="wrap_content"
+        android:layout_height="wrap_content"
+        android:id="@+id/toggle"
+        android:checked="true"/>
+
+</LinearLayout>
diff --git a/res/layout/face_enroll_introduction.xml b/res/layout/face_enroll_introduction.xml
index 7a5c172..025c239 100644
--- a/res/layout/face_enroll_introduction.xml
+++ b/res/layout/face_enroll_introduction.xml
@@ -18,6 +18,7 @@
 <com.google.android.setupdesign.GlifLayout
     xmlns:android="http://schemas.android.com/apk/res/android"
     xmlns:app="http://schemas.android.com/apk/res-auto"
+    xmlns:FaceEnrollAccessibilitySwitch="http://schemas.android.com/apk/res/com.android.settings"
     style="?attr/face_layout_theme"
     android:id="@+id/setup_wizard_layout"
     android:layout_width="match_parent"
@@ -59,6 +60,41 @@
 
         </com.google.android.setupdesign.view.FillContentLayout>
 
+        <FrameLayout
+            android:layout_width="match_parent"
+            android:layout_height="wrap_content"
+            android:layout_gravity="center">
+            <Button
+                android:id="@+id/accessibility_button"
+                style="@style/SuwGlifButton.Secondary"
+                android:layout_gravity="center"
+                android:layout_width="wrap_content"
+                android:layout_height="wrap_content"
+                android:text="@string/security_settings_face_enroll_introduction_accessibility" />
+
+            <LinearLayout
+                android:layout_width="match_parent"
+                android:layout_height="wrap_content"
+                android:layout_gravity="center"
+                android:id="@+id/accessibility_layout"
+                android:orientation="vertical"
+                android:visibility="invisible">
+
+                <com.android.settings.biometrics.face.FaceEnrollAccessibilityToggle
+                    android:id="@+id/toggle_diversity"
+                    android:layout_width="match_parent"
+                    android:layout_height="wrap_content"
+                    FaceEnrollAccessibilitySwitch:messageText="@string/security_settings_face_enroll_introduction_accessibility_diversity"/>
+
+                <com.android.settings.biometrics.face.FaceEnrollAccessibilityToggle
+                    android:id="@+id/toggle_vision"
+                    android:layout_width="match_parent"
+                    android:layout_height="wrap_content"
+                    FaceEnrollAccessibilitySwitch:messageText="@string/security_settings_face_enroll_introduction_accessibility_vision"/>
+
+            </LinearLayout>
+        </FrameLayout>
+
     </LinearLayout>
 
 </com.google.android.setupdesign.GlifLayout>
diff --git a/res/layout/panel_layout.xml b/res/layout/panel_layout.xml
index a6f62a4..c466ce8 100644
--- a/res/layout/panel_layout.xml
+++ b/res/layout/panel_layout.xml
@@ -22,7 +22,7 @@
               android:orientation="vertical">
 
     <TextView
-        android:id="@+id/title"
+        android:id="@+id/panel_title"
         android:layout_width="match_parent"
         android:layout_height="wrap_content"
         android:gravity="center"
diff --git a/res/values/attrs.xml b/res/values/attrs.xml
index 383506d..806e148 100644
--- a/res/values/attrs.xml
+++ b/res/values/attrs.xml
@@ -146,6 +146,11 @@
         <attr name="thickness" format="dimension" />
     </declare-styleable>
 
+    <!-- For Face enroll accessibility toggle -->
+    <declare-styleable name="FaceEnrollAccessibilityToggle">
+        <attr name="messageText" format="reference" />
+    </declare-styleable>
+
     <!-- For TwoStatesButtonPreference -->
     <declare-styleable name="TwoStateButtonPreference">
         <attr name="textOn" format="reference" />
diff --git a/res/values/strings.xml b/res/values/strings.xml
index d07cc53..da05a41 100644
--- a/res/values/strings.xml
+++ b/res/values/strings.xml
@@ -877,6 +877,12 @@
     <string name="security_settings_face_preference_summary_none">Tap to set up face authentication</string>
     <!-- Title shown for menu item that launches face settings or enrollment. [CHAR LIMIT=32] -->
     <string name="security_settings_face_preference_title">Face authentication</string>
+    <!-- Button shown which shows accessibility toggles for face enrollment when clicked. [CHAR LIMIT=32] -->
+    <string name="security_settings_face_enroll_introduction_accessibility">Use accessibility setup</string>
+    <!-- Message shown for a toggle which when disabled, allows the user to enroll using a simpler flow for accessibility [CHAR LIMIT=NONE] -->
+    <string name="security_settings_face_enroll_introduction_accessibility_diversity"></string>
+    <!-- Message shown for a toggle which when disabled, allows the user to enroll using a simpler flow for accessibility [CHAR LIMIT=NONE] -->
+    <string name="security_settings_face_enroll_introduction_accessibility_vision"></string>
     <!-- Button text to cancel enrollment from the introduction [CHAR LIMIT=22] -->
     <string name="security_settings_face_enroll_introduction_cancel">Cancel</string>
     <!-- Introduction title shown in face enrollment to introduce the face unlock feature [CHAR LIMIT=40] -->
diff --git a/src/com/android/settings/biometrics/BiometricEnrollBase.java b/src/com/android/settings/biometrics/BiometricEnrollBase.java
index 2597b29..7a06671 100644
--- a/src/com/android/settings/biometrics/BiometricEnrollBase.java
+++ b/src/com/android/settings/biometrics/BiometricEnrollBase.java
@@ -40,8 +40,10 @@
  */
 public abstract class BiometricEnrollBase extends InstrumentedActivity
         implements View.OnClickListener {
-    public static final String EXTRA_KEY_LAUNCHED_CONFIRM = "launched_confirm_lock";
 
+    public static final String EXTRA_KEY_LAUNCHED_CONFIRM = "launched_confirm_lock";
+    public static final String EXTRA_KEY_REQUIRE_VISION = "accessibility_vision";
+    public static final String EXTRA_KEY_REQUIRE_DIVERSITY = "accessibility_diversity";
 
     /**
      * Used by the choose fingerprint wizard to indicate the wizard is
diff --git a/src/com/android/settings/biometrics/face/FaceEnrollAccessibilityToggle.java b/src/com/android/settings/biometrics/face/FaceEnrollAccessibilityToggle.java
new file mode 100644
index 0000000..49f4f7f
--- /dev/null
+++ b/src/com/android/settings/biometrics/face/FaceEnrollAccessibilityToggle.java
@@ -0,0 +1,66 @@
+/*
+ * 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.biometrics.face;
+
+import android.content.Context;
+import android.content.res.TypedArray;
+import android.util.AttributeSet;
+import android.view.LayoutInflater;
+import android.widget.LinearLayout;
+import android.widget.Switch;
+import android.widget.TextView;
+
+import com.android.settings.R;
+
+/**
+ * A layout that contains a start-justified title, and an end-justified switch.
+ */
+public class FaceEnrollAccessibilityToggle extends LinearLayout {
+
+    private Switch mSwitch;
+
+    public FaceEnrollAccessibilityToggle(Context context) {
+        this(context, null /* attrs */);
+    }
+
+    public FaceEnrollAccessibilityToggle(Context context, AttributeSet attrs) {
+        this(context, attrs, 0);
+    }
+
+    public FaceEnrollAccessibilityToggle(Context context, AttributeSet attrs, int defStyleAttr) {
+        super(context, attrs, defStyleAttr);
+
+        LayoutInflater.from(context).inflate(R.layout.face_enroll_accessibility_toggle,
+                this, true /* attachToRoot */);
+
+        final TypedArray a =
+                context.obtainStyledAttributes(attrs, R.styleable.FaceEnrollAccessibilityToggle);
+        try {
+            final CharSequence title =
+                    a.getText(R.styleable.FaceEnrollAccessibilityToggle_messageText);
+            final TextView titleTextView = findViewById(R.id.title);
+            titleTextView.setText(title);
+        } finally {
+            a.recycle();
+        }
+        mSwitch = findViewById(R.id.toggle);
+    }
+
+    public boolean isChecked() {
+        return mSwitch.isChecked();
+    }
+}
diff --git a/src/com/android/settings/biometrics/face/FaceEnrollEnrolling.java b/src/com/android/settings/biometrics/face/FaceEnrollEnrolling.java
index bb46b18..990eef4 100644
--- a/src/com/android/settings/biometrics/face/FaceEnrollEnrolling.java
+++ b/src/com/android/settings/biometrics/face/FaceEnrollEnrolling.java
@@ -29,11 +29,12 @@
 
 import com.android.internal.logging.nano.MetricsProto;
 import com.android.settings.R;
-import com.android.settings.Utils;
+import com.android.settings.biometrics.BiometricEnrollBase;
 import com.android.settings.biometrics.BiometricEnrollSidecar;
 import com.android.settings.biometrics.BiometricErrorDialog;
 import com.android.settings.biometrics.BiometricsEnrollEnrolling;
-import com.android.settings.password.ChooseLockSettingsHelper;
+
+import java.util.ArrayList;
 
 
 public class FaceEnrollEnrolling extends BiometricsEnrollEnrolling {
@@ -46,6 +47,8 @@
     private Interpolator mLinearOutSlowInInterpolator;
     private FaceEnrollPreviewFragment mPreviewFragment;
 
+    private ArrayList<Integer> mDisabledFeatures = new ArrayList<>();
+
     private FaceFeatureProvider.Listener mListener = new FaceFeatureProvider.Listener() {
         @Override
         public void onEnrolled() {
@@ -91,6 +94,13 @@
         Button skipButton = findViewById(R.id.skip_button);
         skipButton.setOnClickListener(this);
 
+        if (!getIntent().getBooleanExtra(BiometricEnrollBase.EXTRA_KEY_REQUIRE_DIVERSITY, true)) {
+            mDisabledFeatures.add(FaceManager.FEATURE_REQUIRE_REQUIRE_DIVERSITY);
+        }
+        if (!getIntent().getBooleanExtra(BiometricEnrollBase.EXTRA_KEY_REQUIRE_VISION, true)) {
+            mDisabledFeatures.add(FaceManager.FEATURE_REQUIRE_ATTENTION);
+        }
+
         startEnrollment();
     }
 
@@ -114,7 +124,12 @@
 
     @Override
     protected BiometricEnrollSidecar getSidecar() {
-        return new FaceEnrollSidecar();
+        final int[] disabledFeatures = new int[mDisabledFeatures.size()];
+        for (int i = 0; i < mDisabledFeatures.size(); i++) {
+            disabledFeatures[i] = mDisabledFeatures.get(i);
+        }
+
+        return new FaceEnrollSidecar(disabledFeatures);
     }
 
     @Override
diff --git a/src/com/android/settings/biometrics/face/FaceEnrollIntroduction.java b/src/com/android/settings/biometrics/face/FaceEnrollIntroduction.java
index b720ff4..e221c96 100644
--- a/src/com/android/settings/biometrics/face/FaceEnrollIntroduction.java
+++ b/src/com/android/settings/biometrics/face/FaceEnrollIntroduction.java
@@ -20,7 +20,9 @@
 import android.content.Intent;
 import android.hardware.face.FaceManager;
 import android.os.Bundle;
+import android.view.View;
 import android.widget.Button;
+import android.widget.LinearLayout;
 import android.widget.TextView;
 
 import com.android.internal.logging.nano.MetricsProto;
@@ -37,11 +39,22 @@
     private static final String TAG = "FaceIntro";
 
     private FaceManager mFaceManager;
+    private FaceEnrollAccessibilityToggle mSwitchVision;
+    private FaceEnrollAccessibilityToggle mSwitchDiversity;
 
     @Override
     protected void onCreate(Bundle savedInstanceState) {
         super.onCreate(savedInstanceState);
         mFaceManager = Utils.getFaceManagerOrNull(this);
+        final LinearLayout accessibilityLayout = findViewById(R.id.accessibility_layout);
+        final Button accessibilityButton = findViewById(R.id.accessibility_button);
+        accessibilityButton.setOnClickListener(view -> {
+            accessibilityButton.setVisibility(View.INVISIBLE);
+            accessibilityLayout.setVisibility(View.VISIBLE);
+        });
+
+        mSwitchVision = findViewById(R.id.toggle_vision);
+        mSwitchDiversity = findViewById(R.id.toggle_diversity);
     }
 
     @Override
@@ -116,7 +129,10 @@
 
     @Override
     protected Intent getEnrollingIntent() {
-        return new Intent(this, FaceEnrollEnrolling.class);
+        final Intent intent = new Intent(this, FaceEnrollEnrolling.class);
+        intent.putExtra(EXTRA_KEY_REQUIRE_VISION, mSwitchVision.isChecked());
+        intent.putExtra(EXTRA_KEY_REQUIRE_DIVERSITY, mSwitchDiversity.isChecked());
+        return intent;
     }
 
     @Override
diff --git a/src/com/android/settings/biometrics/face/FaceEnrollSidecar.java b/src/com/android/settings/biometrics/face/FaceEnrollSidecar.java
index 2433fcb..7519530 100644
--- a/src/com/android/settings/biometrics/face/FaceEnrollSidecar.java
+++ b/src/com/android/settings/biometrics/face/FaceEnrollSidecar.java
@@ -24,13 +24,22 @@
 import com.android.settings.Utils;
 import com.android.settings.biometrics.BiometricEnrollSidecar;
 
+import java.util.ArrayList;
+import java.util.Arrays;
+
 /**
  * Sidecar fragment to handle the state around face enrollment
  */
 public class FaceEnrollSidecar extends BiometricEnrollSidecar {
 
+    private final int[] mDisabledFeatures;
+
     private FaceManager mFaceManager;
 
+    public FaceEnrollSidecar(int[] disabledFeatures) {
+        mDisabledFeatures = Arrays.copyOf(disabledFeatures, disabledFeatures.length);
+    }
+
     @Override
     public void onAttach(Activity activity) {
         super.onAttach(activity);
@@ -43,9 +52,9 @@
         if (mUserId != UserHandle.USER_NULL) {
             mFaceManager.setActiveUser(mUserId);
         }
-        // TODO: Send the list of disabled features
+
         mFaceManager.enroll(mToken, mEnrollmentCancel,
-                mEnrollmentCallback, new int[0] /* disabledFeatures */);
+                mEnrollmentCallback, mDisabledFeatures);
     }
 
     private FaceManager.EnrollmentCallback mEnrollmentCallback
diff --git a/src/com/android/settings/connecteddevice/usb/ConnectedUsbDeviceUpdater.java b/src/com/android/settings/connecteddevice/usb/ConnectedUsbDeviceUpdater.java
index befdf29..0be1438 100644
--- a/src/com/android/settings/connecteddevice/usb/ConnectedUsbDeviceUpdater.java
+++ b/src/com/android/settings/connecteddevice/usb/ConnectedUsbDeviceUpdater.java
@@ -15,9 +15,12 @@
  */
 package com.android.settings.connecteddevice.usb;
 
+import static android.hardware.usb.UsbPortStatus.DATA_ROLE_DEVICE;
+import static android.hardware.usb.UsbPortStatus.POWER_ROLE_SINK;
+import static android.hardware.usb.UsbPortStatus.POWER_ROLE_SOURCE;
+
 import android.content.Context;
 import android.hardware.usb.UsbManager;
-import android.hardware.usb.UsbPort;
 
 import androidx.annotation.VisibleForTesting;
 import androidx.preference.Preference;
@@ -43,7 +46,7 @@
     UsbConnectionBroadcastReceiver.UsbConnectionListener mUsbConnectionListener =
             (connected, functions, powerRole, dataRole) -> {
                 if (connected) {
-                    mUsbPreference.setSummary(getSummary(dataRole == UsbPort.DATA_ROLE_DEVICE
+                    mUsbPreference.setSummary(getSummary(dataRole == DATA_ROLE_DEVICE
                                     ? functions : UsbManager.FUNCTION_NONE, powerRole));
                     mDevicePreferenceCallback.onDeviceAdded(mUsbPreference);
                 } else {
@@ -100,7 +103,7 @@
 
     public static int getSummary(long functions, int power) {
         switch (power) {
-            case UsbPort.POWER_ROLE_SINK:
+            case POWER_ROLE_SINK:
                 if (functions == UsbManager.FUNCTION_MTP) {
                     return R.string.usb_summary_file_transfers;
                 } else if (functions == UsbManager.FUNCTION_RNDIS) {
@@ -112,7 +115,7 @@
                 } else {
                     return R.string.usb_summary_charging_only;
                 }
-            case UsbPort.POWER_ROLE_SOURCE:
+            case POWER_ROLE_SOURCE:
                 if (functions == UsbManager.FUNCTION_MTP) {
                     return R.string.usb_summary_file_transfers_power;
                 } else if (functions == UsbManager.FUNCTION_RNDIS) {
diff --git a/src/com/android/settings/connecteddevice/usb/UsbBackend.java b/src/com/android/settings/connecteddevice/usb/UsbBackend.java
index f68a4a0..556f76d 100644
--- a/src/com/android/settings/connecteddevice/usb/UsbBackend.java
+++ b/src/com/android/settings/connecteddevice/usb/UsbBackend.java
@@ -15,6 +15,13 @@
  */
 package com.android.settings.connecteddevice.usb;
 
+import static android.hardware.usb.UsbPortStatus.DATA_ROLE_DEVICE;
+import static android.hardware.usb.UsbPortStatus.POWER_ROLE_NONE;
+import static android.hardware.usb.UsbPortStatus.POWER_ROLE_SOURCE;
+import static android.service.usb.UsbPortStatusProto.DATA_ROLE_HOST;
+import static android.service.usb.UsbPortStatusProto.DATA_ROLE_NONE;
+import static android.service.usb.UsbPortStatusProto.POWER_ROLE_SINK;
+
 import android.annotation.Nullable;
 import android.content.Context;
 import android.content.pm.PackageManager;
@@ -27,6 +34,8 @@
 
 import androidx.annotation.VisibleForTesting;
 
+import java.util.List;
+
 /**
  * Provides access to underlying system USB functionality.
  */
@@ -96,30 +105,30 @@
 
     public int getPowerRole() {
         updatePorts();
-        return mPortStatus == null ? UsbPort.POWER_ROLE_NONE : mPortStatus.getCurrentPowerRole();
+        return mPortStatus == null ? POWER_ROLE_NONE : mPortStatus.getCurrentPowerRole();
     }
 
     public int getDataRole() {
         updatePorts();
-        return mPortStatus == null ? UsbPort.DATA_ROLE_NONE : mPortStatus.getCurrentDataRole();
+        return mPortStatus == null ? DATA_ROLE_NONE : mPortStatus.getCurrentDataRole();
     }
 
     public void setPowerRole(int role) {
         int newDataRole = getDataRole();
         if (!areAllRolesSupported()) {
             switch (role) {
-                case UsbPort.POWER_ROLE_SINK:
-                    newDataRole = UsbPort.DATA_ROLE_DEVICE;
+                case POWER_ROLE_SINK:
+                    newDataRole = DATA_ROLE_DEVICE;
                     break;
-                case UsbPort.POWER_ROLE_SOURCE:
-                    newDataRole = UsbPort.DATA_ROLE_HOST;
+                case POWER_ROLE_SOURCE:
+                    newDataRole = DATA_ROLE_HOST;
                     break;
                 default:
-                    newDataRole = UsbPort.DATA_ROLE_NONE;
+                    newDataRole = DATA_ROLE_NONE;
             }
         }
         if (mPort != null) {
-            mUsbManager.setPortRoles(mPort, role, newDataRole);
+            mPort.setRoles(role, newDataRole);
         }
     }
 
@@ -127,31 +136,27 @@
         int newPowerRole = getPowerRole();
         if (!areAllRolesSupported()) {
             switch (role) {
-                case UsbPort.DATA_ROLE_DEVICE:
-                    newPowerRole = UsbPort.POWER_ROLE_SINK;
+                case DATA_ROLE_DEVICE:
+                    newPowerRole = POWER_ROLE_SINK;
                     break;
-                case UsbPort.DATA_ROLE_HOST:
-                    newPowerRole = UsbPort.POWER_ROLE_SOURCE;
+                case DATA_ROLE_HOST:
+                    newPowerRole = POWER_ROLE_SOURCE;
                     break;
                 default:
-                    newPowerRole = UsbPort.POWER_ROLE_NONE;
+                    newPowerRole = POWER_ROLE_NONE;
             }
         }
         if (mPort != null) {
-            mUsbManager.setPortRoles(mPort, newPowerRole, role);
+            mPort.setRoles(newPowerRole, role);
         }
     }
 
     public boolean areAllRolesSupported() {
         return mPort != null && mPortStatus != null
-                && mPortStatus
-                .isRoleCombinationSupported(UsbPort.POWER_ROLE_SINK, UsbPort.DATA_ROLE_DEVICE)
-                && mPortStatus
-                .isRoleCombinationSupported(UsbPort.POWER_ROLE_SINK, UsbPort.DATA_ROLE_HOST)
-                && mPortStatus
-                .isRoleCombinationSupported(UsbPort.POWER_ROLE_SOURCE, UsbPort.DATA_ROLE_DEVICE)
-                && mPortStatus
-                .isRoleCombinationSupported(UsbPort.POWER_ROLE_SOURCE, UsbPort.DATA_ROLE_HOST);
+                && mPortStatus.isRoleCombinationSupported(POWER_ROLE_SINK, DATA_ROLE_DEVICE)
+                && mPortStatus.isRoleCombinationSupported(POWER_ROLE_SINK, DATA_ROLE_HOST)
+                && mPortStatus.isRoleCombinationSupported(POWER_ROLE_SOURCE, DATA_ROLE_DEVICE)
+                && mPortStatus.isRoleCombinationSupported(POWER_ROLE_SOURCE, DATA_ROLE_HOST);
     }
 
     public static String usbFunctionsToString(long functions) {
@@ -205,17 +210,14 @@
     private void updatePorts() {
         mPort = null;
         mPortStatus = null;
-        UsbPort[] ports = mUsbManager.getPorts();
-        if (ports == null) {
-            return;
-        }
+        List<UsbPort> ports = mUsbManager.getPorts();
         // For now look for a connected port, in the future we should identify port in the
         // notification and pick based on that.
-        final int N = ports.length;
+        final int N = ports.size();
         for (int i = 0; i < N; i++) {
-            UsbPortStatus status = mUsbManager.getPortStatus(ports[i]);
+            UsbPortStatus status = ports.get(i).getStatus();
             if (status.isConnected()) {
-                mPort = ports[i];
+                mPort = ports.get(i);
                 mPortStatus = status;
                 break;
             }
diff --git a/src/com/android/settings/connecteddevice/usb/UsbConnectionBroadcastReceiver.java b/src/com/android/settings/connecteddevice/usb/UsbConnectionBroadcastReceiver.java
index 1d43371..beb2375 100644
--- a/src/com/android/settings/connecteddevice/usb/UsbConnectionBroadcastReceiver.java
+++ b/src/com/android/settings/connecteddevice/usb/UsbConnectionBroadcastReceiver.java
@@ -49,8 +49,8 @@
         mUsbBackend = backend;
 
         mFunctions = UsbManager.FUNCTION_NONE;
-        mDataRole = UsbPort.DATA_ROLE_NONE;
-        mPowerRole = UsbPort.POWER_ROLE_NONE;
+        mDataRole = UsbPortStatus.DATA_ROLE_NONE;
+        mPowerRole = UsbPortStatus.POWER_ROLE_NONE;
     }
 
     @Override
diff --git a/src/com/android/settings/connecteddevice/usb/UsbDetailsDataRoleController.java b/src/com/android/settings/connecteddevice/usb/UsbDetailsDataRoleController.java
index 84576b1..a584c11 100644
--- a/src/com/android/settings/connecteddevice/usb/UsbDetailsDataRoleController.java
+++ b/src/com/android/settings/connecteddevice/usb/UsbDetailsDataRoleController.java
@@ -16,6 +16,10 @@
 
 package com.android.settings.connecteddevice.usb;
 
+import static android.hardware.usb.UsbPortStatus.DATA_ROLE_DEVICE;
+import static android.hardware.usb.UsbPortStatus.DATA_ROLE_HOST;
+import static android.hardware.usb.UsbPortStatus.DATA_ROLE_NONE;
+
 import android.content.Context;
 import android.hardware.usb.UsbPort;
 
@@ -55,23 +59,23 @@
     public void displayPreference(PreferenceScreen screen) {
         super.displayPreference(screen);
         mPreferenceCategory = (PreferenceCategory) screen.findPreference(getPreferenceKey());
-        mHostPref = makeRadioPreference(UsbBackend.dataRoleToString(UsbPort.DATA_ROLE_HOST),
+        mHostPref = makeRadioPreference(UsbBackend.dataRoleToString(DATA_ROLE_HOST),
                 R.string.usb_control_host);
-        mDevicePref = makeRadioPreference(UsbBackend.dataRoleToString(UsbPort.DATA_ROLE_DEVICE),
+        mDevicePref = makeRadioPreference(UsbBackend.dataRoleToString(DATA_ROLE_DEVICE),
                 R.string.usb_control_device);
     }
 
     @Override
     protected void refresh(boolean connected, long functions, int powerRole, int dataRole) {
-        if (dataRole == UsbPort.DATA_ROLE_DEVICE) {
+        if (dataRole == DATA_ROLE_DEVICE) {
             mDevicePref.setChecked(true);
             mHostPref.setChecked(false);
             mPreferenceCategory.setEnabled(true);
-        } else if (dataRole == UsbPort.DATA_ROLE_HOST) {
+        } else if (dataRole == DATA_ROLE_HOST) {
             mDevicePref.setChecked(false);
             mHostPref.setChecked(true);
             mPreferenceCategory.setEnabled(true);
-        } else if (!connected || dataRole == UsbPort.DATA_ROLE_NONE){
+        } else if (!connected || dataRole == DATA_ROLE_NONE){
             mPreferenceCategory.setEnabled(false);
             if (mNextRolePref == null) {
                 // Disconnected with no operation pending, so clear subtexts
@@ -80,7 +84,7 @@
             }
         }
 
-        if (mNextRolePref != null && dataRole != UsbPort.DATA_ROLE_NONE) {
+        if (mNextRolePref != null && dataRole != DATA_ROLE_NONE) {
             if (UsbBackend.dataRoleFromString(mNextRolePref.getKey()) == dataRole) {
                 // Clear switching text if switch succeeded
                 mNextRolePref.setSummary("");
diff --git a/src/com/android/settings/connecteddevice/usb/UsbDetailsFunctionsController.java b/src/com/android/settings/connecteddevice/usb/UsbDetailsFunctionsController.java
index f74dc0f..283e56b 100644
--- a/src/com/android/settings/connecteddevice/usb/UsbDetailsFunctionsController.java
+++ b/src/com/android/settings/connecteddevice/usb/UsbDetailsFunctionsController.java
@@ -16,6 +16,7 @@
 
 package com.android.settings.connecteddevice.usb;
 
+import static android.hardware.usb.UsbPortStatus.DATA_ROLE_DEVICE;
 import static android.net.ConnectivityManager.TETHERING_USB;
 
 import android.content.Context;
@@ -88,7 +89,7 @@
 
     @Override
     protected void refresh(boolean connected, long functions, int powerRole, int dataRole) {
-        if (!connected || dataRole != UsbPort.DATA_ROLE_DEVICE) {
+        if (!connected || dataRole != DATA_ROLE_DEVICE) {
             mProfilesContainer.setEnabled(false);
         } else {
             // Functions are only available in device mode
diff --git a/src/com/android/settings/connecteddevice/usb/UsbDetailsPowerRoleController.java b/src/com/android/settings/connecteddevice/usb/UsbDetailsPowerRoleController.java
index 30314f6..b59890a 100644
--- a/src/com/android/settings/connecteddevice/usb/UsbDetailsPowerRoleController.java
+++ b/src/com/android/settings/connecteddevice/usb/UsbDetailsPowerRoleController.java
@@ -16,8 +16,13 @@
 
 package com.android.settings.connecteddevice.usb;
 
+import static android.hardware.usb.UsbPortStatus.POWER_ROLE_NONE;
+import static android.hardware.usb.UsbPortStatus.POWER_ROLE_SINK;
+import static android.hardware.usb.UsbPortStatus.POWER_ROLE_SOURCE;
+
 import android.content.Context;
 import android.hardware.usb.UsbPort;
+import android.hardware.usb.UsbPortStatus;
 
 import androidx.preference.Preference;
 import androidx.preference.Preference.OnPreferenceClickListener;
@@ -40,16 +45,16 @@
     private int mNextPowerRole;
 
     private final Runnable mFailureCallback = () -> {
-        if (mNextPowerRole != UsbPort.POWER_ROLE_NONE) {
+        if (mNextPowerRole != POWER_ROLE_NONE) {
             mSwitchPreference.setSummary(R.string.usb_switching_failed);
-            mNextPowerRole = UsbPort.POWER_ROLE_NONE;
+            mNextPowerRole = POWER_ROLE_NONE;
         }
     };
 
     public UsbDetailsPowerRoleController(Context context, UsbDetailsFragment fragment,
             UsbBackend backend) {
         super(context, fragment, backend);
-        mNextPowerRole = UsbPort.POWER_ROLE_NONE;
+        mNextPowerRole = POWER_ROLE_NONE;
     }
 
     @Override
@@ -70,20 +75,21 @@
         } else if (connected && mUsbBackend.areAllRolesSupported()){
             mFragment.getPreferenceScreen().addPreference(mPreferenceCategory);
         }
-        if (powerRole == UsbPort.POWER_ROLE_SOURCE) {
+        if (powerRole == POWER_ROLE_SOURCE) {
             mSwitchPreference.setChecked(true);
             mPreferenceCategory.setEnabled(true);
-        } else if (powerRole == UsbPort.POWER_ROLE_SINK) {
+        } else if (powerRole == POWER_ROLE_SINK) {
             mSwitchPreference.setChecked(false);
             mPreferenceCategory.setEnabled(true);
-        } else if (!connected || powerRole == UsbPort.POWER_ROLE_NONE){
+        } else if (!connected || powerRole == POWER_ROLE_NONE){
             mPreferenceCategory.setEnabled(false);
-            if (mNextPowerRole == UsbPort.POWER_ROLE_NONE) {
+            if (mNextPowerRole == POWER_ROLE_NONE) {
                 mSwitchPreference.setSummary("");
             }
         }
 
-        if (mNextPowerRole != UsbPort.POWER_ROLE_NONE && powerRole != UsbPort.POWER_ROLE_NONE) {
+        if (mNextPowerRole != POWER_ROLE_NONE
+                && powerRole != POWER_ROLE_NONE) {
             if (mNextPowerRole == powerRole) {
                 // Clear switching text if switch succeeded
                 mSwitchPreference.setSummary("");
@@ -91,16 +97,16 @@
                 // Set failure text if switch failed
                 mSwitchPreference.setSummary(R.string.usb_switching_failed);
             }
-            mNextPowerRole = UsbPort.POWER_ROLE_NONE;
+            mNextPowerRole = POWER_ROLE_NONE;
             mHandler.removeCallbacks(mFailureCallback);
         }
     }
 
     @Override
     public boolean onPreferenceClick(Preference preference) {
-        int newRole = mSwitchPreference.isChecked() ? UsbPort.POWER_ROLE_SOURCE
-                : UsbPort.POWER_ROLE_SINK;
-        if (mUsbBackend.getPowerRole() != newRole && mNextPowerRole == UsbPort.POWER_ROLE_NONE
+        int newRole = mSwitchPreference.isChecked() ? POWER_ROLE_SOURCE
+                : POWER_ROLE_SINK;
+        if (mUsbBackend.getPowerRole() != newRole && mNextPowerRole == POWER_ROLE_NONE
                 && !Utils.isMonkeyRunning()) {
             mUsbBackend.setPowerRole(newRole);
 
diff --git a/src/com/android/settings/homepage/contextualcards/ContextualCardLoader.java b/src/com/android/settings/homepage/contextualcards/ContextualCardLoader.java
index 997d86b..88478e3 100644
--- a/src/com/android/settings/homepage/contextualcards/ContextualCardLoader.java
+++ b/src/com/android/settings/homepage/contextualcards/ContextualCardLoader.java
@@ -21,7 +21,7 @@
 import static androidx.slice.widget.SliceLiveData.SUPPORTED_SPECS;
 
 import static com.android.settings.slices.CustomSliceRegistry.BLUETOOTH_DEVICES_SLICE_URI;
-import static com.android.settings.slices.CustomSliceRegistry.WIFI_SLICE_URI;
+import static com.android.settings.slices.CustomSliceRegistry.CONTEXTUAL_WIFI_SLICE_URI;
 
 import android.content.ContentProviderClient;
 import android.content.ContentResolver;
@@ -204,7 +204,7 @@
     }
 
     private boolean isLargeCard(ContextualCard card) {
-        return card.getSliceUri().equals(WIFI_SLICE_URI)
+        return card.getSliceUri().equals(CONTEXTUAL_WIFI_SLICE_URI)
                 || card.getSliceUri().equals(BLUETOOTH_DEVICES_SLICE_URI);
     }
 
diff --git a/src/com/android/settings/homepage/contextualcards/SettingsContextualCardProvider.java b/src/com/android/settings/homepage/contextualcards/SettingsContextualCardProvider.java
index d5500fb..5797043 100644
--- a/src/com/android/settings/homepage/contextualcards/SettingsContextualCardProvider.java
+++ b/src/com/android/settings/homepage/contextualcards/SettingsContextualCardProvider.java
@@ -34,8 +34,8 @@
     public ContextualCardList getContextualCards() {
         final ContextualCard wifiCard =
                 ContextualCard.newBuilder()
-                        .setSliceUri(CustomSliceRegistry.WIFI_SLICE_URI.toString())
-                        .setCardName(CustomSliceRegistry.WIFI_SLICE_URI.toString())
+                        .setSliceUri(CustomSliceRegistry.CONTEXTUAL_WIFI_SLICE_URI.toString())
+                        .setCardName(CustomSliceRegistry.CONTEXTUAL_WIFI_SLICE_URI.toString())
                         .setCardCategory(ContextualCard.Category.IMPORTANT)
                         .build();
         final ContextualCard connectedDeviceCard =
diff --git a/src/com/android/settings/panel/PanelFeatureProviderImpl.java b/src/com/android/settings/panel/PanelFeatureProviderImpl.java
index 503a5c3..ade2ffd 100644
--- a/src/com/android/settings/panel/PanelFeatureProviderImpl.java
+++ b/src/com/android/settings/panel/PanelFeatureProviderImpl.java
@@ -17,15 +17,16 @@
 package com.android.settings.panel;
 
 import android.content.Context;
+import android.provider.Settings;
 
 public class PanelFeatureProviderImpl implements PanelFeatureProvider {
 
     @Override
     public PanelContent getPanel(Context context, String panelType) {
         switch (panelType) {
-            case SettingsPanelActivity.PANEL_TYPE_WIFI:
+            case Settings.Panel.ACTION_INTERNET_CONNECTIVITY:
                 return InternetConnectivityPanel.create(context);
-            case SettingsPanelActivity.PANEL_TYPE_VOLUME:
+            case Settings.Panel.ACTION_VOLUME:
                 return VolumePanel.create(context);
         }
 
diff --git a/src/com/android/settings/panel/PanelFragment.java b/src/com/android/settings/panel/PanelFragment.java
index e61b8f8..7655be8 100644
--- a/src/com/android/settings/panel/PanelFragment.java
+++ b/src/com/android/settings/panel/PanelFragment.java
@@ -69,7 +69,7 @@
         mPanelSlices = view.findViewById(R.id.panel_parent_layout);
         mSeeMoreButton = view.findViewById(R.id.see_more);
         mDoneButton = view.findViewById(R.id.done);
-        mTitleView = view.findViewById(R.id.title);
+        mTitleView = view.findViewById(R.id.panel_title);
 
         final Bundle arguments = getArguments();
         final String panelType = arguments.getString(SettingsPanelActivity.KEY_PANEL_TYPE_ARGUMENT);
diff --git a/src/com/android/settings/panel/SettingsPanelActivity.java b/src/com/android/settings/panel/SettingsPanelActivity.java
index 09bead4..ffe94f8 100644
--- a/src/com/android/settings/panel/SettingsPanelActivity.java
+++ b/src/com/android/settings/panel/SettingsPanelActivity.java
@@ -16,11 +16,9 @@
 
 package com.android.settings.panel;
 
-import android.content.ComponentName;
 import android.content.Intent;
 import android.os.Bundle;
 
-import android.text.TextUtils;
 import android.util.Log;
 import android.view.Gravity;
 import android.view.Window;
@@ -35,8 +33,6 @@
 
 /**
  * Dialog Activity to host Settings Slices.
- *
- * TODO link to action / framework API
  */
 public class SettingsPanelActivity extends FragmentActivity {
 
@@ -47,28 +43,10 @@
      */
     public static final String KEY_PANEL_TYPE_ARGUMENT = "PANEL_TYPE_ARGUMENT";
 
-
-    // TODO (b/117804442) move to framework
-    public static final String EXTRA_PANEL_TYPE = "com.android.settings.panel.extra";
-
-    // TODO (b/117804442) move to framework
-    public static final String PANEL_TYPE_WIFI = "wifi_panel";
-
-    // TODO (b/117804442) move to framework
-    public static final String PANEL_TYPE_VOLUME = "volume_panel";
-
     @Override
     protected void onCreate(@Nullable Bundle savedInstanceState) {
         super.onCreate(savedInstanceState);
 
-        final ComponentName callingActivityName = getCallingActivity();
-
-        if (callingActivityName == null) {
-            Log.e(TAG, "Must start with startActivityForResult. Closing.");
-            finish();
-            return;
-        }
-
         final Intent callingIntent = getIntent();
         if (callingIntent == null) {
             Log.e(TAG, "Null intent, closing Panel Activity");
@@ -76,12 +54,6 @@
             return;
         }
 
-        final String typeExtra = callingIntent.getStringExtra(EXTRA_PANEL_TYPE);
-        if (TextUtils.isEmpty(typeExtra)) {
-            Log.e(TAG, "No intent passed, closing Panel Activity");
-            return;
-        }
-
         setContentView(R.layout.settings_panel);
 
         // Move the window to the bottom of screen, and make it take up the entire screen width.
@@ -90,9 +62,8 @@
         window.setLayout(WindowManager.LayoutParams.MATCH_PARENT,
                 WindowManager.LayoutParams.WRAP_CONTENT);
 
-
         final Bundle bundle = new Bundle();
-        bundle.putString(KEY_PANEL_TYPE_ARGUMENT, typeExtra);
+        bundle.putString(KEY_PANEL_TYPE_ARGUMENT, callingIntent.getAction());
 
         final PanelFragment panelFragment = new PanelFragment();
         panelFragment.setArguments(bundle);
diff --git a/src/com/android/settings/slices/CustomSliceManager.java b/src/com/android/settings/slices/CustomSliceManager.java
index 4a9de15..bb47df2 100644
--- a/src/com/android/settings/slices/CustomSliceManager.java
+++ b/src/com/android/settings/slices/CustomSliceManager.java
@@ -32,7 +32,8 @@
 import com.android.settings.homepage.contextualcards.slices.BluetoothDevicesSlice;
 import com.android.settings.homepage.contextualcards.slices.LowStorageSlice;
 import com.android.settings.location.LocationSlice;
-import com.android.settings.wifi.WifiSlice;
+import com.android.settings.wifi.slice.ContextualWifiSlice;
+import com.android.settings.wifi.slice.WifiSlice;
 
 import java.util.Map;
 import java.util.WeakHashMap;
@@ -107,6 +108,7 @@
         mUriMap.put(CustomSliceRegistry.BATTERY_FIX_SLICE_URI, BatteryFixSlice.class);
         mUriMap.put(CustomSliceRegistry.BATTERY_INFO_SLICE_URI, BatterySlice.class);
         mUriMap.put(CustomSliceRegistry.BLUETOOTH_DEVICES_SLICE_URI, BluetoothDevicesSlice.class);
+        mUriMap.put(CustomSliceRegistry.CONTEXTUAL_WIFI_SLICE_URI, ContextualWifiSlice.class);
         mUriMap.put(CustomSliceRegistry.DATA_USAGE_SLICE_URI, DataUsageSlice.class);
         mUriMap.put(CustomSliceRegistry.DEVICE_INFO_SLICE_URI, DeviceInfoSlice.class);
         mUriMap.put(CustomSliceRegistry.EMERGENCY_INFO_SLICE_URI, EmergencyInfoSlice.class);
diff --git a/src/com/android/settings/slices/CustomSliceRegistry.java b/src/com/android/settings/slices/CustomSliceRegistry.java
index 1b8cffe..bdf8b35 100644
--- a/src/com/android/settings/slices/CustomSliceRegistry.java
+++ b/src/com/android/settings/slices/CustomSliceRegistry.java
@@ -80,6 +80,17 @@
             .appendPath(SettingsSlicesContract.PATH_SETTING_ACTION)
             .appendPath("bluetooth_devices")
             .build();
+
+    /**
+     * Backing Uri for the Wifi Slice.
+     */
+    public static final Uri CONTEXTUAL_WIFI_SLICE_URI = new Uri.Builder()
+            .scheme(ContentResolver.SCHEME_CONTENT)
+            .authority(SettingsSlicesContract.AUTHORITY)
+            .appendPath(SettingsSlicesContract.PATH_SETTING_ACTION)
+            .appendPath("contextual_wifi")
+            .build();
+
     /**
      * Backing Uri for the Data usage Slice.
      */
@@ -216,6 +227,7 @@
             .appendPath(SettingsSlicesContract.PATH_SETTING_ACTION)
             .appendPath(KEY_WIFI)
             .build();
+
     /**
      * Backing Uri for the Zen Mode Slice.
      */
diff --git a/src/com/android/settings/wifi/WifiDialogActivity.java b/src/com/android/settings/wifi/WifiDialogActivity.java
index 9ef6a39..c32bcf3 100644
--- a/src/com/android/settings/wifi/WifiDialogActivity.java
+++ b/src/com/android/settings/wifi/WifiDialogActivity.java
@@ -38,6 +38,8 @@
 
     private static final String TAG = "WifiDialogActivity";
 
+    public static final String KEY_ACCESS_POINT_STATE = "access_point_state";
+
     /**
      * Boolean extra indicating whether this activity should connect to an access point on the
      * caller's behalf. If this is set to false, the caller should check
@@ -46,9 +48,8 @@
      */
     @VisibleForTesting
     static final String KEY_CONNECT_FOR_CALLER = "connect_for_caller";
-    static final String KEY_ACCESS_POINT_STATE = "access_point_state";
-    private static final String KEY_WIFI_CONFIGURATION = "wifi_configuration";
 
+    private static final String KEY_WIFI_CONFIGURATION = "wifi_configuration";
     private static final int RESULT_CONNECTED = RESULT_FIRST_USER;
     private static final int RESULT_FORGET = RESULT_FIRST_USER + 1;
 
diff --git a/src/com/android/settings/wifi/slice/ContextualWifiSlice.java b/src/com/android/settings/wifi/slice/ContextualWifiSlice.java
new file mode 100644
index 0000000..fa8c267
--- /dev/null
+++ b/src/com/android/settings/wifi/slice/ContextualWifiSlice.java
@@ -0,0 +1,61 @@
+/*
+ * 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.wifi.slice;
+
+import android.content.Context;
+import android.net.Uri;
+import android.net.wifi.WifiSsid;
+import android.text.TextUtils;
+import android.util.Log;
+
+import androidx.annotation.VisibleForTesting;
+import androidx.slice.Slice;
+
+import com.android.settings.slices.CustomSliceRegistry;
+import com.android.settings.slices.CustomSliceable;
+
+/**
+ * {@link CustomSliceable} for Wi-Fi, used by contextual homepage.
+ */
+public class ContextualWifiSlice extends WifiSlice {
+
+    private static final String TAG = "ContextualWifiSlice";
+    @VisibleForTesting
+    boolean mPreviouslyDisplayed;
+
+    public ContextualWifiSlice(Context context) {
+        super(context);
+    }
+
+    @Override
+    public Uri getUri() {
+        return CustomSliceRegistry.CONTEXTUAL_WIFI_SLICE_URI;
+    }
+
+    @Override
+    public Slice getSlice() {
+        if (!mPreviouslyDisplayed && !TextUtils.equals(getActiveSSID(), WifiSsid.NONE)) {
+            Log.d(TAG, "Wifi is connected, no point showing any suggestion.");
+            return null;
+        }
+        // Set mPreviouslyDisplayed to true - we will show *something* on the screen. So we should
+        // keep showing this card to keep UI stable, even if wifi connects to a network later.
+        mPreviouslyDisplayed = true;
+
+        return super.getSlice();
+    }
+}
diff --git a/src/com/android/settings/wifi/WifiSlice.java b/src/com/android/settings/wifi/slice/WifiSlice.java
similarity index 95%
rename from src/com/android/settings/wifi/WifiSlice.java
rename to src/com/android/settings/wifi/slice/WifiSlice.java
index 9f05783..4d3a95a 100644
--- a/src/com/android/settings/wifi/WifiSlice.java
+++ b/src/com/android/settings/wifi/slice/WifiSlice.java
@@ -14,7 +14,7 @@
  * limitations under the License.
  */
 
-package com.android.settings.wifi;
+package com.android.settings.wifi.slice;
 
 import static android.app.slice.Slice.EXTRA_TOGGLE_STATE;
 import static android.provider.SettingsSlicesContract.KEY_WIFI;
@@ -46,6 +46,8 @@
 import com.android.settings.slices.CustomSliceable;
 import com.android.settings.slices.SliceBackgroundWorker;
 import com.android.settings.slices.SliceBuilderUtils;
+import com.android.settings.wifi.WifiDialogActivity;
+import com.android.settings.wifi.WifiSettings;
 import com.android.settings.wifi.details.WifiNetworkDetailsFragment;
 import com.android.settingslib.wifi.AccessPoint;
 import com.android.settingslib.wifi.WifiTracker;
@@ -54,15 +56,15 @@
 import java.util.List;
 
 /**
- * Utility class to build a Wifi Slice, and handle all associated actions.
+ * {@link CustomSliceable} for Wi-Fi, used by generic clients.
  */
 public class WifiSlice implements CustomSliceable {
 
     @VisibleForTesting
     static final int DEFAULT_EXPANDED_ROW_COUNT = 3;
 
+    protected final WifiManager mWifiManager;
     private final Context mContext;
-    private final WifiManager mWifiManager;
 
     public WifiSlice(Context context) {
         mContext = context;
@@ -77,6 +79,7 @@
     @Override
     public Slice getSlice() {
         final boolean isWifiEnabled = isWifiEnabled();
+
         final IconCompat icon = IconCompat.createWithResource(mContext,
                 R.drawable.ic_settings_wireless);
         final String title = mContext.getString(R.string.wifi_settings);
@@ -208,6 +211,13 @@
         return intent;
     }
 
+    protected String getActiveSSID() {
+        if (mWifiManager.getWifiState() != WifiManager.WIFI_STATE_ENABLED) {
+            return WifiSsid.NONE;
+        }
+        return WifiInfo.removeDoubleQuotes(mWifiManager.getConnectionInfo().getSSID());
+    }
+
     private boolean isWifiEnabled() {
         switch (mWifiManager.getWifiState()) {
             case WifiManager.WIFI_STATE_ENABLED:
@@ -221,8 +231,7 @@
     private CharSequence getSummary() {
         switch (mWifiManager.getWifiState()) {
             case WifiManager.WIFI_STATE_ENABLED:
-                final String ssid = WifiInfo.removeDoubleQuotes(mWifiManager.getConnectionInfo()
-                        .getSSID());
+                final String ssid = getActiveSSID();
                 if (TextUtils.equals(ssid, WifiSsid.NONE)) {
                     return mContext.getText(R.string.disconnected);
                 }
diff --git a/tests/robotests/src/com/android/settings/connecteddevice/usb/ConnectedUsbDeviceUpdaterTest.java b/tests/robotests/src/com/android/settings/connecteddevice/usb/ConnectedUsbDeviceUpdaterTest.java
index b698b3a..7c6a305 100644
--- a/tests/robotests/src/com/android/settings/connecteddevice/usb/ConnectedUsbDeviceUpdaterTest.java
+++ b/tests/robotests/src/com/android/settings/connecteddevice/usb/ConnectedUsbDeviceUpdaterTest.java
@@ -15,6 +15,11 @@
  */
 package com.android.settings.connecteddevice.usb;
 
+import static android.hardware.usb.UsbPortStatus.DATA_ROLE_DEVICE;
+import static android.hardware.usb.UsbPortStatus.DATA_ROLE_NONE;
+import static android.hardware.usb.UsbPortStatus.POWER_ROLE_NONE;
+import static android.hardware.usb.UsbPortStatus.POWER_ROLE_SINK;
+
 import static com.google.common.truth.Truth.assertThat;
 
 import static org.mockito.Mockito.verify;
@@ -22,7 +27,6 @@
 
 import android.content.Context;
 import android.hardware.usb.UsbManager;
-import android.hardware.usb.UsbPort;
 
 import com.android.settings.R;
 import com.android.settings.connecteddevice.DevicePreferenceCallback;
@@ -78,7 +82,7 @@
     public void initUsbPreference_usbConnected_preferenceAdded() {
         mDeviceUpdater.initUsbPreference(mContext);
         mDeviceUpdater.mUsbConnectionListener.onUsbConnectionChanged(true /* connected */,
-                UsbManager.FUNCTION_NONE, UsbPort.POWER_ROLE_SINK, UsbPort.DATA_ROLE_DEVICE);
+                UsbManager.FUNCTION_NONE, POWER_ROLE_SINK, DATA_ROLE_DEVICE);
 
         verify(mDevicePreferenceCallback).onDeviceAdded(mDeviceUpdater.mUsbPreference);
     }
@@ -87,7 +91,7 @@
     public void initUsbPreference_usbDisconnected_preferenceRemoved() {
         mDeviceUpdater.initUsbPreference(mContext);
         mDeviceUpdater.mUsbConnectionListener.onUsbConnectionChanged(false /* connected */,
-                UsbManager.FUNCTION_NONE, UsbPort.POWER_ROLE_NONE, UsbPort.DATA_ROLE_NONE);
+                UsbManager.FUNCTION_NONE, POWER_ROLE_NONE, DATA_ROLE_NONE);
 
         verify(mDevicePreferenceCallback).onDeviceRemoved(mDeviceUpdater.mUsbPreference);
     }
diff --git a/tests/robotests/src/com/android/settings/connecteddevice/usb/UsbBackendTest.java b/tests/robotests/src/com/android/settings/connecteddevice/usb/UsbBackendTest.java
index 333d2b6..4e5897d 100644
--- a/tests/robotests/src/com/android/settings/connecteddevice/usb/UsbBackendTest.java
+++ b/tests/robotests/src/com/android/settings/connecteddevice/usb/UsbBackendTest.java
@@ -16,6 +16,11 @@
 
 package com.android.settings.connecteddevice.usb;
 
+import static android.hardware.usb.UsbPortStatus.DATA_ROLE_DEVICE;
+import static android.hardware.usb.UsbPortStatus.DATA_ROLE_HOST;
+import static android.hardware.usb.UsbPortStatus.POWER_ROLE_SINK;
+import static android.hardware.usb.UsbPortStatus.POWER_ROLE_SOURCE;
+
 import static com.google.common.truth.Truth.assertThat;
 
 import static org.mockito.Answers.RETURNS_DEEP_STUBS;
@@ -40,6 +45,8 @@
 import org.mockito.MockitoAnnotations;
 import org.robolectric.RobolectricTestRunner;
 
+import java.util.Collections;
+
 @RunWith(RobolectricTestRunner.class)
 public class UsbBackendTest {
 
@@ -64,9 +71,9 @@
         when((Object) mContext.getSystemService(UsbManager.class)).thenReturn(mUsbManager);
         when(mContext.getSystemService(Context.CONNECTIVITY_SERVICE))
                 .thenReturn(mConnectivityManager);
-        when(mUsbManager.getPorts()).thenReturn(new UsbPort[] {mUsbPort});
+        when(mUsbManager.getPorts()).thenReturn(Collections.singletonList(mUsbPort));
         when(mUsbPortStatus.isConnected()).thenReturn(true);
-        when(mUsbManager.getPortStatus(mUsbPort)).thenReturn(mUsbPortStatus);
+        when(mUsbPort.getStatus()).thenReturn(mUsbPortStatus);
     }
 
     @Test
@@ -74,22 +81,22 @@
         final UsbBackend usbBackend = new UsbBackend(mContext, mUserManager);
 
         when(mUsbPortStatus
-                .isRoleCombinationSupported(UsbPort.POWER_ROLE_SINK, UsbPort.DATA_ROLE_DEVICE))
+                .isRoleCombinationSupported(POWER_ROLE_SINK, DATA_ROLE_DEVICE))
                 .thenReturn(true);
         when(mUsbPortStatus
-                .isRoleCombinationSupported(UsbPort.POWER_ROLE_SINK, UsbPort.DATA_ROLE_HOST))
+                .isRoleCombinationSupported(POWER_ROLE_SINK, DATA_ROLE_HOST))
                 .thenReturn(true);
         when(mUsbPortStatus
-                .isRoleCombinationSupported(UsbPort.POWER_ROLE_SOURCE, UsbPort.DATA_ROLE_DEVICE))
+                .isRoleCombinationSupported(POWER_ROLE_SOURCE, DATA_ROLE_DEVICE))
                 .thenReturn(true);
         when(mUsbPortStatus
-                .isRoleCombinationSupported(UsbPort.POWER_ROLE_SOURCE, UsbPort.DATA_ROLE_HOST))
+                .isRoleCombinationSupported(POWER_ROLE_SOURCE, DATA_ROLE_HOST))
                 .thenReturn(true);
-        when(mUsbPortStatus.getCurrentPowerRole()).thenReturn(UsbPort.POWER_ROLE_SINK);
+        when(mUsbPortStatus.getCurrentPowerRole()).thenReturn(POWER_ROLE_SINK);
 
-        usbBackend.setDataRole(UsbPort.DATA_ROLE_HOST);
+        usbBackend.setDataRole(DATA_ROLE_HOST);
 
-        verify(mUsbManager).setPortRoles(mUsbPort, UsbPort.POWER_ROLE_SINK, UsbPort.DATA_ROLE_HOST);
+        verify(mUsbPort).setRoles(POWER_ROLE_SINK, DATA_ROLE_HOST);
     }
 
     @Test
@@ -97,17 +104,16 @@
         final UsbBackend usbBackend = new UsbBackend(mContext, mUserManager);
 
         when(mUsbPortStatus
-                .isRoleCombinationSupported(UsbPort.POWER_ROLE_SINK, UsbPort.DATA_ROLE_DEVICE))
+                .isRoleCombinationSupported(POWER_ROLE_SINK, DATA_ROLE_DEVICE))
                 .thenReturn(true);
         when(mUsbPortStatus
-                .isRoleCombinationSupported(UsbPort.POWER_ROLE_SOURCE, UsbPort.DATA_ROLE_HOST))
+                .isRoleCombinationSupported(POWER_ROLE_SOURCE, DATA_ROLE_HOST))
                 .thenReturn(true);
-        when(mUsbPortStatus.getCurrentPowerRole()).thenReturn(UsbPort.POWER_ROLE_SINK);
+        when(mUsbPortStatus.getCurrentPowerRole()).thenReturn(POWER_ROLE_SINK);
 
-        usbBackend.setDataRole(UsbPort.DATA_ROLE_HOST);
+        usbBackend.setDataRole(DATA_ROLE_HOST);
 
-        verify(mUsbManager)
-                .setPortRoles(mUsbPort, UsbPort.POWER_ROLE_SOURCE, UsbPort.DATA_ROLE_HOST);
+        verify(mUsbPort).setRoles(POWER_ROLE_SOURCE, DATA_ROLE_HOST);
     }
 
     @Test
@@ -115,23 +121,22 @@
         final UsbBackend usbBackend = new UsbBackend(mContext, mUserManager);
 
         when(mUsbPortStatus
-                .isRoleCombinationSupported(UsbPort.POWER_ROLE_SINK, UsbPort.DATA_ROLE_DEVICE))
+                .isRoleCombinationSupported(POWER_ROLE_SINK, DATA_ROLE_DEVICE))
                 .thenReturn(true);
         when(mUsbPortStatus
-                .isRoleCombinationSupported(UsbPort.POWER_ROLE_SINK, UsbPort.DATA_ROLE_HOST))
+                .isRoleCombinationSupported(POWER_ROLE_SINK, DATA_ROLE_HOST))
                 .thenReturn(true);
         when(mUsbPortStatus
-                .isRoleCombinationSupported(UsbPort.POWER_ROLE_SOURCE, UsbPort.DATA_ROLE_DEVICE))
+                .isRoleCombinationSupported(POWER_ROLE_SOURCE, DATA_ROLE_DEVICE))
                 .thenReturn(true);
         when(mUsbPortStatus
-                .isRoleCombinationSupported(UsbPort.POWER_ROLE_SOURCE, UsbPort.DATA_ROLE_HOST))
+                .isRoleCombinationSupported(POWER_ROLE_SOURCE, DATA_ROLE_HOST))
                 .thenReturn(true);
-        when(mUsbPortStatus.getCurrentDataRole()).thenReturn(UsbPort.DATA_ROLE_DEVICE);
+        when(mUsbPortStatus.getCurrentDataRole()).thenReturn(DATA_ROLE_DEVICE);
 
-        usbBackend.setPowerRole(UsbPort.POWER_ROLE_SOURCE);
+        usbBackend.setPowerRole(POWER_ROLE_SOURCE);
 
-        verify(mUsbManager)
-                .setPortRoles(mUsbPort, UsbPort.POWER_ROLE_SOURCE, UsbPort.DATA_ROLE_DEVICE);
+        verify(mUsbPort).setRoles(POWER_ROLE_SOURCE, DATA_ROLE_DEVICE);
     }
 
     @Test
@@ -139,17 +144,16 @@
         final UsbBackend usbBackend = new UsbBackend(mContext, mUserManager);
 
         when(mUsbPortStatus
-                .isRoleCombinationSupported(UsbPort.POWER_ROLE_SINK, UsbPort.DATA_ROLE_DEVICE))
+                .isRoleCombinationSupported(POWER_ROLE_SINK, DATA_ROLE_DEVICE))
                 .thenReturn(true);
         when(mUsbPortStatus
-                .isRoleCombinationSupported(UsbPort.POWER_ROLE_SOURCE, UsbPort.DATA_ROLE_HOST))
+                .isRoleCombinationSupported(POWER_ROLE_SOURCE, DATA_ROLE_HOST))
                 .thenReturn(true);
-        when(mUsbPortStatus.getCurrentDataRole()).thenReturn(UsbPort.DATA_ROLE_DEVICE);
+        when(mUsbPortStatus.getCurrentDataRole()).thenReturn(DATA_ROLE_DEVICE);
 
-        usbBackend.setPowerRole(UsbPort.POWER_ROLE_SOURCE);
+        usbBackend.setPowerRole(POWER_ROLE_SOURCE);
 
-        verify(mUsbManager)
-                .setPortRoles(mUsbPort, UsbPort.POWER_ROLE_SOURCE, UsbPort.DATA_ROLE_HOST);
+        verify(mUsbPort).setRoles(POWER_ROLE_SOURCE, DATA_ROLE_HOST);
     }
 
     @Test
diff --git a/tests/robotests/src/com/android/settings/connecteddevice/usb/UsbConnectionBroadcastReceiverTest.java b/tests/robotests/src/com/android/settings/connecteddevice/usb/UsbConnectionBroadcastReceiverTest.java
index 1689ee7..1da97f5 100644
--- a/tests/robotests/src/com/android/settings/connecteddevice/usb/UsbConnectionBroadcastReceiverTest.java
+++ b/tests/robotests/src/com/android/settings/connecteddevice/usb/UsbConnectionBroadcastReceiverTest.java
@@ -15,6 +15,11 @@
  */
 package com.android.settings.connecteddevice.usb;
 
+import static android.hardware.usb.UsbPortStatus.DATA_ROLE_DEVICE;
+import static android.hardware.usb.UsbPortStatus.DATA_ROLE_NONE;
+import static android.hardware.usb.UsbPortStatus.POWER_ROLE_NONE;
+import static android.hardware.usb.UsbPortStatus.POWER_ROLE_SINK;
+
 import static com.google.common.truth.Truth.assertThat;
 
 import static org.mockito.Mockito.verify;
@@ -22,7 +27,6 @@
 import android.content.Context;
 import android.content.Intent;
 import android.hardware.usb.UsbManager;
-import android.hardware.usb.UsbPort;
 import android.hardware.usb.UsbPortStatus;
 
 import org.junit.Before;
@@ -63,7 +67,7 @@
         mReceiver.onReceive(mContext, intent);
 
         verify(mListener).onUsbConnectionChanged(true /* connected */, UsbManager.FUNCTION_NONE,
-                UsbPort.POWER_ROLE_NONE, UsbPort.DATA_ROLE_NONE);
+                POWER_ROLE_NONE, DATA_ROLE_NONE);
     }
 
     @Test
@@ -75,7 +79,7 @@
         mReceiver.onReceive(mContext, intent);
 
         verify(mListener).onUsbConnectionChanged(false /* connected */, UsbManager.FUNCTION_NONE,
-                UsbPort.POWER_ROLE_NONE, UsbPort.DATA_ROLE_NONE);
+                POWER_ROLE_NONE, DATA_ROLE_NONE);
     }
 
     @Test
@@ -89,21 +93,21 @@
         mReceiver.onReceive(mContext, intent);
 
         verify(mListener).onUsbConnectionChanged(true /* connected */, UsbManager.FUNCTION_MTP,
-                UsbPort.POWER_ROLE_NONE, UsbPort.DATA_ROLE_NONE);
+                POWER_ROLE_NONE, DATA_ROLE_NONE);
     }
 
     @Test
     public void onReceive_usbPortStatus_invokeCallback() {
         final Intent intent = new Intent();
         intent.setAction(UsbManager.ACTION_USB_PORT_CHANGED);
-        final UsbPortStatus status = new UsbPortStatus(0, UsbPort.POWER_ROLE_SINK,
-                UsbPort.DATA_ROLE_DEVICE, 0);
+        final UsbPortStatus status = new UsbPortStatus(0, POWER_ROLE_SINK,
+                DATA_ROLE_DEVICE, 0);
         intent.putExtra(UsbManager.EXTRA_PORT_STATUS, status);
 
         mReceiver.onReceive(mContext, intent);
 
         verify(mListener).onUsbConnectionChanged(false /* connected */, UsbManager.FUNCTION_NONE,
-                UsbPort.POWER_ROLE_SINK, UsbPort.DATA_ROLE_DEVICE);
+                POWER_ROLE_SINK, DATA_ROLE_DEVICE);
     }
 
     @Test
diff --git a/tests/robotests/src/com/android/settings/connecteddevice/usb/UsbDetailsDataRoleControllerTest.java b/tests/robotests/src/com/android/settings/connecteddevice/usb/UsbDetailsDataRoleControllerTest.java
index 3eda3d1..91e680b 100644
--- a/tests/robotests/src/com/android/settings/connecteddevice/usb/UsbDetailsDataRoleControllerTest.java
+++ b/tests/robotests/src/com/android/settings/connecteddevice/usb/UsbDetailsDataRoleControllerTest.java
@@ -16,6 +16,12 @@
 
 package com.android.settings.connecteddevice.usb;
 
+import static android.hardware.usb.UsbPortStatus.DATA_ROLE_DEVICE;
+import static android.hardware.usb.UsbPortStatus.DATA_ROLE_HOST;
+import static android.hardware.usb.UsbPortStatus.DATA_ROLE_NONE;
+import static android.hardware.usb.UsbPortStatus.POWER_ROLE_NONE;
+import static android.hardware.usb.UsbPortStatus.POWER_ROLE_SINK;
+
 import static com.google.common.truth.Truth.assertThat;
 
 import static org.mockito.ArgumentMatchers.anyLong;
@@ -24,7 +30,6 @@
 
 import android.content.Context;
 import android.hardware.usb.UsbManager;
-import android.hardware.usb.UsbPort;
 import android.os.Handler;
 
 import androidx.fragment.app.FragmentActivity;
@@ -92,11 +97,11 @@
     public void displayRefresh_deviceRole_shouldCheckDevice() {
         mDetailsDataRoleController.displayPreference(mScreen);
 
-        mDetailsDataRoleController.refresh(true, UsbManager.FUNCTION_NONE, UsbPort.POWER_ROLE_SINK,
-                UsbPort.DATA_ROLE_DEVICE);
+        mDetailsDataRoleController.refresh(true, UsbManager.FUNCTION_NONE, POWER_ROLE_SINK,
+                DATA_ROLE_DEVICE);
 
-        final RadioButtonPreference devicePref = getRadioPreference(UsbPort.DATA_ROLE_DEVICE);
-        final RadioButtonPreference hostPref = getRadioPreference(UsbPort.DATA_ROLE_HOST);
+        final RadioButtonPreference devicePref = getRadioPreference(DATA_ROLE_DEVICE);
+        final RadioButtonPreference hostPref = getRadioPreference(DATA_ROLE_HOST);
         assertThat(devicePref.isChecked()).isTrue();
         assertThat(hostPref.isChecked()).isFalse();
     }
@@ -105,11 +110,11 @@
     public void displayRefresh_hostRole_shouldCheckHost() {
         mDetailsDataRoleController.displayPreference(mScreen);
 
-        mDetailsDataRoleController.refresh(true, UsbManager.FUNCTION_NONE, UsbPort.POWER_ROLE_SINK,
-                UsbPort.DATA_ROLE_HOST);
+        mDetailsDataRoleController.refresh(true, UsbManager.FUNCTION_NONE, POWER_ROLE_SINK,
+                DATA_ROLE_HOST);
 
-        final RadioButtonPreference devicePref = getRadioPreference(UsbPort.DATA_ROLE_DEVICE);
-        final RadioButtonPreference hostPref = getRadioPreference(UsbPort.DATA_ROLE_HOST);
+        final RadioButtonPreference devicePref = getRadioPreference(DATA_ROLE_DEVICE);
+        final RadioButtonPreference hostPref = getRadioPreference(DATA_ROLE_HOST);
         assertThat(devicePref.isChecked()).isFalse();
         assertThat(hostPref.isChecked()).isTrue();
     }
@@ -118,8 +123,8 @@
     public void displayRefresh_disconnected_shouldDisable() {
         mDetailsDataRoleController.displayPreference(mScreen);
 
-        mDetailsDataRoleController.refresh(false, UsbManager.FUNCTION_NONE, UsbPort.POWER_ROLE_SINK,
-                UsbPort.DATA_ROLE_DEVICE);
+        mDetailsDataRoleController.refresh(false, UsbManager.FUNCTION_NONE, POWER_ROLE_SINK,
+                DATA_ROLE_DEVICE);
 
         assertThat(mPreference.isEnabled()).isFalse();
     }
@@ -127,12 +132,12 @@
     @Test
     public void onClickDevice_hostEnabled_shouldSetDevice() {
         mDetailsDataRoleController.displayPreference(mScreen);
-        when(mUsbBackend.getDataRole()).thenReturn(UsbPort.DATA_ROLE_HOST);
+        when(mUsbBackend.getDataRole()).thenReturn(DATA_ROLE_HOST);
 
-        final RadioButtonPreference devicePref = getRadioPreference(UsbPort.DATA_ROLE_DEVICE);
+        final RadioButtonPreference devicePref = getRadioPreference(DATA_ROLE_DEVICE);
         devicePref.performClick();
 
-        verify(mUsbBackend).setDataRole(UsbPort.DATA_ROLE_DEVICE);
+        verify(mUsbBackend).setDataRole(DATA_ROLE_DEVICE);
         assertThat(devicePref.getSummary())
                 .isEqualTo(mContext.getString(R.string.usb_switching));
     }
@@ -140,50 +145,50 @@
     @Test
     public void onClickDeviceTwice_hostEnabled_shouldSetDeviceOnce() {
         mDetailsDataRoleController.displayPreference(mScreen);
-        when(mUsbBackend.getDataRole()).thenReturn(UsbPort.DATA_ROLE_HOST);
+        when(mUsbBackend.getDataRole()).thenReturn(DATA_ROLE_HOST);
 
-        final RadioButtonPreference devicePref = getRadioPreference(UsbPort.DATA_ROLE_DEVICE);
+        final RadioButtonPreference devicePref = getRadioPreference(DATA_ROLE_DEVICE);
         devicePref.performClick();
 
         assertThat(devicePref.getSummary())
                 .isEqualTo(mContext.getString(R.string.usb_switching));
         devicePref.performClick();
-        verify(mUsbBackend).setDataRole(UsbPort.DATA_ROLE_DEVICE);
+        verify(mUsbBackend).setDataRole(DATA_ROLE_DEVICE);
     }
 
     @Test
     public void onClickDeviceAndRefresh_success_shouldClearSubtext() {
         mDetailsDataRoleController.displayPreference(mScreen);
-        when(mUsbBackend.getDataRole()).thenReturn(UsbPort.DATA_ROLE_HOST);
+        when(mUsbBackend.getDataRole()).thenReturn(DATA_ROLE_HOST);
 
-        final RadioButtonPreference devicePref = getRadioPreference(UsbPort.DATA_ROLE_DEVICE);
+        final RadioButtonPreference devicePref = getRadioPreference(DATA_ROLE_DEVICE);
         devicePref.performClick();
 
-        verify(mUsbBackend).setDataRole(UsbPort.DATA_ROLE_DEVICE);
+        verify(mUsbBackend).setDataRole(DATA_ROLE_DEVICE);
         assertThat(devicePref.getSummary())
                 .isEqualTo(mContext.getString(R.string.usb_switching));
         mDetailsDataRoleController.refresh(false /* connected */, UsbManager.FUNCTION_NONE,
-                UsbPort.POWER_ROLE_NONE, UsbPort.DATA_ROLE_NONE);
+                POWER_ROLE_NONE, DATA_ROLE_NONE);
         mDetailsDataRoleController.refresh(true /* connected */, UsbManager.FUNCTION_NONE,
-                UsbPort.POWER_ROLE_SINK, UsbPort.DATA_ROLE_DEVICE);
+                POWER_ROLE_SINK, DATA_ROLE_DEVICE);
         assertThat(devicePref.getSummary()).isEqualTo("");
     }
 
     @Test
     public void onClickDeviceAndRefresh_failed_shouldShowFailureText() {
         mDetailsDataRoleController.displayPreference(mScreen);
-        when(mUsbBackend.getDataRole()).thenReturn(UsbPort.DATA_ROLE_HOST);
+        when(mUsbBackend.getDataRole()).thenReturn(DATA_ROLE_HOST);
 
-        final RadioButtonPreference devicePref = getRadioPreference(UsbPort.DATA_ROLE_DEVICE);
+        final RadioButtonPreference devicePref = getRadioPreference(DATA_ROLE_DEVICE);
         devicePref.performClick();
 
-        verify(mUsbBackend).setDataRole(UsbPort.DATA_ROLE_DEVICE);
+        verify(mUsbBackend).setDataRole(DATA_ROLE_DEVICE);
         assertThat(devicePref.getSummary())
                 .isEqualTo(mContext.getString(R.string.usb_switching));
         mDetailsDataRoleController.refresh(false /* connected */, UsbManager.FUNCTION_NONE,
-                UsbPort.POWER_ROLE_NONE, UsbPort.DATA_ROLE_NONE);
+                POWER_ROLE_NONE, DATA_ROLE_NONE);
         mDetailsDataRoleController.refresh(true /* connected */, UsbManager.FUNCTION_NONE,
-                UsbPort.POWER_ROLE_SINK, UsbPort.DATA_ROLE_HOST);
+                POWER_ROLE_SINK, DATA_ROLE_HOST);
         assertThat(devicePref.getSummary())
                 .isEqualTo(mContext.getString(R.string.usb_switching_failed));
     }
@@ -191,18 +196,18 @@
     @Test
     public void onClickDevice_timedOut_shouldShowFailureText() {
         mDetailsDataRoleController.displayPreference(mScreen);
-        when(mUsbBackend.getDataRole()).thenReturn(UsbPort.DATA_ROLE_HOST);
+        when(mUsbBackend.getDataRole()).thenReturn(DATA_ROLE_HOST);
 
-        final RadioButtonPreference devicePref = getRadioPreference(UsbPort.DATA_ROLE_DEVICE);
+        final RadioButtonPreference devicePref = getRadioPreference(DATA_ROLE_DEVICE);
         devicePref.performClick();
 
-        verify(mUsbBackend).setDataRole(UsbPort.DATA_ROLE_DEVICE);
+        verify(mUsbBackend).setDataRole(DATA_ROLE_DEVICE);
         ArgumentCaptor<Runnable> captor = ArgumentCaptor.forClass(Runnable.class);
         verify(mHandler).postDelayed(captor.capture(), anyLong());
         assertThat(devicePref.getSummary())
                 .isEqualTo(mContext.getString(R.string.usb_switching));
         mDetailsDataRoleController.refresh(false /* connected */, UsbManager.FUNCTION_NONE,
-                UsbPort.POWER_ROLE_NONE, UsbPort.DATA_ROLE_NONE);
+                POWER_ROLE_NONE, DATA_ROLE_NONE);
         captor.getValue().run();
 
         assertThat(devicePref.getSummary())
diff --git a/tests/robotests/src/com/android/settings/connecteddevice/usb/UsbDetailsFunctionsControllerTest.java b/tests/robotests/src/com/android/settings/connecteddevice/usb/UsbDetailsFunctionsControllerTest.java
index fc93a58..11fa613 100644
--- a/tests/robotests/src/com/android/settings/connecteddevice/usb/UsbDetailsFunctionsControllerTest.java
+++ b/tests/robotests/src/com/android/settings/connecteddevice/usb/UsbDetailsFunctionsControllerTest.java
@@ -16,6 +16,8 @@
 
 package com.android.settings.connecteddevice.usb;
 
+import static android.hardware.usb.UsbPortStatus.DATA_ROLE_DEVICE;
+import static android.hardware.usb.UsbPortStatus.POWER_ROLE_SINK;
 import static android.net.ConnectivityManager.TETHERING_USB;
 
 import static com.google.common.truth.Truth.assertThat;
@@ -105,8 +107,8 @@
         when(mUsbBackend.areFunctionsSupported(anyLong())).thenReturn(true);
 
         mDetailsFunctionsController.displayPreference(mScreen);
-        mDetailsFunctionsController.refresh(true, UsbManager.FUNCTION_NONE, UsbPort.POWER_ROLE_SINK,
-                UsbPort.DATA_ROLE_DEVICE);
+        mDetailsFunctionsController.refresh(true, UsbManager.FUNCTION_NONE, POWER_ROLE_SINK,
+                DATA_ROLE_DEVICE);
         List<RadioButtonPreference> prefs = getRadioPreferences();
         Iterator<Long> iter = UsbDetailsFunctionsController.FUNCTIONS_MAP.keySet().iterator();
 
@@ -120,7 +122,7 @@
         when(mUsbBackend.areFunctionsSupported(anyLong())).thenReturn(true);
 
         mDetailsFunctionsController.refresh(false, UsbManager.FUNCTION_NONE,
-                UsbPort.POWER_ROLE_SINK, UsbPort.DATA_ROLE_DEVICE);
+                POWER_ROLE_SINK, DATA_ROLE_DEVICE);
         assertThat(mPreferenceCategory.isEnabled()).isFalse();
     }
 
@@ -131,8 +133,8 @@
         when(mUsbBackend.areFunctionsSupported(UsbManager.FUNCTION_PTP)).thenReturn(false);
         when(mUsbBackend.areFunctionsSupported(UsbManager.FUNCTION_RNDIS)).thenReturn(false);
 
-        mDetailsFunctionsController.refresh(true, UsbManager.FUNCTION_NONE, UsbPort.POWER_ROLE_SINK,
-                UsbPort.DATA_ROLE_DEVICE);
+        mDetailsFunctionsController.refresh(true, UsbManager.FUNCTION_NONE, POWER_ROLE_SINK,
+                DATA_ROLE_DEVICE);
         List<RadioButtonPreference> prefs = getRadioPreferences();
         assertThat(prefs.size()).isEqualTo(1);
         assertThat(prefs.get(0).getKey())
@@ -143,8 +145,8 @@
     public void displayRefresh_mtpEnabled_shouldCheckSwitches() {
         when(mUsbBackend.areFunctionsSupported(anyLong())).thenReturn(true);
 
-        mDetailsFunctionsController.refresh(true, UsbManager.FUNCTION_MTP, UsbPort.POWER_ROLE_SINK,
-                UsbPort.DATA_ROLE_DEVICE);
+        mDetailsFunctionsController.refresh(true, UsbManager.FUNCTION_MTP, POWER_ROLE_SINK,
+                DATA_ROLE_DEVICE);
         List<RadioButtonPreference> prefs = getRadioPreferences();
 
         assertThat(prefs.get(0).getKey())
@@ -156,8 +158,8 @@
     public void onClickMtp_noneEnabled_shouldEnableMtp() {
         when(mUsbBackend.areFunctionsSupported(anyLong())).thenReturn(true);
 
-        mDetailsFunctionsController.refresh(true, UsbManager.FUNCTION_NONE, UsbPort.POWER_ROLE_SINK,
-                UsbPort.DATA_ROLE_DEVICE);
+        mDetailsFunctionsController.refresh(true, UsbManager.FUNCTION_NONE, POWER_ROLE_SINK,
+                DATA_ROLE_DEVICE);
         when(mUsbBackend.getCurrentFunctions()).thenReturn(UsbManager.FUNCTION_NONE);
         List<RadioButtonPreference> prefs = getRadioPreferences();
         prefs.get(0).performClick();
@@ -165,8 +167,8 @@
         assertThat(prefs.get(0).getKey())
                 .isEqualTo(UsbBackend.usbFunctionsToString(UsbManager.FUNCTION_MTP));
         verify(mUsbBackend).setCurrentFunctions(UsbManager.FUNCTION_MTP);
-        mDetailsFunctionsController.refresh(true, UsbManager.FUNCTION_MTP, UsbPort.POWER_ROLE_SINK,
-                UsbPort.DATA_ROLE_DEVICE);
+        mDetailsFunctionsController.refresh(true, UsbManager.FUNCTION_MTP, POWER_ROLE_SINK,
+                DATA_ROLE_DEVICE);
         assertThat(prefs.get(0).isChecked()).isTrue();
     }
 
@@ -174,8 +176,8 @@
     public void onClickMtp_ptpEnabled_shouldEnableMtp() {
         when(mUsbBackend.areFunctionsSupported(anyLong())).thenReturn(true);
 
-        mDetailsFunctionsController.refresh(true, UsbManager.FUNCTION_PTP, UsbPort.POWER_ROLE_SINK,
-                UsbPort.DATA_ROLE_DEVICE);
+        mDetailsFunctionsController.refresh(true, UsbManager.FUNCTION_PTP, POWER_ROLE_SINK,
+                DATA_ROLE_DEVICE);
         when(mUsbBackend.getCurrentFunctions()).thenReturn(UsbManager.FUNCTION_PTP);
         List<RadioButtonPreference> prefs = getRadioPreferences();
         prefs.get(0).performClick();
@@ -183,8 +185,8 @@
         assertThat(prefs.get(0).getKey())
                 .isEqualTo(UsbBackend.usbFunctionsToString(UsbManager.FUNCTION_MTP));
         verify(mUsbBackend).setCurrentFunctions(UsbManager.FUNCTION_MTP);
-        mDetailsFunctionsController.refresh(true, UsbManager.FUNCTION_MTP, UsbPort.POWER_ROLE_SINK,
-                UsbPort.DATA_ROLE_DEVICE);
+        mDetailsFunctionsController.refresh(true, UsbManager.FUNCTION_MTP, POWER_ROLE_SINK,
+                DATA_ROLE_DEVICE);
         assertThat(prefs.get(0).isChecked()).isTrue();
         assertThat(prefs.get(3).getKey())
                 .isEqualTo(UsbBackend.usbFunctionsToString(UsbManager.FUNCTION_PTP));
@@ -195,8 +197,8 @@
     public void onClickNone_mtpEnabled_shouldDisableMtp() {
         when(mUsbBackend.areFunctionsSupported(anyLong())).thenReturn(true);
 
-        mDetailsFunctionsController.refresh(true, UsbManager.FUNCTION_MTP, UsbPort.POWER_ROLE_SINK,
-                UsbPort.DATA_ROLE_DEVICE);
+        mDetailsFunctionsController.refresh(true, UsbManager.FUNCTION_MTP, POWER_ROLE_SINK,
+                DATA_ROLE_DEVICE);
         when(mUsbBackend.getCurrentFunctions()).thenReturn(UsbManager.FUNCTION_MTP);
         List<RadioButtonPreference> prefs = getRadioPreferences();
         prefs.get(4).performClick();
@@ -204,8 +206,8 @@
         assertThat(prefs.get(4).getKey())
                 .isEqualTo(UsbBackend.usbFunctionsToString(UsbManager.FUNCTION_NONE));
         verify(mUsbBackend).setCurrentFunctions(UsbManager.FUNCTION_NONE);
-        mDetailsFunctionsController.refresh(true, UsbManager.FUNCTION_NONE, UsbPort.POWER_ROLE_SINK,
-                UsbPort.DATA_ROLE_DEVICE);
+        mDetailsFunctionsController.refresh(true, UsbManager.FUNCTION_NONE, POWER_ROLE_SINK,
+                DATA_ROLE_DEVICE);
         assertThat(prefs.get(0).isChecked()).isFalse();
     }
 
diff --git a/tests/robotests/src/com/android/settings/connecteddevice/usb/UsbDetailsHeaderControllerTest.java b/tests/robotests/src/com/android/settings/connecteddevice/usb/UsbDetailsHeaderControllerTest.java
index d72214f..280b8d4 100644
--- a/tests/robotests/src/com/android/settings/connecteddevice/usb/UsbDetailsHeaderControllerTest.java
+++ b/tests/robotests/src/com/android/settings/connecteddevice/usb/UsbDetailsHeaderControllerTest.java
@@ -16,6 +16,9 @@
 
 package com.android.settings.connecteddevice.usb;
 
+import static android.hardware.usb.UsbPortStatus.DATA_ROLE_DEVICE;
+import static android.hardware.usb.UsbPortStatus.POWER_ROLE_SINK;
+
 import static org.mockito.ArgumentMatchers.argThat;
 import static org.mockito.Mockito.verify;
 import static org.mockito.Mockito.when;
@@ -101,8 +104,8 @@
     @Test
     public void displayRefresh_charging_shouldSetHeader() {
         mDetailsHeaderController.displayPreference(mScreen);
-        mDetailsHeaderController.refresh(true, UsbManager.FUNCTION_NONE, UsbPort.POWER_ROLE_SINK,
-                UsbPort.DATA_ROLE_DEVICE);
+        mDetailsHeaderController.refresh(true, UsbManager.FUNCTION_NONE, POWER_ROLE_SINK,
+                DATA_ROLE_DEVICE);
         verify(mHeaderController).setLabel(mContext.getString(R.string.usb_pref));
         verify(mHeaderController).setIcon(argThat((ArgumentMatcher<Drawable>) t -> {
             DrawableTestHelper.assertDrawableResId(t, R.drawable.ic_usb);
diff --git a/tests/robotests/src/com/android/settings/connecteddevice/usb/UsbDetailsPowerRoleControllerTest.java b/tests/robotests/src/com/android/settings/connecteddevice/usb/UsbDetailsPowerRoleControllerTest.java
index b16a453..aa62741 100644
--- a/tests/robotests/src/com/android/settings/connecteddevice/usb/UsbDetailsPowerRoleControllerTest.java
+++ b/tests/robotests/src/com/android/settings/connecteddevice/usb/UsbDetailsPowerRoleControllerTest.java
@@ -16,6 +16,13 @@
 
 package com.android.settings.connecteddevice.usb;
 
+import static android.hardware.usb.UsbPortStatus.DATA_ROLE_DEVICE;
+import static android.hardware.usb.UsbPortStatus.DATA_ROLE_HOST;
+import static android.hardware.usb.UsbPortStatus.DATA_ROLE_NONE;
+import static android.hardware.usb.UsbPortStatus.POWER_ROLE_NONE;
+import static android.hardware.usb.UsbPortStatus.POWER_ROLE_SINK;
+import static android.hardware.usb.UsbPortStatus.POWER_ROLE_SOURCE;
+
 import static com.google.common.truth.Truth.assertThat;
 
 import static org.mockito.ArgumentMatchers.anyLong;
@@ -25,7 +32,6 @@
 
 import android.content.Context;
 import android.hardware.usb.UsbManager;
-import android.hardware.usb.UsbPort;
 import android.os.Handler;
 
 import androidx.fragment.app.FragmentActivity;
@@ -95,8 +101,8 @@
         mDetailsPowerRoleController.displayPreference(mScreen);
         when(mUsbBackend.areAllRolesSupported()).thenReturn(true);
 
-        mDetailsPowerRoleController.refresh(true, UsbManager.FUNCTION_NONE, UsbPort.POWER_ROLE_SINK,
-                UsbPort.DATA_ROLE_DEVICE);
+        mDetailsPowerRoleController.refresh(true, UsbManager.FUNCTION_NONE, POWER_ROLE_SINK,
+                DATA_ROLE_DEVICE);
 
         SwitchPreference pref = getPreference();
         assertThat(pref.isChecked()).isFalse();
@@ -108,7 +114,7 @@
         when(mUsbBackend.areAllRolesSupported()).thenReturn(true);
 
         mDetailsPowerRoleController.refresh(true, UsbManager.FUNCTION_NONE,
-                UsbPort.POWER_ROLE_SOURCE, UsbPort.DATA_ROLE_HOST);
+                POWER_ROLE_SOURCE, DATA_ROLE_HOST);
 
         SwitchPreference pref = getPreference();
         assertThat(pref.isChecked()).isTrue();
@@ -120,7 +126,7 @@
         when(mUsbBackend.areAllRolesSupported()).thenReturn(true);
 
         mDetailsPowerRoleController.refresh(false, UsbManager.FUNCTION_NONE,
-                UsbPort.POWER_ROLE_SINK, UsbPort.DATA_ROLE_DEVICE);
+                POWER_ROLE_SINK, DATA_ROLE_DEVICE);
 
         assertThat(mPreference.isEnabled()).isFalse();
         assertThat((Preference) mScreen.findPreference(
@@ -132,8 +138,8 @@
         mDetailsPowerRoleController.displayPreference(mScreen);
         when(mUsbBackend.areAllRolesSupported()).thenReturn(false);
 
-        mDetailsPowerRoleController.refresh(true, UsbManager.FUNCTION_NONE, UsbPort.POWER_ROLE_SINK,
-                UsbPort.DATA_ROLE_DEVICE);
+        mDetailsPowerRoleController.refresh(true, UsbManager.FUNCTION_NONE, POWER_ROLE_SINK,
+                DATA_ROLE_DEVICE);
 
         assertThat((Preference) mScreen.findPreference(
                 mDetailsPowerRoleController.getPreferenceKey())).isNull();
@@ -142,12 +148,12 @@
     @Test
     public void onClick_sink_shouldSetSource() {
         mDetailsPowerRoleController.displayPreference(mScreen);
-        when(mUsbBackend.getPowerRole()).thenReturn(UsbPort.POWER_ROLE_SINK);
+        when(mUsbBackend.getPowerRole()).thenReturn(POWER_ROLE_SINK);
 
         SwitchPreference pref = getPreference();
         pref.performClick();
 
-        verify(mUsbBackend).setPowerRole(UsbPort.POWER_ROLE_SOURCE);
+        verify(mUsbBackend).setPowerRole(POWER_ROLE_SOURCE);
         assertThat(pref.getSummary())
                 .isEqualTo(mContext.getString(R.string.usb_switching));
     }
@@ -155,7 +161,7 @@
     @Test
     public void onClickTwice_sink_shouldSetSourceOnce() {
         mDetailsPowerRoleController.displayPreference(mScreen);
-        when(mUsbBackend.getPowerRole()).thenReturn(UsbPort.POWER_ROLE_SINK);
+        when(mUsbBackend.getPowerRole()).thenReturn(POWER_ROLE_SINK);
 
         SwitchPreference pref = getPreference();
         pref.performClick();
@@ -163,42 +169,42 @@
         assertThat(pref.getSummary())
                 .isEqualTo(mContext.getString(R.string.usb_switching));
         pref.performClick();
-        verify(mUsbBackend, times(1)).setPowerRole(UsbPort.POWER_ROLE_SOURCE);
+        verify(mUsbBackend, times(1)).setPowerRole(POWER_ROLE_SOURCE);
     }
 
     @Test
     public void onClickDeviceAndRefresh_success_shouldClearSubtext() {
         mDetailsPowerRoleController.displayPreference(mScreen);
-        when(mUsbBackend.getPowerRole()).thenReturn(UsbPort.POWER_ROLE_SINK);
+        when(mUsbBackend.getPowerRole()).thenReturn(POWER_ROLE_SINK);
 
         SwitchPreference pref = getPreference();
         pref.performClick();
 
-        verify(mUsbBackend).setPowerRole(UsbPort.POWER_ROLE_SOURCE);
+        verify(mUsbBackend).setPowerRole(POWER_ROLE_SOURCE);
         assertThat(pref.getSummary())
                 .isEqualTo(mContext.getString(R.string.usb_switching));
         mDetailsPowerRoleController.refresh(false /* connected */, UsbManager.FUNCTION_NONE,
-                UsbPort.POWER_ROLE_NONE, UsbPort.DATA_ROLE_NONE);
+                POWER_ROLE_NONE, DATA_ROLE_NONE);
         mDetailsPowerRoleController.refresh(true /* connected */, UsbManager.FUNCTION_NONE,
-                UsbPort.POWER_ROLE_SOURCE, UsbPort.DATA_ROLE_DEVICE);
+                POWER_ROLE_SOURCE, DATA_ROLE_DEVICE);
         assertThat(pref.getSummary()).isEqualTo("");
     }
 
     @Test
     public void onClickDeviceAndRefresh_failed_shouldShowFailureText() {
         mDetailsPowerRoleController.displayPreference(mScreen);
-        when(mUsbBackend.getPowerRole()).thenReturn(UsbPort.POWER_ROLE_SINK);
+        when(mUsbBackend.getPowerRole()).thenReturn(POWER_ROLE_SINK);
 
         SwitchPreference pref = getPreference();
         pref.performClick();
 
-        verify(mUsbBackend).setPowerRole(UsbPort.POWER_ROLE_SOURCE);
+        verify(mUsbBackend).setPowerRole(POWER_ROLE_SOURCE);
         assertThat(pref.getSummary())
                 .isEqualTo(mContext.getString(R.string.usb_switching));
         mDetailsPowerRoleController.refresh(false /* connected */, UsbManager.FUNCTION_NONE,
-                UsbPort.POWER_ROLE_NONE, UsbPort.DATA_ROLE_NONE);
+                POWER_ROLE_NONE, DATA_ROLE_NONE);
         mDetailsPowerRoleController.refresh(true /* connected */, UsbManager.FUNCTION_NONE,
-                UsbPort.POWER_ROLE_SINK, UsbPort.DATA_ROLE_DEVICE);
+                POWER_ROLE_SINK, DATA_ROLE_DEVICE);
         assertThat(pref.getSummary())
                 .isEqualTo(mContext.getString(R.string.usb_switching_failed));
     }
@@ -206,18 +212,18 @@
     @Test
     public void onClickDevice_timedOut_shouldShowFailureText() {
         mDetailsPowerRoleController.displayPreference(mScreen);
-        when(mUsbBackend.getPowerRole()).thenReturn(UsbPort.POWER_ROLE_SINK);
+        when(mUsbBackend.getPowerRole()).thenReturn(POWER_ROLE_SINK);
 
         SwitchPreference pref = getPreference();
         pref.performClick();
 
-        verify(mUsbBackend).setPowerRole(UsbPort.POWER_ROLE_SOURCE);
+        verify(mUsbBackend).setPowerRole(POWER_ROLE_SOURCE);
         ArgumentCaptor<Runnable> captor = ArgumentCaptor.forClass(Runnable.class);
         verify(mHandler).postDelayed(captor.capture(), anyLong());
         assertThat(pref.getSummary())
                 .isEqualTo(mContext.getString(R.string.usb_switching));
         mDetailsPowerRoleController.refresh(false /* connected */, UsbManager.FUNCTION_NONE,
-                UsbPort.POWER_ROLE_NONE, UsbPort.DATA_ROLE_NONE);
+                POWER_ROLE_NONE, DATA_ROLE_NONE);
         captor.getValue().run();
         assertThat(pref.getSummary())
                 .isEqualTo(mContext.getString(R.string.usb_switching_failed));
diff --git a/tests/robotests/src/com/android/settings/development/qstile/DevelopmentTilePreferenceControllerTest.java b/tests/robotests/src/com/android/settings/development/qstile/DevelopmentTilePreferenceControllerTest.java
index 8b006fc..dc466df 100644
--- a/tests/robotests/src/com/android/settings/development/qstile/DevelopmentTilePreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/development/qstile/DevelopmentTilePreferenceControllerTest.java
@@ -19,6 +19,7 @@
 import static com.google.common.truth.Truth.assertThat;
 
 import static org.mockito.ArgumentMatchers.any;
+import static org.mockito.Mockito.atLeastOnce;
 import static org.mockito.Mockito.spy;
 import static org.mockito.Mockito.verify;
 import static org.mockito.Mockito.when;
@@ -40,7 +41,6 @@
 import com.android.settings.R;
 
 import org.junit.Before;
-import org.junit.Ignore;
 import org.junit.Test;
 import org.junit.runner.RunWith;
 import org.mockito.ArgumentCaptor;
@@ -52,6 +52,8 @@
 import org.robolectric.shadows.ShadowPackageManager;
 import org.robolectric.util.ReflectionHelpers;
 
+import java.util.Arrays;
+
 @RunWith(RobolectricTestRunner.class)
 public class DevelopmentTilePreferenceControllerTest {
 
@@ -83,7 +85,6 @@
     }
 
     @Test
-    @Ignore("b/119829673")
     public void display_hasTileService_shouldDisplay() {
         final Intent tileProbe = new Intent(TileService.ACTION_QS_TILE)
                 .setPackage(mContext.getPackageName());
@@ -92,11 +93,11 @@
         info.serviceInfo.name = "abc";
         info.serviceInfo.icon = R.drawable.ic_settings_24dp;
         info.serviceInfo.packageName = mContext.getPackageName();
-        mShadowPackageManager.addResolveInfoForIntent(tileProbe, info);
+        mShadowPackageManager.setResolveInfosForIntent(tileProbe, Arrays.asList(info));
 
         mController.displayPreference(mScreen);
 
-        verify(mScreen).addPreference(any(Preference.class));
+        verify(mScreen, atLeastOnce()).addPreference(any(Preference.class));
     }
 
     @Test
diff --git a/tests/robotests/src/com/android/settings/homepage/contextualcards/ContextualCardLoaderTest.java b/tests/robotests/src/com/android/settings/homepage/contextualcards/ContextualCardLoaderTest.java
index 101ca75..c62a6bb 100644
--- a/tests/robotests/src/com/android/settings/homepage/contextualcards/ContextualCardLoaderTest.java
+++ b/tests/robotests/src/com/android/settings/homepage/contextualcards/ContextualCardLoaderTest.java
@@ -145,7 +145,7 @@
         cards.add(new ContextualCard.Builder()
                 .setName("test_wifi")
                 .setCardType(ContextualCard.CardType.SLICE)
-                .setSliceUri(CustomSliceRegistry.WIFI_SLICE_URI)
+                .setSliceUri(CustomSliceRegistry.CONTEXTUAL_WIFI_SLICE_URI)
                 .build());
         cards.add(new ContextualCard.Builder()
                 .setName("test_flashlight")
diff --git a/tests/robotests/src/com/android/settings/homepage/contextualcards/SettingsContextualCardProviderTest.java b/tests/robotests/src/com/android/settings/homepage/contextualcards/SettingsContextualCardProviderTest.java
index 8f36ea5..d4b67f5 100644
--- a/tests/robotests/src/com/android/settings/homepage/contextualcards/SettingsContextualCardProviderTest.java
+++ b/tests/robotests/src/com/android/settings/homepage/contextualcards/SettingsContextualCardProviderTest.java
@@ -70,11 +70,12 @@
     }
 
     @Test
-    public void getContextualCards_wifiSlice_shouldGetCorrectCategory() {
+    public void getContextualCards_wifiSlice_shouldGetImportantCategory() {
         final ContextualCardList cards = mProvider.getContextualCards();
         ContextualCard wifiCard = null;
         for (ContextualCard card : cards.getCardList()) {
-            if (card.getSliceUri().equals(CustomSliceRegistry.WIFI_SLICE_URI.toString())) {
+            if (card.getSliceUri().equals(
+                    CustomSliceRegistry.CONTEXTUAL_WIFI_SLICE_URI.toString())) {
                 wifiCard = card;
             }
         }
diff --git a/tests/robotests/src/com/android/settings/panel/FakePanelContent.java b/tests/robotests/src/com/android/settings/panel/FakePanelContent.java
index 60f0d5d..1d79952 100644
--- a/tests/robotests/src/com/android/settings/panel/FakePanelContent.java
+++ b/tests/robotests/src/com/android/settings/panel/FakePanelContent.java
@@ -29,7 +29,7 @@
  */
 public class FakePanelContent implements PanelContent {
 
-    public static final String FAKE_KEY = "fake_key";
+    public static final String FAKE_ACTION = "fake_action";
 
     public static final CharSequence TITLE = "title";
 
diff --git a/tests/robotests/src/com/android/settings/panel/FakeSettingsPanelActivity.java b/tests/robotests/src/com/android/settings/panel/FakeSettingsPanelActivity.java
index afd0bec..2a62b54 100644
--- a/tests/robotests/src/com/android/settings/panel/FakeSettingsPanelActivity.java
+++ b/tests/robotests/src/com/android/settings/panel/FakeSettingsPanelActivity.java
@@ -27,8 +27,7 @@
 
     @Override
     public Intent getIntent() {
-        final Intent intent = new Intent();
-        intent.putExtra(SettingsPanelActivity.EXTRA_PANEL_TYPE, FakePanelContent.FAKE_KEY);
+        final Intent intent = new Intent(FakePanelContent.FAKE_ACTION);
         return intent;
     }
 }
\ No newline at end of file
diff --git a/tests/robotests/src/com/android/settings/panel/PanelFeatureProviderImplTest.java b/tests/robotests/src/com/android/settings/panel/PanelFeatureProviderImplTest.java
index 754c937..99d5d6c 100644
--- a/tests/robotests/src/com/android/settings/panel/PanelFeatureProviderImplTest.java
+++ b/tests/robotests/src/com/android/settings/panel/PanelFeatureProviderImplTest.java
@@ -20,6 +20,7 @@
 import static com.google.common.truth.Truth.assertThat;
 
 import android.content.Context;
+import android.provider.Settings;
 
 import org.junit.Before;
 import org.junit.Test;
@@ -43,8 +44,16 @@
     @Test
     public void getPanel_internetConnectivityKey_returnsCorrectPanel() {
         final PanelContent panel = mProvider.getPanel(mContext,
-                SettingsPanelActivity.PANEL_TYPE_WIFI);
+                Settings.Panel.ACTION_INTERNET_CONNECTIVITY);
 
         assertThat(panel).isInstanceOf(InternetConnectivityPanel.class);
     }
+
+    @Test
+    public void getPanel_volume_returnsCorrectPanel() {
+        final PanelContent panel = mProvider.getPanel(mContext,
+                Settings.Panel.ACTION_VOLUME);
+
+        assertThat(panel).isInstanceOf(VolumePanel.class);
+    }
 }
diff --git a/tests/robotests/src/com/android/settings/slices/SettingsSliceProviderTest.java b/tests/robotests/src/com/android/settings/slices/SettingsSliceProviderTest.java
index b129267..7eae3e4 100644
--- a/tests/robotests/src/com/android/settings/slices/SettingsSliceProviderTest.java
+++ b/tests/robotests/src/com/android/settings/slices/SettingsSliceProviderTest.java
@@ -55,7 +55,7 @@
 import com.android.settings.testutils.shadow.ShadowThreadUtils;
 import com.android.settings.testutils.shadow.ShadowUserManager;
 import com.android.settings.testutils.shadow.ShadowUtils;
-import com.android.settings.wifi.WifiSlice;
+import com.android.settings.wifi.slice.WifiSlice;
 import com.android.settingslib.wifi.WifiTracker;
 
 import org.junit.After;
diff --git a/tests/robotests/src/com/android/settings/wifi/slice/ContextualWifiSliceTest.java b/tests/robotests/src/com/android/settings/wifi/slice/ContextualWifiSliceTest.java
new file mode 100644
index 0000000..bf5fba8
--- /dev/null
+++ b/tests/robotests/src/com/android/settings/wifi/slice/ContextualWifiSliceTest.java
@@ -0,0 +1,103 @@
+/*
+ * 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.wifi.slice;
+
+import static com.google.common.truth.Truth.assertThat;
+
+import static org.mockito.Mockito.doReturn;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.spy;
+
+import android.content.ContentResolver;
+import android.content.Context;
+import android.net.wifi.WifiConfiguration;
+import android.net.wifi.WifiManager;
+
+import androidx.core.graphics.drawable.IconCompat;
+import androidx.slice.Slice;
+import androidx.slice.SliceItem;
+import androidx.slice.SliceMetadata;
+import androidx.slice.SliceProvider;
+import androidx.slice.core.SliceAction;
+import androidx.slice.widget.SliceLiveData;
+
+import com.android.settings.R;
+import com.android.settings.testutils.SliceTester;
+
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.robolectric.RobolectricTestRunner;
+import org.robolectric.RuntimeEnvironment;
+
+import java.util.List;
+
+@RunWith(RobolectricTestRunner.class)
+public class ContextualWifiSliceTest {
+
+    private Context mContext;
+    private ContentResolver mResolver;
+    private WifiManager mWifiManager;
+    private ContextualWifiSlice mWifiSlice;
+
+    @Before
+    public void setUp() {
+        mContext = spy(RuntimeEnvironment.application);
+        mResolver = mock(ContentResolver.class);
+        doReturn(mResolver).when(mContext).getContentResolver();
+        mWifiManager = mContext.getSystemService(WifiManager.class);
+
+        // Set-up specs for SliceMetadata.
+        SliceProvider.setSpecs(SliceLiveData.SUPPORTED_SPECS);
+        mWifiManager.setWifiEnabled(true);
+
+        mWifiSlice = new ContextualWifiSlice(mContext);
+    }
+
+    @Test
+    public void getWifiSlice_hasActiveConnection_shouldReturnNull() {
+        final WifiConfiguration config = new WifiConfiguration();
+        config.SSID = "123";
+        mWifiManager.connect(config, null /* listener */);
+
+        final Slice wifiSlice = mWifiSlice.getSlice();
+
+        assertThat(wifiSlice).isNull();
+    }
+
+    @Test
+    public void getWifiSlice_previousDisplayed_hasActiveConnection_shouldHaveTitleAndToggle() {
+        mWifiSlice.mPreviouslyDisplayed = true;
+        final WifiConfiguration config = new WifiConfiguration();
+        config.SSID = "123";
+        mWifiManager.connect(config, null /* listener */);
+
+        final Slice wifiSlice = mWifiSlice.getSlice();
+        final SliceMetadata metadata = SliceMetadata.from(mContext, wifiSlice);
+
+        final List<SliceAction> toggles = metadata.getToggles();
+        assertThat(toggles).hasSize(1);
+
+        final SliceAction primaryAction = metadata.getPrimaryAction();
+        final IconCompat expectedToggleIcon = IconCompat.createWithResource(mContext,
+                R.drawable.ic_settings_wireless);
+        assertThat(primaryAction.getIcon().toString()).isEqualTo(expectedToggleIcon.toString());
+
+        final List<SliceItem> sliceItems = wifiSlice.getItems();
+        SliceTester.assertTitle(sliceItems, mContext.getString(R.string.wifi_settings));
+    }
+}
diff --git a/tests/robotests/src/com/android/settings/wifi/WifiSliceTest.java b/tests/robotests/src/com/android/settings/wifi/slice/WifiSliceTest.java
similarity index 96%
rename from tests/robotests/src/com/android/settings/wifi/WifiSliceTest.java
rename to tests/robotests/src/com/android/settings/wifi/slice/WifiSliceTest.java
index 2d4dd04..3c78749 100644
--- a/tests/robotests/src/com/android/settings/wifi/WifiSliceTest.java
+++ b/tests/robotests/src/com/android/settings/wifi/slice/WifiSliceTest.java
@@ -12,16 +12,15 @@
  * 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.wifi;
+package com.android.settings.wifi.slice;
 
 import static android.app.slice.Slice.HINT_LIST_ITEM;
 import static android.app.slice.SliceItem.FORMAT_SLICE;
 
 import static com.android.settings.slices.CustomSliceRegistry.WIFI_SLICE_URI;
-import static com.android.settings.wifi.WifiSlice.DEFAULT_EXPANDED_ROW_COUNT;
+import static com.android.settings.wifi.slice.WifiSlice.DEFAULT_EXPANDED_ROW_COUNT;
 
 import static com.google.common.truth.Truth.assertThat;
 
@@ -29,7 +28,6 @@
 import static org.mockito.Mockito.mock;
 import static org.mockito.Mockito.spy;
 import static org.mockito.Mockito.verify;
-import static org.mockito.Mockito.when;
 
 import android.content.ContentResolver;
 import android.content.Context;