version:2.0.1.6_release

update:2020.07.09
fix:主页区分教管易和设备信息更新,进入主页不自动检查自身更新
add:统一下载逻辑
This commit is contained in:
2020-07-09 18:37:31 +08:00
parent d6857d576c
commit c6c025c225
7 changed files with 132 additions and 69 deletions

View File

@@ -15,10 +15,10 @@ android {
minSdkVersion 20 minSdkVersion 20
targetSdkVersion 29 targetSdkVersion 29
// versionCode 103 // versionCode 104
// versionName "3.0.8"//测试jiaoguanyi.cn // versionName "3.0.9"//测试jiaoguanyi.cn
versionCode 1005 versionCode 1006
versionName "2.0.1.5"// 正式jiaoguanyi.com 双数正式 单数测试 versionName "2.0.1.6"// 正式jiaoguanyi.com 双数正式 单数测试
multiDexEnabled true multiDexEnabled true
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"

View File

@@ -483,7 +483,7 @@ public class MyApplication extends MultiDexApplication {
com.lzy.okserver.download.DownloadManager downloadManager = DownloadService.getDownloadManager(); com.lzy.okserver.download.DownloadManager downloadManager = DownloadService.getDownloadManager();
// downloadManager.setTargetFolder(StorageUtils.getFileRoot(this)); // downloadManager.setTargetFolder(StorageUtils.getFileRoot(this));
downloadManager.setTargetFolder(PathUtils.getExternalDownloadsPath() + "/ygj/"); downloadManager.setTargetFolder(PathUtils.getExternalDownloadsPath() + "/jgy/");
downloadManager.getThreadPool().setCorePoolSize(5); downloadManager.getThreadPool().setCorePoolSize(5);
} }

View File

