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

Commit 0dd83cea authored by Makoto Onuki's avatar Makoto Onuki
Browse files

RavenwoodMethodCallLogger now supports creating a policy file.

When method call log is enabled, RavenwoodMethodCallLogger will be able
to detect all the called methods.

Now, RavenwoodMethodCallLogger will dump all the called methods
in the form of a policy file to "keep" all the detected methods.

The file is created at "/tmp/ravenwood-called-methods.txt".

Optionally, if $RAVENWOOD_METHOD_DUMP_REASON_FILTER is set,
we use it as a regex to filter methods in the policy file by
"filter reason".

This allows us to detect unsupported-yet APIs by a given test and
generate a policy file for them. Here's how to do so:

1. Add a "keepclass" policy to classes that may be called by tests.

Example: add following to frameworks/base/ravenwood/texts/ravenwood-framework-policies.txt

package android.app keepclass # BULK-ENABLE all class

2. Enable the method call log.

i.e. un-comment `--default-method-call-hook` in
frameworks/base/ravenwood/texts/ravenwood-standard-options.txt

3. Run a test with `RAVENWOOD_METHOD_DUMP_REASON_FILTER=BULK-ENABLE`
Example:
```
RAVENWOOD_METHOD_DUMP_REASON_FILTER=BULK-ENABLE atest RavenwoodCoreTest
```

Now, /tmp/ravenwood-called-methods.txt should contain all the methods
used by the test that were enabled by the package policy.
APIs that were already enabled by annotations or other policies shouldn't
show up. (but see the TODO below)

- Also added tests for RavenwoodMethodCallLoggerTest.

TODO: Currently, if a method is "kept" by both an annotation and a policy,
then because the policy file takes precedence over annotations,
filter reasons will be "file-override", not "annotation". This kind of
defeats $RAVENWOOD_METHOD_DUMP_REASON_FILTER because
the point of RAVENWOOD_METHOD_DUMP_REASON_FILTER is to detect
APIs that were already kept by annotations, but from the filter reason,
we can't really tell that. We need to figure out how to fix it somehow
to always suppress APIs enabled by annotations.

Bug: 292141694
Flag: TEST_ONLY
Test: $ANDROID_BUILD_TOP/frameworks/base/ravenwood/scripts/run-ravenwood-tests.sh -s
Change-Id: I934f26e38b4c965fad98ab4103b0d2baba70e238
parent 00119e71
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