update
This commit is contained in:
@@ -306,66 +306,66 @@ public class MyApplication extends MultiDexApplication implements Thread.Uncaugh
|
||||
NetStateChangeReceiver.unregisterReceiver(this);
|
||||
}
|
||||
|
||||
static List<FileData> fileList = new ArrayList<>();
|
||||
|
||||
|
||||
static String packageName = "";
|
||||
|
||||
public void setInstallIngPackageName(String packageNames) {
|
||||
packageName = packageNames;
|
||||
Log.e("fht", "正在安装:" + packageNames);
|
||||
}
|
||||
|
||||
public String getInstallIngPackageName() {
|
||||
return packageName;
|
||||
}
|
||||
|
||||
public void addFileData(FileData data) {
|
||||
fileList.add(data);
|
||||
updateList();
|
||||
}
|
||||
|
||||
public void removeDate(String packageName) {
|
||||
if (fileList != null && fileList.size() > 0) {
|
||||
for (FileData data : fileList) {
|
||||
if (data.getPackageName().equals(packageName)) {
|
||||
fileList.remove(data);
|
||||
break;
|
||||
} else {
|
||||
Log.e("fht", "not found object");
|
||||
}
|
||||
}
|
||||
}
|
||||
setInstallIngPackageName("");
|
||||
if (fileList.size() > 0) {
|
||||
updateList();
|
||||
} else {
|
||||
Log.e("fht", "fileList为空");
|
||||
setInstallIngPackageName("");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public void updateList() {
|
||||
if (getInstallIngPackageName().equals("") || ApkUtils.isAvailable(getAppContext(), packageName)) {
|
||||
if (fileList != null && fileList.size() > 0) {
|
||||
if (!fileList.get(0).getPackageName().equals("") || ApkUtils.isAvailable(getAppContext(), fileList.get(0).getPackageName())) {
|
||||
String s = packageName;
|
||||
ApkUtils.installApp(this, fileList.get(0).getFilePath());
|
||||
setInstallIngPackageName(fileList.get(0).getPackageName());
|
||||
} else {
|
||||
removeDate(fileList.get(0).getPackageName());
|
||||
Log.e("fht", "已安装");
|
||||
setInstallIngPackageName("");
|
||||
}
|
||||
} else {
|
||||
Log.e("fht", "任务为空");
|
||||
}
|
||||
} else {
|
||||
Log.e("fht", "安装中:" + packageName);
|
||||
|
||||
}
|
||||
}
|
||||
// static List<FileData> fileList = new ArrayList<>();
|
||||
//
|
||||
//
|
||||
// static String packageName = "";
|
||||
//
|
||||
// public void setInstallIngPackageName(String packageNames) {
|
||||
// packageName = packageNames;
|
||||
// Log.e("fht", "正在安装:" + packageNames);
|
||||
// }
|
||||
//
|
||||
// public String getInstallIngPackageName() {
|
||||
// return packageName;
|
||||
// }
|
||||
//
|
||||
// public void addFileData(FileData data) {
|
||||
// fileList.add(data);
|
||||
// updateList();
|
||||
// }
|
||||
//
|
||||
// public void removeDate(String packageName) {
|
||||
// if (fileList != null && fileList.size() > 0) {
|
||||
// for (FileData data : fileList) {
|
||||
// if (data.getPackageName().equals(packageName)) {
|
||||
// fileList.remove(data);
|
||||
// break;
|
||||
// } else {
|
||||
// Log.e("fht", "not found object");
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// setInstallIngPackageName("");
|
||||
// if (fileList.size() > 0) {
|
||||
// updateList();
|
||||
// } else {
|
||||
// Log.e("fht", "fileList为空");
|
||||
// setInstallIngPackageName("");
|
||||
// }
|
||||
//
|
||||
// }
|
||||
//
|
||||
// public void updateList() {
|
||||
// if (getInstallIngPackageName().equals("") || ApkUtils.isAvailable(getAppContext(), packageName)) {
|
||||
// if (fileList != null && fileList.size() > 0) {
|
||||
// if (!fileList.get(0).getPackageName().equals("") || ApkUtils.isAvailable(getAppContext(), fileList.get(0).getPackageName())) {
|
||||
// String s = packageName;
|
||||
// ApkUtils.installApp(this, fileList.get(0).getFilePath());
|
||||
// setInstallIngPackageName(fileList.get(0).getPackageName());
|
||||
// } else {
|
||||
// removeDate(fileList.get(0).getPackageName());
|
||||
// Log.e("fht", "已安装");
|
||||
// setInstallIngPackageName("");
|
||||
// }
|
||||
// } else {
|
||||
// Log.e("fht", "任务为空");
|
||||
// }
|
||||
// } else {
|
||||
// Log.e("fht", "安装中:" + packageName);
|
||||
//
|
||||
// }
|
||||
// }
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -160,7 +160,7 @@ public class MainActivity extends AppCompatActivity implements NetStateChangeObs
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.activity_main);
|
||||
|
||||
Aria.download(this).removeAllTask(false);
|
||||
// Aria.download(this).removeAllTask(false);
|
||||
|
||||
callback = new ToastCallback(this);
|
||||
initView();
|
||||
@@ -173,7 +173,19 @@ public class MainActivity extends AppCompatActivity implements NetStateChangeObs
|
||||
sendBroadcast(allIntent);
|
||||
|
||||
}
|
||||
|
||||
//获取教管易版本号
|
||||
synchronized private String getAPPVersionName() {
|
||||
PackageManager pm = getPackageManager();
|
||||
String versionName;
|
||||
try {
|
||||
PackageInfo packageInfo = pm.getPackageInfo("com.jiaoguanyi.store", 0);
|
||||
versionName = packageInfo.versionName;
|
||||
} catch (PackageManager.NameNotFoundException e) {
|
||||
e.printStackTrace();
|
||||
versionName = "0";
|
||||
}
|
||||
return versionName;
|
||||
}
|
||||
|
||||
synchronized public void sendMACaddress() {
|
||||
String rid = JPushInterface.getRegistrationID(getApplicationContext());
|
||||
@@ -181,8 +193,9 @@ public class MainActivity extends AppCompatActivity implements NetStateChangeObs
|
||||
.params("sn", Utils.getSerial())
|
||||
.params("mac", com.blankj.utilcode.util.DeviceUtils.getMacAddress())
|
||||
.params("jpush_id", rid)
|
||||
.params("appstore_version", Utils.getProperty("ro.custom.build.version", "获取失败"))
|
||||
.params("store_version", BuildConfig.VERSION_NAME)
|
||||
.params("devices_version", Utils.getProperty("ro.custom.build.version", "获取失败"))
|
||||
.params("appstore_version", BuildConfig.VERSION_NAME)//设备信息版本号
|
||||
.params("store_version", getAPPVersionName())//管教易版本号
|
||||
.execute(new StringCallback() {
|
||||
@Override
|
||||
public void onSuccess(String s, Call call, Response response) {
|
||||
@@ -404,7 +417,7 @@ public class MainActivity extends AppCompatActivity implements NetStateChangeObs
|
||||
getSystemSetting();//设置系统管控
|
||||
getNetAndLaunchSetting();//联网管控
|
||||
Aria.download(this).resumeAllTask();
|
||||
getForceDownload();//强制下载apk
|
||||
// getForceDownload();//强制下载apk
|
||||
resetDevice();//恢复出厂设置
|
||||
checkUpdate();//更新app
|
||||
// fromNetToUpdate();
|
||||
|
||||
@@ -7,6 +7,7 @@ import android.util.Log;
|
||||
|
||||
import com.mjsheng.myappstore.server.GuardService;
|
||||
import com.mjsheng.myappstore.server.InitJpushServer;
|
||||
import com.mjsheng.myappstore.server.MyDownloadService;
|
||||
import com.mjsheng.myappstore.server.StepService;
|
||||
|
||||
public class BootReceiver extends BroadcastReceiver {
|
||||
@@ -16,10 +17,27 @@ public class BootReceiver extends BroadcastReceiver {
|
||||
public void onReceive(Context context, Intent intent) {
|
||||
Log.e("BootReceiver", intent.getAction());
|
||||
if (intent.getAction().equals("android.intent.action.BOOT_COMPLETED")) {
|
||||
Intent i = new Intent(context, InitJpushServer.class);
|
||||
context.startService(i);
|
||||
context.startService(new Intent(context, InitJpushServer.class));
|
||||
context.startService(new Intent(context, StepService.class));
|
||||
context.startService(new Intent(context, GuardService.class));
|
||||
context.startService(new Intent(context, MyDownloadService.class));
|
||||
} else if (
|
||||
intent.getAction().equals("android.intent.action.BATTERY_CHANGED")
|
||||
|| intent.getAction().equals("android.intent.action.BATTERY_CHANGED")
|
||||
|| intent.getAction().equals("android.intent.action.BATTERY_LOW")
|
||||
|| intent.getAction().equals("android.intent.action.BATTERY_OKAY")
|
||||
|| intent.getAction().equals("android.intent.action.ACTION_POWER_CONNECTED")
|
||||
|| intent.getAction().equals("android.intent.action.DATE_CHANGED")
|
||||
|| intent.getAction().equals("android.intent.action.TIME_TICK")
|
||||
|| intent.getAction().equals("android.intent.action.USER_PRESENT")
|
||||
|| intent.getAction().equals("android.intent.action.ACTION_SCREEN_ON")
|
||||
|| intent.getAction().equals("android.intent.action.ACTION_SCREEN_OFF")
|
||||
) {
|
||||
Log.e("fht", "BootReceiver MSG" + intent.getAction());
|
||||
context.startService(new Intent(context, InitJpushServer.class));
|
||||
context.startService(new Intent(context, StepService.class));
|
||||
context.startService(new Intent(context, GuardService.class));
|
||||
context.startService(new Intent(context, MyDownloadService.class));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -46,20 +46,20 @@ public class NewAppReceiver extends BroadcastReceiver {
|
||||
allIntent.setAction(Utils.DOWNLOAD_ALLTASK_ACTION);
|
||||
context.sendBroadcast(allIntent);
|
||||
String packageName = intent.getDataString().replace("package:", "");
|
||||
MyApplication.getInstance().removeDate(packageName);
|
||||
// MyApplication.getInstance().removeDate(packageName);
|
||||
Log.e(TAG, "安装了:" + packageName + "包名的程序");
|
||||
Log.e("fht", "安装了:" + packageName + "包名的程序");
|
||||
OkGo.post(Configure.HTTP_TAG_DOWNLOAD_URL)
|
||||
.params("key", Configure.HTTP_KEY)
|
||||
.params("sn", Utils.getSerial())
|
||||
.params("package", packageName)
|
||||
.tag(this)
|
||||
.execute(new StringCallback() {
|
||||
@Override
|
||||
public void onSuccess(String s, Call call, Response response) {
|
||||
|
||||
}
|
||||
});
|
||||
// OkGo.post(Configure.HTTP_TAG_DOWNLOAD_URL)
|
||||
// .params("key", Configure.HTTP_KEY)
|
||||
// .params("sn", Utils.getSerial())
|
||||
// .params("package", packageName)
|
||||
// .tag(this)
|
||||
// .execute(new StringCallback() {
|
||||
// @Override
|
||||
// public void onSuccess(String s, Call call, Response response) {
|
||||
//
|
||||
// }
|
||||
// });
|
||||
SaveListUtils.getDownLoadList().remove(packageName);//移除下载列表
|
||||
// ToastTool.show("安装成功");
|
||||
if (!packageName.equals(Utils.YOUNGSYSTEM_APP_TONGBU) && !packageName.equals(context.getPackageName())) {
|
||||
|
||||
@@ -83,14 +83,14 @@ public class GuardService extends Service {
|
||||
//在这里处理任务执行中的状态,如进度进度条的刷新
|
||||
@Download.onTaskRunning
|
||||
protected void running(com.arialyy.aria.core.download.DownloadTask task) {
|
||||
Log.e("mjsheng", "正在下载=--------------::" + task.getState() + "-------" + task.getPercent() + "-------" + task.getExtendField());
|
||||
Log.e("info", "正在下载=--------------::" + task.getState() + "-------" + task.getPercent() + "-------" + task.getExtendField());
|
||||
ToastUtils.showShort("正在下载=--------------::" + task.getExtendField() + "-------" + task.getPercent());
|
||||
}
|
||||
|
||||
@Download.onTaskComplete
|
||||
void taskComplete(com.arialyy.aria.core.download.DownloadTask task) {
|
||||
//在这里处理任务完成的状态
|
||||
String filepath = task.getDownloadPath();
|
||||
final String filepath = task.getDownloadPath();
|
||||
final String packageName = task.getExtendField();
|
||||
Log.e("mjsheng", "downloadPath::" + filepath);
|
||||
Log.e("mjsheng", "extendField::" + packageName);
|
||||
@@ -100,7 +100,12 @@ public class GuardService extends Service {
|
||||
s1 = s + "," + packageName;
|
||||
Settings.System.putString(getContentResolver(), "qch_app_forbid", s1);
|
||||
}
|
||||
ApkUtils.installApp(GuardService.this, filepath);
|
||||
new Thread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
ApkUtils.installApp(GuardService.this, filepath);
|
||||
}
|
||||
}).start();
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -93,6 +93,7 @@ public class InitJpushServer extends Service {
|
||||
|
||||
return super.onStartCommand(intent, flags, startId);
|
||||
}
|
||||
|
||||
private void setJpushTags() {
|
||||
OkGo.get(Configure.GET_DEVICES_TAGS)
|
||||
.params("sn", Utils.getSerial())
|
||||
@@ -352,7 +353,7 @@ public class InitJpushServer extends Service {
|
||||
result = result + "," + appstore;
|
||||
}
|
||||
if (!result.contains(store)) {
|
||||
result = result + ","+ store;
|
||||
result = result + "," + store;
|
||||
}
|
||||
Settings.System.putString(getContentResolver(), "qch_app_forbid", result);
|
||||
} else {
|
||||
@@ -652,6 +653,20 @@ public class InitJpushServer extends Service {
|
||||
});
|
||||
}
|
||||
|
||||
//获取教管易版本号
|
||||
synchronized private String getAPPVersionName() {
|
||||
PackageManager pm = getPackageManager();
|
||||
String versionName;
|
||||
try {
|
||||
PackageInfo packageInfo = pm.getPackageInfo("com.jiaoguanyi.store", 0);
|
||||
versionName = packageInfo.versionName;
|
||||
} catch (PackageManager.NameNotFoundException e) {
|
||||
e.printStackTrace();
|
||||
versionName = "0";
|
||||
}
|
||||
return versionName;
|
||||
}
|
||||
|
||||
synchronized public void sendMACaddress() {
|
||||
String rid = JPushInterface.getRegistrationID(getApplicationContext());
|
||||
|
||||
@@ -659,19 +674,20 @@ public class InitJpushServer extends Service {
|
||||
.params("sn", Utils.getSerial())
|
||||
.params("mac", com.blankj.utilcode.util.DeviceUtils.getMacAddress())
|
||||
.params("jpush_id", rid)
|
||||
.params("appstore_version", Utils.getProperty("ro.custom.build.version","获取失败"))
|
||||
.params("store_version", BuildConfig.VERSION_NAME)
|
||||
.params("devices_version", Utils.getProperty("ro.custom.build.version", "获取失败"))
|
||||
.params("appstore_version", BuildConfig.VERSION_NAME)//设备信息版本号
|
||||
.params("store_version", getAPPVersionName())//管教易版本号
|
||||
.execute(new StringCallback() {
|
||||
@Override
|
||||
public void onSuccess(String s, Call call, Response response) {
|
||||
com.alibaba.fastjson.JSONObject msgObject = JSON.parseObject(s);
|
||||
Log.e("fht", "sendMACaddress onSuccess"+s);
|
||||
Log.e("fht", "sendMACaddress onSuccess" + s);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(Call call, Response response, Exception e) {
|
||||
super.onError(call, response, e);
|
||||
Log.e("fht", "sendMACaddress onError:"+e.getMessage());
|
||||
Log.e("fht", "sendMACaddress onError:" + e.getMessage());
|
||||
}
|
||||
});
|
||||
{
|
||||
@@ -714,7 +730,7 @@ public class InitJpushServer extends Service {
|
||||
getDeselectBrowerID();
|
||||
getNetAndLaunchSetting();
|
||||
Aria.download(this).resumeAllTask();
|
||||
getForceDownload();
|
||||
// getForceDownload();
|
||||
getSystemSetting();//从后台获取功能状态
|
||||
resetDevice();
|
||||
checkUpdate();
|
||||
@@ -949,7 +965,7 @@ public class InitJpushServer extends Service {
|
||||
if (packageInfo == null || packageInfo.versionCode != versionCode) {
|
||||
Aria.download(this)
|
||||
.load(url) //读取下载地址
|
||||
.setFilePath(PathUtils.getExternalDownloadsPath() + "/ygj/" + EncryptUtils.encryptMD5ToString(packageName) + ".apk",true)
|
||||
.setFilePath(PathUtils.getExternalDownloadsPath() + "/ygj/" + EncryptUtils.encryptMD5ToString(packageName) + ".apk", true)
|
||||
.setExtendField(packageName)
|
||||
.start(); //启动下载}
|
||||
} else {
|
||||
|
||||
@@ -67,17 +67,17 @@ public class StepService extends Service {
|
||||
public int onStartCommand(Intent intent, int flags, int startId) {
|
||||
// startForeground(1, new Notification());
|
||||
// 绑定建立链接
|
||||
try {
|
||||
final String filePath = intent.getStringExtra("filePath");
|
||||
final String packageName = intent.getStringExtra("packageName");
|
||||
Log.e("fht", filePath);
|
||||
Log.e("fht", packageName);
|
||||
FileData fileData = new FileData(filePath, packageName);
|
||||
MyApplication.getInstance().addFileData(fileData);
|
||||
|
||||
} catch (Exception e) {
|
||||
Log.e("fht", e.getMessage());
|
||||
}
|
||||
// try {
|
||||
// final String filePath = intent.getStringExtra("filePath");
|
||||
// final String packageName = intent.getStringExtra("packageName");
|
||||
// Log.e("fht", filePath);
|
||||
// Log.e("fht", packageName);
|
||||
// FileData fileData = new FileData(filePath, packageName);
|
||||
// MyApplication.getInstance().addFileData(fileData);
|
||||
//
|
||||
// } catch (Exception e) {
|
||||
// Log.e("fht", e.getMessage());
|
||||
// }
|
||||
|
||||
bindService(new Intent(this, GuardService.class), mServiceConnection, Context.BIND_IMPORTANT);
|
||||
return START_STICKY;
|
||||
|
||||
Reference in New Issue
Block a user