@@ -243,12 +243,13 @@ public class MainActivity extends AppCompatActivity {
} }
synchronized public void sendMACaddress() { synchronized public void sendMACaddress() {
String devices_version = Utils.getProperty("ro.custom.build.version", "获取失败");
String rid = JPushInterface.getRegistrationID(getApplicationContext()); String rid = JPushInterface.getRegistrationID(getApplicationContext());
OkGo.post(Configure.SEND_DEVICES) OkGo.post(Configure.SEND_DEVICES)
.params("sn", Utils.getSerial()) .params("sn", Utils.getSerial())
.params("mac", com.blankj.utilcode.util.DeviceUtils.getMacAddress()) .params("mac", com.blankj.utilcode.util.DeviceUtils.getMacAddress())
.params("jpush_id", rid) .params("jpush_id", rid)
.params("devices_version", Utils.getProperty("ro.custom.build.version", "获取失败")) .params("devices_version", devices_version)
.params("appstore_version", BuildConfig.VERSION_NAME)//设备信息版本号 .params("appstore_version", BuildConfig.VERSION_NAME)//设备信息版本号
.params("store_version", getAPPVersionName())//管教易版本号 .params("store_version", getAPPVersionName())//管教易版本号
.execute(new StringCallback() { .execute(new StringCallback() {
@@ -557,7 +558,7 @@ public class MainActivity extends AppCompatActivity {
private void checkUpdate() { private void checkUpdate() {
HTTPInterface.checkUpdate(mHandler, "com.jiaoguanyi.store"); HTTPInterface.checkUpdate(mHandler, "com.jiaoguanyi.store");
HTTPInterface.checkUpdate(mHandler, "com.jiaoguanyi.appstore"); // HTTPInterface.checkUpdate(mHandler, "com.jiaoguanyi.appstore");
} }
private Handler mHandler = new Handler() { private Handler mHandler = new Handler() {
@@ -645,7 +646,15 @@ public class MainActivity extends AppCompatActivity {
e.printStackTrace(); e.printStackTrace();
} }
if (packageInfo == null || packageInfo.versionCode < versionCode) { if (packageInfo == null || packageInfo.versionCode < versionCode) {
if (packageName.equalsIgnoreCase("com.jiaoguanyi.store")) {
// Aria.download(this)
// .load(url) //读取下载地址
// .setFilePath(PathUtils.getExternalDownloadsPath() + "/jgy/" + EncryptUtils.encryptMD5ToString(packageName) + ".apk", true)
// .setExtendField(object.toJSONString())
// .create(); //启动下载}
Utils.ariaDownload(this, url, object);
return;
}
AlertDialog.Builder builder = new AlertDialog.Builder(MainActivity.this); AlertDialog.Builder builder = new AlertDialog.Builder(MainActivity.this);
builder.setTitle("更新:"); builder.setTitle("更新:");
builder.setMessage("检测到有新版本,是否更新?"); builder.setMessage("检测到有新版本,是否更新?");
@@ -655,11 +664,13 @@ public class MainActivity extends AppCompatActivity {
builder.setPositiveButton("更新", new DialogInterface.OnClickListener() { builder.setPositiveButton("更新", new DialogInterface.OnClickListener() {
@Override @Override
public void onClick(DialogInterface dialog, int which) { public void onClick(DialogInterface dialog, int which) {
Aria.download(this) // Aria.download(this)
.load(url) //读取下载地址 // .load(url) //读取下载地址
.setFilePath(PathUtils.getExternalDownloadsPath() + "/ygj/" + EncryptUtils.encryptMD5ToString(packageName) + ".apk", true) // .setFilePath(PathUtils.getExternalDownloadsPath() + "/jgy/" + EncryptUtils.encryptMD5ToString(packageName) + ".apk", true)
.setExtendField(object.toJSONString()) // .setExtendField(object.toJSONString())
.create(); //启动下载} // .create(); //启动下载}
Utils.ariaDownload(MainActivity.this, url, object);
dialog.dismiss(); dialog.dismiss();
} }
}); });
@@ -672,12 +683,22 @@ public class MainActivity extends AppCompatActivity {
}); });
builder.show(); builder.show();
} else { } else {
ToastUtil.show("已是最新版本"); if (!packageName.equalsIgnoreCase("com.jiaoguanyi.store")) {
mHandler.postDelayed(toast, 4000);
}
Log.e("fht", "已是最新版本"); Log.e("fht", "已是最新版本");
} }
} }
private Runnable toast = new Runnable() {
@Override
public void run() {
ToastUtil.show("已是最新版本");
}
};
private int getBatteryLevel() { private int getBatteryLevel() {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
BatteryManager batteryManager = (BatteryManager) getSystemService(BATTERY_SERVICE); BatteryManager batteryManager = (BatteryManager) getSystemService(BATTERY_SERVICE);
@@ -739,7 +760,7 @@ public class MainActivity extends AppCompatActivity {
@Override @Override
public void onError(Call call, Response response, Exception e) { public void onError(Call call, Response response, Exception e) {
super.onError(call, response, e); super.onError(call, response, e);
Log.e("onError", "error"); Log.e("onError", "error:" + e.getMessage());
} }
});// 请求方式和请求url });// 请求方式和请求url
@@ -1105,7 +1126,7 @@ public class MainActivity extends AppCompatActivity {
if (version_code > AppUtils.getAppVersionCode()) { if (version_code > AppUtils.getAppVersionCode()) {
Aria.download(this) Aria.download(this)
.load(url) //读取下载地址 .load(url) //读取下载地址
.setFilePath(PathUtils.getExternalDownloadsPath() + "/ygj/" + EncryptUtils.encryptMD5ToString(url) + ".apk", true) .setFilePath(PathUtils.getExternalDownloadsPath() + "/jgy/" + EncryptUtils.encryptMD5ToString(url) + ".apk", true)
.setExtendField(BuildConfig.APPLICATION_ID) .setExtendField(BuildConfig.APPLICATION_ID)
.create(); //启动下载}} .create(); //启动下载}}
} }
@@ -1254,7 +1275,7 @@ public class MainActivity extends AppCompatActivity {
// if (!AppUtils.isAppInstalled(app_package)) { // if (!AppUtils.isAppInstalled(app_package)) {
// Aria.download(this) // Aria.download(this)
// .load(app_url) //读取下载地址 // .load(app_url) //读取下载地址
// .setDownloadPath(PathUtils.getExternalDownloadsPath() + "/ygj/" + EncryptUtils.encryptMD5ToString(app_package) + ".apk") // .setDownloadPath(PathUtils.getExternalDownloadsPath() + "/jgy/" + EncryptUtils.encryptMD5ToString(app_package) + ".apk")
// .setExtendField(app_package) // .setExtendField(app_package)
// .start(); //启动下载} // .start(); //启动下载}
// } // }
@@ -1299,20 +1320,23 @@ public class MainActivity extends AppCompatActivity {
} }
if (app_version_code > appVersionCode) { if (app_version_code > appVersionCode) {
Log.e("fht ", "download URL " + app_url); Log.e("fht ", "download URL " + app_url);
Aria.download(this) // Aria.download(this)
.load(app_url) //读取下载地址 // .load(app_url) //读取下载地址
.setFilePath(PathUtils.getExternalDownloadsPath() + "/ygj/" + EncryptUtils.encryptMD5ToString(app_package) + ".apk", true) // .setFilePath(PathUtils.getExternalDownloadsPath() + "/jgy/" + EncryptUtils.encryptMD5ToString(app_package) + ".apk", true)
.setExtendField(jsonObject.toJSONString()) // .setExtendField(jsonObject.toJSONString())
.create(); //启动下载} // .create(); //启动下载}
Utils.ariaDownload(this, app_url, jsonObject);
} }
} else { } else {
Log.e("fht ", "download URL " + app_url); Log.e("fht ", "download URL " + app_url);
// if (!SaveListUtils.isDownLoading(app_package)) { // if (!SaveListUtils.isDownLoading(app_package)) {
Aria.download(this) // Aria.download(this)
.load(app_url) //读取下载地址 // .load(app_url) //读取下载地址
.setFilePath(PathUtils.getExternalDownloadsPath() + "/ygj/" + EncryptUtils.encryptMD5ToString(app_package) + ".apk", true) // .setFilePath(PathUtils.getExternalDownloadsPath() + "/jgy/" + EncryptUtils.encryptMD5ToString(app_package) + ".apk", true)
.setExtendField(jsonObject.toJSONString()) // .setExtendField(jsonObject.toJSONString())
.create(); //启动下载} // .create(); //启动下载}
Utils.ariaDownload(this, app_url, jsonObject);
// SaveListUtils.addDownLoadList(app_package); // SaveListUtils.addDownLoadList(app_package);
// } // }
} }
@@ -1329,11 +1353,13 @@ public class MainActivity extends AppCompatActivity {
com.alibaba.fastjson.JSONObject jsonObject = new com.alibaba.fastjson.JSONObject(); com.alibaba.fastjson.JSONObject jsonObject = new com.alibaba.fastjson.JSONObject();
jsonObject.put("app_name", forceDownloadData.getApp_name()); jsonObject.put("app_name", forceDownloadData.getApp_name());
jsonObject.put("app_package", forceDownloadData.getApp_package()); jsonObject.put("app_package", forceDownloadData.getApp_package());
Aria.download(this) // Aria.download(this)
.load(forceDownloadData.getApp_url()) //读取下载地址 // .load(forceDownloadData.getApp_url()) //读取下载地址
.setFilePath(PathUtils.getExternalDownloadsPath() + "/ygj/" + EncryptUtils.encryptMD5ToString("com.jiaoguanyi.store") + ".apk", true) // .setFilePath(PathUtils.getExternalDownloadsPath() + "/jgy/" + EncryptUtils.encryptMD5ToString("com.jiaoguanyi.store") + ".apk", true)
.setExtendField(jsonObject.toJSONString()) // .setExtendField(jsonObject.toJSONString())
.create(); //启动下载} // .create(); //启动下载}
Utils.ariaDownload(this, forceDownloadData.getApp_url(), jsonObject);
} }
} else { } else {
// Log.e("fht", "未上传应用"); // Log.e("fht", "未上传应用");

View File

@@ -227,11 +227,13 @@ public class MyJPushReceiver extends BroadcastReceiver {
com.alibaba.fastjson.JSONObject packageObj = new com.alibaba.fastjson.JSONObject(); com.alibaba.fastjson.JSONObject packageObj = new com.alibaba.fastjson.JSONObject();
packageObj.put("app_name", app_name); packageObj.put("app_name", app_name);
packageObj.put("app_package", app_package); packageObj.put("app_package", app_package);
Aria.download(this) // Aria.download(this)
.load(url) //读取下载地址 // .load(url) //读取下载地址
.setFilePath(PathUtils.getExternalDownloadsPath() + "/ygj/" + EncryptUtils.encryptMD5ToString(url) + ".apk", true) // .setFilePath(PathUtils.getExternalDownloadsPath() + "/jgy/" + EncryptUtils.encryptMD5ToString(url) + ".apk", true)
.setExtendField(packageObj.toJSONString()) // .setExtendField(packageObj.toJSONString())
.create(); //启动下载} // .create(); //启动下载}
Utils.ariaDownload(mContext, url,packageObj);
break; break;
case SET_HOMEPAG_TAG: case SET_HOMEPAG_TAG:
@@ -469,11 +471,12 @@ public class MyJPushReceiver extends BroadcastReceiver {
} }
if (packageInfo == null) { if (packageInfo == null) {
if (!SaveListUtils.isDownLoading(app_url)) { if (!SaveListUtils.isDownLoading(app_url)) {
Aria.download(this) // Aria.download(this)
.load(app_url) // .load(app_url)
.setFilePath(PathUtils.getExternalDownloadsPath() + "/ygj/" + EncryptUtils.encryptMD5ToString(s) + ".apk", true) // .setFilePath(PathUtils.getExternalDownloadsPath() + "/jgy/" + EncryptUtils.encryptMD5ToString(s) + ".apk", true)
.setExtendField(packageObj.toJSONString()) // .setExtendField(packageObj.toJSONString())
.create(); // .create();
Utils.ariaDownload(mContext, app_url,packageObj);
} }
} else { } else {
long appVersionCode; long appVersionCode;
@@ -484,11 +487,13 @@ public class MyJPushReceiver extends BroadcastReceiver {
} }
if (app_version_code > appVersionCode) { if (app_version_code > appVersionCode) {
if (!SaveListUtils.isDownLoading(app_url)) { if (!SaveListUtils.isDownLoading(app_url)) {
Aria.download(this) // Aria.download(this)
.load(app_url) // .load(app_url)
.setFilePath(PathUtils.getExternalDownloadsPath() + "/ygj/" + EncryptUtils.encryptMD5ToString(s) + ".apk", true) // .setFilePath(PathUtils.getExternalDownloadsPath() + "/jgy/" + EncryptUtils.encryptMD5ToString(s) + ".apk", true)
.setExtendField(packageObj.toJSONString()) // .setExtendField(packageObj.toJSONString())
.create(); // .create();
Utils.ariaDownload(mContext, app_url,packageObj);
} }
} }
} }

View File

@@ -19,6 +19,7 @@ import android.net.Network;
import android.net.NetworkInfo; import android.net.NetworkInfo;
import android.net.wifi.WifiInfo; import android.net.wifi.WifiInfo;
import android.net.wifi.WifiManager; import android.net.wifi.WifiManager;
import android.os.Build;
import android.os.IBinder; import android.os.IBinder;
import android.support.annotation.Nullable; import android.support.annotation.Nullable;
import android.text.format.Formatter; import android.text.format.Formatter;
@@ -31,6 +32,7 @@ import com.arialyy.aria.core.Aria;
import com.arialyy.aria.core.download.DownloadEntity; import com.arialyy.aria.core.download.DownloadEntity;
import com.arialyy.aria.core.task.DownloadTask; import com.arialyy.aria.core.task.DownloadTask;
import com.blankj.utilcode.util.LogUtils; import com.blankj.utilcode.util.LogUtils;
import com.mjsheng.myappstore.BuildConfig;
import com.mjsheng.myappstore.KeepAliveConnection; import com.mjsheng.myappstore.KeepAliveConnection;
import com.mjsheng.myappstore.MyApplication; import com.mjsheng.myappstore.MyApplication;
import com.mjsheng.myappstore.utils.ApkUtils; import com.mjsheng.myappstore.utils.ApkUtils;

View File

@@ -309,7 +309,6 @@ public class InitJpushServer extends Service {
} }
private void deleteOtherApp(String packageList) { private void deleteOtherApp(String packageList) {
Log.e("deleteOtherApp", "packageList:" + packageList); Log.e("deleteOtherApp", "packageList:" + packageList);
String[] result = packageList.split(","); String[] result = packageList.split(",");
@@ -464,20 +463,22 @@ public class InitJpushServer extends Service {
} }
if (app_version_code > appVersionCode) { if (app_version_code > appVersionCode) {
Log.e("fht ", "download URL " + app_url); Log.e("fht ", "download URL " + app_url);
Aria.download(this) // Aria.download(this)
.load(app_url) //读取下载地址 // .load(app_url) //读取下载地址
.setFilePath(PathUtils.getExternalDownloadsPath() + "/ygj/" + EncryptUtils.encryptMD5ToString(app_package) + ".apk", true) // .setFilePath(PathUtils.getExternalDownloadsPath() + "/jgy/" + EncryptUtils.encryptMD5ToString(app_package) + ".apk", true)
.setExtendField(jsonObject.toJSONString()) // .setExtendField(jsonObject.toJSONString())
.create(); //启动下载} // .create(); //启动下载}
Utils.ariaDownload(this, app_url, jsonObject);
} }
} else { } else {
Log.e("fht ", "download URL " + app_url); Log.e("fht ", "download URL " + app_url);
// if (!SaveListUtils.isDownLoading(app_package)) { // if (!SaveListUtils.isDownLoading(app_package)) {
Aria.download(this) // Aria.download(this)
.load(app_url) //读取下载地址 // .load(app_url) //读取下载地址
.setFilePath(PathUtils.getExternalDownloadsPath() + "/ygj/" + EncryptUtils.encryptMD5ToString(app_package) + ".apk", true) // .setFilePath(PathUtils.getExternalDownloadsPath() + "/jgy/" + EncryptUtils.encryptMD5ToString(app_package) + ".apk", true)
.setExtendField(jsonObject.toJSONString()) // .setExtendField(jsonObject.toJSONString())
.create(); //启动下载} // .create(); //启动下载}
Utils.ariaDownload(this, app_url, jsonObject);
// SaveListUtils.addDownLoadList(app_package); // SaveListUtils.addDownLoadList(app_package);
// } // }
} }
@@ -492,11 +493,13 @@ public class InitJpushServer extends Service {
com.alibaba.fastjson.JSONObject packageObj = new com.alibaba.fastjson.JSONObject(); com.alibaba.fastjson.JSONObject packageObj = new com.alibaba.fastjson.JSONObject();
packageObj.put("app_name", forceDownloadData.getApp_name()); packageObj.put("app_name", forceDownloadData.getApp_name());
packageObj.put("app_package", forceDownloadData.getApp_package()); packageObj.put("app_package", forceDownloadData.getApp_package());
Aria.download(this) // Aria.download(this)
.load(forceDownloadData.getApp_url()) //读取下载地址 // .load(forceDownloadData.getApp_url()) //读取下载地址
.setFilePath(PathUtils.getExternalDownloadsPath() + "/ygj/" + EncryptUtils.encryptMD5ToString("com.jiaoguanyi.appstore") + ".apk", true) // .setFilePath(PathUtils.getExternalDownloadsPath() + "/jgy/" + EncryptUtils.encryptMD5ToString("com.jiaoguanyi.appstore") + ".apk", true)
.setExtendField(packageObj.toJSONString()) // .setExtendField(packageObj.toJSONString())
.create(); //启动下载} // .create(); //启动下载}
Utils.ariaDownload(this, forceDownloadData.getApp_url(), packageObj);
} else { } else {
Log.e("fht", "未上传应用"); Log.e("fht", "未上传应用");
} }
@@ -1043,11 +1046,12 @@ public class InitJpushServer extends Service {
e.printStackTrace(); e.printStackTrace();
} }
if (packageInfo == null || packageInfo.versionCode < versionCode) { if (packageInfo == null || packageInfo.versionCode < versionCode) {
Aria.download(this) // Aria.download(this)
.load(url) //读取下载地址 // .load(url) //读取下载地址
.setFilePath(PathUtils.getExternalDownloadsPath() + "/ygj/" + EncryptUtils.encryptMD5ToString(packageName) + ".apk", true) // .setFilePath(PathUtils.getExternalDownloadsPath() + "/jgy/" + EncryptUtils.encryptMD5ToString(packageName) + ".apk", true)
.setExtendField(object.toJSONString()) // .setExtendField(object.toJSONString())
.create(); //启动下载} // .create(); //启动下载}
Utils.ariaDownload(this, url, object);
} else { } else {
Log.e("fht", "无需更新"); Log.e("fht", "无需更新");
} }

