291 {
292 String resolvedComponentName =
294 if (resolvedComponentName == null) {
296 TAG, "Deferred component name was null and could not be resolved from loading unit id.");
297 return;
298 }
299
300
301 if (resolvedComponentName.equals("") && loadingUnitId > 0) {
302
304 return;
305 }
306
307 SplitInstallRequest request =
308 SplitInstallRequest.newBuilder().addModule(resolvedComponentName).build();
309
310 splitInstallManager
311
312
313
314 .startInstall(request)
315
316
317 .addOnSuccessListener(
318 sessionId -> {
319 sessionIdToName.put(sessionId, resolvedComponentName);
320 sessionIdToLoadingUnitId.put(sessionId, loadingUnitId);
321 if (nameToSessionId.containsKey(resolvedComponentName)) {
322 sessionIdToState.remove(nameToSessionId.get(resolvedComponentName));
323 }
324 nameToSessionId.put(resolvedComponentName, sessionId);
325 sessionIdToState.put(sessionId, "Requested");
326 })
327 .addOnFailureListener(
328 exception -> {
329 switch (((SplitInstallException) exception).getErrorCode()) {
330 case SplitInstallErrorCode.NETWORK_ERROR:
332 loadingUnitId,
333 "Install of deferred component module \""
334 + componentName
335 + "\" failed with a network error",
336 true);
337 break;
338 case SplitInstallErrorCode.MODULE_UNAVAILABLE:
340 loadingUnitId,
341 "Install of deferred component module \""
342 + componentName
343 + "\" failed as it is unavailable",
344 false);
345 break;
346 default:
348 loadingUnitId,
349 String.format(
350 "Install of deferred component module \"%s\" failed with error %d: %s",
351 componentName,
352 ((SplitInstallException) exception).getErrorCode(),
353 ((SplitInstallException) exception).getMessage()),
354 false);
355 break;
356 }
357 });
358 }
void deferredComponentInstallFailure(int loadingUnitId, @NonNull String error, boolean isTransient)
void loadDartLibrary(int loadingUnitId, @NonNull String componentName)