update:2020.10.21
fix:蓝牙文件传输管控改为蓝牙开关管控 add:摄像头管控,影音格式管控,电话功能管控
This commit is contained in:
@@ -4,6 +4,7 @@ import android.annotation.SuppressLint;
|
||||
import android.app.ActivityManager;
|
||||
import android.app.usage.UsageStats;
|
||||
import android.app.usage.UsageStatsManager;
|
||||
import android.bluetooth.BluetoothAdapter;
|
||||
import android.content.BroadcastReceiver;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
@@ -11,11 +12,13 @@ import android.content.IntentFilter;
|
||||
import android.content.pm.PackageManager;
|
||||
import android.os.Bundle;
|
||||
import android.os.Environment;
|
||||
import android.os.Message;
|
||||
import android.provider.Settings;
|
||||
import android.text.TextUtils;
|
||||
import android.util.Log;
|
||||
import android.view.WindowManager;
|
||||
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.arialyy.aria.core.Aria;
|
||||
import com.arialyy.aria.core.download.DownloadEntity;
|
||||
import com.info.sn.MainActivity;
|
||||
@@ -31,10 +34,13 @@ import com.lzy.okgo.OkGo;
|
||||
import com.lzy.okgo.callback.StringCallback;
|
||||
import com.lzy.okgo.model.Response;
|
||||
|
||||
import org.json.JSONArray;
|
||||
import org.json.JSONException;
|
||||
import org.json.JSONObject;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.SortedMap;
|
||||
@@ -54,48 +60,45 @@ public class MyReceiver extends BroadcastReceiver {
|
||||
|
||||
@Override
|
||||
public void onReceive(Context context, Intent intent) {
|
||||
try {
|
||||
Bundle bundle = intent.getExtras();
|
||||
Logger.d(TAG, "[MyReceiver] onReceive - " + intent.getAction() + ", extras: " + printBundle(bundle));
|
||||
Bundle bundle = intent.getExtras();
|
||||
Logger.d(TAG, "[MyReceiver] onReceive - " + intent.getAction() + ", extras: " + printBundle(bundle));
|
||||
|
||||
if (JPushInterface.ACTION_REGISTRATION_ID.equals(intent.getAction())) {
|
||||
String regId = bundle.getString(JPushInterface.EXTRA_REGISTRATION_ID);
|
||||
Logger.d(TAG, "[MyReceiver] 接收Registration Id : " + regId);
|
||||
//send the Registration Id to your server...
|
||||
if (JPushInterface.ACTION_REGISTRATION_ID.equals(intent.getAction())) {
|
||||
String regId = bundle.getString(JPushInterface.EXTRA_REGISTRATION_ID);
|
||||
Logger.d(TAG, "[MyReceiver] 接收Registration Id : " + regId);
|
||||
//send the Registration Id to your server...
|
||||
|
||||
} else if (JPushInterface.ACTION_MESSAGE_RECEIVED.equals(intent.getAction())) {
|
||||
Logger.d(TAG, "[MyReceiver] 接收到推送下来的自定义消息: " + bundle.getString(JPushInterface.EXTRA_MESSAGE));
|
||||
processCustomMessage(context, bundle);
|
||||
} else if (JPushInterface.ACTION_MESSAGE_RECEIVED.equals(intent.getAction())) {
|
||||
Logger.d(TAG, "[MyReceiver] 接收到推送下来的自定义消息: " + bundle.getString(JPushInterface.EXTRA_MESSAGE));
|
||||
processCustomMessage(context, bundle);
|
||||
|
||||
} else if (JPushInterface.ACTION_NOTIFICATION_RECEIVED.equals(intent.getAction())) {
|
||||
Logger.d(TAG, "[MyReceiver] 接收到推送下来的通知");
|
||||
int notifactionId = bundle.getInt(JPushInterface.EXTRA_NOTIFICATION_ID);
|
||||
Logger.d(TAG, "[MyReceiver] 接收到推送下来的通知的ID: " + notifactionId);
|
||||
} else if (JPushInterface.ACTION_NOTIFICATION_RECEIVED.equals(intent.getAction())) {
|
||||
Logger.d(TAG, "[MyReceiver] 接收到推送下来的通知");
|
||||
int notifactionId = bundle.getInt(JPushInterface.EXTRA_NOTIFICATION_ID);
|
||||
Logger.d(TAG, "[MyReceiver] 接收到推送下来的通知的ID: " + notifactionId);
|
||||
|
||||
} else if (JPushInterface.ACTION_NOTIFICATION_OPENED.equals(intent.getAction())) {
|
||||
Logger.d(TAG, "[MyReceiver] 用户点击打开了通知");
|
||||
} else if (JPushInterface.ACTION_NOTIFICATION_OPENED.equals(intent.getAction())) {
|
||||
Logger.d(TAG, "[MyReceiver] 用户点击打开了通知");
|
||||
|
||||
//打开自定义的Activity
|
||||
Intent i = new Intent(context, TestActivity.class);
|
||||
i.putExtras(bundle);
|
||||
//i.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
|
||||
i.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TOP);
|
||||
context.startActivity(i);
|
||||
//打开自定义的Activity
|
||||
Intent i = new Intent(context, TestActivity.class);
|
||||
i.putExtras(bundle);
|
||||
//i.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
|
||||
i.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TOP);
|
||||
context.startActivity(i);
|
||||
|
||||
} else if (JPushInterface.ACTION_RICHPUSH_CALLBACK.equals(intent.getAction())) {
|
||||
Logger.d(TAG, "[MyReceiver] 用户收到到RICH PUSH CALLBACK: " + bundle.getString(JPushInterface.EXTRA_EXTRA));
|
||||
//在这里根据 JPushInterface.EXTRA_EXTRA 的内容处理代码,比如打开新的Activity, 打开一个网页等..
|
||||
|
||||
} else if (JPushInterface.ACTION_CONNECTION_CHANGE.equals(intent.getAction())) {
|
||||
boolean connected = intent.getBooleanExtra(JPushInterface.EXTRA_CONNECTION_CHANGE, false);
|
||||
Logger.w(TAG, "[MyReceiver]" + intent.getAction() + " connected state change to " + connected);
|
||||
} else {
|
||||
Logger.d(TAG, "[MyReceiver] Unhandled intent - " + intent.getAction());
|
||||
}
|
||||
} catch (Exception e) {
|
||||
} else if (JPushInterface.ACTION_RICHPUSH_CALLBACK.equals(intent.getAction())) {
|
||||
Logger.d(TAG, "[MyReceiver] 用户收到到RICH PUSH CALLBACK: " + bundle.getString(JPushInterface.EXTRA_EXTRA));
|
||||
//在这里根据 JPushInterface.EXTRA_EXTRA 的内容处理代码,比如打开新的Activity, 打开一个网页等..
|
||||
|
||||
} else if (JPushInterface.ACTION_CONNECTION_CHANGE.equals(intent.getAction())) {
|
||||
boolean connected = intent.getBooleanExtra(JPushInterface.EXTRA_CONNECTION_CHANGE, false);
|
||||
Logger.w(TAG, "[MyReceiver]" + intent.getAction() + " connected state change to " + connected);
|
||||
} else {
|
||||
Logger.d(TAG, "[MyReceiver] Unhandled intent - " + intent.getAction());
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
// 打印所有的 intent extra 数据
|
||||
@@ -193,6 +196,7 @@ public class MyReceiver extends BroadcastReceiver {
|
||||
String title = bundle.getString(JPushInterface.EXTRA_TITLE);
|
||||
String type = bundle.getString(JPushInterface.EXTRA_CONTENT_TYPE);
|
||||
String extras = bundle.getString(JPushInterface.EXTRA_EXTRA);
|
||||
HTTPInterface.checkDevicesInfo(context);
|
||||
|
||||
switch (message) {
|
||||
case JIGUANG_GET_DRIVELINE:
|
||||
@@ -220,7 +224,7 @@ public class MyReceiver extends BroadcastReceiver {
|
||||
setAppLockedstate(context, extras);
|
||||
break;
|
||||
case JIGUANG_FORCE_INSTALLAPK:
|
||||
intallApk(extras);
|
||||
intallApk(context, extras);
|
||||
break;
|
||||
case JIGUANG_FORCE_UNINSTALLAPK:
|
||||
unintallApk(context, extras);
|
||||
@@ -229,18 +233,116 @@ public class MyReceiver extends BroadcastReceiver {
|
||||
bindService(context, extras);
|
||||
break;
|
||||
case JIGUANG_TFMEDIA:
|
||||
|
||||
setTFmedia(context, extras);
|
||||
break;
|
||||
case JIGUANG_CAMRERA:
|
||||
setCameta(context, extras);
|
||||
break;
|
||||
case JIGUANG_PHONE:
|
||||
setPhone(context, extras);
|
||||
break;
|
||||
case JIGUANG_DISABLE_UPDATAE:
|
||||
setAppUpdate(context, extras);
|
||||
break;
|
||||
case JIGUANG_APP_WEBSITE:
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
private int changeNum(int paramInt) {
|
||||
switch (paramInt) {
|
||||
default:
|
||||
return 1;
|
||||
case 0:
|
||||
return 1;
|
||||
case 1:
|
||||
break;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
private void setPhone(Context context, String json) {
|
||||
com.alibaba.fastjson.JSONObject jsonObject = JSON.parseObject(json);
|
||||
int setting_phone = jsonObject.getInteger("setting_phone");
|
||||
Log.e("setting_phone", String.valueOf(setting_phone));
|
||||
boolean qch_call_forbid = Settings.System.putInt(context.getContentResolver(), "qch_call_forbid", setting_phone);
|
||||
boolean qch_white_list_on = Settings.System.putInt(context.getContentResolver(), "qch_white_list_on", setting_phone);
|
||||
boolean qch_white_list_Array = Settings.System.putString(context.getContentResolver(), "qch_white_list_Array", "981964879");
|
||||
Log.e("SystemSetting", "qch_call_forbid---------" + setting_phone);
|
||||
Log.e("SystemSetting", "qch_call_forbid---------" + qch_call_forbid);
|
||||
Log.e("SystemSetting", "qch_call_forbid---------" + qch_white_list_on);
|
||||
Log.e("SystemSetting", "qch_call_forbid---------" + qch_white_list_Array);
|
||||
}
|
||||
|
||||
private void setCameta(Context context, String json) {
|
||||
com.alibaba.fastjson.JSONObject jsonObject = JSON.parseObject(json);
|
||||
//摄像头开关
|
||||
int setting_camera = jsonObject.getInteger("setting_camera");
|
||||
Settings.System.putInt(context.getContentResolver(), "qch_app_camera", setting_camera);
|
||||
ApkUtils.hideSystemSettingAPP(context, "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");
|
||||
context.sendBroadcast(cameraIntent);
|
||||
}
|
||||
|
||||
String tftype = ".png,.bmp,.jpg,.mpo,.jpeg,.gif,.tif,.tiff,.dib,.jpe,.jfif,.psd,.pdd,.rle,.dcm,.dic,.dc3,.eps,.iff,.tdi,.jpf,.jpx,.jp2,.j2c,.jpc,.jps,.j2k,.pcx,.pdp,.raw,.pns,.aac,.ac3,.aiff,.amr,.ape,.au,.fla,.flac,.imy,.m4r,.mid,.mka,.mmf,.mp2,.mp3,.mxmf,.ogg,.ra,.ts,.wma,.wv,.xmf,.m4a,.wav,.3gpp,.mp4,.3gp,.as,.asf,.avi,.dat,.f4v,.flv,.mkv,.mov,.mpg,.rmvb,.swf,.trp,.vob,.webm,.wmv,.navi,.video,.ram,.qsv,.xv,.rm,.vcd,.svcd,.mlv,.mpe,.mpeg,.m2v,.iso,.html,.htm,.txt,.xls,.doc,.docx,.docm,.pdf,.xps,.dot,.dotx,.dotm,.mht,.mhtml,.rft,.xml,.xlsx,.xlsm,.xlsb,.xltx,.xltm,.xlt,.wps,.wpt,.rtf,.et,.ett,.dps,.dpt,.wpp,.ppt,.pptx,.pptm,.pps,.pot,.potm,.ppsx,.ppsm,.odp";
|
||||
|
||||
private void setTFmedia(Context context, String json) {
|
||||
com.alibaba.fastjson.JSONObject jsonObject = JSON.parseObject(json);
|
||||
//影音管控开关
|
||||
int setting_tfmedia = jsonObject.getInteger("setting_tfmedia");
|
||||
Settings.System.putInt(context.getContentResolver(), "qch_tfmedia_forbid", setting_tfmedia);
|
||||
Log.e("SystemSetting", "qch_tfmedia_forbid---------" + setting_tfmedia);
|
||||
|
||||
if (setting_tfmedia == 1) {
|
||||
String s = Settings.System.getString(context.getContentResolver(), "qch_tfmedia_filetypes");//影音管控
|
||||
Log.e("SystemSetting", "qch_tfmedia_filetypes old" + s);
|
||||
boolean b = Settings.System.putString(context.getContentResolver(), "qch_tfmedia_filetypes", tftype);//影音管控
|
||||
Log.e("SystemSetting", "qch_tfmedia_filetypes---------" + b + ":" + tftype);
|
||||
} else {
|
||||
Settings.System.putInt(context.getContentResolver(), "qch_tfmedia_forbid", 0);
|
||||
}
|
||||
}
|
||||
|
||||
private void setAppUpdate(Context context, String json) {
|
||||
com.alibaba.fastjson.JSONObject jsonObject = JSON.parseObject(json);
|
||||
String is_upgrade = jsonObject.getString("is_upgrade");
|
||||
String packageName = jsonObject.getString("package");
|
||||
String nowApplist = Settings.System.getString(context.getContentResolver(), "qch_app_forbid");
|
||||
List<String> applist = new ArrayList<>(Arrays.asList(nowApplist.split(",")));
|
||||
if (is_upgrade.equals("0")) {
|
||||
if (applist.contains(packageName)) {
|
||||
applist.remove(packageName);
|
||||
} else {
|
||||
Log.e("setAppUpdate", "app已经存在");
|
||||
}
|
||||
} else if (is_upgrade.equals("1")) {
|
||||
if (!applist.contains(packageName)) {
|
||||
applist.add(packageName);
|
||||
}
|
||||
}
|
||||
String packageString = "";
|
||||
for (String s : applist) {
|
||||
if (s.equals("")) {
|
||||
continue;
|
||||
}
|
||||
packageString += s + ",";
|
||||
}
|
||||
if (!packageString.equals("")) {
|
||||
packageString = packageString.substring(0, packageString.length() - 1);
|
||||
}
|
||||
Settings.System.putString(context.getContentResolver(), "qch_app_forbid", packageString);
|
||||
Log.e("setAppUpdate", Settings.System.getString(context.getContentResolver(), "qch_app_forbid"));
|
||||
}
|
||||
|
||||
synchronized private void sendStartTime(Context context, String jsonArray) {
|
||||
@@ -337,14 +439,22 @@ public class MyReceiver extends BroadcastReceiver {
|
||||
}
|
||||
}
|
||||
|
||||
private BluetoothAdapter mBluetoothAdapter;
|
||||
|
||||
synchronized private void setBluetoothState(Context context, String jsonArray) {
|
||||
if (jsonArray.length() > 0) {
|
||||
if (null == mBluetoothAdapter) {
|
||||
mBluetoothAdapter = BluetoothAdapter.getDefaultAdapter();//获取默认蓝牙适配器
|
||||
}
|
||||
try {
|
||||
JSONObject extra = new JSONObject(jsonArray);
|
||||
int is_bluetooth = extra.getInt("is_bluetooth");
|
||||
boolean qch_bt_forbid_on = Settings.System.putInt(context.getContentResolver(), "qch_bt_forbid_on", is_bluetooth);
|
||||
if (is_bluetooth==1){
|
||||
mBluetoothAdapter.disable();//设置关闭时关闭蓝牙
|
||||
}
|
||||
boolean qch_bt_forbid_on = Settings.System.putInt(context.getContentResolver(), "qch_bht_forbid_on", is_bluetooth);
|
||||
if (qch_bt_forbid_on) {
|
||||
LogUtils.e("setBluetoothState:", Settings.System.getString(context.getContentResolver(), "qch_bt_forbid_on"));
|
||||
LogUtils.e("setBluetoothState:", Settings.System.getString(context.getContentResolver(), "qch_bht_forbid_on"));
|
||||
} else {
|
||||
ToastUtil.debugShow("setBluetoothState failed,state:" + is_bluetooth);
|
||||
}
|
||||
@@ -364,17 +474,19 @@ public class MyReceiver extends BroadcastReceiver {
|
||||
String white = extra.getString("white");
|
||||
if (white != null && !white.equals("")) {
|
||||
boolean whiteList = Settings.System.putString(context.getContentResolver(), "DeselectBrowserArray", white);
|
||||
Log.e("SystemSetting", "setBrowserList---------" + whiteList + ":" + white);
|
||||
Log.e("SystemSetting", "setBrowserList-whiteList" + whiteList + ":" + white);
|
||||
} else {
|
||||
Settings.System.putString(context.getContentResolver(), "DeselectBrowserArray", " ");
|
||||
}
|
||||
Log.e("whiteList", Settings.System.getString(context.getContentResolver(), "DeselectBrowserArray"));
|
||||
String black = extra.getString("black");
|
||||
if (black != null && !black.equals("")) {
|
||||
boolean blackList = Settings.System.putString(context.getContentResolver(), "qch_webblack_url", black);
|
||||
Log.e("SystemSetting", "setBrowserList---------" + blackList + ":" + black);
|
||||
Log.e("SystemSetting", "setBrowserList-blackList" + blackList + ":" + black);
|
||||
} else {
|
||||
Settings.System.putString(context.getContentResolver(), "qch_webblack_url", " ");
|
||||
}
|
||||
Log.e("blackList", Settings.System.getString(context.getContentResolver(), "qch_webblack_url"));
|
||||
} catch (JSONException e) {
|
||||
e.printStackTrace();
|
||||
LogUtils.e("setBrowserUrlpath", e.getMessage());
|
||||
@@ -393,17 +505,17 @@ public class MyReceiver extends BroadcastReceiver {
|
||||
String package1 = extra.getString("package1");
|
||||
if (package0.length() != 0) {
|
||||
boolean qch_jgy_network_allow = Settings.System.putString(context.getContentResolver(), "qch_jgy_network_allow", package0);
|
||||
LogUtils.e("fht", "setAppNetworkstate::" + qch_jgy_network_allow + ":" + Settings.System.getString(context.getContentResolver(), "qch_jgy_network_allow"));
|
||||
LogUtils.e("fht", "qch_jgy_network_allow::" + qch_jgy_network_allow + ":" + Settings.System.getString(context.getContentResolver(), "qch_jgy_network_allow"));
|
||||
} else {
|
||||
boolean qch_jgy_network_allow = Settings.System.putString(context.getContentResolver(), "qch_jgy_network_allow", "invalid");
|
||||
LogUtils.e("fht", "setAppNetworkstate::" + qch_jgy_network_allow + ":" + Settings.System.getString(context.getContentResolver(), "qch_jgy_network_allow"));
|
||||
LogUtils.e("fht", "qch_jgy_network_allow::" + qch_jgy_network_allow + ":" + Settings.System.getString(context.getContentResolver(), "qch_jgy_network_allow"));
|
||||
}
|
||||
if (package1.length() != 0) {
|
||||
boolean qch_jgy_network_disallow = Settings.System.putString(context.getContentResolver(), "qch_jgy_network_disallow", package1);
|
||||
LogUtils.e("fht", "setAppNetworkstate::" + qch_jgy_network_disallow + ":" + Settings.System.getString(context.getContentResolver(), "qch_jgy_network_disallow"));
|
||||
LogUtils.e("fht", "qch_jgy_network_disallow::" + qch_jgy_network_disallow + ":" + Settings.System.getString(context.getContentResolver(), "qch_jgy_network_disallow"));
|
||||
} else {
|
||||
boolean qch_jgy_network_disallow = Settings.System.putString(context.getContentResolver(), "qch_jgy_network_disallow", "invalid");
|
||||
LogUtils.e("fht", "setAppNetworkstate::" + qch_jgy_network_disallow + ":" + Settings.System.getString(context.getContentResolver(), "qch_jgy_network_disallow"));
|
||||
LogUtils.e("fht", "qch_jgy_network_disallow::" + qch_jgy_network_disallow + ":" + Settings.System.getString(context.getContentResolver(), "qch_jgy_network_disallow"));
|
||||
}
|
||||
|
||||
} catch (JSONException e) {
|
||||
@@ -440,7 +552,8 @@ public class MyReceiver extends BroadcastReceiver {
|
||||
}
|
||||
|
||||
//静默安装应用,使用okgo,断网会出现问题,等待修改使用aria
|
||||
synchronized private void intallApk(String jsondata) {
|
||||
synchronized private void intallApk(Context context, String jsondata) {
|
||||
HTTPInterface.getAllAppPackageName(context);
|
||||
|
||||
try {
|
||||
JSONObject extra = new JSONObject(jsondata);
|
||||
@@ -503,7 +616,7 @@ public class MyReceiver extends BroadcastReceiver {
|
||||
if (!ApkUtils.isAvailable(context.getApplicationContext(), packageName)) {
|
||||
HTTPInterface.setAppuninstallInfo(sn_id, packageName);
|
||||
} else {
|
||||
ApkUtils.deleteApkInSilence(packageName);
|
||||
ApkUtils.uninstallApp(context, packageName);
|
||||
}
|
||||
}
|
||||
} catch (JSONException e) {
|
||||
|
||||
Reference in New Issue
Block a user