blob: fa0a596bcf85d03c78bcb9c229ad53784488a4e1 [file] [log] [blame]
Bob Badour92ecf7c2021-02-12 18:05:29 -08001package {
Etienne Ruffieux917abc32022-02-28 14:07:17 +00002 default_visibility: [":__subpackages__"],
Bob Badour92ecf7c2021-02-12 18:05:29 -08003 default_applicable_licenses: ["system_bt_license"],
William Escanded77d9d12025-08-11 14:21:21 -07004 default_team: "trendy_team_bluetooth",
Bob Badour92ecf7c2021-02-12 18:05:29 -08005}
6
7// Added automatically by a large-scale-change that took the approach of
8// 'apply every license found to every target'. While this makes sure we respect
9// every license restriction, it may not be entirely correct.
10//
11// e.g. GPL in an MIT project might only apply to the contrib/ directory.
12//
13// Please consider splitting the single license below into multiple licenses,
14// taking care not to lose any license_kind information, and overriding the
15// default license using the 'licenses: [...]' property on targets as needed.
16//
17// For unused files, consider creating a 'fileGroup' with "//visibility:private"
18// to attach the license to, and including a comment whether the files may be
19// used in the current project.
20// See: http://go/android-license-faq
21license {
22 name: "system_bt_license",
23 visibility: [":__subpackages__"],
24 license_kinds: [
25 "SPDX-license-identifier-Apache-2.0",
26 "SPDX-license-identifier-BSD",
27 "SPDX-license-identifier-MIT",
28 "legacy_unencumbered",
29 ],
30 license_text: [
31 "NOTICE",
32 ],
33}
34
Jack Hecac30a22018-08-28 18:28:55 -070035filegroup {
Thomas Girardier21e6e032025-02-12 21:39:33 -080036 name: "BluetoothGTestConfigTemplate",
Colin Cross03e29e52019-05-23 14:12:59 -070037 srcs: [
Thomas Girardier21e6e032025-02-12 21:39:33 -080038 "BluetoothGTestTemplate.xml",
39 ],
40}
41
42filegroup {
43 name: "BluetoothRustTestConfigTemplate",
44 srcs: [
45 "BluetoothRustTestTemplate.xml",
Colin Cross03e29e52019-05-23 14:12:59 -070046 ],
Jack Hecac30a22018-08-28 18:28:55 -070047}
David Duartea84ffd12023-03-28 17:58:57 +000048
David Duarte4043a702023-06-04 16:44:03 +000049// This default contains properties that should be common to all the cc targets
50// developed by the Bluetooth team.
51//
52// Be careful when adding new properties here:
53// - The option should not impact negatively any target, for example "-Wno-*"
54// options should not be added here but instead on every targets needing
55// them to avoid allowing adding new warnings in targets that didn't contained
56// them (you can use the bpmodify tool to ease the work of adding this warning
57// everywhere) and also allows cleaning them one at a time.
58//
59// - The option should apply to all the c/c++ code developed by the Bluetooth team:
60// test, tools, fuzzers, etc, not only production targets, if you need to add an option
61// for a subset of Bluetooth cc targets you should look at the defaults including this
62// defaults like "fluoride_defaults" and "gd_defaults".
63//
64// - Try to keep the name as precise as possible to document to the dependent of what
65// this default contains. This also means that if you add a new option that isn't
66// documented by the name of this default, rename it.
67//
William Escande22560942024-09-18 16:44:36 -070068// - Try avoiding adding option that would not fit "future" targets, for example dependencies,
David Duarte4043a702023-06-04 16:44:03 +000069// even if every modules of Bluetooth depends on a specific dependency it should be left out
70// from this default to not push it for future targets that might not need it.
71cc_defaults {
72 name: "bluetooth_cflags",
73 cflags: [
74 "-Wall",
75 "-Werror",
76 "-Wextra",
Henri Chataing22f5e112024-09-21 01:20:25 +000077 "-Wmissing-prototypes",
William Escande27297182023-10-09 17:15:04 -070078 // Override global.go that demote the error to a warning
David Duartec8d2a492024-04-11 18:02:38 +000079 "-Werror=format",
William Escande27297182023-10-09 17:15:04 -070080 "-Werror=reorder-init-list",
Henri Chataing55c29e12025-08-26 23:14:31 +000081 "-Werror=unused-variable",
Henri Chataing90bcf252025-02-13 19:04:05 +000082 "-Wthread-safety",
David Duarte4043a702023-06-04 16:44:03 +000083 ],
David Duarte19954d12023-08-01 14:07:56 +000084 c_std: "c99",
Myles Watsondbd43e72024-02-15 11:02:58 -080085 cpp_std: "c++20",
David Duarte4043a702023-06-04 16:44:03 +000086}
William Escande22560942024-09-18 16:44:36 -070087
Henri Chataingee8f0002025-08-11 15:30:48 -070088// Base configuration for Bluetooth fuzz targets.
89cc_defaults {
90 name: "bluetooth_fuzz_config",
91 fuzz_config: {
92 componentid: 27441, // Android > Android OS & Apps > Systems > bluetooth
93 fuzzed_code_usage: "shipped",
94 service_privilege: "privileged",
95 vector: "remote",
96 users: "single_user",
97 cc: [
98 "android-bluetooth-security@google.com",
99 "android-security-assurance-redteam@google.com",
100 ],
101 hotlists: [
102 "3705175", // ASA Red Team Discovered Issues
103 "4593311", // Ittiam Fuzzer Bug
104 "4810445", // ASA Red Team: Bluetooth Engagement Issues
105 ],
106 acknowledgement: [
107 "Android Bluetooth Team of Google",
108 "Android Red Team of Google",
109 ],
110 },
111}
112
Henri Chataing31dba772024-10-18 14:33:17 -0700113// List of tidy checks that are enabled for cc targets.
114// Note that the goal is not to enable all checks, many of them will
115// appear as noise especially in the modernize-* range.
116bluetooth_tidy_checks = [
117 "-*",
118 "misc-*",
119
Henri Chataing98a8a5c2025-04-08 22:46:23 +0000120 // Checks for unused and missing includes.
121 // Should be enabled as an alternative to IWYU, but currently generates
122 // too many warnings.
123 "-misc-include-cleaner",
124
Henri Chataing31dba772024-10-18 14:33:17 -0700125 // This check implements detection of local variables which could be declared
126 // as const but are not.
127 "-misc-const-correctness",
Henri Chataing693806a2024-10-23 20:45:34 +0000128
129 // Finds classes that contain non-static data members in addition to user-declared
130 // non-static member functions and diagnose all data members declared with a
131 // non-public access specifier.
132 "-misc-non-private-member-variables-in-classes",
Henri Chataing31dba772024-10-18 14:33:17 -0700133]
134
135// This default tidy checks that will be run against all the cc targets
136// developed by the Bluetooth team.
137cc_defaults {
138 name: "bluetooth_tidy",
139 tidy: true,
140 tidy_checks: bluetooth_tidy_checks,
141 tidy_checks_as_errors: bluetooth_tidy_checks,
142}
143
William Escande22560942024-09-18 16:44:36 -0700144java_defaults {
145 name: "bluetooth_errorprone_rules",
146 errorprone: {
147 enabled: true,
148 javacflags: [
149 "-Xep:AlmostJavadoc:ERROR",
150 "-Xep:AlreadyChecked:ERROR",
William Escande15592992025-02-26 17:43:01 -0800151 "-Xep:AmbiguousMethodReference:ERROR",
Ömer Faruk Yılmaz88ec13f2025-02-25 06:20:08 +0000152 "-Xep:ArrayRecordComponent:ERROR",
William Escande685846c2025-05-02 10:41:22 -0700153 "-Xep:AssignmentExpression:ERROR",
William Escande15592992025-02-26 17:43:01 -0800154 "-Xep:AttemptedNegativeZero:ERROR",
William Escande22560942024-09-18 16:44:36 -0700155 "-Xep:BadImport:ERROR",
William Escande15592992025-02-26 17:43:01 -0800156 "-Xep:BadInstanceof:ERROR",
William Escande22560942024-09-18 16:44:36 -0700157 "-Xep:CatchAndPrintStackTrace:ERROR",
158 "-Xep:CatchFail:ERROR",
159 "-Xep:CheckReturnValue:ERROR",
160 "-Xep:ClassCanBeStatic:ERROR",
161 "-Xep:DateFormatConstant:ERROR",
162 "-Xep:DirectInvocationOnMock:ERROR",
William Escandef4c29142024-12-11 18:36:09 -0800163 "-Xep:DuplicateBranches:ERROR",
William Escande8c511f62025-07-30 18:42:21 -0700164 "-Xep:EffectivelyPrivate:ERROR",
William Escande22560942024-09-18 16:44:36 -0700165 "-Xep:EmptyBlockTag:ERROR",
166 "-Xep:EmptyCatch:ERROR",
William Escande023cccb2024-10-17 17:56:01 -0700167 "-Xep:EnumOrdinal:ERROR",
William Escande22560942024-09-18 16:44:36 -0700168 "-Xep:EqualsGetClass:ERROR",
169 "-Xep:EqualsHashCode:ERROR",
170 "-Xep:EqualsIncompatibleType:ERROR",
171 "-Xep:FallThrough:ERROR",
Ömer Faruk Yılmaz4e1dfbd2025-04-15 08:49:51 +0000172 // "-Xep:FieldCanBeFinal:ERROR", // TODO: b/410743019 - enable this check
William Escande4e24ffe2025-02-20 19:02:10 -0800173 "-Xep:FieldCanBeLocal:ERROR",
William Escanded4ada322025-02-20 18:55:31 -0800174 "-Xep:FieldCanBeStatic:ERROR",
William Escande22560942024-09-18 16:44:36 -0700175 "-Xep:Finalize:ERROR",
William Escande0f45ca02025-02-20 18:21:32 -0800176 "-Xep:ForEachIterable:ERROR",
William Escande22560942024-09-18 16:44:36 -0700177 "-Xep:FutureReturnValueIgnored:ERROR",
178 "-Xep:GuardedBy:ERROR",
179 "-Xep:HidingField:ERROR",
180 "-Xep:InconsistentHashCode:ERROR",
William Escande15592992025-02-26 17:43:01 -0800181 "-Xep:IncrementInForLoopAndHeader:ERROR",
William Escande22560942024-09-18 16:44:36 -0700182 "-Xep:InlineFormatString:ERROR",
183 "-Xep:InlineMeInliner:ERROR",
William Escandeedd0da02025-07-01 11:38:26 -0700184 "-Xep:IntLiteralCast:ERROR",
William Escande22560942024-09-18 16:44:36 -0700185 "-Xep:InvalidBlockTag:ERROR",
186 "-Xep:InvalidInlineTag:ERROR",
William Escande15592992025-02-26 17:43:01 -0800187 "-Xep:InvalidLink:ERROR",
William Escande22560942024-09-18 16:44:36 -0700188 "-Xep:InvalidParam:ERROR",
William Escandee7a434f2025-05-02 22:44:22 -0700189 "-Xep:JUnit4EmptyMethods:ERROR",
William Escande15592992025-02-26 17:43:01 -0800190 "-Xep:JavaLangClash:ERROR",
William Escande22560942024-09-18 16:44:36 -0700191 "-Xep:JavaUtilDate:ERROR",
192 "-Xep:JdkObsolete:ERROR",
193 "-Xep:LockOnNonEnclosingClassLiteral:ERROR",
194 "-Xep:LongFloatConversion:ERROR",
195 "-Xep:LoopOverCharArray:ERROR",
William Escande0f45ca02025-02-20 18:21:32 -0800196 "-Xep:MethodCanBeStatic:ERROR",
William Escande22560942024-09-18 16:44:36 -0700197 "-Xep:MissingCasesInEnumSwitch:ERROR",
William Escandeedd9e9f2025-05-13 15:09:40 -0700198 "-Xep:MissingDefault:ERROR",
William Escande22560942024-09-18 16:44:36 -0700199 "-Xep:MixedMutabilityReturnType:ERROR",
200 "-Xep:MockNotUsedInProduction:ERROR",
201 "-Xep:ModifiedButNotUsed:ERROR",
202 "-Xep:ModifyCollectionInEnhancedForLoop:ERROR",
203 "-Xep:NarrowCalculation:ERROR",
204 "-Xep:NarrowingCompoundAssignment:ERROR",
205 "-Xep:NonApiType:ERROR",
206 "-Xep:NonAtomicVolatileUpdate:ERROR",
William Escande6626b1a2025-04-07 17:21:47 -0700207 "-Xep:NonCanonicalStaticMemberImport:ERROR",
William Escande22560942024-09-18 16:44:36 -0700208 "-Xep:NonCanonicalType:ERROR",
209 "-Xep:NotJavadoc:ERROR",
William Escande15592992025-02-26 17:43:01 -0800210 "-Xep:NullOptional:ERROR",
211 "-Xep:NullableOptional:ERROR",
William Escande5cd9c5e2024-10-23 16:43:14 -0700212 "-Xep:NullablePrimitive:ERROR",
213 "-Xep:NullableVoid:ERROR",
William Escande22560942024-09-18 16:44:36 -0700214 "-Xep:ObjectEqualsForPrimitives:ERROR",
William Escande15592992025-02-26 17:43:01 -0800215 // "-Xep:ObjectToString:ERROR", // Wrongfully reporting errors
William Escande22560942024-09-18 16:44:36 -0700216 "-Xep:OperatorPrecedence:ERROR",
William Escande8ead8b12024-12-11 19:14:47 -0800217 "-Xep:RedundantControlFlow:ERROR",
William Escande22560942024-09-18 16:44:36 -0700218 "-Xep:ReferenceEquality:ERROR",
219 "-Xep:ReturnAtTheEndOfVoidFunction:ERROR",
Antoine SOULIER0dc741f2024-08-21 18:07:29 +0000220 "-Xep:ReturnFromVoid:ERROR",
William Escande0b7dd7f2025-02-19 16:00:51 -0800221 "-Xep:SelfAssertion:ERROR",
William Escande62a85d82025-06-28 21:57:39 -0700222 "-Xep:StatementSwitchToExpressionSwitch:ERROR",
William Escande22560942024-09-18 16:44:36 -0700223 "-Xep:StaticAssignmentInConstructor:ERROR",
224 "-Xep:StaticGuardedByInstance:ERROR",
225 "-Xep:StringCaseLocaleUsage:ERROR",
226 "-Xep:StringCharset:ERROR",
William Escande004fcbc2025-05-02 10:44:01 -0700227 "-Xep:StringConcatToTextBlock:ERROR",
William Escande15592992025-02-26 17:43:01 -0800228 // "-Xep:StringSplitter:ERROR", // Not enabled in android platform
William Escandeedd9e9f2025-05-13 15:09:40 -0700229 "-Xep:SwitchDefault:ERROR",
William Escande22560942024-09-18 16:44:36 -0700230 "-Xep:SynchronizeOnNonFinalField:ERROR",
William Escande55cf6ca2025-02-13 15:59:15 -0800231 "-Xep:ThreadJoinLoop:ERROR",
William Escande22560942024-09-18 16:44:36 -0700232 "-Xep:ToStringReturnsNull:ERROR",
William Escandeedd9e9f2025-05-13 15:09:40 -0700233 "-Xep:TraditionalSwitchExpression:ERROR",
William Escande15592992025-02-26 17:43:01 -0800234 "-Xep:TruthAssertExpected:ERROR",
William Escande22560942024-09-18 16:44:36 -0700235 "-Xep:TruthConstantAsserts:ERROR",
William Escande15592992025-02-26 17:43:01 -0800236 "-Xep:TruthGetOrDefault:ERROR",
William Escande22560942024-09-18 16:44:36 -0700237 "-Xep:TruthIncompatibleType:ERROR",
238 "-Xep:UndefinedEquals:ERROR",
239 "-Xep:UnnecessaryAssignment:ERROR",
240 "-Xep:UnnecessaryAsync:ERROR",
William Escandeedd9e9f2025-05-13 15:09:40 -0700241 "-Xep:UnnecessaryBreakInSwitch:ERROR",
242 "-Xep:UnnecessaryDefaultInEnumSwitch:ERROR",
William Escande22560942024-09-18 16:44:36 -0700243 "-Xep:UnnecessaryStringBuilder:ERROR",
244 "-Xep:UnrecognisedJavadocTag:ERROR",
245 "-Xep:UnusedMethod:ERROR",
246 "-Xep:UnusedNestedClass:ERROR",
William Escande15592992025-02-26 17:43:01 -0800247 "-Xep:UnusedTypeParameter:ERROR",
William Escande22560942024-09-18 16:44:36 -0700248 "-Xep:UnusedVariable:ERROR",
William Escandeedd9e9f2025-05-13 15:09:40 -0700249 "-Xep:UseEnumSwitch:ERROR",
William Escande57679d52024-10-28 14:23:27 -0700250 "-Xep:VariableNameSameAsType:ERROR",
William Escande22560942024-09-18 16:44:36 -0700251 "-Xep:WaitNotInLoop:ERROR",
252 "-Xep:WakelockReleasedDangerously:ERROR",
253
254 // Exclude generated files
255 "-XepExcludedPaths:.*/srcjars/.*",
256
William Escandebed62da2024-10-21 14:16:20 -0700257 // The @InlineMe annotation could be made available, but it would
William Escande57679d52024-10-28 14:23:27 -0700258 // apply on external facing API. This is not desired.
259 // For more context, see https://r.android.com/3303475
William Escandebed62da2024-10-21 14:16:20 -0700260 "-Xep:InlineMeSuggester:OFF",
William Escande22560942024-09-18 16:44:36 -0700261 ],
262 },
263}
264
265java_defaults {
266 name: "bluetooth_framework_errorprone_rules",
267 defaults: ["bluetooth_errorprone_rules"],
William Escande22560942024-09-18 16:44:36 -0700268 errorprone: {
William Escandec7480a12024-11-12 11:51:59 -0800269 extra_check_modules: ["error_prone_android_framework"],
270
William Escande22560942024-09-18 16:44:36 -0700271 javacflags: [
272 "-Xep:AndroidFrameworkBinderIdentity:ERROR",
273 "-Xep:AndroidFrameworkBluetoothPermission:ERROR",
274 "-Xep:AndroidFrameworkCompatChange:ERROR",
275 "-Xep:AndroidFrameworkEfficientParcelable:ERROR",
276 "-Xep:AndroidFrameworkEfficientStrings:ERROR",
277 "-Xep:AndroidFrameworkPendingIntentMutability:ERROR",
278 "-Xep:AndroidFrameworkRequiresPermission:ERROR",
279 "-Xep:AndroidFrameworkRethrowFromSystem:ERROR",
280 "-Xep:AndroidFrameworkTargetSdk:ERROR",
281 "-Xep:AndroidHideInComments:ERROR",
282
283 // After fixing this errorprone, we decided to not merge the change.
284 // It is not very readable and the benefits are minimal when looking
285 // at the size of the maps used in the Bluetooth application.
286 // See https://r.android.com/3200511
287 "-Xep:AndroidFrameworkEfficientCollections:OFF",
288
289 // Does not look pertinent in our situation
290 "-Xep:AndroidFrameworkEfficientXml:OFF",
291 ],
292 },
293}
William Escandeaa2964e2025-04-03 14:29:20 -0700294
295java_defaults {
296 name: "bluetooth_lint_rules",
297 lint: {
298 error_checks: [
299 "Autofill",
300 "DefaultLocale",
301 "DuplicateDefinition",
302 // "ExportedContentProvider", // TODO: b/289445022 - enable this check
303 // "ExportedReceiver", // TODO: b/289445022 - enable this check
304 // "ExportedService", // TODO: b/289445022 - enable this check
305 "ExtraText",
306 "ExtraTranslation",
307 "GestureBackNavigation",
308 "GuardedLogInvocation",
309 "HandlerLeak",
310 "InflateParams",
311 // "InvalidPermission", // TODO: b/289445022 - enable this check
312 "LabelFor",
313 "MissingClass",
314 // "MissingVersion", // TODO: b/289445022 - enable this check
315 "MonochromeLauncherIcon",
316 "NewApi",
317 "ObsoleteSdkInt",
318 // "QueryAllPackagesPermission", // TODO: b/289445022 - enable this check
319 "Recycle",
320 "RtlHardcoded",
321 "RtlSymmetry",
322 "ScrollViewSize",
323 "SetTextI18n",
324 "SimpleDateFormat",
325 "StaticFieldLeak",
326 "StringFormatCount",
327 "StringFormatInvalid",
328 "TextFields",
329 "TypographyEllipsis",
330 "UseSparseArrays",
331 "UseValueOf",
332 "VectorPath",
333 "VisibleForTests",
334 "Wakelock",
335 "WakelockTimeout",
336 ],
337 extra_check_modules: ["BluetoothLintChecker"],
338 },
339}