diff options
195 files changed, 99 insertions, 4090 deletions
@@ -1,19 +1,6 @@ -# Bug component: 27441 +set noparent -# Project owners -girardier@google.com #{LAST_RESORT_SUGGESTION} -muhammadfalam@google.com #{LAST_RESORT_SUGGESTION} -siyuanh@google.com #{LAST_RESORT_SUGGESTION} -okamil@google.com #{LAST_RESORT_SUGGESTION} -wescande@google.com #{LAST_RESORT_SUGGESTION} - -# Per-file ownership - -# Build files / test_config / presubmit / preupload / linter file -per-file *.cfg,.cfg,TEST_MAPPING,*.bp,*.xml,.clang-tidy,pyrightconfig.json=file:/OWNERS_build - -# ChromeOS team owns Linux build files -# - build.py is used for Linux build -# - *.gn is for GN build rules -# - Cargo.toml is for Rust build rules -per-file build.py,*.gn,Cargo.toml=file:/OWNERS_chromeos +girardier@google.com +muhammadfalam@google.com +siyuanh@google.com +okamil@google.com diff --git a/OWNERS_automotive b/OWNERS_automotive deleted file mode 100644 index 20c7ac685b..0000000000 --- a/OWNERS_automotive +++ /dev/null @@ -1,3 +0,0 @@ -# Project owners -cmanton@google.com -salsavage@google.com diff --git a/OWNERS_build b/OWNERS_build deleted file mode 100644 index 5b3f4bad26..0000000000 --- a/OWNERS_build +++ /dev/null @@ -1 +0,0 @@ -wescande@google.com diff --git a/OWNERS_chromeos b/OWNERS_chromeos deleted file mode 100644 index 075a04e5e3..0000000000 --- a/OWNERS_chromeos +++ /dev/null @@ -1,22 +0,0 @@ -# Project owners -abhishekpandit@google.com - -# Audio -enshuo@google.com -hychao@google.com -jrwu@google.com -whalechang@google.com - -# General review -michaelfsun@google.com -laikatherine@google.com -yinghsu@google.com -apusaka@google.com -deanliao@google.com -chharry@google.com -melhuishj@google.com -johnlai@google.com -mmandlik@google.com -sarveshkalwit@google.com -howardchung@google.com -jiangzp@google.com diff --git a/OWNERS_content b/OWNERS_content deleted file mode 100644 index 883d5dc782..0000000000 --- a/OWNERS_content +++ /dev/null @@ -1,2 +0,0 @@ -klhyun@google.com -hdmoon@google.com diff --git a/OWNERS_cs b/OWNERS_cs deleted file mode 100644 index 1cebb11002..0000000000 --- a/OWNERS_cs +++ /dev/null @@ -1,2 +0,0 @@ -steveliu@google.com -zning@google.com diff --git a/OWNERS_hearingaid b/OWNERS_hearingaid deleted file mode 100644 index d1c75de900..0000000000 --- a/OWNERS_hearingaid +++ /dev/null @@ -1 +0,0 @@ -henrichataing@google.com diff --git a/OWNERS_leaudio b/OWNERS_leaudio deleted file mode 100644 index 0ba606bbf0..0000000000 --- a/OWNERS_leaudio +++ /dev/null @@ -1,4 +0,0 @@ -siyuanh@google.com -jpawlowski@google.com -rongxuan@google.com -yuyangh@google.com diff --git a/android/BluetoothLegacyMigration/OWNERS b/android/BluetoothLegacyMigration/OWNERS deleted file mode 100644 index 66467c7b3e..0000000000 --- a/android/BluetoothLegacyMigration/OWNERS +++ /dev/null @@ -1,5 +0,0 @@ -# Reviewers for /android/BluetoothLegacyMigration - -eruffieux@google.com -siyuanh@google.com -wescande@google.com diff --git a/android/ChannelSoundingTestApp/OWNERS b/android/ChannelSoundingTestApp/OWNERS deleted file mode 100644 index 29d6f601cc..0000000000 --- a/android/ChannelSoundingTestApp/OWNERS +++ /dev/null @@ -1 +0,0 @@ -include /OWNERS_cs diff --git a/android/apishim/OWNERS b/android/apishim/OWNERS deleted file mode 100644 index 586d2866f1..0000000000 --- a/android/apishim/OWNERS +++ /dev/null @@ -1,6 +0,0 @@ -# Reviewers for /android/apishim - -eruffieux@google.com -jpawlowski@google.com -siyuanh@google.com -wescande@google.com diff --git a/android/app/Android.bp b/android/app/Android.bp index 09d8a91865..db85914522 100644 --- a/android/app/Android.bp +++ b/android/app/Android.bp @@ -108,7 +108,6 @@ cc_library_shared { "libaconfig_storage_read_api_cc", "libbase", "libbluetooth", - "libbluetooth-dumpsys", "libbluetooth-types", "libbluetooth_core_rs", "libbluetooth_core_rs_bridge", diff --git a/android/app/OWNERS b/android/app/OWNERS deleted file mode 100644 index 6f7b40e8f5..0000000000 --- a/android/app/OWNERS +++ /dev/null @@ -1,12 +0,0 @@ -# Reviewers for /android/app - -bhaktha@google.com -eruffieux@google.com -hallstrom@google.com -henrichataing@google.com -jpawlowski@google.com -okamil@google.com -poahlo@google.com -siyuanh@google.com -wescande@google.com -yuyangh@google.com diff --git a/android/app/jni/OWNERS b/android/app/jni/OWNERS deleted file mode 100644 index 826f56b4e0..0000000000 --- a/android/app/jni/OWNERS +++ /dev/null @@ -1,4 +0,0 @@ -per-file com_android_bluetooth_hearing_aid.cpp=file:/OWNERS_hearingaid -per-file com_android_bluetooth_csip_set_coordinator.cpp=file:/OWNERS_leaudio -per-file com_android_bluetooth_le_audio.cpp=file:/OWNERS_leaudio -per-file com_android_bluetooth_vc.cpp=file:/OWNERS_leaudio diff --git a/android/app/jni/com_android_bluetooth_le_audio.cpp b/android/app/jni/com_android_bluetooth_le_audio.cpp index 4ce436e5c4..3a3d8ceed6 100644 --- a/android/app/jni/com_android_bluetooth_le_audio.cpp +++ b/android/app/jni/com_android_bluetooth_le_audio.cpp @@ -706,7 +706,7 @@ static void setUnicastMonitorModeNative(JNIEnv* /* env */, jobject /* object */, sLeAudioClientInterface->SetUnicastMonitorMode(direction, enable); } -static void sendAudioProfilePreferencesNative(JNIEnv* /* env */, jint groupId, +static void sendAudioProfilePreferencesNative(JNIEnv* /* env */, jobject /* object */, jint groupId, jboolean isOutputPreferenceLeAudio, jboolean isDuplexPreferenceLeAudio) { std::shared_lock<std::shared_timed_mutex> lock(interface_mutex); diff --git a/android/app/src/com/android/bluetooth/a2dpsink/OWNERS b/android/app/src/com/android/bluetooth/a2dpsink/OWNERS deleted file mode 100644 index ecd59038a1..0000000000 --- a/android/app/src/com/android/bluetooth/a2dpsink/OWNERS +++ /dev/null @@ -1 +0,0 @@ -include /OWNERS_automotive diff --git a/android/app/src/com/android/bluetooth/avrcpcontroller/OWNERS b/android/app/src/com/android/bluetooth/avrcpcontroller/OWNERS deleted file mode 100644 index ecd59038a1..0000000000 --- a/android/app/src/com/android/bluetooth/avrcpcontroller/OWNERS +++ /dev/null @@ -1 +0,0 @@ -include /OWNERS_automotive diff --git a/android/app/src/com/android/bluetooth/bass_client/OWNERS b/android/app/src/com/android/bluetooth/bass_client/OWNERS deleted file mode 100644 index a7d77894ba..0000000000 --- a/android/app/src/com/android/bluetooth/bass_client/OWNERS +++ /dev/null @@ -1 +0,0 @@ -include /OWNERS_leaudio diff --git a/android/app/src/com/android/bluetooth/btservice/ActiveDeviceManager.java b/android/app/src/com/android/bluetooth/btservice/ActiveDeviceManager.java index 6c79ab4789..bc05fe9ae8 100644 --- a/android/app/src/com/android/bluetooth/btservice/ActiveDeviceManager.java +++ b/android/app/src/com/android/bluetooth/btservice/ActiveDeviceManager.java @@ -412,7 +412,7 @@ public class ActiveDeviceManager implements AdapterService.BluetoothStateCallbac final LeAudioService leAudioService = mFactory.getLeAudioService(); setA2dpActiveDevice(null, true); setHfpActiveDevice(null); - if (Flags.admVerifyActiveFallbackDevice()) { + if (Flags.admVerifyActiveFallbackDevice() && leAudioService != null) { setLeAudioActiveDevice( null, !leAudioService.getActiveDevices().contains(device)); } else { diff --git a/android/app/src/com/android/bluetooth/content_profiles/OWNERS b/android/app/src/com/android/bluetooth/content_profiles/OWNERS deleted file mode 100644 index 8f87191393..0000000000 --- a/android/app/src/com/android/bluetooth/content_profiles/OWNERS +++ /dev/null @@ -1 +0,0 @@ -include /OWNERS_content
\ No newline at end of file diff --git a/android/app/src/com/android/bluetooth/csip/OWNERS b/android/app/src/com/android/bluetooth/csip/OWNERS deleted file mode 100644 index a7d77894ba..0000000000 --- a/android/app/src/com/android/bluetooth/csip/OWNERS +++ /dev/null @@ -1 +0,0 @@ -include /OWNERS_leaudio diff --git a/android/app/src/com/android/bluetooth/hearingaid/OWNERS b/android/app/src/com/android/bluetooth/hearingaid/OWNERS deleted file mode 100644 index bbaa85ddbb..0000000000 --- a/android/app/src/com/android/bluetooth/hearingaid/OWNERS +++ /dev/null @@ -1 +0,0 @@ -include /OWNERS_hearingaid diff --git a/android/app/src/com/android/bluetooth/hfpclient/OWNERS b/android/app/src/com/android/bluetooth/hfpclient/OWNERS deleted file mode 100644 index ecd59038a1..0000000000 --- a/android/app/src/com/android/bluetooth/hfpclient/OWNERS +++ /dev/null @@ -1 +0,0 @@ -include /OWNERS_automotive diff --git a/android/app/src/com/android/bluetooth/le_audio/OWNERS b/android/app/src/com/android/bluetooth/le_audio/OWNERS deleted file mode 100644 index a7d77894ba..0000000000 --- a/android/app/src/com/android/bluetooth/le_audio/OWNERS +++ /dev/null @@ -1 +0,0 @@ -include /OWNERS_leaudio diff --git a/android/app/src/com/android/bluetooth/map/OWNERS b/android/app/src/com/android/bluetooth/map/OWNERS deleted file mode 100644 index 8f87191393..0000000000 --- a/android/app/src/com/android/bluetooth/map/OWNERS +++ /dev/null @@ -1 +0,0 @@ -include /OWNERS_content
\ No newline at end of file diff --git a/android/app/src/com/android/bluetooth/mapclient/OWNERS b/android/app/src/com/android/bluetooth/mapclient/OWNERS deleted file mode 100644 index b0b54fc3d2..0000000000 --- a/android/app/src/com/android/bluetooth/mapclient/OWNERS +++ /dev/null @@ -1,2 +0,0 @@ -include /OWNERS_automotive -include /OWNERS_content diff --git a/android/app/src/com/android/bluetooth/mcp/OWNERS b/android/app/src/com/android/bluetooth/mcp/OWNERS deleted file mode 100644 index a7d77894ba..0000000000 --- a/android/app/src/com/android/bluetooth/mcp/OWNERS +++ /dev/null @@ -1 +0,0 @@ -include /OWNERS_leaudio diff --git a/android/app/src/com/android/bluetooth/opp/OWNERS b/android/app/src/com/android/bluetooth/opp/OWNERS deleted file mode 100644 index 8f87191393..0000000000 --- a/android/app/src/com/android/bluetooth/opp/OWNERS +++ /dev/null @@ -1 +0,0 @@ -include /OWNERS_content
\ No newline at end of file diff --git a/android/app/src/com/android/bluetooth/pan/OWNERS b/android/app/src/com/android/bluetooth/pan/OWNERS deleted file mode 100644 index 8f87191393..0000000000 --- a/android/app/src/com/android/bluetooth/pan/OWNERS +++ /dev/null @@ -1 +0,0 @@ -include /OWNERS_content
\ No newline at end of file diff --git a/android/app/src/com/android/bluetooth/pbap/OWNERS b/android/app/src/com/android/bluetooth/pbap/OWNERS deleted file mode 100644 index 8f87191393..0000000000 --- a/android/app/src/com/android/bluetooth/pbap/OWNERS +++ /dev/null @@ -1 +0,0 @@ -include /OWNERS_content
\ No newline at end of file diff --git a/android/app/src/com/android/bluetooth/pbapclient/OWNERS b/android/app/src/com/android/bluetooth/pbapclient/OWNERS deleted file mode 100644 index b0b54fc3d2..0000000000 --- a/android/app/src/com/android/bluetooth/pbapclient/OWNERS +++ /dev/null @@ -1,2 +0,0 @@ -include /OWNERS_automotive -include /OWNERS_content diff --git a/android/app/src/com/android/bluetooth/sap/OWNERS b/android/app/src/com/android/bluetooth/sap/OWNERS deleted file mode 100644 index 8f87191393..0000000000 --- a/android/app/src/com/android/bluetooth/sap/OWNERS +++ /dev/null @@ -1 +0,0 @@ -include /OWNERS_content
\ No newline at end of file diff --git a/android/app/src/com/android/bluetooth/vc/OWNERS b/android/app/src/com/android/bluetooth/vc/OWNERS deleted file mode 100644 index a7d77894ba..0000000000 --- a/android/app/src/com/android/bluetooth/vc/OWNERS +++ /dev/null @@ -1 +0,0 @@ -include /OWNERS_leaudio diff --git a/android/app/tests/OWNERS b/android/app/tests/OWNERS deleted file mode 100644 index ecd59038a1..0000000000 --- a/android/app/tests/OWNERS +++ /dev/null @@ -1 +0,0 @@ -include /OWNERS_automotive diff --git a/android/app/tests/unit/src/com/android/bluetooth/bass_client/OWNERS b/android/app/tests/unit/src/com/android/bluetooth/bass_client/OWNERS deleted file mode 100644 index a7d77894ba..0000000000 --- a/android/app/tests/unit/src/com/android/bluetooth/bass_client/OWNERS +++ /dev/null @@ -1 +0,0 @@ -include /OWNERS_leaudio diff --git a/android/app/tests/unit/src/com/android/bluetooth/content_profiles/OWNERS b/android/app/tests/unit/src/com/android/bluetooth/content_profiles/OWNERS deleted file mode 100644 index 8f87191393..0000000000 --- a/android/app/tests/unit/src/com/android/bluetooth/content_profiles/OWNERS +++ /dev/null @@ -1 +0,0 @@ -include /OWNERS_content
\ No newline at end of file diff --git a/android/app/tests/unit/src/com/android/bluetooth/csip/OWNERS b/android/app/tests/unit/src/com/android/bluetooth/csip/OWNERS deleted file mode 100644 index a7d77894ba..0000000000 --- a/android/app/tests/unit/src/com/android/bluetooth/csip/OWNERS +++ /dev/null @@ -1 +0,0 @@ -include /OWNERS_leaudio diff --git a/android/app/tests/unit/src/com/android/bluetooth/hearingaid/OWNERS b/android/app/tests/unit/src/com/android/bluetooth/hearingaid/OWNERS deleted file mode 100644 index bbaa85ddbb..0000000000 --- a/android/app/tests/unit/src/com/android/bluetooth/hearingaid/OWNERS +++ /dev/null @@ -1 +0,0 @@ -include /OWNERS_hearingaid diff --git a/android/app/tests/unit/src/com/android/bluetooth/le_audio/OWNERS b/android/app/tests/unit/src/com/android/bluetooth/le_audio/OWNERS deleted file mode 100644 index a7d77894ba..0000000000 --- a/android/app/tests/unit/src/com/android/bluetooth/le_audio/OWNERS +++ /dev/null @@ -1 +0,0 @@ -include /OWNERS_leaudio diff --git a/android/app/tests/unit/src/com/android/bluetooth/map/OWNERS b/android/app/tests/unit/src/com/android/bluetooth/map/OWNERS deleted file mode 100644 index 8f87191393..0000000000 --- a/android/app/tests/unit/src/com/android/bluetooth/map/OWNERS +++ /dev/null @@ -1 +0,0 @@ -include /OWNERS_content
\ No newline at end of file diff --git a/android/app/tests/unit/src/com/android/bluetooth/mapapi/OWNERS b/android/app/tests/unit/src/com/android/bluetooth/mapapi/OWNERS deleted file mode 100644 index 8f87191393..0000000000 --- a/android/app/tests/unit/src/com/android/bluetooth/mapapi/OWNERS +++ /dev/null @@ -1 +0,0 @@ -include /OWNERS_content
\ No newline at end of file diff --git a/android/app/tests/unit/src/com/android/bluetooth/mapclient/OWNERS b/android/app/tests/unit/src/com/android/bluetooth/mapclient/OWNERS deleted file mode 100644 index 8f87191393..0000000000 --- a/android/app/tests/unit/src/com/android/bluetooth/mapclient/OWNERS +++ /dev/null @@ -1 +0,0 @@ -include /OWNERS_content
\ No newline at end of file diff --git a/android/app/tests/unit/src/com/android/bluetooth/mcp/OWNERS b/android/app/tests/unit/src/com/android/bluetooth/mcp/OWNERS deleted file mode 100644 index a7d77894ba..0000000000 --- a/android/app/tests/unit/src/com/android/bluetooth/mcp/OWNERS +++ /dev/null @@ -1 +0,0 @@ -include /OWNERS_leaudio diff --git a/android/app/tests/unit/src/com/android/bluetooth/obex/OWNERS b/android/app/tests/unit/src/com/android/bluetooth/obex/OWNERS deleted file mode 100644 index 8f87191393..0000000000 --- a/android/app/tests/unit/src/com/android/bluetooth/obex/OWNERS +++ /dev/null @@ -1 +0,0 @@ -include /OWNERS_content
\ No newline at end of file diff --git a/android/app/tests/unit/src/com/android/bluetooth/opp/OWNERS b/android/app/tests/unit/src/com/android/bluetooth/opp/OWNERS deleted file mode 100644 index 8f87191393..0000000000 --- a/android/app/tests/unit/src/com/android/bluetooth/opp/OWNERS +++ /dev/null @@ -1 +0,0 @@ -include /OWNERS_content
\ No newline at end of file diff --git a/android/app/tests/unit/src/com/android/bluetooth/pan/OWNERS b/android/app/tests/unit/src/com/android/bluetooth/pan/OWNERS deleted file mode 100644 index 8f87191393..0000000000 --- a/android/app/tests/unit/src/com/android/bluetooth/pan/OWNERS +++ /dev/null @@ -1 +0,0 @@ -include /OWNERS_content
\ No newline at end of file diff --git a/android/app/tests/unit/src/com/android/bluetooth/pbap/OWNERS b/android/app/tests/unit/src/com/android/bluetooth/pbap/OWNERS deleted file mode 100644 index 8f87191393..0000000000 --- a/android/app/tests/unit/src/com/android/bluetooth/pbap/OWNERS +++ /dev/null @@ -1 +0,0 @@ -include /OWNERS_content
\ No newline at end of file diff --git a/android/app/tests/unit/src/com/android/bluetooth/pbapclient/OWNERS b/android/app/tests/unit/src/com/android/bluetooth/pbapclient/OWNERS deleted file mode 100644 index 8f87191393..0000000000 --- a/android/app/tests/unit/src/com/android/bluetooth/pbapclient/OWNERS +++ /dev/null @@ -1 +0,0 @@ -include /OWNERS_content
\ No newline at end of file diff --git a/android/app/tests/unit/src/com/android/bluetooth/sap/OWNERS b/android/app/tests/unit/src/com/android/bluetooth/sap/OWNERS deleted file mode 100644 index 8f87191393..0000000000 --- a/android/app/tests/unit/src/com/android/bluetooth/sap/OWNERS +++ /dev/null @@ -1 +0,0 @@ -include /OWNERS_content
\ No newline at end of file diff --git a/android/app/tests/unit/src/com/android/bluetooth/vc/OWNERS b/android/app/tests/unit/src/com/android/bluetooth/vc/OWNERS deleted file mode 100644 index a7d77894ba..0000000000 --- a/android/app/tests/unit/src/com/android/bluetooth/vc/OWNERS +++ /dev/null @@ -1 +0,0 @@ -include /OWNERS_leaudio diff --git a/android/leaudio/OWNERS b/android/leaudio/OWNERS deleted file mode 100644 index a7d77894ba..0000000000 --- a/android/leaudio/OWNERS +++ /dev/null @@ -1 +0,0 @@ -include /OWNERS_leaudio diff --git a/android/pandora/OWNERS b/android/pandora/OWNERS deleted file mode 100644 index c199a82a60..0000000000 --- a/android/pandora/OWNERS +++ /dev/null @@ -1,2 +0,0 @@ -# Bug component: 1099313 -girardier@google.com diff --git a/android/pandora/test/pairing/OWNERS b/android/pandora/test/pairing/OWNERS deleted file mode 100644 index b430ae987d..0000000000 --- a/android/pandora/test/pairing/OWNERS +++ /dev/null @@ -1,2 +0,0 @@ -# Bug component: 27441 -rwt@google.com diff --git a/apex/OWNERS b/apex/OWNERS deleted file mode 100644 index f05027c972..0000000000 --- a/apex/OWNERS +++ /dev/null @@ -1,5 +0,0 @@ -# Reviewers for /apex - -eruffieux@google.com -wescande@google.com - diff --git a/apex/hiddenapi/OWNERS b/apex/hiddenapi/OWNERS deleted file mode 100644 index 82b599dbf1..0000000000 --- a/apex/hiddenapi/OWNERS +++ /dev/null @@ -1,9 +0,0 @@ -# These files are only intended to be changed by platform-compat and -# the soong teams. -set noparent - -# soong-team@ as the hiddenapi files are tightly coupled with Soong -file:platform/build/soong:/OWNERS - -# compat-team@ for changes to hiddenapi files -file:tools/platform-compat:/OWNERS diff --git a/apex/permissions/OWNERS b/apex/permissions/OWNERS deleted file mode 100644 index 8b8ec67028..0000000000 --- a/apex/permissions/OWNERS +++ /dev/null @@ -1 +0,0 @@ -per-file *.xml,OWNERS = file:platform/frameworks/base:/data/etc/OWNERS diff --git a/common/OWNERS b/common/OWNERS deleted file mode 100644 index 5b3f4bad26..0000000000 --- a/common/OWNERS +++ /dev/null @@ -1 +0,0 @@ -wescande@google.com diff --git a/flags/OWNERS b/flags/OWNERS deleted file mode 100644 index b4f2f7376b..0000000000 --- a/flags/OWNERS +++ /dev/null @@ -1,3 +0,0 @@ -# Bug component: 1387432 -girardier@google.com -wescande@google.com diff --git a/floss/OWNERS b/floss/OWNERS deleted file mode 100644 index a823e6e1dd..0000000000 --- a/floss/OWNERS +++ /dev/null @@ -1 +0,0 @@ -include /OWNERS_chromeos diff --git a/floss/pandora/OWNERS b/floss/pandora/OWNERS deleted file mode 100644 index ca4001b6d4..0000000000 --- a/floss/pandora/OWNERS +++ /dev/null @@ -1,4 +0,0 @@ -# Reviewers for /floss/pandora - -johnlai@google.com -chharry@google.com diff --git a/framework/OWNERS b/framework/OWNERS deleted file mode 100644 index 40a43c47cb..0000000000 --- a/framework/OWNERS +++ /dev/null @@ -1,4 +0,0 @@ -hallstrom@google.com -okamil@google.com -siyuanh@google.com -wescande@google.com diff --git a/framework/java/android/bluetooth/OWNERS b/framework/java/android/bluetooth/OWNERS deleted file mode 100644 index 757ed73819..0000000000 --- a/framework/java/android/bluetooth/OWNERS +++ /dev/null @@ -1,5 +0,0 @@ -per-file BluetoothHearingAid.java=file:/OWNERS_hearingaid -per-file BluetoothCsipSetCoordinator.java=file:/OWNERS_leaudio -per-file BluetoothLeAudio*.java=file:/OWNERS_leaudio -per-file BluetoothLeBroadcast*.java=file:/OWNERS_leaudio -per-file BluetoothVolumeControl.java=file:/OWNERS_leaudio diff --git a/framework/tests/bumble/src/android/bluetooth/hid/OWNERS b/framework/tests/bumble/src/android/bluetooth/hid/OWNERS deleted file mode 100644 index 75539edb09..0000000000 --- a/framework/tests/bumble/src/android/bluetooth/hid/OWNERS +++ /dev/null @@ -1,3 +0,0 @@ -# Bug component: 27441 -# Project owners -rwt@google.com diff --git a/framework/tests/bumble/src/android/bluetooth/pairing/OWNERS b/framework/tests/bumble/src/android/bluetooth/pairing/OWNERS deleted file mode 100644 index 75539edb09..0000000000 --- a/framework/tests/bumble/src/android/bluetooth/pairing/OWNERS +++ /dev/null @@ -1,3 +0,0 @@ -# Bug component: 27441 -# Project owners -rwt@google.com diff --git a/framework/tests/bumble/src/android/bluetooth/service_discovery/OWNERS b/framework/tests/bumble/src/android/bluetooth/service_discovery/OWNERS deleted file mode 100644 index 353b5d03a5..0000000000 --- a/framework/tests/bumble/src/android/bluetooth/service_discovery/OWNERS +++ /dev/null @@ -1,3 +0,0 @@ -# Bug component: 27441 -# Project owners -jpawlowski@google.com diff --git a/framework/tests/metrics/OWNERS b/framework/tests/metrics/OWNERS deleted file mode 100644 index 01d41baf7e..0000000000 --- a/framework/tests/metrics/OWNERS +++ /dev/null @@ -1,3 +0,0 @@ -# Bug component: 1099313 -# Project owners -ahujapalash@google.com diff --git a/framework/tests/util/Android.bp b/framework/tests/util/Android.bp index f1e942f4c6..dc42f777a5 100644 --- a/framework/tests/util/Android.bp +++ b/framework/tests/util/Android.bp @@ -43,6 +43,7 @@ java_library { "//packages/modules/Connectivity/nearby/tests/cts/fastpair", "//packages/modules/Permission/tests/cts/permission", "//packages/modules/Permission/tests/cts/permissionui", + "//packages/modules/Uwb/ranging/tests/cts/tests", "//test/cts-root/tests/bluetooth", ], } diff --git a/pandora/OWNERS b/pandora/OWNERS deleted file mode 100644 index 14634f3b78..0000000000 --- a/pandora/OWNERS +++ /dev/null @@ -1,2 +0,0 @@ -# Project owners -girardier@google.com diff --git a/service/OWNERS b/service/OWNERS deleted file mode 100644 index 5b3f4bad26..0000000000 --- a/service/OWNERS +++ /dev/null @@ -1 +0,0 @@ -wescande@google.com diff --git a/sysprop/OWNERS b/sysprop/OWNERS deleted file mode 100644 index 5b3f4bad26..0000000000 --- a/sysprop/OWNERS +++ /dev/null @@ -1 +0,0 @@ -wescande@google.com diff --git a/system/BUILD.gn b/system/BUILD.gn index 783428604a..01286ec4e8 100644 --- a/system/BUILD.gn +++ b/system/BUILD.gn @@ -55,7 +55,6 @@ group("bluetooth") { group("tools") { deps = [ - "//bt/system/gd/dumpsys/bundler:bluetooth_flatbuffer_bundler", "//bt/system/gd/packet/parser:bluetooth_packetgen", ] } diff --git a/system/OWNERS b/system/OWNERS deleted file mode 100644 index 15ec13fb04..0000000000 --- a/system/OWNERS +++ /dev/null @@ -1,13 +0,0 @@ -# Reviewers for /system - -bhaktha@google.com -eruffieux@google.com -hallstrom@google.com -henrichataing@google.com -jpawlowski@google.com -okamil@google.com -poahlo@google.com -rongxuan@google.com -rwt@google.com -wescande@google.com -yuyangh@google.com diff --git a/system/audio/Android.bp b/system/audio/Android.bp index d5dde594e1..481182dc5f 100644 --- a/system/audio/Android.bp +++ b/system/audio/Android.bp @@ -83,9 +83,6 @@ cc_library_host_shared { "liblog", ], stl: "libc++_static", - generated_headers: [ - "BluetoothGeneratedDumpsysDataSchema_h", - ], } python_test_host { diff --git a/system/audio_hal_interface/Android.bp b/system/audio_hal_interface/Android.bp index f485de80aa..a074c7f959 100644 --- a/system/audio_hal_interface/Android.bp +++ b/system/audio_hal_interface/Android.bp @@ -228,7 +228,6 @@ cc_defaults { "android.hardware.common.fmq-V1-ndk", "libFraunhoferAAC", "libbase", - "libbluetooth-dumpsys", "libbluetooth-protos", "libbluetooth-types", "libbluetooth_core_rs", diff --git a/system/audio_hal_interface/fuzzer/Android.bp b/system/audio_hal_interface/fuzzer/Android.bp index 9a32f910e3..f2301b6d00 100644 --- a/system/audio_hal_interface/fuzzer/Android.bp +++ b/system/audio_hal_interface/fuzzer/Android.bp @@ -59,7 +59,6 @@ cc_defaults { "bluetooth_flags_c_lib", "libFraunhoferAAC", "libbase", - "libbluetooth-dumpsys", "libbluetooth-protos", "libbluetooth-types", "libbluetooth_core_rs", diff --git a/system/bta/Android.bp b/system/bta/Android.bp index f99f437bd4..698752dbb4 100644 --- a/system/bta/Android.bp +++ b/system/bta/Android.bp @@ -27,9 +27,6 @@ cc_defaults { "packages/modules/Bluetooth/system/udrv/include", ], header_libs: ["libbluetooth_headers"], - generated_headers: [ - "BluetoothGeneratedDumpsysDataSchema_h", - ], } filegroup { @@ -238,7 +235,6 @@ cc_library_static { cc_test { name: "net_test_bta", defaults: [ - "bluetooth_flatbuffer_bundler_defaults", "fluoride_bta_defaults", "latest_android_hardware_audio_common_ndk_static", "latest_android_hardware_bluetooth_audio_ndk_static", @@ -288,9 +284,6 @@ cc_test { "test/bta_sdp_test.cc", "test/bta_sec_test.cc", ], - generated_headers: [ - "BluetoothGeneratedDumpsysDataSchema_h", - ], shared_libs: [ "libaconfig_storage_read_api_cc", "libcrypto", @@ -376,9 +369,6 @@ cc_test { "test/gatt/database_builder_test.cc", "test/gatt/database_test.cc", ], - generated_headers: [ - "BluetoothGeneratedDumpsysDataSchema_h", - ], shared_libs: [ "libaconfig_storage_read_api_cc", "libbase", @@ -466,9 +456,6 @@ cc_test { "packages/modules/Bluetooth/system", "packages/modules/Bluetooth/system/gd", ], - generated_headers: [ - "BluetoothGeneratedDumpsysDataSchema_h", - ], srcs: [ ":TestCommonMockFunctions", ":TestFakeOsi", @@ -764,7 +751,6 @@ cc_test { test_suites: ["general-tests"], defaults: [ "aconfig_lib_cc_shared_link.defaults", - "bluetooth_flatbuffer_bundler_defaults", "fluoride_defaults", "mts_defaults", ], @@ -811,7 +797,6 @@ cc_test { ":audio_set_scenarios_json", ], generated_headers: [ - "BluetoothGeneratedDumpsysDataSchema_h", "LeAudioSetConfigSchemas_h", ], shared_libs: [ @@ -848,7 +833,6 @@ cc_test { name: "bluetooth_le_audio_test", test_suites: ["general-tests"], defaults: [ - "bluetooth_flatbuffer_bundler_defaults", "fluoride_defaults", "mts_defaults", ], @@ -921,7 +905,6 @@ cc_test { ":audio_set_scenarios_json", ], generated_headers: [ - "BluetoothGeneratedDumpsysDataSchema_h", "LeAudioSetConfigSchemas_h", ], shared_libs: [ @@ -959,7 +942,6 @@ cc_test { name: "bluetooth_le_audio_client_test", test_suites: ["general-tests"], defaults: [ - "bluetooth_flatbuffer_bundler_defaults", "fluoride_bta_defaults", "mts_defaults", ], @@ -1149,7 +1131,6 @@ cc_test { test_suites: ["general-tests"], defaults: [ "aconfig_lib_cc_shared_link.defaults", - "bluetooth_flatbuffer_bundler_defaults", "fluoride_bta_defaults", "mts_defaults", ], @@ -1346,9 +1327,6 @@ cc_test { "libgmock", "libosi", ], - generated_headers: [ - "BluetoothGeneratedDumpsysDataSchema_h", - ], sanitize: { cfi: true, scs: true, @@ -1417,9 +1395,6 @@ cc_test { "libgmock", "libosi", ], - generated_headers: [ - "BluetoothGeneratedDumpsysDataSchema_h", - ], sanitize: { cfi: true, scs: true, diff --git a/system/bta/BUILD.gn b/system/bta/BUILD.gn index 928359ab22..425289338b 100644 --- a/system/bta/BUILD.gn +++ b/system/bta/BUILD.gn @@ -14,8 +14,7 @@ # limitations under the License. # -import("//bt/system/gd/dumpsys/bundler/bundler.gni") -import("//common-mk/flatbuffer.gni") +import("//bt/system/bta/bundler.gni") static_library("bta") { sources = [ diff --git a/system/gd/dumpsys/bundler/bundler.gni b/system/bta/bundler.gni index 2942bbee1d..2942bbee1d 100644 --- a/system/gd/dumpsys/bundler/bundler.gni +++ b/system/bta/bundler.gni diff --git a/system/bta/hearing_aid/OWNERS b/system/bta/hearing_aid/OWNERS deleted file mode 100644 index bbaa85ddbb..0000000000 --- a/system/bta/hearing_aid/OWNERS +++ /dev/null @@ -1 +0,0 @@ -include /OWNERS_hearingaid diff --git a/system/bta/include/OWNERS b/system/bta/include/OWNERS deleted file mode 100644 index 9dfb8422a1..0000000000 --- a/system/bta/include/OWNERS +++ /dev/null @@ -1 +0,0 @@ -per-file bta_hearing_aid_api.h=file:/OWNERS_hearingaid diff --git a/system/bta/le_audio/OWNERS b/system/bta/le_audio/OWNERS deleted file mode 100644 index a7d77894ba..0000000000 --- a/system/bta/le_audio/OWNERS +++ /dev/null @@ -1 +0,0 @@ -include /OWNERS_leaudio diff --git a/system/btif/Android.bp b/system/btif/Android.bp index 59846db8b0..c8de253527 100644 --- a/system/btif/Android.bp +++ b/system/btif/Android.bp @@ -123,9 +123,6 @@ cc_library_static { "src/btif_rc.cc", "src/btif_vc.cc", ], - generated_headers: [ - "BluetoothGeneratedDumpsysDataSchema_h", - ], local_include_dirs: [ "include", ], @@ -214,9 +211,6 @@ cc_library_static { "src/btif_util.cc", "src/stack_manager.cc", ], - generated_headers: [ - "BluetoothGeneratedDumpsysDataSchema_h", - ], target: { android: { whole_static_libs: [ @@ -309,7 +303,6 @@ cc_test { "bluetooth_flags_c_lib_for_test", "libFraunhoferAAC", "libbase", - "libbluetooth-dumpsys", "libbluetooth-for-tests", "libbluetooth-types", "libbluetooth_core_rs", @@ -391,9 +384,6 @@ cc_test { "test/btif_profile_queue_test.cc", ], header_libs: ["libbluetooth_headers"], - generated_headers: [ - "BluetoothGeneratedDumpsysDataSchema_h", - ], static_libs: [ "libbluetooth-types", "libbluetooth_gd", @@ -427,9 +417,6 @@ cc_test { "test/btif_avrcp_audio_track_test.cc", ], header_libs: ["libbluetooth_headers"], - generated_headers: [ - "BluetoothGeneratedDumpsysDataSchema_h", - ], static_libs: [ "libbluetooth-types", "libbluetooth_log", @@ -575,10 +562,6 @@ cc_test { ":TestMockUdrv", "test/btif_hh_test.cc", ], - generated_headers: [ - "BluetoothGeneratedBundlerSchema_h_bfbs", - "BluetoothGeneratedDumpsysDataSchema_h", - ], header_libs: ["libbluetooth_headers"], aidl: { libs: ["bluetooth_constants"], @@ -700,10 +683,6 @@ cc_test { ":TestMockUdrv", "test/btif_core_test.cc", ], - generated_headers: [ - "BluetoothGeneratedBundlerSchema_h_bfbs", - "BluetoothGeneratedDumpsysDataSchema_h", - ], header_libs: ["libbluetooth_headers"], aidl: { libs: ["bluetooth_constants"], diff --git a/system/btif/src/OWNERS b/system/btif/src/OWNERS deleted file mode 100644 index e495e167d4..0000000000 --- a/system/btif/src/OWNERS +++ /dev/null @@ -1 +0,0 @@ -per-file btif_hearing_aid.cc=file:/OWNERS_hearingaid diff --git a/system/btif/src/btif_dm.cc b/system/btif/src/btif_dm.cc index b9bd933899..8be2d87394 100644 --- a/system/btif/src/btif_dm.cc +++ b/system/btif/src/btif_dm.cc @@ -3073,7 +3073,7 @@ static void id_status_callback(tBT_TRANSPORT transport, bool is_valid, const Oct auto advertiser = bluetooth::shim::get_ble_advertiser_instance(); ::AdvertiseParameters parameters{}; - parameters.advertising_event_properties = 0x0045 /* connectable, discoverable, tx power */; + parameters.advertising_event_properties = 0x0041 /* connectable, tx power */; parameters.min_interval = 0xa0; // 100 ms parameters.max_interval = 0x500; // 800 ms parameters.channel_map = 0x7; // Use all the channels @@ -3082,6 +3082,7 @@ static void id_status_callback(tBT_TRANSPORT transport, bool is_valid, const Oct parameters.secondary_advertising_phy = 2; parameters.scan_request_notification_enable = 0; parameters.own_address_type = BLE_ADDR_RANDOM; + parameters.discoverable = true; std::vector<uint8_t> advertisement{0x02, 0x01 /* Flags */, 0x02 /* Connectable */}; std::vector<uint8_t> scan_data{}; diff --git a/system/device/Android.bp b/system/device/Android.bp index 5411561278..eb71e3f414 100644 --- a/system/device/Android.bp +++ b/system/device/Android.bp @@ -29,9 +29,6 @@ cc_library_static { apex_available: [ "com.android.btservices", ], - generated_headers: [ - "BluetoothGeneratedDumpsysDataSchema_h", - ], min_sdk_version: "Tiramisu", header_libs: ["libbluetooth_headers"], static_libs: [ diff --git a/system/device/fuzzer/Android.bp b/system/device/fuzzer/Android.bp index d1b7357de9..c7a6917898 100644 --- a/system/device/fuzzer/Android.bp +++ b/system/device/fuzzer/Android.bp @@ -40,9 +40,6 @@ cc_fuzz { "liblog", "server_configurable_flags", ], - generated_headers: [ - "BluetoothGeneratedDumpsysDataSchema_h", - ], static_libs: [ "bluetooth_flags_c_lib", "libbluetooth-types", diff --git a/system/gd/Android.bp b/system/gd/Android.bp index f00f34557e..a4c2120ddd 100644 --- a/system/gd/Android.bp +++ b/system/gd/Android.bp @@ -125,7 +125,6 @@ cc_defaults { }, srcs: [ ":BluetoothCommonSources", - ":BluetoothDumpsysSources", ":BluetoothHalSources", ":BluetoothHciSources", ":BluetoothLppOffloadSources", @@ -136,13 +135,8 @@ cc_defaults { ":BluetoothShimSources", ":BluetoothStorageSources", "module.cc", - "module_dumper.cc", "stack_manager.cc", ], - generated_headers: [ - "BluetoothGeneratedBundlerSchema_h_bfbs", - "BluetoothGeneratedDumpsysDataSchema_h", - ], shared_libs: [ "libcrypto", "libflatbuffers-cpp", @@ -160,7 +154,6 @@ cc_defaults { static_libs: [ "libaconfig_storage_read_api_cc", "libbase", - "libbluetooth-dumpsys", "libbluetooth-protos", "libbluetooth-types", "libbluetooth_crypto_toolbox", @@ -268,8 +261,6 @@ cc_binary { ], generated_headers: [ "BlueberryFacadeGeneratedStub_h", - "BluetoothGeneratedBundlerSchema_h_bfbs", - "BluetoothGeneratedDumpsysDataSchema_h", ], generated_sources: [ "BlueberryFacadeGeneratedStub_cc", @@ -278,7 +269,6 @@ cc_binary { "bluetooth_flags_c_lib", "breakpad_client", "libPlatformProperties", - "libbluetooth-dumpsys", "libbluetooth-protos", "libbluetooth-types", "libbluetooth_crypto_toolbox", @@ -437,12 +427,6 @@ cc_test { "module_unittest.cc", "stack_manager_unittest.cc", ], - generated_headers: [ - "BluetoothGeneratedBundlerSchema_h_bfbs", - "BluetoothGeneratedDumpsysDataSchema_h", - "BluetoothGeneratedDumpsysInternalTestData_h", - "BluetoothGeneratedDumpsysTestData_h", - ], static_libs: [ "bluetooth_flags_c_lib_for_test", "libbase", @@ -545,9 +529,6 @@ cc_defaults { "libosi", ], host_supported: true, - generated_headers: [ - "BluetoothGeneratedDumpsysDataSchema_h", - ], shared_libs: [ "libPlatformProperties", "libaconfig_storage_read_api_cc", @@ -633,38 +614,3 @@ cc_benchmark { "server_configurable_flags", ], } - -// Generates binary schema data to be bundled and source file generated -genrule { - name: "BluetoothGeneratedDumpsysBinarySchema_bfbs", - tools: [ - "flatc", - ], - cmd: "$(location flatc) -I packages/modules/Bluetooth/system/gd -b --schema -o $(genDir) $(in) ", - srcs: [ - "dumpsys_data.fbs", - "module_unittest.fbs", - "os/wakelock_manager.fbs", - ], - out: [ - "dumpsys_data.bfbs", - "wakelock_manager.bfbs", - ], -} - -genrule { - name: "BluetoothGeneratedDumpsysDataSchema_h", - tools: [ - "flatc", - ], - cmd: "$(location flatc) -I packages/modules/Bluetooth/system/gd -o $(genDir) --cpp $(in) ", - srcs: [ - "dumpsys_data.fbs", - "module_unittest.fbs", - "os/wakelock_manager.fbs", - ], - out: [ - "dumpsys_data_generated.h", - "wakelock_manager_generated.h", - ], -} diff --git a/system/gd/BUILD.gn b/system/gd/BUILD.gn index 8056da7a36..fc51ba806f 100644 --- a/system/gd/BUILD.gn +++ b/system/gd/BUILD.gn @@ -13,7 +13,6 @@ # See the License for the specific language governing permissions and # limitations under the License. -import("//bt/system/gd/dumpsys/bundler/bundler.gni") import("//bt/system/gd/packet/parser/packetgen.gni") import("//common-mk/flatbuffer.gni") @@ -47,8 +46,6 @@ config("rust_defaults") { group("gd_default_deps") { deps = [ "//bt/system:libbt-platform-protos-lite", - "//bt/system/gd:BluetoothGeneratedDumpsysDataSchema_h", - "//bt/system/gd/dumpsys:libbluetooth-dumpsys", "//bt/system/pdl:BluetoothGeneratedPackets_h", ] } @@ -56,7 +53,6 @@ group("gd_default_deps") { static_library("libbluetooth_gd") { sources = [ "module.cc", - "module_dumper.cc", "stack_manager.cc", ] @@ -65,7 +61,6 @@ static_library("libbluetooth_gd") { deps = [ "//bt/system/gd/rust/topshim:libbluetooth_topshim", "//bt/system/gd/common:BluetoothCommonSources", - "//bt/system/gd/dumpsys:BluetoothDumpsysSources", "//bt/system/gd/hal:BluetoothHalSources", "//bt/system/gd/hal:BluetoothHalSources_hci_host", "//bt/system/gd/hal:BluetoothHalSources_ranging_host", @@ -78,19 +73,3 @@ static_library("libbluetooth_gd") { "//bt/system/pdl:BluetoothGeneratedPackets_h", ] } - -flatbuffer("BluetoothGeneratedDumpsysDataSchema_h") { - sources = [ - "dumpsys_data.fbs", - "os/wakelock_manager.fbs", - ] -} - -bt_flatc_binary_schema("BluetoothGeneratedDumpsysBinarySchema_bfbs") { - sources = [ - "dumpsys_data.fbs", - "os/wakelock_manager.fbs", - ] - - include_dir = "system/gd" -} diff --git a/system/gd/dumpsys/Android.bp b/system/gd/dumpsys/Android.bp deleted file mode 100644 index 84074824ac..0000000000 --- a/system/gd/dumpsys/Android.bp +++ /dev/null @@ -1,212 +0,0 @@ -package { - // See: http://go/android-license-faq - // A large-scale-change added 'default_applicable_licenses' to import - // all of the 'license_kinds' from "system_bt_license" - // to get the below license kinds: - // SPDX-license-identifier-Apache-2.0 - default_applicable_licenses: ["system_bt_license"], -} - -filegroup { - name: "BluetoothDumpsysSources", - srcs: [ - "filter.cc", - "internal/filter_internal.cc", - "reflection_schema.cc", - ], -} - -filegroup { - name: "BluetoothDumpsysTestSources", - srcs: [ - "filter_test.cc", - "internal/filter_internal_test.cc", - "reflection_schema_test.cc", - ], -} - -genrule { - name: "BluetoothGeneratedDumpsysTestData_h", - tools: [ - "flatc", - ], - cmd: "$(location flatc) -I packages/modules/Bluetooth/system/gd -b --schema -o $(genDir) --cpp $(in) ", - srcs: [ - "test_data/bar.fbs", - "test_data/baz.fbs", - "test_data/foo.fbs", - "test_data/qux.fbs", - "test_data/root.fbs", - ], - out: [ - "bar_generated.h", - "baz_generated.h", - "foo_generated.h", - "qux_generated.h", - "root_generated.h", - ], -} - -genrule { - name: "BluetoothGeneratedDumpsysTestData_bfbs", - visibility: ["//visibility:private"], - tools: [ - "flatc", - ], - cmd: "$(location flatc) -I packages/modules/Bluetooth/system/gd -b --schema -o $(genDir) --cpp $(in) ", - srcs: [ - "test_data/bar.fbs", - "test_data/baz.fbs", - "test_data/foo.fbs", - "test_data/qux.fbs", - "test_data/root.fbs", - ], - out: [ - "bar.bfbs", - "baz.bfbs", - "foo.bfbs", - "qux.bfbs", - "root.bfbs", - ], -} - -genrule { - name: "BluetoothGeneratedDumpsysTestSchema_cc", - visibility: ["//visibility:private"], - tools: [ - "bluetooth_flatbuffer_bundler", - ], - cmd: "$(location bluetooth_flatbuffer_bundler) -w -m bluetooth.DumpsysData -f dumpsys_module_schema_data -n testing -g $(genDir) $(locations :BluetoothGeneratedDumpsysBinarySchema_bfbs)", - srcs: [ - ":BluetoothGeneratedDumpsysBinarySchema_bfbs", - ], - out: [ - "dumpsys_module_schema_data.cc", - ], -} - -genrule { - name: "BluetoothGeneratedDumpsysBundledSchema_cc", - visibility: ["//visibility:private"], - tools: [ - "bluetooth_flatbuffer_bundler", - ], - cmd: "$(location bluetooth_flatbuffer_bundler) -w -m bluetooth.DumpsysData -f generated_dumpsys_bundled_schema -n bluetooth::dumpsys -g $(genDir) $(locations :BluetoothGeneratedDumpsysBinarySchema_bfbs)", - srcs: [ - ":BluetoothGeneratedDumpsysBinarySchema_bfbs", - ], - out: [ - "generated_dumpsys_bundled_schema.cc", - ], -} - -genrule { - name: "BluetoothGeneratedDumpsysBundledTestSchema_cc", - visibility: ["//visibility:private"], - tools: [ - "bluetooth_flatbuffer_bundler", - ], - cmd: "$(location bluetooth_flatbuffer_bundler) -w -m testing.DumpsysTestDataRoot -f generated_dumpsys_bundled_test_schema -n testing -g $(genDir) $(locations :BluetoothGeneratedDumpsysTestData_bfbs)", - srcs: [ - ":BluetoothGeneratedDumpsysTestData_bfbs", - ], - out: [ - "generated_dumpsys_bundled_test_schema.cc", - ], -} - -genrule { - name: "BluetoothFlatbufferTestData_h", - tools: [ - "flatc", - ], - cmd: "$(location flatc) -I packages/modules/Bluetooth/system/gd -b --schema -o $(genDir) --cpp $(in) ", - srcs: [ - "bluetooth_flatbuffer_test.fbs", - ], - out: [ - "bluetooth_flatbuffer_test.bfbs", - "bluetooth_flatbuffer_test_generated.h", - ], -} - -genrule { - name: "BluetoothGeneratedDumpsysInternalTestData_h", - tools: [ - "flatc", - ], - cmd: "$(location flatc) --cpp -o $(genDir)/dumpsys/internal/test_data $(in)", - srcs: [ - "internal/test_data/float.fbs", - "internal/test_data/integer.fbs", - "internal/test_data/string.fbs", - "internal/test_data/struct.fbs", - ], - out: [ - "dumpsys/internal/test_data/float_generated.h", - "dumpsys/internal/test_data/integer_generated.h", - "dumpsys/internal/test_data/string_generated.h", - "dumpsys/internal/test_data/struct_generated.h", - ], -} - -cc_library { - name: "libbluetooth-dumpsys", - host_supported: true, - defaults: [ - "gd_defaults", - ], - generated_sources: [ - "BluetoothGeneratedDumpsysBundledSchema_cc", - ], - apex_available: [ - "com.android.btservices", - ], - min_sdk_version: "30", -} - -cc_library { - name: "libbluetooth-dumpsys-test", - host_supported: true, - defaults: [ - "gd_defaults", - ], - generated_sources: [ - "BluetoothGeneratedDumpsysBundledTestSchema_cc", - ], -} - -cc_library { - name: "libbluetooth-dumpsys-unittest", - host_supported: true, - defaults: [ - "gd_defaults", - ], - generated_headers: [ - "BluetoothGeneratedDumpsysTestSchema_cc", - ], -} - -cc_test { - name: "bluetooth_flatbuffer_tests", - test_suites: ["general-tests"], - defaults: [ - "bluetooth_cflags", - "mts_defaults", - ], - host_supported: true, - test_options: { - unit_test: true, - }, - static_libs: [ - "libflatbuffers-cpp", - "libgmock", - ], - srcs: [ - "bluetooth_flatbuffer_test.cc", - ], - generated_headers: [ - "BluetoothFlatbufferTestData_h", - ], - min_sdk_version: "30", -} diff --git a/system/gd/dumpsys/BUILD.gn b/system/gd/dumpsys/BUILD.gn deleted file mode 100644 index 327089c2ed..0000000000 --- a/system/gd/dumpsys/BUILD.gn +++ /dev/null @@ -1,43 +0,0 @@ -# -# Copyright 2021 Google, Inc. -# -# 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. - -import("//bt/system/gd/dumpsys/bundler/bundler.gni") - -source_set("BluetoothDumpsysSources") { - sources = [ - "filter.cc", - "internal/filter_internal.cc", - "reflection_schema.cc", - ] - - cflags_cc = [ "-Wno-enum-compare-switch" ] - - configs += [ - "//bt/system/gd:gd_defaults", - "//bt/system/log:log_defaults", - ] - deps = [ "//bt/system/gd:gd_default_deps" ] -} - -bt_flatc_bundler("libbluetooth-dumpsys") { - root_name = "bluetooth.DumpsysData" - filename = "generated_dumpsys_bundled_schema" - namespace = "bluetooth::dumpsys" - deps = [ "//bt/system/gd:BluetoothGeneratedDumpsysBinarySchema_bfbs" ] - configs = [ - "//bt/system/gd:gd_defaults", - "//bt/system/log:log_defaults", - ] -} diff --git a/system/gd/dumpsys/bluetooth_flatbuffer_test.cc b/system/gd/dumpsys/bluetooth_flatbuffer_test.cc deleted file mode 100644 index 7c77e1075d..0000000000 --- a/system/gd/dumpsys/bluetooth_flatbuffer_test.cc +++ /dev/null @@ -1,71 +0,0 @@ -/* - * Copyright 2020 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 <gmock/gmock.h> -#include <gtest/gtest.h> - -#include "bluetooth_flatbuffer_test_generated.h" -#include "flatbuffers/flatbuffers.h" -#include "flatbuffers/idl.h" -#include "flatbuffers/util.h" - -namespace bluetooth { -namespace dumpsys { - -class BluetoothFlatbufferTest : public ::testing::Test { -protected: - void SetUp() override {} - - void TearDown() override {} -}; - -TEST_F(BluetoothFlatbufferTest, precondition) {} - -TEST_F(BluetoothFlatbufferTest, BuilderTest) { - flatbuffers::FlatBufferBuilder builder(1024); - auto string_private = builder.CreateString("String private"); - auto string_opaque = builder.CreateString("String opaque"); - auto string_anonymized = builder.CreateString("String anonymized"); - auto string_any = builder.CreateString("String any"); - - TestTableBuilder table_builder(builder); - table_builder.add_string_private(string_private); - table_builder.add_string_opaque(string_opaque); - table_builder.add_string_anonymized(string_anonymized); - table_builder.add_string_any(string_any); - - table_builder.add_int_private(123); - table_builder.add_int_opaque(456); - table_builder.add_int_anonymized(789); - table_builder.add_int_any(0xabc); - - builder.Finish(table_builder.Finish()); - - const TestTable* test_table = GetTestTable(builder.GetBufferPointer()); - - ASSERT_EQ("String private", test_table->string_private()->str()); - ASSERT_EQ("String opaque", test_table->string_opaque()->str()); - ASSERT_EQ("String anonymized", test_table->string_anonymized()->str()); - ASSERT_EQ("String any", test_table->string_any()->str()); - - ASSERT_EQ(123, test_table->int_private()); - ASSERT_EQ(456, test_table->int_opaque()); - ASSERT_EQ(789, test_table->int_anonymized()); - ASSERT_EQ(0xabc, test_table->int_any()); -} - -} // namespace dumpsys -} // namespace bluetooth diff --git a/system/gd/dumpsys/bluetooth_flatbuffer_test.fbs b/system/gd/dumpsys/bluetooth_flatbuffer_test.fbs deleted file mode 100644 index f449813620..0000000000 --- a/system/gd/dumpsys/bluetooth_flatbuffer_test.fbs +++ /dev/null @@ -1,17 +0,0 @@ -// Bluetooth module test schema - -attribute "privacy"; - -table TestTable { - string_private:string; // no privacy attribute implies private - string_opaque:string (privacy:"Opaque"); - string_anonymized:string (privacy:"Anonymized"); - string_any:string (privacy:"Any"); - - int_private:int32 (privacy:"Private"); // Explicitly private - int_opaque:int32 (privacy:"Opaque"); - int_anonymized:int32 (privacy:"Anonymized"); - int_any:int32 (privacy:"Any"); -} - -root_type TestTable; diff --git a/system/gd/dumpsys/bundler/Android.bp b/system/gd/dumpsys/bundler/Android.bp deleted file mode 100644 index 301346ec6c..0000000000 --- a/system/gd/dumpsys/bundler/Android.bp +++ /dev/null @@ -1,91 +0,0 @@ -package { - // See: http://go/android-license-faq - // A large-scale-change added 'default_applicable_licenses' to import - // all of the 'license_kinds' from "system_bt_license" - // to get the below license kinds: - // SPDX-license-identifier-Apache-2.0 - default_applicable_licenses: ["system_bt_license"], -} - -filegroup { - name: "BluetoothFlatbufferBundlerSources", - visibility: ["//visibility:private"], - srcs: [ - "bundler.cc", - "main.cc", - ], -} - -filegroup { - name: "BluetoothFlatbufferBundlerTestSources", - visibility: ["//visibility:private"], - srcs: [ - "bundler.cc", - "test.cc", - ], -} - -// Flatbuffer bundler schema that wraps the bundled binary module schema -genrule { - name: "BluetoothGeneratedBundlerSchema_h_bfbs", - visibility: [ - "//packages/modules/Bluetooth/system/bta", - "//packages/modules/Bluetooth/system/btif", - "//packages/modules/Bluetooth/system/btm", - "//packages/modules/Bluetooth/system/gd", - "//packages/modules/Bluetooth/system/main", - "//packages/modules/Bluetooth/system/rust", - "//packages/modules/Bluetooth/system/stack", - ], - tools: [ - "flatc", - ], - cmd: "$(location flatc) -I packages/modules/Bluetooth/system/gd -b --schema -o $(genDir) --cpp $(in) ", - srcs: [ - "bundler_schema.fbs", - ], - out: [ - "bundler_schema.bfbs", - "bundler_schema_generated.h", - ], -} - -cc_defaults { - name: "bluetooth_flatbuffer_bundler_defaults", - defaults: ["bluetooth_cflags"], - generated_headers: [ - "BluetoothGeneratedBundlerSchema_h_bfbs", - ], - sanitize: { - misc_undefined: ["bounds"], - }, - static_libs: [ - "libflatbuffers-cpp", - ], -} - -cc_binary_host { - name: "bluetooth_flatbuffer_bundler", - srcs: [ - ":BluetoothFlatbufferBundlerSources", - ], - defaults: [ - "bluetooth_flatbuffer_bundler_defaults", - ], -} - -cc_test_host { - name: "bluetooth_flatbuffer_bundler_test", - srcs: [ - ":BluetoothFlatbufferBundlerTestSources", - ], - defaults: [ - "bluetooth_flatbuffer_bundler_defaults", - ], - data: [ - "test.bfbs", - ], - test_options: { - unit_test: true, - }, -} diff --git a/system/gd/dumpsys/bundler/BUILD.gn b/system/gd/dumpsys/bundler/BUILD.gn deleted file mode 100644 index 324afbb4f1..0000000000 --- a/system/gd/dumpsys/bundler/BUILD.gn +++ /dev/null @@ -1,50 +0,0 @@ -# -# Copyright 2021 Google, Inc. -# -# 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. - -import("//bt/system/gd/dumpsys/bundler/bundler.gni") -import("//common-mk/flatbuffer.gni") - -bt_flatc_binary_schema("BluetoothGeneratedBundlerSchema_h_bfbs") { - sources = [ "bundler_schema.fbs" ] - include_dir = "bt/system/gd" - gen_header = true -} - -# -# The remaining rules are for building on the host -# - -config("bundler_defaults") { - cflags = [ "-fPIC" ] - - cflags_cc = [ - "-std=c++17", - "-Wno-unused-variable", - "-Wno-poison-system-directories", - ] -} - -executable("bluetooth_flatbuffer_bundler") { - sources = [ - "bundler.cc", - "main.cc", - ] - - libs = [ "flatbuffers" ] - - deps = [ ":BluetoothGeneratedBundlerSchema_h_bfbs" ] - - configs += [ ":bundler_defaults" ] -} diff --git a/system/gd/dumpsys/bundler/bundler.cc b/system/gd/dumpsys/bundler/bundler.cc deleted file mode 100644 index 72097ac101..0000000000 --- a/system/gd/dumpsys/bundler/bundler.cc +++ /dev/null @@ -1,322 +0,0 @@ -/* - * Copyright 2020 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 "bundler.h" - -#include <assert.h> -#include <stdlib.h> -#include <unistd.h> - -#include <cassert> -#include <list> -#include <map> -#include <vector> - -#include "bundler_schema_generated.h" -#include "flatbuffers/idl.h" -#include "flatbuffers/util.h" - -// TODO(b/369381361) Enfore -Wmissing-prototypes -#pragma GCC diagnostic ignored "-Wmissing-prototypes" - -using namespace bluetooth; -using namespace dumpsys; - -struct Opts opts; - -/** - * Load a binary schema from persistent store using flatbuffer API. - * - * @param filename; Name of file to open and read. - * @param binary_schema: Backing store for flatbuffer binary schema data. - * - * @return: True if operation successful, false otherwise. - */ -bool LoadBinarySchema(const char* filename, std::string* binary_schema) { - assert(filename != nullptr); - assert(binary_schema != nullptr); - if (!flatbuffers::LoadFile(filename, helper::AsBinaryFile, binary_schema)) { - fprintf(stderr, "Unable to open binary flatbuffer schema file:%s\n", filename); - return false; - }; - return true; -} - -/** - * Verify a binary schema using flatbuffer API. - * - * @param schema: Raw binary schema to verify - * - * @return: True if operation successful, false otherwise. - */ -bool VerifyBinarySchema(const std::vector<uint8_t>& raw_schema) { - flatbuffers::Verifier verifier(raw_schema.data(), raw_schema.size()); - if (!reflection::VerifySchemaBuffer(verifier)) { - return false; - } - return true; -} - -/** - * Bundle a set of binary flatbuffer schema into the bundler database. - * - * @param builder; Flatbuffer builder - * @param filenames: Set of filenames to include in bundle - * @param vector_map: Filename to filedata mapping - * - * @return: True if operation successful, false otherwise. - */ -bool CreateBinarySchemaBundle(flatbuffers::FlatBufferBuilder* builder, - const std::vector<std::string>& filenames, - std::vector<flatbuffers::Offset<BundledSchemaMap>>* vector_map, - std::list<std::string>* bundled_names) { - assert(builder != nullptr); - assert(vector_map != nullptr); - assert(bundled_names != nullptr); - - for (auto filename : filenames) { - std::string string_schema; - if (!LoadBinarySchema(filename.c_str(), &string_schema)) { - fprintf(stderr, "Unable to load binary schema from filename:%s\n", filename.c_str()); - return false; - } - std::vector<uint8_t> raw_schema(string_schema.begin(), string_schema.end()); - if (!VerifyBinarySchema(raw_schema)) { - fprintf(stderr, "Failed verification on binary schema filename:%s\n", filename.c_str()); - return false; - } - - const reflection::Schema* schema = reflection::GetSchema(raw_schema.data()); - if (schema->root_table() == nullptr) { - fprintf(stderr, "Unable to find root table for binary flatbuffer schema:%s\n", - filename.c_str()); - return false; - } - - bundled_names->push_back(schema->root_table()->name()->str()); - auto name = builder->CreateString(schema->root_table()->name()->str()); - auto data = builder->CreateVector<uint8_t>(raw_schema.data(), raw_schema.size()); - vector_map->push_back(CreateBundledSchemaMap(*builder, name, data)); - - if (opts.verbose) { - fprintf(stdout, "Bundled binary schema file:%s\n", schema->root_table()->name()->c_str()); - } - } - return true; -} - -/** - * Write generated header file containing the bundled binary schema - * data and meta data - * - * @param data: Source file data. - * @param data_len: length of data - */ -void WriteHeaderFile(FILE* fp, const uint8_t* data, size_t data_len) { - assert(fp != nullptr); - std::string delim(kDefaultNamespaceDelim); - std::string ns_string(opts.ns_name); - std::vector<std::string> namespaces; - - size_t start = 0; - size_t end = ns_string.find(delim); - while (end != std::string::npos) { - namespaces.push_back(ns_string.substr(start, end - start)); - start = end + delim.size(); - end = ns_string.find(delim, start); - } - if (start != 0 && start != std::string::npos) { - namespaces.push_back(ns_string.substr(start)); - } else if (!ns_string.empty()) { - namespaces.push_back(ns_string); - } - - std::string namespace_prefix; - for (const auto& name : namespaces) { - namespace_prefix += (name + '_'); - } - - fprintf(fp, - "// Generated file by bluetooth_flatbuffer bundler\n" - "#include <string>\n"); - for_each(namespaces.begin(), namespaces.end(), - [fp](const std::string& s) { fprintf(fp, "namespace %s {\n", s.c_str()); }); - fprintf(fp, "extern const std::string& GetBundledSchemaData();\n"); - fprintf(fp, "const unsigned char %sdata_[%zu] = {\n", namespace_prefix.c_str(), data_len); - - for (size_t i = 0; i < data_len; i++) { - fprintf(fp, " 0x%02x", data[i]); - if (i != data_len - 1) { - fprintf(fp, ","); - } - if ((i + 1) % 16 == 0) { - fprintf(fp, "\n"); - } - } - fprintf(fp, " };\n"); - fprintf(fp, "const std::string %sstring_data_(%sdata_, %sdata_ + sizeof(%sdata_));\n", - namespace_prefix.c_str(), namespace_prefix.c_str(), namespace_prefix.c_str(), - namespace_prefix.c_str()); - fprintf(fp, "const std::string& GetBundledSchemaData() { return %sstring_data_; }\n", - namespace_prefix.c_str()); - - for_each(namespaces.crbegin(), namespaces.crend(), - [fp](const std::string& s) { fprintf(fp, "} // namespace %s\n", s.c_str()); }); -} - -int ReadBundledSchema() { - const char* filename = opts.filename; - assert(filename != nullptr); - - std::string flatfile_data; - if (!flatbuffers::LoadFile(filename, helper::AsBinaryFile, &flatfile_data)) { - fprintf(stderr, "Unable to load schema data file:%s\n", filename); - return -5; - } - - auto bundle_schema = flatbuffers::GetRoot<BundledSchema>(flatfile_data.c_str()); - const flatbuffers::Vector<flatbuffers::Offset<BundledSchemaMap>>* map = bundle_schema->map(); - - fprintf(stdout, "Bundle schema title:%s\n", bundle_schema->title()->c_str()); - fprintf(stdout, "Bundle schema root_name:%s\n", bundle_schema->root_name()->c_str()); - int cnt = 0; - for (auto it = map->cbegin(); it != map->cend(); ++it, cnt++) { - fprintf(stdout, " %d name:%s schema:%s\n", cnt, it->name()->c_str(), "schema"); - } - return EXIT_SUCCESS; -} - -int WriteBundledSchema() { - const char* filename = opts.filename; - assert(filename != nullptr); - - const char* main_root_name = opts.main_root_name; - if (main_root_name == nullptr) { - fprintf(stderr, "Must specify the name of the main root name for this bundle\n"); - return EXIT_FAILURE; - } - - std::vector<std::string> bfbs_filenames; - for (int i = 0; i < opts.arg.c; i++) { - bfbs_filenames.push_back(std::string(opts.arg.v[i])); - } - if (bfbs_filenames.empty()) { - fprintf(stderr, "No bfbs files are specified to bundle\n"); - return EXIT_FAILURE; - } - - flatbuffers::FlatBufferBuilder builder(1024); - - std::list<std::string> bundled_names; - std::vector<flatbuffers::Offset<BundledSchemaMap>> vector_map; - if (!CreateBinarySchemaBundle(&builder, bfbs_filenames, &vector_map, &bundled_names)) { - fprintf(stderr, "Unable to bundle schema bfbs files\n"); - return EXIT_FAILURE; - } - - if (std::find(bundled_names.begin(), bundled_names.end(), main_root_name) == - bundled_names.end()) { - fprintf(stderr, "The main root name must match one of the bundled schema names\n"); - fprintf(stderr, " main root name:%s\n", main_root_name); - for (auto name : bundled_names) { - fprintf(stderr, " bundled schema name:%s\n", name.c_str()); - } - return EXIT_FAILURE; - } - - const char* title = opts.title; - auto schema_offset = CreateBundledSchemaDirect(builder, title, main_root_name, &vector_map); - builder.Finish(schema_offset); - - std::string final_filename(opts.gen); - final_filename.append("/"); - final_filename.append(filename); - if (!flatbuffers::SaveFile(final_filename.c_str(), (const char*)builder.GetBufferPointer(), - builder.GetSize(), helper::AsBinaryFile)) { - fprintf(stderr, "Unable to save file:%s\n", final_filename.c_str()); - return EXIT_FAILURE; - } - - std::string header(opts.gen); - header += ("/" + std::string(opts.filename) + ".cc"); - FILE* fp = fopen(header.c_str(), "w+"); - if (fp == nullptr) { - fprintf(stdout, "Unable to open for writing header file:%s\n", header.c_str()); - return EXIT_FAILURE; - } - WriteHeaderFile(fp, builder.GetBufferPointer(), builder.GetSize()); - fclose(fp); - return EXIT_SUCCESS; -} - -int Usage(int /*argc*/, char** argv) { - fprintf(stderr, - "Usage: %s [-r | -w] [-f <filename>] [-g <gen_out_path>] [-n <namespace> ] [-v] -m " - "<main_root_name> <file.bfbs " - "...>\n", - argv[0]); - fprintf(stderr, " -r|-w : Read or write a dumpsys file\n"); - fprintf(stderr, " -f : Filename bundled schema to read or write (default:%s)\n", - kDefaultBundleDataFile); - fprintf(stderr, " -g : Generated file output path\n"); - fprintf(stderr, " -n : Namespace to embed binary output bundle data source\n"); - fprintf(stderr, " -m : Name of the main root of this bundle\n"); - fprintf(stderr, " -v : Verbose printing mode\n"); - return EXIT_FAILURE; -} - -void ParseArgs(int argc, char** argv) { - int opt; - int parsed_cnt = 1; - while ((opt = getopt(argc, argv, "f:g:m:n:rt:vw")) != -1) { - parsed_cnt++; - switch (opt) { - case 'f': - opts.filename = optarg; - parsed_cnt++; - break; - case 'g': - opts.gen = optarg; - parsed_cnt++; - break; - case 'm': - opts.main_root_name = optarg; - parsed_cnt++; - break; - case 'n': - opts.ns_name = optarg; - parsed_cnt++; - break; - case 'r': - opts.read = true; - break; - case 'w': - opts.write = true; - break; - case 't': - opts.title = optarg; - parsed_cnt++; - break; - case 'v': - opts.verbose = true; - break; - default: - exit(Usage(argc, argv)); - break; - } - } - opts.arg.c = argc - parsed_cnt; - opts.arg.v = &argv[parsed_cnt]; -} diff --git a/system/gd/dumpsys/bundler/bundler.h b/system/gd/dumpsys/bundler/bundler.h deleted file mode 100644 index 9dc4b243d2..0000000000 --- a/system/gd/dumpsys/bundler/bundler.h +++ /dev/null @@ -1,71 +0,0 @@ -/* - * Copyright 2020 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 { -constexpr char kDefaultBundleDataFile[] = "bundle_bfbs.bin"; -constexpr char kDefaultGeneratedOutputPath[] = "."; -constexpr char kDefaultNamespace[] = ""; -constexpr char kDefaultNamespaceDelim[] = "::"; -constexpr char kDefaultTitle[] = "Bundled schema tables"; -} // namespace - -struct Opts { - bool verbose{false}; - bool read{false}; - bool write{false}; - const char* filename{kDefaultBundleDataFile}; - const char* gen{kDefaultGeneratedOutputPath}; - const char* main_root_name{nullptr}; - const char* ns_name{kDefaultNamespace}; - const char* title{kDefaultTitle}; - struct { - int c{0}; - char** v{nullptr}; - } arg; -}; -extern Opts opts; - -namespace { -namespace helper { // Part of flatbuffers API -constexpr bool AsBinaryFile = true; -constexpr bool AsTextFile = false; -} // namespace helper - -} // namespace - -/** - * Read and parse a previously generated bundle data file - * - **/ -int ReadBundledSchema(); - -/** - * Generate a bundle data file from the binary flatbuffer schema - * files provided as input - * - **/ -int WriteBundledSchema(); - -/** - * Print tool usage options - */ -int Usage(int argc, char** argv); - -/** - * Parse tool usage options - */ -void ParseArgs(int argc, char** argv); diff --git a/system/gd/dumpsys/bundler/bundler_schema.fbs b/system/gd/dumpsys/bundler/bundler_schema.fbs deleted file mode 100644 index a11fb7f150..0000000000 --- a/system/gd/dumpsys/bundler/bundler_schema.fbs +++ /dev/null @@ -1,19 +0,0 @@ -// Bundled Schema -// -// Describes a collection of binary flatbuffer schema. -// - -namespace bluetooth.dumpsys; - -table BundledSchemaMap { - name:string; - data:[ubyte]; -} - -table BundledSchema { - title:string; - root_name:string; - map:[BundledSchemaMap]; -} - -root_type BundledSchema; diff --git a/system/gd/dumpsys/bundler/extract_files_and_call.py b/system/gd/dumpsys/bundler/extract_files_and_call.py deleted file mode 100755 index df0415f611..0000000000 --- a/system/gd/dumpsys/bundler/extract_files_and_call.py +++ /dev/null @@ -1,58 +0,0 @@ -#!/usr/bin/env python3 -# -*- coding: utf-8 -*- -# -# Copyright 2021 Google, Inc. -# -# 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. -""" Get contents of given files and pass as args to remaining params. - -Example: - a.files = [ "foo", "bar" ] - b.files = [ "fizz", "buzz" ] - - extract_files_and_call.py a.files b.files -- somebin -a --set foo -c -o - - will result in this call: - - somebin -a --set foo -c -o foo bar fizz buzz - -""" - -from __future__ import print_function - -import subprocess -import sys - - -def file_to_args(filename): - """ Read file and return lines with empties removed. - """ - with open(filename, 'r') as f: - return [x.strip() for x in f.readlines() if x.strip()] - - -def main(): - file_contents = [] - args = [] - for i in range(1, len(sys.argv) - 1): - if sys.argv[i] == '--': - args = sys.argv[i + 1:] + file_contents - break - else: - file_contents.extend(file_to_args(sys.argv[i])) - - subprocess.check_call(args) - - -if __name__ == "__main__": - main() diff --git a/system/gd/dumpsys/bundler/main.cc b/system/gd/dumpsys/bundler/main.cc deleted file mode 100644 index e040ef2b8e..0000000000 --- a/system/gd/dumpsys/bundler/main.cc +++ /dev/null @@ -1,27 +0,0 @@ -/* - * Copyright 2020 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 "bundler.h" -#include "bundler_schema_generated.h" - -int main(int argc, char** argv) { - ParseArgs(argc, argv); - if (opts.read) { - exit(ReadBundledSchema()); - } - if (opts.write) { - exit(WriteBundledSchema()); - } -} diff --git a/system/gd/dumpsys/bundler/test.bfbs b/system/gd/dumpsys/bundler/test.bfbs Binary files differdeleted file mode 100644 index 0dda6e54f8..0000000000 --- a/system/gd/dumpsys/bundler/test.bfbs +++ /dev/null diff --git a/system/gd/dumpsys/bundler/test.cc b/system/gd/dumpsys/bundler/test.cc deleted file mode 100644 index eebd2eacbb..0000000000 --- a/system/gd/dumpsys/bundler/test.cc +++ /dev/null @@ -1,89 +0,0 @@ -/* - * Copyright 2020 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 <gtest/gtest.h> - -#include <list> -#include <vector> - -#include "bundler.h" -#include "bundler_schema_generated.h" -#include "flatbuffers/flatbuffers.h" - -// Must be run from the same directory as the test data 'test.bfbs'. -// This is how the presubmit unit test pipeline functions. -constexpr char kTestFilename[] = "test.bfbs"; - -bool LoadBinarySchema(const char* filename, std::string* binary_schema); -bool VerifyBinarySchema(const std::vector<uint8_t>& raw_schema); -bool CreateBinarySchemaBundle( - flatbuffers::FlatBufferBuilder* builder, const std::vector<std::string>& filenames, - std::vector<flatbuffers::Offset<bluetooth::dumpsys::BundledSchemaMap>>* vector_map, - std::list<std::string>* bundled_names); -int WriteHeaderFile(FILE* fp, const uint8_t* data, size_t data_len); - -class BundlerTest : public ::testing::Test { -public: - void SetUp() override {} - - void TearDown() override {} -}; - -TEST_F(BundlerTest, LoadBinarySchema) { - std::string string_schema; - ASSERT_FALSE(LoadBinarySchema(nullptr, &string_schema)); - ASSERT_DEATH(LoadBinarySchema(kTestFilename, nullptr), ""); - ASSERT_TRUE(LoadBinarySchema(kTestFilename, &string_schema)); - ASSERT_FALSE(LoadBinarySchema("does_not_exist.bfbs", &string_schema)); -} - -TEST_F(BundlerTest, VerifyBinarySchema) { - std::string string_schema; - ASSERT_TRUE(LoadBinarySchema(kTestFilename, &string_schema)); - std::vector<uint8_t> raw_schema(string_schema.begin(), string_schema.end()); - ASSERT_TRUE(VerifyBinarySchema(raw_schema)); - - std::vector<uint8_t> bogus_raw_schema(string_schema.begin() + 1, string_schema.end()); - ASSERT_FALSE(VerifyBinarySchema(bogus_raw_schema)); -} - -TEST_F(BundlerTest, CreateBinarySchemaBundle) { - flatbuffers::FlatBufferBuilder builder; - std::vector<std::string> filenames; - std::vector<flatbuffers::Offset<bluetooth::dumpsys::BundledSchemaMap>> vector_map; - std::list<std::string> bundled_names; - ASSERT_TRUE(CreateBinarySchemaBundle(&builder, filenames, &vector_map, &bundled_names)); - ASSERT_EQ((unsigned int)0, vector_map.size()); -} - -TEST_F(BundlerTest, WriteHeaderFile) { - std::vector<uint8_t> data; - data.push_back(0x10); - data.push_back(0x11); - data.push_back(0x12); - data.push_back(0x13); - ASSERT_DEATH(WriteHeaderFile(nullptr, data.data(), data.size()), ""); - FILE* fp = fopen("/tmp/test.h", "w+"); - ASSERT_NE(fp, nullptr); - WriteHeaderFile(fp, data.data(), data.size()); - fseek(fp, 0L, SEEK_SET); - char buf[16]; - fread(buf, 1, 15, fp); - buf[12] = '\0'; - std::string s(buf); - ASSERT_EQ("// Generated", s); - fclose(fp); - unlink("/tmp/test.h"); -} diff --git a/system/gd/dumpsys/dumpsys.h b/system/gd/dumpsys/dumpsys.h deleted file mode 100644 index 6d2cafd465..0000000000 --- a/system/gd/dumpsys/dumpsys.h +++ /dev/null @@ -1,24 +0,0 @@ -/* - * 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. - */ - -#pragma once -#include <string> - -namespace bluetooth { -namespace dumpsys { -const std::string& GetBundledSchemaData(); -} // namespace dumpsys -} // namespace bluetooth diff --git a/system/gd/dumpsys/dumpsys_test_data.h b/system/gd/dumpsys/dumpsys_test_data.h deleted file mode 100644 index 763d702f48..0000000000 --- a/system/gd/dumpsys/dumpsys_test_data.h +++ /dev/null @@ -1,22 +0,0 @@ -/* - * 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. - */ - -#pragma once -#include <string> - -namespace testing { -const std::string& GetBundledSchemaData(); -} // namespace testing diff --git a/system/gd/dumpsys/filter.cc b/system/gd/dumpsys/filter.cc deleted file mode 100644 index 13cd2e5adf..0000000000 --- a/system/gd/dumpsys/filter.cc +++ /dev/null @@ -1,95 +0,0 @@ -/* - * Copyright 2020 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 "dumpsys/filter.h" - -#include <bluetooth/log.h> - -#include <memory> - -using namespace bluetooth; -using namespace dumpsys; - -class Filter { -public: - Filter(const dumpsys::ReflectionSchema& reflection_schema) - : reflection_schema_(reflection_schema) {} - - virtual ~Filter() = default; - - virtual void FilterInPlace(char* dumpsys_data) = 0; - - static std::unique_ptr<Filter> Factory(const dumpsys::ReflectionSchema& reflection_schema); - -protected: - /** - * Given both reflection field data and the populated flatbuffer table data, if any, - * filter the contents of the field based upon the filtering privacy level. - * - * Primitives and composite strings may be successfully processed at this point. - * Other composite types (e.g. structs or tables) must be expanded into the - * respective grouping of subfields. - * - * @param field The reflection field information from the bundled schema - * @param table The populated field data, if any - * - * @return true if field was filtered successfully, false otherwise. - */ - virtual bool FilterField(const reflection::Field* /* field */, flatbuffers::Table* /* table */) { - return false; - } - - /** - * Given both reflection object data and the populated flatbuffer table data, if any, - * filter the object fields based upon the filtering privacy level. - * - * @param object The reflection object information from the bundled schema - * @param table The populated field data, if any - * - */ - virtual void FilterObject(const reflection::Object* /* object */, - flatbuffers::Table* /* table */) {} - - /** - * Given both reflection field data and the populated table data, if any, - * filter the contents of the table based upon the filtering privacy level. - * - * @param schema The reflection schema information from the bundled schema - * @param table The populated field data, if any - * - */ - virtual void FilterTable(const reflection::Schema* /* schema */, - flatbuffers::Table* /* table */) {} - - const dumpsys::ReflectionSchema& reflection_schema_; -}; - -class DeveloperPrivacyFilter : public Filter { -public: - DeveloperPrivacyFilter(const dumpsys::ReflectionSchema& reflection_schema) - : Filter(reflection_schema) {} - void FilterInPlace(char* /* dumpsys_data */) override { /* Nothing to do in this mode */ } -}; - -std::unique_ptr<Filter> Filter::Factory(const dumpsys::ReflectionSchema& reflection_schema) { - return std::make_unique<DeveloperPrivacyFilter>(reflection_schema); -} - -void bluetooth::dumpsys::FilterSchema(const ReflectionSchema& reflection_schema, - std::string* dumpsys_data) { - auto filter = Filter::Factory(reflection_schema); - filter->FilterInPlace(dumpsys_data->data()); -} diff --git a/system/gd/dumpsys/filter.h b/system/gd/dumpsys/filter.h deleted file mode 100644 index b932b4c6bf..0000000000 --- a/system/gd/dumpsys/filter.h +++ /dev/null @@ -1,27 +0,0 @@ -/* - * Copyright 2020 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 <string> - -#include "dumpsys/reflection_schema.h" - -namespace bluetooth { -namespace dumpsys { - -void FilterSchema(const ReflectionSchema& reflection_schema, std::string* dumpsys_data); - -} // namespace dumpsys -} // namespace bluetooth diff --git a/system/gd/dumpsys/filter_test.cc b/system/gd/dumpsys/filter_test.cc deleted file mode 100644 index a1678ec373..0000000000 --- a/system/gd/dumpsys/filter_test.cc +++ /dev/null @@ -1,122 +0,0 @@ -/* - * Copyright 2020 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 "dumpsys/filter.h" - -#include <gmock/gmock.h> -#include <gtest/gtest.h> - -#include <list> -#include <queue> - -#include "dumpsys/dumpsys_test_data.h" -#include "test_data/bar.h" -#include "test_data/baz.h" -#include "test_data/foo.h" -#include "test_data/qux.h" -#include "test_data/root.h" - -using namespace bluetooth; - -namespace testing { - -class DumpsysFilterTest : public Test { -protected: - void SetUp() override { - test_data_classes_.push_back(std::make_unique<BarTestDataClass>()); - test_data_classes_.push_back(std::make_unique<BazTestDataClass>()); - test_data_classes_.push_back(std::make_unique<FooTestDataClass>()); - test_data_classes_.push_back(std::make_unique<QuxTestDataClass>()); - } - - void TearDown() override {} - - std::list<std::unique_ptr<DumpsysTestDataClass>> test_data_classes_; - - std::string PopulateTestSchema(); -}; - -std::string DumpsysFilterTest::PopulateTestSchema() { - flatbuffers::FlatBufferBuilder fb_builder(1024); - - auto string_private = fb_builder.CreateString("String private"); - auto string_opaque = fb_builder.CreateString("String opaque"); - auto string_anonymized = fb_builder.CreateString("String anonymized"); - auto string_any = fb_builder.CreateString("String any"); - - std::queue<TableAddFunction> queue; - for (auto& test_data_class : test_data_classes_) { - queue.push(test_data_class->GetTable(fb_builder)); - } - - testing::DumpsysTestDataRootBuilder builder(fb_builder); - - builder.add_string_private(string_private); - builder.add_string_opaque(string_opaque); - builder.add_string_anonymized(string_anonymized); - builder.add_string_any(string_any); - - builder.add_int_private(123); - builder.add_int_opaque(456); - builder.add_int_anonymized(789); - builder.add_int_any(0xabc); - - while (!queue.empty()) { - queue.front()(&builder); - queue.pop(); - } - fb_builder.Finish(builder.Finish()); - - return std::string(fb_builder.GetBufferPointer(), - fb_builder.GetBufferPointer() + fb_builder.GetSize()); -} - -TEST_F(DumpsysFilterTest, filter_as_developer) { - std::string dumpsys_data = PopulateTestSchema(); - dumpsys::ReflectionSchema reflection_schema(testing::GetBundledSchemaData()); - - dumpsys::FilterSchema(reflection_schema, &dumpsys_data); - - const testing::DumpsysTestDataRoot* data_root = GetDumpsysTestDataRoot(dumpsys_data.data()); - - ASSERT_EQ("String private", data_root->string_private()->str()); - ASSERT_EQ("String opaque", data_root->string_opaque()->str()); - ASSERT_EQ("String anonymized", data_root->string_anonymized()->str()); - ASSERT_EQ("String any", data_root->string_any()->str()); - - ASSERT_EQ(123, data_root->int_private()); - ASSERT_EQ(456, data_root->int_opaque()); - ASSERT_EQ(789, data_root->int_anonymized()); - ASSERT_EQ(0xabc, data_root->int_any()); - - ASSERT_EQ(nullptr, data_root->bar_module_data()); - - const testing::FooTestSchema* foo = data_root->foo_module_data(); - - ASSERT_EQ(123, foo->foo_int_private()); - ASSERT_EQ(123, foo->foo_int_opaque()); - ASSERT_EQ(123, foo->foo_int_anonymized()); - ASSERT_EQ(123, foo->foo_int_any()); - ASSERT_STREQ("123", foo->foo_int_string()->c_str()); - - ASSERT_FLOAT_EQ(123.456, foo->foo_float_private()); - ASSERT_FLOAT_EQ(123.456, foo->foo_float_opaque()); - ASSERT_FLOAT_EQ(123.456, foo->foo_float_anonymized()); - ASSERT_FLOAT_EQ(123.456, foo->foo_float_any()); - ASSERT_STREQ("123.456", foo->foo_float_string()->c_str()); -} - -} // namespace testing diff --git a/system/gd/dumpsys/internal/filter_internal.cc b/system/gd/dumpsys/internal/filter_internal.cc deleted file mode 100644 index 2db2878f95..0000000000 --- a/system/gd/dumpsys/internal/filter_internal.cc +++ /dev/null @@ -1,289 +0,0 @@ -/* - * Copyright 2020 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 "dumpsys/internal/filter_internal.h" - -#include <bluetooth/log.h> - -#include <algorithm> -#include <string> - -#include "flatbuffers/flatbuffers.h" -#include "flatbuffers/idl.h" - -#define DBG 0 - -using namespace bluetooth; -using namespace dumpsys; - -constexpr flatbuffers::voffset_t kErasedFromTable = 0; -constexpr bool kFieldIsNotPopulated = true; -constexpr bool kFieldHasBeenFiltered = true; -constexpr bool kFieldContinueFiltering = false; - -void internal::ScrubFromTable(flatbuffers::Table* table, flatbuffers::voffset_t field_offset) { - log::assert_that(table != nullptr, "assert failed: table != nullptr"); - uint8_t* vtable = const_cast<uint8_t*>(table->GetVTable()); - vtable[field_offset] = kErasedFromTable; -} - -void internal::ReplaceInString(flatbuffers::String* string, int c) { - uint8_t* p = const_cast<uint8_t*>(string->Data()); - memset(p, c, string->size()); -} - -void internal::RandomizeInString(flatbuffers::String* string) { - std::size_t hash = std::hash<std::string>{}(string->str()); - std::string hashed_string = std::to_string(hash); - ReplaceInString(string, ' '); - size_t len = std::min(static_cast<size_t>(string->size()), hashed_string.size()); - uint8_t* p = const_cast<uint8_t*>(string->Data()); - memcpy(p, hashed_string.c_str(), len); -} - -const char* internal::PrivacyLevelName(PrivacyLevel privacy_level) { - switch (privacy_level) { - case kPrivate: - return "Private"; - break; - case kOpaque: - return "Opaque"; - break; - case kAnonymized: - return "Anonymized"; - break; - case kAny: - return "Any"; - break; - } -} -internal::PrivacyLevel internal::GetPrivacyLevelAttribute(const std::string& string) { - if (string == "Any") { - return kAny; - } else if (string == "Anonymized") { - return kAnonymized; - } else if (string == "Opaque") { - return kOpaque; - } else if (string == "Private") { - return kPrivate; - } - return kDefaultPrivacyLevel; -} - -internal::PrivacyLevel internal::FindFieldPrivacyLevel(const reflection::Field& field) { - PrivacyLevel privacy_level = kDefaultPrivacyLevel; - - if (field.attributes() != nullptr) { - auto key = field.attributes()->LookupByKey(kPrivacyAttributeKeyword); - if (key != nullptr) { - privacy_level = internal::GetPrivacyLevelAttribute(key->value()->str()); - } - } - return privacy_level; -} - -const reflection::Object* internal::FindReflectionObject( - const flatbuffers::Vector<flatbuffers::Offset<reflection::Object>>* objects, - const flatbuffers::String* name) { - log::assert_that(objects != nullptr, "assert failed: objects != nullptr"); - log::assert_that(name != nullptr, "assert failed: name != nullptr"); - for (auto it = objects->cbegin(); it != objects->cend(); ++it) { - if (it->name()->str() == name->str()) { - return *it; - } - } - return nullptr; -} - -bool internal::FilterTypeBool(const reflection::Field& field, flatbuffers::Table* table, - PrivacyLevel privacy_level) { - log::assert_that(table != nullptr, "assert failed: table != nullptr"); - - const bool default_val = flatbuffers::GetFieldDefaultI<int8_t>(field); - flatbuffers::voffset_t field_offset = field.offset(); - - // boolean privacy levels are simpler. - switch (privacy_level) { - case kPrivate: - case kOpaque: - case kAnonymized: - flatbuffers::SetField<int8_t>(table, field, default_val); - internal::ScrubFromTable(table, field_offset); - break; - default: - case kAny: - break; - } - return kFieldHasBeenFiltered; -} - -bool internal::FilterTypeInteger(const reflection::Field& field, flatbuffers::Table* table, - PrivacyLevel privacy_level) { - log::assert_that(table != nullptr, "assert failed: table != nullptr"); - log::assert_that(flatbuffers::IsInteger(field.type()->base_type()), - "assert failed: flatbuffers::IsInteger(field.type()->base_type())"); - - int32_t default_val = flatbuffers::GetFieldDefaultI<int32_t>(field); - flatbuffers::voffset_t field_offset = field.offset(); - [[maybe_unused]] int32_t val = table->GetField<int32_t>(field_offset, default_val); - - switch (privacy_level) { - case kPrivate: - flatbuffers::SetField<int32_t>(table, field, default_val); - internal::ScrubFromTable(table, field_offset); - break; - case kOpaque: - flatbuffers::SetField<int32_t>(table, field, default_val); - break; - case kAnonymized: { - auto target_field = flatbuffers::GetFieldI<int32_t>(*table, field); - int32_t new_val = - static_cast<int32_t>(std::hash<std::string>{}(std::to_string(target_field))); - flatbuffers::SetField<int32_t>(table, field, new_val); - } break; - default: - case kAny: - break; - } - - if (DBG) { - log::info("Integer Field_name:{} privacy_level:{} old_value:{} / 0x{:x} ==> new_value:{}", - field.name()->c_str(), PrivacyLevelName(privacy_level), val, val, - table->GetField<int32_t>(field_offset, default_val)); - } - return kFieldHasBeenFiltered; -} - -bool internal::FilterTypeFloat(const reflection::Field& field, flatbuffers::Table* table, - PrivacyLevel privacy_level) { - log::assert_that(table != nullptr, "assert failed: table != nullptr"); - log::assert_that(flatbuffers::IsFloat(field.type()->base_type()), - "assert failed: flatbuffers::IsFloat(field.type()->base_type())"); - - float default_val = flatbuffers::GetFieldDefaultI<float>(field); - flatbuffers::voffset_t field_offset = field.offset(); - [[maybe_unused]] float val = table->GetField<float>(field_offset, default_val); - switch (privacy_level) { - case kPrivate: - flatbuffers::SetField<float>(table, field, default_val); - internal::ScrubFromTable(table, field_offset); - break; - case kOpaque: - flatbuffers::SetField<float>(table, field, default_val); - break; - case kAnonymized: { - auto target_field = flatbuffers::GetFieldF<float>(*table, field); - int32_t new_val = static_cast<float>(std::hash<std::string>{}(std::to_string(target_field))); - flatbuffers::SetField<float>(table, field, new_val); - } break; - default: - case kAny: - break; - } - if (DBG) { - log::info("Float Field_name:{} privacy_level:{} old_value:{:f} ==> new_value:{:f}", - field.name()->c_str(), PrivacyLevelName(privacy_level), val, - table->GetField<float>(field_offset, default_val)); - } - return kFieldHasBeenFiltered; -} - -bool internal::FilterTypeLong(const reflection::Field& field, flatbuffers::Table* table, - PrivacyLevel privacy_level) { - log::assert_that(table != nullptr, "assert failed: table != nullptr"); - - const int64_t default_val = flatbuffers::GetFieldDefaultI<int64_t>(field); - flatbuffers::voffset_t field_offset = field.offset(); - - switch (privacy_level) { - case kPrivate: - flatbuffers::SetField<int64_t>(table, field, default_val); - internal::ScrubFromTable(table, field_offset); - break; - case kOpaque: - flatbuffers::SetField<int64_t>(table, field, default_val); - break; - case kAnonymized: { - auto target_field = flatbuffers::GetFieldI<int64_t>(*table, field); - int64_t new_val = - static_cast<int64_t>(std::hash<std::string>{}(std::to_string(target_field))); - flatbuffers::SetField<int64_t>(table, field, new_val); - } break; - default: - case kAny: - break; - } - return kFieldHasBeenFiltered; -} - -bool internal::FilterTypeString(const reflection::Field& field, flatbuffers::Table* table, - PrivacyLevel privacy_level) { - log::assert_that(table != nullptr, "assert failed: table != nullptr"); - log::assert_that(field.type()->base_type() == reflection::BaseType::String, - "assert failed: field.type()->base_type() == reflection::BaseType::String"); - - flatbuffers::voffset_t field_offset = field.offset(); - - const flatbuffers::String* string = flatbuffers::GetFieldS(*table, field); - if (string == nullptr) { - return kFieldIsNotPopulated; - // Field is not populated - } - log::assert_that(string != nullptr, "assert failed: string != nullptr"); - flatbuffers::String* mutable_string = const_cast<flatbuffers::String*>(string); - - [[maybe_unused]] std::string old_string(string->str()); - switch (privacy_level) { - case kPrivate: - internal::ReplaceInString(mutable_string, '*'); - internal::ScrubFromTable(table, field_offset); - break; - case kOpaque: - internal::ReplaceInString(mutable_string, '*'); - break; - case kAnonymized: - internal::RandomizeInString(mutable_string); - break; - default: - case kAny: - break; - } - if (DBG) { - log::info("Field_name:{} size:{} privacy_level:{} old_string:{} ==> new_string:{}", - field.name()->c_str(), string->size(), PrivacyLevelName(privacy_level), old_string, - string->c_str()); - } - return kFieldHasBeenFiltered; -} - -bool internal::FilterTypeStruct(const reflection::Field& field, flatbuffers::Table* table, - PrivacyLevel privacy_level) { - log::assert_that(table != nullptr, "assert failed: table != nullptr"); - log::assert_that(!flatbuffers::IsScalar(field.type()->base_type()), - "assert failed: !flatbuffers::IsScalar(field.type()->base_type())"); - - flatbuffers::voffset_t field_offset = field.offset(); - - if (privacy_level != kAny) { - flatbuffers::SetFieldT(table, field, nullptr); - internal::ScrubFromTable(table, field_offset); - if (DBG) { - log::info("Table Removing field name:{} privacy_level:{}", field.name()->c_str(), - PrivacyLevelName(privacy_level)); - } - } - return kFieldContinueFiltering; -} diff --git a/system/gd/dumpsys/internal/filter_internal.h b/system/gd/dumpsys/internal/filter_internal.h deleted file mode 100644 index a18575c72f..0000000000 --- a/system/gd/dumpsys/internal/filter_internal.h +++ /dev/null @@ -1,157 +0,0 @@ -/* - * Copyright 2020 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 - -#include <base/strings/stringprintf.h> - -#include <string> - -#include "flatbuffers/flatbuffers.h" -#include "flatbuffers/idl.h" -#include "macros.h" - -namespace bluetooth { -namespace dumpsys { -namespace internal { - -constexpr char kPrivacyAttributeKeyword[] = "privacy"; - -enum PrivacyLevel { - kPrivate = 0, - kOpaque = 1, - kAnonymized = 2, - kAny = 4, - kDefaultPrivacyLevel = kPrivate, -}; - -/** - * Remove the field offset from flatbuffer table eliminating ability to - * access value. - * - * @param table Table under consideration for field removeal - * @param field_offset Virtual offset of field into table. - */ -void ScrubFromTable(flatbuffers::Table* table, flatbuffers::voffset_t field_offset); - -/** - * Overwrite ihe contents of flatbuffer string with the integer value proviced. - * The entire size of the string will be set to the value provided. - * - * @param string Flatbuffer string under consideration for content changing. - * @param value Value to overwrite the string contents. - */ -void ReplaceInString(flatbuffers::String* string, int value); - -/** - * Overwrite the contents of flatbuffer string with a hashed value. - * The portion of the string greater than the hash value will be set to SPACE. - * If the string is not large enough for the entire hash value, the hash - * value will be truncated to the size of the string. - * - * @param string Flatbuffer string under consideration for content changing. - */ -void RandomizeInString(flatbuffers::String* string); - -/** - * Returns the privacy level name corresponding to the axtual numeric level. - * - * @param privacy_level PrivacyLevel - * - * @return Name of privacy level. - */ -const char* PrivacyLevelName(PrivacyLevel privacy_level); - -/** - * Returns the privacy level for the given field. If there is no explicitly - * privacy level for this field, the default privacy level is returned. - * - * @param field The reflection field for the schema - * - * @return Privacy level enumeration value - */ -PrivacyLevel FindFieldPrivacyLevel(const reflection::Field& field); - -/** - * Returns the privacy level for given privacy level keyword name. - * If the privacy level for this field, the default privacy level is returned. - * - * @param name The privacy level name. - * - * @return Privacy level enumeration value. - */ -PrivacyLevel GetPrivacyLevelAttribute(const std::string& name); - -/** - * Find a the reflection object that corresponds to the name provided. - * Returns nullptr is not found. - * - * @param objects Vector container of flatbuffer objects - * @param name Flatbuffer string name to search - * - * @return Reflection object if found, nullptr otherwise. - */ -const reflection::Object* FindReflectionObject( - const flatbuffers::Vector<flatbuffers::Offset<reflection::Object>>* objects, - const flatbuffers::String* name); - -/** - * Process and filter the respective data types. - * - * @param field The reflection field schema. - * @param table The mutable table data corresponding to the schema. - * @param privacy_level The privacy level in which to filter the data. - * - * @return true if successfully filtered, false otherwise. - */ -bool FilterTypeBool(const reflection::Field& field, flatbuffers::Table* table, - PrivacyLevel privacy_level); -bool FilterTypeFloat(const reflection::Field& field, flatbuffers::Table* table, - PrivacyLevel privacy_level); -bool FilterTypeInteger(const reflection::Field& field, flatbuffers::Table* table, - PrivacyLevel privacy_level); -bool FilterTypeLong(const reflection::Field& field, flatbuffers::Table* table, - PrivacyLevel privacy_level); -bool FilterTypeString(const reflection::Field& field, flatbuffers::Table* table, - PrivacyLevel privacy_level); -bool FilterTypeStruct(const reflection::Field& field, flatbuffers::Table* table, - PrivacyLevel privacy_level); - -inline std::string FlatbufferTypeText(const flatbuffers::BaseType& type) { - switch (type) { - CASE_RETURN_TEXT(flatbuffers::BASE_TYPE_NONE); - CASE_RETURN_TEXT(flatbuffers::BASE_TYPE_BOOL); - CASE_RETURN_TEXT(flatbuffers::BASE_TYPE_CHAR); - CASE_RETURN_TEXT(flatbuffers::BASE_TYPE_UCHAR); - CASE_RETURN_TEXT(flatbuffers::BASE_TYPE_SHORT); - CASE_RETURN_TEXT(flatbuffers::BASE_TYPE_USHORT); - CASE_RETURN_TEXT(flatbuffers::BASE_TYPE_INT); - CASE_RETURN_TEXT(flatbuffers::BASE_TYPE_UINT); - CASE_RETURN_TEXT(flatbuffers::BASE_TYPE_LONG); - CASE_RETURN_TEXT(flatbuffers::BASE_TYPE_ULONG); - CASE_RETURN_TEXT(flatbuffers::BASE_TYPE_FLOAT); - CASE_RETURN_TEXT(flatbuffers::BASE_TYPE_DOUBLE); - CASE_RETURN_TEXT(flatbuffers::BASE_TYPE_STRING); - CASE_RETURN_TEXT(flatbuffers::BASE_TYPE_VECTOR); - CASE_RETURN_TEXT(flatbuffers::BASE_TYPE_STRUCT); - CASE_RETURN_TEXT(flatbuffers::BASE_TYPE_UNION); - default: - return base::StringPrintf("UNKNOWN[%d]", (int)type); - } -} - -} // namespace internal -} // namespace dumpsys -} // namespace bluetooth diff --git a/system/gd/dumpsys/internal/filter_internal_test.cc b/system/gd/dumpsys/internal/filter_internal_test.cc deleted file mode 100644 index 38f3481f0c..0000000000 --- a/system/gd/dumpsys/internal/filter_internal_test.cc +++ /dev/null @@ -1,424 +0,0 @@ -/* - * Copyright 2020 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 "dumpsys/internal/filter_internal.h" - -#include <gmock/gmock.h> -#include <gtest/gtest.h> - -#include "dumpsys/internal/test_data/float_bfbs.h" -#include "dumpsys/internal/test_data/float_generated.h" -#include "dumpsys/internal/test_data/integer_bfbs.h" -#include "dumpsys/internal/test_data/integer_generated.h" -#include "dumpsys/internal/test_data/string_bfbs.h" -#include "dumpsys/internal/test_data/string_generated.h" -#include "dumpsys/internal/test_data/struct_bfbs.h" -#include "dumpsys/internal/test_data/struct_generated.h" - -namespace testing { - -class DumpsysFilterInternalTest : public Test { -protected: - void SetUp() override {} - void TearDown() override {} - - flatbuffers::Table* GetMutableTable() const { - return flatbuffers::GetMutableRoot<flatbuffers::Table>(fb_builder_.GetBufferPointer()); - } - - void ParseReflectionSchema(unsigned char* bfbs, unsigned int bfbs_len) { - ASSERT_TRUE(reflection_schema_.empty()); - reflection_schema_ = std::vector<uint8_t>(bfbs, bfbs + bfbs_len); - flatbuffers::Verifier verifier(reflection_schema_.data(), reflection_schema_.size()); - ASSERT_TRUE(reflection::VerifySchemaBuffer(verifier)); - schema_ = reflection::GetSchema(reflection_schema_.data()); - ASSERT_TRUE(schema_ != nullptr); - } - - const reflection::Schema* schema_{nullptr}; - flatbuffers::FlatBufferBuilder fb_builder_ = flatbuffers::FlatBufferBuilder(1024); - -private: - std::vector<uint8_t> reflection_schema_; -}; - -class DumpsysFilterInternalIntegerTest : public DumpsysFilterInternalTest { -protected: - void SetUp() override { this->ParseReflectionSchema(integer_bfbs, integer_bfbs_len); } - - const testing::TestTableInteger* CreateInteger(int32_t value) { - TestTableIntegerBuilder builder(fb_builder_); - builder.add_test_int(value); - fb_builder_.Finish(builder.Finish()); - return GetTestTableInteger(fb_builder_.GetBufferPointer()); - } -}; - -class DumpsysFilterInternalFloatTest : public DumpsysFilterInternalTest { -protected: - void SetUp() override { this->ParseReflectionSchema(float_bfbs, float_bfbs_len); } - - const testing::TestTableFloat* CreateFloat(double value) { - TestTableFloatBuilder builder(fb_builder_); - builder.add_test_float(value); - fb_builder_.Finish(builder.Finish()); - return GetTestTableFloat(fb_builder_.GetBufferPointer()); - } -}; - -class DumpsysFilterInternalStringTest : public DumpsysFilterInternalTest { -protected: - void SetUp() override { this->ParseReflectionSchema(string_bfbs, string_bfbs_len); } - - const testing::TestTableString* CreateString(std::string string) { - auto test_string = fb_builder_.CreateString(string); - TestTableStringBuilder builder(fb_builder_); - builder.add_test_string(test_string); - fb_builder_.Finish(builder.Finish()); - return GetTestTableString(fb_builder_.GetBufferPointer()); - } -}; - -class DumpsysFilterInternalStructTest : public DumpsysFilterInternalTest { -protected: - void SetUp() override { this->ParseReflectionSchema(struct_bfbs, struct_bfbs_len); } - - flatbuffers::Offset<TestSubTable> CreateSubTable(int val) { - TestSubTableBuilder builder(fb_builder_); - builder.add_placeholder(val); - return builder.Finish(); - } - - const testing::TestTableStruct* CreateStruct(int val) { - auto sub_table = CreateSubTable(val); - - TestTableStructBuilder builder(fb_builder_); - builder.add_sub_table(sub_table); - fb_builder_.Finish(builder.Finish()); - return GetTestTableStruct(fb_builder_.GetBufferPointer()); - } -}; - -TEST_F(DumpsysFilterInternalIntegerTest, filter_type_integer_any) { - const testing::TestTableInteger* test_table = CreateInteger(123); - ASSERT_EQ(123, test_table->test_int()); - - flatbuffers::Table* table = GetMutableTable(); - - const reflection::Object* object = schema_->root_table(); - ASSERT_TRUE(object != nullptr); - - for (auto it = object->fields()->cbegin(); it != object->fields()->cend(); ++it) { - bluetooth::dumpsys::internal::FilterTypeInteger( - **it, table, bluetooth::dumpsys::internal::PrivacyLevel::kAny); - } - ASSERT_EQ(123, test_table->test_int()); -} - -TEST_F(DumpsysFilterInternalIntegerTest, filter_type_integer_anonymized) { - const testing::TestTableInteger* test_table = CreateInteger(123); - ASSERT_EQ(123, test_table->test_int()); - - flatbuffers::Table* table = GetMutableTable(); - - const reflection::Object* object = schema_->root_table(); - ASSERT_TRUE(object != nullptr); - - for (auto it = object->fields()->cbegin(); it != object->fields()->cend(); ++it) { - bluetooth::dumpsys::internal::FilterTypeInteger( - **it, table, bluetooth::dumpsys::internal::PrivacyLevel::kAnonymized); - } - ASSERT_NE(123, test_table->test_int()); -} - -TEST_F(DumpsysFilterInternalIntegerTest, filter_type_integer_opaque) { - const testing::TestTableInteger* test_table = CreateInteger(123); - ASSERT_EQ(123, test_table->test_int()); - - flatbuffers::Table* table = GetMutableTable(); - - const reflection::Object* object = schema_->root_table(); - ASSERT_TRUE(object != nullptr); - - for (auto it = object->fields()->cbegin(); it != object->fields()->cend(); ++it) { - bluetooth::dumpsys::internal::FilterTypeInteger( - **it, table, bluetooth::dumpsys::internal::PrivacyLevel::kOpaque); - } - ASSERT_EQ(0, test_table->test_int()); -} - -TEST_F(DumpsysFilterInternalIntegerTest, filter_type_integer_privacy) { - const testing::TestTableInteger* test_table = CreateInteger(123); - ASSERT_EQ(123, test_table->test_int()); - - flatbuffers::Table* table = GetMutableTable(); - - const reflection::Object* object = schema_->root_table(); - ASSERT_TRUE(object != nullptr); - - for (auto it = object->fields()->cbegin(); it != object->fields()->cend(); ++it) { - bluetooth::dumpsys::internal::FilterTypeInteger( - **it, table, bluetooth::dumpsys::internal::PrivacyLevel::kPrivate); - } - ASSERT_EQ(0, test_table->test_int()); -} - -TEST_F(DumpsysFilterInternalFloatTest, filter_type_float_any) { - const testing::TestTableFloat* test_table = CreateFloat(1.23); - ASSERT_FLOAT_EQ(1.23, test_table->test_float()); - - flatbuffers::Table* table = GetMutableTable(); - - const reflection::Object* object = schema_->root_table(); - ASSERT_TRUE(object != nullptr); - - for (auto it = object->fields()->cbegin(); it != object->fields()->cend(); ++it) { - bluetooth::dumpsys::internal::FilterTypeFloat(**it, table, - bluetooth::dumpsys::internal::PrivacyLevel::kAny); - } - ASSERT_FLOAT_EQ(1.23, test_table->test_float()); -} - -TEST_F(DumpsysFilterInternalFloatTest, filter_type_float_anonymized) { - const testing::TestTableFloat* test_table = CreateFloat(1.23); - ASSERT_FLOAT_EQ(1.23, test_table->test_float()); - - flatbuffers::Table* table = GetMutableTable(); - - const reflection::Object* object = schema_->root_table(); - ASSERT_TRUE(object != nullptr); - - for (auto it = object->fields()->cbegin(); it != object->fields()->cend(); ++it) { - bluetooth::dumpsys::internal::FilterTypeFloat( - **it, table, bluetooth::dumpsys::internal::PrivacyLevel::kAnonymized); - } - ASSERT_THAT(test_table->test_float(), Not(FloatEq(1.23))); -} - -TEST_F(DumpsysFilterInternalFloatTest, filter_type_float_opaque) { - const testing::TestTableFloat* test_table = CreateFloat(1.23); - ASSERT_FLOAT_EQ(1.23, test_table->test_float()); - - flatbuffers::Table* table = GetMutableTable(); - - const reflection::Object* object = schema_->root_table(); - ASSERT_TRUE(object != nullptr); - - for (auto it = object->fields()->cbegin(); it != object->fields()->cend(); ++it) { - bluetooth::dumpsys::internal::FilterTypeFloat( - **it, table, bluetooth::dumpsys::internal::PrivacyLevel::kOpaque); - } - ASSERT_FLOAT_EQ(0.0, test_table->test_float()); -} - -TEST_F(DumpsysFilterInternalFloatTest, filter_type_float_private) { - const testing::TestTableFloat* test_table = CreateFloat(1.23); - ASSERT_FLOAT_EQ(1.23, test_table->test_float()); - - flatbuffers::Table* table = GetMutableTable(); - - const reflection::Object* object = schema_->root_table(); - ASSERT_TRUE(object != nullptr); - - for (auto it = object->fields()->cbegin(); it != object->fields()->cend(); ++it) { - bluetooth::dumpsys::internal::FilterTypeFloat( - **it, table, bluetooth::dumpsys::internal::PrivacyLevel::kPrivate); - } - ASSERT_FLOAT_EQ(0.0, test_table->test_float()); -} - -TEST_F(DumpsysFilterInternalStringTest, filter_type_string_any) { - const testing::TestTableString* test_table = CreateString("This is a string"); - ASSERT_STREQ("This is a string", test_table->test_string()->c_str()); - - flatbuffers::Table* table = GetMutableTable(); - - const reflection::Object* object = schema_->root_table(); - ASSERT_TRUE(object != nullptr); - - for (auto it = object->fields()->cbegin(); it != object->fields()->cend(); ++it) { - bluetooth::dumpsys::internal::FilterTypeString( - **it, table, bluetooth::dumpsys::internal::PrivacyLevel::kAny); - } - ASSERT_STREQ("This is a string", test_table->test_string()->c_str()); -} - -TEST_F(DumpsysFilterInternalStringTest, filter_type_string_anonymous) { - const testing::TestTableString* test_table = CreateString("This is a string"); - ASSERT_STREQ("This is a string", test_table->test_string()->c_str()); - - flatbuffers::Table* table = GetMutableTable(); - - const reflection::Object* object = schema_->root_table(); - ASSERT_TRUE(object != nullptr); - - for (auto it = object->fields()->cbegin(); it != object->fields()->cend(); ++it) { - bluetooth::dumpsys::internal::FilterTypeString( - **it, table, bluetooth::dumpsys::internal::PrivacyLevel::kAnonymized); - } - ASSERT_NE("This is a string", test_table->test_string()->c_str()); -} - -TEST_F(DumpsysFilterInternalStringTest, filter_type_string_anonymous_small) { - const testing::TestTableString* test_table = CreateString("A"); - ASSERT_STREQ("A", test_table->test_string()->c_str()); - - flatbuffers::Table* table = GetMutableTable(); - - const reflection::Object* object = schema_->root_table(); - ASSERT_TRUE(object != nullptr); - - for (auto it = object->fields()->cbegin(); it != object->fields()->cend(); ++it) { - bluetooth::dumpsys::internal::FilterTypeString( - **it, table, bluetooth::dumpsys::internal::PrivacyLevel::kAnonymized); - } - ASSERT_NE("A", test_table->test_string()->c_str()); -} - -TEST_F(DumpsysFilterInternalStringTest, filter_type_string_anonymous_large) { - const testing::TestTableString* test_table = - CreateString("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"); - ASSERT_STREQ("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz", - test_table->test_string()->c_str()); - - flatbuffers::Table* table = GetMutableTable(); - - const reflection::Object* object = schema_->root_table(); - ASSERT_TRUE(object != nullptr); - - for (auto it = object->fields()->cbegin(); it != object->fields()->cend(); ++it) { - bluetooth::dumpsys::internal::FilterTypeString( - **it, table, bluetooth::dumpsys::internal::PrivacyLevel::kAnonymized); - } - ASSERT_NE("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz", - test_table->test_string()->c_str()); -} - -TEST_F(DumpsysFilterInternalStringTest, filter_type_string_opaque) { - const testing::TestTableString* test_table = CreateString("This is a string"); - ASSERT_STREQ("This is a string", test_table->test_string()->c_str()); - - flatbuffers::Table* table = GetMutableTable(); - - const reflection::Object* object = schema_->root_table(); - ASSERT_TRUE(object != nullptr); - - for (auto it = object->fields()->cbegin(); it != object->fields()->cend(); ++it) { - bluetooth::dumpsys::internal::FilterTypeString( - **it, table, bluetooth::dumpsys::internal::PrivacyLevel::kOpaque); - } - - std::string opaque_expected(strlen("This is a string"), '*'); - ASSERT_STREQ(opaque_expected.c_str(), test_table->test_string()->c_str()); -} - -TEST_F(DumpsysFilterInternalStringTest, filter_type_string_private) { - const testing::TestTableString* test_table = CreateString("This is a string"); - ASSERT_STREQ("This is a string", test_table->test_string()->c_str()); - - flatbuffers::Table* table = GetMutableTable(); - - const reflection::Object* object = schema_->root_table(); - ASSERT_TRUE(object != nullptr); - - for (auto it = object->fields()->cbegin(); it != object->fields()->cend(); ++it) { - bluetooth::dumpsys::internal::FilterTypeString( - **it, table, bluetooth::dumpsys::internal::PrivacyLevel::kPrivate); - } - ASSERT_EQ(nullptr, test_table->test_string()); -} - -TEST_F(DumpsysFilterInternalStringTest, filter_type_string_private_small) { - const testing::TestTableString* test_table = CreateString("A"); - ASSERT_STREQ("A", test_table->test_string()->c_str()); - - flatbuffers::Table* table = GetMutableTable(); - - const reflection::Object* object = schema_->root_table(); - ASSERT_TRUE(object != nullptr); - - for (auto it = object->fields()->cbegin(); it != object->fields()->cend(); ++it) { - bluetooth::dumpsys::internal::FilterTypeString( - **it, table, bluetooth::dumpsys::internal::PrivacyLevel::kPrivate); - } - ASSERT_EQ(nullptr, test_table->test_string()); -} - -TEST_F(DumpsysFilterInternalStructTest, filter_type_struct_any) { - const testing::TestTableStruct* test_table = CreateStruct(456); - ASSERT_EQ(456, test_table->sub_table()->placeholder()); - - flatbuffers::Table* table = GetMutableTable(); - - const reflection::Object* object = schema_->root_table(); - ASSERT_TRUE(object != nullptr); - - for (auto it = object->fields()->cbegin(); it != object->fields()->cend(); ++it) { - bluetooth::dumpsys::internal::FilterTypeStruct( - **it, table, bluetooth::dumpsys::internal::PrivacyLevel::kAny); - } - ASSERT_EQ(456, test_table->sub_table()->placeholder()); -} - -TEST_F(DumpsysFilterInternalStructTest, filter_type_struct_anonymous) { - const testing::TestTableStruct* test_table = CreateStruct(456); - ASSERT_EQ(456, test_table->sub_table()->placeholder()); - - flatbuffers::Table* table = GetMutableTable(); - - const reflection::Object* object = schema_->root_table(); - ASSERT_TRUE(object != nullptr); - - for (auto it = object->fields()->cbegin(); it != object->fields()->cend(); ++it) { - bluetooth::dumpsys::internal::FilterTypeStruct( - **it, table, bluetooth::dumpsys::internal::PrivacyLevel::kAnonymized); - } - ASSERT_EQ(nullptr, test_table->sub_table()); -} - -TEST_F(DumpsysFilterInternalStructTest, filter_type_struct_opaque) { - const testing::TestTableStruct* test_table = CreateStruct(456); - ASSERT_EQ(456, test_table->sub_table()->placeholder()); - - flatbuffers::Table* table = GetMutableTable(); - - const reflection::Object* object = schema_->root_table(); - ASSERT_TRUE(object != nullptr); - - for (auto it = object->fields()->cbegin(); it != object->fields()->cend(); ++it) { - bluetooth::dumpsys::internal::FilterTypeStruct( - **it, table, bluetooth::dumpsys::internal::PrivacyLevel::kOpaque); - } - ASSERT_EQ(nullptr, test_table->sub_table()); -} - -TEST_F(DumpsysFilterInternalStructTest, filter_type_struct_private) { - const testing::TestTableStruct* test_table = CreateStruct(456); - ASSERT_EQ(456, test_table->sub_table()->placeholder()); - - flatbuffers::Table* table = GetMutableTable(); - - const reflection::Object* object = schema_->root_table(); - ASSERT_TRUE(object != nullptr); - - for (auto it = object->fields()->cbegin(); it != object->fields()->cend(); ++it) { - bluetooth::dumpsys::internal::FilterTypeStruct( - **it, table, bluetooth::dumpsys::internal::PrivacyLevel::kPrivate); - } - ASSERT_EQ(nullptr, test_table->sub_table()); -} - -} // namespace testing diff --git a/system/gd/dumpsys/internal/test_data/float.bfbs b/system/gd/dumpsys/internal/test_data/float.bfbs Binary files differdeleted file mode 100644 index 547ecd93bf..0000000000 --- a/system/gd/dumpsys/internal/test_data/float.bfbs +++ /dev/null diff --git a/system/gd/dumpsys/internal/test_data/float.fbs b/system/gd/dumpsys/internal/test_data/float.fbs deleted file mode 100644 index 2f832e685c..0000000000 --- a/system/gd/dumpsys/internal/test_data/float.fbs +++ /dev/null @@ -1,7 +0,0 @@ -namespace testing; - -table TestTableFloat { - test_float:float; -} - -root_type TestTableFloat; diff --git a/system/gd/dumpsys/internal/test_data/float_bfbs.h b/system/gd/dumpsys/internal/test_data/float_bfbs.h deleted file mode 100644 index 06488b95a8..0000000000 --- a/system/gd/dumpsys/internal/test_data/float_bfbs.h +++ /dev/null @@ -1,18 +0,0 @@ -unsigned char float_bfbs[] = { - 0x18, 0x00, 0x00, 0x00, 0x42, 0x46, 0x42, 0x53, 0x10, 0x00, 0x1c, 0x00, 0x04, 0x00, 0x08, - 0x00, 0x0c, 0x00, 0x10, 0x00, 0x14, 0x00, 0x18, 0x00, 0x10, 0x00, 0x00, 0x00, 0x30, 0x00, - 0x00, 0x00, 0x28, 0x00, 0x00, 0x00, 0x1c, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, 0x3c, - 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x01, 0x00, 0x00, 0x00, 0x18, 0x00, 0x00, 0x00, 0x14, 0x00, 0x14, 0x00, 0x04, 0x00, - 0x08, 0x00, 0x00, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x14, - 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00, 0x14, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, - 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, - 0x00, 0x2c, 0x00, 0x00, 0x00, 0x16, 0x00, 0x00, 0x00, 0x74, 0x65, 0x73, 0x74, 0x69, 0x6e, - 0x67, 0x2e, 0x54, 0x65, 0x73, 0x74, 0x54, 0x61, 0x62, 0x6c, 0x65, 0x46, 0x6c, 0x6f, 0x61, - 0x74, 0x00, 0x00, 0x0c, 0x00, 0x10, 0x00, 0x08, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x06, 0x00, - 0x0c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x04, 0x00, 0x24, 0x00, 0x00, 0x00, 0x14, 0x00, 0x00, - 0x00, 0x10, 0x00, 0x0c, 0x00, 0x07, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x08, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0b, 0x01, 0x00, 0x00, 0x00, 0x0a, - 0x00, 0x00, 0x00, 0x74, 0x65, 0x73, 0x74, 0x5f, 0x66, 0x6c, 0x6f, 0x61, 0x74, 0x00, 0x00}; -unsigned int float_bfbs_len = 240; diff --git a/system/gd/dumpsys/internal/test_data/integer.bfbs b/system/gd/dumpsys/internal/test_data/integer.bfbs Binary files differdeleted file mode 100644 index 110c65dbee..0000000000 --- a/system/gd/dumpsys/internal/test_data/integer.bfbs +++ /dev/null diff --git a/system/gd/dumpsys/internal/test_data/integer.fbs b/system/gd/dumpsys/internal/test_data/integer.fbs deleted file mode 100644 index b8a5569eb2..0000000000 --- a/system/gd/dumpsys/internal/test_data/integer.fbs +++ /dev/null @@ -1,7 +0,0 @@ -namespace testing; - -table TestTableInteger { - test_int:int; -} - -root_type TestTableInteger; diff --git a/system/gd/dumpsys/internal/test_data/integer_bfbs.h b/system/gd/dumpsys/internal/test_data/integer_bfbs.h deleted file mode 100644 index 7f6ba61d7e..0000000000 --- a/system/gd/dumpsys/internal/test_data/integer_bfbs.h +++ /dev/null @@ -1,19 +0,0 @@ -unsigned char integer_bfbs[] = { - 0x18, 0x00, 0x00, 0x00, 0x42, 0x46, 0x42, 0x53, 0x10, 0x00, 0x1c, 0x00, 0x04, 0x00, 0x08, - 0x00, 0x0c, 0x00, 0x10, 0x00, 0x14, 0x00, 0x18, 0x00, 0x10, 0x00, 0x00, 0x00, 0x30, 0x00, - 0x00, 0x00, 0x28, 0x00, 0x00, 0x00, 0x1c, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, 0x3c, - 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x01, 0x00, 0x00, 0x00, 0x18, 0x00, 0x00, 0x00, 0x14, 0x00, 0x14, 0x00, 0x04, 0x00, - 0x08, 0x00, 0x00, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x14, - 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00, 0x14, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, - 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, - 0x00, 0x30, 0x00, 0x00, 0x00, 0x18, 0x00, 0x00, 0x00, 0x74, 0x65, 0x73, 0x74, 0x69, 0x6e, - 0x67, 0x2e, 0x54, 0x65, 0x73, 0x74, 0x54, 0x61, 0x62, 0x6c, 0x65, 0x49, 0x6e, 0x74, 0x65, - 0x67, 0x65, 0x72, 0x00, 0x00, 0x00, 0x00, 0x0c, 0x00, 0x10, 0x00, 0x08, 0x00, 0x0c, 0x00, - 0x00, 0x00, 0x06, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x04, 0x00, 0x24, 0x00, 0x00, - 0x00, 0x14, 0x00, 0x00, 0x00, 0x10, 0x00, 0x0c, 0x00, 0x07, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x08, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x01, - 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00, 0x74, 0x65, 0x73, 0x74, 0x5f, 0x69, 0x6e, 0x74, - 0x00, 0x00, 0x00, 0x00}; -unsigned int integer_bfbs_len = 244; diff --git a/system/gd/dumpsys/internal/test_data/mkfiles b/system/gd/dumpsys/internal/test_data/mkfiles deleted file mode 100644 index 95577d05d2..0000000000 --- a/system/gd/dumpsys/internal/test_data/mkfiles +++ /dev/null @@ -1,9 +0,0 @@ -../../../../../out/host/linux-x86/bin/flatc -b --schema --cpp string.fbs -xxd -i string.bfbs > string_bfbs.h -../../../../../out/host/linux-x86/bin/flatc -b --schema --cpp integer.fbs -xxd -i integer.bfbs > integer_bfbs.h -../../../../../out/host/linux-x86/bin/flatc -b --schema --cpp float.fbs -xxd -i float.bfbs > float_bfbs.h -../../../../../out/host/linux-x86/bin/flatc -b --schema --cpp struct.fbs -xxd -i struct.bfbs > struct_bfbs.h - diff --git a/system/gd/dumpsys/internal/test_data/root.h b/system/gd/dumpsys/internal/test_data/root.h deleted file mode 100644 index 5830ee8cf0..0000000000 --- a/system/gd/dumpsys/internal/test_data/root.h +++ /dev/null @@ -1,17 +0,0 @@ - - -#pragma once - -#include "flatbuffers/flatbuffers.h" -#include "root_generated.h" - -using TableAddFunction = std::function<void(testing::DumpsysTestDataRootBuilder* root_builder)>; - -namespace testing { - -struct DumpsysTestDataClass { - virtual TableAddFunction GetTable(flatbuffers::FlatBufferBuilder& builder) = 0; - virtual ~DumpsysTestDataClass() = default; -}; - -} // namespace testing diff --git a/system/gd/dumpsys/internal/test_data/string.bfbs b/system/gd/dumpsys/internal/test_data/string.bfbs Binary files differdeleted file mode 100644 index a414802b43..0000000000 --- a/system/gd/dumpsys/internal/test_data/string.bfbs +++ /dev/null diff --git a/system/gd/dumpsys/internal/test_data/string.fbs b/system/gd/dumpsys/internal/test_data/string.fbs deleted file mode 100644 index ba4f2fdfc9..0000000000 --- a/system/gd/dumpsys/internal/test_data/string.fbs +++ /dev/null @@ -1,7 +0,0 @@ -namespace testing; - -table TestTableString { - test_string:string; -} - -root_type TestTableString; diff --git a/system/gd/dumpsys/internal/test_data/string_bfbs.h b/system/gd/dumpsys/internal/test_data/string_bfbs.h deleted file mode 100644 index 1b241352ce..0000000000 --- a/system/gd/dumpsys/internal/test_data/string_bfbs.h +++ /dev/null @@ -1,16 +0,0 @@ -unsigned char string_bfbs[] = { - 0x18, 0x00, 0x00, 0x00, 0x42, 0x46, 0x42, 0x53, 0x10, 0x00, 0x1c, 0x00, 0x04, 0x00, 0x08, - 0x00, 0x0c, 0x00, 0x10, 0x00, 0x14, 0x00, 0x18, 0x00, 0x10, 0x00, 0x00, 0x00, 0x30, 0x00, - 0x00, 0x00, 0x28, 0x00, 0x00, 0x00, 0x1c, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, 0x34, - 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x01, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, 0x0c, 0x00, 0x10, 0x00, 0x04, 0x00, - 0x08, 0x00, 0x00, 0x00, 0x0c, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x14, 0x00, 0x00, 0x00, 0x08, - 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x2c, 0x00, 0x00, 0x00, - 0x17, 0x00, 0x00, 0x00, 0x74, 0x65, 0x73, 0x74, 0x69, 0x6e, 0x67, 0x2e, 0x54, 0x65, 0x73, - 0x74, 0x54, 0x61, 0x62, 0x6c, 0x65, 0x53, 0x74, 0x72, 0x69, 0x6e, 0x67, 0x00, 0x0c, 0x00, - 0x12, 0x00, 0x08, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x06, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x04, 0x00, 0x18, 0x00, 0x00, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x06, 0x00, - 0x08, 0x00, 0x07, 0x00, 0x06, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0d, 0x0b, 0x00, 0x00, - 0x00, 0x74, 0x65, 0x73, 0x74, 0x5f, 0x73, 0x74, 0x72, 0x69, 0x6e, 0x67, 0x00}; -unsigned int string_bfbs_len = 208; diff --git a/system/gd/dumpsys/internal/test_data/struct.bfbs b/system/gd/dumpsys/internal/test_data/struct.bfbs Binary files differdeleted file mode 100644 index c3ecca8841..0000000000 --- a/system/gd/dumpsys/internal/test_data/struct.bfbs +++ /dev/null diff --git a/system/gd/dumpsys/internal/test_data/struct.fbs b/system/gd/dumpsys/internal/test_data/struct.fbs deleted file mode 100644 index 83d4974f9b..0000000000 --- a/system/gd/dumpsys/internal/test_data/struct.fbs +++ /dev/null @@ -1,11 +0,0 @@ -namespace testing; - -table TestSubTable { - placeholder:int; -} - -table TestTableStruct{ - sub_table:TestSubTable; -} - -root_type TestTableStruct; diff --git a/system/gd/dumpsys/internal/test_data/struct_bfbs.h b/system/gd/dumpsys/internal/test_data/struct_bfbs.h deleted file mode 100644 index 5df51a98f4..0000000000 --- a/system/gd/dumpsys/internal/test_data/struct_bfbs.h +++ /dev/null @@ -1,29 +0,0 @@ -unsigned char struct_bfbs[] = { - 0x18, 0x00, 0x00, 0x00, 0x42, 0x46, 0x42, 0x53, 0x10, 0x00, 0x1c, 0x00, 0x04, 0x00, 0x08, - 0x00, 0x0c, 0x00, 0x10, 0x00, 0x14, 0x00, 0x18, 0x00, 0x10, 0x00, 0x00, 0x00, 0x30, 0x00, - 0x00, 0x00, 0x28, 0x00, 0x00, 0x00, 0x1c, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, 0x2c, - 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x02, 0x00, 0x00, 0x00, 0xb0, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x6c, 0xff, - 0xff, 0xff, 0x18, 0x00, 0x00, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0xac, - 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x3c, 0x00, 0x00, 0x00, 0x17, 0x00, 0x00, 0x00, - 0x74, 0x65, 0x73, 0x74, 0x69, 0x6e, 0x67, 0x2e, 0x54, 0x65, 0x73, 0x74, 0x54, 0x61, 0x62, - 0x6c, 0x65, 0x53, 0x74, 0x72, 0x75, 0x63, 0x74, 0x00, 0x1c, 0x00, 0x10, 0x00, 0x08, 0x00, - 0x0c, 0x00, 0x00, 0x00, 0x06, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x05, 0x00, 0x1c, 0x00, 0x00, 0x00, 0x00, 0x01, 0x04, 0x00, - 0x28, 0x00, 0x00, 0x00, 0x14, 0x00, 0x00, 0x00, 0x10, 0x00, 0x10, 0x00, 0x07, 0x00, 0x00, - 0x00, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0c, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x0f, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x09, 0x00, 0x00, 0x00, 0x73, - 0x75, 0x62, 0x5f, 0x74, 0x61, 0x62, 0x6c, 0x65, 0x00, 0x00, 0x00, 0x14, 0x00, 0x14, 0x00, - 0x04, 0x00, 0x08, 0x00, 0x00, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, - 0x00, 0x14, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00, 0x14, 0x00, 0x00, 0x00, 0x01, 0x00, - 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, - 0x00, 0x00, 0x00, 0x2c, 0x00, 0x00, 0x00, 0x14, 0x00, 0x00, 0x00, 0x74, 0x65, 0x73, 0x74, - 0x69, 0x6e, 0x67, 0x2e, 0x54, 0x65, 0x73, 0x74, 0x53, 0x75, 0x62, 0x54, 0x61, 0x62, 0x6c, - 0x65, 0x00, 0x00, 0x00, 0x00, 0x0c, 0x00, 0x10, 0x00, 0x08, 0x00, 0x0c, 0x00, 0x00, 0x00, - 0x06, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x04, 0x00, 0x24, 0x00, 0x00, 0x00, 0x14, - 0x00, 0x00, 0x00, 0x10, 0x00, 0x0c, 0x00, 0x07, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x08, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x01, 0x00, 0x00, - 0x00, 0x0b, 0x00, 0x00, 0x00, 0x70, 0x6c, 0x61, 0x63, 0x65, 0x68, 0x6f, 0x6c, 0x64, 0x65, - 0x72, 0x00}; -unsigned int struct_bfbs_len = 392; diff --git a/system/gd/dumpsys/reflection_schema.cc b/system/gd/dumpsys/reflection_schema.cc deleted file mode 100644 index b2d79313eb..0000000000 --- a/system/gd/dumpsys/reflection_schema.cc +++ /dev/null @@ -1,91 +0,0 @@ -/* - * Copyright 2020 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 "dumpsys/reflection_schema.h" - -#include <bluetooth/log.h> - -#include <string> - -#include "bundler_schema_generated.h" -#include "flatbuffers/flatbuffers.h" -#include "flatbuffers/idl.h" - -using namespace bluetooth; - -dumpsys::ReflectionSchema::ReflectionSchema(const std::string& pre_bundled_schema) - : pre_bundled_schema_(pre_bundled_schema) { - bundled_schema_ = - flatbuffers::GetRoot<bluetooth::dumpsys::BundledSchema>(pre_bundled_schema_.data()); - log::assert_that(bundled_schema_ != nullptr, "assert failed: bundled_schema_ != nullptr"); -} - -int dumpsys::ReflectionSchema::GetNumberOfBundledSchemas() const { - return bundled_schema_->map()->size(); -} - -std::string dumpsys::ReflectionSchema::GetTitle() const { return bundled_schema_->title()->str(); } - -std::string dumpsys::ReflectionSchema::GetRootName() const { - return bundled_schema_->root_name()->str(); -} - -const reflection::Schema* dumpsys::ReflectionSchema::GetRootReflectionSchema() const { - return FindInReflectionSchema(GetRootName()); -} - -const reflection::Schema* dumpsys::ReflectionSchema::FindInReflectionSchema( - const std::string& name) const { - const flatbuffers::Vector<flatbuffers::Offset<bluetooth::dumpsys::BundledSchemaMap>>* map = - bundled_schema_->map(); - - for (auto it = map->cbegin(); it != map->cend(); ++it) { - if (it->name()->str() == name) { - flatbuffers::Verifier verifier(reinterpret_cast<const uint8_t*>(it->data()->Data()), - it->data()->size()); - if (!reflection::VerifySchemaBuffer(verifier)) { - log::warn("Unable to verify schema buffer name:{}", name); - return nullptr; - } - return reflection::GetSchema(it->data()->Data()); - } - } - return nullptr; -} - -void dumpsys::ReflectionSchema::PrintReflectionSchema() const { - const flatbuffers::Vector<flatbuffers::Offset<bluetooth::dumpsys::BundledSchemaMap>>* map = - bundled_schema_->map(); - log::info("Bundled schema title:{} root_name:{}", bundled_schema_->title()->c_str(), - bundled_schema_->root_name()->c_str()); - for (auto it = map->cbegin(); it != map->cend(); ++it) { - log::info("schema:{}", it->name()->c_str()); - } -} - -bool dumpsys::ReflectionSchema::VerifyReflectionSchema() const { - const flatbuffers::Vector<flatbuffers::Offset<bluetooth::dumpsys::BundledSchemaMap>>* map = - bundled_schema_->map(); - - for (auto it = map->cbegin(); it != map->cend(); ++it) { - flatbuffers::Verifier verifier(reinterpret_cast<const uint8_t*>(it->data()->Data()), - it->data()->size()); - if (!reflection::VerifySchemaBuffer(verifier)) { - return false; - } - } - return true; -} diff --git a/system/gd/dumpsys/reflection_schema.h b/system/gd/dumpsys/reflection_schema.h deleted file mode 100644 index 7100a6b1b6..0000000000 --- a/system/gd/dumpsys/reflection_schema.h +++ /dev/null @@ -1,47 +0,0 @@ -/* - * Copyright 2020 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 - -#include <string> - -#include "bundler_schema_generated.h" -#include "flatbuffers/flatbuffers.h" -#include "flatbuffers/idl.h" - -namespace bluetooth { -namespace dumpsys { - -class ReflectionSchema { -public: - ReflectionSchema(const std::string& pre_bundled_schema); - - std::string GetTitle() const; - std::string GetRootName() const; - int GetNumberOfBundledSchemas() const; - - bool VerifyReflectionSchema() const; - const reflection::Schema* GetRootReflectionSchema() const; - const reflection::Schema* FindInReflectionSchema(const std::string& name) const; - void PrintReflectionSchema() const; - -private: - const BundledSchema* bundled_schema_; - const std::string pre_bundled_schema_; -}; - -} // namespace dumpsys -} // namespace bluetooth diff --git a/system/gd/dumpsys/reflection_schema_test.cc b/system/gd/dumpsys/reflection_schema_test.cc deleted file mode 100644 index 83e433eddd..0000000000 --- a/system/gd/dumpsys/reflection_schema_test.cc +++ /dev/null @@ -1,63 +0,0 @@ -/* - * Copyright 2020 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 "dumpsys/reflection_schema.h" - -#include <gtest/gtest.h> - -#include "dumpsys/dumpsys_test_data.h" - -namespace bluetooth { -namespace dumpsys { -extern const unsigned char* data; -extern const size_t data_size; -const std::string& GetBundledSchemaData(); -} // namespace dumpsys -} // namespace bluetooth - -namespace testing { - -using namespace bluetooth; - -class ReflectionSchemaTest : public Test { -protected: - void SetUp() override {} - - void TearDown() override {} -}; - -TEST_F(ReflectionSchemaTest, verify_test_content) { - dumpsys::ReflectionSchema reflection_schema(testing::GetBundledSchemaData()); - ASSERT_EQ(5, reflection_schema.GetNumberOfBundledSchemas()); - ASSERT_TRUE(reflection_schema.FindInReflectionSchema("testing.DumpsysTestDataRoot") != nullptr); - ASSERT_TRUE(reflection_schema.FindInReflectionSchema("testing.BarTestSchema") != nullptr); - ASSERT_TRUE(reflection_schema.FindInReflectionSchema("testing.BazTestSchema") != nullptr); - ASSERT_TRUE(reflection_schema.FindInReflectionSchema("testing.FooTestSchema") != nullptr); - ASSERT_TRUE(reflection_schema.FindInReflectionSchema("testing.QuxTestSchema") != nullptr); - ASSERT_TRUE(reflection_schema.FindInReflectionSchema("DoesNotExist") == nullptr); -} - -TEST_F(ReflectionSchemaTest, verify_test_schema) { - dumpsys::ReflectionSchema reflection_schema(testing::GetBundledSchemaData()); - ASSERT_TRUE(reflection_schema.VerifyReflectionSchema()); -} - -TEST_F(ReflectionSchemaTest, verify_production_schema) { - dumpsys::ReflectionSchema reflection_schema(bluetooth::dumpsys::GetBundledSchemaData()); - ASSERT_TRUE(reflection_schema.VerifyReflectionSchema()); -} - -} // namespace testing diff --git a/system/gd/dumpsys/test_data/bar.fbs b/system/gd/dumpsys/test_data/bar.fbs deleted file mode 100644 index dc423fea9e..0000000000 --- a/system/gd/dumpsys/test_data/bar.fbs +++ /dev/null @@ -1,12 +0,0 @@ -namespace testing; - -attribute "privacy"; - -table BarTestSchema { - bar_x:int; - bar_y:int; - another_field:string (privacy:"Any"); -} - -root_type BarTestSchema; - diff --git a/system/gd/dumpsys/test_data/bar.h b/system/gd/dumpsys/test_data/bar.h deleted file mode 100644 index 26af6c09e2..0000000000 --- a/system/gd/dumpsys/test_data/bar.h +++ /dev/null @@ -1,17 +0,0 @@ -/** - * - **/ -#include "bar_generated.h" -#include "root.h" -#include "root_generated.h" - -namespace testing { - -class BarTestDataClass : public DumpsysTestDataClass { -public: - TableAddFunction GetTable(flatbuffers::FlatBufferBuilder& /* fb_builder */) override { - return [](DumpsysTestDataRootBuilder* /* builder */) {}; - } -}; - -} // namespace testing diff --git a/system/gd/dumpsys/test_data/baz.fbs b/system/gd/dumpsys/test_data/baz.fbs deleted file mode 100644 index 38649a9c8c..0000000000 --- a/system/gd/dumpsys/test_data/baz.fbs +++ /dev/null @@ -1,35 +0,0 @@ -namespace testing; - -attribute "privacy"; - -table BazSubTablePrivate { - subtable_int_any:int (privacy:"Any"); - subtable_string_any:string (privacy:"Any"); -} - -table BazSubTableOpaque { - subtable_int_any:int (privacy:"Any"); - subtable_string_any:string (privacy:"Any"); -} - -table BazSubTableAnonymized { - subtable_int_any:int (privacy:"Any"); - subtable_string_any:string (privacy:"Any"); -} - -table BazSubTableAny { - subtable_int_private:int (privacy:"Private"); - subtable_int_opaque:int (privacy:"Opaque"); - subtable_int_anonymized:int (privacy:"Anonymized"); - subtable_int_any:int (privacy:"Any"); - subtable_string_any:string (privacy:"Any"); -} - -table BazTestSchema { - sub_table_private:BazSubTablePrivate; // private by default - sub_table_opaque:BazSubTableOpaque (privacy:"Opaque"); - sub_table_anonymized:BazSubTableAnonymized (privacy:"Anonymized"); - sub_table_any:BazSubTableAny (privacy:"Any"); -} - -root_type BazTestSchema; diff --git a/system/gd/dumpsys/test_data/baz.h b/system/gd/dumpsys/test_data/baz.h deleted file mode 100644 index 326f025bb9..0000000000 --- a/system/gd/dumpsys/test_data/baz.h +++ /dev/null @@ -1,34 +0,0 @@ - -#include "baz_generated.h" -#include "root.h" -#include "root_generated.h" - -namespace testing { - -class BazTestDataClass : public DumpsysTestDataClass { -public: - TableAddFunction GetTable(flatbuffers::FlatBufferBuilder& fb_builder) override { - auto sub_name_private = fb_builder.CreateString("Baz Subtable Private"); - auto sub_name_opaque = fb_builder.CreateString("Baz Subtable Opaque"); - auto sub_name_anonymized = fb_builder.CreateString("Baz Subtable Anonymized"); - auto sub_name_any = fb_builder.CreateString("Baz Subtable Any"); - - auto private_subtable = CreateBazSubTablePrivate(fb_builder, 1, sub_name_private); - auto opaque_subtable = CreateBazSubTableOpaque(fb_builder, 1, sub_name_opaque); - auto anonymized_subtable = CreateBazSubTableAnonymized(fb_builder, 1, sub_name_anonymized); - auto any_subtable = CreateBazSubTableAny(fb_builder, 1, 2, 3, 4, sub_name_any); - - BazTestSchemaBuilder builder(fb_builder); - builder.add_sub_table_private(private_subtable); - builder.add_sub_table_opaque(opaque_subtable); - builder.add_sub_table_anonymized(anonymized_subtable); - builder.add_sub_table_any(any_subtable); - auto baz_table = builder.Finish(); - - return [baz_table](DumpsysTestDataRootBuilder* builder) { - builder->add_baz_module_data(baz_table); - }; - } -}; - -} // namespace testing diff --git a/system/gd/dumpsys/test_data/foo.fbs b/system/gd/dumpsys/test_data/foo.fbs deleted file mode 100644 index b7482c326f..0000000000 --- a/system/gd/dumpsys/test_data/foo.fbs +++ /dev/null @@ -1,25 +0,0 @@ -namespace testing; - -attribute "privacy"; - -table FooTestSchema { - foo_int_private:int; - foo_int_opaque:int (privacy:"Opaque"); - foo_int_anonymized:int (privacy:"Anonymized"); - foo_int_any:int (privacy:"Any"); - foo_int_string:string (privacy:"Any"); - - foo_float_private:float; - foo_float_opaque:float (privacy:"Opaque"); - foo_float_anonymized:float (privacy:"Anonymized"); - foo_float_any:float (privacy:"Any"); - foo_float_string:string (privacy:"Any"); - - foo_bool_private:bool (privacy:"Private"); - foo_bool_opaque:bool (privacy:"Opaque"); - foo_bool_anonymized:bool (privacy:"Anonymized"); - foo_bool_any:bool (privacy:"Any"); - foo_bool_string:string (privacy:"Any"); -} - -root_type FooTestSchema; diff --git a/system/gd/dumpsys/test_data/foo.h b/system/gd/dumpsys/test_data/foo.h deleted file mode 100644 index 7d346657d4..0000000000 --- a/system/gd/dumpsys/test_data/foo.h +++ /dev/null @@ -1,42 +0,0 @@ - -#include "foo_generated.h" -#include "root.h" -#include "root_generated.h" - -namespace testing { - -class FooTestDataClass : public DumpsysTestDataClass { -public: - TableAddFunction GetTable(flatbuffers::FlatBufferBuilder& fb_builder) override { - auto int_string = fb_builder.CreateString("123"); - auto float_string = fb_builder.CreateString("123.456"); - auto bool_string = fb_builder.CreateString("true"); - - FooTestSchemaBuilder builder(fb_builder); - builder.add_foo_int_private(123); - builder.add_foo_int_opaque(123); - builder.add_foo_int_anonymized(123); - builder.add_foo_int_any(123); - builder.add_foo_int_string(int_string); - - builder.add_foo_float_private(123.456); - builder.add_foo_float_opaque(123.456); - builder.add_foo_float_anonymized(123.456); - builder.add_foo_float_any(123.456); - builder.add_foo_float_string(float_string); - - builder.add_foo_bool_private(true); - builder.add_foo_bool_opaque(true); - builder.add_foo_bool_anonymized(true); - builder.add_foo_bool_any(true); - builder.add_foo_bool_string(bool_string); - - auto foo_table = builder.Finish(); - - return [foo_table](DumpsysTestDataRootBuilder* builder) { - builder->add_foo_module_data(foo_table); - }; - } -}; - -} // namespace testing diff --git a/system/gd/dumpsys/test_data/qux.fbs b/system/gd/dumpsys/test_data/qux.fbs deleted file mode 100644 index 15e17dab7d..0000000000 --- a/system/gd/dumpsys/test_data/qux.fbs +++ /dev/null @@ -1,13 +0,0 @@ -namespace testing; - -attribute "privacy"; - -table QuxTestSchema { - qux_int_private:int; - qux_int_opaque:int (privacy:"Opaque"); - qux_int_anonymized:int (privacy:"Anonymized"); - qux_int_any:int (privacy:"Any"); - qux_string_name:string (privacy:"Any"); -} - -root_type QuxTestSchema; diff --git a/system/gd/dumpsys/test_data/qux.h b/system/gd/dumpsys/test_data/qux.h deleted file mode 100644 index 1e70de3879..0000000000 --- a/system/gd/dumpsys/test_data/qux.h +++ /dev/null @@ -1,28 +0,0 @@ - -#include "qux_generated.h" -#include "root.h" -#include "root_generated.h" - -namespace testing { - -class QuxTestDataClass : public DumpsysTestDataClass { -public: - TableAddFunction GetTable(flatbuffers::FlatBufferBuilder& fb_builder) override { - auto name = fb_builder.CreateString("Qux Module String"); - - QuxTestSchemaBuilder builder(fb_builder); - builder.add_qux_int_private(123); - builder.add_qux_int_opaque(456); - builder.add_qux_int_anonymized(789); - builder.add_qux_int_any(0xabc); - builder.add_qux_string_name(name); - - auto qux_table = builder.Finish(); - - return [qux_table](DumpsysTestDataRootBuilder* builder) { - builder->add_qux_module_data(qux_table); - }; - } -}; - -} // namespace testing diff --git a/system/gd/dumpsys/test_data/root.fbs b/system/gd/dumpsys/test_data/root.fbs deleted file mode 100644 index cedd310d11..0000000000 --- a/system/gd/dumpsys/test_data/root.fbs +++ /dev/null @@ -1,27 +0,0 @@ -include "foo.fbs"; -include "bar.fbs"; -include "baz.fbs"; -include "qux.fbs"; - -namespace testing; - -attribute "privacy"; - -table DumpsysTestDataRoot { - string_private:string; - string_opaque:string (privacy:"Opaque"); - string_anonymized:string (privacy:"Anonymized"); - string_any:string (privacy:"Any"); - - int_private:int32 (privacy:"Private"); - int_opaque:int32 (privacy:"Opaque"); - int_anonymized:int32 (privacy:"Anonymized"); - int_any:int32 (privacy:"Any"); - - foo_module_data:FooTestSchema (privacy:"Any"); - bar_module_data:BarTestSchema (privacy:"Any"); - baz_module_data:BazTestSchema (privacy:"Any"); - qux_module_data:QuxTestSchema (privacy:"Any"); -} - -root_type DumpsysTestDataRoot; diff --git a/system/gd/dumpsys/test_data/root.h b/system/gd/dumpsys/test_data/root.h deleted file mode 100644 index 9f58c8ebed..0000000000 --- a/system/gd/dumpsys/test_data/root.h +++ /dev/null @@ -1,17 +0,0 @@ - - -#pragma once - -#include "flatbuffers/flatbuffers.h" -#include "root_generated.h" - -using TableAddFunction = std::function<void(testing::DumpsysTestDataRootBuilder* root_builder)>; - -namespace testing { - -struct DumpsysTestDataClass { - virtual TableAddFunction GetTable(flatbuffers::FlatBufferBuilder& fb_builder) = 0; - virtual ~DumpsysTestDataClass() = default; -}; - -} // namespace testing diff --git a/system/gd/dumpsys_data.fbs b/system/gd/dumpsys_data.fbs deleted file mode 100644 index 2556a4da4f..0000000000 --- a/system/gd/dumpsys_data.fbs +++ /dev/null @@ -1,25 +0,0 @@ -// Top level module dumpsys data schema -// -// Possible field privacy levels from strongest to weakest. -// When unspecified defaults to the strongest privacy level. -// -// privacy:"Private" -// privacy:"Opaque" -// privacy:"Anonymized" -// privacy:"Any" - - -include "module_unittest.fbs"; -include "os/wakelock_manager.fbs"; - -namespace bluetooth; - -attribute "privacy"; - -table DumpsysData { - title:string (privacy:"Any"); - wakelock_manager_data:bluetooth.os.WakelockManagerData (privacy:"Any"); - module_unittest_data:bluetooth.ModuleUnitTestData; // private -} - -root_type DumpsysData; diff --git a/system/gd/hal/snoop_logger.cc b/system/gd/hal/snoop_logger.cc index 84eb0302e5..2e587cbfd6 100644 --- a/system/gd/hal/snoop_logger.cc +++ b/system/gd/hal/snoop_logger.cc @@ -35,7 +35,6 @@ #include "common/strings.h" #include "hal/snoop_logger_common.h" #include "hci/hci_packets.h" -#include "module_dumper_flatbuffer.h" #include "os/files.h" #include "os/parameter_provider.h" #include "os/system_properties.h" diff --git a/system/gd/hal/snoop_logger_test.cc b/system/gd/hal/snoop_logger_test.cc index 380e68a0e5..bfe81f3194 100644 --- a/system/gd/hal/snoop_logger_test.cc +++ b/system/gd/hal/snoop_logger_test.cc @@ -129,7 +129,6 @@ public: class SnoopLoggerModuleTest : public Test { public: - flatbuffers::FlatBufferBuilder* builder_; TestModuleRegistry* test_registry; protected: @@ -149,7 +148,6 @@ protected: temp_dir_ / (std::string(test_info->name()) + "_btsnoop_hci.log.filtered"); temp_snoop_log_filtered_last = temp_dir_ / (std::string(test_info->name()) + "_btsnoop_hci.log.filtered.last"); - builder_ = new flatbuffers::FlatBufferBuilder(); DeleteSnoopLogFiles(); ASSERT_FALSE(std::filesystem::exists(temp_snoop_log_)); @@ -164,7 +162,6 @@ protected: void TearDown() override { DeleteSnoopLogFiles(); - delete builder_; fake_timerfd_reset(); test_registry->StopAll(); delete test_registry; diff --git a/system/gd/hci/acl_manager.cc b/system/gd/hci/acl_manager.cc index 682800522c..a8edc9ea39 100644 --- a/system/gd/hci/acl_manager.cc +++ b/system/gd/hci/acl_manager.cc @@ -29,7 +29,6 @@ #include "common/bidi_queue.h" #include "common/byte_array.h" -#include "dumpsys_data_generated.h" #include "hci/acl_manager/acl_scheduler.h" #include "hci/acl_manager/classic_impl.h" #include "hci/acl_manager/le_acceptlist_callbacks.h" diff --git a/system/gd/hci/controller.cc b/system/gd/hci/controller.cc index 18180a547c..18743a1038 100644 --- a/system/gd/hci/controller.cc +++ b/system/gd/hci/controller.cc @@ -25,7 +25,6 @@ #include <string> #include <utility> -#include "dumpsys_data_generated.h" #include "hci/controller_interface.h" #include "hci/event_checkers.h" #include "hci/hci_layer.h" diff --git a/system/gd/hci/controller_test.cc b/system/gd/hci/controller_test.cc index 04b1380fa4..05dcaf9d7e 100644 --- a/system/gd/hci/controller_test.cc +++ b/system/gd/hci/controller_test.cc @@ -29,7 +29,6 @@ #include "common/bind.h" #include "hci/address.h" #include "hci/hci_layer_fake.h" -#include "module_dumper.h" #include "os/thread.h" #include "packet/raw_builder.h" diff --git a/system/gd/metrics/chromeos/OWNERS b/system/gd/metrics/chromeos/OWNERS deleted file mode 100644 index a823e6e1dd..0000000000 --- a/system/gd/metrics/chromeos/OWNERS +++ /dev/null @@ -1 +0,0 @@ -include /OWNERS_chromeos diff --git a/system/gd/metrics/linux/OWNERS b/system/gd/metrics/linux/OWNERS deleted file mode 100644 index a823e6e1dd..0000000000 --- a/system/gd/metrics/linux/OWNERS +++ /dev/null @@ -1 +0,0 @@ -include /OWNERS_chromeos diff --git a/system/gd/module.cc b/system/gd/module.cc index 5a2cdf142c..97f6132f31 100644 --- a/system/gd/module.cc +++ b/system/gd/module.cc @@ -45,13 +45,6 @@ Module* Module::GetDependency(const ModuleFactory* module) const { log::fatal("Module was not listed as a dependency in ListDependencies"); } -bluetooth::DumpsysDataFinisher EmptyDumpsysDataFinisher = - [](bluetooth::DumpsysDataBuilder* /* dumpsys_data_builder */) {}; - -DumpsysDataFinisher Module::GetDumpsysData(flatbuffers::FlatBufferBuilder* /* builder */) const { - return EmptyDumpsysDataFinisher; -} - Module* ModuleRegistry::Get(const ModuleFactory* module) const { auto instance = started_modules_.find(module); log::assert_that(instance != started_modules_.end(), diff --git a/system/gd/module.h b/system/gd/module.h index 44aa0bcb29..80b2369edf 100644 --- a/system/gd/module.h +++ b/system/gd/module.h @@ -17,7 +17,6 @@ #pragma once #include <bluetooth/log.h> -#include <flatbuffers/flatbuffers.h> #include <chrono> #include <functional> @@ -35,7 +34,6 @@ namespace bluetooth { class Module; -class ModuleDumper; class ModuleRegistry; class TestModuleRegistry; class FuzzTestModuleRegistry; @@ -68,11 +66,6 @@ private: std::vector<const ModuleFactory*> list_; }; -struct DumpsysDataBuilder; -using DumpsysDataFinisher = std::function<void(DumpsysDataBuilder*)>; - -extern DumpsysDataFinisher EmptyDumpsysDataFinisher; - // Each leaf node module must have a factory like so: // // static const ModuleFactory Factory; @@ -81,7 +74,6 @@ extern DumpsysDataFinisher EmptyDumpsysDataFinisher; // The module registry will also use the factory as the identifier // for that module. class Module { - friend ModuleDumper; friend ModuleRegistry; friend TestModuleRegistry; @@ -120,8 +112,6 @@ protected: GetHandler()->CallOn(obj, std::forward<Functor>(functor), std::forward<Args>(args)...); } - virtual DumpsysDataFinisher GetDumpsysData(flatbuffers::FlatBufferBuilder* builder) const; - private: Module* GetDependency(const ModuleFactory* module) const; @@ -132,7 +122,6 @@ private: class ModuleRegistry { friend Module; - friend ModuleDumper; friend class StackManager; public: diff --git a/system/gd/module_dumper.cc b/system/gd/module_dumper.cc deleted file mode 100644 index 23bb6aa8f2..0000000000 --- a/system/gd/module_dumper.cc +++ /dev/null @@ -1,62 +0,0 @@ -/* - * Copyright 2023 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. - */ -#define LOG_TAG "BtGdModule" - -#include "module_dumper.h" - -#include <sstream> - -#include "dumpsys_data_generated.h" -#include "module.h" -#include "os/wakelock_manager.h" - -using ::bluetooth::os::WakelockManager; - -namespace bluetooth { - -void ModuleDumper::DumpState(std::string* output, std::ostringstream& /*oss*/) const { - log::assert_that(output != nullptr, "assert failed: output != nullptr"); - - flatbuffers::FlatBufferBuilder builder(1024); - auto title = builder.CreateString(title_); - - auto wakelock_offset = WakelockManager::Get().GetDumpsysData(&builder); - - std::queue<DumpsysDataFinisher> queue; - for (auto it = module_registry_.start_order_.rbegin(); it != module_registry_.start_order_.rend(); - it++) { - auto instance = module_registry_.started_modules_.find(*it); - log::assert_that(instance != module_registry_.started_modules_.end(), - "assert failed: instance != module_registry_.started_modules_.end()"); - log::verbose("Starting dumpsys module:{}", instance->second->ToString()); - queue.push(instance->second->GetDumpsysData(&builder)); - log::verbose("Finished dumpsys module:{}", instance->second->ToString()); - } - - DumpsysDataBuilder data_builder(builder); - data_builder.add_title(title); - data_builder.add_wakelock_manager_data(wakelock_offset); - - while (!queue.empty()) { - queue.front()(&data_builder); - queue.pop(); - } - - builder.Finish(data_builder.Finish()); - *output = std::string(builder.GetBufferPointer(), builder.GetBufferPointer() + builder.GetSize()); -} - -} // namespace bluetooth diff --git a/system/gd/module_dumper.h b/system/gd/module_dumper.h deleted file mode 100644 index d1953a224d..0000000000 --- a/system/gd/module_dumper.h +++ /dev/null @@ -1,39 +0,0 @@ -/* - * Copyright 2019 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 - -#include <sstream> -#include <string> - -#include "module.h" - -namespace bluetooth { - -class ModuleRegistry; - -class ModuleDumper { -public: - ModuleDumper(int /*fd*/, const ModuleRegistry& module_registry, const char* title) - : module_registry_(module_registry), title_(title) {} - void DumpState(std::string* output, std::ostringstream& oss) const; - -private: - const ModuleRegistry& module_registry_; - const std::string title_; -}; - -} // namespace bluetooth diff --git a/system/gd/module_dumper_flatbuffer.h b/system/gd/module_dumper_flatbuffer.h deleted file mode 100644 index 21b19a7291..0000000000 --- a/system/gd/module_dumper_flatbuffer.h +++ /dev/null @@ -1,28 +0,0 @@ -/* - * Copyright 2023 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 - -#include <functional> - -namespace bluetooth { - -struct DumpsysDataBuilder; -using DumpsysDataFinisher = std::function<void(DumpsysDataBuilder* dumpsys_data_builder)>; - -extern DumpsysDataFinisher EmptyDumpsysDataFinisher; - -} // namespace bluetooth diff --git a/system/gd/module_unittest.cc b/system/gd/module_unittest.cc index 123cd3e469..24ccc8b3d2 100644 --- a/system/gd/module_unittest.cc +++ b/system/gd/module_unittest.cc @@ -22,10 +22,7 @@ #include <sstream> #include <string> -#include "dumpsys_data_generated.h" #include "gtest/gtest.h" -#include "module_dumper.h" -#include "module_unittest_generated.h" #include "os/handler.h" #include "os/thread.h" @@ -161,48 +158,6 @@ protected: const ModuleFactory TestModuleTwoDependencies::Factory = ModuleFactory([]() { return new TestModuleTwoDependencies(); }); -// To generate module unittest flatbuffer headers: -// $ flatc --cpp module_unittest.fbs -class TestModuleDumpState : public Module { -public: - static const ModuleFactory Factory; - - std::string test_string_{"Initial Test String"}; - -protected: - void ListDependencies(ModuleList* list) const { list->add<TestModuleNoDependency>(); } - - void Start() override { - EXPECT_TRUE(GetModuleRegistry()->IsStarted<TestModuleNoDependency>()); - - // A module is not considered started until Start() finishes - EXPECT_FALSE(GetModuleRegistry()->IsStarted<TestModuleDumpState>()); - test_module_one_dependency_handler = GetHandler(); - } - - void Stop() override { - EXPECT_TRUE(GetModuleRegistry()->IsStarted<TestModuleNoDependency>()); - - // A module is not considered stopped until after Stop() finishes - EXPECT_TRUE(GetModuleRegistry()->IsStarted<TestModuleDumpState>()); - } - - std::string ToString() const override { return std::string("TestModuleDumpState"); } - - DumpsysDataFinisher GetDumpsysData(flatbuffers::FlatBufferBuilder* fb_builder) const override { - auto string = fb_builder->CreateString(test_string_.c_str()); - - auto builder = ModuleUnitTestDataBuilder(*fb_builder); - builder.add_title(string); - auto table = builder.Finish(); - - return [table](DumpsysDataBuilder* builder) { builder->add_module_unittest_data(table); }; - } -}; - -const ModuleFactory TestModuleDumpState::Factory = - ModuleFactory([]() { return new TestModuleDumpState(); }); - TEST_F(ModuleTest, no_dependency) { ModuleList list; list.add<TestModuleNoDependency>(); @@ -270,38 +225,5 @@ TEST_F(ModuleTest, shutdown_with_unhandled_callback) { registry_->StopAll(); } -TEST_F(ModuleTest, dump_state) { - static const char* title = "Test Dump Title"; - ModuleList list; - list.add<TestModuleDumpState>(); - registry_->Start(&list, thread_); - - ModuleDumper dumper(STDOUT_FILENO, *registry_, title); - - std::string output; - std::ostringstream oss; - dumper.DumpState(&output, oss); - - auto data = flatbuffers::GetRoot<DumpsysData>(output.data()); - EXPECT_STREQ(title, data->title()->c_str()); - - auto test_data = data->module_unittest_data(); - EXPECT_STREQ("Initial Test String", test_data->title()->c_str()); - - TestModuleDumpState* test_module = static_cast<TestModuleDumpState*>( - registry_->Start(&TestModuleDumpState::Factory, nullptr)); - test_module->test_string_ = "A Second Test String"; - - oss.clear(); - output.clear(); - dumper.DumpState(&output, oss); - - data = flatbuffers::GetRoot<DumpsysData>(output.data()); - test_data = data->module_unittest_data(); - EXPECT_STREQ("A Second Test String", test_data->title()->c_str()); - - registry_->StopAll(); -} - } // namespace } // namespace bluetooth diff --git a/system/gd/module_unittest.fbs b/system/gd/module_unittest.fbs deleted file mode 100644 index 3c0a1b6bd0..0000000000 --- a/system/gd/module_unittest.fbs +++ /dev/null @@ -1,10 +0,0 @@ -// module_unittest -namespace bluetooth; - -attribute "privacy"; - -table ModuleUnitTestData { - title:string (privacy:"Any"); -} - -root_type ModuleUnitTestData; diff --git a/system/gd/module_unittest_generated.h b/system/gd/module_unittest_generated.h deleted file mode 100644 index 1176e5cbc9..0000000000 --- a/system/gd/module_unittest_generated.h +++ /dev/null @@ -1,86 +0,0 @@ -// automatically generated by the FlatBuffers compiler, do not modify - -#ifndef FLATBUFFERS_GENERATED_MODULEUNITTEST_BLUETOOTH_H_ -#define FLATBUFFERS_GENERATED_MODULEUNITTEST_BLUETOOTH_H_ - -#include "flatbuffers/flatbuffers.h" - -namespace bluetooth { - -struct ModuleUnitTestData; -struct ModuleUnitTestDataBuilder; - -struct ModuleUnitTestData FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table { - typedef ModuleUnitTestDataBuilder Builder; - enum FlatBuffersVTableOffset FLATBUFFERS_VTABLE_UNDERLYING_TYPE { VT_TITLE = 4 }; - const flatbuffers::String* title() const { - return GetPointer<const flatbuffers::String*>(VT_TITLE); - } - bool Verify(flatbuffers::Verifier& verifier) const { - return VerifyTableStart(verifier) && VerifyOffset(verifier, VT_TITLE) && - verifier.VerifyString(title()) && verifier.EndTable(); - } -}; - -struct ModuleUnitTestDataBuilder { - typedef ModuleUnitTestData Table; - flatbuffers::FlatBufferBuilder& fbb_; - flatbuffers::uoffset_t start_; - void add_title(flatbuffers::Offset<flatbuffers::String> title) { - fbb_.AddOffset(ModuleUnitTestData::VT_TITLE, title); - } - explicit ModuleUnitTestDataBuilder(flatbuffers::FlatBufferBuilder& _fbb) : fbb_(_fbb) { - start_ = fbb_.StartTable(); - } - ModuleUnitTestDataBuilder& operator=(const ModuleUnitTestDataBuilder&); - flatbuffers::Offset<ModuleUnitTestData> Finish() { - const auto end = fbb_.EndTable(start_); - auto o = flatbuffers::Offset<ModuleUnitTestData>(end); - return o; - } -}; - -inline flatbuffers::Offset<ModuleUnitTestData> CreateModuleUnitTestData( - flatbuffers::FlatBufferBuilder& _fbb, flatbuffers::Offset<flatbuffers::String> title = 0) { - ModuleUnitTestDataBuilder builder_(_fbb); - builder_.add_title(title); - return builder_.Finish(); -} - -inline flatbuffers::Offset<ModuleUnitTestData> CreateModuleUnitTestDataDirect( - flatbuffers::FlatBufferBuilder& _fbb, const char* title = nullptr) { - auto title__ = title ? _fbb.CreateString(title) : 0; - return bluetooth::CreateModuleUnitTestData(_fbb, title__); -} - -inline const bluetooth::ModuleUnitTestData* GetModuleUnitTestData(const void* buf) { - return flatbuffers::GetRoot<bluetooth::ModuleUnitTestData>(buf); -} - -inline const bluetooth::ModuleUnitTestData* GetSizePrefixedModuleUnitTestData(const void* buf) { - return flatbuffers::GetSizePrefixedRoot<bluetooth::ModuleUnitTestData>(buf); -} - -inline bool VerifyModuleUnitTestDataBuffer(flatbuffers::Verifier& verifier) { - return verifier.VerifyBuffer<bluetooth::ModuleUnitTestData>(nullptr); -} - -inline bool VerifySizePrefixedModuleUnitTestDataBuffer(flatbuffers::Verifier& verifier) { - return verifier.VerifySizePrefixedBuffer<bluetooth::ModuleUnitTestData>(nullptr); -} - -inline void FinishModuleUnitTestDataBuffer( - flatbuffers::FlatBufferBuilder& fbb, - flatbuffers::Offset<bluetooth::ModuleUnitTestData> root) { - fbb.Finish(root); -} - -inline void FinishSizePrefixedModuleUnitTestDataBuffer( - flatbuffers::FlatBufferBuilder& fbb, - flatbuffers::Offset<bluetooth::ModuleUnitTestData> root) { - fbb.FinishSizePrefixed(root); -} - -} // namespace bluetooth - -#endif // FLATBUFFERS_GENERATED_MODULEUNITTEST_BLUETOOTH_H_ diff --git a/system/gd/os/linux_generic/wakelock_manager.cc b/system/gd/os/linux_generic/wakelock_manager.cc index b8cc9000ba..7cca56201a 100644 --- a/system/gd/os/linux_generic/wakelock_manager.cc +++ b/system/gd/os/linux_generic/wakelock_manager.cc @@ -134,9 +134,10 @@ struct WakelockManager::Stats { total_acquired_interval_ms += delta_ms; } - flatbuffers::Offset<WakelockManagerData> GetDumpsysData( - flatbuffers::FlatBufferBuilder* fb_builder, bool is_native) const { + template <typename OutputT> + void Dump(OutputT&& out, bool is_native) { const uint64_t just_now_ms = now_ms(); + // Compute the last acquired interval if the wakelock is still acquired uint64_t delta_ms = 0; uint64_t last_interval_ms = last_acquired_interval_ms; @@ -154,31 +155,36 @@ struct WakelockManager::Stats { } last_interval_ms = delta_ms; } + uint64_t total_interval_ms = total_acquired_interval_ms + delta_ms; if (acquired_count > 0) { avg_interval_ms = total_interval_ms / acquired_count; } - WakelockManagerDataBuilder builder(*fb_builder); - builder.add_title(fb_builder->CreateString("Bluetooth Wakelock Statistics")); - builder.add_is_acquired(is_acquired); - builder.add_is_native(is_native); - builder.add_acquired_count(acquired_count); - builder.add_released_count(released_count); - builder.add_acquired_error_count(acquired_errors); - builder.add_released_error_count(released_errors); - builder.add_last_acquire_error_code(last_acquired_error); - builder.add_last_release_error_code(last_released_error); - builder.add_last_acquired_timestamp_millis(last_interval_ms); - builder.add_last_released_timestamp_millis(last_released_timestamp_ms); - builder.add_last_interval_millis(last_acquired_interval_ms); - builder.add_max_interval_millis(max_interval_ms); - builder.add_min_interval_millis(min_interval_ms); - builder.add_avg_interval_millis(avg_interval_ms); - builder.add_total_interval_millis(total_interval_ms); - builder.add_total_time_since_reset_millis(just_now_ms - last_reset_timestamp_ms); - return builder.Finish(); + std::format_to(out, "\nWakelock Dumpsys:\n"); + std::format_to(out, + " is_acquired: {}\n" + " is_native: {}\n" + " acquired_count: {}\n" + " released_count: {}\n" + " acquired_error_count: {}\n" + " released_error_count: {}\n" + " last_acquired_error_code: {}\n" + " last_released_error_code: {}\n" + " last_acquired_timestamp_ms: {}\n" + " last_released_timestamp_ms: {}\n" + " last_interval_ms: {}\n" + " max_interval_ms: {}\n" + " min_interval_ms: {}\n" + " avg_interval_ms: {}\n" + " total_interval_ms: {}\n" + " total_time_since_reeset_ms: {}\n", + is_acquired, is_native, acquired_count, released_count, acquired_errors, + released_errors, last_acquired_error, last_released_error, last_interval_ms, + last_released_timestamp_ms, last_acquired_interval_ms, max_interval_ms, + min_interval_ms, avg_interval_ms, total_interval_ms, + just_now_ms - last_reset_timestamp_ms); } }; @@ -266,10 +272,11 @@ void WakelockManager::CleanUp() { initialized_ = false; } -flatbuffers::Offset<WakelockManagerData> WakelockManager::GetDumpsysData( - flatbuffers::FlatBufferBuilder* fb_builder) { +void WakelockManager::Dump(int fd) const { std::lock_guard<std::recursive_mutex> lock_guard(mutex_); - return pstats_->GetDumpsysData(fb_builder, is_native_); + std::string out; + pstats_->Dump(std::back_inserter(out), is_native_); + dprintf(fd, "%s", out.c_str()); } WakelockManager::WakelockManager() : pstats_(std::make_unique<Stats>()) {} diff --git a/system/gd/os/linux_generic/wakelock_manager_unittest.cc b/system/gd/os/linux_generic/wakelock_manager_unittest.cc index e070d24fb5..d8b4dbf537 100644 --- a/system/gd/os/linux_generic/wakelock_manager_unittest.cc +++ b/system/gd/os/linux_generic/wakelock_manager_unittest.cc @@ -24,20 +24,14 @@ #include <unordered_map> #include "common/bind.h" -#include "flatbuffers/flatbuffers.h" #include "os/handler.h" #include "os/thread.h" -#include "wakelock_manager_generated.h" namespace testing { -using bluetooth::os::FinishWakelockManagerDataBuffer; -using bluetooth::os::GetWakelockManagerData; using bluetooth::os::Handler; using bluetooth::os::Thread; using bluetooth::os::WakelockManager; -using bluetooth::os::WakelockManagerData; -using bluetooth::os::WakelockManagerDataBuilder; class TestOsCallouts : public WakelockManager::OsCallouts { public: @@ -165,28 +159,8 @@ TEST_F(WakelockManagerTest, test_with_os_callouts_in_a_loop_and_dump) { ASSERT_THAT(os_callouts.GetNetAcquiredCount(WakelockManager::kBtWakelockId), Optional(Eq(0))); } - { - flatbuffers::FlatBufferBuilder builder(1024); - auto offset = WakelockManager::Get().GetDumpsysData(&builder); - FinishWakelockManagerDataBuffer(builder, offset); - auto data = GetWakelockManagerData(builder.GetBufferPointer()); - - ASSERT_EQ(data->acquired_count(), 1000); - ASSERT_EQ(data->released_count(), 1000); - } - WakelockManager::Get().CleanUp(); SyncHandler(); - - { - flatbuffers::FlatBufferBuilder builder(1024); - auto offset = WakelockManager::Get().GetDumpsysData(&builder); - FinishWakelockManagerDataBuffer(builder, offset); - auto data = GetWakelockManagerData(builder.GetBufferPointer()); - - ASSERT_EQ(data->acquired_count(), 0); - ASSERT_EQ(data->released_count(), 0); - } } } // namespace testing diff --git a/system/gd/os/wakelock_manager.fbs b/system/gd/os/wakelock_manager.fbs deleted file mode 100644 index 7b85e28044..0000000000 --- a/system/gd/os/wakelock_manager.fbs +++ /dev/null @@ -1,26 +0,0 @@ - -namespace bluetooth.os; - -attribute "privacy"; - -table WakelockManagerData { - title:string; - is_acquired:bool; - is_native:bool; - acquired_count:int; - released_count:int; - acquired_error_count:int; - released_error_count:int; - last_acquire_error_code:int; - last_release_error_code:int; - last_acquired_timestamp_millis:int64; - last_released_timestamp_millis:int64; - last_interval_millis:int64; - max_interval_millis:int64; - min_interval_millis:int64; - avg_interval_millis:int64; - total_interval_millis:int64; - total_time_since_reset_millis:int64; -} - -root_type WakelockManagerData; diff --git a/system/gd/os/wakelock_manager.h b/system/gd/os/wakelock_manager.h index 7f59895502..d920a5b4b4 100644 --- a/system/gd/os/wakelock_manager.h +++ b/system/gd/os/wakelock_manager.h @@ -18,14 +18,11 @@ #pragma once -#include <flatbuffers/flatbuffers.h> - #include <memory> #include <mutex> #include <string> #include "handler.h" -#include "wakelock_manager_generated.h" namespace bluetooth { namespace os { @@ -73,16 +70,16 @@ public: // This will NOT clean up the callouts void CleanUp(); - // Dump wakelock-related debug info to a flat buffer defined in wakelock_manager.fbs - flatbuffers::Offset<WakelockManagerData> GetDumpsysData( - flatbuffers::FlatBufferBuilder* fb_builder); + /// Write debug information relevant for the wakelock manager + /// to the dumpsys output file descriptor. + void Dump(int fd) const; ~WakelockManager(); private: WakelockManager(); - std::recursive_mutex mutex_; + mutable std::recursive_mutex mutex_; bool initialized_ = false; OsCallouts* os_callouts_ = nullptr; Handler* os_callouts_handler_ = nullptr; diff --git a/system/gd/rust/linux/OWNERS b/system/gd/rust/linux/OWNERS deleted file mode 100644 index a823e6e1dd..0000000000 --- a/system/gd/rust/linux/OWNERS +++ /dev/null @@ -1 +0,0 @@ -include /OWNERS_chromeos diff --git a/system/gd/rust/topshim/Android.bp b/system/gd/rust/topshim/Android.bp index b7d3af79ea..5d0e9c2102 100644 --- a/system/gd/rust/topshim/Android.bp +++ b/system/gd/rust/topshim/Android.bp @@ -52,7 +52,6 @@ cc_library_static { "vc/vc_shim.cc", ], generated_headers: [ - "BluetoothGeneratedDumpsysDataSchema_h", "cxx-bridge-header", "libbt_topshim_bridge_header", ], diff --git a/system/gd/rust/topshim/OWNERS b/system/gd/rust/topshim/OWNERS deleted file mode 100644 index a823e6e1dd..0000000000 --- a/system/gd/rust/topshim/OWNERS +++ /dev/null @@ -1 +0,0 @@ -include /OWNERS_chromeos diff --git a/system/gd/rust/topshim/facade/Android.bp b/system/gd/rust/topshim/facade/Android.bp index 505d5e8624..cc51c5f435 100644 --- a/system/gd/rust/topshim/facade/Android.bp +++ b/system/gd/rust/topshim/facade/Android.bp @@ -38,7 +38,6 @@ rust_defaults { "lib-bt-packets-avrcp", "lib-bt-packets-base", "libFraunhoferAAC", - "libbluetooth-dumpsys", "libbluetooth-types", "libbluetooth_crypto_toolbox", "libbluetooth_gd", // Gabeldorsche diff --git a/system/gd/shim/Android.bp b/system/gd/shim/Android.bp index c2b1d8b68e..d91ba15804 100644 --- a/system/gd/shim/Android.bp +++ b/system/gd/shim/Android.bp @@ -13,10 +13,3 @@ filegroup { "dumpsys.cc", ], } - -filegroup { - name: "BluetoothShimTestSources", - srcs: [ - "dumpsys_test.cc", - ], -} diff --git a/system/gd/shim/BUILD.gn b/system/gd/shim/BUILD.gn index d30e609c2f..89d318afc1 100644 --- a/system/gd/shim/BUILD.gn +++ b/system/gd/shim/BUILD.gn @@ -20,8 +20,6 @@ source_set("BluetoothShimSources") { deps = [ "//bt/flags:bluetooth_flags_c_lib", - "//bt/system/gd/dumpsys:libbluetooth-dumpsys", - "//bt/system/gd/dumpsys/bundler:BluetoothGeneratedBundlerSchema_h_bfbs", "//bt/system/pdl:BluetoothGeneratedPackets_h", ] diff --git a/system/gd/shim/dumpsys.cc b/system/gd/shim/dumpsys.cc index ae5d2c9fad..b93ffd9efb 100644 --- a/system/gd/shim/dumpsys.cc +++ b/system/gd/shim/dumpsys.cc @@ -15,8 +15,6 @@ */ #define LOG_TAG "bt_gd_shim" -#include "dumpsys/dumpsys.h" - #include <bluetooth/log.h> #include <com_android_bluetooth_flags.h> #include <unistd.h> @@ -25,136 +23,55 @@ #include <sstream> #include <string> -#include "dumpsys/filter.h" #include "hal/snoop_logger.h" #include "hci/acl_manager.h" #include "hci/controller_interface.h" #include "main/shim/entry.h" #include "main/shim/stack.h" #include "module.h" -#include "module_dumper.h" #include "os/system_properties.h" +#include "os/wakelock_manager.h" #include "shim/dumpsys.h" namespace bluetooth { namespace shim { -static const std::string kReadOnlyDebuggableProperty = "ro.debuggable"; - namespace { constexpr char kModuleName[] = "shim::Dumpsys"; -constexpr char kDumpsysTitle[] = "----- Gd Dumpsys ------"; } // namespace struct Dumpsys::impl { public: - void DumpWithArgsSync(int fd, const char** args, std::promise<void> promise); + void DumpSync(int fd, std::promise<void> promise); int GetNumberOfBundledSchemas() const; - impl(const Dumpsys& dumpsys_module, const dumpsys::ReflectionSchema& reflection_schema); + impl(const Dumpsys& dumpsys_module); ~impl() = default; -protected: - void FilterSchema(std::string* dumpsys_data) const; - std::string PrintAsJson(std::string* dumpsys_data) const; - - bool IsDebuggable() const; - private: - void DumpWithArgsAsync(int fd, const char** args) const; + void DumpAsync(int fd) const; const Dumpsys& dumpsys_module_; - const dumpsys::ReflectionSchema reflection_schema_; }; const ModuleFactory Dumpsys::Factory = - ModuleFactory([]() { return new Dumpsys(bluetooth::dumpsys::GetBundledSchemaData()); }); - -Dumpsys::impl::impl(const Dumpsys& dumpsys_module, - const dumpsys::ReflectionSchema& reflection_schema) - : dumpsys_module_(dumpsys_module), reflection_schema_(std::move(reflection_schema)) {} - -int Dumpsys::impl::GetNumberOfBundledSchemas() const { - return reflection_schema_.GetNumberOfBundledSchemas(); -} - -bool Dumpsys::impl::IsDebuggable() const { - return os::GetSystemProperty(kReadOnlyDebuggableProperty) == "1"; -} + ModuleFactory([]() { return new Dumpsys(); }); -void Dumpsys::impl::FilterSchema(std::string* dumpsys_data) const { - log::assert_that(dumpsys_data != nullptr, "assert failed: dumpsys_data != nullptr"); - dumpsys::FilterSchema(reflection_schema_, dumpsys_data); -} - -std::string Dumpsys::impl::PrintAsJson(std::string* dumpsys_data) const { - log::assert_that(dumpsys_data != nullptr, "assert failed: dumpsys_data != nullptr"); +Dumpsys::impl::impl(const Dumpsys& dumpsys_module) + : dumpsys_module_(dumpsys_module) {} - const std::string root_name = reflection_schema_.GetRootName(); - if (root_name.empty()) { - char buf[255]; - snprintf(buf, sizeof(buf), "ERROR: Unable to find root name in prebundled reflection schema\n"); - log::warn("{}", buf); - return std::string(buf); - } - - const reflection::Schema* schema = reflection_schema_.FindInReflectionSchema(root_name); - if (schema == nullptr) { - char buf[255]; - snprintf(buf, sizeof(buf), "ERROR: Unable to find schema root name:%s\n", root_name.c_str()); - log::warn("{}", buf); - return std::string(buf); - } - - flatbuffers::IDLOptions options{}; - options.output_default_scalars_in_json = true; - flatbuffers::Parser parser{options}; - if (!parser.Deserialize(schema)) { - char buf[255]; - snprintf(buf, sizeof(buf), "ERROR: Unable to deserialize bundle root name:%s\n", - root_name.c_str()); - log::warn("{}", buf); - return std::string(buf); - } - - std::string jsongen; - // GenerateText was renamed to GenText in 23.5.26 because the return behavior was changed. - // https://github.com/google/flatbuffers/commit/950a71ab893e96147c30dd91735af6db73f72ae0 -#if FLATBUFFERS_VERSION_MAJOR < 23 || \ - (FLATBUFFERS_VERSION_MAJOR == 23 && \ - (FLATBUFFERS_VERSION_MINOR < 5 || \ - (FLATBUFFERS_VERSION_MINOR == 5 && FLATBUFFERS_VERSION_REVISION < 26))) - flatbuffers::GenerateText(parser, dumpsys_data->data(), &jsongen); -#else - const char* error = flatbuffers::GenText(parser, dumpsys_data->data(), &jsongen); - if (error != nullptr) { - log::warn("{}", error); - } -#endif - return jsongen; -} - -void Dumpsys::impl::DumpWithArgsAsync(int fd, const char** /*args*/) const { +void Dumpsys::impl::DumpAsync(int fd) const { const auto registry = dumpsys_module_.GetModuleRegistry(); bluetooth::shim::GetController()->Dump(fd); bluetooth::shim::GetAclManager()->Dump(fd); + bluetooth::os::WakelockManager::Get().Dump(fd); bluetooth::shim::GetSnoopLogger()->DumpSnoozLogToFile(); - - ModuleDumper dumper(fd, *registry, kDumpsysTitle); - std::string dumpsys_data; - std::ostringstream oss; - dumper.DumpState(&dumpsys_data, oss); - - dprintf(fd, " ----- Filtering as Developer -----\n"); - FilterSchema(&dumpsys_data); - - dprintf(fd, "%s", PrintAsJson(&dumpsys_data).c_str()); } -void Dumpsys::impl::DumpWithArgsSync(int fd, const char** args, std::promise<void> promise) { +void Dumpsys::impl::DumpSync(int fd, std::promise<void> promise) { if (bluetooth::shim::Stack::GetInstance()->LockForDumpsys([=, *this]() { log::info("Started dumpsys procedure"); - this->DumpWithArgsAsync(fd, args); + this->DumpAsync(fd); })) { log::info("Successful dumpsys procedure"); } else { @@ -163,15 +80,14 @@ void Dumpsys::impl::DumpWithArgsSync(int fd, const char** args, std::promise<voi promise.set_value(); } -Dumpsys::Dumpsys(const std::string& pre_bundled_schema) - : reflection_schema_(dumpsys::ReflectionSchema(pre_bundled_schema)) {} +Dumpsys::Dumpsys() {} -void Dumpsys::Dump(int fd, const char** args, std::promise<void> promise) { +void Dumpsys::Dump(int fd, const char** /*args*/, std::promise<void> promise) { if (fd <= 0) { promise.set_value(); return; } - CallOn(pimpl_.get(), &Dumpsys::impl::DumpWithArgsSync, fd, args, std::move(promise)); + CallOn(pimpl_.get(), &Dumpsys::impl::DumpSync, fd, std::move(promise)); } /** @@ -179,7 +95,7 @@ void Dumpsys::Dump(int fd, const char** args, std::promise<void> promise) { */ void Dumpsys::ListDependencies(ModuleList* /* list */) const {} -void Dumpsys::Start() { pimpl_ = std::make_unique<impl>(*this, reflection_schema_); } +void Dumpsys::Start() { pimpl_ = std::make_unique<impl>(*this); } void Dumpsys::Stop() { pimpl_.reset(); } diff --git a/system/gd/shim/dumpsys.h b/system/gd/shim/dumpsys.h index 95756cdfe9..5ead5839b2 100644 --- a/system/gd/shim/dumpsys.h +++ b/system/gd/shim/dumpsys.h @@ -19,19 +19,16 @@ #include <memory> #include <string> -#include "dumpsys/reflection_schema.h" #include "module.h" namespace bluetooth { namespace shim { -constexpr char kArgumentDeveloper[] = "--dev"; - class Dumpsys : public bluetooth::Module { public: void Dump(int fd, const char** args, std::promise<void> promise); - Dumpsys(const std::string& pre_bundled_schema); + Dumpsys(); Dumpsys(const Dumpsys&) = delete; Dumpsys& operator=(const Dumpsys&) = delete; @@ -48,7 +45,6 @@ protected: private: struct impl; std::unique_ptr<impl> pimpl_; - const dumpsys::ReflectionSchema reflection_schema_; }; } // namespace shim diff --git a/system/gd/shim/dumpsys_test.cc b/system/gd/shim/dumpsys_test.cc deleted file mode 100644 index 8107f20a6c..0000000000 --- a/system/gd/shim/dumpsys_test.cc +++ /dev/null @@ -1,132 +0,0 @@ -/* - * Copyright 2020 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 "shim/dumpsys.h" - -#include <gtest/gtest.h> -#include <sys/socket.h> -#include <sys/types.h> - -#include <future> - -#include "module.h" -#include "os/thread.h" -#include "test_data/dumpsys_test_data_bin.h" - -namespace testing { - -using bluetooth::TestModuleRegistry; -using namespace bluetooth; - -namespace { - -bool SimpleJsonValidator(int fd, int* dumpsys_byte_cnt) { - char buf{0}; - bool within_double_quotes{false}; - int left_bracket{0}, right_bracket{0}; - while (read(fd, &buf, 1) != -1) { - switch (buf) { - (*dumpsys_byte_cnt)++; - case '"': - within_double_quotes = !within_double_quotes; - break; - case '{': - if (!within_double_quotes) { - left_bracket++; - } - break; - case '}': - if (!within_double_quotes) { - right_bracket++; - } - break; - default: - break; - } - } - return left_bracket == right_bracket; -} - -} // namespace - -// To create dumpsys_test_header_bin.h: -// make bluetooth_flatbuffer_bundler -// ${ANDROID_BUILD_TOP}/out/host/linux-x86/bin/bluetooth_flatbuffer_bundler -w -m -// bluetooth.DumpsysData -f test_gen/dumpsys_test_data_bin -n bluetooth::test test_gen/* - -class DumpsysTest : public Test { -protected: - void SetUp() override { - dumpsys_module_ = new bluetooth::shim::Dumpsys(bluetooth::test::GetBundledSchemaData()); - fake_registry_.InjectTestModule(&shim::Dumpsys::Factory, dumpsys_module_); - } - - void TearDown() override { fake_registry_.StopAll(); } - - int GetSocketBufferSize(int sockfd) { - int socket_buffer_size; - socklen_t optlen = sizeof(socket_buffer_size); - getsockopt(sockfd, SOL_SOCKET, SO_RCVBUF, (void*)&socket_buffer_size, &optlen); - return socket_buffer_size; - } - - void SetSocketBufferSize(int sockfd, int socket_buffer_size) { - socklen_t optlen = sizeof(socket_buffer_size); - ASSERT_EQ(0, - setsockopt(sockfd, SOL_SOCKET, SO_RCVBUF, (const void*)&socket_buffer_size, optlen)); - } - - TestModuleRegistry fake_registry_; - os::Thread& thread_ = fake_registry_.GetTestThread(); - bluetooth::shim::Dumpsys* dumpsys_module_ = nullptr; - os::Handler* client_handler_ = nullptr; -}; - -TEST_F(DumpsysTest, dump_as_developer) { - const char* args[]{bluetooth::shim::kArgumentDeveloper, nullptr}; - - int sv[2]; - ASSERT_EQ(0, socketpair(AF_LOCAL, SOCK_STREAM | SOCK_NONBLOCK, 0, sv)); - int socket_buffer_size = GetSocketBufferSize(sv[0]); - - std::promise<void> promise; - std::future future = promise.get_future(); - dumpsys_module_->Dump(sv[0], args, std::move(promise)); - future.wait(); - - int dumpsys_byte_cnt = 0; - ASSERT_TRUE(SimpleJsonValidator(sv[1], &dumpsys_byte_cnt)); - ASSERT_TRUE(dumpsys_byte_cnt < socket_buffer_size); -} - -TEST_F(DumpsysTest, dump_as_user) { - const char* args[]{"not-a-developer-option", nullptr}; - - int sv[2]; - ASSERT_EQ(0, socketpair(AF_LOCAL, SOCK_STREAM | SOCK_NONBLOCK, 0, sv)); - int socket_buffer_size = GetSocketBufferSize(sv[0]); - - std::promise<void> promise; - std::future future = promise.get_future(); - dumpsys_module_->Dump(sv[0], args, std::move(promise)); - future.wait(); - - int dumpsys_byte_cnt = 0; - ASSERT_TRUE(SimpleJsonValidator(sv[1], &dumpsys_byte_cnt)); - ASSERT_TRUE(dumpsys_byte_cnt < socket_buffer_size); -} - -} // namespace testing diff --git a/system/gd/shim/test_data/dumpsys_data.bfbs b/system/gd/shim/test_data/dumpsys_data.bfbs Binary files differdeleted file mode 100644 index afe2ea5407..0000000000 --- a/system/gd/shim/test_data/dumpsys_data.bfbs +++ /dev/null diff --git a/system/gd/shim/test_data/dumpsys_test_data_bin b/system/gd/shim/test_data/dumpsys_test_data_bin Binary files differdeleted file mode 100644 index b9c410d5c7..0000000000 --- a/system/gd/shim/test_data/dumpsys_test_data_bin +++ /dev/null diff --git a/system/gd/shim/test_data/dumpsys_test_data_bin.h b/system/gd/shim/test_data/dumpsys_test_data_bin.h deleted file mode 100644 index d1f118d0fa..0000000000 --- a/system/gd/shim/test_data/dumpsys_test_data_bin.h +++ /dev/null @@ -1,76 +0,0 @@ -// Generated file by bluetooth_flatbuffer bundler -#pragma once -#include <sys/types.h> - -#include <string> -namespace bluetooth { -namespace test { -extern const unsigned char* data; -extern const size_t data_size; -const std::string& GetBundledSchemaData(); -} // namespace test -} // namespace bluetooth -const unsigned char data_[] = { - 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0a, 0x00, 0x10, 0x00, 0x04, 0x00, 0x08, 0x00, 0x0c, - 0x00, 0x0a, 0x00, 0x00, 0x00, 0x30, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, 0x04, 0x00, - 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x44, 0x00, 0x00, 0x00, 0x15, 0x00, 0x00, 0x00, 0x62, - 0x6c, 0x75, 0x65, 0x74, 0x6f, 0x6f, 0x74, 0x68, 0x2e, 0x44, 0x75, 0x6d, 0x70, 0x73, 0x79, - 0x73, 0x44, 0x61, 0x74, 0x61, 0x00, 0x00, 0x00, 0x15, 0x00, 0x00, 0x00, 0x42, 0x75, 0x6e, - 0x64, 0x6c, 0x65, 0x64, 0x20, 0x73, 0x63, 0x68, 0x65, 0x6d, 0x61, 0x20, 0x74, 0x61, 0x62, - 0x6c, 0x65, 0x73, 0x00, 0x00, 0x00, 0x08, 0x00, 0x0c, 0x00, 0x04, 0x00, 0x08, 0x00, 0x08, - 0x00, 0x00, 0x00, 0xec, 0x02, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0xe0, 0x02, 0x00, 0x00, - 0x18, 0x00, 0x00, 0x00, 0x42, 0x46, 0x42, 0x53, 0x10, 0x00, 0x1c, 0x00, 0x04, 0x00, 0x08, - 0x00, 0x0c, 0x00, 0x10, 0x00, 0x14, 0x00, 0x18, 0x00, 0x10, 0x00, 0x00, 0x00, 0x30, 0x00, - 0x00, 0x00, 0x28, 0x00, 0x00, 0x00, 0x1c, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, 0x30, - 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x03, 0x00, 0x00, 0x00, 0x0c, 0x00, 0x00, 0x00, 0xd8, 0x01, 0x00, 0x00, 0x38, 0x01, - 0x00, 0x00, 0x3c, 0xfe, 0xff, 0xff, 0x1c, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00, 0x01, - 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x34, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, - 0xf4, 0x00, 0x00, 0x00, 0x15, 0x00, 0x00, 0x00, 0x62, 0x6c, 0x75, 0x65, 0x74, 0x6f, 0x6f, - 0x74, 0x68, 0x2e, 0x44, 0x75, 0x6d, 0x70, 0x73, 0x79, 0x73, 0x44, 0x61, 0x74, 0x61, 0x00, - 0x00, 0x00, 0x0c, 0x00, 0x10, 0x00, 0x08, 0x00, 0x0c, 0x00, 0x04, 0x00, 0x06, 0x00, 0x0c, - 0x00, 0x00, 0x00, 0x02, 0x00, 0x08, 0x00, 0x14, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, - 0x82, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x0f, 0x01, 0x00, 0x00, 0x00, 0x14, 0x00, 0x00, - 0x00, 0x6d, 0x6f, 0x64, 0x75, 0x6c, 0x65, 0x5f, 0x75, 0x6e, 0x69, 0x74, 0x74, 0x65, 0x73, - 0x74, 0x5f, 0x64, 0x61, 0x74, 0x61, 0x00, 0x00, 0x00, 0x00, 0x18, 0x00, 0x14, 0x00, 0x08, - 0x00, 0x0c, 0x00, 0x04, 0x00, 0x06, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x10, 0x00, 0x18, 0x00, 0x00, 0x00, 0x01, 0x00, 0x06, 0x00, 0x4c, 0x00, 0x00, - 0x00, 0x3c, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x04, 0x00, - 0x00, 0x00, 0x74, 0xfe, 0xff, 0xff, 0x10, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x03, - 0x00, 0x00, 0x00, 0x41, 0x6e, 0x79, 0x00, 0x07, 0x00, 0x00, 0x00, 0x70, 0x72, 0x69, 0x76, - 0x61, 0x63, 0x79, 0x00, 0x00, 0x00, 0x0a, 0x00, 0x0c, 0x00, 0x07, 0x00, 0x00, 0x00, 0x08, - 0x00, 0x0a, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0f, 0x02, 0x00, 0x00, 0x00, 0x11, 0x00, - 0x00, 0x00, 0x73, 0x68, 0x69, 0x6d, 0x5f, 0x64, 0x75, 0x6d, 0x70, 0x73, 0x79, 0x73, 0x5f, - 0x64, 0x61, 0x74, 0x61, 0x00, 0x00, 0x00, 0x0c, 0x00, 0x10, 0x00, 0x08, 0x00, 0x0c, 0x00, - 0x00, 0x00, 0x06, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x04, 0x00, 0x10, 0x00, 0x00, - 0x00, 0x04, 0x00, 0x00, 0x00, 0xb6, 0xfe, 0xff, 0xff, 0x00, 0x00, 0x00, 0x0d, 0x05, 0x00, - 0x00, 0x00, 0x74, 0x69, 0x74, 0x6c, 0x65, 0x00, 0x00, 0x00, 0x70, 0xff, 0xff, 0xff, 0x14, - 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, - 0x2c, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00, 0x62, 0x6c, 0x75, 0x65, 0x74, 0x6f, 0x6f, - 0x74, 0x68, 0x2e, 0x73, 0x68, 0x69, 0x6d, 0x2e, 0x44, 0x75, 0x6d, 0x70, 0x73, 0x79, 0x73, - 0x4d, 0x6f, 0x64, 0x75, 0x6c, 0x65, 0x44, 0x61, 0x74, 0x61, 0x00, 0x00, 0x00, 0x00, 0x68, - 0xff, 0xff, 0xff, 0x00, 0x00, 0x04, 0x00, 0x3c, 0x00, 0x00, 0x00, 0x30, 0x00, 0x00, 0x00, - 0x04, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x50, 0xff, 0xff, - 0xff, 0x10, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x41, 0x6e, - 0x79, 0x00, 0x07, 0x00, 0x00, 0x00, 0x70, 0x72, 0x69, 0x76, 0x61, 0x63, 0x79, 0x00, 0x46, - 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x0d, 0x05, 0x00, 0x00, 0x00, 0x74, 0x69, 0x74, 0x6c, - 0x65, 0x00, 0x00, 0x00, 0x0c, 0x00, 0x10, 0x00, 0x04, 0x00, 0x08, 0x00, 0x00, 0x00, 0x0c, - 0x00, 0x0c, 0x00, 0x00, 0x00, 0x14, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00, 0x01, 0x00, - 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x40, 0x00, 0x00, 0x00, 0x1c, 0x00, 0x00, 0x00, 0x62, - 0x6c, 0x75, 0x65, 0x74, 0x6f, 0x6f, 0x74, 0x68, 0x2e, 0x4d, 0x6f, 0x64, 0x75, 0x6c, 0x65, - 0x55, 0x6e, 0x69, 0x74, 0x54, 0x65, 0x73, 0x74, 0x44, 0x61, 0x74, 0x61, 0x00, 0x00, 0x00, - 0x00, 0x18, 0x00, 0x14, 0x00, 0x08, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x06, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x18, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x04, 0x00, 0x4c, 0x00, 0x00, 0x00, 0x40, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, - 0x01, 0x00, 0x00, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x08, 0x00, 0x0c, 0x00, 0x04, 0x00, 0x08, - 0x00, 0x08, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x03, 0x00, - 0x00, 0x00, 0x41, 0x6e, 0x79, 0x00, 0x07, 0x00, 0x00, 0x00, 0x70, 0x72, 0x69, 0x76, 0x61, - 0x63, 0x79, 0x00, 0x00, 0x00, 0x06, 0x00, 0x08, 0x00, 0x07, 0x00, 0x06, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x0d, 0x05, 0x00, 0x00, 0x00, 0x74, 0x69, 0x74, 0x6c, 0x65, 0x00, 0x00, - 0x00, 0x15, 0x00, 0x00, 0x00, 0x62, 0x6c, 0x75, 0x65, 0x74, 0x6f, 0x6f, 0x74, 0x68, 0x2e, - 0x44, 0x75, 0x6d, 0x70, 0x73, 0x79, 0x73, 0x44, 0x61, 0x74, 0x61, 0x00, 0x00, 0x00}; -const std::string string_data_(data_, data_ + sizeof(data_)); -const unsigned char* bluetooth::test::data = data_; -const size_t bluetooth::test::data_size = 884; -const std::string& bluetooth::test::GetBundledSchemaData() { return string_data_; } diff --git a/system/log/OWNERS b/system/log/OWNERS deleted file mode 100644 index d1c75de900..0000000000 --- a/system/log/OWNERS +++ /dev/null @@ -1 +0,0 @@ -henrichataing@google.com diff --git a/system/main/Android.bp b/system/main/Android.bp index 5b270923f4..27c00e6232 100644 --- a/system/main/Android.bp +++ b/system/main/Android.bp @@ -41,10 +41,6 @@ cc_library_static { "packages/modules/Bluetooth/system/udrv/include", "system/security/keystore/include", ], - generated_headers: [ - "BluetoothGeneratedBundlerSchema_h_bfbs", - "BluetoothGeneratedDumpsysDataSchema_h", - ], apex_available: [ "com.android.btservices", ], @@ -129,10 +125,6 @@ cc_library_static { "packages/modules/Bluetooth/system/gd", "packages/modules/Bluetooth/system/stack/include", ], - generated_headers: [ - "BluetoothGeneratedBundlerSchema_h_bfbs", - "BluetoothGeneratedDumpsysDataSchema_h", - ], whole_static_libs: [ "libbluetooth_gd", // Gabeldorsche ], @@ -197,7 +189,6 @@ cc_test { static_libs: [ "bluetooth_flags_c_lib_for_test", "libbase", - "libbluetooth-dumpsys", "libbluetooth-types", "libbluetooth_core_rs_bridge", "libbluetooth_crypto_toolbox", @@ -236,10 +227,6 @@ cc_test { undefined: true, }, }, - generated_headers: [ - "BluetoothGeneratedBundlerSchema_h_bfbs", - "BluetoothGeneratedDumpsysDataSchema_h", - ], min_sdk_version: "Tiramisu", header_libs: ["libbluetooth_headers"], } diff --git a/system/main/shim/BUILD.gn b/system/main/shim/BUILD.gn index d1d7353950..ff7bdae78a 100644 --- a/system/main/shim/BUILD.gn +++ b/system/main/shim/BUILD.gn @@ -29,9 +29,7 @@ source_set("BluetoothStackManagerSources") { ] deps = [ - "//bt/system/gd:BluetoothGeneratedDumpsysDataSchema_h", "//bt/system/gd/common:BluetoothCommonSources", - "//bt/system/gd/dumpsys/bundler:BluetoothGeneratedBundlerSchema_h_bfbs", "//bt/system/gd/hci:BluetoothHciSources", "//bt/system/gd/lpp:BluetoothLppOffloadSources", "//bt/system/gd/os:BluetoothOsSources_linux_generic", @@ -76,9 +74,7 @@ source_set("LibBluetoothShimSources") { deps = [ "//bt/sysprop:libcom.android.sysprop.bluetooth", - "//bt/system/gd:BluetoothGeneratedDumpsysDataSchema_h", "//bt/system/gd/common:BluetoothCommonSources", - "//bt/system/gd/dumpsys/bundler:BluetoothGeneratedBundlerSchema_h_bfbs", "//bt/system/gd/hci:BluetoothHciSources", "//bt/system/gd/lpp:BluetoothLppOffloadSources", "//bt/system/gd/os:BluetoothOsSources_linux_generic", diff --git a/system/main/test/main_shim_dumpsys_test.cc b/system/main/test/main_shim_dumpsys_test.cc index a61a55cda5..0670c991c6 100644 --- a/system/main/test/main_shim_dumpsys_test.cc +++ b/system/main/test/main_shim_dumpsys_test.cc @@ -30,14 +30,6 @@ using namespace bluetooth; using namespace testing; -namespace { - -constexpr char kTrue[] = "1"; -constexpr char kFalse[] = "0"; -constexpr char kReadOnlyDebuggableProperty[] = "ro.debuggable"; - -} // namespace - class MainShimDumpsysTest : public testing::Test { public: protected: @@ -55,18 +47,7 @@ protected: os::Handler* handler_{nullptr}; }; -TEST_F(MainShimDumpsysTest, dumpsys_developer) { - ASSERT_TRUE(os::SetSystemProperty(kReadOnlyDebuggableProperty, kTrue)); - - std::promise<void> promise; - auto future = promise.get_future(); - stack_manager_.GetInstance<shim::Dumpsys>()->Dump(STDOUT_FILENO, nullptr, std::move(promise)); - future.get(); -} - -TEST_F(MainShimDumpsysTest, dumpsys_user) { - ASSERT_TRUE(os::SetSystemProperty(kReadOnlyDebuggableProperty, kFalse)); - +TEST_F(MainShimDumpsysTest, dumpsys) { std::promise<void> promise; auto future = promise.get_future(); stack_manager_.GetInstance<shim::Dumpsys>()->Dump(STDOUT_FILENO, nullptr, std::move(promise)); diff --git a/system/profile/avrcp/device.cc b/system/profile/avrcp/device.cc index a5012e8389..1d0b32567e 100644 --- a/system/profile/avrcp/device.cc +++ b/system/profile/avrcp/device.cc @@ -154,6 +154,7 @@ void Device::VendorPacketHandler(uint8_t label, std::shared_ptr<VendorPacket> pk // TODO (apanicke): Add a retry mechanism if the response has a // different volume than the one we set. For now, we don't care // about the response to this message. + active_labels_.erase(label); break; default: log::warn("{}: Unhandled Response: pdu={}", address_, pkt->GetCommandPdu()); diff --git a/system/rust/Android.bp b/system/rust/Android.bp index 04be44dbec..1ff271b6c6 100644 --- a/system/rust/Android.bp +++ b/system/rust/Android.bp @@ -127,9 +127,6 @@ cc_library_static { generated_headers: [ "cxx-bridge-header", "libbluetooth_core_rs_bridge_codegen_header", - - "BluetoothGeneratedBundlerSchema_h_bfbs", - "BluetoothGeneratedDumpsysDataSchema_h", ], export_generated_headers: [ "cxx-bridge-header", diff --git a/system/stack/Android.bp b/system/stack/Android.bp index 155dcd4208..06b2ce1587 100644 --- a/system/stack/Android.bp +++ b/system/stack/Android.bp @@ -72,9 +72,6 @@ cc_library_static { "packages/modules/Bluetooth/system/gd/hal", "packages/modules/Bluetooth/system/udrv/include", ], - generated_headers: [ - "BluetoothGeneratedDumpsysDataSchema_h", - ], srcs: [ "a2dp/a2dp_aac.cc", "a2dp/a2dp_aac_decoder.cc", @@ -322,7 +319,6 @@ cc_library_static { "srvc/srvc_eng.cc", ], generated_headers: [ - "BluetoothGeneratedDumpsysDataSchema_h", "cxx-bridge-header", ], cflags: [ @@ -358,7 +354,6 @@ cc_defaults { host_supported: true, defaults: [ "bluetooth_cflags", - "bluetooth_flatbuffer_bundler_defaults", ], include_dirs: [ "packages/modules/Bluetooth/system", @@ -465,9 +460,6 @@ cc_fuzz { "packages/modules/Bluetooth/system/stack/test/common", "packages/modules/Bluetooth/system/stack/test/rfcomm", ], - generated_headers: [ - "BluetoothGeneratedDumpsysDataSchema_h", - ], srcs: [ ":BluetoothPacketSources", ":TestCommonMockFunctions", @@ -519,9 +511,6 @@ cc_fuzz { "external/rust/crates/quiche/deps/boringssl/src/include", "packages/modules/Bluetooth/system/stack/btm", ], - generated_headers: [ - "BluetoothGeneratedDumpsysDataSchema_h", - ], srcs: [ ":BluetoothPacketSources", ":TestCommonMockFunctions", @@ -574,9 +563,6 @@ cc_fuzz { "external/rust/crates/quiche/deps/boringssl/src/include", "packages/modules/Bluetooth/system/stack/btm", ], - generated_headers: [ - "BluetoothGeneratedDumpsysDataSchema_h", - ], srcs: [ ":BluetoothPacketSources", ":TestCommonMockFunctions", @@ -623,9 +609,6 @@ cc_fuzz { "external/rust/crates/quiche/deps/boringssl/src/include", "packages/modules/Bluetooth/system/stack/btm", ], - generated_headers: [ - "BluetoothGeneratedDumpsysDataSchema_h", - ], srcs: [ ":BluetoothPacketSources", ":TestCommonMockFunctions", @@ -664,9 +647,6 @@ cc_fuzz { "external/rust/crates/quiche/deps/boringssl/src/include", "packages/modules/Bluetooth/system/stack/btm", ], - generated_headers: [ - "BluetoothGeneratedDumpsysDataSchema_h", - ], srcs: [ ":BluetoothPacketSources", ":TestCommonMockFunctions", @@ -714,9 +694,6 @@ cc_fuzz { "external/rust/crates/quiche/deps/boringssl/src/include", "packages/modules/Bluetooth/system/stack/btm", ], - generated_headers: [ - "BluetoothGeneratedDumpsysDataSchema_h", - ], srcs: [ ":BluetoothPacketSources", ":TestCommonMockFunctions", @@ -807,7 +784,6 @@ cc_test { "bluetooth_flags_c_lib_for_test", "libFraunhoferAAC", "libbase", - "libbluetooth-dumpsys", "libbluetooth-for-tests", "libbluetooth-types", "libbluetooth_core_rs", @@ -909,9 +885,6 @@ cc_test { "test/rfcomm/stack_rfcomm_test_utils.cc", "test/rfcomm/stack_rfcomm_test_utils_test.cc", ], - generated_headers: [ - "BluetoothGeneratedDumpsysDataSchema_h", - ], shared_libs: [ "libcrypto", "libcutils", @@ -957,7 +930,6 @@ cc_test { cc_test { name: "net_test_stack_smp", defaults: [ - "bluetooth_flatbuffer_bundler_defaults", "fluoride_defaults", "mts_defaults", ], @@ -998,9 +970,6 @@ cc_test { "smp/smp_utils.cc", "test/stack_smp_test.cc", ], - generated_headers: [ - "BluetoothGeneratedDumpsysDataSchema_h", - ], shared_libs: [ "libaconfig_storage_read_api_cc", "libcrypto", @@ -1572,7 +1541,6 @@ cc_test { unit_test: true, }, defaults: [ - "bluetooth_flatbuffer_bundler_defaults", "fluoride_defaults", "mts_defaults", ], @@ -1581,9 +1549,6 @@ cc_test { "include", "test/common", ], - generated_headers: [ - "BluetoothGeneratedDumpsysDataSchema_h", - ], include_dirs: [ "packages/modules/Bluetooth/system", "packages/modules/Bluetooth/system/gd", @@ -1634,7 +1599,6 @@ cc_test { unit_test: true, }, defaults: [ - "bluetooth_flatbuffer_bundler_defaults", "fluoride_defaults", "mts_defaults", ], @@ -1651,9 +1615,6 @@ cc_test { "packages/modules/Bluetooth/system/bta", "packages/modules/Bluetooth/system/gd", ], - generated_headers: [ - "BluetoothGeneratedDumpsysDataSchema_h", - ], srcs: [ ":TestCommonMainHandler", ":TestCommonMockFunctions", @@ -1712,7 +1673,6 @@ cc_test { unit_test: true, }, defaults: [ - "bluetooth_flatbuffer_bundler_defaults", "fluoride_defaults", "mts_defaults", ], @@ -1725,9 +1685,6 @@ cc_test { "packages/modules/Bluetooth/system", "packages/modules/Bluetooth/system/gd", ], - generated_headers: [ - "BluetoothGeneratedDumpsysDataSchema_h", - ], srcs: [ ":BluetoothHalSources_hci_host", ":BluetoothHalSources_ranging_host", @@ -1981,9 +1938,6 @@ cc_test { "packages/modules/Bluetooth/system/gd", "packages/modules/Bluetooth/system/stack/btm", ], - generated_headers: [ - "BluetoothGeneratedDumpsysDataSchema_h", - ], srcs: [ ":TestCommonMockFunctions", ":TestMockBta", @@ -2057,9 +2011,6 @@ cc_test { "packages/modules/Bluetooth/system/gd", "packages/modules/Bluetooth/system/stack/btm", ], - generated_headers: [ - "BluetoothGeneratedDumpsysDataSchema_h", - ], srcs: [ ":OsiCompatSources", ":TestCommonMainHandler", @@ -2150,7 +2101,6 @@ cc_test { test_suites: ["general-tests"], host_supported: true, defaults: [ - "bluetooth_flatbuffer_bundler_defaults", "fluoride_defaults", "mts_defaults", ], @@ -2163,9 +2113,6 @@ cc_test { "packages/modules/Bluetooth/system/gd", "packages/modules/Bluetooth/system/stack/btm", ], - generated_headers: [ - "BluetoothGeneratedDumpsysDataSchema_h", - ], srcs: [ ":OsiCompatSources", ":TestCommonMainHandler", @@ -2250,7 +2197,6 @@ cc_test { test_suites: ["general-tests"], host_supported: true, defaults: [ - "bluetooth_flatbuffer_bundler_defaults", "fluoride_defaults", "mts_defaults", ], @@ -2263,9 +2209,6 @@ cc_test { "packages/modules/Bluetooth/system/gd", "packages/modules/Bluetooth/system/stack/btm", ], - generated_headers: [ - "BluetoothGeneratedDumpsysDataSchema_h", - ], srcs: [ ":OsiCompatSources", ":TestCommonMainHandler", @@ -2348,7 +2291,6 @@ cc_test { unit_test: true, }, defaults: [ - "bluetooth_flatbuffer_bundler_defaults", "fluoride_defaults", "mts_defaults", ], @@ -2361,9 +2303,6 @@ cc_test { "packages/modules/Bluetooth/system", "packages/modules/Bluetooth/system/gd", ], - generated_headers: [ - "BluetoothGeneratedDumpsysDataSchema_h", - ], srcs: [ ":BluetoothHalSources_hci_host", ":BluetoothHalSources_ranging_host", diff --git a/system/stack/ais/ais_ble.cc b/system/stack/ais/ais_ble.cc index 879797ed34..a4e4a65549 100644 --- a/system/stack/ais/ais_ble.cc +++ b/system/stack/ais/ais_ble.cc @@ -28,9 +28,6 @@ #include "stack/include/gatt_api.h" #include "types/bluetooth/uuid.h" -// TODO(b/369381361) Enfore -Wmissing-prototypes -#pragma GCC diagnostic ignored "-Wmissing-prototypes" - using bluetooth::Uuid; using bluetooth::log::error; using bluetooth::log::warn; @@ -104,7 +101,7 @@ void ais_request_cback(tCONN_ID conn_id, uint32_t trans_id, tGATTS_REQ_TYPE type * Returns void. * ******************************************************************************/ -void ais_attr_db_init(void) { +static void ais_attr_db_init(void) { if (!com::android::bluetooth::flags::android_os_identifier()) { return; } diff --git a/system/stack/bnep/bnep_utils.cc b/system/stack/bnep/bnep_utils.cc index 0740451fda..64ea5f2501 100644 --- a/system/stack/bnep/bnep_utils.cc +++ b/system/stack/bnep/bnep_utils.cc @@ -45,9 +45,6 @@ #include "types/bt_transport.h" #include "types/raw_address.h" -// TODO(b/369381361) Enfore -Wmissing-prototypes -#pragma GCC diagnostic ignored "-Wmissing-prototypes" - using namespace bluetooth; using bluetooth::Uuid; @@ -56,8 +53,9 @@ using bluetooth::Uuid; /******************************************************************************/ static uint8_t* bnepu_init_hdr(BT_HDR* p_buf, uint16_t hdr_len, uint8_t pkt_type); -void bnepu_process_peer_multicast_filter_set(tBNEP_CONN* p_bcb, uint8_t* p_filters, uint16_t len); -void bnepu_send_peer_multicast_filter_rsp(tBNEP_CONN* p_bcb, uint16_t response_code); +static void bnepu_process_peer_multicast_filter_set(tBNEP_CONN* p_bcb, uint8_t* p_filters, + uint16_t len); +static void bnepu_send_peer_multicast_filter_rsp(tBNEP_CONN* p_bcb, uint16_t response_code); /******************************************************************************* * @@ -343,7 +341,7 @@ void bnepu_send_peer_our_multi_filters(tBNEP_CONN* p_bcb) { * Returns void * ******************************************************************************/ -void bnepu_send_peer_filter_rsp(tBNEP_CONN* p_bcb, uint16_t response_code) { +static void bnepu_send_peer_filter_rsp(tBNEP_CONN* p_bcb, uint16_t response_code) { BT_HDR* p_buf = (BT_HDR*)osi_malloc(BNEP_BUF_SIZE); uint8_t* p; @@ -1030,7 +1028,8 @@ void bnepu_process_multicast_filter_rsp(tBNEP_CONN* p_bcb, uint8_t* p_data) { * Returns void * ******************************************************************************/ -void bnepu_process_peer_multicast_filter_set(tBNEP_CONN* p_bcb, uint8_t* p_filters, uint16_t len) { +static void bnepu_process_peer_multicast_filter_set(tBNEP_CONN* p_bcb, uint8_t* p_filters, + uint16_t len) { uint16_t resp_code = BNEP_FILTER_CRL_OK; uint16_t num_filters, xx; uint8_t *p_temp_filters, null_bda[BD_ADDR_LEN] = {0, 0, 0, 0, 0, 0}; @@ -1106,7 +1105,7 @@ void bnepu_process_peer_multicast_filter_set(tBNEP_CONN* p_bcb, uint8_t* p_filte * Returns void * ******************************************************************************/ -void bnepu_send_peer_multicast_filter_rsp(tBNEP_CONN* p_bcb, uint16_t response_code) { +static void bnepu_send_peer_multicast_filter_rsp(tBNEP_CONN* p_bcb, uint16_t response_code) { BT_HDR* p_buf = (BT_HDR*)osi_malloc(BNEP_BUF_SIZE); uint8_t* p; diff --git a/system/stack/btm/btm_ble_gap.cc b/system/stack/btm/btm_ble_gap.cc index 6f6e42b216..77cd227c06 100644 --- a/system/stack/btm/btm_ble_gap.cc +++ b/system/stack/btm/btm_ble_gap.cc @@ -66,6 +66,7 @@ #include "stack/include/gattdefs.h" #include "stack/include/hci_error_code.h" #include "stack/include/inq_hci_link_interface.h" +#include "stack/rnr/remote_name_request.h" #include "types/ble_address_with_type.h" #include "types/raw_address.h" @@ -76,7 +77,6 @@ using namespace bluetooth; extern tBTM_CB btm_cb; -void btm_inq_remote_name_timer_timeout(void* data); void btm_ble_adv_filter_init(void); #define BTM_EXT_BLE_RMT_NAME_TIMEOUT_MS (30 * 1000) diff --git a/system/stack/btm/btm_sec.cc b/system/stack/btm/btm_sec.cc index 8c6d057f53..8bd03e2e08 100644 --- a/system/stack/btm/btm_sec.cc +++ b/system/stack/btm/btm_sec.cc @@ -4513,6 +4513,14 @@ tBTM_STATUS btm_sec_execute_procedure(tBTM_SEC_DEV_REC* p_dev_rec) { } if (start_auth) { + if (com::android::bluetooth::flags::ignore_auth_req_when_collision_timer_active() && + alarm_is_scheduled(btm_sec_cb.sec_collision_timer) && + (btm_sec_cb.p_collided_dev_rec->bd_addr == p_dev_rec->bd_addr)) { + log::debug( + "Security Manager: Authentication will be executed after collision " + "timer expired"); + return tBTM_STATUS::BTM_CMD_STARTED; + } log::debug("Security Manager: Start authentication"); /* diff --git a/system/stack/connection_manager/connection_manager.cc b/system/stack/connection_manager/connection_manager.cc index c29ac5d403..4cd7df3f28 100644 --- a/system/stack/connection_manager/connection_manager.cc +++ b/system/stack/connection_manager/connection_manager.cc @@ -42,9 +42,6 @@ #define DIRECT_CONNECT_TIMEOUT (30 * 1000) /* 30 seconds */ -// TODO(b/369381361) Enfore -Wmissing-prototypes -#pragma GCC diagnostic ignored "-Wmissing-prototypes" - using namespace bluetooth; constexpr char kBtmLogTag[] = "TA"; @@ -62,8 +59,8 @@ static void alarm_closure_cb(void* p) { } // Periodic alarms are not supported, because we clean up data in callback -void alarm_set_closure(const base::Location& posted_from, alarm_t* alarm, uint64_t interval_ms, - base::OnceClosure user_task) { +static void alarm_set_closure(const base::Location& posted_from, alarm_t* alarm, + uint64_t interval_ms, base::OnceClosure user_task) { closure_data* data = new closure_data; data->posted_from = posted_from; data->user_task = std::move(user_task); @@ -118,7 +115,7 @@ std::set<tAPP_ID> get_apps_connecting_to(const RawAddress& address) { return (it != bgconn_dev.end()) ? it->second.doing_bg_conn : std::set<tAPP_ID>(); } -bool IsTargetedAnnouncement(const uint8_t* p_eir, uint16_t eir_len) { +static bool IsTargetedAnnouncement(const uint8_t* p_eir, uint16_t eir_len) { const uint8_t* p_service_data = p_eir; uint8_t service_data_len = 0; @@ -186,7 +183,7 @@ static void target_announcement_observe_results_cb(tBTM_INQ_RESULTS* p_inq, cons do_in_main_thread(base::BindOnce(schedule_direct_connect_add, app_id, addr)); } -void target_announcements_filtering_set(bool enable) { +static void target_announcements_filtering_set(bool enable) { log::debug("enable {}", enable); BTM_LogHistory(kBtmLogTag, RawAddress::kEmpty, (enable ? "Start filtering" : "Stop filtering")); @@ -431,7 +428,7 @@ void reset(bool after_reset) { } } -void wl_direct_connect_timeout_cb(uint8_t app_id, const RawAddress& address) { +static void wl_direct_connect_timeout_cb(uint8_t app_id, const RawAddress& address) { log::debug("app_id={}, address={}", static_cast<int>(app_id), address); on_connection_timed_out(app_id, address); diff --git a/system/stack/hid/hidh_api.cc b/system/stack/hid/hidh_api.cc index a02af75063..97d811ed5b 100644 --- a/system/stack/hid/hidh_api.cc +++ b/system/stack/hid/hidh_api.cc @@ -49,9 +49,6 @@ #include "types/bluetooth/uuid.h" #include "types/raw_address.h" -// TODO(b/369381361) Enfore -Wmissing-prototypes -#pragma GCC diagnostic ignored "-Wmissing-prototypes" - using namespace bluetooth; using namespace bluetooth::legacy::stack::sdp; using bluetooth::Uuid; @@ -95,7 +92,7 @@ tHID_STATUS HID_HostGetSDPRecord(const RawAddress& addr, tSDP_DISCOVERY_DB* p_db } } -void hidh_get_str_attr(tSDP_DISC_REC* p_rec, uint16_t attr_id, uint16_t max_len, char* str) { +static void hidh_get_str_attr(tSDP_DISC_REC* p_rec, uint16_t attr_id, uint16_t max_len, char* str) { tSDP_DISC_ATTR* p_attr; uint16_t name_len; diff --git a/system/stack/mmc/OWNERS b/system/stack/mmc/OWNERS deleted file mode 100644 index a823e6e1dd..0000000000 --- a/system/stack/mmc/OWNERS +++ /dev/null @@ -1 +0,0 @@ -include /OWNERS_chromeos diff --git a/system/stack/rfcomm/rfc_ts_frames.cc b/system/stack/rfcomm/rfc_ts_frames.cc index e9df718116..495d0aea08 100644 --- a/system/stack/rfcomm/rfc_ts_frames.cc +++ b/system/stack/rfcomm/rfc_ts_frames.cc @@ -35,9 +35,6 @@ #include "stack/rfcomm/port_int.h" #include "stack/rfcomm/rfc_int.h" -// TODO(b/369381361) Enfore -Wmissing-prototypes -#pragma GCC diagnostic ignored "-Wmissing-prototypes" - using namespace bluetooth; /******************************************************************************* @@ -378,7 +375,7 @@ void rfc_send_rls(tRFC_MCB* p_mcb, uint8_t dlci, bool is_command, uint8_t status * Description This function sends Non Supported Command Response. * ******************************************************************************/ -void rfc_send_nsc(tRFC_MCB* p_mcb) { +static void rfc_send_nsc(tRFC_MCB* p_mcb) { uint8_t* p_data; BT_HDR* p_buf = (BT_HDR*)osi_malloc(RFCOMM_CMD_BUF_SIZE); diff --git a/system/stack/rnr/remote_name_request.cc b/system/stack/rnr/remote_name_request.cc index ed6801a855..bd0fcbce44 100644 --- a/system/stack/rnr/remote_name_request.cc +++ b/system/stack/rnr/remote_name_request.cc @@ -27,16 +27,12 @@ #include "stack/btm/security_device_record.h" #include "stack/include/btm_client_interface.h" -// TODO(b/369381361) Enfore -Wmissing-prototypes -#pragma GCC diagnostic ignored "-Wmissing-prototypes" +using namespace bluetooth; extern tBTM_CB btm_cb; -using namespace bluetooth; tBTM_STATUS btm_ble_read_remote_name(const RawAddress& remote_bda, tBTM_NAME_CMPL_CB* p_cb); bool btm_ble_cancel_remote_name(const RawAddress& remote_bda); -void btm_ble_read_remote_name_cmpl(bool status, const RawAddress& bda, uint16_t length, - char* p_name); bool BTM_SecAddRmtNameNotifyCallback(tBTM_RMT_NAME_CALLBACK* p_callback) { int i; @@ -80,7 +76,7 @@ bool BTM_IsRemoteNameKnown(const RawAddress& bd_addr, tBT_TRANSPORT /* transport * Returns void * ******************************************************************************/ -void btm_inq_rmt_name_failed_cancelled(void) { +static void btm_inq_rmt_name_failed_cancelled(void) { log::error("remname_active={}", btm_cb.rnr.remname_active); if (btm_cb.rnr.remname_active) { @@ -123,8 +119,8 @@ static uint16_t get_clock_offset_from_storage(const RawAddress& remote_bda) { : 0; } -tBTM_STATUS btm_initiate_rem_name(const RawAddress& remote_bda, uint64_t timeout_ms, - tBTM_NAME_CMPL_CB* p_cb) { +static tBTM_STATUS btm_initiate_rem_name(const RawAddress& remote_bda, uint64_t timeout_ms, + tBTM_NAME_CMPL_CB* p_cb) { /*** Make sure the device is ready ***/ if (!get_btm_client_interface().local.BTM_IsDeviceUp()) { return tBTM_STATUS::BTM_WRONG_MODE; diff --git a/system/stack/rnr/remote_name_request.h b/system/stack/rnr/remote_name_request.h index 6df83680dc..356f24ca49 100644 --- a/system/stack/rnr/remote_name_request.h +++ b/system/stack/rnr/remote_name_request.h @@ -151,6 +151,8 @@ tBTM_STATUS BTM_CancelRemoteDeviceName(void); void btm_process_remote_name(const RawAddress* bda, const BD_NAME bdn, uint16_t /* evt_len */, tHCI_STATUS hci_status); +void btm_inq_remote_name_timer_timeout(void* data); + namespace bluetooth { namespace stack { namespace rnr { diff --git a/system/stack/srvc/srvc_dis.cc b/system/stack/srvc/srvc_dis.cc index 38751c653c..2a0014e5c1 100644 --- a/system/stack/srvc/srvc_dis.cc +++ b/system/stack/srvc/srvc_dis.cc @@ -32,9 +32,6 @@ #include "types/bluetooth/uuid.h" #include "types/raw_address.h" -// TODO(b/369381361) Enfore -Wmissing-prototypes -#pragma GCC diagnostic ignored "-Wmissing-prototypes" - using namespace bluetooth; static const uint16_t dis_attr_uuid[] = { @@ -120,7 +117,7 @@ static void dis_gatt_c_read_dis_value_cmpl(tCONN_ID conn_id) { * Returns void * ******************************************************************************/ -bool dis_gatt_c_read_dis_req(tCONN_ID conn_id) { +static bool dis_gatt_c_read_dis_req(tCONN_ID conn_id) { tGATT_READ_PARAM param; memset(¶m, 0, sizeof(tGATT_READ_PARAM)); diff --git a/system/stack/test/btm/stack_btm_test.cc b/system/stack/test/btm/stack_btm_test.cc index c308911bce..7471d4faca 100644 --- a/system/stack/test/btm/stack_btm_test.cc +++ b/system/stack/test/btm/stack_btm_test.cc @@ -32,15 +32,13 @@ #include "stack/include/acl_hci_link_interface.h" #include "stack/include/btm_client_interface.h" #include "stack/l2cap/l2c_int.h" +#include "stack/rnr/remote_name_request.h" #include "stack/test/btm/btm_test_fixtures.h" #include "test/common/mock_functions.h" #include "test/mock/mock_legacy_hci_interface.h" #include "test/mock/mock_main_shim_entry.h" #include "types/raw_address.h" -// TODO(b/369381361) Enfore -Wmissing-prototypes -#pragma GCC diagnostic ignored "-Wmissing-prototypes" - using ::testing::_; using ::testing::Each; using ::testing::Eq; @@ -50,11 +48,11 @@ extern tBTM_CB btm_cb; tL2C_CB l2cb; -void btm_inq_remote_name_timer_timeout(void*) {} - const std::string kSmpOptions("mock smp options"); const std::string kBroadcastAudioConfigOptions("mock broadcast audio config options"); +void btm_inq_remote_name_timer_timeout(void*) {} + namespace { using testing::Return; diff --git a/system/stack/test/fuzzers/Android.bp b/system/stack/test/fuzzers/Android.bp index af2ad8623c..30ad5a5092 100644 --- a/system/stack/test/fuzzers/Android.bp +++ b/system/stack/test/fuzzers/Android.bp @@ -38,7 +38,6 @@ cc_defaults { "android.system.suspend.control-V1-ndk", "bluetooth_flags_c_lib", "libFraunhoferAAC", - "libbluetooth-dumpsys", "libbluetooth-types", "libbluetooth_core_rs", "libbluetooth_crypto_toolbox", diff --git a/system/test/headless/Android.bp b/system/test/headless/Android.bp index ec61ea012f..09a08f8fec 100644 --- a/system/test/headless/Android.bp +++ b/system/test/headless/Android.bp @@ -82,7 +82,6 @@ cc_binary { "lib-bt-packets-base", "libFraunhoferAAC", "libbase", - "libbluetooth-dumpsys", "libbluetooth-types", "libbluetooth_core_rs", "libbluetooth_crypto_toolbox", diff --git a/system/test/mock/mock_stack_hidh.cc b/system/test/mock/mock_stack_hidh.cc index 15b16a4ae8..607fa16753 100644 --- a/system/test/mock/mock_stack_hidh.cc +++ b/system/test/mock/mock_stack_hidh.cc @@ -27,9 +27,6 @@ #include "test/common/mock_functions.h" #include "types/raw_address.h" -// TODO(b/369381361) Enfore -Wmissing-prototypes -#pragma GCC diagnostic ignored "-Wmissing-prototypes" - tHID_STATUS HID_HostAddDev(const RawAddress& /* addr */, uint16_t /* attr_mask */, uint8_t* /* handle */) { inc_func_call_count(__func__); @@ -70,7 +67,3 @@ tHID_STATUS HID_HostWriteDev(uint8_t /* dev_handle */, uint8_t /* t_type */, uin return HID_SUCCESS; } void HID_HostInit(void) { inc_func_call_count(__func__); } -void hidh_get_str_attr(tSDP_DISC_REC* /* p_rec */, uint16_t /* attr_id */, uint16_t /* max_len */, - char* /* str */) { - inc_func_call_count(__func__); -} diff --git a/system/test/mock/mock_stack_srvc_dis.cc b/system/test/mock/mock_stack_srvc_dis.cc index fc301ea0a1..9a7a3ac884 100644 --- a/system/test/mock/mock_stack_srvc_dis.cc +++ b/system/test/mock/mock_stack_srvc_dis.cc @@ -22,22 +22,16 @@ #include <cstdint> #include "stack/include/srvc_api.h" +#include "stack/srvc/srvc_dis_int.h" #include "stack/srvc/srvc_eng_int.h" #include "test/common/mock_functions.h" #include "types/raw_address.h" -// TODO(b/369381361) Enfore -Wmissing-prototypes -#pragma GCC diagnostic ignored "-Wmissing-prototypes" - bool DIS_ReadDISInfo(const RawAddress& /* peer_bda */, tDIS_READ_CBACK* /* p_cback */, tDIS_ATTR_MASK /* mask */) { inc_func_call_count(__func__); return false; } -bool dis_gatt_c_read_dis_req(uint16_t /* conn_id */) { - inc_func_call_count(__func__); - return false; -} void dis_c_cmpl_cback(tSRVC_CLCB* /* p_clcb */, tGATTC_OPTYPE /* op */, tGATT_STATUS /* status */, tGATT_CL_COMPLETE* /* p_data */) { inc_func_call_count(__func__); diff --git a/system/test/suite/Android.bp b/system/test/suite/Android.bp index 98307ada71..ac4a5e3b24 100644 --- a/system/test/suite/Android.bp +++ b/system/test/suite/Android.bp @@ -65,7 +65,6 @@ cc_defaults { "lib-bt-packets-avrcp", "lib-bt-packets-base", "libFraunhoferAAC", - "libbluetooth-dumpsys", "libbluetooth-types", "libbluetooth_core_rs", "libbluetooth_core_rs_bridge", @@ -142,9 +141,6 @@ cc_test { "libbinder", "server_configurable_flags", ], - generated_headers: [ - "BluetoothGeneratedDumpsysDataSchema_h", - ], target: { android: { static_libs: [ diff --git a/tools/OWNERS b/tools/OWNERS deleted file mode 100644 index b2869ce1bc..0000000000 --- a/tools/OWNERS +++ /dev/null @@ -1,5 +0,0 @@ -# Reviewers for /tools - -jpawlowski@google.com -siyuanh@google.com -wescande@google.com diff --git a/tools/lint/OWNERS b/tools/lint/OWNERS deleted file mode 100644 index 9dd2d58fe3..0000000000 --- a/tools/lint/OWNERS +++ /dev/null @@ -1,2 +0,0 @@ -# Additional OWNERS for Bluetooth AndroidLint -salsavage@google.com diff --git a/tools/rootcanal/OWNERS b/tools/rootcanal/OWNERS deleted file mode 100644 index 22b124fd96..0000000000 --- a/tools/rootcanal/OWNERS +++ /dev/null @@ -1,3 +0,0 @@ -# Reviewers for /tools/rootcanal - -henrichataing@google.com |