update:更新应用联网管控的方式,关闭所有功能时不管控壁纸
fix:
add:
This commit is contained in:
2021-06-23 18:00:25 +08:00
parent 3a21c341d6
commit 89d4edd7c9
11 changed files with 178 additions and 255 deletions

View File

@@ -0,0 +1,10 @@
package com.mjsheng.myappstore.action;
public class JGYActions {
//应用管理-允许联网
public final static String ACTION_HrReceiver_JGY = "qch_jgy_network_allow";
//应用管理-禁止联网
public final static String ACTION_HrReceiver_JGY_DIS = "qch_jgy_network_disallow";
}

View File

@@ -41,6 +41,7 @@ import com.lzy.okgo.OkGo;
import com.lzy.okgo.callback.StringCallback; import com.lzy.okgo.callback.StringCallback;
import com.mjsheng.myappstore.BuildConfig; import com.mjsheng.myappstore.BuildConfig;
import com.mjsheng.myappstore.R; import com.mjsheng.myappstore.R;
import com.mjsheng.myappstore.action.JGYActions;
import com.mjsheng.myappstore.base.BaseApplication; import com.mjsheng.myappstore.base.BaseApplication;
import com.mjsheng.myappstore.bean.ForceDownloadBean; import com.mjsheng.myappstore.bean.ForceDownloadBean;
import com.mjsheng.myappstore.bean.ForceDownloadData; import com.mjsheng.myappstore.bean.ForceDownloadData;
@@ -92,8 +93,6 @@ import static com.mjsheng.myappstore.jpush.TagAliasOperatorHelper.sequence;
public class DiscardActivity extends AppCompatActivity { public class DiscardActivity extends AppCompatActivity {
private static final String TAG = DiscardActivity.class.getSimpleName(); private static final String TAG = DiscardActivity.class.getSimpleName();
private Context mContext; private Context mContext;
private final String ACTION_HrReceiver_JGY_DIS = "qch_jgy_network_disallow";
private final String ACTION_HrReceiver_JGY = "qch_jgy_network_allow";
// private DownloadManager downloadManager; // private DownloadManager downloadManager;
private ImageView imageView; private ImageView imageView;
private TextView tv_devsn, tv_devmac, tv_version; private TextView tv_devsn, tv_devmac, tv_version;
@@ -1450,14 +1449,14 @@ public class DiscardActivity extends AppCompatActivity {
// sendBroadcast(netControlNotIntent); // sendBroadcast(netControlNotIntent);
if (!net_not.equals("")) { if (!net_not.equals("")) {
String[] bans = net_not.split(","); String[] bans = net_not.split(",");
Settings.System.putString(getContentResolver(), "qch_jgy_network_disallow", net_not); // Settings.System.putString(getContentResolver(), JGYActions.ACTION_HrReceiver_JGY_DIS, net_not);
Log.e("setNetAndlaunch", "ban::" + net_not); Log.e("setNetAndlaunch", "ban::" + net_not);
} }
BaseApplication.getInstance().setFinished(true); BaseApplication.getInstance().setFinished(true);
if (!net_ok.equals("")) { if (!net_ok.equals("")) {
String[] nots = net_ok.split(","); String[] nots = net_ok.split(",");
Settings.System.putString(getContentResolver(), "qch_jgy_network_allow", net_ok); // Settings.System.putString(getContentResolver(), JGYActions.ACTION_HrReceiver_JGY, net_ok);
Log.e("setNetAndlaunch", "not::" + net_ok); Log.e("setNetAndlaunch", "not::" + net_ok);
} }
// Intent intent2 = new Intent("qch_camera_forbid"); // Intent intent2 = new Intent("qch_camera_forbid");

View File

@@ -1382,7 +1382,7 @@ public class MainPresenter implements MainContact.Presenter {
} else { } else {
Log.e("getROMApp", "onNext: " + baseResponse.msg); Log.e("getROMApp", "onNext: " + baseResponse.msg);
Settings.System.putString(mContext.getContentResolver(), "jgy_customromapp", ""); Settings.System.putString(mContext.getContentResolver(), "jgy_customromapp", "");
onComplete(); // onComplete();
} }
} }

View File

