diff --git a/.clang-tidy b/.clang-tidy new file mode 100644 index 0000000000000000000000000000000000000000..a11ef26d94e150a5ec414e85a560d27b77a5c1f3 --- /dev/null +++ b/.clang-tidy @@ -0,0 +1,20 @@ +--- +CheckOptions: + - key: misc-include-cleaner.IgnoreHeaders + value: "(\ + fmt/.*|\ + bits/.*.h|\ + asm-generic/.*.h|\ + sys/poll.h|\ + sys/endian.h|\ + sys/ioctl.h|\ + arpa/inet.h|\ + linux/time.h|\ + linux/if.h|\ + linux/sockios.h|\ + netinet/in.h|\ + osi/include/compat.h|\ + android_bluetooth_sysprop.h|\ + hfp.sysprop.h|\ + enums.pb.h|\ + __chrono/duration.h)" diff --git a/.gitignore b/.gitignore index 3e6891d63f92bc5e07030d36e1c14e83d8b368ef..057f4717e3b89dc48c1d3bee5b572eaefc804c61 100644 --- a/.gitignore +++ b/.gitignore @@ -15,3 +15,4 @@ compile_commands.json **/.idea **/__pycache__/ *.py[cod] +**/._* diff --git a/Android.bp b/Android.bp index e88d6ab550663c690b388f625f84d7c4374146f1..9142bd51aedbf286bf3383a8849dc6cca07cd7b7 100644 --- a/Android.bp +++ b/Android.bp @@ -66,6 +66,7 @@ cc_defaults { "-Wall", "-Werror", "-Wextra", + "-Wmissing-prototypes", // Override global.go that demote the error to a warning "-Werror=format", "-Werror=reorder-init-list", @@ -74,6 +75,32 @@ cc_defaults { cpp_std: "c++20", } +// List of tidy checks that are enabled for cc targets. +// Note that the goal is not to enable all checks, many of them will +// appear as noise especially in the modernize-* range. +bluetooth_tidy_checks = [ + "-*", + "misc-*", + + // This check implements detection of local variables which could be declared + // as const but are not. + "-misc-const-correctness", + + // Finds classes that contain non-static data members in addition to user-declared + // non-static member functions and diagnose all data members declared with a + // non-public access specifier. + "-misc-non-private-member-variables-in-classes", +] + +// This default tidy checks that will be run against all the cc targets +// developed by the Bluetooth team. +cc_defaults { + name: "bluetooth_tidy", + tidy: true, + tidy_checks: bluetooth_tidy_checks, + tidy_checks_as_errors: bluetooth_tidy_checks, +} + java_defaults { name: "bluetooth_errorprone_rules", errorprone: { @@ -90,6 +117,7 @@ java_defaults { "-Xep:DirectInvocationOnMock:ERROR", "-Xep:EmptyBlockTag:ERROR", "-Xep:EmptyCatch:ERROR", + "-Xep:EnumOrdinal:ERROR", "-Xep:EqualsGetClass:ERROR", "-Xep:EqualsHashCode:ERROR", "-Xep:EqualsIncompatibleType:ERROR", @@ -120,10 +148,13 @@ java_defaults { "-Xep:NonAtomicVolatileUpdate:ERROR", "-Xep:NonCanonicalType:ERROR", "-Xep:NotJavadoc:ERROR", + "-Xep:NullablePrimitive:ERROR", + "-Xep:NullableVoid:ERROR", "-Xep:ObjectEqualsForPrimitives:ERROR", "-Xep:OperatorPrecedence:ERROR", "-Xep:ReferenceEquality:ERROR", "-Xep:ReturnAtTheEndOfVoidFunction:ERROR", + "-Xep:ReturnFromVoid:ERROR", "-Xep:StaticAssignmentInConstructor:ERROR", "-Xep:StaticGuardedByInstance:ERROR", "-Xep:StringCaseLocaleUsage:ERROR", @@ -140,14 +171,17 @@ java_defaults { "-Xep:UnusedMethod:ERROR", "-Xep:UnusedNestedClass:ERROR", "-Xep:UnusedVariable:ERROR", + "-Xep:VariableNameSameAsType:ERROR", "-Xep:WaitNotInLoop:ERROR", "-Xep:WakelockReleasedDangerously:ERROR", // Exclude generated files "-XepExcludedPaths:.*/srcjars/.*", - // The @InlineMe annotation is not available - // "-Xep:InlineMeSuggester:OFF", + // The @InlineMe annotation could be made available, but it would + // apply on external facing API. This is not desired. + // For more context, see https://r.android.com/3303475 + "-Xep:InlineMeSuggester:OFF", ], }, } @@ -155,10 +189,9 @@ java_defaults { java_defaults { name: "bluetooth_framework_errorprone_rules", defaults: ["bluetooth_errorprone_rules"], - plugins: [ - "error_prone_android_framework", - ], errorprone: { + extra_check_modules: ["error_prone_android_framework"], + javacflags: [ "-Xep:AndroidFrameworkBinderIdentity:ERROR", "-Xep:AndroidFrameworkBluetoothPermission:ERROR", diff --git a/CPPLINT.cfg b/CPPLINT.cfg index cc062661c71c86524b7e04325cfa758571dfe361..3dff24b5c46df0be4e5fb1ad8d47e81adb93723b 100644 --- a/CPPLINT.cfg +++ b/CPPLINT.cfg @@ -4,14 +4,6 @@ linelength=100 # CPPLint enforces +1, but our rule is no indentation. filter=-whitespace/indent -# TODO: b/364967694 re-enable the warning -filter=-whitespace/newline -# TODO: b/364967694 re-enable the warning -filter=-whitespace/blank_line -# TODO: b/364967694 re-enable the warning -filter=-whitespace/ending_newline -# TODO: b/364967694 re-enable the warning -filter=-readability/check # TODO: b/364967694 re-enable the warning filter=-runtime/int # TODO: b/364967694 re-enable the warning diff --git a/Cargo.toml b/Cargo.toml index 5ed873e057fcc55b349cac7ba86e32a73638078a..d3cee8799b46262cccfb9f91b3268870ee10c96d 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -16,7 +16,6 @@ [workspace] default-members = [ - "system/gd/rust/shim", "system/gd/rust/topshim", "system/gd/rust/linux/mgmt", "system/gd/rust/linux/service", @@ -26,7 +25,6 @@ default-members = [ ] members = [ - "system/gd/rust/shim", "system/gd/rust/topshim", "system/gd/rust/linux/mgmt", "system/gd/rust/linux/service", diff --git a/OWNERS b/OWNERS index a69eb5a72e7892e41c2e94bb10e6849599256ce3..b403b68882c86cef1c2d76edf792127d985c8880 100644 --- a/OWNERS +++ b/OWNERS @@ -1,17 +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} - -# Per-file ownership - -# Build files / test_config / presubmit / preupload -per-file PREUPLOAD.cfg,TEST_MAPPING,*.bp,*.xml=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 15f209f6c7cfb41b7c6992143a8e5ed417c03d92..0000000000000000000000000000000000000000 --- a/OWNERS_automotive +++ /dev/null @@ -1,3 +0,0 @@ -# Project owners -salsavage@google.com -samdaria@google.com diff --git a/OWNERS_build b/OWNERS_build deleted file mode 100644 index 5b3f4bad26bb6d12a5b76f2f028bde581286585c..0000000000000000000000000000000000000000 --- a/OWNERS_build +++ /dev/null @@ -1 +0,0 @@ -wescande@google.com diff --git a/OWNERS_chromeos b/OWNERS_chromeos deleted file mode 100644 index 075a04e5e3c80b043790f920a8dbeebb1d79ef51..0000000000000000000000000000000000000000 --- 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 883d5dc78270ee858422af716d0278378815c494..0000000000000000000000000000000000000000 --- 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 1cebb11002355eb9d6ac0cb895e240ae67180c9e..0000000000000000000000000000000000000000 --- 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 e70772a9527eb199cb115399b3cf6bab7bae263a..0000000000000000000000000000000000000000 --- a/OWNERS_hearingaid +++ /dev/null @@ -1 +0,0 @@ -charliebout@google.com diff --git a/OWNERS_leaudio b/OWNERS_leaudio deleted file mode 100644 index 0ba606bbf0a93823fbc6d975e4764668385a7116..0000000000000000000000000000000000000000 --- a/OWNERS_leaudio +++ /dev/null @@ -1,4 +0,0 @@ -siyuanh@google.com -jpawlowski@google.com -rongxuan@google.com -yuyangh@google.com diff --git a/TEST_MAPPING b/TEST_MAPPING index 5f21a9b8008fcf89ae41382b075e80d0a67004f6..bd98b7d91cfe93b32e7f067135c4193a4f2682fd 100644 --- a/TEST_MAPPING +++ b/TEST_MAPPING @@ -56,7 +56,7 @@ "name": "net_test_device_iot_config" }, { - "name": "net_test_gatt_conn_multiplexing" + "name": "net_test_conn_multiplexing" }, { "name": "net_test_hci" @@ -107,9 +107,6 @@ { "name": "bluetooth_test_common" }, - { - "name": "bluetooth_test_sdp" - }, { "name": "bluetooth_vc_test" }, @@ -251,7 +248,7 @@ "name": "net_test_device_iot_config" }, { - "name": "net_test_gatt_conn_multiplexing" + "name": "net_test_conn_multiplexing" }, { "name": "net_test_stack" @@ -272,9 +269,6 @@ { "name": "bluetooth_test_common" }, - { - "name": "bluetooth_test_sdp" - }, { "name": "bluetooth_vc_test" }, @@ -314,10 +308,10 @@ "name": "bluetooth-test-audio-hal-a2dp-provider-info" }, { - "name": "bluetooth_test_gdx_unit" + "name": "net_test_bta_jv" }, { - "name": "net_test_bta_jv" + "name": "net_test_stack_avctp" }, { "name": "asrc_resampler_test" diff --git a/android/BluetoothLegacyMigration/OWNERS b/android/BluetoothLegacyMigration/OWNERS deleted file mode 100644 index 66467c7b3e9b237dba67c24e1e78ea8246b35568..0000000000000000000000000000000000000000 --- 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 29d6f601cc6984632dd46c191cfcc55446318d5c..0000000000000000000000000000000000000000 --- a/android/ChannelSoundingTestApp/OWNERS +++ /dev/null @@ -1 +0,0 @@ -include /OWNERS_cs diff --git a/android/ChannelSoundingTestApp/app/src/main/java/com/android/bluetooth/channelsoundingtestapp/DistanceMeasurementInitiator.java b/android/ChannelSoundingTestApp/app/src/main/java/com/android/bluetooth/channelsoundingtestapp/DistanceMeasurementInitiator.java index 9d39dcb10f633e92e60c9e76c6666dcb424db8a3..1dc753318e8fd654638eb0d635fe1cd6e1058467 100644 --- a/android/ChannelSoundingTestApp/app/src/main/java/com/android/bluetooth/channelsoundingtestapp/DistanceMeasurementInitiator.java +++ b/android/ChannelSoundingTestApp/app/src/main/java/com/android/bluetooth/channelsoundingtestapp/DistanceMeasurementInitiator.java @@ -38,6 +38,34 @@ import java.util.concurrent.Executors; class DistanceMeasurementInitiator { + enum Freq { + HIGH(DistanceMeasurementParams.REPORT_FREQUENCY_HIGH), + MEDIUM(DistanceMeasurementParams.REPORT_FREQUENCY_MEDIUM), + LOW(DistanceMeasurementParams.REPORT_FREQUENCY_LOW); + private final int freq; + + Freq(int freq) { + this.freq = freq; + } + + int getFreq() { + return freq; + } + + @Override + public String toString() { + return name(); + } + + public static Freq fromName(String name) { + try { + return Freq.valueOf(name); + } catch (IllegalArgumentException e) { + return MEDIUM; + } + } + } + private static final int DISTANCE_MEASUREMENT_DURATION_SEC = 3600; private static final List> mDistanceMeasurementMethodMapping = List.of( @@ -119,8 +147,12 @@ class DistanceMeasurementInitiator { return methods; } + List getMeasurementFreqs() { + return List.of(Freq.MEDIUM.toString(), Freq.HIGH.toString(), Freq.LOW.toString()); + } + @SuppressLint("MissingPermission") // permissions are checked upfront - void startDistanceMeasurement(String distanceMeasurementMethodName) { + void startDistanceMeasurement(String distanceMeasurementMethodName, String selectedFreq) { if (mTargetDevice == null) { printLog("do Gatt connect first"); @@ -132,7 +164,7 @@ class DistanceMeasurementInitiator { DistanceMeasurementParams params = new DistanceMeasurementParams.Builder(mTargetDevice) .setDurationSeconds(DISTANCE_MEASUREMENT_DURATION_SEC) - .setFrequency(DistanceMeasurementParams.REPORT_FREQUENCY_LOW) + .setFrequency(Freq.fromName(selectedFreq).getFreq()) .setMethodId(getDistanceMeasurementMethodId(distanceMeasurementMethodName)) .build(); DistanceMeasurementManager distanceMeasurementManager = diff --git a/android/ChannelSoundingTestApp/app/src/main/java/com/android/bluetooth/channelsoundingtestapp/InitiatorFragment.java b/android/ChannelSoundingTestApp/app/src/main/java/com/android/bluetooth/channelsoundingtestapp/InitiatorFragment.java index fe3a211f9f7965d6df3fb5f2b3c0c10a1c174d60..b1b96d7bb18a26307f33d5824025119492aabd98 100644 --- a/android/ChannelSoundingTestApp/app/src/main/java/com/android/bluetooth/channelsoundingtestapp/InitiatorFragment.java +++ b/android/ChannelSoundingTestApp/app/src/main/java/com/android/bluetooth/channelsoundingtestapp/InitiatorFragment.java @@ -43,9 +43,11 @@ public class InitiatorFragment extends Fragment { private static final DecimalFormat DISTANCE_DECIMAL_FMT = new DecimalFormat("0.00"); private ArrayAdapter mDmMethodArrayAdapter; + private ArrayAdapter mFreqArrayAdapter; private TextView mDistanceText; private CanvasView mDistanceCanvasView; private Spinner mSpinnerDmMethod; + private Spinner mSpinnerFreq; private Button mButtonCs; private LinearLayout mDistanceViewLayout; private TextView mLogText; @@ -63,6 +65,7 @@ public class InitiatorFragment extends Fragment { mButtonCs = (Button) root.findViewById(R.id.btn_cs); mSpinnerDmMethod = (Spinner) root.findViewById(R.id.spinner_dm_method); + mSpinnerFreq = (Spinner) root.findViewById(R.id.spinner_freq); mDistanceViewLayout = (LinearLayout) root.findViewById(R.id.layout_distance_view); mDistanceText = new TextView(getContext()); mDistanceViewLayout.addView(mDistanceText); @@ -85,6 +88,11 @@ public class InitiatorFragment extends Fragment { mDmMethodArrayAdapter.setDropDownViewResource( android.R.layout.simple_spinner_dropdown_item); mSpinnerDmMethod.setAdapter(mDmMethodArrayAdapter); + mFreqArrayAdapter = + new ArrayAdapter( + getContext(), android.R.layout.simple_spinner_item, new ArrayList<>()); + mFreqArrayAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); + mSpinnerFreq.setAdapter(mFreqArrayAdapter); mInitiatorViewModel = new ViewModelProvider(this).get(InitiatorViewModel.class); mBleConnectionViewModel = new ViewModelProvider(this).get(BleConnectionViewModel.class); @@ -134,14 +142,15 @@ public class InitiatorFragment extends Fragment { }); mDmMethodArrayAdapter.addAll(mInitiatorViewModel.getSupportedDmMethods()); - + mFreqArrayAdapter.addAll(mInitiatorViewModel.getMeasurementFreqs()); mButtonCs.setOnClickListener( v -> { String methodName = mSpinnerDmMethod.getSelectedItem().toString(); + String freq = mSpinnerFreq.getSelectedItem().toString(); if (TextUtils.isEmpty(methodName)) { printLog("the device doesn't support any distance measurement methods."); } - mInitiatorViewModel.toggleCsStartStop(methodName); + mInitiatorViewModel.toggleCsStartStop(methodName, freq); }); } diff --git a/android/ChannelSoundingTestApp/app/src/main/java/com/android/bluetooth/channelsoundingtestapp/InitiatorViewModel.java b/android/ChannelSoundingTestApp/app/src/main/java/com/android/bluetooth/channelsoundingtestapp/InitiatorViewModel.java index f54ec7b94a6b859b91fe46e8b4aa84787a5008e4..e07e7a15934f7595ae7feeaffc9723ee77f1519d 100644 --- a/android/ChannelSoundingTestApp/app/src/main/java/com/android/bluetooth/channelsoundingtestapp/InitiatorViewModel.java +++ b/android/ChannelSoundingTestApp/app/src/main/java/com/android/bluetooth/channelsoundingtestapp/InitiatorViewModel.java @@ -71,9 +71,14 @@ public class InitiatorViewModel extends AndroidViewModel { return mDistanceMeasurementInitiator.getDistanceMeasurementMethods(); } - void toggleCsStartStop(String distanceMeasurementMethodName) { + List getMeasurementFreqs() { + return mDistanceMeasurementInitiator.getMeasurementFreqs(); + } + + void toggleCsStartStop(String distanceMeasurementMethodName, String freq) { if (!mCsStarted.getValue()) { - mDistanceMeasurementInitiator.startDistanceMeasurement(distanceMeasurementMethodName); + mDistanceMeasurementInitiator.startDistanceMeasurement( + distanceMeasurementMethodName, freq); } else { mDistanceMeasurementInitiator.stopDistanceMeasurement(); } diff --git a/android/ChannelSoundingTestApp/app/src/main/res/layout/fragment_initiator.xml b/android/ChannelSoundingTestApp/app/src/main/res/layout/fragment_initiator.xml index f5f57f2c273979fb10115bf3335b89833957e581..39b0246c057622f40048d3433e1263006ac17bde 100644 --- a/android/ChannelSoundingTestApp/app/src/main/res/layout/fragment_initiator.xml +++ b/android/ChannelSoundingTestApp/app/src/main/res/layout/fragment_initiator.xml @@ -21,15 +21,43 @@ app:layout_constraintStart_toStartOf="parent" app:layout_constraintTop_toTopOf="parent" /> - + + +