Skip to content

Commit

Permalink
Fix java warnings for unchecked conversions in PlayStoreDynamicFeatur…
Browse files Browse the repository at this point in the history
…eManager (flutter#22628)
  • Loading branch information
GaryQian authored Nov 20, 2020
1 parent 59c440f commit c0b08e8
Showing 1 changed file with 16 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
import android.content.pm.PackageManager.NameNotFoundException;
import android.content.res.AssetManager;
import android.os.Build;
import android.util.SparseArray;
import android.util.SparseIntArray;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import com.google.android.play.core.splitinstall.SplitInstallException;
Expand All @@ -22,10 +24,8 @@
import io.flutter.embedding.engine.FlutterJNI;
import java.io.File;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import java.util.Queue;

/**
Expand All @@ -40,14 +40,14 @@ public class PlayStoreDynamicFeatureManager implements DynamicFeatureManager {
private @NonNull Context context;
// Each request to install a feature module gets a session ID. These maps associate
// the session ID with the loading unit and module name that was requested.
private @NonNull Map<Integer, String> sessionIdToName;
private @NonNull Map<Integer, Integer> sessionIdToLoadingUnitId;
private @NonNull SparseArray<String> sessionIdToName;
private @NonNull SparseIntArray sessionIdToLoadingUnitId;

private FeatureInstallStateUpdatedListener listener;

private class FeatureInstallStateUpdatedListener implements SplitInstallStateUpdatedListener {
public void onStateUpdate(SplitInstallSessionState state) {
if (sessionIdToName.containsKey(state.sessionId())) {
if (sessionIdToName.get(state.sessionId()) != null) {
// TODO(garyq): Add system channel for split aot messages.
switch (state.status()) {
case SplitInstallSessionStatus.FAILED:
Expand All @@ -63,8 +63,8 @@ public void onStateUpdate(SplitInstallSessionState state) {
sessionIdToLoadingUnitId.get(state.sessionId()),
"Module install failed with " + state.errorCode(),
true);
sessionIdToName.remove(state.sessionId());
sessionIdToLoadingUnitId.remove(state.sessionId());
sessionIdToName.delete(state.sessionId());
sessionIdToLoadingUnitId.delete(state.sessionId());
break;
}
case SplitInstallSessionStatus.INSTALLED:
Expand All @@ -83,8 +83,8 @@ public void onStateUpdate(SplitInstallSessionState state) {
loadDartLibrary(
sessionIdToLoadingUnitId.get(state.sessionId()),
sessionIdToName.get(state.sessionId()));
sessionIdToName.remove(state.sessionId());
sessionIdToLoadingUnitId.remove(state.sessionId());
sessionIdToName.delete(state.sessionId());
sessionIdToLoadingUnitId.delete(state.sessionId());
break;
}
case SplitInstallSessionStatus.CANCELED:
Expand All @@ -94,7 +94,8 @@ public void onStateUpdate(SplitInstallSessionState state) {
String.format(
"Module \"%s\" (sessionId %d) install canceled.",
sessionIdToName.get(state.sessionId()), state.sessionId()));
sessionIdToName.remove(state.sessionId());
sessionIdToName.delete(state.sessionId());
sessionIdToLoadingUnitId.delete(state.sessionId());
break;
}
case SplitInstallSessionStatus.CANCELING:
Expand Down Expand Up @@ -164,8 +165,8 @@ public PlayStoreDynamicFeatureManager(@NonNull Context context, @Nullable Flutte
splitInstallManager = SplitInstallManagerFactory.create(context);
listener = new FeatureInstallStateUpdatedListener();
splitInstallManager.registerListener(listener);
sessionIdToName = new HashMap();
sessionIdToLoadingUnitId = new HashMap();
sessionIdToName = new SparseArray<String>();
sessionIdToLoadingUnitId = new SparseIntArray();
}

public void setJNI(@NonNull FlutterJNI flutterJNI) {
Expand Down Expand Up @@ -293,10 +294,10 @@ public void loadDartLibrary(int loadingUnitId, String moduleName) {
// performant and robust.

// Search directly in APKs first
List<String> apkPaths = new ArrayList();
List<String> apkPaths = new ArrayList<String>();
// If not found in APKs, we check in extracted native libs for the lib directly.
List<String> soPaths = new ArrayList();
Queue<File> searchFiles = new LinkedList();
List<String> soPaths = new ArrayList<String>();
Queue<File> searchFiles = new LinkedList<File>();
searchFiles.add(context.getFilesDir());
while (!searchFiles.isEmpty()) {
File file = searchFiles.remove();
Expand Down

0 comments on commit c0b08e8

Please sign in to comment.