Commit graph

9 commits

Author SHA1 Message Date
Handa Wang
cca941a232 Move the Thread proguard flags to ConnectivityService's proguard.flags
We needed this proguard flag because
ThreadNetworkService#onLocalNetworkInfoChanged will otherwise be
stripped. We need to keep the method to ensure the border routing
feature works.

Initially we put the flag in thread/service/proguard.flags. However,
this seems not working on udc-mainline-prod branch. After moving it to
Connectivity/service/proguard.flags, it works as desired.

Bug: 313539492

Change-Id: I33cb0602095a617dbb1cfe3d9002f9c68e93cccf
2024-01-26 09:14:53 +00:00
Mark
53e71c3f3f Allow jarjar com.android.server*
Jarjar com.android.server* and adjust the test by jarjar
FrameworksNetTestsLib to make sure the test cases still can access
package sope fields. Don't auto-jarjar non-connectivity module tests
in FrameworksNetTests because some non-connectivity module test cases
rely on service.core and service.net. The reason why not auto-jarjar
whole ConnectivityCoverageTests because tethering doesn't adopt
auto-jarjar-gen yet. The coverage test must jarjar the same as module so
that test coverage can calculate correctly.

Remove com.android.server* from proguard becasue it already be covered
by android.net* after jarjar'ed.

Move MetricsTestUtil to non connectivity module test group because it
only be used for IpConnectivityEventBuilderTest which is non connectivity
module test. Only jarjar the util without jarjar the caller make the test
failure.

Bug: 248001529
Test: atest ConnectivityCoverageTests FrameworksNetTests

Change-Id: I8439341ef4c03f29697fdf34557ea8ef2825d691
2023-02-14 15:43:43 +00:00
Chalard Jean
88edc35da6 Keep primitive members used by MessageUtils.
This includes in particular {Full,Network}Score.POLICY_* members
which were removed recently.

Before :
  Policies : 55&62&63
After :
  Policies : EVER_EVALUATED&EVER_VALIDATED&IS_VALIDATED

This patch also unifies the directives under Tethering/ for
simplicity.

Test: adb logcat & dumpsys connectivity & dumpsys tethering
Change-Id: I3d231fbaaebe233b2633da8bb880b5ad1613a32f
2022-10-13 13:11:53 +09:00
zhidou
b33a2638db Enable R8 shrinking of standalone system server jar service-connectivity
This change enables R8 shrinking, and R8 full mode of standalone system
server jar service-connectivity. Keep rules are specified based on the entries in
frameworks/base/services/java/com/android/server/SystemServer.java. Keep rules of classes extending SystemServer is inherited from "standalone-system-server-module-optimize-defaults", https://cs.android.com/android/platform/superproject/+/master:packages/modules/common/proguard/Android.bp, which is a set of common rules for standalone system server jar. Keep rules of proto is inherited from "proguard_basic_keeps", https://cs.android.com/android/platform/superproject/+/master:build/make/core/proguard_basic_keeps.flags, which is the common set of keep rules for all dex target.

The
size of service-connectivity will be reduced by 31% from 2094301B to 1426485B.

Test: Presubmit and MTS. Run MTS locally with command `mts-tradefed run` with `mts-tethering`, `mts-network`, `mts-cellbroadcast` on  Pixel 4 with sunfish-userdebug image.
Bug: 233746531
Change-Id: I291c9d880a1ffc7dc87f932f9d27ce3740b9dc36
2022-09-27 04:03:13 +00:00
Remi NGUYEN VAN
e55a88d30f Use jarjar rule generator for connectivity rules
(This rolls forward part of a previous change, now that jarjar was fixed
to not get very slow when the number of rules increases).

Autogenerate connectivity jarjar rules at build time, to avoid issues
with forgotten jarjar rules or hard-to-diagnose errors introduced by
incorrect rules.

This change causes all classes in framework-connectivity(-t) and
service-connectivity to be jarjared into android.net.connectivity, but
still avoids jarjaring classes in com.android.server as before, to keep
it small.
For many classes this differs from the original jarjar rule.

Notes on implementation:

 - connectivity-jarjar-rules now has a subset
   framework-connectivity-jarjar-rules containing only the rules
   necessary for framework-connectivity. This is necessary because
   framework-connectivity cannot depend on rules generated based on
   service-connectivity, as there would be a dependency cycle
   (service-connectivity depends on framework-connectivity); Soong even
   crashes with a stack overflow.

 - framework-wifi.stubs.module_lib is added to
   framework-connectivity-pre-jarjar as it is necessary to build it (it
   is already in impl_only_libs in the defaults).
   It is unclear why framework-connectivity-pre-jarjar could build
   before that (possibly because it was only used as "lib" ?)

 - Fix package-private visibility; for example NattSocketKeepalive,
   TcpSocketKeepalive are not API so should be jarjared, but are used
   by ConnectivityManager which is not jarjared, so they are not in the
   same package after the change. Package-private members in the
   former 2 need to be public to be accessible. Changes in this commit
   are all that is needed, as demonstrated by followup commits that move
   the classes to a different package without further changes, and that
   enforce that no class in an API package gets jarjared.

 - framework-connectivity-internal-test-defaults is separated from
   framework-connectivity-test-defaults, for unit tests that need to
   access internal jarjared classes. Such tests need to use the jarjar
   rules themselves too, so this is only appropriate for connectivity
   internal unit tests.

