Skip to content

Commit

Permalink
Fix onKeyLongPress() in RELEASE
Browse files Browse the repository at this point in the history
Summary:
In RELEASE mode, the `devSupportManager` received is ReleaseDevSupportManager for which `showDevOptionsDialog()` is a no-op
https://github.com/facebook/react-native/blob/main/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/devsupport/ReleaseDevSupportManager.java#L66

Which is expected since this is a capability only in Dev mode(useDeveloperSupport = true). However, ATM `onKeyLongPresss()` returns true in RELEASE as well which is a bug.

Since there is no need for `onKeyLongPress()` in RELEASE, changing it's logic to introduce that check and return false in case of RELEASE.

Changelog:
[Android][Fixed] onKeyLongPress() in RELEASE mode

Reviewed By: christophpurrer, RSNara

Differential Revision: D56850466
  • Loading branch information
arushikesarwani94 authored and facebook-github-bot committed May 2, 2024
1 parent 0383669 commit f4d038c
Showing 1 changed file with 7 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -221,11 +221,13 @@ && getReactNativeHost().getUseDeveloperSupport()))) {

public boolean onKeyLongPress(int keyCode) {
if (keyCode == KeyEvent.KEYCODE_MEDIA_FAST_FORWARD) {
if (ReactFeatureFlags.enableBridgelessArchitecture
&& mReactHost != null
&& mReactHost.getDevSupportManager() != null) {
mReactHost.getDevSupportManager().showDevOptionsDialog();
return true;
if (ReactFeatureFlags.enableBridgelessArchitecture && mReactHost != null) {
DevSupportManager devSupportManager = mReactHost.getDevSupportManager();
// onKeyLongPress is a Dev API and not supported in RELEASE mode.
if (devSupportManager != null && !(devSupportManager instanceof ReleaseDevSupportManager)) {
devSupportManager.showDevOptionsDialog();
return true;
}
} else {
if (getReactNativeHost().hasInstance() && getReactNativeHost().getUseDeveloperSupport()) {
getReactNativeHost().getReactInstanceManager().showDevOptionsDialog();
Expand Down

0 comments on commit f4d038c

Please sign in to comment.