Skip to content

Commit

Permalink
Polish DevServerHelper (#37266)
Browse files Browse the repository at this point in the history
Summary:
Pull Request resolved: #37266

This class is full of warnings and other issues which I'm doing a pass on it since I touched it:
- Missing `NonNull` annotations
- Try with resources missing
- Unused inner Interfaces that can be removed

Technically a breaking change for users as we do have some public interfaces that have been removed, though not sure why people would depend on those.

Changelog:
[Android] [Removed] - Polish DevServerHelper (remove unused Interfaces)

Reviewed By: motiz88

Differential Revision: D45600284

fbshipit-source-id: 6274ae29ff3384d7409764fd6474da68d777958a
  • Loading branch information
cortinico authored and facebook-github-bot committed May 5, 2023
1 parent da358d0 commit 7dcaf00
Showing 1 changed file with 8 additions and 21 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@

import android.content.Context;
import android.os.AsyncTask;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import com.facebook.common.logging.FLog;
import com.facebook.infer.annotation.Assertions;
Expand Down Expand Up @@ -64,10 +65,6 @@ public class DevServerHelper {

private static final String DEBUGGER_MSG_DISABLE = "{ \"id\":1,\"method\":\"Debugger.disable\" }";

public interface OnServerContentChangeListener {
void onServerContentChanged();
}

public interface PackagerCommandListener {
void onPackagerConnected();

Expand All @@ -84,8 +81,6 @@ public interface PackagerCommandListener {
Map<String, RequestHandler> customCommandHandlers();
}

public interface PackagerCustomCommandProvider {}

private enum BundleType {
BUNDLE("bundle"),
MAP("map");
Expand All @@ -112,7 +107,7 @@ public String typeID() {

private @Nullable JSPackagerClient mPackagerClient;
private @Nullable InspectorPackagerConnection mInspectorPackagerConnection;
private InspectorPackagerConnection.BundleStatusProvider mBundlerStatusProvider;
private final InspectorPackagerConnection.BundleStatusProvider mBundlerStatusProvider;

public DevServerHelper(
DeveloperSettings developerSettings,
Expand Down Expand Up @@ -349,15 +344,14 @@ private String createSplitBundleURL(String mainModuleID, String host) {
private String createBundleURL(
String mainModuleID, BundleType type, String host, boolean modulesOnly, boolean runModule) {
boolean dev = getDevMode();
boolean lazy = dev;
return String.format(
Locale.US,
"http://%s/%s.%s?platform=android&dev=%s&lazy=%s&minify=%s&app=%s&modulesOnly=%s&runModule=%s",
host,
mainModuleID,
type.typeID(),
dev,
lazy,
dev, // dev
dev, // lazy
getJSMinifyMode(),
mPackageName,
modulesOnly ? "true" : "false",
Expand Down Expand Up @@ -405,14 +399,13 @@ public void launchJSDevtools() {
.enqueue(
new Callback() {
@Override
public void onFailure(Call call, IOException e) {
public void onFailure(@NonNull Call call, @NonNull IOException e) {
// ignore HTTP call response, this is just to open a debugger page and there is no
// reason
// to report failures from here
// reason to report failures from here
}

@Override
public void onResponse(Call call, Response response) throws IOException {
public void onResponse(@NonNull Call call, @NonNull Response response) {
// ignore HTTP call response - see above
}
});
Expand Down Expand Up @@ -449,15 +442,9 @@ public String getJSBundleURLForRemoteDebugging(String mainModuleName) {
if (!response.isSuccessful()) {
return null;
}
Sink output = null;

try {
output = Okio.sink(outputFile);
try (Sink output = Okio.sink(outputFile)) {
Okio.buffer(response.body().source()).readAll(output);
} finally {
if (output != null) {
output.close();
}
}

return outputFile;
Expand Down

0 comments on commit 7dcaf00

Please sign in to comment.