version:2.1.8

update:删除不用的数据,开机发送白名单管控
fix:修复qch_app_power_on为空时设备断网,修复开机动画不能写入bug,
add:
This commit is contained in:
2021-07-02 18:04:10 +08:00
parent 89d4edd7c9
commit e38530fd81
18 changed files with 232 additions and 3600 deletions

View File

@@ -5,6 +5,7 @@ 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";
//
public final static String ACTION_StatusBar_STATUS = "jgy_statusbar_status";
}

View File

@@ -196,6 +196,7 @@ public class MainActivity extends BaseActivity implements MainContact.MainView {
public void setLockedState(boolean loocked) {
if (loocked) {
iv_locked.setVisibility(View.VISIBLE);
iv_locked.setImageDrawable(getDrawable(R.drawable.locked));
//上传APP信息
ApkUtils.getAppInfo(this);
if (netWorkIsRunning || MainService.netWorkIsRunning) {
@@ -211,7 +212,8 @@ public class MainActivity extends BaseActivity implements MainContact.MainView {
mPresenter.getSystemSettingbegin();
netWorkIsRunning = true;
} else {
iv_locked.setVisibility(View.GONE);
iv_locked.setVisibility(View.VISIBLE);
iv_locked.setImageDrawable(getDrawable(R.drawable.unlock));
netWorkIsRunning = false;
SysSettingUtils.setEnableSetting(this);
}

View File

@@ -105,7 +105,7 @@ public class MainPresenter implements MainContact.Presenter {
@Override
public void onNext(@NonNull BaseResponse<StudentsInfo> studentsInfoBaseResponse) {
Log.e("getStudesInfo", "onNext: ");
Log.e("getStudesInfo", "onNext: " + studentsInfoBaseResponse.data);
if (studentsInfoBaseResponse.code == OK) {
String sno = studentsInfoBaseResponse.data.getSno();
String realname = studentsInfoBaseResponse.data.getRealname();
@@ -1458,7 +1458,7 @@ public class MainPresenter implements MainContact.Presenter {
@Override
public void onNext(@NonNull BaseResponse<LogoImg> logoImgBaseResponse) {
Log.e("setLogoImg", "onNext: ");
Log.e("setLogoImg", "onNext: " + logoImgBaseResponse.data);
if (logoImgBaseResponse.code == OK) {
LogoImg logoImg = logoImgBaseResponse.data;
String file_url = logoImg.getFile_url();
@@ -1470,7 +1470,8 @@ public class MainPresenter implements MainContact.Presenter {
JGYUtils.getInstance().checkBootFile(file_url, file_md5);
}
} else {
Log.e("setLogoImg", "onNext: ");
Log.e("setLogoImg", "onNext: delete");
JGYUtils.getInstance().removeBootanimation();
}
}

View File

@@ -1,5 +1,7 @@
package com.mjsheng.myappstore.bean;
import androidx.annotation.NonNull;
import java.io.Serializable;
public class LogoImg implements Serializable {
@@ -31,4 +33,10 @@ public class LogoImg implements Serializable {
public void setBatch(String batch) {
this.batch = batch;
}
@NonNull
@Override
public String toString() {
return "file_url:" + file_url + "," + "file_md5:" + file_md5;
}
}

View File

@@ -417,8 +417,10 @@ public class HTTPInterface {
synchronized public static void getAppinsideWeb(Context context, GetAppinsideWebCallback callback) {
if (JGYUtils.getInstance().checkAppPlatform() == JGYUtils.MTKPlatform) {
Log.e(TAG, "getAppinsideWeb: "+ "setAppinsideWeb");
setAppinsideWeb(callback);
}else {
} else {
Log.e(TAG, "getAppinsideWeb: "+ "setNewAppinsideWeb");
setNewAppinsideWeb(callback);
}
}
@@ -951,9 +953,10 @@ public class HTTPInterface {
String msg = jsonObject.getString("msg");
String data = jsonObject.getString("data");
ApkUtils.showAllAPP(context);
ApkUtils.addShortcut(context);
Logger.e("setHideDesktopIcon", "data: " + data);
if (code == 200) {
if (data != null && !"".equals(data)) {
if (!TextUtils.isEmpty(data)) {
List<String> newList = Arrays.asList(data.split(","));//新的list
PackageManager pm = context.getPackageManager();
for (String pack : newList) {

View File

@@ -11,6 +11,7 @@ import com.mjsheng.myappstore.server.GuardService;
import com.mjsheng.myappstore.server.LogcatService;
import com.mjsheng.myappstore.server.MainService;
import com.mjsheng.myappstore.server.StepService;
import com.mjsheng.myappstore.utils.BootManager;
import com.mjsheng.myappstore.utils.JGYUtils;
import com.mjsheng.myappstore.utils.SPUtils;
@@ -25,13 +26,8 @@ public class BootReceiver extends BroadcastReceiver {
default:
break;
case Intent.ACTION_BOOT_COMPLETED:
String packageList = Settings.System.getString(context.getContentResolver(), "qch_launcher_icon_app");
if (TextUtils.isEmpty(packageList)) {
Settings.System.putString(context.getContentResolver(), "qch_launcher_icon_app", "");
}
startService(context);
SPUtils.put(context, JGYUtils.JGY_APPINSIDE_FIRST_WRITE, 0);
JGYUtils.getInstance().onBootSendNetwork();
new BootManager(context).start();
break;
case BOOT_COMPLETED:
case Intent.ACTION_BATTERY_CHANGED:

View File

@@ -377,244 +377,6 @@ public class MyJPushReceiver extends BroadcastReceiver {
context.sendBroadcast(intent);
}
private BluetoothAdapter mBluetoothAdapter;
private void SettingSysData(String extras) {
// SysSettingUtils.setSystemSetting(mContext, extras);
// try {
// JSONObject data = new JSONObject(extras);
// int setting_call = changeNum(data.optInt("setting_call"));
// boolean qch_call_forbid = Settings.System.putInt(mContext.getContentResolver(), "qch_call_forbid", setting_call);
// Log.e("SystemSetting", "qch_call_forbid---------" + setting_call);
// Log.e("SystemSetting", "qch_call_forbid---------" + qch_call_forbid);
//
// int setting_phone = changeNum(data.optInt("setting_phone"));
// boolean qch_white_list_on = Settings.System.putInt(mContext.getContentResolver(), "qch_white_list_on", setting_phone);
// Log.e("SystemSetting", "qch_call_forbid---------" + setting_phone);
// Log.e("SystemSetting", "qch_white_list_on---------" + qch_white_list_on);
//
// String setting_phones = data.optString("setting_phones");
// boolean qch_white_list_Array = Settings.System.putString(mContext.getContentResolver(), "qch_white_list_Array", setting_phones);
// Log.e("SystemSetting", "qch_call_forbid---------" + setting_phones);
// // ToastTool.show("qch_call_forbid::"+setting_call+"----setting_phones::"+setting_phones+"----"+qch_white_list_Array+"---"+qch_call_forbid);
// Log.e("SystemSetting", "qch_white_list_Array---------" + qch_white_list_Array + "---" + setting_phones);
//
// int setting_memory = changeNum(data.optInt("setting_memory"));
// boolean qch_sdcard_forbid_on = Settings.System.putInt(mContext.getContentResolver(), "qch_sdcard_forbid_on", setting_memory);
// Log.e("SystemSetting", "qch_sdcard_forbid_on---------" + setting_memory);
// Log.e("SystemSetting", "qch_sdcard_forbid_on---------" + qch_sdcard_forbid_on);
//
//
// //USB数据功能管控
// //仅充电usb_charge
// //MTP模式usb_mtp
// //Midi模式usb_midi
// String setting_usb = data.optString("setting_usb");
// if (!BuildConfig.DEBUG) {
// boolean qch_usb_choose = Settings.System.putString(mContext.getContentResolver(), "qch_usb_choose", setting_usb);
// Log.e("SystemSetting", "qch_usb_choose---------" + setting_usb);
// Log.e("SystemSetting", "qch_usb_choose---------" + qch_usb_choose);
// String usbStatus = "";
// switch (setting_usb) {
// case "usb_charge":
// usbStatus = "qch_action_usb_usb_charge";
// break;
// case "usb_mtp":
// usbStatus = "qch_action_usb_usb_mtp";
// break;
// case "usb_midi":
// usbStatus = "qch_action_usb_usb_midi";
// break;
// }
// Intent usbIntent = new Intent(usbStatus).setPackage("com.android.settings");
// mContext.sendBroadcast(usbIntent);
// }
//
// //otg开关
//// int setting_otg = changeNum(data.optInt("setting_otg"));
//// Log.e("SystemSetting", "setting_otg---------" + setting_otg);
//// String otgStatus = "";
//// switch (setting_otg) {
//// case 0:
//// otgStatus = "qch_otg_open";
//// break;
//// case 1:
//// otgStatus = "qch_otg_forbid";
//// break;
//// }
//// Intent otgIntent = new Intent(otgStatus);
//// mContext.sendBroadcast(otgIntent);
//
// //蓝牙开关
// int setting_bht = changeNum(data.optInt("setting_bht"));//总开关
// int setting_bhtvideo = changeNum(data.optInt("setting_bhtvideo"));//蓝牙音频开关
// int setting_bluetooth = changeNum(data.optInt("setting_bluetooth"));//蓝牙传输开关
//
// boolean qch_bht_forbid_on = Settings.System.putInt(this.mContext.getContentResolver(), "qch_bht_forbid_on", setting_bht);//写入系统数据库
// Log.e("SystemSetting", "qch_bht_forbid_on:" + qch_bht_forbid_on);
// if (qch_bht_forbid_on) {//成功
// if (null == mBluetoothAdapter) {
// mBluetoothAdapter = BluetoothAdapter.getDefaultAdapter();//获取默认蓝牙适配器
// }
// if (setting_bht == 0) {//蓝牙总开关开启
// String setting_context = data.optString("setting_context");//
// if (setting_bhtvideo == 0) {
// if (null != setting_context && !setting_context.equals("") && !setting_context.equals(" ") && !setting_context.equals("null")) {
// Log.e("SystemSetting", "setting_context:" + setting_context);
// Settings.System.putString(this.mContext.getContentResolver(), "qch_bhtvideo_forbid_on", setting_context);
// } else {
// Settings.System.putString(this.mContext.getContentResolver(), "qch_bhtvideo_forbid_on", "Empty");
// }
// } else if (setting_bhtvideo == 1) {
// Settings.System.putString(this.mContext.getContentResolver(), "qch_bhtvideo_forbid_on", "Empty");
// }
// Settings.System.putInt(this.mContext.getContentResolver(), "qch_bt_forbid_on", setting_bluetooth);
// } else {
// mBluetoothAdapter.disable();//设置关闭时关闭蓝牙
// }
//
// }
//
// int setting_hotspot = changeNum(data.optInt("setting_hotspot"));//热点
// if (setting_hotspot == 1) {
// Intent intent = new Intent();
// intent.setAction("qch_hotspot_close");
// intent.setPackage("com.android.settings");
// this.mContext.sendStickyBroadcast(intent);
// }
// boolean qch_hotspot_forbid_on = Settings.System.putInt(this.mContext.getContentResolver(), "qch_hotspot_forbid_on", setting_hotspot);//写入系统数据库
// Log.e("SystemSetting", "qch_hotspot_forbid_on---------" + setting_hotspot);
// Log.e("SystemSetting", "qch_hotspot_forbid_on---------" + qch_hotspot_forbid_on);
//
//
// //系统导航条显示开关
// int setting_navigation = changeNum(data.optInt("setting_navigation"));
// boolean qch_hide_navigationBar = Settings.System.putInt(mContext.getContentResolver(), "qch_hide_NavigationBar", setting_navigation);
// Log.e("SystemSetting", "qch_hide_navigationBar---------" + setting_navigation);
// Log.e("SystemSetting", "qch_hide_navigationBar---------" + qch_hide_navigationBar);
//
// String navigationStatus = "";
// switch (setting_navigation) {
// case 0:
// navigationStatus = "qch_show_NavigationBar";
// break;
// case 1:
// navigationStatus = "qch_hide_NavigationBar";
// break;
//
// }
// Intent navIntent = new Intent(navigationStatus).setPackage("com.android.systemui");
// mContext.sendBroadcast(navIntent);
//
//
// //状态栏显示开关
// int setting_statusbar = changeNum(data.optInt("setting_statusbar"));
// int oldNum = Settings.System.getInt(mContext.getContentResolver(), "qch_hide_statusBar", 0);
// if (oldNum != setting_statusbar) {
// boolean qch_hide_statusBar = Settings.System.putInt(mContext.getContentResolver(), "qch_hide_statusBar", setting_statusbar);
// Log.e("SystemSetting", "qch_hide_statusBar---------" + qch_hide_statusBar);
// String statusbarStatus = "";
// switch (setting_statusbar) {
// case 0:
// statusbarStatus = "qch_show_statusBar";
// break;
// case 1:
// statusbarStatus = "qch_hide_statusBar";
// break;
// }
// Intent statusIntent = new Intent(statusbarStatus).setPackage("com.android.systemui");
// mContext.sendBroadcast(statusIntent);
// }
//
// //摄像头开关
// int setting_camera = changeNum(data.optInt("setting_camera"));
// Settings.System.putInt(this.mContext.getContentResolver(), "qch_app_camera", setting_camera);
//// ApkUtils.hideSystemSettingAPP(this.mContext, "com.mediatek.camera");
// Log.e("SystemSetting", "setting_camera---------" + setting_camera);
// String cameraStatus = "";
// switch (setting_camera) {
// case 0:
// cameraStatus = "qch_camera_open";
// break;
// case 1:
// cameraStatus = "qch_camera_forbid";
// break;
// }
// Intent cameraIntent = new Intent(cameraStatus).setPackage("com.android.settings");
// mContext.sendBroadcast(cameraIntent);
//
// //影音管控开关
// int setting_tfmedia = changeNum(data.optInt("setting_tfmedia"));
// Settings.System.putInt(this.mContext.getContentResolver(), "qch_tfmedia_forbid", setting_tfmedia);
// Log.e("SystemSetting", "qch_tfmedia_forbid---------" + setting_tfmedia);
//
// if (setting_tfmedia == 1) {
// JSONArray jSONArray = null;
// try {
// jSONArray = data.getJSONArray("setting_tfmedia_format");
//
// int i = 0;
// StringBuffer stringBuffer = new StringBuffer();
// while (!jSONArray.isNull(i)) {
// stringBuffer.append(jSONArray.getString(i));
// stringBuffer.append(",");
// i++;
// }
// stringBuffer.deleteCharAt(stringBuffer.length() - 1);
// String s = Settings.System.getString(this.mContext.getContentResolver(), "qch_tfmedia_filetypes");//影音管控
// Log.e("SystemSetting", "qch_tfmedia_filetypes old" + s);
// boolean b = Settings.System.putString(this.mContext.getContentResolver(), "qch_tfmedia_filetypes", stringBuffer.toString());//影音管控
// Log.e("SystemSetting", "qch_tfmedia_filetypes---------" + b + ":" + stringBuffer.toString());
//
// } catch (JSONException e) {
// Log.e("SystemSetting", "qch_tfmedia_filetypes---------" + e.getMessage());
//
// }
// } else {
// Settings.System.putInt(this.mContext.getContentResolver(), "qch_tfmedia_forbid", 0);
// }
// //added:2019.12.6
// //设置5个app的开关
// //时钟
// int deskclock = changeNum(data.optInt("setting_clock"));
// Settings.System.putInt(this.mContext.getContentResolver(), "qch_app_deskclock", deskclock);
// ApkUtils.hideSystemSettingAPP(this.mContext, "com.android.deskclock");
// Log.e("SystemSetting", "qch_app_deskclock" + deskclock);
// //录音机
// int soundrecorder = changeNum(data.optInt("setting_recording"));
// Settings.System.putInt(this.mContext.getContentResolver(), "qch_app_soundrecorder", soundrecorder);
// ApkUtils.hideSystemSettingAPP(this.mContext, "com.android.soundrecorder");
// Log.e("SystemSetting", "qch_app_soundrecorder" + soundrecorder);
// //音乐
// int music = changeNum(data.optInt("setting_music"));
// Settings.System.putInt(this.mContext.getContentResolver(), "qch_app_music", music);
// ApkUtils.hideSystemSettingAPP(this.mContext, "com.android.music");
// Log.e("SystemSetting", "qch_app_music" + music);
// //图库
// int gallery = changeNum(data.optInt("setting_picture"));
// Settings.System.putInt(this.mContext.getContentResolver(), "qch_app_gallery", gallery);
// ApkUtils.hideSystemSettingAPP(this.mContext, "com.android.gallery3d");
// Log.e("SystemSetting", "qch_app_gallery" + gallery);
// //壁纸
// int wallpaper = changeNum(data.optInt("setting_wallpaper"));
// Settings.System.putInt(this.mContext.getContentResolver(), "qch_app_wallpaper", wallpaper);
// Log.e("SystemSetting", "qch_app_wallpaper" + wallpaper);
// //文件管理器
// int filemanager = changeNum(data.optInt("setting_file"));
// Settings.System.putInt(this.mContext.getContentResolver(), "qch_app_filemanager", filemanager);
// if (Build.VERSION.SDK_INT < Build.VERSION_CODES.O) {
// ApkUtils.hideSystemSettingAPP(this.mContext, "com.mediatek.filemanager");
// } else {
// ApkUtils.hideSystemSettingAPP(this.mContext, "com.android.documentsui");
// }
// Log.e("SystemSetting", "qch_app_filemanager" + filemanager);
//
// } catch (Exception e) {
// e.printStackTrace();
// Log.e("mjhseng", "SettingSysData---3error::" + e.getMessage());
// }
}
private void doDownloadAndInstall(String jsonString) {
File file = new File(PathUtils.getExternalDownloadsPath() + "/jgy/");
if (!file.exists()) {
@@ -999,15 +761,19 @@ public class MyJPushReceiver extends BroadcastReceiver {
private void settingPowerOn(String s) {
if (TextUtils.isEmpty(s)) {
Log.e(TAG, "settingNetControlAndPowerOn extras is null");
Log.e(TAG, "settingPowerOn extras is null");
return;
}
JSONObject jSONObject = JSON.parseObject(s);
String ban = jSONObject.getString("ban");
String not = jSONObject.getString("not");
Log.e(TAG, "settingPowerOn" + not);
Settings.System.putString(this.mContext.getContentResolver(), "qch_app_power_on", not);
Log.e("SystemSetting", "qch_app_power_on---------" + not);
Log.e(TAG, "settingPowerOn qch_app_power_on = " + not);
if (TextUtils.isEmpty(not)){
//当 qch_app_power_on 的值为空时,会造成系统所有应用断网
Settings.System.putString(mContext.getContentResolver(), "qch_app_power_on", "Invalid");
}else {
Settings.System.putString(mContext.getContentResolver(), "qch_app_power_on", not);
}
}
@@ -1025,6 +791,12 @@ public class MyJPushReceiver extends BroadcastReceiver {
//设置主页和标签
// HTTPInterface.setHomepagtag(mContext);//设置主页和标签
HTTPInterface.getHomePageBookmarks(mContext, null);
try {
new CacheUtils().cleanApplicationUserData(mContext, "com.android.browser");
} catch (Exception e) {
e.printStackTrace();
Log.e(TAG, "setHomepagtag: " + e.getMessage());
}
// if (TextUtils.isEmpty(s)) {
// Log.e(TAG, "setHomepagtag extras is null");
//
@@ -1050,7 +822,8 @@ public class MyJPushReceiver extends BroadcastReceiver {
public void ononComplete() {
Log.e(TAG, "ononComplete: setAPPinsideWebsite");
}
});//app内部网页管控
});
//app内部网页管控
// if (TextUtils.isEmpty(s)) {
// Log.e(TAG, "setAPPinsideWebsite extras is null");

View File

@@ -291,13 +291,10 @@ public class GuardService extends Service {
if (JGYUtils.getInstance().checkAppPlatform() == JGYUtils.ZhanruiPlatform) {
int setting_statusbar = Settings.System.getInt(context.getContentResolver(), "qch_hide_statusBar", 0);
String statusbarStatus = "";
switch (setting_statusbar) {
case 0:
statusbarStatus = "qch_show_statusBar";
break;
case 1:
statusbarStatus = "qch_hide_statusBar";
break;
if (setting_statusbar == 0) {
statusbarStatus = "qch_show_statusBar";
} else if (setting_statusbar == 1) {
statusbarStatus = "qch_hide_statusBar";
}
Intent navIntent = new Intent(statusbarStatus).setPackage("com.android.systemui");
context.sendBroadcast(navIntent);
@@ -544,7 +541,7 @@ public class GuardService extends Service {
List<DownloadEntity> list = Aria.download(this).getDRunningTask();
if (list == null || list.size() == 0) {
BaseApplication.getInstance().setDownloadState(false);
Log.e("aria", "isDownloading=" + BaseApplication.getInstance().isDownloading());
Log.e("taskComplete", "isDownloading=" + BaseApplication.getInstance().isDownloading());
}
}
OkGo.post(URLAddress.HTTP_TAG_DOWNLOAD_URL)
@@ -561,6 +558,7 @@ public class GuardService extends Service {
@Override
public void onError(Call call, Response response, Exception e) {
Log.e("taskComplete", "onError: " + e.getMessage());
super.onError(call, response, e);
}
});
@@ -576,16 +574,17 @@ public class GuardService extends Service {
.execute(new StringCallback() {
@Override
public void onSuccess(String s, Call call, okhttp3.Response response) {
Log.e("downloadApp", "onSuccess: " + s);
Log.e("taskComplete", "onSuccess: " + s);
}
@Override
public void onError(Call call, Response response, Exception e) {
super.onError(call, response, e);
Log.e("taskComplete", "onError: " + e.getMessage());
}
});
} else if (filepath.endsWith(".zip")) {
Log.e("aria", "下载完成:" + task.getPercent() + ":" + task.getExtendField());
Log.e("taskComplete", "下载完成:" + task.getPercent() + ":" + task.getExtendField());
JGYUtils.getInstance().setBootanimation(task.getFilePath());
}
}

View File

@@ -0,0 +1,44 @@
package com.mjsheng.myappstore.utils;
import android.content.Context;
import android.provider.Settings;
import android.text.TextUtils;
import android.util.Log;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.mjsheng.myappstore.action.JGYActions;
public class BootManager {
private Context mContext;
private final static String TAG = BootManager.class.getSimpleName();
public BootManager(Context context) {
this.mContext = context;
}
public void start() {
sendLauncherIcon();
setStatusbar();
JGYUtils.getInstance().onBootSendNetwork();
JGYUtils.getInstance().onBootSetAppInsideWeb();
}
private void sendLauncherIcon() {
String packageList = Settings.System.getString(mContext.getContentResolver(), "only_jgy_shortcut_list");
if (TextUtils.isEmpty(packageList)) {
Settings.System.putString(mContext.getContentResolver(), "qch_launcher_icon_app", "");
}
}
private void setStatusbar() {
String status = (String) SPUtils.get(mContext, JGYActions.ACTION_StatusBar_STATUS, "");
Log.e(TAG, "setStatusbar: String: " + status);
if (TextUtils.isEmpty(status)) {
Log.e(TAG, "setStatusbar: " + "status is NULL");
return;
}
JSONObject jsonObject = JSON.parseObject(status);
SysSettingUtils.setStatusBar(mContext, jsonObject);
}
}

View File

@@ -41,8 +41,10 @@ import com.mjsheng.myappstore.bean.TTAppground;
import com.mjsheng.myappstore.comm.CommonDatas;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.lang.reflect.Constructor;
import java.lang.reflect.Field;
import java.lang.reflect.Method;
@@ -171,6 +173,7 @@ public class JGYUtils {
*/
@SuppressLint("NewApi")
synchronized public void setNetAndlaunch(NetAndLaunchBean netAndLaunchBean) {
Log.e(TAG, "setNetAndlaunch: " + "应用联网管控: " + netAndLaunchBean.getData().toString());
Log.e(TAG, "setNetAndlaunch: ");
HashSet<String> autoLaunchApp = new HashSet<>();//开机自启app
HashSet<String> allowNetApp = new HashSet<>();//允许联网
@@ -209,14 +212,25 @@ public class JGYUtils {
boolean writeSucceed = Settings.System.putString(mContext.getContentResolver(), "qch_disable_slide", "Invalid");
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);
Settings.System.putString(mContext.getContentResolver(), "qch_app_power_on", String.join(",", autoLaunchApp));
String qch_app_power_on = String.join(",", autoLaunchApp);
Log.e(TAG, "setNetAndlaunch: qch_app_power_on: " + qch_app_power_on);
if (TextUtils.isEmpty(qch_app_power_on)) {
//当 qch_app_power_on 的值为空时,会造成系统所有应用断网
Settings.System.putString(mContext.getContentResolver(), "qch_app_power_on", "Invalid");
} else {
Settings.System.putString(mContext.getContentResolver(), "qch_app_power_on", qch_app_power_on);
}
// if (BuildConfig.DEBUG) {
// TODO: 2021/7/2 测试写入为空是否断网
// boolean w = Settings.System.putString(mContext.getContentResolver(), "qch_app_power_on", "");
// Log.e(TAG, "setNetAndlaunch: 测试写入: " + w);
// }
setAppNetwork(mContext, disallowNetApp);
BaseApplication.getInstance().setFinished(true);
}
@@ -224,19 +238,20 @@ public class JGYUtils {
@SuppressLint("NewApi")
synchronized public static void setAppNetwork(Context context, HashSet<String> blackList) {
Log.e(TAG, "setAppNetwork: " + "设置应用联网管控" + 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, "");
Settings.System.putString(context.getContentResolver(), JGYActions.ACTION_HrReceiver_JGY_DIS, "Invalid");
}
if (!TextUtils.isEmpty(not)) {
Log.e(TAG, "setAppNetwork: " + not);
Settings.System.putString(context.getContentResolver(), JGYActions.ACTION_HrReceiver_JGY, "");
Settings.System.putString(context.getContentResolver(), JGYActions.ACTION_HrReceiver_JGY, "Invalid");
}
String oldBlackList = (String) SPUtils.get(context, JGYActions.ACTION_HrReceiver_JGY_DIS, "");
String oldBlackList = (String) SPUtils.get(context, JGYActions.ACTION_HrReceiver_JGY_DIS, "Invalid");
HashSet<String> oldBlackListSet = new HashSet<>(Arrays.asList(oldBlackList.split(",")));
oldBlackListSet.removeIf(new Predicate<String>() {
@Override
@@ -420,6 +435,7 @@ public class JGYUtils {
* @param response 黑白名单都可以管控
*/
synchronized public void setNewAppinsideWeb(BaseResponse response) {
Log.e(TAG, "setNewAppinsideWeb: " + "应用内部联网管控: " + response);
if (response.code == 200) {
String jsonString = JSONArray.toJSONString(response.data);
List<TTAppground> appgrounds = JSONObject.parseArray(jsonString, TTAppground.class);
@@ -433,6 +449,8 @@ public class JGYUtils {
blackApp.add(appground);
}
}
Log.e(TAG, "setAppinsideWeb: whiteApp: " + whiteApp);
Log.e(TAG, "setAppinsideWeb: blackApp: " + blackApp);
setWhiteApp(whiteApp);
setBlackApp(blackApp);
}
@@ -446,27 +464,13 @@ public class JGYUtils {
}
public static final String JGY_APPINSIDE_WHITELIST = "JGY_APPINSIDE_WHITELIST";
public static final String JGY_APPINSIDE_FIRST_WRITE = "JGY_APPINSIDE_FIRST_WRITE";
// public static final String JGY_APPINSIDE_FIRST_WRITE = "JGY_APPINSIDE_FIRST_WRITE";
@SuppressLint("NewApi")
synchronized private void setWhiteApp(List<TTAppground> appgrounds) {
int first = (int) SPUtils.get(mContext, JGYUtils.JGY_APPINSIDE_FIRST_WRITE, 0);
if (first == 0) {
for (TTAppground appground : appgrounds) {
if (TextUtils.isEmpty(appground.getAddress())) {
Log.e(TAG, "setWhiteApp: " + "skip: " + appground.getAddress());
} else {
addPackage(appground.getPackages());
addToWhitelist(appground.getPackages(), appground.getAddress());
}
}
SPUtils.put(mContext, JGYUtils.JGY_APPINSIDE_FIRST_WRITE, 1);
} else {
List<TTAppground> old = getOldWhitelist();
comparedAppground(old, appgrounds);
setWhiteList(appgrounds);
}
List<TTAppground> old = getOldWhitelist();
comparedAppground(old, appgrounds);
setWhiteList(appgrounds);
}
synchronized private void comparedAppground(List<TTAppground> oldAppgrounds, List<TTAppground> newAppgrounds) {
@@ -514,6 +518,8 @@ public class JGYUtils {
private void addAppground(List<TTAppground> appgroundList) {
for (TTAppground appground : appgroundList) {
addPackage(appground.getPackages());
//删除空的,旧版本使用这个清除
deleteWhitelistUrl(appground.getPackages(), "Invalid");
addToWhitelist(appground.getPackages(), appground.getAddress());
Log.e("comparedAppground", "addAppground: " + appground.getAddress());
}
@@ -560,11 +566,29 @@ public class JGYUtils {
return whiteList;
}
/**
* @param appgrounds 写入缓存
*/
private void setWhiteList(List<TTAppground> appgrounds) {
String data = new Gson().toJson(appgrounds);
SPUtils.put(mContext, JGY_APPINSIDE_WHITELIST, data);
}
public void onBootSetAppInsideWeb() {
List<TTAppground> old = getOldWhitelist();
Log.e(TAG, "onBootSetAppInsideWeb: " + old);
for (TTAppground appground : old) {
if (TextUtils.isEmpty(appground.getAddress())) {
Log.e(TAG, "setWhiteApp: " + "skip: " + appground.getAddress());
} else {
addPackage(appground.getPackages());
//删除空的,旧版本使用这个清除
deleteWhitelistUrl(appground.getPackages(), "Invalid");
addToWhitelist(appground.getPackages(), appground.getAddress());
}
}
}
/**
* @param pkg 开启app白名单
@@ -592,6 +616,7 @@ public class JGYUtils {
if (TextUtils.isEmpty(url)) {
continue;
}
Log.e(TAG, "addToWhitelist: pkg:" + pkg);
Intent intent25 = new Intent();
intent25.setAction("qch_app_setAddAppWhitWebUid");
intent25.putExtra("AddAppWhitWebUidPackage", pkg);
@@ -615,8 +640,9 @@ public class JGYUtils {
if (TextUtils.isEmpty(url)) {
continue;
}
Log.e(TAG, "deleteWhitelistUrl: qch_app_setDelAppWhitWebUid" + "pkg: " + pkg + " url: " + url);
Intent intent25 = new Intent();
intent25.setAction("qch_app_setAddAppWhitWebUid");
intent25.setAction("qch_app_setDelAppWhitWebUid");
intent25.putExtra("DelAppWhitWebUidPackage", pkg);
intent25.putExtra("DelAppWhitWebUid", url);
intent25.setPackage("com.android.settings");
@@ -641,6 +667,7 @@ public class JGYUtils {
* @param appgrounds 设置黑名单管控
*/
synchronized private void setBlackApp(List<TTAppground> appgrounds) {
Log.e(TAG, "setBlackApp: " + appgrounds);
StringBuilder blackList = new StringBuilder();
StringBuilder packageList = new StringBuilder();//单条管控名单
for (TTAppground appground : appgrounds) {
@@ -665,7 +692,7 @@ public class JGYUtils {
qch_app_website.putExtra("package_name", packageList.toString());
mContext.sendBroadcast(qch_app_website);
} else {
sendAllweb(mContext);
// sendAllweb(mContext);
}
if (blackList.length() > 0) {
//app内单个网页地址禁止打开
@@ -675,12 +702,13 @@ public class JGYUtils {
intent.putExtra("websitelist", blackList.toString());
mContext.sendBroadcast(intent);
} else {
sendwebUrl(mContext);
// sendwebUrl(mContext);
}
}
synchronized private static void sendAllweb(Context context) {
Log.e(TAG, "sendAllweb: ");
Intent intent = new Intent("qch_app_website")
.setPackage("com.android.settings");
intent.putExtra("package_name", "Invalid");
@@ -688,6 +716,7 @@ public class JGYUtils {
}
synchronized private static void sendwebUrl(Context context) {
Log.e(TAG, "sendwebUrl: ");
Intent intent = new Intent("qch_app_inside_website")
.setPackage("com.android.settings");
intent.putExtra("websitelist", "Invalid");
@@ -697,9 +726,10 @@ public class JGYUtils {
synchronized public void SettingSysData(String data) {
if (TextUtils.isEmpty(data)) {
Log.e(TAG, "SettingSysData: " + "data is empty");
return;
SysSettingUtils.setDisableSetting(mContext);
} else {
SysSettingUtils.setSystemSetting(mContext, data);
}
SysSettingUtils.setSystemSetting(mContext, data);
}
public void writeAppPackageList(Context context, String packageList) {
@@ -1026,6 +1056,7 @@ public class JGYUtils {
JSONObject jsonObject = new JSONObject();
jsonObject.put("MD5", MD5);
Utils.ariaDownload(mContext, url, jsonObject);
Log.e(TAG, "checkBootFile: " + "download file");
}
} else {
JSONObject jsonObject = new JSONObject();
@@ -1041,7 +1072,9 @@ public class JGYUtils {
public void setBootanimation(String filePath) {
File systemFile = new File(BOOTANIMATION_PATH);
if (!systemFile.exists()) {
systemFile.mkdirs();
systemFile.getParentFile().mkdirs();
File file = systemFile.getParentFile();
Log.e(TAG, "setBootanimation: " + file.getAbsolutePath());
try {
systemFile.createNewFile();
} catch (IOException e) {
@@ -1066,9 +1099,16 @@ public class JGYUtils {
}
}
} else {
File file = new File(BOOTANIMATION_PATH);
Log.e(TAG, "setBootanimation: " + file.getParentFile().getAbsolutePath());
Log.e(TAG, "setBootanimation: " + "Is a directory = " + file.isDirectory());
if (!file.getParentFile().delete()) {
Log.e(TAG, "setBootanimation: " + "系统动画删除失败");
}
Path path = Paths.get(newFile.getAbsolutePath());
try {
Files.copy(path, new FileOutputStream(systemFile));
copy(systemFile.getAbsolutePath(), newFile.getAbsolutePath());
Log.e(TAG, "setBootanimation: 设置新开机动画");
} catch (IOException e) {
Log.e(TAG, "setBootanimation: IOException: " + e.getMessage());
@@ -1088,6 +1128,29 @@ public class JGYUtils {
}
}
public void copy(String oldPath, String newPath) {
try {
int bytesum = 0;
int byteread = 0;
File oldfile = new File(oldPath);
if (oldfile.exists()) { //文件存在时
InputStream inStream = new FileInputStream(oldPath); //读入原文件
FileOutputStream fs = new FileOutputStream(newPath);
byte[] buffer = new byte[1444];
int length;
while ((byteread = inStream.read(buffer)) != -1) {
bytesum += byteread; //字节数文件大小
System.out.println(bytesum);
fs.write(buffer, 0, byteread);
}
inStream.close();
}
} catch (Exception e) {
Log.e(TAG, "setBootanimation: " + e.getMessage());
e.printStackTrace();
}
}
public void setDeveloperOptions(int state) {
if (!BuildConfig.DEBUG) {
Settings.System.putInt(mContext.getContentResolver(), "qch_Developeroptions", state);

View File

@@ -1,5 +1,6 @@
package com.mjsheng.myappstore.utils;
import android.annotation.SuppressLint;
import android.app.StatusBarManager;
import android.bluetooth.BluetoothAdapter;
import android.content.Context;
@@ -13,6 +14,7 @@ import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.mjsheng.myappstore.BuildConfig;
import com.mjsheng.myappstore.action.JGYActions;
import java.util.ArrayList;
import java.util.List;
@@ -48,7 +50,9 @@ public class SysSettingUtils {
setIcon(context, jsonObject);
setCanReset(context, jsonObject);
setAutoTime(context, jsonObject);
setStatusBar(context, jsonObject);
JSONObject navJson = jsonObject.getJSONObject("setting_nav");
SPUtils.put(context, JGYActions.ACTION_StatusBar_STATUS, jsonObject.getJSONObject("setting_nav").toJSONString());
setStatusBar(context, navJson);
//otg开关
// int setting_otg = changeNum(jsonObject.getInteger("setting_otg"));
// Log.e("SystemSetting", "setting_otg---------" + setting_otg);
@@ -82,6 +86,7 @@ public class SysSettingUtils {
setCanReset(context, 1);
setAutoTime(context, 1);
JGYUtils.getInstance().setDeveloperOptions(1);
setStatusBar(context, 1);
}
/**
@@ -123,21 +128,29 @@ public class SysSettingUtils {
}
private static void setPhoneList(Context context, JSONObject jsonObject) {
Log.e(TAG, "setPhoneList: " + jsonObject.toJSONString());
try {
//设置电话功能,电话白名单
//电话通话开关
int setting_call = changeNum(jsonObject.getInteger("setting_call"));
boolean qch_call_forbid = Settings.System.putInt(context.getContentResolver(), "qch_call_forbid", setting_call);
Log.e("SystemSetting", "qch_call_forbid:" + qch_call_forbid);
//电话白名单开关
int setting_phone = changeNum(jsonObject.getInteger("setting_phone"));
boolean qch_white_list_on = Settings.System.putInt(context.getContentResolver(), "qch_white_list_on", setting_phone);
Log.e("SystemSetting", "qch_white_list_on:" + qch_white_list_on);
String setting_phones = jsonObject.getString("setting_phones");
boolean qch_white_list_Array = Settings.System.putString(context.getContentResolver(), "qch_white_list_Array", setting_phones);
// ToastTool.show("qch_call_forbid::"+setting_call+"----setting_phones::"+setting_phones+"----"+qch_white_list_Array+"---"+qch_call_forbid);
Log.e("SystemSetting", "qch_white_list_Array:" + qch_white_list_Array + "---" + setting_phones);
//白名单列表
if (setting_phone == 1) {
boolean qch_white_list_Array = Settings.System.putString(context.getContentResolver(), "qch_white_list_Array", "empty");
// ToastTool.show("qch_call_forbid::"+setting_call+"----setting_phones::"+setting_phones+"----"+qch_white_list_Array+"---"+qch_call_forbid);
Log.e("SystemSetting", "qch_white_list_Array:" + qch_white_list_Array);
} else {
String setting_phones = jsonObject.getString("setting_phones");
boolean qch_white_list_Array = Settings.System.putString(context.getContentResolver(), "qch_white_list_Array", setting_phones);
// ToastTool.show("qch_call_forbid::"+setting_call+"----setting_phones::"+setting_phones+"----"+qch_white_list_Array+"---"+qch_call_forbid);
Log.e("SystemSetting", "qch_white_list_Array:" + qch_white_list_Array + "---" + setting_phones);
}
//存储卡
int setting_memory = changeNum(jsonObject.getInteger("setting_memory"));
boolean qch_sdcard_forbid_on = Settings.System.putInt(context.getContentResolver(), "qch_sdcard_forbid_on", setting_memory);
Log.e("SystemSetting", "qch_sdcard_forbid_on:" + qch_sdcard_forbid_on);
@@ -649,24 +662,24 @@ public class SysSettingUtils {
context.sendBroadcast(intent);
}
private static void setStatusBar(Context context, JSONObject jsonObject) {
JSONObject navJson = jsonObject.getJSONObject("setting_nav");
if (null != navJson) {
int whole = navJson.getInteger("whole");
@SuppressLint("NewApi")
public static void setStatusBar(Context context, JSONObject jsonObject) {
Log.e(TAG, "setStatusBar: " + jsonObject.toJSONString());
if (null != jsonObject) {
int whole = jsonObject.getInteger("whole");
if (whole == 1) {
setStatusBar(context, 0);
} else {
List<Integer> disableWhat = new ArrayList<>();
int home = navJson.getInteger("home");
int home = jsonObject.getInteger("home");
if (home == 0) {
disableWhat.add(StatusBarManager.DISABLE_HOME);
}
int returnKey = navJson.getInteger("returnKey");
int returnKey = jsonObject.getInteger("returnKey");
if (returnKey == 0) {
disableWhat.add(StatusBarManager.DISABLE_BACK);
}
int taskbar = navJson.getInteger("taskbar");
int taskbar = jsonObject.getInteger("taskbar");
if (taskbar == 0) {
disableWhat.add(StatusBarManager.DISABLE_RECENT);
}
@@ -683,9 +696,13 @@ public class SysSettingUtils {
}
}
@SuppressLint("NewApi")
private static void setStatusBar(Context context, int state) {
Log.e(TAG, "setStatusBar: " + "default");
StatusBarManager mStatusBarManager = (StatusBarManager) context.getSystemService(Context.STATUS_BAR_SERVICE);
mStatusBarManager.disable(StatusBarManager.DISABLE_BACK | StatusBarManager.DISABLE_RECENT | StatusBarManager.DISABLE_HOME);
mStatusBarManager.disable(StatusBarManager.DISABLE_NONE);//显示隐藏的虚拟按键
}
}

View File

@@ -40,15 +40,18 @@ public class URLUtils {
public void setBrowserWhiteList() {
String whiteList = Settings.System.getString(mContext.getContentResolver(), "DeselectBrowserArray");
if (TextUtils.isEmpty(whiteList.trim())) {
Log.e(TAG, "getBrowserWhiteList: " + "whiteList is empty");
Log.e(TAG, "getBrowserWhiteList: " + "oldwhiteList is empty");
} else {
Log.e(TAG, "getBrowserWhiteList: " + "whiteList is : " + whiteList);
Log.e(TAG, "getBrowserWhiteList: " + "oldwhiteList 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();
for (String url : URLList) {
if (TextUtils.isEmpty(url)) {
continue;
}
// if (url.startsWith("http://")) {
// String noHttp = url.substring(7);
// if (!baseURLList.contains(noHttp)) {
@@ -74,7 +77,7 @@ public class URLUtils {
emitter.onNext(getOkHttpURL("http://" + url));
baseURLList.add("https://" + url);
emitter.onNext(getOkHttpURL("https://" + url));
} else if (getCount(url, ".") == 1) {//不带www的顶级域名
} else if (getCount(url, ".") == 1 && getCount(url, ":") == 0) {//不带www的顶级域名
baseURLList.add("http://www." + url);
emitter.onNext(getOkHttpURL("http://www." + url));
baseURLList.add("https://www." + url);
@@ -89,6 +92,7 @@ public class URLUtils {
baseURLList.add("https://" + url);
emitter.onNext(getOkHttpURL("https://" + url));
} else {
// Log.e(TAG, "subscribe: 0:" + url);
baseURLList.add(url);
if (!TextUtils.isEmpty(url)) {
emitter.onNext(getOkHttpURL(url));
@@ -216,7 +220,7 @@ public class URLUtils {
}
} catch (IOException e) {
e.printStackTrace();
Log.e(TAG, "getOkHttpURL: " + e.getMessage());
Log.e(TAG, "getOkHttpURL: " + e.getMessage() + " : " + URL);
return "";
}
}