Fix proto invalid write type

While dumpProtoLocked is called, InvalidProtocolBufferException
occurred because types are mismatched between platform side and
module side.

netstats.proto was moved into connectivity module, both the
platform(incident.proto) and the module uses protoc-gen-javastream
to generate the Java classes from it. It should be fine since
platform includes the source of the proto, and jarjar the generated
classess in the module to avoid conflict with platform.

Bug: 218566849
Test: adb shell incident 3001
      adb shell dumpsys netstats --proto
      atest CtsIncidentHostTestCases:IncidentdTest#testIncidentReportDumpAuto
Change-Id: I09cae385050e569b1da98ad7de0e226b13ee6895
Merged-In: I09cae385050e569b1da98ad7de0e226b13ee6895
This commit is contained in:
Aaron Huang 2022-02-14 21:38:14 +08:00
commit dac7e4b84a
2 changed files with 32 additions and 15 deletions

View file

@ -64,6 +64,7 @@ java_defaults {
":framework-connectivity-sources",
":net-utils-framework-common-srcs",
":framework-connectivity-api-shared-srcs",
":framework-connectivity-javastream-protos",
],
aidl: {
generate_get_transaction_name: true,
@ -85,7 +86,6 @@ java_defaults {
"net-utils-device-common",
],
static_libs: [
"framework-connectivity-protos",
"modules-utils-backgroundthread",
"modules-utils-build",
"modules-utils-preconditions",
@ -182,22 +182,36 @@ cc_library_shared {
],
}
// TODO: reduce size of this library; consider using
// proto nano for example
java_library {
filegroup {
name: "framework-connectivity-protos",
sdk_version: "module_current",
min_sdk_version: "30",
proto: {
type: "lite",
},
srcs: [
"proto/**/*.*",
"proto/**/*.proto",
],
static_libs: ["libprotobuf-java-lite"],
apex_available: [
"com.android.tethering",
visibility: ["//frameworks/base"],
}
gensrcs {
name: "framework-connectivity-javastream-protos",
depfile: true,
tools: [
"aprotoc",
"protoc-gen-javastream",
"soong_zip",
],
lint: { strict_updatability_linting: true },
visibility: ["//visibility:private"],
cmd: "mkdir -p $(genDir)/$(in) " +
"&& $(location aprotoc) " +
" --plugin=$(location protoc-gen-javastream) " +
" --dependency_out=$(depfile) " +
" --javastream_out=$(genDir)/$(in) " +
" -Iexternal/protobuf/src " +
" -I . " +
" $(in) " +
"&& $(location soong_zip) -jar -o $(out) -C $(genDir)/$(in) -D $(genDir)/$(in)",
srcs: [
":framework-connectivity-protos",
],
output_extension: "srcjar",
}

View file

@ -105,5 +105,8 @@ rule com.android.internal.util.State* com.android.connectivity.@0
# From the API shims
rule com.android.networkstack.apishim.** com.android.connectivity.@0
# From filegroup framework-connectivity-protos
rule android.service.*Proto com.android.connectivity.@0
# Remaining are connectivity sources in com.android.server and com.android.server.connectivity:
# TODO: move to a subpackage of com.android.connectivity (such as com.android.connectivity.server)