Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit c0d10972 authored by Makoto Onuki's avatar Makoto Onuki
Browse files

Make text filter policy resolution more intuitive

- Previously, text policies would always win over annotation based
policies.

For example, even if a class has `@Remove`, a package-wide "keep" policy
would still override it. But that was kind of unintuitive and
made package policies less useful.

Now, text policies will not override it if the fallback policy is
more narrowly scoped.

Meaning:
    - Package text policies won't override class annotations
    - Class text policies won't override member annotations

- We couldn't previously do it because InMemoryOutputFilter couldn't tell
apart if a fallback policy is explicitly set (e.g. with annotations)
or if it's just the default policy.

In order to solve this problem, now we have a field "isDefault"
in FilterPolicyWithReason.

- This CL inherits the "'experimental' policies won't override
'supported' policies" behavior from the previous CL.
However, the previous implementation didn't allow making
a @KeepPartialClass as "experimental". (to make all unsupported
experimental while keeping annotated methods as-is.)

This is because `@KeepPartialClass` is considered to be "supported"
at the class level, and "experimental" class policy wouldn't override
it. So this means, for example, even if we added
"class ActivityThread experimental" in the policy file, it was
ignored. But we want to do it to make all unsupported methods in it
as experimental.

To solve it, now we have a new filter policy, ExperimentalClass.

ExperimentalClass is basically the same as KeepClass -- specifically,
the class itself is considered to have "Keep" -- but it distributes
"experimental" to the members.

ExperimentalClass (at the class level) _is_ considered to be supported,
because it means "Keep" for the class itself.
But its members will get "Experimental", which is considered to be
unsupported.

- The above changes will allow, for example, marking ActivityThread
(which currently has @RavenwoodKeepPartialClass) as "experimental" and
enable all its methods. Note some of its members have `@Ignore`
annotations, and the class-wide "experimental" policy won't override
it, because method annotations are more narrowly scoped. If we want to
change it, we'd use a method level text policy.

- See the javadoc on InMemoryOutputFilter and FilterPolicy for more
details.

Bug: 292141694
Flag: TEST_ONLY
Test: $ANDROID_BUILD_TOP/frameworks/base/ravenwood/scripts/run-ravenwood-tests.sh -s
Change-Id: I85c62dcb14aca4e1fbc6c06330bfc8c57abcdce8
parent cae12a92
Loading
Loading
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment