Skip to content

Commit

Permalink
adjust initialization operation.
Browse files Browse the repository at this point in the history
  • Loading branch information
kissonchan committed Aug 17, 2020
1 parent 21959ce commit f623dcc
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -109,9 +109,11 @@ public static void install(@NonNull Context context, @NonNull Downloader downloa
public static void install(@NonNull Context context,
@NonNull Downloader downloader,
@NonNull SplitConfiguration configuration) {
if (sReference.compareAndSet(null, new Qigsaw(context, downloader, configuration))) {
Qigsaw.instance().onBaseContextAttached();
//Qigsaw instance may be cached.
if (sReference.get() == null) {
sReference.set(new Qigsaw(context, downloader, configuration));
}
Qigsaw.instance().onBaseContextAttached();
}

private void onBaseContextAttached() {
Expand All @@ -129,7 +131,11 @@ private void onBaseContextAttached() {
currentProcessName,
splitConfiguration.workProcesses,
splitConfiguration.forbiddenWorkProcesses);
//data may be cached.
SplitLoadManagerService.getInstance().clear();
SplitLoadManagerService.getInstance().injectPathClassloader();
//data may be cached.
AABExtension.getInstance().clear();
AABExtension.getInstance().createAndActiveSplitApplication(context, qigsawMode);
SplitCompat.install(context);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -177,4 +177,8 @@ private Set<String> getSplitNames() {
return modules;
}

public final void clear() {
sSplitContentProviderMap.clear();
aabApplications.clear();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -162,14 +162,15 @@ private static List<String> getLoadedResourcesDirs(AssetManager asset) throws No
int totalResCount = appStringBlocks.length;
SplitLog.i(TAG, "Total resources count: " + totalResCount);
for (int appResIndex = 1; appResIndex <= totalResCount; ++appResIndex) {
String inApp;
try {
String inApp = (String) VersionCompat.getGetCookieNameMethod().invoke(asset, appResIndex);
existedAppResDirList.add(inApp);
} catch (IndexOutOfBoundsException e) {
inApp = (String) VersionCompat.getGetCookieNameMethod().invoke(asset, appResIndex);
} catch (Throwable e) {
//some phone like LG and SONY, may occur empty cookie error.
} catch (InvocationTargetException e) {
SplitLog.w(TAG, "Unable to get cookie name for resources index " + appResIndex, e);
continue;
}
existedAppResDirList.add(inApp);
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -146,4 +146,7 @@ final Set<Split> getLoadedSplits() {
return loadedSplits;
}

public final void clear() {
loadedSplits.clear();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,9 @@ public static void install(Context context,
String currentProcessName,
String[] workProcesses,
String[] forbiddenWorkProcesses) {
sReference.set(create(context, splitLoadMode, qigsawMode, isMainProcess, currentProcessName, workProcesses, forbiddenWorkProcesses));
if (sReference.get() == null) {
sReference.set(create(context, splitLoadMode, qigsawMode, isMainProcess, currentProcessName, workProcesses, forbiddenWorkProcesses));
}
}

public static boolean hasInstance() {
Expand Down

0 comments on commit f623dcc

Please sign in to comment.