Repository navigation
Commit c7d73bb
authored
Keep UIManagerHelper.getUIManager and UIManager.resolveView in ProGuard rules (#59892)
Summary:
Tools that inspect an app's views from outside the app's own code, such as OS-level accessibility and UI-understanding services, can identify the views React Native rendered by asking React Native itself. `UIManagerHelper.getUIManager()` returns the `UIManager` for a view's React context. `UIManager.resolveView(reactTag)` then returns the view React Native mounted under that tag, and the tool compares it with the view it has. In R8-minified release builds, that path isn't reliably available:
- `UIManagerHelper` is outside the `com.facebook.react.bridge` package that the shipped consumer rules keep, so R8 renames it or removes it entirely. The only path left is `ReactContext.getFabricUIManager()`, which is deprecated in favor of `UIManagerHelper.getUIManager()`.
- Builds that use `reactnative.pro` instead of the shipped consumer rules don't keep the `bridge` package, and R8 removes `resolveView` from `FabricUIManager`.
This change adds the same rules to the shipped consumer rules (`proguard-rules.pro`) and to `reactnative.pro`:
- Keep `UIManagerHelper.getUIManager`.
- Keep `UIManager.resolveView(int)` on the interface. Because the interface method keeps its name, R8 keeps `resolveView` under that name on the implementations in use, such as `FabricUIManager`. The shipped rules already keep it through the `bridge` rule. Naming it explicitly keeps it if that rule is ever narrowed.
The rules don't keep class names such as `ReactRootView` or `ReactViewGroup`. A tool can cache the classes that `resolveView` confirms and skip the lookup for later views of the same class. It can recognize React Native's context through `getUIManager`'s parameter type, even when `ReactContext` is renamed.
Changelog:
[Android][Changed] - Keep `UIManagerHelper.getUIManager` and `UIManager.resolveView` in the ProGuard rules, so tools can identify React Native views in minified apps
Reviewed By: javache
Differential Revision: D129915044
Pull Request resolved: #598921 parent 546c71c commit c7d73bb
2 files changed
Lines changed: 20 additions & 0 deletions
File tree
- packages/react-native/ReactAndroid
- src/main/java/com/facebook/react/bridge
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
51 | 51 | | |
52 | 52 | | |
53 | 53 | | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
54 | 65 | | |
55 | 66 | | |
56 | 67 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
18 | 18 | | |
19 | 19 | | |
20 | 20 | | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
21 | 30 | | |
22 | 31 | | |
23 | 32 | | |
| |||
0 commit comments