libcutils is Android-specific and does not exist in Linux/Chrome OS.
This patch removes direct dependency on it and instead creates an
abstract layer called os_utils which contain separate implementations
for Android (using libcutils) and other OSes.
Bug:
176847216
Tag: #refactor
Test: atest --host bluetooth_test_common
Change-Id: Ifaebbd2baf5d3f7d638d70b3a9b97a1cb7724d10
#include <base/logging.h>
#include <openssl/rand.h>
-#include <private/android_filesystem_config.h>
#include <unistd.h>
#include <cctype>
#include "btif_keystore.h"
#include "common/address_obfuscator.h"
#include "common/metric_id_allocator.h"
+#include "common/os_utils.h"
#include "main/shim/config.h"
#include "main/shim/shim.h"
#include "osi/include/alarm.h"
static bool config_checksum_pass(int check_bit) {
return ((get_niap_config_compare_result() & check_bit) == check_bit);
}
-static bool btif_is_niap_mode() {
- return getuid() == AID_BLUETOOTH && is_niap_mode();
-}
+static bool btif_is_niap_mode() { return is_bluetooth_uid() && is_niap_mode(); }
static bool btif_in_encrypt_key_name_list(std::string key);
static const int CONFIG_FILE_COMPARE_PASS = 1;
"metric_id_allocator.cc",
"metrics.cc",
"once_timer.cc",
+ "os_utils.cc",
"repeating_timer.cc",
"time_util.cc",
],
--- /dev/null
+/*
+ * Copyright 2021 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.
+ */
+
+#ifdef OS_ANDROID
+#include <private/android_filesystem_config.h>
+#include <unistd.h>
+#endif
+
+bool is_bluetooth_uid() {
+#ifdef OS_ANDROID
+ return getuid() == AID_BLUETOOTH;
+#else
+ return false;
+#endif
+}
--- /dev/null
+/*
+ * Copyright 2021 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.
+ */
+
+bool is_bluetooth_uid();
*
******************************************************************************/
-#include <cutils/log.h>
#include <string.h>
#include "a2dp_codec_api.h"
#include "avdt_api.h"
#include "bt_types.h"
#include "bt_utils.h"
#include "btu.h"
+#include "log/log.h"
#include "osi/include/osi.h"
/* This table is used to lookup the callback event that matches a particular
#define LOG_TAG "bluetooth"
-#include <cutils/log.h>
#include "bt_target.h"
+#include "log/log.h"
#include <string.h>
#include "btm_ble_api.h"