update:2020.05.28
fix:去掉应用安装权限申请 add:升级apk覆盖安装推送和接口
This commit is contained in:
@@ -15,8 +15,8 @@ android {
|
|||||||
minSdkVersion 20
|
minSdkVersion 20
|
||||||
targetSdkVersion 29
|
targetSdkVersion 29
|
||||||
|
|
||||||
versionCode 136
|
versionCode 138
|
||||||
versionName "2.9.3"//测试jiaoguanyi.cn
|
versionName "2.9.5"//测试jiaoguanyi.cn
|
||||||
// versionCode 127
|
// versionCode 127
|
||||||
// versionName "2.0.0.7"// 正式jiaoguanyi.com 双数正式 单数测试
|
// versionName "2.0.0.7"// 正式jiaoguanyi.com 双数正式 单数测试
|
||||||
multiDexEnabled true
|
multiDexEnabled true
|
||||||
|
|||||||
@@ -10,6 +10,7 @@ import android.os.Build;
|
|||||||
import android.os.Handler;
|
import android.os.Handler;
|
||||||
import android.os.Looper;
|
import android.os.Looper;
|
||||||
import android.support.multidex.MultiDexApplication;
|
import android.support.multidex.MultiDexApplication;
|
||||||
|
import android.text.TextUtils;
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
|
|
||||||
import com.alibaba.fastjson.JSON;
|
import com.alibaba.fastjson.JSON;
|
||||||
@@ -46,6 +47,7 @@ import org.lzh.framework.updatepluginlib.model.CheckEntity;
|
|||||||
|
|
||||||
import java.text.SimpleDateFormat;
|
import java.text.SimpleDateFormat;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
import java.util.Arrays;
|
||||||
import java.util.Calendar;
|
import java.util.Calendar;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
@@ -490,6 +492,74 @@ public class MyApplication extends MultiDexApplication {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static long totalTime;
|
||||||
|
private static int totalTimes;
|
||||||
|
|
||||||
|
synchronized public static void setAPPUsage() {
|
||||||
|
StatisticsInfo statisticsInfo = new StatisticsInfo(getAppContext());
|
||||||
|
totalTime = statisticsInfo.getTotalTime();//全部时间
|
||||||
|
totalTimes = statisticsInfo.getTotalTimes();//全部次数
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
synchronized public static void setAPPUsage(List<String> lists) {
|
||||||
|
StatisticsInfo statisticsInfo = new StatisticsInfo(getAppContext());
|
||||||
|
List<AppInformation> list = null;
|
||||||
|
List<AppInformation> localAppList = new ArrayList<>();
|
||||||
|
|
||||||
|
totalTime = statisticsInfo.getTotalTime();//全部时间
|
||||||
|
totalTimes = statisticsInfo.getTotalTimes();//全部次数
|
||||||
|
|
||||||
|
list = statisticsInfo.getShowList();
|
||||||
|
if (list != null && list.size() > 0) {
|
||||||
|
for (AppInformation appInformation : list) {
|
||||||
|
if (lists.indexOf(appInformation.getPackageName()) != -1) {
|
||||||
|
localAppList.add(appInformation);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
} else {
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
synchronized public void getWhitePackageList() {
|
||||||
|
OkGo.post(Configure.SEND_APP_USAGE)
|
||||||
|
.params("sn", Utils.getSerial())
|
||||||
|
.params("key", Configure.HTTP_KEY)
|
||||||
|
.execute(new StringCallback() {
|
||||||
|
@Override
|
||||||
|
public void onSuccess(String s, Call call, Response response) {
|
||||||
|
com.alibaba.fastjson.JSONObject jsonObject = JSON.parseObject(s);
|
||||||
|
int code = jsonObject.getInteger("code");
|
||||||
|
String msg = jsonObject.getString("msg");
|
||||||
|
String data = jsonObject.getString("data");
|
||||||
|
if (code == 200) {
|
||||||
|
com.alibaba.fastjson.JSONObject resultJson = JSON.parseObject(data);
|
||||||
|
String result = resultJson.getString("result");
|
||||||
|
if (!TextUtils.isEmpty(result)) {
|
||||||
|
String[] list = result.split(",");
|
||||||
|
List<String> allList = new ArrayList<>(Arrays.asList(list));
|
||||||
|
setAPPUsage(allList);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
setAPPUsage();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onError(Call call, Response response, Exception e) {
|
||||||
|
super.onError(call, response, e);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
private void catchException() {
|
private void catchException() {
|
||||||
Thread.setDefaultUncaughtExceptionHandler(
|
Thread.setDefaultUncaughtExceptionHandler(
|
||||||
new Thread.UncaughtExceptionHandler() {
|
new Thread.UncaughtExceptionHandler() {
|
||||||
|
|||||||
@@ -364,6 +364,7 @@ public class MainActivity extends AppCompatActivity implements NetStateChangeObs
|
|||||||
private void initData() {
|
private void initData() {
|
||||||
Log.e("mjhsneg", "gagagag--------------------------" + Utils.getSerial());
|
Log.e("mjhsneg", "gagagag--------------------------" + Utils.getSerial());
|
||||||
getLockedState();
|
getLockedState();
|
||||||
|
MyApplication.getInstance().getWhitePackageList();
|
||||||
initJpush();//初始化极光推送
|
initJpush();//初始化极光推送
|
||||||
HTTPInterface.setJpushTags(this);
|
HTTPInterface.setJpushTags(this);
|
||||||
// update();//接口更新app
|
// update();//接口更新app
|
||||||
@@ -422,7 +423,7 @@ public class MainActivity extends AppCompatActivity implements NetStateChangeObs
|
|||||||
// Permission.READ_SMS,
|
// Permission.READ_SMS,
|
||||||
// Permission.RECEIVE_SMS,
|
// Permission.RECEIVE_SMS,
|
||||||
// Permission.SEND_SMS,
|
// Permission.SEND_SMS,
|
||||||
Permission.REQUEST_INSTALL_PACKAGES,
|
// Permission.REQUEST_INSTALL_PACKAGES,//不用请求也可以安装
|
||||||
Permission.READ_EXTERNAL_STORAGE,
|
Permission.READ_EXTERNAL_STORAGE,
|
||||||
Permission.WRITE_EXTERNAL_STORAGE,
|
Permission.WRITE_EXTERNAL_STORAGE,
|
||||||
// Permission.READ_PHONE_STATE
|
// Permission.READ_PHONE_STATE
|
||||||
@@ -621,6 +622,7 @@ public class MainActivity extends AppCompatActivity implements NetStateChangeObs
|
|||||||
sendBroadcast(allIntent);
|
sendBroadcast(allIntent);
|
||||||
loadHeadImg(Configure.HTTP_TAG_HOME_PAGE_URL);
|
loadHeadImg(Configure.HTTP_TAG_HOME_PAGE_URL);
|
||||||
lazyLoading();
|
lazyLoading();
|
||||||
|
MyApplication.getInstance().getWhitePackageList();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1150,15 +1152,38 @@ public class MainActivity extends AppCompatActivity implements NetStateChangeObs
|
|||||||
ForceDownloadData forceDownloadData = data.get(i);
|
ForceDownloadData forceDownloadData = data.get(i);
|
||||||
String app_package = forceDownloadData.getApp_package();
|
String app_package = forceDownloadData.getApp_package();
|
||||||
String app_url = forceDownloadData.getApp_url();
|
String app_url = forceDownloadData.getApp_url();
|
||||||
Log.e("fht ", "packageName=" + app_package + ",URL= " + app_url);
|
int app_version_code = forceDownloadData.getApp_version_code();
|
||||||
|
Log.e("fht ", "packageName=" + app_package + ",URL= " + app_url + ",app_version_code=" + app_version_code);
|
||||||
if (data.get(i).getApp_package().equals("com.jiaoguanyi.store")) {
|
if (data.get(i).getApp_package().equals("com.jiaoguanyi.store")) {
|
||||||
continue;//为自身的跳过下载
|
continue;//为自身的跳过下载
|
||||||
}
|
}
|
||||||
if (!list.contains(app_package)) {
|
if (!list.contains(app_package)) {
|
||||||
list.add(app_package);
|
list.add(app_package);
|
||||||
}
|
}
|
||||||
|
PackageManager pm = getPackageManager();
|
||||||
if (!AppUtils.isAppInstalled(app_package)) {
|
PackageInfo packageInfo = null;
|
||||||
|
try {
|
||||||
|
packageInfo = pm.getPackageInfo(app_package, 0);
|
||||||
|
} catch (PackageManager.NameNotFoundException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
Log.e("fht", "forceDownload=" + e.getMessage());
|
||||||
|
}
|
||||||
|
if (packageInfo != null) {
|
||||||
|
long appVersionCode;
|
||||||
|
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.P) {
|
||||||
|
appVersionCode = packageInfo.getLongVersionCode();
|
||||||
|
} else {
|
||||||
|
appVersionCode = packageInfo.versionCode;
|
||||||
|
}
|
||||||
|
if (app_version_code > appVersionCode) {
|
||||||
|
Log.e("fht ", "download URL " + app_url);
|
||||||
|
Aria.download(this)
|
||||||
|
.load(app_url) //读取下载地址
|
||||||
|
.setFilePath(PathUtils.getExternalDownloadsPath() + "/ygj/" + EncryptUtils.encryptMD5ToString(app_package) + ".apk", true)
|
||||||
|
.setExtendField(app_package)
|
||||||
|
.create(); //启动下载}
|
||||||
|
}
|
||||||
|
} 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)
|
||||||
|
|||||||
@@ -14,6 +14,7 @@ public class ForceDownloadData {
|
|||||||
|
|
||||||
private String app_package;
|
private String app_package;
|
||||||
private String app_url;
|
private String app_url;
|
||||||
|
private int app_version_code;
|
||||||
|
|
||||||
public String getApp_package() {
|
public String getApp_package() {
|
||||||
return app_package;
|
return app_package;
|
||||||
@@ -31,6 +32,14 @@ public class ForceDownloadData {
|
|||||||
this.app_url = app_url;
|
this.app_url = app_url;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public int getApp_version_code() {
|
||||||
|
return app_version_code;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setApp_version_code(int app_version_code) {
|
||||||
|
this.app_version_code = app_version_code;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return "ForceDownloadData{" +
|
return "ForceDownloadData{" +
|
||||||
|
|||||||
@@ -342,6 +342,7 @@ public class HTTPInterface {
|
|||||||
}
|
}
|
||||||
|
|
||||||
synchronized public static void setHomepagtag(final Context context) {
|
synchronized public static void setHomepagtag(final Context context) {
|
||||||
|
//7.0setPackage不加没有问题,.setPackage("com.android.settings"),10.0需要加上,待底层修改后
|
||||||
OkGo.post(Configure.SET_HOMEPAG_TAG)
|
OkGo.post(Configure.SET_HOMEPAG_TAG)
|
||||||
.params("key", Configure.HTTP_KEY)
|
.params("key", Configure.HTTP_KEY)
|
||||||
.params("sn", Utils.getSerial())
|
.params("sn", Utils.getSerial())
|
||||||
@@ -349,48 +350,52 @@ public class HTTPInterface {
|
|||||||
@Override
|
@Override
|
||||||
public void onSuccess(String s, Call call, Response response) {
|
public void onSuccess(String s, Call call, Response response) {
|
||||||
// try {
|
// try {
|
||||||
JSONObject jsonObject = JSON.parseObject(s);
|
JSONObject jsonObject = JSON.parseObject(s);
|
||||||
int code = jsonObject.getInteger("code");
|
int code = jsonObject.getInteger("code");
|
||||||
String msg = jsonObject.getString("msg");
|
String msg = jsonObject.getString("msg");
|
||||||
if (code == 200) {
|
if (code == 200) {
|
||||||
String data = jsonObject.getString("data");
|
String data = jsonObject.getString("data");
|
||||||
JSONObject jsondata = JSON.parseObject(data);
|
JSONObject jsondata = JSON.parseObject(data);
|
||||||
//主页
|
//主页
|
||||||
String homepagURL = jsondata.getString("homepage");
|
String homepagURL = jsondata.getString("homepage");
|
||||||
Intent homepag = new Intent("qch_app_brower_homepage")
|
Intent homepag = new Intent("qch_app_brower_homepage")
|
||||||
.setPackage("com.android.settings")
|
.setPackage("com.android.settings")
|
||||||
.setPackage("com.android.browser");
|
// .setPackage("com.android.browser")
|
||||||
if (homepagURL != null && !homepagURL.equals("")) {
|
;
|
||||||
homepag.putExtra("homepage", homepagURL);
|
if (homepagURL != null && !homepagURL.equals("")) {
|
||||||
} else {
|
homepag.putExtra("homepage", homepagURL);
|
||||||
homepag.putExtra("homepage", "Invalid");
|
|
||||||
}
|
|
||||||
context.sendBroadcast(homepag);
|
|
||||||
|
|
||||||
//书签
|
|
||||||
String labelpage = jsondata.getString("labelpage");
|
|
||||||
Intent websiteBookMark = new Intent("qch_app_brower_website")
|
|
||||||
.setPackage("com.android.settings")
|
|
||||||
.setPackage("com.android.browser");
|
|
||||||
if (labelpage != null && !labelpage.equals("")) {
|
|
||||||
websiteBookMark.putExtra("websiteBookMark", labelpage);
|
|
||||||
} else {
|
|
||||||
websiteBookMark.putExtra("websiteBookMark", "Invalid");
|
|
||||||
}
|
|
||||||
context.sendBroadcast(websiteBookMark);
|
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
Intent intent1 = new Intent("qch_app_brower_homepage")
|
homepag.putExtra("homepage", "Invalid");
|
||||||
.setPackage("com.android.settings")
|
|
||||||
.setPackage("com.android.browser");
|
|
||||||
intent1.putExtra("homepage", "Invalid");
|
|
||||||
context.sendBroadcast(intent1);
|
|
||||||
Intent intent2 = new Intent("qch_app_brower_website")
|
|
||||||
.setPackage("com.android.settings")
|
|
||||||
.setPackage("com.android.browser");
|
|
||||||
intent2.putExtra("websiteBookMark", "Invalid");
|
|
||||||
context.sendBroadcast(intent2);
|
|
||||||
}
|
}
|
||||||
|
context.sendBroadcast(homepag);
|
||||||
|
|
||||||
|
//书签
|
||||||
|
String labelpage = jsondata.getString("labelpage");
|
||||||
|
Intent websiteBookMark = new Intent("qch_app_brower_website")
|
||||||
|
.setPackage("com.android.settings")
|
||||||
|
// .setPackage("com.android.browser")
|
||||||
|
;
|
||||||
|
if (labelpage != null && !labelpage.equals("")) {
|
||||||
|
websiteBookMark.putExtra("websiteBookMark", labelpage);
|
||||||
|
} else {
|
||||||
|
websiteBookMark.putExtra("websiteBookMark", "Invalid");
|
||||||
|
}
|
||||||
|
context.sendBroadcast(websiteBookMark);
|
||||||
|
|
||||||
|
} else {
|
||||||
|
Intent intent1 = new Intent("qch_app_brower_homepage")
|
||||||
|
.setPackage("com.android.settings")
|
||||||
|
// .setPackage("com.android.browser")
|
||||||
|
;
|
||||||
|
intent1.putExtra("homepage", "Invalid");
|
||||||
|
context.sendBroadcast(intent1);
|
||||||
|
Intent intent2 = new Intent("qch_app_brower_website")
|
||||||
|
.setPackage("com.android.settings")
|
||||||
|
// .setPackage("com.android.browser")
|
||||||
|
;
|
||||||
|
intent2.putExtra("websiteBookMark", "Invalid");
|
||||||
|
context.sendBroadcast(intent2);
|
||||||
|
}
|
||||||
// } catch (Exception e) {
|
// } catch (Exception e) {
|
||||||
// Log.e("fht", "setHomepagtag" + e.getMessage());
|
// Log.e("fht", "setHomepagtag" + e.getMessage());
|
||||||
//// ToastUtil.show("数据错误");
|
//// ToastUtil.show("数据错误");
|
||||||
@@ -434,7 +439,8 @@ public class HTTPInterface {
|
|||||||
packageList = packageList.substring(0, packageList.length() - 1);
|
packageList = packageList.substring(0, packageList.length() - 1);
|
||||||
//去掉多余的,
|
//去掉多余的,
|
||||||
Log.e("setAppinsideWeb ", "packageList:" + packageList);
|
Log.e("setAppinsideWeb ", "packageList:" + packageList);
|
||||||
Intent qch_app_website = new Intent("qch_app_website").setPackage("com.android.settings");
|
Intent qch_app_website = new Intent("qch_app_website")
|
||||||
|
.setPackage("com.android.settings");
|
||||||
qch_app_website.putExtra("package_name", packageList);
|
qch_app_website.putExtra("package_name", packageList);
|
||||||
context.sendBroadcast(qch_app_website);
|
context.sendBroadcast(qch_app_website);
|
||||||
} else {
|
} else {
|
||||||
@@ -445,7 +451,8 @@ public class HTTPInterface {
|
|||||||
strings = strings.substring(0, strings.length() - 1);
|
strings = strings.substring(0, strings.length() - 1);
|
||||||
//去掉多余的;
|
//去掉多余的;
|
||||||
Log.e("setAppinsideWeb ", "strings:" + strings);
|
Log.e("setAppinsideWeb ", "strings:" + strings);
|
||||||
Intent intent = new Intent("qch_app_inside_website").setPackage("com.android.settings");
|
Intent intent = new Intent("qch_app_inside_website")
|
||||||
|
.setPackage("com.android.settings");
|
||||||
intent.putExtra("websitelist", strings);
|
intent.putExtra("websitelist", strings);
|
||||||
context.sendBroadcast(intent);
|
context.sendBroadcast(intent);
|
||||||
} else {
|
} else {
|
||||||
@@ -474,13 +481,15 @@ public class HTTPInterface {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private static void sendAllweb(Context context) {
|
private static void sendAllweb(Context context) {
|
||||||
Intent intent = new Intent("qch_app_website").setPackage("com.android.settings");
|
Intent intent = new Intent("qch_app_website")
|
||||||
|
.setPackage("com.android.settings");
|
||||||
intent.putExtra("package_name", "Invalid");
|
intent.putExtra("package_name", "Invalid");
|
||||||
context.sendBroadcast(intent);
|
context.sendBroadcast(intent);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void sendwebUrl(Context context) {
|
private static void sendwebUrl(Context context) {
|
||||||
Intent intent = new Intent("qch_app_inside_website").setPackage("com.android.settings");
|
Intent intent = new Intent("qch_app_inside_website")
|
||||||
|
.setPackage("com.android.settings");
|
||||||
intent.putExtra("websitelist", "Invalid");
|
intent.putExtra("websitelist", "Invalid");
|
||||||
context.sendBroadcast(intent);
|
context.sendBroadcast(intent);
|
||||||
}
|
}
|
||||||
@@ -518,7 +527,7 @@ public class HTTPInterface {
|
|||||||
Log.e("fht", "setBrowserList" + msg);
|
Log.e("fht", "setBrowserList" + msg);
|
||||||
}
|
}
|
||||||
} catch (JSONException e) {
|
} catch (JSONException e) {
|
||||||
Log.e("fht", "setBrowserList" +e.getMessage());
|
Log.e("fht", "setBrowserList" + e.getMessage());
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,6 +5,9 @@ import android.content.Context;
|
|||||||
import android.content.ContextWrapper;
|
import android.content.ContextWrapper;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.content.IntentFilter;
|
import android.content.IntentFilter;
|
||||||
|
import android.content.pm.ApplicationInfo;
|
||||||
|
import android.content.pm.PackageInfo;
|
||||||
|
import android.content.pm.PackageManager;
|
||||||
import android.os.BatteryManager;
|
import android.os.BatteryManager;
|
||||||
import android.os.Build;
|
import android.os.Build;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
@@ -293,22 +296,46 @@ public class MyJPushReceiver extends BroadcastReceiver {
|
|||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
JSONObject jSONObject = new JSONObject(s);
|
JSONObject jSONObject = new JSONObject(s);
|
||||||
s = jSONObject.optString("app_package");
|
String app_package = jSONObject.optString("app_package");
|
||||||
String str = jSONObject.optString("app_url");
|
String app_url = jSONObject.optString("app_url");
|
||||||
Log.e("mymjsheng", "app_package::" + s);
|
int app_version_code = jSONObject.optInt("app_version_code");
|
||||||
Log.e("mymjsheng", "app_url::" + str);
|
Log.e("mymjsheng", "app_package::" + app_package);
|
||||||
SaveListUtils.addList(s);
|
Log.e("mymjsheng", "app_url::" + app_url);
|
||||||
|
SaveListUtils.addList(app_package);
|
||||||
SaveListUtils.sendForceAPP(mContext);
|
SaveListUtils.sendForceAPP(mContext);
|
||||||
if (!AppUtils.isAppInstalled(s)) {
|
PackageManager pm = mContext.getPackageManager();
|
||||||
if (!SaveListUtils.isDownLoading(s)) {
|
PackageInfo packageInfo = null;
|
||||||
(Aria.download(this)
|
try {
|
||||||
.load(str)
|
packageInfo = pm.getPackageInfo(app_package, 0);
|
||||||
.setFilePath(PathUtils.getExternalDownloadsPath() + "/ygj/" + EncryptUtils.encryptMD5ToString(s) + ".apk").setExtendField(s))
|
} catch (PackageManager.NameNotFoundException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
if (packageInfo == null) {
|
||||||
|
if (!SaveListUtils.isDownLoading(app_url)) {
|
||||||
|
Aria.download(this)
|
||||||
|
.load(app_url)
|
||||||
|
.setFilePath(PathUtils.getExternalDownloadsPath() + "/ygj/" + EncryptUtils.encryptMD5ToString(s) + ".apk").setExtendField(app_package)
|
||||||
.create();
|
.create();
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
long appVersionCode;
|
||||||
|
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.P) {
|
||||||
|
appVersionCode = packageInfo.getLongVersionCode();
|
||||||
|
} else {
|
||||||
|
appVersionCode = packageInfo.versionCode;
|
||||||
|
}
|
||||||
|
if (app_version_code > appVersionCode) {
|
||||||
|
if (!SaveListUtils.isDownLoading(app_url)) {
|
||||||
|
Aria.download(this)
|
||||||
|
.load(app_url)
|
||||||
|
.setFilePath(PathUtils.getExternalDownloadsPath() + "/ygj/" + EncryptUtils.encryptMD5ToString(s) + ".apk").setExtendField(app_package)
|
||||||
|
.create();
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
|
Log.e("fht", "doDownloadAndInstall:" + e.getMessage());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -7,6 +7,7 @@ import android.content.Intent;
|
|||||||
import android.content.IntentFilter;
|
import android.content.IntentFilter;
|
||||||
import android.content.pm.PackageInfo;
|
import android.content.pm.PackageInfo;
|
||||||
import android.content.pm.PackageManager;
|
import android.content.pm.PackageManager;
|
||||||
|
import android.os.Build;
|
||||||
import android.os.Handler;
|
import android.os.Handler;
|
||||||
import android.os.IBinder;
|
import android.os.IBinder;
|
||||||
import android.os.Message;
|
import android.os.Message;
|
||||||
@@ -90,7 +91,6 @@ public class InitJpushServer extends Service {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int onStartCommand(Intent intent, int flags, int startId) {
|
public int onStartCommand(Intent intent, int flags, int startId) {
|
||||||
// 初始化 JPush
|
// 初始化 JPush
|
||||||
@@ -139,7 +139,7 @@ public class InitJpushServer extends Service {
|
|||||||
|
|
||||||
|
|
||||||
//重新设置jpush
|
//重新设置jpush
|
||||||
synchronized private void timerImitate() {
|
synchronized private void timerImitate() {
|
||||||
Observable.timer(15000, TimeUnit.MILLISECONDS)
|
Observable.timer(15000, TimeUnit.MILLISECONDS)
|
||||||
.observeOn(rx.android.schedulers.AndroidSchedulers.mainThread())
|
.observeOn(rx.android.schedulers.AndroidSchedulers.mainThread())
|
||||||
.subscribe(new Action1<Long>() {
|
.subscribe(new Action1<Long>() {
|
||||||
@@ -418,21 +418,47 @@ public class InitJpushServer extends Service {
|
|||||||
ForceDownloadData forceDownloadData = data.get(i);
|
ForceDownloadData forceDownloadData = data.get(i);
|
||||||
String app_package = forceDownloadData.getApp_package();
|
String app_package = forceDownloadData.getApp_package();
|
||||||
String app_url = forceDownloadData.getApp_url();
|
String app_url = forceDownloadData.getApp_url();
|
||||||
|
int app_version_code = forceDownloadData.getApp_version_code();
|
||||||
|
Log.e("fht ", "packageName=" + app_package + ",URL= " + app_url + ",app_version_code=" + app_version_code);
|
||||||
if (data.get(i).getApp_package().equals("com.jiaoguanyi.appstore")) {
|
if (data.get(i).getApp_package().equals("com.jiaoguanyi.appstore")) {
|
||||||
continue;//为自身的跳过下载
|
continue;//为自身的跳过下载
|
||||||
}
|
}
|
||||||
if (!list.contains(app_package)) {
|
if (!list.contains(app_package)) {
|
||||||
list.add(app_package);
|
list.add(app_package);
|
||||||
}
|
}
|
||||||
if (!AppUtils.isAppInstalled(app_package)) {
|
PackageManager pm = getPackageManager();
|
||||||
if (!SaveListUtils.isDownLoading(app_package)) {
|
PackageInfo packageInfo = null;
|
||||||
|
try {
|
||||||
|
packageInfo = pm.getPackageInfo(app_package, 0);
|
||||||
|
} catch (PackageManager.NameNotFoundException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
Log.e("fht", "forceDownload=" + e.getMessage());
|
||||||
|
}
|
||||||
|
if (packageInfo != null) {
|
||||||
|
long appVersionCode;
|
||||||
|
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.P) {
|
||||||
|
appVersionCode = packageInfo.getLongVersionCode();
|
||||||
|
} else {
|
||||||
|
appVersionCode = packageInfo.versionCode;
|
||||||
|
}
|
||||||
|
if (app_version_code > appVersionCode) {
|
||||||
|
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")
|
.setFilePath(PathUtils.getExternalDownloadsPath() + "/ygj/" + EncryptUtils.encryptMD5ToString(app_package) + ".apk", true)
|
||||||
.setExtendField(app_package)
|
.setExtendField(app_package)
|
||||||
.create(); //启动下载}
|
.create(); //启动下载}
|
||||||
SaveListUtils.addDownLoadList(app_package);
|
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
Log.e("fht ", "download URL " + app_url);
|
||||||
|
// if (!SaveListUtils.isDownLoading(app_package)) {
|
||||||
|
Aria.download(this)
|
||||||
|
.load(app_url) //读取下载地址
|
||||||
|
.setFilePath(PathUtils.getExternalDownloadsPath() + "/ygj/" + EncryptUtils.encryptMD5ToString(app_package) + ".apk", true)
|
||||||
|
.setExtendField(app_package)
|
||||||
|
.create(); //启动下载}
|
||||||
|
// SaveListUtils.addDownLoadList(app_package);
|
||||||
|
// }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
SaveListUtils.setList(list);
|
SaveListUtils.setList(list);
|
||||||
@@ -682,6 +708,7 @@ public class InitJpushServer extends Service {
|
|||||||
HTTPInterface.setBrowserList(InitJpushServer.this);//浏览器网址管控
|
HTTPInterface.setBrowserList(InitJpushServer.this);//浏览器网址管控
|
||||||
HTTPInterface.setAppinsideWeb(InitJpushServer.this);//app内部网页管控
|
HTTPInterface.setAppinsideWeb(InitJpushServer.this);//app内部网页管控
|
||||||
HTTPInterface.setHomepagtag(InitJpushServer.this);//设置主页和标签
|
HTTPInterface.setHomepagtag(InitJpushServer.this);//设置主页和标签
|
||||||
|
MyApplication.getInstance().getWhitePackageList();
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -197,4 +197,6 @@ public class Configure {
|
|||||||
public static final String SET_APPINSIDEWEB = HTTP_TAG_HEAD_NEW + "Appground";
|
public static final String SET_APPINSIDEWEB = HTTP_TAG_HEAD_NEW + "Appground";
|
||||||
//浏览器黑白名单地址
|
//浏览器黑白名单地址
|
||||||
public static final String SET_BROWSER_LIST = HTTP_TAG_HEAD_NEW + "browser";
|
public static final String SET_BROWSER_LIST = HTTP_TAG_HEAD_NEW + "browser";
|
||||||
|
|
||||||
|
public static final String SEND_APP_USAGE = HTTP_TAG_HEAD_NEW + "firmware/index";
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user