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

Commit 74d09ea6 authored by Jared Duke's avatar Jared Duke
Browse files

Use @UsesReflection for LocalTransport keep rules

Prefer the @UsesReflection annotation to generate the keep rules
necessary to preserve LocalTransport derived class names. These
class names should be kept as they are used to generate a name that
may be referenced by other packages. Other classes currently in the
proguard config are automatically kept by manifest-generated keep
rules, or are otherwise unnecessary.

This change is effectively a no-op under the current shrinking
configuration for both LocalTransport and EncryptedLocalTransport. If
obfuscation is enabled, this annotation will ensure continued
correctness.

Bug: 248580093
Test: m + ensure all classes kept
Change-Id: I867693861e5b1ca9765c926d676c0b18b16cc340
parent 22f11911
Loading
Loading
Loading
Loading
+0 −3
Original line number Diff line number Diff line
@@ -27,9 +27,6 @@ android_app {
    name: "EncryptedLocalTransport",
    defaults: ["platform_app_defaults"],
    srcs: ["src/**/*.java"],
    optimize: {
        proguard_flags_files: ["proguard.flags"],
    },
    static_libs: ["LocalTransport"],
    platform_apis: true,
    certificate: "platform",
+0 −2
Original line number Diff line number Diff line
-keep class com.android.localTransport.EncryptedLocalTransport
-keep class com.android.localTransport.EncryptedLocalTransportService
+1 −3
Original line number Diff line number Diff line
@@ -27,9 +27,7 @@ android_app {
    name: "LocalTransport",
    defaults: ["platform_app_defaults"],
    srcs: ["src/**/*.java"],
    optimize: {
        proguard_flags_files: ["proguard.flags"],
    },
    libs: ["keepanno-annotations"],
    platform_apis: true,
    certificate: "platform",
    privileged: true,
+0 −5
Original line number Diff line number Diff line
-keep class com.android.localTransport.LocalTransport
-keep class com.android.localTransport.LocalTransportParameters
-keep class com.android.localTransport.LocalTransportService

+10 −0
Original line number Diff line number Diff line
@@ -35,6 +35,9 @@ import android.util.ArrayMap;
import android.util.Base64;
import android.util.Log;

import com.android.tools.r8.keepanno.annotations.KeepTarget;
import com.android.tools.r8.keepanno.annotations.UsesReflection;

import libcore.io.IoUtils;

import java.io.BufferedOutputStream;
@@ -122,6 +125,13 @@ public class LocalTransport extends BackupTransport {
        return mParameters;
    }


    @UsesReflection({
            // As the runtime class name is used to generate the returned name, and the returned
            // name may be used used with reflection, generate the necessary keep rules.
            @KeepTarget(classConstant = LocalTransport.class),
            @KeepTarget(extendsClassConstant = LocalTransport.class)
    })
    @Override
    public String name() {
        return new ComponentName(mContext, this.getClass()).flattenToShortString();