Skip to content

Commit 690d119

Browse files
authored
Fix reflection error in com.google.android.datatransport.Priority when using aggressive Proguard rules. (#2016)
The enum's values are accessed via reflection, so aggressive Proguard rules can cause it to be stripped out. e.g., #1996 This fix switches out PriorityMapping's Map implementation to avoid reflection. EnumMap uses reflection under the hood. Switching to a HashMap removes the reflection call, so we don't need the Proguard rule keeping `values` after all.
1 parent aa3c89f commit 690d119

File tree

1 file changed

+2
-2
lines changed
  • transport/transport-runtime/src/main/java/com/google/android/datatransport/runtime/util

1 file changed

+2
-2
lines changed

transport/transport-runtime/src/main/java/com/google/android/datatransport/runtime/util/PriorityMapping.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,11 @@
1717
import android.util.SparseArray;
1818
import androidx.annotation.NonNull;
1919
import com.google.android.datatransport.Priority;
20-
import java.util.EnumMap;
20+
import java.util.HashMap;
2121

2222
public final class PriorityMapping {
2323
private static SparseArray<Priority> PRIORITY_MAP = new SparseArray<>();
24-
private static EnumMap<Priority, Integer> PRIORITY_INT_MAP = new EnumMap<>(Priority.class);
24+
private static HashMap<Priority, Integer> PRIORITY_INT_MAP = new HashMap<>();
2525

2626
static {
2727
PRIORITY_INT_MAP.put(Priority.DEFAULT, 0);

0 commit comments

Comments
 (0)