Handle only asset-only deferred components case (flutter/engine#26333)

This commit is contained in:
Gary Qian
2021-05-21 17:08:01 -07:00
committed by GitHub
parent 70e1f8a459
commit 4ba3454b35
2 changed files with 23 additions and 9 deletions

View File

@@ -269,15 +269,19 @@ public class PlayStoreDeferredComponentManager implements DeferredComponentManag
"No loading unit to dynamic feature module name found. Ensure '"
+ MAPPING_KEY
+ "' is defined in the base module's AndroidManifest.");
} else {
for (String entry : rawMappingString.split(",")) {
// Split with -1 param to include empty string following trailing ":"
String[] splitEntry = entry.split(":", -1);
int loadingUnitId = Integer.parseInt(splitEntry[0]);
loadingUnitIdToComponentNames.put(loadingUnitId, splitEntry[1]);
if (splitEntry.length > 2) {
loadingUnitIdToSharedLibraryNames.put(loadingUnitId, splitEntry[2]);
}
return;
}
if (rawMappingString.equals("")) {
// Asset-only components, so no loading units to map.
return;
}
for (String entry : rawMappingString.split(",")) {
// Split with -1 param to include empty string following trailing ":"
String[] splitEntry = entry.split(":", -1);
int loadingUnitId = Integer.parseInt(splitEntry[0]);
loadingUnitIdToComponentNames.put(loadingUnitId, splitEntry[1]);
if (splitEntry.length > 2) {
loadingUnitIdToSharedLibraryNames.put(loadingUnitId, splitEntry[2]);
}
}
}

View File

@@ -307,4 +307,14 @@ public class PlayStoreDeferredComponentManagerTest {
assertTrue(playStoreManager.uninstallDeferredComponent(2, null));
assertFalse(playStoreManager.uninstallDeferredComponent(3, null));
}
@Test
public void assetOnlyMappingParses() throws NameNotFoundException {
TestFlutterJNI jni = new TestFlutterJNI();
Bundle bundle = new Bundle();
bundle.putString(PlayStoreDeferredComponentManager.MAPPING_KEY, "");
Context spyContext = createSpyContext(bundle);
TestPlayStoreDeferredComponentManager playStoreManager =
new TestPlayStoreDeferredComponentManager(spyContext, jni);
}
}