update:2020.06.15
fix:没有推送也能删除应用 add:没有锁定设备不初始化极光推送
This commit is contained in:
@@ -52,28 +52,26 @@ import okhttp3.ResponseBody;
|
||||
|
||||
public class MyJPushReceiver extends BroadcastReceiver {
|
||||
private static final String TAG = "MyJPushReceiver";
|
||||
|
||||
private final String ACTION_HrReceiver_JGY = "qch_jgy_network_allow";
|
||||
|
||||
private final String ACTION_HrReceiver_JGY_DIS = "qch_jgy_network_disallow";
|
||||
|
||||
private final String MSG_APPID = "5";
|
||||
|
||||
private final String MSG_BROWSER = "4";
|
||||
|
||||
private final String MSG_DELETE = "1";
|
||||
|
||||
private final String MSG_INSTALL = "9";
|
||||
private final String MSG_SETTING = "2";
|
||||
|
||||
private final String MSG_LOCK = "10";//解锁
|
||||
private final String MSG_BROWSER = "4";
|
||||
|
||||
private final String MSG_APPID = "5";
|
||||
|
||||
private final String MSG_NET_CONTROL = "6";
|
||||
|
||||
private final String MSG_POWER_ON = "7";
|
||||
|
||||
private final String MSG_RESET = "8";//加锁
|
||||
private final String MSG_RESET = "8";//重置
|
||||
|
||||
private final String MSG_SETTING = "2";
|
||||
private final String MSG_INSTALL = "9";
|
||||
|
||||
private final String MSG_LOCK = "10";//解锁
|
||||
|
||||
private final String MSG_CAMERA = "11";
|
||||
|
||||
@@ -81,7 +79,7 @@ public class MyJPushReceiver extends BroadcastReceiver {
|
||||
|
||||
private final String GET_APP_USEDTIME = "13";
|
||||
|
||||
private final String GET_FORCEDOWNLOADURL = "14";
|
||||
private final String GET_FORCEDOWNLOADURL = "14";//强制下载
|
||||
|
||||
private final String SET_HOMEPAG_TAG = "15";//主页和书签管控
|
||||
|
||||
@@ -93,9 +91,126 @@ public class MyJPushReceiver extends BroadcastReceiver {
|
||||
|
||||
private final String DISABLE_APP_SLIDE = "19";//禁止滑动
|
||||
|
||||
|
||||
private Context mContext;
|
||||
|
||||
private int changeNum(int paramInt) {
|
||||
switch (paramInt) {
|
||||
default:
|
||||
return 1;
|
||||
case 0:
|
||||
return 1;
|
||||
case 1:
|
||||
break;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
private void processCustomMessage(final Context context, Bundle bundle) {
|
||||
String message = bundle.getString(JPushInterface.EXTRA_MESSAGE);
|
||||
String title = bundle.getString(JPushInterface.EXTRA_TITLE);
|
||||
String type = bundle.getString(JPushInterface.EXTRA_CONTENT_TYPE);
|
||||
String extras = bundle.getString(JPushInterface.EXTRA_EXTRA);
|
||||
String package_name = bundle.getString("package_name");
|
||||
|
||||
LogUtils.e("mjsheng", "message::" + message + "--type::" + type + "--title::" + title + "--extras::" + extras);
|
||||
// ToastUtils.showShort("message::" + message + "--type::" + type + "--title::" + title + "--extras::" + extras + "---package_name:" + package_name);
|
||||
// Toast.makeText(context, "message::" + message + "--type::" + type + "--title::" + title + "--extras::" + extras + "---package_name:" + package_name, Toast.LENGTH_SHORT).show();
|
||||
switch (message) {
|
||||
case MSG_DELETE:
|
||||
if (!TextUtils.isEmpty(title)) {
|
||||
if (SaveListUtils.getlist().contains(title)) {
|
||||
SaveListUtils.getlist().remove(title);
|
||||
}
|
||||
SaveListUtils.sendForceAPP(mContext);
|
||||
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
|
||||
ApkUtils.uninstall(mContext, title);
|
||||
} else {
|
||||
ApkUtils.deleteApkInSilence(title);
|
||||
}
|
||||
}
|
||||
getAppLimitApi();
|
||||
HTTPInterface.getNetAndLaunchSetting(mContext);
|
||||
break;
|
||||
case MSG_SETTING:
|
||||
if (!TextUtils.isEmpty(extras)) {
|
||||
SettingSysData(extras);
|
||||
Log.e(TAG, "title--------" + extras);
|
||||
}
|
||||
// getSystemSetting();
|
||||
break;
|
||||
case MSG_BROWSER:
|
||||
getDeselectBrowerID();
|
||||
break;
|
||||
case MSG_APPID:
|
||||
getDeselectID();
|
||||
break;
|
||||
case MSG_NET_CONTROL:
|
||||
settingNetControl(extras);
|
||||
break;
|
||||
case MSG_POWER_ON:
|
||||
settingPowerOn(extras);
|
||||
break;
|
||||
case MSG_RESET:
|
||||
Utils.doMasterClear(mContext);
|
||||
break;
|
||||
case MSG_INSTALL:
|
||||
// mContext.sendBroadcast(new Intent("android.intent.action.MASTER_CLEAR"));
|
||||
getAppLimitApi();
|
||||
doDownloadAndInstall(extras);
|
||||
HTTPInterface.setHideDesktopIcon(mContext);
|
||||
break;
|
||||
case MSG_LOCK:
|
||||
settingLock(extras);
|
||||
break;
|
||||
case MSG_CAMERA:
|
||||
settingCamera(extras);
|
||||
break;
|
||||
case MSG_ONEPACKAGES:
|
||||
if (MyApplication.getInstance().isFinished()) {
|
||||
settingOneNet(extras);
|
||||
}
|
||||
break;
|
||||
case GET_APP_USEDTIME:
|
||||
com.alibaba.fastjson.JSONObject jsonObject = JSON.parseObject(extras);
|
||||
String random = jsonObject.getString("random");
|
||||
String sendType = jsonObject.getString("type");
|
||||
MyApplication.sendAppUsedTime(random, sendType);
|
||||
break;
|
||||
case GET_FORCEDOWNLOADURL:
|
||||
com.alibaba.fastjson.JSONObject URI = JSON.parseObject(extras);
|
||||
String versionCode = URI.getString("version_code");
|
||||
String url = URI.getString("url");
|
||||
com.alibaba.fastjson.JSONObject packageObj = new com.alibaba.fastjson.JSONObject();
|
||||
packageObj.put("app_name", "教管易");
|
||||
packageObj.put("app_package", "com.jiaoguanyi.store");
|
||||
Aria.download(this)
|
||||
.load(url) //读取下载地址
|
||||
.setFilePath(PathUtils.getExternalDownloadsPath() + "/ygj/" + EncryptUtils.encryptMD5ToString("com.jiaoguanyi.store") + ".apk", true)
|
||||
.setExtendField(packageObj.toJSONString())
|
||||
.create(); //启动下载}
|
||||
|
||||
break;
|
||||
case SET_HOMEPAG_TAG:
|
||||
setHomepagtag(extras);
|
||||
break;
|
||||
|
||||
case APP_WEBSITE:
|
||||
setAPPinsideWebsite(extras);
|
||||
break;
|
||||
case DISABLE_APPUPDATE:
|
||||
Log.e("fht", extras);
|
||||
setDisableUpdateList(extras);
|
||||
break;
|
||||
case HIDE_DESKTOP_ICON:
|
||||
HTTPInterface.setHideDesktopIcon(context);
|
||||
break;
|
||||
case DISABLE_APP_SLIDE:
|
||||
setDisableSlideList(extras);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
private void SettingSysData(String extras) {
|
||||
try {
|
||||
JSONObject data = new JSONObject(extras);
|
||||
@@ -282,18 +397,6 @@ public class MyJPushReceiver extends BroadcastReceiver {
|
||||
}
|
||||
}
|
||||
|
||||
private int changeNum(int paramInt) {
|
||||
switch (paramInt) {
|
||||
default:
|
||||
return 1;
|
||||
case 0:
|
||||
return 1;
|
||||
case 1:
|
||||
break;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
private void doDownloadAndInstall(String s) {
|
||||
if (TextUtils.isEmpty(s)) {
|
||||
Log.e("mjsheng", "doDownloadAndInstall extras is null");
|
||||
@@ -517,112 +620,6 @@ public class MyJPushReceiver extends BroadcastReceiver {
|
||||
return stringBuilder.toString();
|
||||
}
|
||||
|
||||
private void processCustomMessage(final Context context, Bundle bundle) {
|
||||
String message = bundle.getString(JPushInterface.EXTRA_MESSAGE);
|
||||
String title = bundle.getString(JPushInterface.EXTRA_TITLE);
|
||||
String type = bundle.getString(JPushInterface.EXTRA_CONTENT_TYPE);
|
||||
String extras = bundle.getString(JPushInterface.EXTRA_EXTRA);
|
||||
String package_name = bundle.getString("package_name");
|
||||
|
||||
|
||||
LogUtils.e("mjsheng", "message::" + message + "--type::" + type + "--title::" + title + "--extras::" + extras);
|
||||
// ToastUtils.showShort("message::" + message + "--type::" + type + "--title::" + title + "--extras::" + extras + "---package_name:" + package_name);
|
||||
// Toast.makeText(context, "message::" + message + "--type::" + type + "--title::" + title + "--extras::" + extras + "---package_name:" + package_name, Toast.LENGTH_SHORT).show();
|
||||
switch (message) {
|
||||
case MSG_DELETE:
|
||||
if (!TextUtils.isEmpty(title)) {
|
||||
if (SaveListUtils.getlist().contains(title)) {
|
||||
SaveListUtils.getlist().remove(title);
|
||||
}
|
||||
SaveListUtils.sendForceAPP(mContext);
|
||||
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
|
||||
ApkUtils.uninstall(mContext, title);
|
||||
} else {
|
||||
ApkUtils.deleteApkInSilence(title);
|
||||
}
|
||||
}
|
||||
getAppLimitApi();
|
||||
HTTPInterface.getNetAndLaunchSetting(mContext);
|
||||
break;
|
||||
case MSG_SETTING:
|
||||
if (!TextUtils.isEmpty(extras)) {
|
||||
SettingSysData(extras);
|
||||
Log.e(TAG, "title--------" + extras);
|
||||
}
|
||||
// getSystemSetting();
|
||||
break;
|
||||
case MSG_BROWSER:
|
||||
getDeselectBrowerID();
|
||||
break;
|
||||
case MSG_APPID:
|
||||
getDeselectID();
|
||||
break;
|
||||
case MSG_NET_CONTROL:
|
||||
settingNetControl(extras);
|
||||
break;
|
||||
case MSG_POWER_ON:
|
||||
settingPowerOn(extras);
|
||||
break;
|
||||
case MSG_RESET:
|
||||
Utils.doMasterClear(mContext);
|
||||
break;
|
||||
case MSG_INSTALL:
|
||||
// mContext.sendBroadcast(new Intent("android.intent.action.MASTER_CLEAR"));
|
||||
getAppLimitApi();
|
||||
doDownloadAndInstall(extras);
|
||||
HTTPInterface.setHideDesktopIcon(mContext);
|
||||
break;
|
||||
case MSG_LOCK:
|
||||
settingLock(extras);
|
||||
break;
|
||||
case MSG_CAMERA:
|
||||
settingCamera(extras);
|
||||
break;
|
||||
case MSG_ONEPACKAGES:
|
||||
if (MyApplication.getInstance().isFinished()) {
|
||||
settingOneNet(extras);
|
||||
}
|
||||
break;
|
||||
case GET_APP_USEDTIME:
|
||||
com.alibaba.fastjson.JSONObject jsonObject = JSON.parseObject(extras);
|
||||
String random = jsonObject.getString("random");
|
||||
String sendType = jsonObject.getString("type");
|
||||
MyApplication.sendAppUsedTime(random, sendType);
|
||||
break;
|
||||
case GET_FORCEDOWNLOADURL:
|
||||
com.alibaba.fastjson.JSONObject URI = JSON.parseObject(extras);
|
||||
String versionCode = URI.getString("version_code");
|
||||
String url = URI.getString("url");
|
||||
com.alibaba.fastjson.JSONObject packageObj = new com.alibaba.fastjson.JSONObject();
|
||||
packageObj.put("app_name", "教管易");
|
||||
packageObj.put("app_package", "com.jiaoguanyi.store");
|
||||
Aria.download(this)
|
||||
.load(url) //读取下载地址
|
||||
.setFilePath(PathUtils.getExternalDownloadsPath() + "/ygj/" + EncryptUtils.encryptMD5ToString("com.jiaoguanyi.store") + ".apk", true)
|
||||
.setExtendField(packageObj.toJSONString())
|
||||
.create(); //启动下载}
|
||||
|
||||
break;
|
||||
case SET_HOMEPAG_TAG:
|
||||
setHomepagtag(extras);
|
||||
break;
|
||||
|
||||
case APP_WEBSITE:
|
||||
setAPPinsideWebsite(extras);
|
||||
break;
|
||||
case DISABLE_APPUPDATE:
|
||||
Log.e("fht", extras);
|
||||
setDisableUpdateList(extras);
|
||||
break;
|
||||
case HIDE_DESKTOP_ICON:
|
||||
HTTPInterface.setHideDesktopIcon(context);
|
||||
break;
|
||||
case DISABLE_APP_SLIDE:
|
||||
setDisableSlideList(extras);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
private void setDisableSlideList(String s) {
|
||||
try {
|
||||
@@ -659,7 +656,6 @@ public class MyJPushReceiver extends BroadcastReceiver {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// args[1] = message::11--type::11--title::ok--extras::{"ban":"com.lizi.yuwen,com.iyuyan.jp2listensimple,com.netease.edu.study," +
|
||||
// "cn.xuexi.android,com.tuixin.pospointsystem"
|
||||
// ,"not":"com.duoduo.child.story,com.shanbay.words,com.jiongji.andriod.card,fm.jihua.kecheng,com.duia.duiaapp," +
|
||||
@@ -692,7 +688,6 @@ public class MyJPushReceiver extends BroadcastReceiver {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private void settingOneNet(String s) {
|
||||
if (TextUtils.isEmpty(s)) {
|
||||
Log.e("mjsheng", "settingNetControl extras is null");
|
||||
@@ -753,7 +748,6 @@ public class MyJPushReceiver extends BroadcastReceiver {
|
||||
|
||||
}
|
||||
|
||||
|
||||
private void settingPowerOn(String s) {
|
||||
if (TextUtils.isEmpty(s)) {
|
||||
Log.e("mjsheng", "settingNetControlAndPowerOn extras is null");
|
||||
@@ -845,7 +839,6 @@ public class MyJPushReceiver extends BroadcastReceiver {
|
||||
// }
|
||||
}
|
||||
|
||||
|
||||
//应用id管控
|
||||
private void writeDeselectIDtoSystem(String s1, String result) {
|
||||
if (!TextUtils.isEmpty(s1) && !TextUtils.isEmpty(result)) {
|
||||
@@ -885,7 +878,7 @@ public class MyJPushReceiver extends BroadcastReceiver {
|
||||
// Log.e(TAG, "[MyReceiver] 接收到推送下来的自定义消息: " + bundle.getString(JPushInterface.EXTRA_MESSAGE)
|
||||
// + "---" + bundle.getString(JPushInterface.EXTRA_TITLE) + "---" + bundle.getString(JPushInterface.EXTRA_CONTENT_TYPE)
|
||||
// + "---" + bundle.getString(JPushInterface.EXTRA_EXTRA) + "----" + bundle.getString("package_name"));
|
||||
processCustomMessage(context, bundle);
|
||||
processCustomMessage(context, bundle);//屏蔽推送
|
||||
} else if (JPushInterface.ACTION_NOTIFICATION_RECEIVED.equals(intent.getAction())) {
|
||||
Log.e(TAG, "[MyReceiver] 接收到推送下来的通知" + bundle.getString(JPushInterface.EXTRA_EXTRA));
|
||||
// doDownloadAndInstall(bundle.getString(JPushInterface.EXTRA_EXTRA));
|
||||
|
||||
Reference in New Issue
Block a user