New Bluetooth default state settings Test

Test: https://android-build.corp.google.com/test_investigate/invocation/I16800010315926500/test/TR58029442397324524/

Bug: 365978110
Change-Id: I53b1908697f87a6d9450dbc4421de446c5187d8b
diff --git a/libraries/app-helpers/interfaces/auto/src/android/platform/helpers/IAutoBluetoothSettingsHelper.java b/libraries/app-helpers/interfaces/auto/src/android/platform/helpers/IAutoBluetoothSettingsHelper.java
index b4004bd..92f5b9b 100644
--- a/libraries/app-helpers/interfaces/auto/src/android/platform/helpers/IAutoBluetoothSettingsHelper.java
+++ b/libraries/app-helpers/interfaces/auto/src/android/platform/helpers/IAutoBluetoothSettingsHelper.java
@@ -47,6 +47,13 @@
     boolean isPhonePreferenceChecked();
 
     /**
+     * Setup Expectations: The bluetooth settings view is open
+     *
+     * @return - Whether the use bluetooth toggle is currently checked
+     */
+    boolean isUseBluetoothToggleChecked();
+
+    /**
      * Setup Expectations: The bluetooth settings view is open, and at least one device is listed
      * under "Paired devices"
      *
diff --git a/libraries/automotive-helpers/auto-default-config/resources/assets/defaultSpectatioConfig.json b/libraries/automotive-helpers/auto-default-config/resources/assets/defaultSpectatioConfig.json
index 6aa761f..f03c8b8 100644
--- a/libraries/automotive-helpers/auto-default-config/resources/assets/defaultSpectatioConfig.json
+++ b/libraries/automotive-helpers/auto-default-config/resources/assets/defaultSpectatioConfig.json
@@ -1006,6 +1006,27 @@
       "VALUE": "summary",
       "PACKAGE": "android"
     },
+    "USE_BLUETOOTH_SETTINGS_TOGGLE": {
+      "TYPE": "MULTIPLE",
+      "SPECIFIERS": [
+        {
+          "TYPE": "CLASS",
+          "VALUE": "android.widget.Switch"
+        },
+        {
+          "TYPE": "HAS_ANCESTOR",
+          "MAX_DEPTH": 3,
+          "ANCESTOR": {
+            "TYPE": "HAS_DESCENDANT",
+            "MAX_DEPTH": 2,
+            "DESCENDANT": {
+              "TYPE": "TEXT",
+              "VALUE": "Use Bluetooth"
+            }
+          }
+        }
+      ]
+    },
     "DISPLAY_SETTINGS_SCROLL_ELEMENT": {
       "TYPE": "RESOURCE_ID",
       "VALUE": "car_ui_internal_recycler_view",
diff --git a/libraries/automotive-helpers/auto-default-config/src/android/platform/helpers/AutomotiveConfigConstants.java b/libraries/automotive-helpers/auto-default-config/src/android/platform/helpers/AutomotiveConfigConstants.java
index b41d3dd..3ebdb53 100644
--- a/libraries/automotive-helpers/auto-default-config/src/android/platform/helpers/AutomotiveConfigConstants.java
+++ b/libraries/automotive-helpers/auto-default-config/src/android/platform/helpers/AutomotiveConfigConstants.java
@@ -231,6 +231,9 @@
     // Display Settings Constants
     public static final String BRIGHTNESS_SEEKBAR = "BRIGHTNESS_SEEKBAR";
 
+    // Bluetooth Settings Constants
+    public static final String USE_BLUETOOTH_SETTINGS_TOGGLE = "USE_BLUETOOTH_SETTINGS_TOGGLE";
+
     // Date and time Settings Constants
     public static final String DATE_TIME_SETTINGS_SCROLL_ACTION =
             "DATE_TIME_SETTINGS_SCROLL_ACTION";
diff --git a/libraries/automotive-helpers/settings-app-helper/src/android/platform/helpers/SettingsBluetoothHelperImpl.java b/libraries/automotive-helpers/settings-app-helper/src/android/platform/helpers/SettingsBluetoothHelperImpl.java
index 2079a60..456521b 100644
--- a/libraries/automotive-helpers/settings-app-helper/src/android/platform/helpers/SettingsBluetoothHelperImpl.java
+++ b/libraries/automotive-helpers/settings-app-helper/src/android/platform/helpers/SettingsBluetoothHelperImpl.java
@@ -49,6 +49,12 @@
 
     /** {@inheritDoc} */
     @Override
+    public boolean isUseBluetoothToggleChecked() {
+        return buttonChecked(AutomotiveConfigConstants.USE_BLUETOOTH_SETTINGS_TOGGLE);
+    }
+
+    /** {@inheritDoc} */
+    @Override
     public boolean isMediaPreferenceChecked() {
         return buttonChecked(AutomotiveConfigConstants.MEDIA_BUTTON);
     }
diff --git a/tests/automotive/functional/settings/src/android/platform/tests/BluetoothSettingTest.java b/tests/automotive/functional/settings/src/android/platform/tests/BluetoothSettingTest.java
new file mode 100644
index 0000000..ed5f891
--- /dev/null
+++ b/tests/automotive/functional/settings/src/android/platform/tests/BluetoothSettingTest.java
@@ -0,0 +1,56 @@
+/*
+ * Copyright (C) 2024 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package android.platform.tests;
+
+import static junit.framework.Assert.assertTrue;
+
+import android.platform.helpers.HelperAccessor;
+import android.platform.helpers.IAutoBluetoothSettingsHelper;
+import android.platform.helpers.IAutoSettingHelper;
+import android.platform.helpers.SettingsConstants;
+
+import androidx.test.runner.AndroidJUnit4;
+
+import org.junit.After;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+
+@RunWith(AndroidJUnit4.class)
+public class BluetoothSettingTest {
+    private HelperAccessor<IAutoBluetoothSettingsHelper> mBluetoothSettingHelper;
+    private HelperAccessor<IAutoSettingHelper> mSettingHelper;
+
+    public BluetoothSettingTest() throws Exception {
+        mBluetoothSettingHelper = new HelperAccessor<>(IAutoBluetoothSettingsHelper.class);
+        mSettingHelper = new HelperAccessor<>(IAutoSettingHelper.class);
+    }
+
+    @After
+    public void goBackToSettingsScreen() {
+        mSettingHelper.get().goBackToSettingsScreen();
+    }
+
+    @Test
+    public void testBluetoothDefaultState() {
+        mSettingHelper.get().openSetting(SettingsConstants.BLUETOOTH_SETTINGS);
+        assertTrue(
+                "Bluetooth default state is not turned on in the System",
+                mSettingHelper.get().isBluetoothOn());
+        assertTrue(
+                "Use Bluetooth toggle is not turned on in the Settings",
+                mBluetoothSettingHelper.get().isUseBluetoothToggleChecked());
+    }
+}