diff --git a/res/values/strings.xml b/res/values/strings.xml
index 70ff0c53479..d08f97a8191 100644
--- a/res/values/strings.xml
+++ b/res/values/strings.xml
@@ -431,6 +431,8 @@
Previously connected devices
Previously connected
+
+ Bluetooth turned on
Date & time
diff --git a/src/com/android/settings/bluetooth/BluetoothPairingDetail.java b/src/com/android/settings/bluetooth/BluetoothPairingDetail.java
index b3f60967c49..2f52aef5203 100644
--- a/src/com/android/settings/bluetooth/BluetoothPairingDetail.java
+++ b/src/com/android/settings/bluetooth/BluetoothPairingDetail.java
@@ -22,6 +22,7 @@ import android.bluetooth.BluetoothAdapter;
import android.bluetooth.BluetoothDevice;
import android.content.Context;
import android.os.Bundle;
+import android.widget.Toast;
import androidx.annotation.VisibleForTesting;
import android.util.Log;
@@ -166,6 +167,9 @@ public class BluetoothPairingDetail extends DeviceListPreferenceFragment impleme
public void onBluetoothStateChanged(int bluetoothState) {
super.onBluetoothStateChanged(bluetoothState);
updateContent(bluetoothState);
+ if (bluetoothState == BluetoothAdapter.STATE_ON) {
+ showBluetoothTurnedOnToast();
+ }
}
@Override
@@ -205,4 +209,9 @@ public class BluetoothPairingDetail extends DeviceListPreferenceFragment impleme
return KEY_AVAIL_DEVICES;
}
+ @VisibleForTesting
+ void showBluetoothTurnedOnToast() {
+ Toast.makeText(getContext(), R.string.connected_device_bluetooth_turned_on_toast,
+ Toast.LENGTH_SHORT).show();
+ }
}
diff --git a/tests/robotests/src/com/android/settings/bluetooth/BluetoothPairingDetailTest.java b/tests/robotests/src/com/android/settings/bluetooth/BluetoothPairingDetailTest.java
index 3060734e491..7dcf76c9c88 100644
--- a/tests/robotests/src/com/android/settings/bluetooth/BluetoothPairingDetailTest.java
+++ b/tests/robotests/src/com/android/settings/bluetooth/BluetoothPairingDetailTest.java
@@ -192,4 +192,13 @@ public class BluetoothPairingDetailTest {
// Verify that clean up only happen once at initialization
verify(mAvailableDevicesCategory, times(1)).removeAll();
}
+
+ @Test
+ public void onBluetoothStateChanged_whenTurnedOnBTShowToast() {
+ doNothing().when(mFragment).updateContent(anyInt());
+
+ mFragment.onBluetoothStateChanged(BluetoothAdapter.STATE_ON);
+
+ verify(mFragment).showBluetoothTurnedOnToast();
+ }
}