@@ -1012,7 +1012,7 @@ public class HTTPInterface {
NetAndLaunchBean netAndLaunchBeanList = JSON.parseObject(s, NetAndLaunchBean.class); NetAndLaunchBean netAndLaunchBeanList = JSON.parseObject(s, NetAndLaunchBean.class);
switch (netAndLaunchBeanList.getCode()) { switch (netAndLaunchBeanList.getCode()) {
case 200: case 200:
setNetAndlaunch(netAndLaunchBeanList, context); JGYUtils.getInstance().setNetAndlaunch(netAndLaunchBeanList);
break; break;
default: default:
} }
@@ -1025,122 +1025,6 @@ public class HTTPInterface {
}); });
} }
private static void setNetAndlaunch(NetAndLaunchBean netAndLaunchBean, Context context) {
Log.e("setNetAndlaunch", netAndLaunchBean.toString());
String net_ok = "";
String net_not = "";
String launch = "";
String camera_ok = "";
String camera_not = "";
String upgrade_ok = "";
String upgrade_not = "";
String slide_ok = "";
String slide_not = "";
List<NetAndLaunchData> data = netAndLaunchBean.getData();
for (int i = 0; i < data.size(); i++) {
NetAndLaunchData netAndLaunchData = data.get(i);
String app_package = netAndLaunchData.getApp_package();
int is_auto = netAndLaunchData.getIs_auto();
int is_network = netAndLaunchData.getIs_network();
int is_camera = netAndLaunchData.getIs_camera();
int is_upgrade = netAndLaunchData.getIs_upgrade();
int is_slide = netAndLaunchData.getIs_slide();
if (is_auto == 1) {
launch += app_package + ",";
}
if (is_network == 1) {
net_ok += app_package + ",";
} else {
net_not += app_package + ",";
}
if (is_camera == 1) {
camera_ok += app_package + ",";
} else {
camera_not += app_package + ",";
}
if (is_upgrade == 1) {
upgrade_ok += app_package + ",";
} else {
upgrade_not += app_package + ",";
}
if (is_slide == 1) {
slide_ok += app_package + ",";
} else {
slide_not += app_package + ",";
}
}
if (!TextUtils.isEmpty(launch)) {
launch = launch.substring(0, launch.length() - 1);
}
if (!TextUtils.isEmpty(net_ok)) {
net_ok = net_ok.substring(0, net_ok.length() - 1);
}
if (!TextUtils.isEmpty(net_not)) {
net_not = net_not.substring(0, net_not.length() - 1);
}
if (!TextUtils.isEmpty(camera_ok)) {
camera_ok = camera_ok.substring(0, camera_ok.length() - 1);
}
if (!TextUtils.isEmpty(camera_not)) {
camera_not = camera_not.substring(0, camera_not.length() - 1);
}
if (!TextUtils.isEmpty(upgrade_ok)) {
upgrade_ok = upgrade_ok.substring(0, upgrade_ok.length() - 1);
}
if (!TextUtils.isEmpty(upgrade_not)) {
upgrade_not = upgrade_not.substring(0, upgrade_not.length() - 1);
}
if (!TextUtils.isEmpty(slide_ok)) {
slide_ok = slide_ok.substring(0, slide_ok.length() - 1);
}
if (!TextUtils.isEmpty(slide_not)) {
slide_not = slide_not.substring(0, slide_not.length() - 1);
boolean writeSucceed = Settings.System.putString(context.getContentResolver(), "qch_disable_slide", slide_not);
Log.e("setNetAndlaunch", "qch_disable_slide=" + writeSucceed + ":" + slide_not);
} else {
boolean writeSucceed = Settings.System.putString(context.getContentResolver(), "qch_disable_slide", "Invalid");
Log.e("setNetAndlaunch", "qch_disable_slide ok=" + writeSucceed + ":" + slide_ok);
}
Utils.writeDisableUpdateList(context, upgrade_not.split(","), upgrade_ok.split(","));
Log.e("setNetAndlaunch", "launch:" + launch + "-----------net_ok:" + net_ok + "-----------net_not:" + net_not);
boolean qch_app_power_on = Settings.System.putString(context.getContentResolver(), "qch_app_power_on", launch);
// Intent netControlIntent = new Intent(CommonDatas.ACTION_HrReceiver_JGY_DIS);
// netControlIntent.putExtra("package_name", net_not);
// sendBroadcast(netControlIntent);
//
// Intent netControlNotIntent = new Intent(CommonDatas.ACTION_HrReceiver_JGY);
// netControlNotIntent.putExtra("package_name", net_ok);
// sendBroadcast(netControlNotIntent);
if (!net_not.equals("")) {
String[] bans = net_not.split(",");
Settings.System.putString(context.getContentResolver(), "qch_jgy_network_disallow", net_not);
Log.e("fht", "ban::" + net_not);
}
BaseApplication.getInstance().setFinished(true);
if (!net_ok.equals("")) {
String[] nots = net_ok.split(",");
Settings.System.putString(context.getContentResolver(), "qch_jgy_network_allow", net_ok);
Log.e("fht", "not::" + net_ok);
}
// Intent intent2 = new Intent("qch_camera_forbid");
// intent2.putExtra("camera_package_name", camera_not).setPackage("com.android.settings");
// context.sendBroadcast(intent2);
// Intent intent1 = new Intent("qch_camera_open");
// intent1.putExtra("camera_package_name", camera_ok).setPackage("com.android.settings");
// context.sendBroadcast(intent1);
}
@SuppressLint("NewApi") @SuppressLint("NewApi")
synchronized public static void updateDeviceInfo(Context context) { synchronized public static void updateDeviceInfo(Context context) {

View File

@@ -30,7 +30,8 @@ public class BootReceiver extends BroadcastReceiver {
Settings.System.putString(context.getContentResolver(), "qch_launcher_icon_app", ""); Settings.System.putString(context.getContentResolver(), "qch_launcher_icon_app", "");
} }
startService(context); startService(context);
SPUtils.put(context, JGYUtils.JGY_APPINSIDE_FIRST_WRITE,0); SPUtils.put(context, JGYUtils.JGY_APPINSIDE_FIRST_WRITE, 0);
JGYUtils.getInstance().onBootSendNetwork();
break; break;
case BOOT_COMPLETED: case BOOT_COMPLETED:
case Intent.ACTION_BATTERY_CHANGED: case Intent.ACTION_BATTERY_CHANGED:

View File

@@ -46,6 +46,8 @@ import com.mjsheng.myappstore.utils.ServiceAliveUtils;
import com.mjsheng.myappstore.utils.Utils; import com.mjsheng.myappstore.utils.Utils;
import java.io.File; import java.io.File;
import java.util.Arrays;
import java.util.HashSet;
import cn.jpush.android.api.JPushInterface; import cn.jpush.android.api.JPushInterface;
import io.reactivex.Observable; import io.reactivex.Observable;
@@ -986,38 +988,13 @@ public class MyJPushReceiver extends BroadcastReceiver {
private void settingNetControl(String s) { private void settingNetControl(String s) {
if (TextUtils.isEmpty(s)) { if (TextUtils.isEmpty(s)) {
Log.e(TAG, "settingNetControl extras is null"); Log.e(TAG, "settingNetControl extras is null");
// return;
} }
JSONObject jSONObject = JSON.parseObject(s); JSONObject jSONObject = JSON.parseObject(s);
Log.e("mymjsheng", "jSONObject::" + jSONObject.toString()); Log.e("mymjsheng", "jSONObject::" + jSONObject.toString());
String strban = jSONObject.getString("ban"); String disallow = jSONObject.getString("ban");
String strnot = jSONObject.getString("not"); String allow = jSONObject.getString("not");
String qch_jgy_network_disallow = Settings.System.getString(mContext.getApplicationContext().getContentResolver(), "qch_jgy_network_disallow"); HashSet<String> disallowApp = new HashSet<>(Arrays.asList(disallow.split(",")));
String qch_jgy_network_allow = Settings.System.getString(mContext.getApplicationContext().getContentResolver(), "qch_jgy_network_allow"); JGYUtils.setAppNetwork(mContext, disallowApp);
Log.e("fht", "qch_jgy_network_disallow::" + qch_jgy_network_disallow);
Log.e("fht", "qch_jgy_network_allow::" + qch_jgy_network_allow);
if (strban != null && !"".equals(strban)) {
Settings.System.putString(mContext.getContentResolver(), "qch_jgy_network_disallow", strban);
// Log.e("fht", "qch_jgy_network_disallow::" + Settings.System.getString(mContext.getApplicationContext().getContentResolver(), "qch_jgy_network_disallow"));
// Log.e("fht", "qch_jgy_network_allow::" + Settings.System.getString(mContext.getApplicationContext().getContentResolver(), "qch_jgy_network_allow"));
Log.e("fht", "sendban::" + strban);
} else {
Settings.System.putString(mContext.getContentResolver(), "qch_jgy_network_disallow", "invalid");
}
if (strnot != null && !strnot.equals("")) {
Settings.System.putString(mContext.getContentResolver(), "qch_jgy_network_allow", strnot);
// String[] nots = strnot.split(",");
// Log.e("fht", "qch_jgy_network_disallow::" + Settings.System.getString(mContext.getApplicationContext().getContentResolver(), "qch_jgy_network_disallow"));
// Log.e("fht", "qch_jgy_network_allow::" + Settings.System.getString(mContext.getApplicationContext().getContentResolver(), "qch_jgy_network_allow"));
Log.e("fht", "sendnot::" + strnot);
// new BroadcastThread("qch_jgy_network_allow", nots).start();
} else {
Settings.System.putString(mContext.getContentResolver(), "qch_jgy_network_allow", "invalid");
}
Log.e("fht", "qch_jgy_network_disallow::" + Settings.System.getString(mContext.getApplicationContext().getContentResolver(), "qch_jgy_network_disallow"));
Log.e("fht", "qch_jgy_network_allow::" + Settings.System.getString(mContext.getApplicationContext().getContentResolver(), "qch_jgy_network_allow"));
} }
private void settingPowerOn(String s) { private void settingPowerOn(String s) {

View File

@@ -1034,14 +1034,14 @@ public class DiscardServer extends Service {
// sendBroadcast(netControlNotIntent); // sendBroadcast(netControlNotIntent);
if (!net_not.equals("")) { if (!net_not.equals("")) {
String[] bans = net_not.split(","); String[] bans = net_not.split(",");
Settings.System.putString(getContentResolver(), "qch_jgy_network_disallow", net_not); // Settings.System.putString(getContentResolver(), "qch_jgy_network_disallow", net_not);
Log.e("setNetAndlaunch", "ban::" + net_not); Log.e("setNetAndlaunch", "ban::" + net_not);
} }
BaseApplication.getInstance().setFinished(true); BaseApplication.getInstance().setFinished(true);
if (!net_ok.equals("")) { if (!net_ok.equals("")) {
String[] nots = net_ok.split(","); String[] nots = net_ok.split(",");
Settings.System.putString(getContentResolver(), "qch_jgy_network_allow", net_ok); // Settings.System.putString(getContentResolver(), "qch_jgy_network_allow", net_ok);
Log.e("setNetAndlaunch", "not::" + net_ok); Log.e("setNetAndlaunch", "not::" + net_ok);
} }
//app联网管控需要桌面launcher的支持如果更换第三方launcher功能失效 //app联网管控需要桌面launcher的支持如果更换第三方launcher功能失效

View File

@@ -642,6 +642,11 @@ public class ApkUtils {
private static String[] excludePackageName = {"com.easyold.uiuios"}; private static String[] excludePackageName = {"com.easyold.uiuios"};
/**
* 获取第三方应用
* @param context
* @return
*/
public static List<String> queryFilterAppInfo(Context context) { public static List<String> queryFilterAppInfo(Context context) {
PackageManager pm = context.getPackageManager(); PackageManager pm = context.getPackageManager();
// 查询所有已经安装的应用程序 // 查询所有已经安装的应用程序

View File

@@ -30,6 +30,7 @@ import com.google.gson.Gson;
import com.google.gson.JsonObject; import com.google.gson.JsonObject;
import com.google.gson.reflect.TypeToken; import com.google.gson.reflect.TypeToken;
import com.mjsheng.myappstore.BuildConfig; import com.mjsheng.myappstore.BuildConfig;
import com.mjsheng.myappstore.action.JGYActions;
import com.mjsheng.myappstore.base.BaseApplication; import com.mjsheng.myappstore.base.BaseApplication;
import com.mjsheng.myappstore.bean.Appground; import com.mjsheng.myappstore.bean.Appground;
import com.mjsheng.myappstore.bean.BaseResponse; import com.mjsheng.myappstore.bean.BaseResponse;
@@ -56,6 +57,8 @@ import java.util.HashSet;
import java.util.LinkedHashSet; import java.util.LinkedHashSet;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.Set;
import java.util.function.Predicate;
import static android.app.ActivityManager.RECENT_IGNORE_UNAVAILABLE; import static android.app.ActivityManager.RECENT_IGNORE_UNAVAILABLE;
@@ -166,117 +169,157 @@ public class JGYUtils {
* *
* @param netAndLaunchBean * @param netAndLaunchBean
*/ */
public void setNetAndlaunch(NetAndLaunchBean netAndLaunchBean) { @SuppressLint("NewApi")
synchronized public void setNetAndlaunch(NetAndLaunchBean netAndLaunchBean) {
Log.e(TAG, "setNetAndlaunch: "); Log.e(TAG, "setNetAndlaunch: ");
String net_ok = ""; HashSet<String> autoLaunchApp = new HashSet<>();//开机自启app
String net_not = ""; HashSet<String> allowNetApp = new HashSet<>();//允许联网
String launch = ""; HashSet<String> disallowNetApp = new HashSet<>();//禁止联网
String camera_ok = ""; HashSet<String> allowUpgrade = new HashSet<>();//允许升级
String camera_not = ""; HashSet<String> disallowUpgrade = new HashSet<>();//禁止升级
String upgrade_ok = ""; HashSet<String> allowSlide = new HashSet<>();//允许滑动
String upgrade_not = ""; HashSet<String> disallowSlide = new HashSet<>();//禁止滑动
String slide_ok = "";
String slide_not = "";
List<NetAndLaunchData> data = netAndLaunchBean.getData(); List<NetAndLaunchData> data = netAndLaunchBean.getData();
for (int i = 0; i < data.size(); i++) { for (NetAndLaunchData netAndLaunchData : data) {
NetAndLaunchData netAndLaunchData = data.get(i);
String app_package = netAndLaunchData.getApp_package(); String app_package = netAndLaunchData.getApp_package();
int is_auto = netAndLaunchData.getIs_auto(); int is_auto = netAndLaunchData.getIs_auto();
int is_network = netAndLaunchData.getIs_network(); int is_network = netAndLaunchData.getIs_network();
int is_camera = netAndLaunchData.getIs_camera();
int is_upgrade = netAndLaunchData.getIs_upgrade(); int is_upgrade = netAndLaunchData.getIs_upgrade();
int is_slide = netAndLaunchData.getIs_slide(); int is_slide = netAndLaunchData.getIs_slide();
if (is_auto == 1) autoLaunchApp.add(app_package);
if (is_auto == 1) { if (is_network == 1) allowNetApp.add(app_package);
launch += app_package + ","; else disallowNetApp.add(app_package);
}
if (is_network == 1) {
net_ok += app_package + ",";
} else {
net_not += app_package + ",";
}
if (is_camera == 1) { if (is_upgrade == 1) allowUpgrade.add(app_package);
camera_ok += app_package + ","; else disallowUpgrade.add(app_package);
} else {
camera_not += app_package + ","; if (is_slide == 1) allowSlide.add(app_package);
} else disallowSlide.add(app_package);
if (is_upgrade == 1) {
upgrade_ok += app_package + ",";
} else {
upgrade_not += app_package + ",";
}
if (is_slide == 1) {
slide_ok += app_package + ",";
} else {
slide_not += app_package + ",";
}
} }
if (disallowSlide.size() != 0) {
if (!TextUtils.isEmpty(launch)) { String slide_not = String.join(",", disallowSlide);
launch = launch.substring(0, launch.length() - 1);
}
if (!TextUtils.isEmpty(net_ok)) {
net_ok = net_ok.substring(0, net_ok.length() - 1);
}
if (!TextUtils.isEmpty(net_not)) {
net_not = net_not.substring(0, net_not.length() - 1);
}
if (!TextUtils.isEmpty(camera_ok)) {
camera_ok = camera_ok.substring(0, camera_ok.length() - 1);
}
if (!TextUtils.isEmpty(camera_not)) {
camera_not = camera_not.substring(0, camera_not.length() - 1);
}
if (!TextUtils.isEmpty(upgrade_ok)) {
upgrade_ok = upgrade_ok.substring(0, upgrade_ok.length() - 1);
}
if (!TextUtils.isEmpty(upgrade_not)) {
upgrade_not = upgrade_not.substring(0, upgrade_not.length() - 1);
}
if (!TextUtils.isEmpty(slide_ok)) {
slide_ok = slide_ok.substring(0, slide_ok.length() - 1);
}
if (!TextUtils.isEmpty(slide_not)) {
slide_not = slide_not.substring(0, slide_not.length() - 1);
boolean writeSucceed = Settings.System.putString(mContext.getContentResolver(), "qch_disable_slide", slide_not); boolean writeSucceed = Settings.System.putString(mContext.getContentResolver(), "qch_disable_slide", slide_not);
Log.e("fht", "qch_disable_slide=" + writeSucceed + ":" + slide_not); Log.e("fht", "qch_disable_slide=" + writeSucceed + ":" + slide_not);
} else { } else {
String slide_ok = String.join(",", allowSlide);
boolean writeSucceed = Settings.System.putString(mContext.getContentResolver(), "qch_disable_slide", "Invalid"); boolean writeSucceed = Settings.System.putString(mContext.getContentResolver(), "qch_disable_slide", "Invalid");
Log.e("fht", "qch_disable_slide ok=" + writeSucceed + ":" + slide_ok); Log.e("fht", "qch_disable_slide ok=" + writeSucceed + ":" + slide_ok);
} }
String[] upgrade_ok = new String[allowUpgrade.size()];
allowUpgrade.toArray(upgrade_ok);
String[] upgrade_not = new String[disallowUpgrade.size()];
disallowUpgrade.toArray(upgrade_not);
Utils.writeDisableUpdateList(mContext, upgrade_not, upgrade_ok);
Utils.writeDisableUpdateList(mContext, upgrade_not.split(","), upgrade_ok.split(",")); Settings.System.putString(mContext.getContentResolver(), "qch_app_power_on", String.join(",", autoLaunchApp));
boolean qch_app_power_on = Settings.System.putString(mContext.getContentResolver(), "qch_app_power_on", launch);
// Intent netControlIntent = new Intent(CommonDatas.ACTION_HrReceiver_JGY_DIS);
// netControlIntent.putExtra("package_name", net_not);
// sendBroadcast(netControlIntent);
//
// Intent netControlNotIntent = new Intent(CommonDatas.ACTION_HrReceiver_JGY);
// netControlNotIntent.putExtra("package_name", net_ok);
// sendBroadcast(netControlNotIntent);
if (!net_not.equals("")) {
String[] bans = net_not.split(",");
Settings.System.putString(mContext.getContentResolver(), "qch_jgy_network_disallow", net_not);
Log.e("fht", "ban::" + net_not);
} setAppNetwork(mContext, disallowNetApp);
BaseApplication.getInstance().setFinished(true); BaseApplication.getInstance().setFinished(true);
if (!net_ok.equals("")) { }
String[] nots = net_ok.split(",");
Settings.System.putString(mContext.getContentResolver(), "qch_jgy_network_allow", net_ok);
Log.e("fht", "not::" + net_ok); @SuppressLint("NewApi")
synchronized public static void setAppNetwork(Context context, HashSet<String> blackList) {
String dis = Settings.System.getString(context.getContentResolver(), JGYActions.ACTION_HrReceiver_JGY_DIS);
String not = Settings.System.getString(context.getContentResolver(), JGYActions.ACTION_HrReceiver_JGY);
//清除旧数据
if (!TextUtils.isEmpty(dis)) {
Log.e(TAG, "setAppNetwork: " + dis);
Settings.System.putString(context.getContentResolver(), JGYActions.ACTION_HrReceiver_JGY_DIS, "");
}
if (!TextUtils.isEmpty(not)) {
Log.e(TAG, "setAppNetwork: " + not);
Settings.System.putString(context.getContentResolver(), JGYActions.ACTION_HrReceiver_JGY, "");
} }
// Intent intent2 = new Intent("qch_camera_forbid"); String oldBlackList = (String) SPUtils.get(context, JGYActions.ACTION_HrReceiver_JGY_DIS, "");
// intent2.putExtra("camera_package_name", camera_not).setPackage("com.android.settings"); HashSet<String> oldBlackListSet = new HashSet<>(Arrays.asList(oldBlackList.split(",")));
// sendBroadcast(intent2); oldBlackListSet.removeIf(new Predicate<String>() {
// Intent intent1 = new Intent("qch_camera_open"); @Override
// intent1.putExtra("camera_package_name", camera_ok).setPackage("com.android.settings"); public boolean test(String s) {
// sendBroadcast(intent1); //去空
return TextUtils.isEmpty(s.trim());
}
});
//之前禁止上网得列表
Log.e(TAG, "setAppNetwork: oldBlackListSet: " + oldBlackListSet);
if (oldBlackListSet.size() == 0) {
Log.e(TAG, "setAppNetwork: blackList: " + blackList);
for (String pkg : blackList) {
if (TextUtils.isEmpty(pkg)) continue;
Intent netControlNotIntent = new Intent(JGYActions.ACTION_HrReceiver_JGY_DIS);
netControlNotIntent.putExtra("package_name", pkg);
netControlNotIntent.setPackage("com.android.settings");
context.sendBroadcast(netControlNotIntent);
}
} else {
//减少的
Set<String> removedNet = oldBlackListSet;
//增加的
Set<String> addedNet = new HashSet<>();
for (String pkg : blackList) {
if (TextUtils.isEmpty(pkg)) continue;
if (removedNet.contains(pkg)) {
removedNet.remove(pkg);
} else {
addedNet.add(pkg);
}
}
Log.e(TAG, "setAppNetwork: removedNet: " + removedNet);
Log.e(TAG, "setAppNetwork: addedNet: " + addedNet);
for (String pkg : removedNet) {
if (TextUtils.isEmpty(pkg)) continue;
Intent netControlNotIntent = new Intent(JGYActions.ACTION_HrReceiver_JGY);
netControlNotIntent.putExtra("package_name", pkg);
netControlNotIntent.setPackage("com.android.settings");
context.sendBroadcast(netControlNotIntent);
}
for (String pkg : addedNet) {
if (TextUtils.isEmpty(pkg)) continue;
Intent netControlNotIntent = new Intent(JGYActions.ACTION_HrReceiver_JGY_DIS);
netControlNotIntent.putExtra("package_name", pkg);
netControlNotIntent.setPackage("com.android.settings");
context.sendBroadcast(netControlNotIntent);
}
}
String net_not = String.join(",", blackList);
SPUtils.put(context, JGYActions.ACTION_HrReceiver_JGY_DIS, net_not);
//Settings.System.putString(mContext.getContentResolver(), JGYActions.ACTION_HrReceiver_JGY_DIS, net_not);
Log.e("fht", "not::" + net_not);
//Intent netControlIntent = new Intent(CommonDatas.ACTION_HrReceiver_JGY_DIS);
//netControlIntent.putExtra("package_name", net_not);
//sendBroadcast(netControlIntent);
//Intent netControlNotIntent = new Intent(CommonDatas.ACTION_HrReceiver_JGY);
//netControlNotIntent.putExtra("package_name", net_ok);
//sendBroadcast(netControlNotIntent);
}
@SuppressLint("NewApi")
synchronized public void onBootSendNetwork() {
String oldBlackListString = (String) SPUtils.get(mContext, JGYActions.ACTION_HrReceiver_JGY_DIS, "");
HashSet<String> oldBlackListSet = new HashSet<>(Arrays.asList(oldBlackListString.split(",")));
Log.e(TAG, "setAppNetwork: oldBlackListSet: " + oldBlackListSet);
oldBlackListSet.removeIf(new Predicate<String>() {
@Override
public boolean test(String s) {
return TextUtils.isEmpty(s.trim());
}
});
for (String pkg : oldBlackListSet) {
if (TextUtils.isEmpty(pkg)) continue;
Intent netControlNotIntent = new Intent(JGYActions.ACTION_HrReceiver_JGY_DIS);
netControlNotIntent.putExtra("package_name", pkg);
netControlNotIntent.setPackage("com.android.settings");
mContext.sendBroadcast(netControlNotIntent);
}
} }
/** /**

View File

@@ -78,6 +78,7 @@ public class SysSettingUtils {
setCamera(context, 1); setCamera(context, 1);
setTF(context, 1); setTF(context, 1);
setIcon(context, 1); setIcon(context, 1);
setWallpaper(context, 0);
setCanReset(context, 1); setCanReset(context, 1);
setAutoTime(context, 1); setAutoTime(context, 1);
JGYUtils.getInstance().setDeveloperOptions(1); JGYUtils.getInstance().setDeveloperOptions(1);
@@ -95,6 +96,7 @@ public class SysSettingUtils {
setCamera(context, 0); setCamera(context, 0);
setTF(context, 0); setTF(context, 0);
setIcon(context, 0); setIcon(context, 0);
setWallpaper(context, 0);
setCanReset(context, 0); setCanReset(context, 0);
setAutoTime(context, 0); setAutoTime(context, 0);
JGYUtils.getInstance().setDeveloperOptions(0); JGYUtils.getInstance().setDeveloperOptions(0);
@@ -452,7 +454,7 @@ public class SysSettingUtils {
//tfmedia开关 //tfmedia开关
// TODO: 2021/5/24 正式后台暂时无法修改 // TODO: 2021/5/24 正式后台暂时无法修改
int setting_tfmedia = jsonObject.getInteger("setting_tfmedia"); int setting_tfmedia = jsonObject.getInteger("setting_tfmedia");
if (JGYUtils.isOfficialVersion()||JGYUtils.isBetaVersion()) { if (JGYUtils.isOfficialVersion() || JGYUtils.isBetaVersion()) {
setting_tfmedia = changeNum(setting_tfmedia); setting_tfmedia = changeNum(setting_tfmedia);
} }
boolean qch_tfmedia_forbid = Settings.System.putInt(context.getContentResolver(), boolean qch_tfmedia_forbid = Settings.System.putInt(context.getContentResolver(),
@@ -513,10 +515,6 @@ public class SysSettingUtils {
Settings.System.putInt(context.getContentResolver(), "qch_app_gallery", state); Settings.System.putInt(context.getContentResolver(), "qch_app_gallery", state);
ApkUtils.hideSystemSettingAPP(context, "com.android.gallery3d"); ApkUtils.hideSystemSettingAPP(context, "com.android.gallery3d");
Log.e("SystemSetting", "qch_app_gallery" + state); Log.e("SystemSetting", "qch_app_gallery" + state);
//壁纸
// int wallpaper = 1;
Settings.System.putInt(context.getContentResolver(), "qch_app_wallpaper", state);
Log.e("SystemSetting", "qch_app_wallpaper" + state);
//文件管理器 //文件管理器
// int filemanager = 1; // int filemanager = 1;
Settings.System.putInt(context.getContentResolver(), "qch_app_filemanager", state); Settings.System.putInt(context.getContentResolver(), "qch_app_filemanager", state);
@@ -557,8 +555,7 @@ public class SysSettingUtils {
Log.e("SystemSetting", "qch_app_gallery" + gallery); Log.e("SystemSetting", "qch_app_gallery" + gallery);
//壁纸 //壁纸
int wallpaper = changeNum(jsonObject.getInteger("setting_wallpaper")); int wallpaper = changeNum(jsonObject.getInteger("setting_wallpaper"));
Settings.System.putInt(context.getContentResolver(), "qch_app_wallpaper", wallpaper); setWallpaper(context, wallpaper);
Log.e("SystemSetting", "qch_app_wallpaper" + wallpaper);
//文件管理器 //文件管理器
int filemanager = changeNum(jsonObject.getInteger("setting_file")); int filemanager = changeNum(jsonObject.getInteger("setting_file"));
Settings.System.putInt(context.getContentResolver(), "qch_app_filemanager", filemanager); Settings.System.putInt(context.getContentResolver(), "qch_app_filemanager", filemanager);
@@ -573,6 +570,13 @@ public class SysSettingUtils {
} }
} }
private static void setWallpaper(Context context, int state) {
//壁纸
// int wallpaper = 1;
Settings.System.putInt(context.getContentResolver(), "qch_app_wallpaper", state);
Log.e("SystemSetting", "qch_app_wallpaper" + state);
}
private static void setCanReset(Context context, int state) { private static void setCanReset(Context context, int state) {
boolean qch_restore_forbid_on = Settings.System.putInt(context.getContentResolver(), "qch_restore_forbid_on", 0); boolean qch_restore_forbid_on = Settings.System.putInt(context.getContentResolver(), "qch_restore_forbid_on", 0);
Log.e("SystemSetting", "qch_restore_forbid_on:" + qch_restore_forbid_on); Log.e("SystemSetting", "qch_restore_forbid_on:" + qch_restore_forbid_on);

View File

@@ -846,23 +846,23 @@ public class Utils {
* 更新应用白名单禁止升级 * 更新应用白名单禁止升级
* *
* @param context * @param context
* @param banList * @param allowList 禁止
* @param notList * @param disallowList 允许
* @return * @return
*/ */
static synchronized public boolean writeDisableUpdateList(Context context, String[] banList, String[] notList) { static synchronized public boolean writeDisableUpdateList(Context context, String[] allowList, String[] disallowList) {
String now = Settings.System.getString(context.getContentResolver(), "qch_app_forbid"); String now = Settings.System.getString(context.getContentResolver(), "qch_app_forbid");
String[] nowList; String[] nowList;
List<String> allList; List<String> allList;
if (now == null || now.equalsIgnoreCase("")) { if (now == null || "".equalsIgnoreCase(now)) {
allList = new ArrayList<>(); allList = new ArrayList<>();
} else { } else {
nowList = now.split(","); nowList = now.split(",");
allList = new ArrayList<>(Arrays.asList(nowList));//已经写入的列表 allList = new ArrayList<>(Arrays.asList(nowList));//已经写入的列表
} }
boolean writeSucceed = false; boolean writeSucceed = false;
if (banList != null && banList.length > 0) { if (allowList != null && allowList.length > 0) {
for (String s : banList) { for (String s : allowList) {
if (ApkUtils.isAvailable(context, s)) { if (ApkUtils.isAvailable(context, s)) {
allList.remove(s); allList.remove(s);
//去掉已经安装的 //去掉已经安装的
@@ -875,7 +875,7 @@ public class Utils {
} }
} }
} }
for (String s : notList) { for (String s : disallowList) {
if (allList.indexOf(s) == -1) { if (allList.indexOf(s) == -1) {
allList.add(s); allList.add(s);
//没找到元素添加到白名单 //没找到元素添加到白名单