Merge changes I750c5981,Iec1a7ac6,I4c6127cf
* changes:
Add button for discoverable bluetooth
Add buttons to launch enable/disable bluetooth intents
Add buttons to launch enable/disable wifi intents
diff --git a/tests/EmbeddedKitchenSinkApp/res/layout/connectivity_fragment.xml b/tests/EmbeddedKitchenSinkApp/res/layout/connectivity_fragment.xml
index 245ba03..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
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 0306698..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
@@ -18,7 +18,9 @@
import android.annotation.Nullable;
import android.annotation.SuppressLint;
+import android.bluetooth.BluetoothAdapter;
import android.content.Context;
+import android.content.Intent;
import android.graphics.Color;
import android.location.LocationManager;
import android.net.ConnectivityManager;
@@ -496,9 +498,49 @@
mTetheringStatusPolled = (TextView) view.findViewById(R.id.tetheringStatusPolled);
mLocalOnlyStatus = (TextView) view.findViewById(R.id.localOnlyStatus);
+ 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());
+ view.findViewById(R.id.networkDiscoverableBluetoothIntent)
+ .setOnClickListener(v -> discoverableBluetoothIntent());
+
return view;
}
+ private void enableWifiIntent() {
+ Intent enableWifi = new Intent(WifiManager.ACTION_REQUEST_ENABLE);
+ enableWifi.putExtra(Intent.EXTRA_PACKAGE_NAME, getContext().getPackageName());
+ startActivity(enableWifi);
+ }
+
+ private void disableWifiIntent() {
+ Intent disableWifi = new Intent(WifiManager.ACTION_REQUEST_DISABLE);
+ disableWifi.putExtra(Intent.EXTRA_PACKAGE_NAME, getContext().getPackageName());
+ 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);
+ }
+
+ 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();