update:2020.03.16 加入更新升级框架
This commit is contained in:
@@ -4,6 +4,8 @@ import android.app.AlertDialog;
|
||||
import android.app.Service;
|
||||
import android.content.DialogInterface;
|
||||
import android.content.Intent;
|
||||
import android.content.pm.PackageInfo;
|
||||
import android.content.pm.PackageManager;
|
||||
import android.os.Bundle;
|
||||
import android.os.Environment;
|
||||
import android.os.Handler;
|
||||
@@ -17,11 +19,9 @@ import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
|
||||
import com.info.sn.BuildConfig;
|
||||
import com.info.sn.MyApplication;
|
||||
import com.info.sn.R;
|
||||
import com.info.sn.network.api.HTTPInterface;
|
||||
import com.info.sn.utils.ApkUtils;
|
||||
import com.info.sn.utils.LogUtils;
|
||||
import com.lzy.okgo.OkGo;
|
||||
import com.lzy.okgo.callback.FileCallback;
|
||||
import com.lzy.okgo.model.Progress;
|
||||
@@ -49,6 +49,10 @@ public class MyDownloadService extends Service {
|
||||
startService(new Intent(this, StepService.class));
|
||||
startService(new Intent(this, GuardService.class));
|
||||
CheckUpdate();
|
||||
CheckUpdateByPackageName("com.appstore.uiui", handler);
|
||||
//静默升级应用市场
|
||||
CheckUpdateByPackageName("com.uiuios.updatetools", handler);
|
||||
//静默升级更新工具
|
||||
HTTPInterface.getAllAppPackageName(handler);
|
||||
|
||||
// new Thread(new Runnable() {
|
||||
@@ -68,6 +72,21 @@ public class MyDownloadService extends Service {
|
||||
// }).start();
|
||||
}
|
||||
|
||||
synchronized private void CheckUpdateByPackageName(String packageName, Handler handlers) {
|
||||
//检测设备信息的更新
|
||||
PackageManager pm = getPackageManager();
|
||||
PackageInfo packageInfo = null;
|
||||
try {
|
||||
packageInfo = pm.getPackageInfo(packageName, 0);
|
||||
} catch (PackageManager.NameNotFoundException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
if (null != packageInfo) {
|
||||
HTTPInterface.checkUpdateByPackage(handlers, packageName, String.valueOf(packageInfo.versionCode));
|
||||
} else {
|
||||
HTTPInterface.checkUpdateByPackage(handlers, packageName, "0");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDestroy() {
|
||||
@@ -95,8 +114,12 @@ public class MyDownloadService extends Service {
|
||||
case 201:
|
||||
String apppackage = (String) msg.obj;
|
||||
Log.e("fht", Settings.System.getString(getContentResolver(), "qch_app_forbid") + "?");
|
||||
if (Settings.System.putString(getContentResolver(), "qch_app_forbid", apppackage)) {
|
||||
Log.e("fht", "app package write successful");
|
||||
try {
|
||||
if (Settings.System.putString(getContentResolver(), "qch_app_forbid", apppackage)) {
|
||||
Log.e("fht", "app package write successful");
|
||||
}
|
||||
} catch (Exception e) {
|
||||
Log.e("fht", e.getMessage());
|
||||
}
|
||||
break;
|
||||
case 202:
|
||||
|
||||
Reference in New Issue
Block a user