diff --git a/res/values/strings.xml b/res/values/strings.xml
index 3fb50e5e09b..40152f73cb7 100644
--- a/res/values/strings.xml
+++ b/res/values/strings.xml
@@ -398,6 +398,12 @@
Currently connected
Saved devices
+
+ Add device
+
+ Bluetooth will turn on to enable pairing
+
+ Connection preferences
Date & time
diff --git a/res/xml/connected_devices.xml b/res/xml/connected_devices.xml
index 497a485166f..5417051103c 100644
--- a/res/xml/connected_devices.xml
+++ b/res/xml/connected_devices.xml
@@ -16,6 +16,7 @@
@@ -26,4 +27,17 @@
+
+
+
+
diff --git a/src/com/android/settings/bluetooth/BluetoothPairingDetail.java b/src/com/android/settings/bluetooth/BluetoothPairingDetail.java
index fcfa3e2336e..a9756a6951b 100644
--- a/src/com/android/settings/bluetooth/BluetoothPairingDetail.java
+++ b/src/com/android/settings/bluetooth/BluetoothPairingDetail.java
@@ -73,10 +73,20 @@ public class BluetoothPairingDetail extends DeviceListPreferenceFragment impleme
public void onStart() {
super.onStart();
- updateContent(mLocalAdapter.getBluetoothState());
+ updateBluetooth();
mAvailableDevicesCategory.setProgress(mLocalAdapter.isDiscovering());
}
+ @VisibleForTesting
+ void updateBluetooth() {
+ if (mLocalAdapter.isEnabled()) {
+ updateContent(mLocalAdapter.getBluetoothState());
+ } else {
+ // Turn on bluetooth if it is disabled
+ mLocalAdapter.enable();
+ }
+ }
+
@Override
public void onStop() {
super.onStop();
diff --git a/src/com/android/settings/connecteddevice/ConnectedDeviceDashboardFragment.java b/src/com/android/settings/connecteddevice/ConnectedDeviceDashboardFragment.java
index e4a6a64c3e6..e9ae11ef408 100644
--- a/src/com/android/settings/connecteddevice/ConnectedDeviceDashboardFragment.java
+++ b/src/com/android/settings/connecteddevice/ConnectedDeviceDashboardFragment.java
@@ -64,8 +64,8 @@ public class ConnectedDeviceDashboardFragment extends DashboardFragment {
controllers.add(new ConnectedDeviceGroupController(this, lifecycle));
controllers.add(new SavedDeviceGroupController(this, lifecycle));
- return controllers;
+ return controllers;
}
@VisibleForTesting
diff --git a/tests/robotests/src/com/android/settings/bluetooth/BluetoothPairingDetailTest.java b/tests/robotests/src/com/android/settings/bluetooth/BluetoothPairingDetailTest.java
index 2b30ae404cf..f434186a088 100644
--- a/tests/robotests/src/com/android/settings/bluetooth/BluetoothPairingDetailTest.java
+++ b/tests/robotests/src/com/android/settings/bluetooth/BluetoothPairingDetailTest.java
@@ -31,7 +31,6 @@ import static org.mockito.Mockito.verify;
import android.bluetooth.BluetoothAdapter;
import android.content.Context;
import android.content.res.Resources;
-import android.os.UserManager;
import android.support.v7.preference.PreferenceGroup;
import com.android.settings.R;
@@ -55,8 +54,6 @@ import org.robolectric.annotation.Config;
@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION_O)
public class BluetoothPairingDetailTest {
- @Mock
- private UserManager mUserManager;
@Mock
private Resources mResource;
@Mock
@@ -133,6 +130,25 @@ public class BluetoothPairingDetailTest {
verify(mFragment).finish();
}
+ @Test
+ public void testUpdateBluetooth_bluetoothOff_turnOnBluetooth() {
+ doReturn(false).when(mLocalAdapter).isEnabled();
+
+ mFragment.updateBluetooth();
+
+ verify(mLocalAdapter).enable();
+ }
+
+ @Test
+ public void testUpdateBluetooth_bluetoothOn_updateState() {
+ doReturn(true).when(mLocalAdapter).isEnabled();
+ doNothing().when(mFragment).updateContent(anyInt());
+
+ mFragment.updateBluetooth();
+
+ verify(mFragment).updateContent(anyInt());
+ }
+
@Test
public void testOnScanningStateChanged_restartScanAfterInitialScanning() {
mFragment.mAvailableDevicesCategory = mAvailableDevicesCategory;
@@ -181,6 +197,4 @@ public class BluetoothPairingDetailTest {
verify(mAvailableDevicesCategory, times(1)).removeAll();
}
-
-
}