View File

@@ -39,6 +39,10 @@ import android.view.inputmethod.InputMethodManager;
import android.widget.EditText; import android.widget.EditText;
import android.widget.Toast; import android.widget.Toast;
import com.alibaba.fastjson.JSONObject;
import com.arialyy.aria.core.Aria;
import com.blankj.utilcode.util.EncryptUtils;
import com.blankj.utilcode.util.PathUtils;
import com.google.zxing.BarcodeFormat; import com.google.zxing.BarcodeFormat;
import com.google.zxing.EncodeHintType; import com.google.zxing.EncodeHintType;
import com.google.zxing.WriterException; import com.google.zxing.WriterException;
@@ -969,4 +973,26 @@ public class Utils {
context.startActivity(iReboot); context.startActivity(iReboot);
} }
private static String getFileNamefromURL(String url) {
int position = url.lastIndexOf("/");
return url.substring(position + 1);
}
private String getMD5fromFileName(String fileName) {
int position = fileName.lastIndexOf("/");
return fileName.substring(position + 9);
}
public static void ariaDownload(Context context, String url, JSONObject jsonObject) {
String fileName = getFileNamefromURL(url);
Aria.download(context)
.load(url) //读取下载地址
.setFilePath(PathUtils.getExternalDownloadsPath() + "/jgy/" + fileName, true)
.setExtendField(jsonObject.toJSONString())
.create(); //启动下载}
// SaveListUtils.addDownLoadList(app_package);
// }
}
} }