|
|
@@ -1,6 +1,7 @@
|
|
|
package com.kfzs.duanduan.utils;
|
|
|
|
|
|
import android.annotation.SuppressLint;
|
|
|
+import android.app.ProgressDialog;
|
|
|
import android.content.Context;
|
|
|
import android.content.Intent;
|
|
|
import android.content.pm.ApplicationInfo;
|
|
|
@@ -9,6 +10,7 @@ import android.content.pm.PackageManager;
|
|
|
import android.content.pm.Signature;
|
|
|
import android.graphics.drawable.Drawable;
|
|
|
import android.net.Uri;
|
|
|
+import android.support.v7.app.AlertDialog;
|
|
|
import android.text.TextUtils;
|
|
|
import android.util.Base64;
|
|
|
import android.view.View;
|
|
|
@@ -93,6 +95,9 @@ public class ApkUtils {
|
|
|
* @param apkPath apkPath
|
|
|
*/
|
|
|
public static final void installApk(final Context context, final String apkPath) {
|
|
|
+ final ProgressDialog progress = new ProgressDialog(SheepApp.getInstance().getCurrentActivity());
|
|
|
+ progress.setMessage("正在检测安装程序的安全性,请稍候");
|
|
|
+ progress.show();
|
|
|
final ApkFileInfo apkFileInfo = new ApkFileInfo();
|
|
|
apkFileInfo.setPath(apkPath);
|
|
|
Observable.just(apkFileInfo)
|
|
|
@@ -107,6 +112,7 @@ public class ApkUtils {
|
|
|
|
|
|
@Override
|
|
|
public void onComplete() {
|
|
|
+ hideProgress();
|
|
|
if (doneNext)
|
|
|
return;
|
|
|
if (apkFileInfo.isAppInstalled()) {//在onNext中未处理且应用已经安装的情况下,直接打开应用
|
|
|
@@ -118,6 +124,7 @@ public class ApkUtils {
|
|
|
|
|
|
@Override
|
|
|
public void onError(Throwable e) {
|
|
|
+ hideProgress();
|
|
|
G.showToast(e.getMessage());
|
|
|
}
|
|
|
|
|
|
@@ -127,6 +134,12 @@ public class ApkUtils {
|
|
|
checkAndInstall(item);
|
|
|
}
|
|
|
|
|
|
+ private void hideProgress() {
|
|
|
+ if (progress != null && progress.isShowing()) {
|
|
|
+ progress.dismiss();
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
private void checkAndInstall(ApkFileInfo item) {
|
|
|
if (!item.isAppInstalled() || (item.isEqualsSignMd5() && item.isCanInstallVersion())) {
|
|
|
PackageUtil.installApk(context, item.getPath());
|