Add buttons to launch enable/disable bluetooth intents
Added buttons in an additional list inside connectivity to house buttons
to launch enable and disable bluetooth intents.
Bug: 133189770
Test: Manual
Change-Id: Iec1a7ac6df171a4280ace1c4cf8ec2558e692f20
diff --git a/tests/EmbeddedKitchenSinkApp/res/layout/connectivity_fragment.xml b/tests/EmbeddedKitchenSinkApp/res/layout/connectivity_fragment.xml
index 9bd49dd..b657367 100644
--- a/tests/EmbeddedKitchenSinkApp/res/layout/connectivity_fragment.xml
+++ b/tests/EmbeddedKitchenSinkApp/res/layout/connectivity_fragment.xml
@@ -203,4 +203,19 @@
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 b865f5b..6afa6d3 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
@@ -18,6 +18,7 @@
import android.annotation.Nullable;
import android.annotation.SuppressLint;
+import android.bluetooth.BluetoothAdapter;
import android.content.Context;
import android.content.Intent;
import android.graphics.Color;
@@ -500,6 +501,10 @@
view.findViewById(R.id.networkEnableWifiIntent).setOnClickListener(v -> enableWifiIntent());
view.findViewById(R.id.networkDisableWifiIntent)
.setOnClickListener(v -> disableWifiIntent());
+ view.findViewById(R.id.networkEnableBluetoothIntent)
+ .setOnClickListener(v -> enableBluetoothIntent());
+ view.findViewById(R.id.networkDisableBluetoothIntent)
+ .setOnClickListener(v -> disableBluetoothIntent());
return view;
}
@@ -516,6 +521,18 @@
startActivity(disableWifi);
}
+ private void enableBluetoothIntent() {
+ Intent enableBluetooth = new Intent(BluetoothAdapter.ACTION_REQUEST_ENABLE);
+ enableBluetooth.putExtra(Intent.EXTRA_PACKAGE_NAME, getContext().getPackageName());
+ startActivity(enableBluetooth);
+ }
+
+ private void disableBluetoothIntent() {
+ Intent disableBluetooth = new Intent(BluetoothAdapter.ACTION_REQUEST_DISABLE);
+ disableBluetooth.putExtra(Intent.EXTRA_PACKAGE_NAME, getContext().getPackageName());
+ startActivity(disableBluetooth);
+ }
+
@Override
public void onResume() {
super.onResume();