Merge remote-tracking branch 'origin/release' into dev-5.2.0

# Conflicts:
#	dependencies.gradle
This commit is contained in:
juntao
2021-08-30 17:22:45 +08:00
47 changed files with 414 additions and 286 deletions

View File

@ -16,10 +16,8 @@ import android.os.PowerManager;
import android.text.TextUtils;
import androidx.annotation.Nullable;
import androidx.annotation.WorkerThread;
import com.g00fy2.versioncompare.Version;
import com.gh.common.AppExecutor;
import com.gh.common.xapk.XapkInstaller;
import com.gh.gamecenter.BuildConfig;
import com.gh.gamecenter.entity.ApkEntity;
@ -241,13 +239,9 @@ public class PackageUtils {
return null;
}
// TODO 找一个更高效的方式来比较 V2 签名
// TODO 找一个更好的办法来比较签名并且不触发 ANR
public static boolean compareSignatureBetweenInstalledAppWithApk(Context context, String packageName, String apkFilePath) {
try {
AppExecutor.getUiExecutor().execute(() -> {
ToastUtils.toast("安装包校验中约需要3~5秒请稍候");
});
// 据 Sentry 统计,刚上架一个周末的包里对这个方法有 700+ 次调用,然后其中一部分会造成 ANR
Signature sig = context.getPackageManager().getPackageInfo(packageName, PackageManager.GET_SIGNATURES).signatures[0];
@ -300,14 +294,11 @@ public class PackageUtils {
}
/**
* 根据 path 获取 apk 是否可安装 (全新安装或覆盖安装)
*
* 由于部分不存在 V1 签名的大安装包在调用系统 API 获取签名信息时会非常慢,所以请在工作线程里调用此方法
* 根据 path 获取 apk 信息确定处理方式
*
* @return true 为直接唤起系统 PackageInstaller, false 为需要插件化
* @return true 为直接唤起系统 PackageInstaller, false 为需要插件化
*/
@WorkerThread
public static boolean isInstallable(Context context, String path) {
public static boolean isCanLaunchSetup(Context context, String path) {
String packageName = getPackageNameByPath(context, path);
if (TextUtils.isEmpty(packageName)) {