Add button for discoverable bluetooth
Bug: 133189770
Test: Manual
Change-Id: I750c59812392204e2817937647eac142fa51022b
diff --git a/tests/EmbeddedKitchenSinkApp/res/layout/connectivity_fragment.xml b/tests/EmbeddedKitchenSinkApp/res/layout/connectivity_fragment.xml
index b657367..3d8f94a 100644
--- a/tests/EmbeddedKitchenSinkApp/res/layout/connectivity_fragment.xml
+++ b/tests/EmbeddedKitchenSinkApp/res/layout/connectivity_fragment.xml
@@ -126,6 +126,40 @@
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
</LinearLayout>
+
+ <LinearLayout
+ android:orientation="horizontal"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:layout_margin="4dp">
+ <Button android:id="@+id/networkEnableWifiIntent"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:text="Enable Wifi Intent"/>
+ <Button android:id="@+id/networkDisableWifiIntent"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:text="Disable Wifi Intent"/>
+ </LinearLayout>
+
+ <LinearLayout
+ android:orientation="horizontal"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:layout_margin="4dp">
+ <Button android:id="@+id/networkEnableBluetoothIntent"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:text="Enable Bluetooth Intent"/>
+ <Button android:id="@+id/networkDisableBluetoothIntent"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:text="Disable Bluetooth Intent"/>
+ <Button android:id="@+id/networkDiscoverableBluetoothIntent"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:text="Discoverable Bluetooth Intent"/>
+ </LinearLayout>
</LinearLayout>
<LinearLayout
@@ -188,34 +222,4 @@
</LinearLayout>
- <LinearLayout>
- android:orientation="horizontal"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:layout_margin="4dp">
- <Button android:id="@+id/networkEnableWifiIntent"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:text="Enable Wifi Intent"/>
- <Button android:id="@+id/networkDisableWifiIntent"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:text="Disable Wifi Intent"/>
- </LinearLayout>
-
- <LinearLayout>
- android:orientation="horizontal"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:layout_margin="4dp">
- <Button android:id="@+id/networkEnableBluetoothIntent"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:text="Enable Bluetooth Intent"/>
- <Button android:id="@+id/networkDisableBluetoothIntent"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:text="Disable Bluetooth Intent"/>
- </LinearLayout>
-
</androidx.viewpager.widget.ViewPager>
diff --git a/tests/EmbeddedKitchenSinkApp/src/com/google/android/car/kitchensink/connectivity/ConnectivityFragment.java b/tests/EmbeddedKitchenSinkApp/src/com/google/android/car/kitchensink/connectivity/ConnectivityFragment.java
index 6afa6d3..7ec9f78 100644
--- a/tests/EmbeddedKitchenSinkApp/src/com/google/android/car/kitchensink/connectivity/ConnectivityFragment.java
+++ b/tests/EmbeddedKitchenSinkApp/src/com/google/android/car/kitchensink/connectivity/ConnectivityFragment.java
@@ -505,6 +505,8 @@
.setOnClickListener(v -> enableBluetoothIntent());
view.findViewById(R.id.networkDisableBluetoothIntent)
.setOnClickListener(v -> disableBluetoothIntent());
+ view.findViewById(R.id.networkDiscoverableBluetoothIntent)
+ .setOnClickListener(v -> discoverableBluetoothIntent());
return view;
}
@@ -533,6 +535,12 @@
startActivity(disableBluetooth);
}
+ private void discoverableBluetoothIntent() {
+ Intent discoverableBluetooth = new Intent(BluetoothAdapter.ACTION_REQUEST_DISCOVERABLE);
+ discoverableBluetooth.putExtra(Intent.EXTRA_PACKAGE_NAME, getContext().getPackageName());
+ startActivity(discoverableBluetooth);
+ }
+
@Override
public void onResume() {
super.onResume();