Apply Nullsafe FIXMEs for xplat/js/react-native-github/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/devsupport/DevSupportManagerBase.java (#50067)

Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/50067

Note this diff is only adding FIXMEs that will be removed in the next diff. This diff exists to make the next diff easily reviewable

Changelog: [Internal]

Reviewed By: mdvacca

Differential Revision: D71126382

fbshipit-source-id: d90966e62372395e864425c82321dc1fc04c1413
This commit is contained in:
Gijs Weterings
2025-03-18 06:08:17 -07:00
committed by Facebook GitHub Bot
parent 61d4b04159
commit a00f884496
@@ -223,6 +223,7 @@ public abstract class DevSupportManagerBase implements DevSupportManager {
if (e instanceof JavascriptException) {
FLog.e(ReactConstants.TAG, "Exception in native call from JS", e);
showNewError(
// NULLSAFE_FIXME[Nullable Dereference]
e.getMessage().toString(), new StackFrame[] {}, JSEXCEPTION_ERROR_COOKIE, ErrorType.JS);
} else {
showNewJavaError(message.toString(), e);
@@ -230,6 +231,7 @@ public abstract class DevSupportManagerBase implements DevSupportManager {
}
@Override
// NULLSAFE_FIXME[Inconsistent Subclass Parameter Annotation]
public void showNewJavaError(@Nullable String message, Throwable e) {
FLog.e(ReactConstants.TAG, "Exception in native call", e);
showNewError(
@@ -242,16 +244,19 @@ public abstract class DevSupportManagerBase implements DevSupportManager {
* called.
*/
@Override
// NULLSAFE_FIXME[Inconsistent Subclass Parameter Annotation]
public void addCustomDevOption(String optionName, DevOptionHandler optionHandler) {
mCustomDevOptions.put(optionName, optionHandler);
}
@Override
// NULLSAFE_FIXME[Inconsistent Subclass Parameter Annotation]
public void showNewJSError(String message, ReadableArray details, int errorCookie) {
showNewError(message, StackTraceHelper.convertJsStackTrace(details), errorCookie, ErrorType.JS);
}
@Override
// NULLSAFE_FIXME[Inconsistent Subclass Parameter Annotation]
public void registerErrorCustomizer(ErrorCustomizer errorCustomizer) {
if (mErrorCustomizers == null) {
mErrorCustomizers = new ArrayList<>();
@@ -260,6 +265,7 @@ public abstract class DevSupportManagerBase implements DevSupportManager {
}
@Override
// NULLSAFE_FIXME[Inconsistent Subclass Parameter Annotation]
public Pair<String, StackFrame[]> processErrorCustomizers(Pair<String, StackFrame[]> errorInfo) {
if (mErrorCustomizers != null) {
for (ErrorCustomizer errorCustomizer : mErrorCustomizers) {
@@ -281,10 +287,12 @@ public abstract class DevSupportManagerBase implements DevSupportManager {
mRedBoxSurfaceDelegate.hide();
}
// NULLSAFE_FIXME[Inconsistent Subclass Parameter Annotation]
public @Nullable View createRootView(String appKey) {
return mReactInstanceDevHelper.createRootView(appKey);
}
// NULLSAFE_FIXME[Inconsistent Subclass Parameter Annotation]
public void destroyRootView(View rootView) {
mReactInstanceDevHelper.destroyRootView(rootView);
}
@@ -518,12 +526,14 @@ public abstract class DevSupportManagerBase implements DevSupportManager {
mDevOptionsDialog =
new AlertDialog.Builder(context)
.setCustomTitle(header)
// NULLSAFE_FIXME[Not Vetted Third-Party]
.setAdapter(
adapter,
(dialog, which) -> {
optionHandlers[which].onOptionSelected();
mDevOptionsDialog = null;
})
// NULLSAFE_FIXME[Not Vetted Third-Party]
.setOnCancelListener(dialog -> mDevOptionsDialog = null)
.create();
mDevOptionsDialog.show();
@@ -538,6 +548,7 @@ public abstract class DevSupportManagerBase implements DevSupportManager {
try {
return getReactInstanceDevHelper().getJavaScriptExecutorFactory().toString();
} catch (IllegalStateException e) {
// NULLSAFE_FIXME[Return Not Nullable]
return null;
}
}
@@ -624,6 +635,7 @@ public abstract class DevSupportManagerBase implements DevSupportManager {
try {
String packageName = mApplicationContext.getPackageName();
PackageInfo thisPackage =
// NULLSAFE_FIXME[Nullable Dereference]
mApplicationContext.getPackageManager().getPackageInfo(packageName, 0);
if (mJSBundleDownloadedFile.lastModified() > thisPackage.lastUpdateTime) {
// Base APK has not been updated since we downloaded JS, but if app is using exopackage
@@ -663,6 +675,7 @@ public abstract class DevSupportManagerBase implements DevSupportManager {
if (mCurrentReactContext != null) {
try {
URL sourceUrl = new URL(getSourceUrl());
// NULLSAFE_FIXME[Nullable Dereference]
String path = sourceUrl.getPath().substring(1); // strip initial slash in path
String host = sourceUrl.getHost();
String scheme = sourceUrl.getProtocol();
@@ -785,6 +798,7 @@ public abstract class DevSupportManagerBase implements DevSupportManager {
}
@Override
// NULLSAFE_FIXME[Inconsistent Subclass Parameter Annotation]
public void onFailure(Exception cause) {
UiThreadUtil.runOnUiThread(
DevSupportManagerBase.this::hideSplitBundleDevLoadingView);
@@ -793,6 +807,7 @@ public abstract class DevSupportManagerBase implements DevSupportManager {
},
bundleFile,
bundleUrl,
// NULLSAFE_FIXME[Parameter Not Nullable]
null);
});
}
@@ -821,6 +836,7 @@ public abstract class DevSupportManagerBase implements DevSupportManager {
}
@Override
// NULLSAFE_FIXME[Inconsistent Subclass Parameter Annotation]
public @Nullable File downloadBundleResourceFromUrlSync(
final String resourceURL, final File outputFile) {
return mDevServerHelper.downloadBundleResourceFromUrlSync(resourceURL, outputFile);
@@ -888,6 +904,7 @@ public abstract class DevSupportManagerBase implements DevSupportManager {
}
@Override
// NULLSAFE_FIXME[Inconsistent Subclass Parameter Annotation]
public void onFailure(final Exception cause) {
hideDevLoadingView();
if (mBundleDownloadListener != null) {
@@ -975,6 +992,7 @@ public abstract class DevSupportManagerBase implements DevSupportManager {
// start shake gesture detector
if (!mIsShakeDetectorStarted) {
mShakeDetector.start(
// NULLSAFE_FIXME[Parameter Not Nullable]
(SensorManager) mApplicationContext.getSystemService(Context.SENSOR_SERVICE));
mIsShakeDetectorStarted = true;
}
@@ -1060,6 +1078,7 @@ public abstract class DevSupportManagerBase implements DevSupportManager {
}
@Override
// NULLSAFE_FIXME[Inconsistent Subclass Parameter Annotation]
public void setPackagerLocationCustomizer(
DevSupportManager.PackagerLocationCustomizer packagerLocationCustomizer) {
mPackagerLocationCustomizer = packagerLocationCustomizer;
@@ -1071,6 +1090,7 @@ public abstract class DevSupportManagerBase implements DevSupportManager {
}
@Override
// NULLSAFE_FIXME[Inconsistent Subclass Parameter Annotation]
public @Nullable SurfaceDelegate createSurfaceDelegate(String moduleName) {
if (mSurfaceDelegateFactory == null) {
return null;