update:2020.5.8
fix:增加app内部网页管控 add:静默下载显示网速,单例toast
This commit is contained in:
@@ -8,12 +8,11 @@ import android.content.IntentFilter;
|
||||
import android.os.BatteryManager;
|
||||
import android.os.Build;
|
||||
import android.os.Bundle;
|
||||
import android.provider.Browser;
|
||||
import android.provider.Settings;
|
||||
import android.text.TextUtils;
|
||||
import android.util.Log;
|
||||
|
||||
import cn.jpush.android.api.JPushInterface;
|
||||
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.arialyy.aria.core.Aria;
|
||||
import com.blankj.utilcode.util.AppUtils;
|
||||
@@ -23,26 +22,29 @@ import com.blankj.utilcode.util.PathUtils;
|
||||
import com.mjsheng.myappstore.BuildConfig;
|
||||
import com.mjsheng.myappstore.MyApplication;
|
||||
import com.mjsheng.myappstore.comm.CommonDatas;
|
||||
import com.mjsheng.myappstore.network.HTTPInterface;
|
||||
import com.mjsheng.myappstore.network.Network;
|
||||
import com.mjsheng.myappstore.utils.ApkUtils;
|
||||
import com.mjsheng.myappstore.utils.MySQLData;
|
||||
import com.mjsheng.myappstore.utils.SaveListUtils;
|
||||
import com.mjsheng.myappstore.utils.ToastUtil;
|
||||
import com.mjsheng.myappstore.utils.Utils;
|
||||
|
||||
import io.reactivex.Observer;
|
||||
import io.reactivex.android.schedulers.AndroidSchedulers;
|
||||
import io.reactivex.disposables.Disposable;
|
||||
import io.reactivex.schedulers.Schedulers;
|
||||
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
|
||||
import okhttp3.ResponseBody;
|
||||
|
||||
import org.json.JSONArray;
|
||||
import org.json.JSONException;
|
||||
import org.json.JSONObject;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
|
||||
import cn.jpush.android.api.JPushInterface;
|
||||
import io.reactivex.Observer;
|
||||
import io.reactivex.android.schedulers.AndroidSchedulers;
|
||||
import io.reactivex.disposables.Disposable;
|
||||
import io.reactivex.schedulers.Schedulers;
|
||||
import okhttp3.ResponseBody;
|
||||
|
||||
public class MyJPushReceiver extends BroadcastReceiver {
|
||||
private static final String TAG = "MyJPushReceiver";
|
||||
|
||||
@@ -76,6 +78,10 @@ public class MyJPushReceiver extends BroadcastReceiver {
|
||||
|
||||
private final String GET_FORCEDOWNLOADURL = "14";
|
||||
|
||||
private final String SET_HOMEPAG_TAG = "15";//主页和书签管控
|
||||
|
||||
private final String APP_WEBSITE = "16";//app内网页管控
|
||||
|
||||
|
||||
private Context mContext;
|
||||
|
||||
@@ -304,8 +310,8 @@ public class MyJPushReceiver extends BroadcastReceiver {
|
||||
|
||||
(Aria.download(this)
|
||||
.load(str)
|
||||
.setDownloadPath(PathUtils.getExternalDownloadsPath() + "/ygj/" + EncryptUtils.encryptMD5ToString(s) + ".apk").setExtendField(s))
|
||||
.start();
|
||||
.setFilePath(PathUtils.getExternalDownloadsPath() + "/ygj/" + EncryptUtils.encryptMD5ToString(s) + ".apk").setExtendField(s))
|
||||
.create();
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
@@ -544,9 +550,17 @@ public class MyJPushReceiver extends BroadcastReceiver {
|
||||
.load(url) //读取下载地址
|
||||
.setFilePath(PathUtils.getExternalDownloadsPath() + "/ygj/" + EncryptUtils.encryptMD5ToString("com.jiaoguanyi.store") + ".apk", true)
|
||||
.setExtendField("com.jiaoguanyi.store")
|
||||
.start(); //启动下载}
|
||||
.create(); //启动下载}
|
||||
|
||||
break;
|
||||
case SET_HOMEPAG_TAG:
|
||||
setHomepagtag(extras);
|
||||
break;
|
||||
|
||||
case APP_WEBSITE:
|
||||
setAPPinsideWebsite(extras);
|
||||
break;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -641,34 +655,9 @@ public class MyJPushReceiver extends BroadcastReceiver {
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private class BroadcastThread extends Thread {
|
||||
String[] packagename;
|
||||
String action;
|
||||
|
||||
public BroadcastThread(String a, String[] s) {
|
||||
super();
|
||||
this.packagename = s;
|
||||
this.action = a;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
super.run();
|
||||
for (String name : packagename) {
|
||||
Intent disIntent = new Intent(action);
|
||||
disIntent.putExtra("package_name", name);
|
||||
Log.e("mymjsheng", "package_name::" + name);
|
||||
mContext.sendBroadcast(disIntent);
|
||||
try {
|
||||
sleep(5000);
|
||||
} catch (InterruptedException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void settingPowerOn(String s) {
|
||||
if (TextUtils.isEmpty(s)) {
|
||||
@@ -717,6 +706,76 @@ public class MyJPushReceiver extends BroadcastReceiver {
|
||||
// Log.e("mjsheng", "writeDeselectBrowserIDtoSystem is null:");
|
||||
}
|
||||
|
||||
private void setHomepagtag(String s) {
|
||||
//设置主页和标签
|
||||
HTTPInterface.setHomepagtag(mContext);
|
||||
|
||||
// if (TextUtils.isEmpty(s)) {
|
||||
// Log.e("mjsheng", "setHomepagtag extras is null");
|
||||
//
|
||||
// return;
|
||||
// } else {
|
||||
// try {
|
||||
// com.alibaba.fastjson.JSONObject jsonObject = JSON.parseObject(s);
|
||||
// String packageweb = jsonObject.getString("");
|
||||
// ArrayList<String> strings = new ArrayList<>();
|
||||
// Intent intent = new Intent("action");
|
||||
// intent.putStringArrayListExtra("package", strings);
|
||||
// mContext.sendBroadcast(intent);
|
||||
// } catch (Exception e) {
|
||||
// ToastUtil.show("数据错误");
|
||||
// }
|
||||
// }
|
||||
}
|
||||
|
||||
private void setAPPinsideWebsite(String s) {
|
||||
//禁止app内部网页访问,包名用,隔开
|
||||
HTTPInterface.setAppinsideWeb(mContext);
|
||||
// if (TextUtils.isEmpty(s)) {
|
||||
// Log.e("mjsheng", "setAPPinsideWebsite extras is null");
|
||||
//
|
||||
// return;
|
||||
// } else {
|
||||
// try {
|
||||
// JSONObject jSONObject = new JSONObject(s);
|
||||
// String str = jSONObject.optString("package");
|
||||
// Intent intent = new Intent("qch_app_website");
|
||||
// intent.putExtra("package_name", str);
|
||||
// mContext.sendBroadcast(intent);
|
||||
// } catch (JSONException e) {
|
||||
// e.printStackTrace();
|
||||
// }
|
||||
// }
|
||||
}
|
||||
|
||||
private class BroadcastThread extends Thread {
|
||||
String[] packagename;
|
||||
String action;
|
||||
|
||||
public BroadcastThread(String a, String[] s) {
|
||||
super();
|
||||
this.packagename = s;
|
||||
this.action = a;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
super.run();
|
||||
for (String name : packagename) {
|
||||
Intent disIntent = new Intent(action);
|
||||
disIntent.putExtra("package_name", name);
|
||||
Log.e("mymjsheng", "package_name::" + name);
|
||||
mContext.sendBroadcast(disIntent);
|
||||
try {
|
||||
sleep(5000);
|
||||
} catch (InterruptedException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//应用id管控
|
||||
private void writeDeselectIDtoSystem(String s1, String result) {
|
||||
if (!TextUtils.isEmpty(s1) && !TextUtils.isEmpty(result)) {
|
||||
|
||||
Reference in New Issue
Block a user