Add common method to native gd to check that pts mode is enabled

Bug: 413596230
Bug: 414408261
Flag: EXEMPT, PTS changes only
Test: atest pts-bot
Change-Id: Ia4013943984549c72d96d51602b048aa78758e6e
diff --git a/system/gd/Android.bp b/system/gd/Android.bp
index 61a6fd3..ea4f36e 100644
--- a/system/gd/Android.bp
+++ b/system/gd/Android.bp
@@ -104,6 +104,7 @@
         "common/audit_log.cc",
         "common/stop_watch.cc",
         "common/strings.cc",
+        "common/utils.cc",
         "hal/link_clocker.cc",
         "hal/snoop_logger.cc",
         "hal/snoop_logger_socket.cc",
diff --git a/system/gd/common/utils.cc b/system/gd/common/utils.cc
new file mode 100644
index 0000000..a205ec6
--- /dev/null
+++ b/system/gd/common/utils.cc
@@ -0,0 +1,30 @@
+/*
+ * Copyright 2025 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.
+ */
+
+#include "gd/common/utils.h"
+
+#include "os/system_properties.h"
+
+namespace bluetooth {
+namespace common {
+static const std::string kPropertyBluetoothPTS = "persist.bluetooth.pts";
+
+bool IsPtsTestMode(void) {
+  return bluetooth::os::GetSystemPropertyBool(kPropertyBluetoothPTS, false);
+}
+
+}  // namespace common
+}  // namespace bluetooth
diff --git a/system/gd/common/utils.h b/system/gd/common/utils.h
new file mode 100644
index 0000000..bb9b722
--- /dev/null
+++ b/system/gd/common/utils.h
@@ -0,0 +1,31 @@
+/*
+ * Copyright 2025 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.
+ */
+
+#pragma once
+
+namespace bluetooth {
+namespace common {
+/**
+ * Check if we are running in PTS test mode. To enable/disable PTS test mode manually, invoke
+ * {@code adb shell setprop persist.bluetooth.pts true/false}. It is set automatically during PTS
+ * BOT Tests.
+ *
+ * @return true if in PTS Test mode, false otherwise
+ */
+bool IsPtsTestMode(void);
+
+}  // namespace common
+}  // namespace bluetooth