update:2019.03.18

fix:增加桌面,应用市场,updatetools静默安装。增加亮屏后检测更新
add:
This commit is contained in:
2020-03-18 18:40:06 +08:00
parent e898f83670
commit f51ceac69d
8 changed files with 385 additions and 30 deletions

View File

@@ -94,6 +94,7 @@ public class MainActivity extends AppCompatActivity {
initView();
initData();
HTTPInterface.checkDevicesInfo(handler);
HTTPInterface.checkUpdateByself(handler, this.getPackageName(), String.valueOf(BuildConfig.VERSION_CODE));
startService(new Intent(MainActivity.this, MyDownloadService.class));
}
@@ -135,7 +136,7 @@ public class MainActivity extends AppCompatActivity {
if (mHits[0] >= (SystemClock.uptimeMillis() - DURATION)) {
mHits = new long[COUNTS];//重新初始化数组
Toast.makeText(this, "正在检查更新", Toast.LENGTH_SHORT).show();
HTTPInterface.checkUpdateByPackage(handler, this.getPackageName(), String.valueOf(BuildConfig.VERSION_CODE));
HTTPInterface.checkUpdateByself(handler, this.getPackageName(), String.valueOf(BuildConfig.VERSION_CODE));
}
}
@@ -275,21 +276,27 @@ public class MainActivity extends AppCompatActivity {
SPUtils.put(MainActivity.this, "isLogined", 2);
setImageAndText(imageView, "未经验证的设备,请联系客服");
break;
case 200:
case 300:
Bundle bundle = (Bundle) msg.obj;
getFile(bundle);
break;
case -200:
ToastUtil.show("已是最新版本");
break;
case -300:
ToastUtil.show("网络连接失败,检查网络连接");
break;
}
}
};
private void getFile(final Bundle bundle) {
String url = bundle.getString("url");
final File path = new File(Environment.getExternalStoragePublicDirectory("Download") + "/Sninfo/");
path.mkdirs();
final File file = new File(Environment.getExternalStoragePublicDirectory("Download") + "/Sninfo/Update" + bundle.getString("versionCode") + ".apk");
final File file = new File(Environment.getExternalStoragePublicDirectory("Download") + "/Sninfo/" + url.substring(url.lastIndexOf("/") + 1));
if (file.exists() && file.isFile()) {
AlertDialog.Builder builder = new AlertDialog.Builder(this)
@@ -309,8 +316,8 @@ public class MainActivity extends AppCompatActivity {
ad.setCanceledOnTouchOutside(false); //点击外面区域不会让dialog消失
ad.show();
} else {
OkGo.<File>get(bundle.getString("url"))
.execute(new FileCallback("Sninfo/Update" + bundle.getString("versionCode") + ".apk") {
OkGo.<File>get(url)
.execute(new FileCallback("Sninfo/" + url.substring(url.lastIndexOf("/") + 1)) {
@Override
public void onSuccess(final Response<File> response) {
// Settings.System.putString(getApplicationContext().getContentResolver(), "qch_app_forbid", "com.baidu.video");