|
@@ -8,6 +8,7 @@ import com.alibaba.fastjson.JSONObject;
|
|
|
import com.didi.virtualapk.PluginManager;
|
|
import com.didi.virtualapk.PluginManager;
|
|
|
import com.didi.virtualapk.internal.LoadedPlugin;
|
|
import com.didi.virtualapk.internal.LoadedPlugin;
|
|
|
import com.didi.virtualapk.internal.utils.PluginUtil;
|
|
import com.didi.virtualapk.internal.utils.PluginUtil;
|
|
|
|
|
+import com.kfzs.cfyl.share_library.util.CallBackAPI;
|
|
|
import com.sheep.gamegroup.absBase.AbsObserver;
|
|
import com.sheep.gamegroup.absBase.AbsObserver;
|
|
|
import com.sheep.gamegroup.model.entity.BaseMessage;
|
|
import com.sheep.gamegroup.model.entity.BaseMessage;
|
|
|
import com.sheep.gamegroup.model.util.SheepSubscriber;
|
|
import com.sheep.gamegroup.model.util.SheepSubscriber;
|
|
@@ -55,6 +56,10 @@ public class SheepPluginUtil {
|
|
|
//检查并更新插件
|
|
//检查并更新插件
|
|
|
public static Observable<Plugin> checkAndRunPlugin(Activity activity, Plugin plugin) {
|
|
public static Observable<Plugin> checkAndRunPlugin(Activity activity, Plugin plugin) {
|
|
|
return Observable.create((ObservableOnSubscribe<Plugin>) emitter -> {
|
|
return Observable.create((ObservableOnSubscribe<Plugin>) emitter -> {
|
|
|
|
|
+ if(TextUtils.isEmpty(plugin.getSuffix())){//后缀为空,不需要下载文件,可以直接使用
|
|
|
|
|
+ emitter.onNext(plugin);
|
|
|
|
|
+ return;
|
|
|
|
|
+ }
|
|
|
String packageName = plugin.getPackageName();
|
|
String packageName = plugin.getPackageName();
|
|
|
String type = SheepPluginUtil.getCPU_ABI();
|
|
String type = SheepPluginUtil.getCPU_ABI();
|
|
|
int versionCode = BuildConfig.VERSION_CODE;
|
|
int versionCode = BuildConfig.VERSION_CODE;
|
|
@@ -67,7 +72,7 @@ public class SheepPluginUtil {
|
|
|
.map(clientPackage -> {
|
|
.map(clientPackage -> {
|
|
|
if (clientPackage != null && clientPackage.getMd_5() != null) {
|
|
if (clientPackage != null && clientPackage.getMd_5() != null) {
|
|
|
String key = ApiKey.getPackageVersion(packageName, type, versionCode);
|
|
String key = ApiKey.getPackageVersion(packageName, type, versionCode);
|
|
|
- File file = getFile(key);
|
|
|
|
|
|
|
+ File file = getFile(key, plugin);
|
|
|
if (file.exists()) {
|
|
if (file.exists()) {
|
|
|
if (Md5Util.checkMD5(clientPackage.getMd_5(), file)) {
|
|
if (Md5Util.checkMD5(clientPackage.getMd_5(), file)) {
|
|
|
return null;
|
|
return null;
|
|
@@ -93,26 +98,8 @@ public class SheepPluginUtil {
|
|
|
});
|
|
});
|
|
|
}).subscribeOn(Schedulers.io())
|
|
}).subscribeOn(Schedulers.io())
|
|
|
.filter(plugin1 -> {
|
|
.filter(plugin1 -> {
|
|
|
- if (PluginManager.getInstance(SheepApp.getInstance()).getLoadedPlugin(plugin1.getPackageName()) == null) {
|
|
|
|
|
-// String cpuAbi = getCPU_ABI();
|
|
|
|
|
-// String pluginPath = String.format(Locale.CHINA, "%s/media_%s.apk", ClassFileHelper.DIR, cpuAbi);
|
|
|
|
|
- String pluginPath = ClassFileHelper.DIR + "/media_release.apk";
|
|
|
|
|
-// LogUtil.println(PluginUtil.class.getSimpleName(), "CPU_ABI =", cpuAbi, "pluginPath =", pluginPath);
|
|
|
|
|
- File file = new File(pluginPath);
|
|
|
|
|
- boolean isUserTestFile = TestUtil.isTest() && file.exists();
|
|
|
|
|
- LogUtil.println("startPlugin", isUserTestFile);
|
|
|
|
|
- File pluginFile = isUserTestFile ? file : getFile(plugin1);
|
|
|
|
|
- if (!pluginFile.exists()) {
|
|
|
|
|
- return false;
|
|
|
|
|
- }
|
|
|
|
|
- try {
|
|
|
|
|
- PluginManager.getInstance(SheepApp.getInstance()).loadPlugin(pluginFile);
|
|
|
|
|
- } catch (Exception e) {
|
|
|
|
|
- e.printStackTrace();
|
|
|
|
|
- return false;
|
|
|
|
|
- }
|
|
|
|
|
- }
|
|
|
|
|
- return true;
|
|
|
|
|
|
|
+ CallBackAPI.get().setPackageName(plugin1.getPackageName());
|
|
|
|
|
+ return plugin1.loadPlugin();
|
|
|
});
|
|
});
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -202,7 +189,7 @@ public class SheepPluginUtil {
|
|
|
|
|
|
|
|
public static File getFile(Plugin plugin) {
|
|
public static File getFile(Plugin plugin) {
|
|
|
String key = getKey(plugin);
|
|
String key = getKey(plugin);
|
|
|
- return getFile(key);
|
|
|
|
|
|
|
+ return getFile(key, plugin);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
public static String getDownloadPluginKey(Plugin plugin) {
|
|
public static String getDownloadPluginKey(Plugin plugin) {
|
|
@@ -218,10 +205,10 @@ public class SheepPluginUtil {
|
|
|
|
|
|
|
|
public static String getFileName(Plugin plugin) {
|
|
public static String getFileName(Plugin plugin) {
|
|
|
String key = getKey(plugin);
|
|
String key = getKey(plugin);
|
|
|
- return key.hashCode() + ".apk";
|
|
|
|
|
|
|
+ return key.hashCode() + plugin.getSuffix();
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- public static File getFile(String key) {
|
|
|
|
|
- return new File(getDir(), key.hashCode() + ".apk");
|
|
|
|
|
|
|
+ public static File getFile(String key, Plugin plugin) {
|
|
|
|
|
+ return new File(getDir(), key.hashCode() + plugin.getSuffix());
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|