version:
update:2021.03.31 fix:修复推送没有自启,开机动画后台对接 add:
This commit is contained in:
@@ -9,11 +9,11 @@ def releaseTime() {
|
||||
}
|
||||
|
||||
android {
|
||||
compileSdkVersion 30
|
||||
compileSdkVersion 29
|
||||
defaultConfig {
|
||||
applicationId "com.jiaoguanyi.appstore"
|
||||
minSdkVersion 20
|
||||
targetSdkVersion 30
|
||||
targetSdkVersion 29
|
||||
|
||||
// versionCode 105
|
||||
// versionName "3.1.0"//测试jiaoguanyi.cn
|
||||
@@ -105,8 +105,8 @@ android {
|
||||
|
||||
newl {
|
||||
flavorDimensions "default"
|
||||
versionCode 167
|
||||
// versionCode 1031
|
||||
// versionCode 167
|
||||
versionCode 1033
|
||||
versionName "1.2.7"
|
||||
/*********************************极光推送************************************/
|
||||
manifestPlaceholders = [
|
||||
|
||||
@@ -324,6 +324,11 @@ public class MainActivity extends BaseActivity implements MainContact.MainView {
|
||||
|
||||
@Override
|
||||
public void setSystemSettingFinished() {
|
||||
mPresenter.setLogoImg();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setLogoImgFinished() {
|
||||
netWorkIsRunning = false;
|
||||
Log.e(TAG, "SettingFinished: " + (System.currentTimeMillis() - timeMillis) + " ms");
|
||||
}
|
||||
|
||||
@@ -59,6 +59,8 @@ public class MainContact {
|
||||
//获取第三方应用内部网页跳转屏蔽结束
|
||||
void setSystemSettingFinished();
|
||||
//获取系统其他管控设置结束
|
||||
void setLogoImgFinished ();
|
||||
//设置开机动画
|
||||
/*
|
||||
* MainService
|
||||
* */
|
||||
@@ -116,6 +118,8 @@ public class MainContact {
|
||||
//获取第三方应用内部网页跳转屏蔽
|
||||
void setSystemSetting();
|
||||
//获取系统其他管控设置
|
||||
void setLogoImg();
|
||||
//设置开机动画
|
||||
/*
|
||||
* MainService
|
||||
* */
|
||||
|
||||
@@ -25,7 +25,9 @@ import com.jiaoguanyi.appstore.bean.BaseResponse;
|
||||
import com.jiaoguanyi.appstore.bean.Batch;
|
||||
import com.jiaoguanyi.appstore.bean.BrowserBookmarks;
|
||||
import com.jiaoguanyi.appstore.bean.BrowserData;
|
||||
import com.jiaoguanyi.appstore.bean.Desktop;
|
||||
import com.jiaoguanyi.appstore.bean.ForceDownloadBean;
|
||||
import com.jiaoguanyi.appstore.bean.LogoImg;
|
||||
import com.jiaoguanyi.appstore.bean.NetAndLaunchBean;
|
||||
import com.jiaoguanyi.appstore.bean.StudentsInfo;
|
||||
import com.jiaoguanyi.appstore.jpush.TagAliasOperatorHelper;
|
||||
@@ -1075,6 +1077,49 @@ public class MainPresenter implements MainContact.Presenter {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setLogoImg() {
|
||||
NetInterfaceManager.getInstance()
|
||||
.getLogoImgObservable()
|
||||
.subscribe(new Observer<BaseResponse<LogoImg>>() {
|
||||
@Override
|
||||
public void onSubscribe(@NonNull Disposable d) {
|
||||
Log.e("setLogoImg", "onSubscribe: ");
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNext(@NonNull BaseResponse<LogoImg> logoImgBaseResponse) {
|
||||
Log.e("setLogoImg", "onNext: ");
|
||||
if (logoImgBaseResponse.code == 200) {
|
||||
LogoImg logoImg = logoImgBaseResponse.data;
|
||||
String file_url = logoImg.getFile_url();
|
||||
String file_md5 = logoImg.getFile_md5();
|
||||
String batch = logoImg.getBatch();
|
||||
if (TextUtils.isEmpty(file_url)) {
|
||||
Log.e("setLogoImg", "onNext: file_url is empty");
|
||||
} else {
|
||||
JGYUtils.getInstance().checkBootFile(file_url, file_md5);
|
||||
}
|
||||
} else {
|
||||
Log.e("setLogoImg", "onNext: ");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(@NonNull Throwable e) {
|
||||
onComplete();
|
||||
Log.e("setLogoImg", "onError: ");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onComplete() {
|
||||
Log.e("setLogoImg", "onComplete: ");
|
||||
mView.setLogoImgFinished();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getScreenLockState() {
|
||||
String channel_value = JGYUtils.getInstance().getStringMetaData();
|
||||
@@ -1127,21 +1172,27 @@ public class MainPresenter implements MainContact.Presenter {
|
||||
}
|
||||
NetInterfaceManager.getInstance()
|
||||
.getDesktopObservable()
|
||||
.subscribe(new Observer<BaseResponse>() {
|
||||
.subscribe(new Observer<ResponseBody>() {
|
||||
|
||||
|
||||
@Override
|
||||
public void onSubscribe(@NonNull Disposable d) {
|
||||
Log.e("getDefaultDesktop", "onSubscribe: ");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNext(@NonNull BaseResponse response) {
|
||||
public void onNext(@NonNull ResponseBody responseBody) {
|
||||
Log.e("getDefaultDesktop", "onNext: ");
|
||||
if (response.code == 200) {
|
||||
JSONObject jsonObject = JSONObject.parseObject(response.data.toString());
|
||||
JGYUtils.getInstance().installDesktop(jsonObject);
|
||||
} else {
|
||||
Log.e("getDefaultDesktop", "onNext: " + response);
|
||||
try {
|
||||
JSONObject jsonObject = JSONObject.parseObject(responseBody.string());
|
||||
JSONObject data = jsonObject.getJSONObject("data");
|
||||
JGYUtils.getInstance().installDesktop(data);
|
||||
Log.e("getDefaultDesktop", "onNext: " + data.toJSONString());
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
Log.e("getDefaultDesktop", "onNext: IOException: " + e.getMessage());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
package com.jiaoguanyi.appstore.activity;
|
||||
|
||||
import android.app.StatusBarManager;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.os.Bundle;
|
||||
import android.os.Environment;
|
||||
|
||||
@@ -97,7 +97,7 @@ public class BaseApplication extends MultiDexApplication{
|
||||
@Override
|
||||
public void onCreate() {
|
||||
super.onCreate();
|
||||
if (SystemUtils.IsMainProcessName(this, Process.myPid())) {
|
||||
if (SystemUtils.isMainProcessName(this, Process.myPid())) {
|
||||
//非主进程不初始化
|
||||
init();
|
||||
}
|
||||
|
||||
@@ -14,6 +14,7 @@ public class BaseResponse<T> implements Serializable {
|
||||
public String msg;
|
||||
public T data;
|
||||
|
||||
|
||||
@NonNull
|
||||
@Override
|
||||
public String toString() {
|
||||
|
||||
43
app/src/main/java/com/jiaoguanyi/appstore/bean/Desktop.java
Normal file
43
app/src/main/java/com/jiaoguanyi/appstore/bean/Desktop.java
Normal file
@@ -0,0 +1,43 @@
|
||||
package com.jiaoguanyi.appstore.bean;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
public class Desktop implements Serializable {
|
||||
private static final long serialVersionUID = 8747792657698028628L;
|
||||
private String app_name;
|
||||
private String app_url;
|
||||
private String app_package;
|
||||
private String app_version_code;
|
||||
|
||||
public String getApp_name() {
|
||||
return app_name;
|
||||
}
|
||||
|
||||
public void setApp_name(String app_name) {
|
||||
this.app_name = app_name;
|
||||
}
|
||||
|
||||
public String getApp_url() {
|
||||
return app_url;
|
||||
}
|
||||
|
||||
public void setApp_url(String app_url) {
|
||||
this.app_url = app_url;
|
||||
}
|
||||
|
||||
public String getApp_package() {
|
||||
return app_package;
|
||||
}
|
||||
|
||||
public void setApp_package(String app_package) {
|
||||
this.app_package = app_package;
|
||||
}
|
||||
|
||||
public String getApp_version_code() {
|
||||
return app_version_code;
|
||||
}
|
||||
|
||||
public void setApp_version_code(String app_version_code) {
|
||||
this.app_version_code = app_version_code;
|
||||
}
|
||||
}
|
||||
34
app/src/main/java/com/jiaoguanyi/appstore/bean/LogoImg.java
Normal file
34
app/src/main/java/com/jiaoguanyi/appstore/bean/LogoImg.java
Normal file
@@ -0,0 +1,34 @@
|
||||
package com.jiaoguanyi.appstore.bean;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
public class LogoImg implements Serializable {
|
||||
private static final long serialVersionUID = -225928093718933004L;
|
||||
private String file_url;
|
||||
private String file_md5;
|
||||
private String batch;
|
||||
|
||||
public String getFile_url() {
|
||||
return file_url;
|
||||
}
|
||||
|
||||
public void setFile_url(String file_url) {
|
||||
this.file_url = file_url;
|
||||
}
|
||||
|
||||
public String getFile_md5() {
|
||||
return file_md5;
|
||||
}
|
||||
|
||||
public void setFile_md5(String file_md5) {
|
||||
this.file_md5 = file_md5;
|
||||
}
|
||||
|
||||
public String getBatch() {
|
||||
return batch;
|
||||
}
|
||||
|
||||
public void setBatch(String batch) {
|
||||
this.batch = batch;
|
||||
}
|
||||
}
|
||||
@@ -8,7 +8,9 @@ import com.jiaoguanyi.appstore.bean.Appground;
|
||||
import com.jiaoguanyi.appstore.bean.BaseResponse;
|
||||
import com.jiaoguanyi.appstore.bean.BrowserBookmarks;
|
||||
import com.jiaoguanyi.appstore.bean.BrowserData;
|
||||
import com.jiaoguanyi.appstore.bean.Desktop;
|
||||
import com.jiaoguanyi.appstore.bean.ForceDownloadBean;
|
||||
import com.jiaoguanyi.appstore.bean.LogoImg;
|
||||
import com.jiaoguanyi.appstore.bean.NetAndLaunchBean;
|
||||
import com.jiaoguanyi.appstore.bean.StudentsInfo;
|
||||
import com.jiaoguanyi.appstore.network.api.AppLimitApi;
|
||||
@@ -33,6 +35,7 @@ import com.jiaoguanyi.appstore.network.api.newapi.GetBatchApi;
|
||||
import com.jiaoguanyi.appstore.network.api.newapi.GetDesktopApi;
|
||||
import com.jiaoguanyi.appstore.network.api.newapi.GetLockStateApi;
|
||||
import com.jiaoguanyi.appstore.network.api.newapi.JpushTagsApi;
|
||||
import com.jiaoguanyi.appstore.network.api.newapi.LogoImgApi;
|
||||
import com.jiaoguanyi.appstore.network.api.newapi.MACAddressApi;
|
||||
import com.jiaoguanyi.appstore.network.api.newapi.ScreenLockStateApi;
|
||||
import com.jiaoguanyi.appstore.network.api.newapi.SnTimeControl;
|
||||
@@ -270,7 +273,7 @@ public class NetInterfaceManager {
|
||||
.observeOn(AndroidSchedulers.mainThread());
|
||||
}
|
||||
|
||||
public Observable<BaseResponse> getDesktopObservable() {
|
||||
public Observable<ResponseBody> getDesktopObservable() {
|
||||
return mRetrofit
|
||||
.create(GetDesktopApi.class)
|
||||
.getDesktop(Utils.getSerial())
|
||||
@@ -286,6 +289,14 @@ public class NetInterfaceManager {
|
||||
.observeOn(AndroidSchedulers.mainThread());
|
||||
}
|
||||
|
||||
public Observable<BaseResponse<LogoImg>> getLogoImgObservable() {
|
||||
return mRetrofit
|
||||
.create(LogoImgApi.class)
|
||||
.getLogoImg(Utils.getSerial())
|
||||
.subscribeOn(Schedulers.io())
|
||||
.observeOn(AndroidSchedulers.mainThread());
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
*
|
||||
|
||||
@@ -52,4 +52,6 @@ public class URLAddress {
|
||||
//获取顶部app管控
|
||||
public final static String GET_SN_APP_TEST = HTTP_TAG_HEAD_NEW + "Sn/getSnAppTest";
|
||||
//获取测试app
|
||||
public final static String GET_LOGO_IMG = HTTP_TAG_HEAD_NEW + "Sn/getLogoImg";
|
||||
|
||||
}
|
||||
|
||||
@@ -1,15 +1,15 @@
|
||||
package com.jiaoguanyi.appstore.network.api.newapi;
|
||||
|
||||
import com.jiaoguanyi.appstore.bean.BaseResponse;
|
||||
import com.jiaoguanyi.appstore.network.URLAddress;
|
||||
|
||||
import io.reactivex.Observable;
|
||||
import okhttp3.ResponseBody;
|
||||
import retrofit2.http.GET;
|
||||
import retrofit2.http.Query;
|
||||
|
||||
public interface GetDesktopApi {
|
||||
@GET(URLAddress.GET_DESKTOP)
|
||||
Observable<BaseResponse> getDesktop(
|
||||
Observable<ResponseBody> getDesktop(
|
||||
@Query("sn") String sn
|
||||
);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,16 @@
|
||||
package com.jiaoguanyi.appstore.network.api.newapi;
|
||||
|
||||
import com.jiaoguanyi.appstore.bean.BaseResponse;
|
||||
import com.jiaoguanyi.appstore.bean.LogoImg;
|
||||
import com.jiaoguanyi.appstore.network.URLAddress;
|
||||
|
||||
import io.reactivex.Observable;
|
||||
import retrofit2.http.GET;
|
||||
import retrofit2.http.Query;
|
||||
|
||||
public interface LogoImgApi {
|
||||
@GET(URLAddress.GET_LOGO_IMG)
|
||||
Observable<BaseResponse<LogoImg>> getLogoImg(
|
||||
@Query("sn") String sn
|
||||
);
|
||||
}
|
||||
@@ -31,6 +31,7 @@ import com.arialyy.annotations.Download;
|
||||
import com.arialyy.aria.core.Aria;
|
||||
import com.arialyy.aria.core.download.DownloadEntity;
|
||||
import com.arialyy.aria.core.task.DownloadTask;
|
||||
import com.jiaoguanyi.appstore.utils.JGYUtils;
|
||||
import com.lzy.okgo.OkGo;
|
||||
import com.lzy.okgo.callback.StringCallback;
|
||||
import com.jiaoguanyi.appstore.KeepAliveConnection;
|
||||
@@ -284,61 +285,65 @@ public class GuardService extends Service {
|
||||
void taskComplete(DownloadTask task) {
|
||||
//在这里处理任务完成的状态
|
||||
final String filepath = task.getFilePath();
|
||||
final String packageName = task.getExtendField();
|
||||
Log.e("aria", "downloadPath::" + filepath);
|
||||
Log.e("aria", "extendField::" + packageName);
|
||||
JSONObject jsonObject = JSON.parseObject(task.getExtendField());
|
||||
String app_name = jsonObject.getString("app_name");
|
||||
String app_package = jsonObject.getString("app_package");
|
||||
ToastUtil.show(app_name + "\t:下载完成");
|
||||
OkGo.post(URLAddress.HTTP_TAG_DOWNLOAD_URL)
|
||||
.params("key", NetInterfaceManager.HTTP_KEY)
|
||||
.params("sn", Utils.getSerial())
|
||||
.params("package", app_package)
|
||||
.tag(this)
|
||||
.execute(new StringCallback() {
|
||||
@Override
|
||||
public void onSuccess(String s, Call call, okhttp3.Response response) {
|
||||
Log.e("taskComplete", s);
|
||||
}
|
||||
if (filepath.endsWith("apk")) {
|
||||
final String packageName = task.getExtendField();
|
||||
Log.e("aria", "downloadPath::" + filepath);
|
||||
Log.e("aria", "extendField::" + packageName);
|
||||
JSONObject jsonObject = JSON.parseObject(task.getExtendField());
|
||||
String app_name = jsonObject.getString("app_name");
|
||||
String app_package = jsonObject.getString("app_package");
|
||||
ToastUtil.show(app_name + "\t:下载完成");
|
||||
OkGo.post(URLAddress.HTTP_TAG_DOWNLOAD_URL)
|
||||
.params("key", NetInterfaceManager.HTTP_KEY)
|
||||
.params("sn", Utils.getSerial())
|
||||
.params("package", app_package)
|
||||
.tag(this)
|
||||
.execute(new StringCallback() {
|
||||
@Override
|
||||
public void onSuccess(String s, Call call, okhttp3.Response response) {
|
||||
Log.e("taskComplete", s);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(Call call, Response response, Exception e) {
|
||||
super.onError(call, response, e);
|
||||
Log.e("taskComplete", ":" + e.getMessage());
|
||||
}
|
||||
});
|
||||
int userId = (int) SPUtils.get(GuardService.this, "admin_id", 0);
|
||||
long app_size = task.getFileSize();
|
||||
OkGo.post(URLAddress.SEND_DOWNLOAD_FILE_INFO)
|
||||
.params("key", NetInterfaceManager.HTTP_KEY)
|
||||
.params("sn", Utils.getSerial())
|
||||
.params("userId", userId)
|
||||
.params("package_name", packageName)
|
||||
.params("app_size", app_size)
|
||||
.tag(this)
|
||||
.execute(new StringCallback() {
|
||||
@Override
|
||||
public void onSuccess(String s, Call call, okhttp3.Response response) {
|
||||
@Override
|
||||
public void onError(Call call, Response response, Exception e) {
|
||||
super.onError(call, response, e);
|
||||
Log.e("taskComplete", ":" + e.getMessage());
|
||||
}
|
||||
});
|
||||
int userId = (int) SPUtils.get(GuardService.this, "admin_id", 0);
|
||||
long app_size = task.getFileSize();
|
||||
OkGo.post(URLAddress.SEND_DOWNLOAD_FILE_INFO)
|
||||
.params("key", NetInterfaceManager.HTTP_KEY)
|
||||
.params("sn", Utils.getSerial())
|
||||
.params("userId", userId)
|
||||
.params("package_name", packageName)
|
||||
.params("app_size", app_size)
|
||||
.tag(this)
|
||||
.execute(new StringCallback() {
|
||||
@Override
|
||||
public void onSuccess(String s, Call call, okhttp3.Response response) {
|
||||
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
// ApkUtils.installApp(filepath);
|
||||
new Thread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
ApkUtils.installApp(GuardService.this, filepath);
|
||||
}
|
||||
}).start();
|
||||
new Thread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
ApkUtils.installApp(GuardService.this, filepath);
|
||||
}
|
||||
}).start();
|
||||
// try {
|
||||
// Aria.download(this).load(Aria.download(this).getFirstDownloadEntity(task.getKey()).getId()).cancel();
|
||||
// } catch (Exception e) {
|
||||
// Log.e("aria", e.getMessage());
|
||||
// }
|
||||
List<DownloadEntity> list = Aria.download(this).getDRunningTask();
|
||||
if (list == null || list.size() == 0) {
|
||||
BaseApplication.getInstance().setDownloadState(false);
|
||||
Log.e("aria", "isDownloading=" + BaseApplication.getInstance().isDownloading());
|
||||
List<DownloadEntity> list = Aria.download(this).getDRunningTask();
|
||||
if (list == null || list.size() == 0) {
|
||||
BaseApplication.getInstance().setDownloadState(false);
|
||||
Log.e("aria", "isDownloading=" + BaseApplication.getInstance().isDownloading());
|
||||
}
|
||||
} else if (filepath.endsWith("zip")) {
|
||||
JGYUtils.getInstance().setBootanimation(task.getFilePath());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -62,24 +62,26 @@ public class MainService extends Service implements MainContact.MainView {
|
||||
mPresenter.detachView();
|
||||
}
|
||||
|
||||
long timeMillis;
|
||||
long runningTime;
|
||||
//执行所有请求的时间
|
||||
|
||||
long startCommandTime = 0;
|
||||
//MainService上次执行时间
|
||||
|
||||
@Override
|
||||
public int onStartCommand(Intent intent, int flags, int startId) {
|
||||
if ((SystemClock.elapsedRealtime() - startCommandTime) < 60000) {
|
||||
Log.e(TAG, "onStartCommand: " + "启动时间过短");
|
||||
//一分钟内防止多次调用
|
||||
} else {
|
||||
startCommandTime = SystemClock.elapsedRealtime();
|
||||
if (MainActivity.isForeground) {
|
||||
if (MainActivity.isForeground){
|
||||
Log.e(TAG, "onStartCommand: MainActivity: " + MainActivity.isForeground);
|
||||
}else {
|
||||
if (((SystemClock.elapsedRealtime() - startCommandTime) < 60000) ){
|
||||
Log.e(TAG, "onStartCommand: " + "启动时间过短");
|
||||
//一分钟内防止多次调用
|
||||
}else {
|
||||
mPresenter.getFirstConnect();
|
||||
timeMillis = System.currentTimeMillis();
|
||||
mPresenter.getLockedState();
|
||||
Log.e(TAG, "onStartCommand: " + (SystemClock.elapsedRealtime() - startCommandTime));
|
||||
} else {
|
||||
startCommandTime = runningTime = SystemClock.elapsedRealtime();
|
||||
Log.e(TAG, "onStartCommand: isForeground: " + MainActivity.isForeground);
|
||||
Log.e(TAG, "onStartCommand: " + (SystemClock.elapsedRealtime() - startCommandTime));
|
||||
}
|
||||
}
|
||||
return START_STICKY;
|
||||
@@ -420,8 +422,13 @@ public class MainService extends Service implements MainContact.MainView {
|
||||
|
||||
@Override
|
||||
public void setSystemSettingFinished() {
|
||||
mPresenter.setLogoImg();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setLogoImgFinished() {
|
||||
netWorkIsRunning = false;
|
||||
Log.e(TAG, "SettingFinished: " + (System.currentTimeMillis() - timeMillis) + " ms");
|
||||
Log.e(TAG, "SettingFinished: " + (SystemClock.elapsedRealtime() - runningTime) + " ms");
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -10,12 +10,15 @@ import android.content.pm.PackageInfo;
|
||||
import android.content.pm.PackageManager;
|
||||
import android.os.BatteryManager;
|
||||
import android.os.Build;
|
||||
import android.os.Environment;
|
||||
import android.os.PowerManager;
|
||||
import android.provider.Settings;
|
||||
import android.text.TextUtils;
|
||||
import android.util.Log;
|
||||
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.blankj.utilcode.util.FileUtils;
|
||||
import com.blankj.utilcode.util.PathUtils;
|
||||
import com.google.gson.JsonObject;
|
||||
import com.jiaoguanyi.appstore.BuildConfig;
|
||||
import com.jiaoguanyi.appstore.base.BaseApplication;
|
||||
@@ -26,6 +29,14 @@ import com.jiaoguanyi.appstore.bean.NetAndLaunchBean;
|
||||
import com.jiaoguanyi.appstore.bean.NetAndLaunchData;
|
||||
import com.jiaoguanyi.appstore.comm.CommonDatas;
|
||||
|
||||
import org.w3c.dom.Text;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Path;
|
||||
import java.nio.file.Paths;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
@@ -570,4 +581,53 @@ public class JGYUtils {
|
||||
String value = appInfo.metaData.getString("CHANNEL_VALUE");
|
||||
return value;
|
||||
}
|
||||
|
||||
public void checkBootFile(String url, String MD5) {
|
||||
String urlFileName = Utils.getFileNamefromURL(url);
|
||||
File bootFile = new File(PathUtils.getExternalDownloadsPath() + File.separator + "jgy" + File.separator + urlFileName);
|
||||
if (bootFile.exists() && bootFile.isFile()) {
|
||||
String oldMd5 = FileUtils.getFileMD5ToString(bootFile);
|
||||
if (!TextUtils.isEmpty(oldMd5) && oldMd5.equalsIgnoreCase(MD5)) {
|
||||
Log.e(TAG, "checkBootFile: Bootanimation file exists");
|
||||
setBootanimation(bootFile.getAbsolutePath());
|
||||
} else {
|
||||
JSONObject jsonObject = new JSONObject();
|
||||
jsonObject.put("MD5", MD5);
|
||||
Utils.ariaDownload(mContext, url, jsonObject);
|
||||
}
|
||||
} else {
|
||||
JSONObject jsonObject = new JSONObject();
|
||||
jsonObject.put("MD5", MD5);
|
||||
Utils.ariaDownload(mContext, url, jsonObject);
|
||||
}
|
||||
}
|
||||
|
||||
private static final String BOOTANIMATION_PATH = "/data/local/qchmedia/bootanimation.zip";
|
||||
|
||||
public void setBootanimation(String filePath) {
|
||||
File systemFile = new File(BOOTANIMATION_PATH);
|
||||
File newFile = new File(filePath);
|
||||
if (systemFile.exists() && systemFile.isFile()) {
|
||||
String systemMD5 = FileUtils.getFileMD5ToString(systemFile);
|
||||
String newMD5 = FileUtils.getFileMD5ToString(newFile);
|
||||
if (systemMD5.equals(newMD5)) {
|
||||
Log.e(TAG, "setBootanimation: 文件一致");
|
||||
} else {
|
||||
Path path = Paths.get(newFile.getAbsolutePath());
|
||||
try {
|
||||
Files.copy(path, new FileOutputStream(systemFile));
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
} else {
|
||||
Path path = Paths.get(newFile.getAbsolutePath());
|
||||
try {
|
||||
Files.copy(path, new FileOutputStream(systemFile));
|
||||
Log.e(TAG, "setBootanimation: 设置新开机动画");
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -75,7 +75,7 @@ public class SysSettingUtils {
|
||||
|
||||
public static void setEnableSetting(Context mContext) {
|
||||
setPhoneList(mContext,0);
|
||||
setUSBstate(mContext,0);
|
||||
// setUSBstate(mContext,0);
|
||||
setBluetooth(mContext,0);
|
||||
setHotspot(mContext,0);
|
||||
setBar(mContext,0);
|
||||
|
||||
@@ -7,7 +7,7 @@ import java.util.List;
|
||||
|
||||
public class SystemUtils {
|
||||
|
||||
public static boolean IsMainProcessName(Context cxt, int pid) {
|
||||
public static boolean isMainProcessName(Context cxt, int pid) {
|
||||
String packageName = cxt.getPackageName();
|
||||
ActivityManager am = (ActivityManager) cxt.getSystemService(Context.ACTIVITY_SERVICE);
|
||||
List<ActivityManager.RunningAppProcessInfo> runningApps = am.getRunningAppProcesses();
|
||||
|
||||
@@ -13,6 +13,10 @@ import java.text.ParseException;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* @author Administrator
|
||||
* 时间管控工具类
|
||||
*/
|
||||
public class TimeUtils {
|
||||
private static DateFormat df = new SimpleDateFormat("HH:mm");
|
||||
public static final String START_TIME_KEY = "START_TIME";
|
||||
|
||||
@@ -1025,7 +1025,7 @@ public class Utils {
|
||||
context.startActivity(iReboot);
|
||||
}
|
||||
|
||||
private static String getFileNamefromURL(String url) {
|
||||
public static String getFileNamefromURL(String url) {
|
||||
int position = url.lastIndexOf("/");
|
||||
return url.substring(position + 1);
|
||||
}
|
||||
@@ -1378,7 +1378,7 @@ public class Utils {
|
||||
ActivityManager.MemoryInfo memoryInfo = new ActivityManager.MemoryInfo();
|
||||
activityManager.getMemoryInfo(memoryInfo);
|
||||
long freeMem = memoryInfo.totalMem - memoryInfo.availMem;
|
||||
Log.e("getHardware", "getFreeMemory: " + freeMem);
|
||||
// Log.e("getHardware", "getFreeMemory: " + freeMem);
|
||||
return freeMem;
|
||||
}
|
||||
|
||||
@@ -1391,7 +1391,7 @@ public class Utils {
|
||||
ActivityManager activityManager = (ActivityManager) context.getSystemService(Context.ACTIVITY_SERVICE);
|
||||
ActivityManager.MemoryInfo memoryInfo = new ActivityManager.MemoryInfo();
|
||||
activityManager.getMemoryInfo(memoryInfo);
|
||||
Log.e("getHardware", "getFreeMemory: " + memoryInfo.totalMem);
|
||||
// Log.e("getHardware", "getFreeMemory: " + memoryInfo.totalMem);
|
||||
return memoryInfo.totalMem;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
package com.jiaoguanyi.appstore.utils;
|
||||
|
||||
public class XApkUtils {
|
||||
public class XAPKUtils {
|
||||
}
|
||||
Reference in New Issue
Block a user