|
@@ -1,6 +1,7 @@
|
|
|
package com.wdkl.callingbed.util.silentupdate;
|
|
|
|
|
|
import android.content.Context;
|
|
|
+import android.content.pm.ApplicationInfo;
|
|
|
import android.content.pm.IPackageManager;
|
|
|
import android.content.pm.PackageInfo;
|
|
|
import android.content.pm.PackageManager;
|
|
@@ -103,6 +104,11 @@ public class SilentUpdateUtil {
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
+ /*if (!checkApkAvailable(context, DownloadUtil.FILE_APK_PATH + "/" + DownloadUtil.FILE_APK_NAME)) {
|
|
|
+ ToastUtil.showToast("apk文件不匹配,升级失败!");
|
|
|
+ return;
|
|
|
+ }*/
|
|
|
+
|
|
|
// if (Build.VERSION.SDK_INT >= 26) {
|
|
|
//rk3368 8.1
|
|
|
DownloadUtils downloadUtils = new DownloadUtils(context);
|
|
@@ -218,4 +224,22 @@ public class SilentUpdateUtil {
|
|
|
}
|
|
|
return pName.contains(packageName);
|
|
|
}
|
|
|
+
|
|
|
+ private static boolean checkApkAvailable(Context context, String path) {
|
|
|
+ try {
|
|
|
+ PackageManager pm = context.getPackageManager();
|
|
|
+ PackageInfo info = pm.getPackageArchiveInfo(path, 0);
|
|
|
+ ApplicationInfo applicationInfo = info.applicationInfo;
|
|
|
+ String newPkg = applicationInfo.packageName;
|
|
|
+ String curPkg = context.getPackageName();
|
|
|
+ LogUtil.d("updateApk", "new package: " + newPkg + ", cur package: " + curPkg);
|
|
|
+ if (curPkg.equals(newPkg)) {
|
|
|
+ return true;
|
|
|
+ }
|
|
|
+ } catch (Exception e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ }
|
|
|
+
|
|
|
+ return false;
|
|
|
+ }
|
|
|
}
|