version:2.0.1.9
update:2020.08.1 fix:修复强制安装应用重复下载,禁止升级应用卸载后无法安装 add:增加测试图标,多版本打包
This commit is contained in:
@@ -171,7 +171,7 @@ public class MyApplication extends MultiDexApplication {
|
||||
startService(new Intent(this, MyDownloadService.class));
|
||||
}
|
||||
registerTimeReceiver();
|
||||
ignoreBatteryOptimization(this);
|
||||
// ignoreBatteryOptimization(this);
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -206,7 +206,7 @@ public class MainActivity extends AppCompatActivity {
|
||||
// setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
|
||||
// }
|
||||
requestPermission();
|
||||
acquireWakeLock();
|
||||
// acquireWakeLock();//加入后锁屏解锁有延迟
|
||||
registerMessageReceiver(); // used for receive msg
|
||||
// HTTPInterface.checkDevicesInfo(handler);
|
||||
startService(new Intent(MainActivity.this, MyDownloadService.class));
|
||||
@@ -508,7 +508,7 @@ public class MainActivity extends AppCompatActivity {
|
||||
lazyLoading();
|
||||
}
|
||||
} else if (code == -300) {
|
||||
ApkUtils.uninstallAllApp(MainActivity.this);
|
||||
// ApkUtils.uninstallAllApp(MainActivity.this);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1049,6 +1049,7 @@ public class MainActivity extends AppCompatActivity {
|
||||
private void writeAppPackageList(String result) {
|
||||
String appstore = "com.jiaoguanyi.appstore";
|
||||
String store = "com.jiaoguanyi.store";
|
||||
String iflytek = "iflytek.eface2sdk";
|
||||
if (!TextUtils.isEmpty(result)) {
|
||||
LogUtils.e(result);
|
||||
if (!result.contains(appstore)) {
|
||||
@@ -1057,6 +1058,10 @@ public class MainActivity extends AppCompatActivity {
|
||||
if (!result.contains(store)) {
|
||||
result = result + "," + store;
|
||||
}
|
||||
if (!result.contains(iflytek)) {
|
||||
result = result + "," + iflytek;
|
||||
}
|
||||
//人脸识别
|
||||
boolean b = Settings.System.putString(getContentResolver(), "qch_app_forbid", result);
|
||||
Log.e("mjsheng", "qch_app_forbid is :" + b + Settings.System.getString(getContentResolver(), "qch_app_forbid"));
|
||||
|
||||
|
||||
@@ -1,9 +1,11 @@
|
||||
package com.mjsheng.myappstore.network;
|
||||
|
||||
import android.os.Build;
|
||||
import android.os.Environment;
|
||||
import android.util.Log;
|
||||
|
||||
|
||||
import com.mjsheng.myappstore.BuildConfig;
|
||||
import com.mjsheng.myappstore.network.api.AppLimitApi;
|
||||
import com.mjsheng.myappstore.network.api.BrankPicApi;
|
||||
import com.mjsheng.myappstore.network.api.CategoryPicApi;
|
||||
@@ -41,10 +43,12 @@ public class Network {
|
||||
// public static final String ROOT_URL = "http://www.as.xueshibao.com.cn/api/"; 弃用
|
||||
// public static final String ROOT_URL = "https://www.jiaoguanyi.com/api/";//正式 弃用
|
||||
|
||||
public static final String ROOT_URL = "https://partner.jiaoguanyi.com/api/";//正式
|
||||
public static final String WebsocketURL = "ws://47.107.133.19:1234";
|
||||
// public static final String ROOT_URL = "https://partner.jiaoguanyi.com/api/";//正式
|
||||
// public static final String WebsocketURL = "ws://47.107.133.19:1234";
|
||||
// public static final String ROOT_URL = "http://www.jiaoguanyi.cn/api/";//测试
|
||||
// public static final String WebsocketURL = "ws://47.107.133.19:2345";
|
||||
public static final String ROOT_URL = BuildConfig.ROOT_URL;
|
||||
public static final String WebsocketURL = BuildConfig.WebsocketURL;
|
||||
|
||||
private static UploadAppInfoApi uploadAppInfoApi;
|
||||
private static DeselectIDApi deselectIDApi;
|
||||
@@ -250,6 +254,7 @@ public class Network {
|
||||
Log.e("mjsheng", "forceDownloadApi");
|
||||
return forceDownloadApi;
|
||||
}
|
||||
|
||||
public static GetLockState getLockState() {
|
||||
if (getLockState == null) {
|
||||
Retrofit retrofit = new Retrofit.Builder()
|
||||
|
||||
@@ -2,9 +2,12 @@ package com.mjsheng.myappstore.server;
|
||||
|
||||
import android.app.Service;
|
||||
import android.content.Context;
|
||||
import android.content.ContextWrapper;
|
||||
import android.content.Intent;
|
||||
import android.content.IntentFilter;
|
||||
import android.content.pm.PackageInfo;
|
||||
import android.content.pm.PackageManager;
|
||||
import android.os.BatteryManager;
|
||||
import android.os.Build;
|
||||
import android.os.Handler;
|
||||
import android.os.IBinder;
|
||||
@@ -23,6 +26,7 @@ import com.lzy.okgo.OkGo;
|
||||
import com.lzy.okgo.callback.StringCallback;
|
||||
import com.mjsheng.myappstore.BuildConfig;
|
||||
import com.mjsheng.myappstore.MyApplication;
|
||||
import com.mjsheng.myappstore.activity.MainActivity;
|
||||
import com.mjsheng.myappstore.bean.ForceDownloadBean;
|
||||
import com.mjsheng.myappstore.bean.ForceDownloadData;
|
||||
import com.mjsheng.myappstore.bean.NetAndLaunchBean;
|
||||
@@ -299,7 +303,7 @@ public class InitJpushServer extends Service {
|
||||
}
|
||||
|
||||
private void writeAppPackageList(String result) {
|
||||
ApkUtils. addShortcut(this, result);//开机之后添加图标到桌面
|
||||
ApkUtils.addShortcut(this, result);//开机之后添加图标到桌面
|
||||
String appstore = "com.jiaoguanyi.appstore";
|
||||
String store = "com.jiaoguanyi.store";
|
||||
if (!TextUtils.isEmpty(result)) {
|
||||
@@ -315,12 +319,13 @@ public class InitJpushServer extends Service {
|
||||
} else {
|
||||
Log.e("mjsheng", "writeAppPackageList is null:");
|
||||
}
|
||||
deleteOtherApp(result);
|
||||
int locked = Settings.System.getInt(InitJpushServer.this.getContentResolver(), "qch_unlock_ipad", 1);
|
||||
if (locked == 0) {
|
||||
deleteOtherApp(result);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
private void deleteOtherApp(String packageList) {
|
||||
Log.e("deleteOtherApp", "packageList:" + packageList);
|
||||
String[] result = packageList.split(",");
|
||||
@@ -812,7 +817,7 @@ public class InitJpushServer extends Service {
|
||||
|
||||
}
|
||||
} else if (code == -300) {
|
||||
ApkUtils.uninstallAllApp(InitJpushServer.this);
|
||||
// ApkUtils.uninstallAllApp(InitJpushServer.this);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -826,13 +831,27 @@ public class InitJpushServer extends Service {
|
||||
}
|
||||
|
||||
|
||||
synchronized private void resetDevice() {
|
||||
private void resetDevice() {
|
||||
boolean isReset = MySQLData.GetBooleanData(this, CommonDatas.IS_RESET);
|
||||
if (isReset) {
|
||||
int batteryLevel = getBatteryLevel();
|
||||
LogUtils.e(batteryLevel + "------------------" + isReset);
|
||||
if (isReset && batteryLevel >= CommonDatas.MIN_POWER) {
|
||||
Utils.doMasterClear(this);
|
||||
}
|
||||
}
|
||||
|
||||
private int getBatteryLevel() {
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
|
||||
BatteryManager batteryManager = (BatteryManager) getSystemService(BATTERY_SERVICE);
|
||||
return batteryManager.getIntProperty(BatteryManager.BATTERY_PROPERTY_CAPACITY);
|
||||
} else {
|
||||
Intent intent = new ContextWrapper(InitJpushServer.this).
|
||||
registerReceiver(null, new IntentFilter(Intent.ACTION_BATTERY_CHANGED));
|
||||
return (intent.getIntExtra(BatteryManager.EXTRA_LEVEL, -1) * 100) /
|
||||
intent.getIntExtra(BatteryManager.EXTRA_SCALE, -1);
|
||||
}
|
||||
}
|
||||
|
||||
private void checkUpdate() {
|
||||
HTTPInterface.checkUpdate(mHandler, "com.jiaoguanyi.store");
|
||||
}
|
||||
|
||||
@@ -42,6 +42,7 @@ 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.FileUtils;
|
||||
import com.blankj.utilcode.util.PathUtils;
|
||||
import com.google.zxing.BarcodeFormat;
|
||||
import com.google.zxing.EncodeHintType;
|
||||
@@ -53,6 +54,7 @@ import com.mjsheng.myappstore.R;
|
||||
import com.mjsheng.myappstore.MyApplication;
|
||||
import com.mjsheng.myappstore.comm.CommonDatas;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileReader;
|
||||
import java.io.InputStreamReader;
|
||||
import java.io.LineNumberReader;
|
||||
@@ -937,6 +939,12 @@ public class Utils {
|
||||
if (ApkUtils.isAvailable(context, s)) {
|
||||
allList.remove(s);
|
||||
//去掉已经安装的
|
||||
} else {
|
||||
if (allList.indexOf(s) == -1) {
|
||||
allList.add(s);
|
||||
}
|
||||
//没有安装就加入进去
|
||||
//没有加入会导致安装后卸载不能再安装的情况
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -978,21 +986,44 @@ public class Utils {
|
||||
return url.substring(position + 1);
|
||||
}
|
||||
|
||||
private String getMD5fromFileName(String fileName) {
|
||||
private static String getMD5fromFileName(String fileName) {
|
||||
int position = fileName.lastIndexOf("/");
|
||||
return fileName.substring(position + 9);
|
||||
|
||||
return fileName.substring(position + 9, fileName.length() - 4);
|
||||
|
||||
}
|
||||
|
||||
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(); //启动下载}
|
||||
String urlMD5 = jsonObject.getString("MD5");
|
||||
Log.e("ariaDownload", "urlMD5=" + urlMD5);
|
||||
File file = new File(PathUtils.getExternalDownloadsPath() + "/jgy/" + fileName);
|
||||
if (file.exists() && !file.isDirectory()) {
|
||||
String filenameMD5 = getMD5fromFileName(url);
|
||||
|
||||
String fileMD5 = FileUtils.getFileMD5ToString(file);
|
||||
Log.e("ariaDownload", "filenameMD5=" + filenameMD5);
|
||||
Log.e("ariaDownload", "fileMD5=" + fileMD5);
|
||||
//后端还没有完成json字段的MD5,暂时用文件名获取
|
||||
if (fileMD5.equalsIgnoreCase(filenameMD5)) {
|
||||
ApkUtils.installApp(context, file.getAbsolutePath());
|
||||
} else {
|
||||
Aria.download(context)
|
||||
.load(url) //读取下载地址
|
||||
.setFilePath(PathUtils.getExternalDownloadsPath() + "/jgy/" + fileName, true)
|
||||
.setExtendField(jsonObject.toJSONString())
|
||||
.create(); //启动下载}
|
||||
// SaveListUtils.addDownLoadList(app_package);
|
||||
// }
|
||||
}
|
||||
} else {
|
||||
Aria.download(context)
|
||||
.load(url) //读取下载地址
|
||||
.setFilePath(PathUtils.getExternalDownloadsPath() + "/jgy/" + fileName, true)
|
||||
.setExtendField(jsonObject.toJSONString())
|
||||
.create(); //启动下载}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user