version:2.1.1
update:黑白名单手动添加http前缀,白名单优化 fix: add:
This commit is contained in:
@@ -29,12 +29,9 @@ import com.mjsheng.myappstore.bean.ForceDownloadBean;
|
||||
import com.mjsheng.myappstore.bean.ForceDownloadData;
|
||||
import com.mjsheng.myappstore.bean.LogoImg;
|
||||
import com.mjsheng.myappstore.bean.NetAndLaunchBean;
|
||||
import com.mjsheng.myappstore.bean.NewAppground;
|
||||
import com.mjsheng.myappstore.bean.SplitApks;
|
||||
import com.mjsheng.myappstore.bean.StudentsInfo;
|
||||
import com.mjsheng.myappstore.jpush.TagAliasOperatorHelper;
|
||||
import com.mjsheng.myappstore.manager.NetInterfaceManager;
|
||||
import com.mjsheng.myappstore.network.api.newapi.UpdateDeviceInfoApi;
|
||||
import com.mjsheng.myappstore.server.MainService;
|
||||
import com.mjsheng.myappstore.utils.ApkUtils;
|
||||
import com.mjsheng.myappstore.utils.ForegroundAppUtil;
|
||||
@@ -117,24 +114,28 @@ public class MainPresenter implements MainContact.Presenter {
|
||||
String batch = studentsInfoBaseResponse.data.getBatch();
|
||||
if (TextUtils.isEmpty(sno)) {
|
||||
mView.setNumberText("", View.GONE);
|
||||
SPUtils.put(mContext, "sno", DEFAULT_INFO);
|
||||
} else {
|
||||
mView.setNumberText(sno, View.VISIBLE);
|
||||
SPUtils.put(mContext, "sno", sno);
|
||||
}
|
||||
if (TextUtils.isEmpty(realname)) {
|
||||
mView.setNameText("", View.GONE);
|
||||
SPUtils.put(mContext, "realname", DEFAULT_INFO);
|
||||
} else {
|
||||
mView.setNameText(realname, View.VISIBLE);
|
||||
SPUtils.put(mContext, "realname", realname);
|
||||
}
|
||||
if (TextUtils.isEmpty(classes)) {
|
||||
mView.setClassText("", View.GONE);
|
||||
SPUtils.put(mContext, "classes", DEFAULT_INFO);
|
||||
} else {
|
||||
mView.setClassText(classes, View.VISIBLE);
|
||||
SPUtils.put(mContext, "classes", classes);
|
||||
}
|
||||
if (TextUtils.isEmpty(batch)) {
|
||||
mView.setBatchText("", View.GONE);
|
||||
SPUtils.put(mContext, "batch", DEFAULT_INFO);
|
||||
} else {
|
||||
mView.setBatchText(batch, View.VISIBLE);
|
||||
SPUtils.put(mContext, "batch", batch);
|
||||
@@ -1101,7 +1102,9 @@ public class MainPresenter implements MainContact.Presenter {
|
||||
|
||||
@Override
|
||||
public void getBrowserWhiteList() {
|
||||
new URLUtils(mContext).setBrowserList();
|
||||
new URLUtils(mContext).setBrowserWhiteList();
|
||||
new URLUtils(mContext).setBrowserBlackList();
|
||||
|
||||
// try {
|
||||
// int qch_website_isBlackWebUrl = Settings.System.getInt(mContext.getContentResolver(), "qch_website_isBlackWebUrl");
|
||||
// String BlackBrowserArray = Settings.System.getString(mContext.getContentResolver(), "BlackBrowserArray");
|
||||
@@ -1266,11 +1269,11 @@ public class MainPresenter implements MainContact.Presenter {
|
||||
|
||||
@Override
|
||||
public void setAppinsideWeb() {
|
||||
if (JGYUtils.isOfficialVersion()) {
|
||||
// if (JGYUtils.isOfficialVersion()) {
|
||||
getAppinsideWeb();
|
||||
} else {
|
||||
getNewAppinsideWeb();
|
||||
}
|
||||
// } else {
|
||||
// getNewAppinsideWeb();
|
||||
// }
|
||||
}
|
||||
|
||||
private void getAppinsideWeb() {
|
||||
|
||||
@@ -32,4 +32,9 @@ public class NewAppground implements Serializable {
|
||||
public void setType(int type) {
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return packages + "," + address;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -526,30 +526,33 @@ public class HTTPInterface {
|
||||
white += "," + homePage;
|
||||
}
|
||||
boolean whiteList = Settings.System.putString(context.getContentResolver(), "DeselectBrowserArray", white);
|
||||
new URLUtils(context).setBrowserList();
|
||||
new URLUtils(context).setBrowserWhiteList();
|
||||
|
||||
Log.e("SystemSetting", "setBrowserList----white-----" + whiteList + ":" + white);
|
||||
Log.e("setBrowserBlackList", "setBrowserList----white-----" + whiteList + ":" + white);
|
||||
} else {
|
||||
Settings.System.putString(context.getContentResolver(), "DeselectBrowserArray", " ");
|
||||
}
|
||||
String black = data.getString("black");
|
||||
if (!TextUtils.isEmpty(black)) {
|
||||
boolean blackList = Settings.System.putString(context.getContentResolver(), "qch_webblack_url", black);
|
||||
Log.e("SystemSetting", "setBrowserList----black-----" + blackList + ":" + black);
|
||||
Log.e("setBrowserBlackList", "setBrowserList----black-----" + blackList + ":" + black);
|
||||
new URLUtils(context).setBrowserBlackList();
|
||||
} else {
|
||||
Settings.System.putString(context.getContentResolver(), "qch_webblack_url", " ");
|
||||
}
|
||||
} else {
|
||||
Log.e("fht", "setBrowserList" + msg);
|
||||
Log.e("setBrowserBlackList", "setBrowserList" + msg);
|
||||
}
|
||||
} catch (JSONException e) {
|
||||
Log.e("fht", "setBrowserList" + e.getMessage());
|
||||
Log.e("setBrowserBlackList", "JSONException" + e.getMessage());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(Call call, Response response, Exception e) {
|
||||
super.onError(call, response, e);
|
||||
Log.e(TAG, "onError: " + e.getMessage());
|
||||
}
|
||||
});
|
||||
}
|
||||
@@ -610,7 +613,7 @@ public class HTTPInterface {
|
||||
@Override
|
||||
public void onComplete() {
|
||||
Log.e("NewSetBrowserList", "onComplete: ");
|
||||
new URLUtils(context).setBrowserList();
|
||||
new URLUtils(context).setBrowserWhiteList();
|
||||
}
|
||||
});
|
||||
}
|
||||
@@ -671,7 +674,7 @@ public class HTTPInterface {
|
||||
|
||||
@Override
|
||||
public void onComplete() {
|
||||
new URLUtils(context).setBrowserList();
|
||||
new URLUtils(context).setBrowserWhiteList();
|
||||
Log.e("SetBrowserList", "onComplete: ");
|
||||
}
|
||||
});
|
||||
@@ -830,7 +833,7 @@ public class HTTPInterface {
|
||||
if ("com.android.mms".equals(pack)) {
|
||||
pm.setApplicationEnabledSetting("com.android.messaging", PackageManager.COMPONENT_ENABLED_STATE_DISABLED, 0);
|
||||
}
|
||||
}catch (Exception ex){
|
||||
} catch (Exception ex) {
|
||||
Log.e("setHideDesktopIcon", "Exception: ex: " + ex.getMessage());
|
||||
}
|
||||
pm.setApplicationEnabledSetting(pack, PackageManager.COMPONENT_ENABLED_STATE_DISABLED, 0);
|
||||
|
||||
@@ -334,9 +334,8 @@ public class JGYUtils {
|
||||
}
|
||||
if (packageList.length() > 0) {
|
||||
//app内所有的网页禁止
|
||||
//packageList = packageList.substring(0, packageList.length() - 1);
|
||||
//去掉多余的,
|
||||
Log.e("setAppinsideWeb ", "packageList:" + packageList);
|
||||
|
||||
Log.e("setAppinsideWeb ", "packageList:" + packageList.toString());
|
||||
Intent qch_app_website = new Intent("qch_app_website")
|
||||
.setPackage("com.android.settings");
|
||||
qch_app_website.putExtra("package_name", packageList.toString());
|
||||
@@ -346,9 +345,8 @@ public class JGYUtils {
|
||||
}
|
||||
if (strings.length() > 0) {
|
||||
//app内单个网页地址禁止打开
|
||||
//strings = strings.substring(0, strings.length() - 1);
|
||||
//去掉多余的;
|
||||
Log.e("setAppinsideWeb ", "strings:" + strings);
|
||||
|
||||
Log.e("setAppinsideWeb ", "strings:" + strings.toString());
|
||||
Intent intent = new Intent("qch_app_inside_website")
|
||||
.setPackage("com.android.settings");
|
||||
intent.putExtra("websitelist", strings.toString());
|
||||
@@ -398,6 +396,7 @@ public class JGYUtils {
|
||||
}
|
||||
}
|
||||
}
|
||||
// TODO: 2021/6/9
|
||||
if (whiteList.length() > 0) {
|
||||
Intent intent = new Intent();
|
||||
intent.setAction("黑名单key");
|
||||
@@ -412,7 +411,7 @@ public class JGYUtils {
|
||||
//old
|
||||
if (packageList.length() > 0) {
|
||||
//app内所有的网页禁止
|
||||
Log.e("setAppinsideWeb ", "packageList:" + packageList);
|
||||
Log.e("setAppinsideWeb ", "packageList:" + packageList.toString());
|
||||
Intent qch_app_website = new Intent("qch_app_website")
|
||||
.setPackage("com.android.settings");
|
||||
qch_app_website.putExtra("package_name", packageList.toString());
|
||||
@@ -422,7 +421,7 @@ public class JGYUtils {
|
||||
}
|
||||
if (blackList.length() > 0) {
|
||||
//app内单个网页地址禁止打开
|
||||
Log.e("setAppinsideWeb ", "blackList:" + blackList);
|
||||
Log.e("setAppinsideWeb ", "blackList:" + blackList.toString());
|
||||
Intent intent = new Intent("qch_app_inside_website")
|
||||
.setPackage("com.android.settings");
|
||||
intent.putExtra("websitelist", blackList.toString());
|
||||
|
||||
@@ -11,6 +11,7 @@ import java.io.IOException;
|
||||
import java.net.URI;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
@@ -30,38 +31,71 @@ import okhttp3.Response;
|
||||
public class URLUtils {
|
||||
private static String TAG = URLUtils.class.getSimpleName();
|
||||
private Context mContext;
|
||||
private List<String> baseURLList = new ArrayList<>();
|
||||
private HashSet<String> baseURLList = new HashSet<>();
|
||||
|
||||
public URLUtils(Context context) {
|
||||
this.mContext = context;
|
||||
}
|
||||
|
||||
public void setBrowserList() {
|
||||
public void setBrowserWhiteList() {
|
||||
String whiteList = Settings.System.getString(mContext.getContentResolver(), "DeselectBrowserArray");
|
||||
if (TextUtils.isEmpty(whiteList)) {
|
||||
Log.e(TAG, "getBrowserWhiteList: " + "whiteList is empty");
|
||||
} else {
|
||||
List<String> URLList = Arrays.asList(whiteList.split(","));
|
||||
Log.e(TAG, "getBrowserWhiteList: " + "whiteList is : " + whiteList);
|
||||
HashSet<String> URLList = new HashSet<>(Arrays.asList(whiteList.split(",")));
|
||||
Observable.create(new ObservableOnSubscribe<String>() {
|
||||
@Override
|
||||
public void subscribe(ObservableEmitter<String> emitter) throws Exception {
|
||||
baseURLList.clear();
|
||||
baseURLList.addAll(URLList);
|
||||
for (String url : URLList) {
|
||||
if (url.startsWith("http://")) {
|
||||
String noHttp = url.substring(7);
|
||||
if (!baseURLList.contains(noHttp)) {
|
||||
baseURLList.add(noHttp);
|
||||
// if (url.startsWith("http://")) {
|
||||
// String noHttp = url.substring(7);
|
||||
// if (!baseURLList.contains(noHttp)) {
|
||||
// baseURLList.add(noHttp);
|
||||
// }
|
||||
// } else if (url.startsWith("https://")) {
|
||||
// String noHttps = url.substring(8);
|
||||
// if (!baseURLList.contains(noHttps)) {
|
||||
// baseURLList.add(noHttps);
|
||||
// }
|
||||
// }else {
|
||||
// }
|
||||
baseURLList.add(url);
|
||||
if (url.startsWith("www.")) {//前缀为www的顶级域名
|
||||
String nowww = url.substring(4);
|
||||
baseURLList.add(nowww);
|
||||
baseURLList.add("http://" + nowww);
|
||||
emitter.onNext(getOkHttpURL("http://" + nowww));
|
||||
baseURLList.add("https://" + nowww);
|
||||
emitter.onNext(getOkHttpURL("https://" + nowww));
|
||||
Log.e(TAG, "subscribe: nowww: " + nowww);
|
||||
baseURLList.add("http://" + url);
|
||||
emitter.onNext(getOkHttpURL("http://" + url));
|
||||
baseURLList.add("https://" + url);
|
||||
emitter.onNext(getOkHttpURL("https://" + url));
|
||||
} else if (getCount(url, ".") == 1) {//不带www的顶级域名
|
||||
baseURLList.add("http://www." + url);
|
||||
emitter.onNext(getOkHttpURL("http://www." + url));
|
||||
baseURLList.add("https://www." + url);
|
||||
emitter.onNext(getOkHttpURL("https://www." + url));
|
||||
baseURLList.add("http://" + url);
|
||||
emitter.onNext(getOkHttpURL("http://" + url));
|
||||
baseURLList.add("https://" + url);
|
||||
emitter.onNext(getOkHttpURL("https://" + url));
|
||||
} else if (!url.startsWith("http://") && !url.startsWith("https://")) {//没有前缀的网址
|
||||
baseURLList.add("http://" + url);
|
||||
emitter.onNext(getOkHttpURL("http://" + url));
|
||||
baseURLList.add("https://" + url);
|
||||
emitter.onNext(getOkHttpURL("https://" + url));
|
||||
} else {
|
||||
baseURLList.add(url);
|
||||
if (!TextUtils.isEmpty(url)) {
|
||||
emitter.onNext(getOkHttpURL(url));
|
||||
}
|
||||
}
|
||||
if (url.startsWith("https://")) {
|
||||
String noHttps = url.substring(8);
|
||||
if (!baseURLList.contains(noHttps)) {
|
||||
baseURLList.add(noHttps);
|
||||
}
|
||||
}
|
||||
emitter.onNext(getOkHttpURL(url));
|
||||
Log.e(TAG, "subscribe: " + url);
|
||||
// emitter.onNext(getOkHttpURL(url));
|
||||
}
|
||||
emitter.onComplete();
|
||||
}
|
||||
@@ -76,33 +110,27 @@ public class URLUtils {
|
||||
@Override
|
||||
public void onNext(String s) {
|
||||
Log.e(TAG, "onNext: " + s);
|
||||
if (!baseURLList.contains(s)) {
|
||||
baseURLList.add(s);
|
||||
}
|
||||
baseURLList.add(s);
|
||||
if (s.startsWith("http://")) {
|
||||
String noHttp = s.substring(7);
|
||||
Log.e(TAG, "onNext: noHttp: " + noHttp);
|
||||
if (!baseURLList.contains(noHttp)) {
|
||||
baseURLList.add(noHttp);
|
||||
}
|
||||
baseURLList.add(noHttp);
|
||||
}
|
||||
if (s.startsWith("https://")) {
|
||||
String noHttps = s.substring(8);
|
||||
Log.e(TAG, "onNext: noHttps: " + noHttps);
|
||||
if (!baseURLList.contains(noHttps)) {
|
||||
baseURLList.add(noHttps);
|
||||
}
|
||||
baseURLList.add(noHttps);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(Throwable e) {
|
||||
|
||||
Log.e(TAG, "onError: " + e.getMessage());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onComplete() {
|
||||
Log.e(TAG, "onComplete: ");
|
||||
Log.e(TAG, "onComplete: " + baseURLList);
|
||||
StringBuilder stringBuilder = new StringBuilder();
|
||||
for (String s : baseURLList) {
|
||||
if (stringBuilder.length() > 0) {
|
||||
@@ -111,8 +139,8 @@ public class URLUtils {
|
||||
stringBuilder.append(s);
|
||||
}
|
||||
String DeselectBrowserArray = stringBuilder.toString();
|
||||
boolean write = Settings.System.putString(mContext.getContentResolver(), "DeselectBrowserArray", DeselectBrowserArray);
|
||||
Log.e(TAG, "onComplete: " + "white list: " + DeselectBrowserArray);
|
||||
boolean write = Settings.System.putString(mContext.getContentResolver(), "DeselectBrowserArray", DeselectBrowserArray);
|
||||
Log.e(TAG, "onComplete: " + "write :" + write);
|
||||
}
|
||||
});
|
||||
@@ -120,7 +148,45 @@ public class URLUtils {
|
||||
|
||||
}
|
||||
|
||||
|
||||
private HashSet<String> blackList = new HashSet<>();
|
||||
|
||||
public void setBrowserBlackList() {
|
||||
String qch_webblack_url = Settings.System.getString(mContext.getContentResolver(), "qch_webblack_url");
|
||||
Log.e(TAG, "setBrowserBlackList: " + qch_webblack_url);
|
||||
if (TextUtils.isEmpty(qch_webblack_url.trim())) {
|
||||
return;
|
||||
}
|
||||
HashSet<String> URLList = new HashSet<>(Arrays.asList(qch_webblack_url.split(",")));
|
||||
for (String url : URLList) {
|
||||
Log.e(TAG, "setBrowserBlackList: url: " + url);
|
||||
if (qch_webblack_url.startsWith("http://")) {
|
||||
blackList.add(url);
|
||||
blackList.add(url.replace("http://", "https://"));
|
||||
} else if (qch_webblack_url.startsWith("https://")) {
|
||||
blackList.add(url);
|
||||
blackList.add(url.replace("https://", "http://"));
|
||||
} else {
|
||||
blackList.add("http://" + url);
|
||||
blackList.add("https://" + url);
|
||||
}
|
||||
}
|
||||
StringBuilder stringBuilder = new StringBuilder();
|
||||
for (String url : blackList) {
|
||||
if (stringBuilder.length() > 0) {
|
||||
stringBuilder.append(",");
|
||||
}
|
||||
stringBuilder.append(url);
|
||||
}
|
||||
Log.e(TAG, "setBrowserBlackList: blackList: " + blackList);
|
||||
boolean write = Settings.System.putString(mContext.getContentResolver(), "qch_webblack_url", stringBuilder.toString());
|
||||
Log.e(TAG, "setBrowserBlackList: write: " + write);
|
||||
}
|
||||
|
||||
private String getOkHttpURL(String URL) {
|
||||
if (!URL.startsWith("http")) {
|
||||
return "";
|
||||
}
|
||||
OkHttpClient okHttpClient = new OkHttpClient();
|
||||
final Request request = new Request.Builder()
|
||||
.url(URL)
|
||||
@@ -225,4 +291,17 @@ public class URLUtils {
|
||||
}
|
||||
return sb.toString();
|
||||
}
|
||||
|
||||
public int getCount(String str, String key) {
|
||||
if (str == null || key == null || "".equals(str.trim()) || "".equals(key.trim())) {
|
||||
return 0;
|
||||
}
|
||||
int count = 0;
|
||||
int index = 0;
|
||||
while ((index = str.indexOf(key, index)) != -1) {
|
||||
index = index + key.length();
|
||||
count++;
|
||||
}
|
||||
return count;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user