Skip to content

Commit

Permalink
add process check when load splits
Browse files Browse the repository at this point in the history
  • Loading branch information
xida committed Dec 16, 2020
1 parent f623dcc commit 10f15e1
Show file tree
Hide file tree
Showing 2 changed files with 60 additions and 2 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
/*
* MIT License
*
* Copyright (c) 2019-present, iQIYI, Inc. All rights reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/

package com.iqiyi.android.qigsaw.core.splitload;

class SkipSplitLoadTaskImpl implements Runnable {

@Override
public final void run() {
// empty
}

}

Original file line number Diff line number Diff line change
Expand Up @@ -110,10 +110,14 @@ public void getResources(Resources resources) {

@Override
public Runnable createSplitLoadTask(List<Intent> splitFileIntents, @Nullable OnSplitLoadListener loadListener) {
List<Intent> filterSplitFileIntentList = filterIntentsCanWorkInThisProcess(splitFileIntents);
if (filterSplitFileIntentList.isEmpty()) {
return new SkipSplitLoadTaskImpl();
}
if (splitLoadMode() == SplitLoad.MULTIPLE_CLASSLOADER) {
return new SplitLoadTaskImpl(this, splitFileIntents, loadListener);
return new SplitLoadTaskImpl(this, filterSplitFileIntentList, loadListener);
} else {
return new SplitLoadTaskImpl2(this, splitFileIntents, loadListener);
return new SplitLoadTaskImpl2(this, filterSplitFileIntentList, loadListener);
}
}

Expand Down Expand Up @@ -147,6 +151,25 @@ private void loadInstalledSplitsInternal(Collection<String> splitNames) {
createSplitLoadTask(splitFileIntents, null).run();
}

private List<Intent> filterIntentsCanWorkInThisProcess(@NonNull List<Intent> intentList) {
List<Intent> filterIntentList = new ArrayList<>(intentList.size());
SplitInfoManager infoManager = SplitInfoManagerService.getInstance();
if (infoManager == null) {
return intentList;
}
for (Intent splitFileIntent : intentList) {
final String splitName = splitFileIntent.getStringExtra(SplitConstants.KET_NAME);
SplitInfo info = infoManager.getSplitInfo(getContext(), splitName);
if (canBeWorkedInThisProcessForSplit(info)) {
filterIntentList.add(splitFileIntent);
SplitLog.i(TAG, "Split %s need load in process %s", info.getSplitName(), currentProcessName);
} else {
SplitLog.i(TAG, "Split %s do not need load in process %s", info.getSplitName(), currentProcessName);
}
}
return filterIntentList;
}

private boolean isInjectPathClassloaderNeeded() {
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.Q) {
return qigsawMode;
Expand Down

0 comments on commit 10f15e1

Please sign in to comment.