53 lines
1.6 KiB
Java
53 lines
1.6 KiB
Java
package com.gh.common.util;
|
|
|
|
import com.gh.gamecenter.BuildConfig;
|
|
import com.gh.gamecenter.entity.ApkEntity;
|
|
import com.gh.gamecenter.entity.GameEntity;
|
|
import com.gh.gamecenter.manager.PackagesManager;
|
|
import com.lightgame.utils.Utils;
|
|
|
|
import java.util.List;
|
|
|
|
import io.reactivex.functions.Function;
|
|
|
|
/**
|
|
* Created by khy on 10/05/17.
|
|
*/
|
|
|
|
public class ApkActiveUtils {
|
|
|
|
public static void filterHideApk(GameEntity gameEntity) {
|
|
try {
|
|
if (gameEntity == null || gameEntity.getOriginalApk().size() == 0) return;
|
|
List<ApkEntity> apkList = gameEntity.getOriginalApk();
|
|
for (int i = 0; i < apkList.size(); i++) {
|
|
ApkEntity apkEntity = apkList.get(i);
|
|
String packageName = apkEntity.getPackageName();
|
|
String id = gameEntity.getId();
|
|
if (!apkEntity.isActive() && !PackagesManager.INSTANCE.isCanPluggable(id, packageName)) {
|
|
apkList.remove(i);
|
|
i--;
|
|
}
|
|
}
|
|
} catch (Exception e) {
|
|
if (BuildConfig.DEBUG) {
|
|
Utils.log("filter hide game apk throws exception:" + e.toString());
|
|
}
|
|
}
|
|
}
|
|
|
|
// 过滤隐藏apk包
|
|
public static Function<List<GameEntity>, List<GameEntity>> filterMapperList = list -> {
|
|
for (GameEntity gameEntity : list) {
|
|
ApkActiveUtils.filterHideApk(gameEntity);
|
|
}
|
|
return list;
|
|
};
|
|
|
|
// 过滤隐藏apk包
|
|
public static Function<GameEntity, GameEntity> filterMapper = list -> {
|
|
ApkActiveUtils.filterHideApk(list);
|
|
return list;
|
|
};
|
|
}
|