Test: atest ConnectivityCoverageTests CtsNetTestCases
Bug: 217129444
Change-Id: Ib1bd939b71c0171d945fc01b96195d2f620ff13b
2022-07-20 19:57:11 +09:00
Chun Zhang
193797326e Fix pro-guard rules for service-nearby
(clean cherry-pick of downstream change)

Test: build and check classes in service-connectivity.jar.
Bug: 217115866
Merged-In: I9f7db4509bf8fe736f5d9fc08b164a20b2274aa8
Change-Id: Ia97b7ab645e3425780b335c699b57a6dc7589f2a
2022-06-23 16:31:56 +09:00
Colin Cross
ece3171cf0 Revert "Autogenerate connectivity jarjar rules"
This reverts commit 53eb35cd82.

Reason for revert: b/233081774, caused long build times in FrameworkNetTests

Change-Id: Ide01c994f694b55fc0e87bb0e81584ac44196e68
2022-05-18 18:30:27 +00:00
Remi NGUYEN VAN
53eb35cd82 Autogenerate connectivity jarjar rules
Jarjar rules are hard to keep in sync with code, and hard to maintain
manually as the distinction between what should and should not be
jarjared is not always clear. This results in unsafe binaries that are
manually maintained, and developer frustration when something fails due
to incorrect jarjar rules.

Autogenerate jarjar rules at build time instead. This is achieved by
introducing a jarjar-rules-generator python-based library, which scans
pre-jarjar intermediate artifacts, and outputs jarjar rules for every
class to put it in a package specific to the module. The only exceptions
are:

 - Classes that are API (module-lib API is the largest API surface of
   the module)
 - Classes that have unsupportedappusage symbols
 - Classes that are excluded manually (for example, because they have
   hardcoded external references, like for
   ConnectivityServiceInitializer in SystemServer).

This change causes all classes in framework-connectivity(-t) and
service-connectivity to be jarjared into android.net.connectivity, but
still avoids jarjaring classes in com.android.server as before, to keep
it small.
For many classes this differs from the original jarjar rule.

Notes on implementation:

 - connectivity-jarjar-rules now has a subset
   framework-connectivity-jarjar-rules containing only the rules
   necessary for framework-connectivity. This is necessary because
   framework-connectivity cannot depend on rules generated based on
   service-connectivity, as there would be a dependency cycle
   (service-connectivity depends on framework-connectivity); Soong even
   crashes with a stack overflow.

 - framework-wifi.stubs.module_lib is added to
   framework-connectivity-pre-jarjar as it is necessary to build it (it
   is already in impl_only_libs in the defaults).
   It is unclear why framework-connectivity-pre-jarjar could build
   before that (possibly because it was only used as "lib" ?)

 - Fix package-private visibility; for example NattSocketKeepalive,
   TcpSocketKeepalive are not API so should be jarjared, but are used
   by ConnectivityManager which is not jarjared, so they are not in the
   same package after the change. Package-private members in the
   former 2 need to be public to be accessible. Changes in this commit
   are all that is needed, as demonstrated by followup commits that move
   the classes to a different package without further changes, and that
   enforce that no class in an API package gets jarjared.

 - framework-connectivity-internal-test-defaults is separated from
   framework-connectivity-test-defaults, for unit tests that need to
   access internal jarjared classes. Such tests need to use the jarjar
   rules themselves too, so this is only appropriate for connectivity
   internal unit tests.

Test: atest ConnectivityCoverageTests CtsNetTestCases
Bug: 217129444
Change-Id: Ied17c3955ea2fda130089265d02908937ad8af1e
2022-05-13 17:30:06 +09:00
Remi NGUYEN VAN
c6f8fb0c4f Enable optimizer on service-connectivity
The optimizer has been enabled in downstream branches (including those
used for upcoming module releases) for a few months. This brings aosp in
line with them.

This is a cherry-pick of change:
I3be9422a431a5b5bc1478960ce332a89377bd632

where proguard.flags have been replaced with the most up-to-date version
used in downstream branches.

Test: m
Merged-In: I3be9422a431a5b5bc1478960ce332a89377bd632
Change-Id: I55455eb58d3fdc4dbf3ea81961d5c7756fea0046
2022-05-11 12:34:15 +09:00