feat: 预检查 Webview 是否安装/安装错误ABI
This commit is contained in:
@ -17,12 +17,13 @@ import android.text.TextUtils;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.annotation.WorkerThread;
|
||||
import androidx.webkit.WebViewCompat;
|
||||
|
||||
import com.android.apksig.ApkVerifier;
|
||||
import com.android.apksig.internal.apk.ApkSigningBlockUtilsLite;
|
||||
import com.g00fy2.versioncompare.Version;
|
||||
import com.gh.common.xapk.XapkInstaller;
|
||||
import com.gh.download.DownloadManager;
|
||||
import com.gh.gamecenter.BuildConfig;
|
||||
import com.gh.gamecenter.common.constant.Constants;
|
||||
import com.gh.gamecenter.common.utils.ExtensionsKt;
|
||||
@ -34,7 +35,6 @@ import com.gh.gamecenter.manager.PackagesManager;
|
||||
import com.gh.vspace.VHelper;
|
||||
import com.gh.vspace.db.VGameEntity;
|
||||
import com.halo.assistant.HaloApp;
|
||||
import com.lightgame.download.DownloadEntity;
|
||||
import com.lightgame.utils.Utils;
|
||||
|
||||
import net.dongliu.apk.parser.ApkFile;
|
||||
@ -47,6 +47,8 @@ import org.json.JSONObject;
|
||||
import java.io.BufferedReader;
|
||||
import java.io.ByteArrayInputStream;
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.FileNotFoundException;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.InputStreamReader;
|
||||
@ -60,6 +62,7 @@ import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.zip.ZipEntry;
|
||||
import java.util.zip.ZipFile;
|
||||
import java.util.zip.ZipInputStream;
|
||||
|
||||
public class PackageUtils {
|
||||
|
||||
@ -902,4 +905,42 @@ public class PackageUtils {
|
||||
return result;
|
||||
}
|
||||
|
||||
public static String getWebviewPath(Context context) {
|
||||
final PackageInfo webViewPackageInfo = WebViewCompat.getCurrentWebViewPackage(context);
|
||||
return webViewPackageInfo != null ? webViewPackageInfo.applicationInfo.sourceDir : null;
|
||||
}
|
||||
|
||||
@WorkerThread
|
||||
public static List<String> getApkAbiList(String path) {
|
||||
File file = new File(path);
|
||||
List<String> abiList = new ArrayList<>();
|
||||
if (!file.exists()) return abiList;
|
||||
InputStream inputStream;
|
||||
try {
|
||||
inputStream = new FileInputStream(file);
|
||||
ZipInputStream zipInputStream = new ZipInputStream(inputStream);
|
||||
ZipEntry zipEntry;
|
||||
while ((zipEntry = zipInputStream.getNextEntry()) != null) {
|
||||
final String name = zipEntry.getName();
|
||||
if (name.startsWith("lib/armeabi-v7a")
|
||||
|| name.startsWith("lib/arm64-v8a")
|
||||
|| name.startsWith("lib/x86")
|
||||
|| name.startsWith("lib/armeabi")
|
||||
|| name.startsWith("lib/x86_64")) {
|
||||
String abiName = name.substring(4, name.lastIndexOf("/"));
|
||||
if (!abiList.contains(abiName)) {
|
||||
abiList.add(abiName);
|
||||
}
|
||||
}
|
||||
}
|
||||
zipInputStream.close();
|
||||
inputStream.close();
|
||||
} catch (FileNotFoundException e) {
|
||||
e.printStackTrace();
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return abiList;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user