• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1// Media Statistics service
2//
3
4package {
5    // See: http://go/android-license-faq
6    // A large-scale-change added 'default_applicable_licenses' to import
7    // all of the 'license_kinds' from "frameworks_av_license"
8    // to get the below license kinds:
9    //   SPDX-license-identifier-Apache-2.0
10    default_applicable_licenses: ["frameworks_av_license"],
11}
12
13tidy_errors = [
14    // https://clang.llvm.org/extra/clang-tidy/checks/list.html
15    // For many categories, the checks are too many to specify individually.
16    // Feel free to disable as needed - as warnings are generally ignored,
17    // we treat warnings as errors.
18    "android-*",
19    "bugprone-*",
20    "cert-*",
21    "clang-analyzer-security*",
22    "google-*",
23    "misc-*",
24    //"modernize-*",  // explicitly list the modernize as they can be subjective.
25    "modernize-avoid-bind",
26    //"modernize-avoid-c-arrays", // std::array<> can be verbose
27    "modernize-concat-nested-namespaces",
28    //"modernize-deprecated-headers", // C headers still ok even if there is C++ equivalent.
29    "modernize-deprecated-ios-base-aliases",
30    "modernize-loop-convert",
31    "modernize-make-shared",
32    "modernize-make-unique",
33    // "modernize-pass-by-value", // found in TimeMachine.h
34    "modernize-raw-string-literal",
35    "modernize-redundant-void-arg",
36    "modernize-replace-auto-ptr",
37    "modernize-replace-random-shuffle",
38    "modernize-return-braced-init-list",
39    "modernize-shrink-to-fit",
40    "modernize-unary-static-assert",
41    // "modernize-use-auto",  // found in MediaMetricsService.h, debatable - auto can obscure type
42    "modernize-use-bool-literals",
43    "modernize-use-default-member-init",
44    "modernize-use-emplace",
45    "modernize-use-equals-default",
46    "modernize-use-equals-delete",
47    // "modernize-use-nodiscard", // found in TimeMachine.h
48    "modernize-use-noexcept",
49    "modernize-use-nullptr",
50    "modernize-use-override",
51    //"modernize-use-trailing-return-type", // not necessarily more readable
52    "modernize-use-transparent-functors",
53    "modernize-use-uncaught-exceptions",
54    "modernize-use-using",
55    "performance-*",
56
57    // Remove some pedantic stylistic requirements.
58    "-google-readability-casting", // C++ casts not always necessary and may be verbose
59    "-google-readability-todo",    // do not require TODO(info)
60
61    "-bugprone-unhandled-self-assignment", // found in TimeMachine.h
62    "-bugprone-suspicious-string-compare", // found in TimeMachine.h
63    "-cert-oop54-cpp", // found in TransactionLog.h
64    "-bugprone-narrowing-conversions", // b/182410845
65]
66
67cc_defaults {
68    name: "mediametrics_flags_defaults",
69    // https://clang.llvm.org/docs/UsersManual.html#command-line-options
70    // https://clang.llvm.org/docs/DiagnosticsReference.html
71    cflags: [
72        "-Wall",
73        "-Wdeprecated",
74        "-Werror",
75        "-Werror=implicit-fallthrough",
76        "-Werror=sometimes-uninitialized",
77        "-Werror=conditional-uninitialized",
78        "-Wextra",
79        "-Wredundant-decls",
80        "-Wshadow",
81        "-Wstrict-aliasing",
82        "-fstrict-aliasing",
83        "-Wthread-safety",
84        //"-Wthread-safety-negative", // experimental - looks broken in R.
85        "-Wunreachable-code",
86        "-Wunreachable-code-break",
87        "-Wunreachable-code-return",
88        "-Wunused",
89        "-Wused-but-marked-unused",
90    ],
91    // https://clang.llvm.org/extra/clang-tidy/
92    tidy: true,
93    tidy_checks: tidy_errors,
94    tidy_checks_as_errors: tidy_errors,
95    tidy_flags: [
96      "-format-style=file",
97    ],
98}
99
100cc_binary {
101    name: "mediametrics",
102    defaults: [
103        "mediametrics_flags_defaults",
104    ],
105
106    srcs: [
107        "main_mediametrics.cpp",
108    ],
109
110    shared_libs: [
111        "libbinder",
112        "liblog",
113        "libmediametricsservice",
114        "libmediautils",
115        "libutils",
116        "mediametricsservice-aidl-cpp",
117        "packagemanager_aidl-cpp",
118    ],
119    header_libs: [
120        "libaudioutils_headers",
121        "libmediametrics_headers",
122    ],
123
124    init_rc: [
125        "mediametrics.rc",
126    ],
127}
128
129cc_library {
130    name: "libmediametricsservice",
131    defaults: [
132        "mediametrics_flags_defaults",
133    ],
134
135    srcs: [
136        "AudioAnalytics.cpp",
137        "AudioPowerUsage.cpp",
138        "AudioTypes.cpp",
139        "cleaner.cpp",
140        "iface_statsd.cpp",
141        "MediaDrmStatsdHelper.cpp",
142        "MediaMetricsService.cpp",
143        "statsd_audiopolicy.cpp",
144        "statsd_audiorecord.cpp",
145        "statsd_audiothread.cpp",
146        "statsd_audiotrack.cpp",
147        "statsd_codec.cpp",
148        "statsd_drm.cpp",
149        "statsd_extractor.cpp",
150        "statsd_mediaparser.cpp",
151        "statsd_nuplayer.cpp",
152        "statsd_recorder.cpp",
153        "StringUtils.cpp",
154        "ValidateId.cpp",
155    ],
156
157    proto: {
158        type: "lite",
159    },
160
161    shared_libs: [
162        "mediametricsservice-aidl-cpp",
163        "libbase", // android logging
164        "libbinder",
165        "libcutils",
166        "liblog",
167        "libmedia_helper",
168        "libmediametrics",
169        "libmediautils",
170        "libmemunreachable",
171        "libprotobuf-cpp-lite",
172        "libstagefright_foundation",
173        "libstats_media_metrics",
174        "libstatspull",
175        "libstatssocket",
176        "libutils",
177        "packagemanager_aidl-cpp",
178    ],
179
180    export_shared_lib_headers: [
181        "libstats_media_metrics",
182        "libstatspull",
183        "libstatssocket",
184    ],
185
186    // within the library, we use "xxx.h"
187    local_include_dirs: [
188        "include/mediametricsservice",
189    ],
190
191    // external parties use <mediametricsservice/xxx.h>
192    export_include_dirs: [
193        "include",
194    ],
195
196    static_libs: [
197        "libplatformprotos",
198    ],
199
200    header_libs: [
201        "libaaudio_headers",
202        "libaudioutils_headers",
203    ],
204}
205
206cc_library {
207    name: "libstats_media_metrics",
208    generated_sources: ["stats_media_metrics.cpp"],
209    generated_headers: ["stats_media_metrics.h"],
210    export_generated_headers: ["stats_media_metrics.h"],
211    shared_libs: [
212        "libcutils",
213        "libstatspull",
214        "libstatssocket",
215    ],
216}
217
218genrule {
219    name: "stats_media_metrics.h",
220    tools: ["stats-log-api-gen"],
221    cmd: "$(location stats-log-api-gen) --header $(genDir)/stats_media_metrics.h --module media_metrics --namespace android,stats,media_metrics",
222    out: [
223        "stats_media_metrics.h",
224    ],
225}
226
227genrule {
228    name: "stats_media_metrics.cpp",
229    tools: ["stats-log-api-gen"],
230    cmd: "$(location stats-log-api-gen) --cpp $(genDir)/stats_media_metrics.cpp --module media_metrics --namespace android,stats,media_metrics --importHeader stats_media_metrics.h",
231    out: [
232        "stats_media_metrics.cpp",
233    ],
234}
235