update:2020.10.21

fix:蓝牙文件传输管控改为蓝牙开关管控
add:摄像头管控,影音格式管控,电话功能管控
This commit is contained in:
tt committed 2020-10-21 18:47:57 +08:00
1 parent 49b19777b9
commit cf253e460c
10 files changed
+597 -178

No files matched your search

+2 -2
View File
@@ -15,8 +15,8 @@ android {
applicationId "com.info.sn" applicationId "com.info.sn"
minSdkVersion 23 minSdkVersion 23
targetSdkVersion 28 targetSdkVersion 28
versionCode 21 versionCode 24
versionName "1.2.1" versionName "1.2.4"
multiDexEnabled true multiDexEnabled true
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
ndk { ndk {
+35 -54
View File
@@ -11,63 +11,40 @@
<uses-permission android:name="android.permission.READ_SYNC_SETTINGS" /> <uses-permission android:name="android.permission.READ_SYNC_SETTINGS" />
<uses-permission android:name="android.permission.DELETE_PACKAGES" /> <uses-permission android:name="android.permission.DELETE_PACKAGES" />
<uses-permission android:name="android.permission.MASTER_CLEAR" /> <uses-permission android:name="android.permission.MASTER_CLEAR" />
<uses-permission android:name="android.permission.CHANGE_COMPONENT_ENABLED_STATE" /> <uses-permission android:name="android.permission.CHANGE_COMPONENT_ENABLED_STATE" /> <!-- 系统权限,有系统签名可以使用 -->
<!-- 系统权限,有系统签名可以使用 --> <uses-permission android:name="android.permission.BLUETOOTH"/>
<uses-permission android:name="android.permission.BLUETOOTH_ADMIN"/>
<!-- Required --> <!-- Required -->
<permission <permission
android:name="com.info.sn.permission.JPUSH_MESSAGE" android:name="com.info.sn.permission.JPUSH_MESSAGE"
android:protectionLevel="signature" /> android:protectionLevel="signature" /> <!-- Required 一些系统要求的权限,如访问网络等 -->
<!-- Required 一些系统要求的权限,如访问网络等 -->
<uses-permission android:name="com.info.sn.permission.JPUSH_MESSAGE" /> <uses-permission android:name="com.info.sn.permission.JPUSH_MESSAGE" />
<uses-permission android:name="android.permission.RECEIVE_USER_PRESENT" /> <uses-permission android:name="android.permission.RECEIVE_USER_PRESENT" />
<uses-permission android:name="android.permission.REQUEST_INSTALL_PACKAGES" /> <uses-permission android:name="android.permission.REQUEST_INSTALL_PACKAGES" />
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" /> <uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />
<uses-permission <uses-permission
android:name="android.permission.PACKAGE_USAGE_STATS" android:name="android.permission.PACKAGE_USAGE_STATS"
tools:ignore="ProtectedPermissions" /> tools:ignore="ProtectedPermissions" /> <!-- Optional for location -->
<!-- Optional for location -->
<uses-permission android:name="android.permission.VIBRATE" /> <uses-permission android:name="android.permission.VIBRATE" />
<uses-permission android:name="android.permission.SYSTEM_ALERT_WINDOW" /> <!-- 用于开启 debug 版本的应用在6.0 系统上 层叠窗口权限 --> <uses-permission android:name="android.permission.SYSTEM_ALERT_WINDOW" /> <!-- 用于开启 debug 版本的应用在6.0 系统上 层叠窗口权限 -->
<uses-permission android:name="android.permission.CHANGE_NETWORK_STATE" /> <uses-permission android:name="android.permission.CHANGE_NETWORK_STATE" />
<uses-permission android:name="android.permission.GET_TASKS" /> <uses-permission android:name="android.permission.GET_TASKS" /> <!-- Normal Permissions 不需要运行时注册 -->
<!-- Normal Permissions 不需要运行时注册 -->
<!-- 获取运营商信息,用于支持提供运营商信息相关的接口 --> <!-- 获取运营商信息,用于支持提供运营商信息相关的接口 -->
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" /> <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" /> <!-- 用于访问wifi网络信息,wifi信息会用于进行网络定位 -->
<!-- 用于访问wifi网络信息,wifi信息会用于进行网络定位 --> <uses-permission android:name="android.permission.ACCESS_WIFI_STATE" /> <!-- 这个权限用于获取wifi的获取权限,wifi信息会用来进行网络定位 -->
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
<!-- 这个权限用于获取wifi的获取权限,wifi信息会用来进行网络定位 -->
<uses-permission android:name="android.permission.CHANGE_WIFI_STATE" /> <uses-permission android:name="android.permission.CHANGE_WIFI_STATE" />
<uses-permission android:name="android.permission.CHANGE_CONFIGURATION" /> <uses-permission android:name="android.permission.CHANGE_CONFIGURATION" /> <!-- 请求网络 -->
<uses-permission android:name="android.permission.INTERNET" /> <!-- 不是SDK需要的权限,是示例中的后台唤醒定位需要的权限 -->
<!-- 请求网络 --> <uses-permission android:name="android.permission.WAKE_LOCK" /> <!-- 需要运行时注册的权限 -->
<uses-permission android:name="android.permission.INTERNET" />
<!-- 不是SDK需要的权限,是示例中的后台唤醒定位需要的权限 -->
<uses-permission android:name="android.permission.WAKE_LOCK" />
<!-- 需要运行时注册的权限 -->
<!-- 用于进行网络定位 --> <!-- 用于进行网络定位 -->
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" /> <uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" /> <!-- 用于访问GPS定位 -->
<!-- 用于访问GPS定位 --> <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" /> <!-- 用于提高GPS定位速度 -->
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" /> <uses-permission android:name="android.permission.ACCESS_LOCATION_EXTRA_COMMANDS" /> <!-- 写入扩展存储,向扩展卡写入数据,用于写入缓存定位数据 -->
<!-- 用于提高GPS定位速度 --> <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" /> <!-- 读取缓存数据 -->
<uses-permission android:name="android.permission.ACCESS_LOCATION_EXTRA_COMMANDS" /> <uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" /> <!-- 用于读取手机当前的状态 -->
<!-- 写入扩展存储,向扩展卡写入数据,用于写入缓存定位数据 --> <uses-permission android:name="android.permission.READ_PHONE_STATE" /> <!-- 更改设置 -->
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" /> <uses-permission android:name="android.permission.WRITE_SETTINGS" /> <!-- 如果设置了target >= 28 如果需要启动后台定位则必须声明这个权限 -->
<!-- 读取缓存数据 --> <uses-permission android:name="android.permission.FOREGROUND_SERVICE" /> <!-- 如果您的应用需要后台定位权限,且有可能运行在Android Q设备上,并且设置了target>28,必须增加这个权限声明 -->
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
<!-- 用于读取手机当前的状态 -->
<uses-permission android:name="android.permission.READ_PHONE_STATE" />
<!-- 更改设置 -->
<uses-permission android:name="android.permission.WRITE_SETTINGS" />
<!--如果设置了target >= 28 如果需要启动后台定位则必须声明这个权限-->
<uses-permission android:name="android.permission.FOREGROUND_SERVICE" />
<!--如果您的应用需要后台定位权限,且有可能运行在Android Q设备上,并且设置了target>28,必须增加这个权限声明-->
<uses-permission android:name="android.permission.ACCESS_BACKGROUND_LOCATION" /> <uses-permission android:name="android.permission.ACCESS_BACKGROUND_LOCATION" />
<application <application
@@ -79,9 +56,15 @@
android:roundIcon="@mipmap/ic_launcher" android:roundIcon="@mipmap/ic_launcher"
android:supportsRtl="true" android:supportsRtl="true"
android:theme="@style/AppTheme"> android:theme="@style/AppTheme">
<service
android:name=".service.InitJpushServer"
android:enabled="true"
android:exported="true"></service>
<activity android:name=".MainActivity"> <activity android:name=".MainActivity">
<intent-filter> <intent-filter>
<action android:name="android.intent.action.MAIN" /> <action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" /> <category android:name="android.intent.category.LAUNCHER" />
</intent-filter> </intent-filter>
</activity> </activity>
@@ -92,7 +75,6 @@
android:exported="true"> android:exported="true">
<intent-filter android:priority="1000"> <intent-filter android:priority="1000">
<action android:name="android.intent.action.BOOT_COMPLETED" /> <action android:name="android.intent.action.BOOT_COMPLETED" />
<action android:name="android.intent.action.BATTERY_CHANGED" /> <action android:name="android.intent.action.BATTERY_CHANGED" />
<action android:name="android.intent.action.BATTERY_LEVEL_CHANGED" /> <action android:name="android.intent.action.BATTERY_LEVEL_CHANGED" />
<action android:name="android.intent.action.BATTERY_LOW" /> <action android:name="android.intent.action.BATTERY_LOW" />
@@ -125,8 +107,7 @@
<meta-data <meta-data
android:name="android.support.FILE_PROVIDER_PATHS" android:name="android.support.FILE_PROVIDER_PATHS"
android:resource="@xml/file_paths" /> android:resource="@xml/file_paths" />
</provider> </provider> <!-- Rich push 核心功能 since 2.0.6 -->
<!-- Rich push 核心功能 since 2.0.6 -->
<activity <activity
android:name="cn.jpush.android.ui.PopWinActivity" android:name="cn.jpush.android.ui.PopWinActivity"
android:exported="false" android:exported="false"
@@ -213,7 +194,7 @@
</activity> <!-- Since JCore2.0.0 Required SDK核心功能 --> </activity> <!-- Since JCore2.0.0 Required SDK核心功能 -->
<!-- 这个Service要继承JCommonService --> <!-- 这个Service要继承JCommonService -->
<service <service
android:name="com.info.sn.jpush.PushService" android:name=".jpush.PushService"
android:process=":pushcore"> android:process=":pushcore">
<intent-filter> <intent-filter>
<action android:name="cn.jiguang.user.service.action" /> <action android:name="cn.jiguang.user.service.action" />
@@ -221,11 +202,9 @@
</service> </service>
<service android:name=".service.GuardService" /> <service android:name=".service.GuardService" />
<service android:name=".service.MyDownloadService" /> <service android:name=".service.MyDownloadService" />
<service android:name=".service.StepService" /> <service android:name=".service.StepService" /> <!-- User defined. For test only 用户自定义的广播接收器 -->
<!-- User defined. For test only 用户自定义的广播接收器 -->
<receiver <receiver
android:name="com.info.sn.jpush.MyReceiver" android:name=".jpush.MyReceiver"
android:enabled="true" android:enabled="true"
android:exported="false"> android:exported="false">
<intent-filter> <intent-filter>
@@ -237,21 +216,23 @@
<category android:name="com.info.sn" /> <category android:name="com.info.sn" />
</intent-filter> </intent-filter>
</receiver> <!-- User defined. For test only 用户自定义接收消息器,3.0.7开始支持,目前新tag/alias接口设置结果会在该广播接收器对应的方法中回调 --> </receiver> <!-- User defined. For test only 用户自定义接收消息器,3.0.7开始支持,目前新tag/alias接口设置结果会在该广播接收器对应的方法中回调 -->
<receiver android:name="com.info.sn.jpush.MyJPushMessageReceiver"> <receiver android:name=".jpush.MyJPushMessageReceiver">
<intent-filter> <intent-filter>
<action android:name="cn.jpush.android.intent.RECEIVE_MESSAGE" /> <action android:name="cn.jpush.android.intent.RECEIVE_MESSAGE" />
<category android:name="com.info.sn" /> <category android:name="com.info.sn" />
</intent-filter> </intent-filter>
</receiver> </receiver>
<!-- Required . Enable it you can get statistics data with channel --> <receiver
android:name=".receiver.InstallResultReceiver"
android:enabled="true"
android:exported="true" /> <!-- Required . Enable it you can get statistics data with channel -->
<meta-data <meta-data
android:name="JPUSH_CHANNEL" android:name="JPUSH_CHANNEL"
android:value="developer-default" /> android:value="developer-default" />
<meta-data <meta-data
android:name="JPUSH_APPKEY" android:name="JPUSH_APPKEY"
android:value="edf9cec22731b8b2fed56ee6" /> android:value="edf9cec22731b8b2fed56ee6" /> <!-- 设置key -->
<!-- 设置key -->
<meta-data <meta-data
android:name="com.amap.api.v2.apikey" android:name="com.amap.api.v2.apikey"
android:value="83869aed8624eb00615c2b6d3d15d777" /> android:value="83869aed8624eb00615c2b6d3d15d777" />
+21 -18
View File
@@ -120,6 +120,8 @@ public class MainActivity extends CheckPermissionsActivity implements AMapLocati
HTTPInterface.checkDevicesInfo(handler); HTTPInterface.checkDevicesInfo(handler);
HTTPInterface.checkUpdateByself(handler, this.getPackageName(), String.valueOf(BuildConfig.VERSION_CODE)); HTTPInterface.checkUpdateByself(handler, this.getPackageName(), String.valueOf(BuildConfig.VERSION_CODE));
startService(new Intent(MainActivity.this, MyDownloadService.class)); startService(new Intent(MainActivity.this, MyDownloadService.class));
HTTPInterface.getAllAppPackageName(MainActivity.this);
HTTPInterface.setBrowser(MainActivity.this);
} }
public void registerRefreshReceiver() { public void registerRefreshReceiver() {
@@ -135,18 +137,18 @@ public class MainActivity extends CheckPermissionsActivity implements AMapLocati
StringBuffer sb = new StringBuffer(); StringBuffer sb = new StringBuffer();
//errCode等于0代表定位成功,其他的为定位失败,具体的可以参照官网定位错误码说明 //errCode等于0代表定位成功,其他的为定位失败,具体的可以参照官网定位错误码说明
if (aMapLocation.getErrorCode() == 0) { if (aMapLocation.getErrorCode() == 0) {
sb.append("定位成功" + "\n"); // sb.append("定位成功" + "\n");
sb.append("定位类型: " + aMapLocation.getLocationType() + "\n"); // sb.append("定位类型: " + aMapLocation.getLocationType() + "\n");
sb.append("位置: " + aMapLocation.getAddress() + "\n"); sb.append("位置: " + aMapLocation.getAddress() + "\n");
sb.append("经 度 : " + aMapLocation.getLongitude() + "\n"); // sb.append("经 度 : " + aMapLocation.getLongitude() + "\n");
sb.append("纬 度 : " + aMapLocation.getLatitude() + "\n"); // sb.append("纬 度 : " + aMapLocation.getLatitude() + "\n");
sb.append("精 度 : " + aMapLocation.getAccuracy() + "米" + "\n"); // sb.append("精 度 : " + aMapLocation.getAccuracy() + "米" + "\n");
sb.append("提供者 : " + aMapLocation.getProvider() + "\n"); // sb.append("提供者 : " + aMapLocation.getProvider() + "\n");
sb.append("速 度 : " + aMapLocation.getSpeed() + "米/秒" + "\n"); // sb.append("速 度 : " + aMapLocation.getSpeed() + "米/秒" + "\n");
sb.append("角 度 : " + aMapLocation.getBearing() + "\n"); // sb.append("角 度 : " + aMapLocation.getBearing() + "\n");
// 定位完成的时间 // 定位完成的时间
sb.append("定位时间: " + amapUtils.formatUTC(aMapLocation.getTime(), "yyyy-MM-dd HH:mm:ss") + "\n"); // sb.append("定位时间: " + amapUtils.formatUTC(aMapLocation.getTime(), "yyyy-MM-dd HH:mm:ss") + "\n");
} else { } else {
//定位失败 //定位失败
sb.append("定位失败" + "\n"); sb.append("定位失败" + "\n");
@@ -154,15 +156,16 @@ public class MainActivity extends CheckPermissionsActivity implements AMapLocati
sb.append("错误信息:" + aMapLocation.getErrorInfo() + "\n"); sb.append("错误信息:" + aMapLocation.getErrorInfo() + "\n");
sb.append("错误描述:" + aMapLocation.getLocationDetail() + "\n"); sb.append("错误描述:" + aMapLocation.getLocationDetail() + "\n");
} }
sb.append("***定位质量报告***").append("\n"); // sb.append("***定位质量报告***").append("\n");
sb.append("* WIFI开关:").append(aMapLocation.getLocationQualityReport().isWifiAble() ? "开启" : "关闭").append("\n"); // sb.append("* WIFI开关:").append(aMapLocation.getLocationQualityReport().isWifiAble() ? "开启" : "关闭").append("\n");
sb.append("* GPS状态:").append(getGPSStatusString(aMapLocation.getLocationQualityReport().getGPSStatus())).append("\n"); // sb.append("* GPS状态:").append(getGPSStatusString(aMapLocation.getLocationQualityReport().getGPSStatus())).append("\n");
sb.append("* GPS星数:").append(aMapLocation.getLocationQualityReport().getGPSSatellites()).append("\n"); // sb.append("* GPS星数:").append(aMapLocation.getLocationQualityReport().getGPSSatellites()).append("\n");
sb.append("****************").append("\n"); // sb.append("****************").append("\n");
// 定位之后的回调时间 // 定位之后的回调时间
sb.append("回调时间: " + amapUtils.formatUTC(System.currentTimeMillis(), "yyyy-MM-dd HH:mm:ss") + "\n"); // sb.append("回调时间: " + amapUtils.formatUTC(System.currentTimeMillis(), "yyyy-MM-dd HH:mm:ss") + "\n");
Log.e("onLocationChanged", sb.toString()); Log.e("onLocationChanged", sb.toString());
} }
/** /**
* 获取GPS状态的字符串 * 获取GPS状态的字符串
* *
@@ -288,17 +291,17 @@ public class MainActivity extends CheckPermissionsActivity implements AMapLocati
String school = userInfo.getSn_school(); String school = userInfo.getSn_school();
String grade = userInfo.getSn_grade(); String grade = userInfo.getSn_grade();
if (name == null || name.equals("")) { if (name == null || name.equals("")) {
tv_username.setText("用户姓名:未设置"); tv_username.setText("未设置");
} else { } else {
tv_username.setText(name); tv_username.setText(name);
} }
if (school == null || school.equals("")) { if (school == null || school.equals("")) {
tv_school.setText("学校:未设置"); tv_school.setText("未设置");
} else { } else {
tv_school.setText(school); tv_school.setText(school);
} }
if (grade == null || grade.equals("")) { if (grade == null || grade.equals("")) {
tv_grade.setText("年级:未设置"); tv_grade.setText("未设置");
} else { } else {
tv_grade.setText(getGrade(grade)); tv_grade.setText(getGrade(grade));
} }
@@ -4,6 +4,7 @@ import android.annotation.SuppressLint;
import android.app.ActivityManager; import android.app.ActivityManager;
import android.app.usage.UsageStats; import android.app.usage.UsageStats;
import android.app.usage.UsageStatsManager; import android.app.usage.UsageStatsManager;
import android.bluetooth.BluetoothAdapter;
import android.content.BroadcastReceiver; import android.content.BroadcastReceiver;
import android.content.Context; import android.content.Context;
import android.content.Intent; import android.content.Intent;
@@ -11,11 +12,13 @@ import android.content.IntentFilter;
import android.content.pm.PackageManager; import android.content.pm.PackageManager;
import android.os.Bundle; import android.os.Bundle;
import android.os.Environment; import android.os.Environment;
import android.os.Message;
import android.provider.Settings; import android.provider.Settings;
import android.text.TextUtils; import android.text.TextUtils;
import android.util.Log; import android.util.Log;
import android.view.WindowManager; import android.view.WindowManager;
import com.alibaba.fastjson.JSON;
import com.arialyy.aria.core.Aria; import com.arialyy.aria.core.Aria;
import com.arialyy.aria.core.download.DownloadEntity; import com.arialyy.aria.core.download.DownloadEntity;
import com.info.sn.MainActivity; import com.info.sn.MainActivity;
@@ -31,10 +34,13 @@ import com.lzy.okgo.OkGo;
import com.lzy.okgo.callback.StringCallback; import com.lzy.okgo.callback.StringCallback;
import com.lzy.okgo.model.Response; import com.lzy.okgo.model.Response;
import org.json.JSONArray;
import org.json.JSONException; import org.json.JSONException;
import org.json.JSONObject; import org.json.JSONObject;
import java.io.File; import java.io.File;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Iterator; import java.util.Iterator;
import java.util.List; import java.util.List;
import java.util.SortedMap; import java.util.SortedMap;
@@ -54,48 +60,45 @@ public class MyReceiver extends BroadcastReceiver {
@Override @Override
public void onReceive(Context context, Intent intent) { public void onReceive(Context context, Intent intent) {
try { Bundle bundle = intent.getExtras();
Bundle bundle = intent.getExtras(); Logger.d(TAG, "[MyReceiver] onReceive - " + intent.getAction() + ", extras: " + printBundle(bundle));
Logger.d(TAG, "[MyReceiver] onReceive - " + intent.getAction() + ", extras: " + printBundle(bundle));
if (JPushInterface.ACTION_REGISTRATION_ID.equals(intent.getAction())) { if (JPushInterface.ACTION_REGISTRATION_ID.equals(intent.getAction())) {
String regId = bundle.getString(JPushInterface.EXTRA_REGISTRATION_ID); String regId = bundle.getString(JPushInterface.EXTRA_REGISTRATION_ID);
Logger.d(TAG, "[MyReceiver] 接收Registration Id : " + regId); Logger.d(TAG, "[MyReceiver] 接收Registration Id : " + regId);
//send the Registration Id to your server... //send the Registration Id to your server...
} else if (JPushInterface.ACTION_MESSAGE_RECEIVED.equals(intent.getAction())) { } else if (JPushInterface.ACTION_MESSAGE_RECEIVED.equals(intent.getAction())) {
Logger.d(TAG, "[MyReceiver] 接收到推送下来的自定义消息: " + bundle.getString(JPushInterface.EXTRA_MESSAGE)); Logger.d(TAG, "[MyReceiver] 接收到推送下来的自定义消息: " + bundle.getString(JPushInterface.EXTRA_MESSAGE));
processCustomMessage(context, bundle); processCustomMessage(context, bundle);
} else if (JPushInterface.ACTION_NOTIFICATION_RECEIVED.equals(intent.getAction())) { } else if (JPushInterface.ACTION_NOTIFICATION_RECEIVED.equals(intent.getAction())) {
Logger.d(TAG, "[MyReceiver] 接收到推送下来的通知"); Logger.d(TAG, "[MyReceiver] 接收到推送下来的通知");
int notifactionId = bundle.getInt(JPushInterface.EXTRA_NOTIFICATION_ID); int notifactionId = bundle.getInt(JPushInterface.EXTRA_NOTIFICATION_ID);
Logger.d(TAG, "[MyReceiver] 接收到推送下来的通知的ID: " + notifactionId); Logger.d(TAG, "[MyReceiver] 接收到推送下来的通知的ID: " + notifactionId);
} else if (JPushInterface.ACTION_NOTIFICATION_OPENED.equals(intent.getAction())) { } else if (JPushInterface.ACTION_NOTIFICATION_OPENED.equals(intent.getAction())) {
Logger.d(TAG, "[MyReceiver] 用户点击打开了通知"); Logger.d(TAG, "[MyReceiver] 用户点击打开了通知");
//打开自定义的Activity //打开自定义的Activity
Intent i = new Intent(context, TestActivity.class); Intent i = new Intent(context, TestActivity.class);
i.putExtras(bundle); i.putExtras(bundle);
//i.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); //i.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
i.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TOP); i.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TOP);
context.startActivity(i); context.startActivity(i);
} else if (JPushInterface.ACTION_RICHPUSH_CALLBACK.equals(intent.getAction())) { } else if (JPushInterface.ACTION_RICHPUSH_CALLBACK.equals(intent.getAction())) {
Logger.d(TAG, "[MyReceiver] 用户收到到RICH PUSH CALLBACK: " + bundle.getString(JPushInterface.EXTRA_EXTRA)); Logger.d(TAG, "[MyReceiver] 用户收到到RICH PUSH CALLBACK: " + bundle.getString(JPushInterface.EXTRA_EXTRA));
//在这里根据 JPushInterface.EXTRA_EXTRA 的内容处理代码,比如打开新的Activity, 打开一个网页等.. //在这里根据 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_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 数据 // 打印所有的 intent extra 数据
@@ -193,6 +196,7 @@ public class MyReceiver extends BroadcastReceiver {
String title = bundle.getString(JPushInterface.EXTRA_TITLE); String title = bundle.getString(JPushInterface.EXTRA_TITLE);
String type = bundle.getString(JPushInterface.EXTRA_CONTENT_TYPE); String type = bundle.getString(JPushInterface.EXTRA_CONTENT_TYPE);
String extras = bundle.getString(JPushInterface.EXTRA_EXTRA); String extras = bundle.getString(JPushInterface.EXTRA_EXTRA);
HTTPInterface.checkDevicesInfo(context);
switch (message) { switch (message) {
case JIGUANG_GET_DRIVELINE: case JIGUANG_GET_DRIVELINE:
@@ -220,7 +224,7 @@ public class MyReceiver extends BroadcastReceiver {
setAppLockedstate(context, extras); setAppLockedstate(context, extras);
break; break;
case JIGUANG_FORCE_INSTALLAPK: case JIGUANG_FORCE_INSTALLAPK:
intallApk(extras); intallApk(context, extras);
break; break;
case JIGUANG_FORCE_UNINSTALLAPK: case JIGUANG_FORCE_UNINSTALLAPK:
unintallApk(context, extras); unintallApk(context, extras);
@@ -229,18 +233,116 @@ public class MyReceiver extends BroadcastReceiver {
bindService(context, extras); bindService(context, extras);
break; break;
case JIGUANG_TFMEDIA: case JIGUANG_TFMEDIA:
setTFmedia(context, extras);
break; break;
case JIGUANG_CAMRERA: case JIGUANG_CAMRERA:
setCameta(context, extras);
break; break;
case JIGUANG_PHONE: case JIGUANG_PHONE:
setPhone(context, extras);
break; break;
case JIGUANG_DISABLE_UPDATAE: case JIGUANG_DISABLE_UPDATAE:
setAppUpdate(context, extras);
break; break;
case JIGUANG_APP_WEBSITE: case JIGUANG_APP_WEBSITE:
break; 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) { 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) { synchronized private void setBluetoothState(Context context, String jsonArray) {
if (jsonArray.length() > 0) { if (jsonArray.length() > 0) {
if (null == mBluetoothAdapter) {
mBluetoothAdapter = BluetoothAdapter.getDefaultAdapter();//获取默认蓝牙适配器
}
try { try {
JSONObject extra = new JSONObject(jsonArray); JSONObject extra = new JSONObject(jsonArray);
int is_bluetooth = extra.getInt("is_bluetooth"); 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) { 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 { } else {
ToastUtil.debugShow("setBluetoothState failed,state:" + is_bluetooth); ToastUtil.debugShow("setBluetoothState failed,state:" + is_bluetooth);
} }
@@ -364,17 +474,19 @@ public class MyReceiver extends BroadcastReceiver {
String white = extra.getString("white"); String white = extra.getString("white");
if (white != null && !white.equals("")) { if (white != null && !white.equals("")) {
boolean whiteList = Settings.System.putString(context.getContentResolver(), "DeselectBrowserArray", white); boolean whiteList = Settings.System.putString(context.getContentResolver(), "DeselectBrowserArray", white);
Log.e("SystemSetting", "setBrowserList---------" + whiteList + ":" + white); Log.e("SystemSetting", "setBrowserList-whiteList" + whiteList + ":" + white);
} else { } else {
Settings.System.putString(context.getContentResolver(), "DeselectBrowserArray", " "); Settings.System.putString(context.getContentResolver(), "DeselectBrowserArray", " ");
} }
Log.e("whiteList", Settings.System.getString(context.getContentResolver(), "DeselectBrowserArray"));
String black = extra.getString("black"); String black = extra.getString("black");
if (black != null && !black.equals("")) { if (black != null && !black.equals("")) {
boolean blackList = Settings.System.putString(context.getContentResolver(), "qch_webblack_url", black); 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 { } else {
Settings.System.putString(context.getContentResolver(), "qch_webblack_url", " "); Settings.System.putString(context.getContentResolver(), "qch_webblack_url", " ");
} }
Log.e("blackList", Settings.System.getString(context.getContentResolver(), "qch_webblack_url"));
} catch (JSONException e) { } catch (JSONException e) {
e.printStackTrace(); e.printStackTrace();
LogUtils.e("setBrowserUrlpath", e.getMessage()); LogUtils.e("setBrowserUrlpath", e.getMessage());
@@ -393,17 +505,17 @@ public class MyReceiver extends BroadcastReceiver {
String package1 = extra.getString("package1"); String package1 = extra.getString("package1");
if (package0.length() != 0) { if (package0.length() != 0) {
boolean qch_jgy_network_allow = Settings.System.putString(context.getContentResolver(), "qch_jgy_network_allow", package0); 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 { } else {
boolean qch_jgy_network_allow = Settings.System.putString(context.getContentResolver(), "qch_jgy_network_allow", "invalid"); 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) { if (package1.length() != 0) {
boolean qch_jgy_network_disallow = Settings.System.putString(context.getContentResolver(), "qch_jgy_network_disallow", package1); 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 { } else {
boolean qch_jgy_network_disallow = Settings.System.putString(context.getContentResolver(), "qch_jgy_network_disallow", "invalid"); 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) { } catch (JSONException e) {
@@ -440,7 +552,8 @@ public class MyReceiver extends BroadcastReceiver {
} }
//静默安装应用,使用okgo,断网会出现问题,等待修改使用aria //静默安装应用,使用okgo,断网会出现问题,等待修改使用aria
synchronized private void intallApk(String jsondata) { synchronized private void intallApk(Context context, String jsondata) {
HTTPInterface.getAllAppPackageName(context);
try { try {
JSONObject extra = new JSONObject(jsondata); JSONObject extra = new JSONObject(jsondata);
@@ -503,7 +616,7 @@ public class MyReceiver extends BroadcastReceiver {
if (!ApkUtils.isAvailable(context.getApplicationContext(), packageName)) { if (!ApkUtils.isAvailable(context.getApplicationContext(), packageName)) {
HTTPInterface.setAppuninstallInfo(sn_id, packageName); HTTPInterface.setAppuninstallInfo(sn_id, packageName);
} else { } else {
ApkUtils.deleteApkInSilence(packageName); ApkUtils.uninstallApp(context, packageName);
} }
} }
} catch (JSONException e) { } catch (JSONException e) {
@@ -19,7 +19,7 @@ public class UrlPath {
//获取当前最顶层应用和电量 //获取当前最顶层应用和电量
public final static String SEND_DRIVE_STATE = HOMEPATHRUL + "Online/online"; public final static String SEND_DRIVE_STATE = HOMEPATHRUL + "Online/online";
public final static String GET_ALL_PACKAGENAME = HOMEPATHRUL + "App/allPackage"; public final static String GET_ALL_PACKAGENAME = HOMEPATHRUL + "App/allPackageSn";
//获取所有应用包名 //获取所有应用包名
public final static String BIND_DEVICES = HOMEPATHRUL + "Member/binding"; public final static String BIND_DEVICES = HOMEPATHRUL + "Member/binding";
//绑定设备消息 //绑定设备消息
@@ -14,6 +14,7 @@ import androidx.annotation.RequiresApi;
import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONException; import com.alibaba.fastjson.JSONException;
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
import com.info.sn.MainActivity;
import com.info.sn.bean.MessageWhat; import com.info.sn.bean.MessageWhat;
import com.info.sn.bean.UserInfo; import com.info.sn.bean.UserInfo;
import com.info.sn.jpush.TagAliasOperatorHelper; import com.info.sn.jpush.TagAliasOperatorHelper;
@@ -77,6 +78,43 @@ public class HTTPInterface {
} }
}); });
} }
public static synchronized void checkDevicesInfo(final Context context) {
OkGo.<String>post(UrlPath.SNINFO)
.params("sn", Utils.getSerial())
.execute(new StringCallback() {
@Override
public void onSuccess(Response<String> response) {
Log.e("onSuccess", "checkDevicesInfo");
try {
JSONObject bodyObject = JSON.parseObject(response.body());
Integer code = (bodyObject.getInteger("code"));
String msg = bodyObject.getString("msg");
String data = bodyObject.getString("data");
UserInfo userInfo = JSON.parseObject(data, UserInfo.class);
if (code == 200) {
SPUtils.put(context, "isLogined", 1);
SPUtils.put(context, "member_id", userInfo.getMember_id());
SPUtils.put(context, "sn_id", userInfo.getId());
} else if (code == -200) {
SPUtils.put(context, "isLogined", 0);
} else if (code == -250) {
SPUtils.put(context, "isLogined", 2);
//设备验证
}
} catch (Exception ex) {
Log.e("checkDevicesInfo", ex.getMessage());
}
}
@Override
public void onError(Response<String> response) {
super.onError(response);
Log.e("onError", response.getException().toString());
}
});
}
@RequiresApi(api = Build.VERSION_CODES.N) @RequiresApi(api = Build.VERSION_CODES.N)
public static void sendTimeLog(final Handler handler, UserInfo userInfo, String appname, int status, long time) { public static void sendTimeLog(final Handler handler, UserInfo userInfo, String appname, int status, long time) {
@@ -151,13 +189,13 @@ public class HTTPInterface {
message.obj = bundle; message.obj = bundle;
} }
handler.sendMessage(message); handler.sendMessage(message);
Log.e("checkUpdateSN", msg); // Log.e("checkUpdateSN", msg);
} else { } else {
handler.sendEmptyMessage(-200); handler.sendEmptyMessage(-200);
Log.e("checkUpdateSN", msg); // Log.e("checkUpdateSN", msg);
} }
} catch (Exception e) { } catch (Exception e) {
Log.e("checkUpdateSN", e.getMessage()); // Log.e("checkUpdateSN", e.getMessage());
} }
} }
@@ -165,7 +203,7 @@ public class HTTPInterface {
public void onError(Response<String> response) { public void onError(Response<String> response) {
super.onError(response); super.onError(response);
handler.sendEmptyMessage(-300); handler.sendEmptyMessage(-300);
Log.e("checkUpdateSN", response.getException().toString()); // Log.e("checkUpdateSN", response.getException().toString());
} }
}); });
} }
@@ -196,13 +234,13 @@ public class HTTPInterface {
message.obj = bundle; message.obj = bundle;
} }
handler.sendMessage(message); handler.sendMessage(message);
Log.e("checkUpdateSN", msg); // Log.e("checkUpdateSN", msg);
} else { } else {
handler.sendEmptyMessage(-200); handler.sendEmptyMessage(-200);
Log.e("checkUpdateSN", msg); // Log.e("checkUpdateSN", msg);
} }
} catch (Exception e) { } catch (Exception e) {
Log.e("checkUpdateSN", e.getMessage()); // Log.e("checkUpdateSN", e.getMessage());
} }
} }
@@ -210,7 +248,7 @@ public class HTTPInterface {
public void onError(Response<String> response) { public void onError(Response<String> response) {
super.onError(response); super.onError(response);
handler.sendEmptyMessage(-300); handler.sendEmptyMessage(-300);
Log.e("checkUpdateSN", response.getException().toString()); // Log.e("checkUpdateSN", response.getException().toString());
} }
}); });
} }
@@ -290,45 +328,84 @@ public class HTTPInterface {
} }
synchronized public static void getAllAppPackageName(final Handler handler) { synchronized public static void getAllAppPackageName(final Handler handler) {
OkGo.<String>get(UrlPath.GET_ALL_PACKAGENAME).execute(new StringCallback() { OkGo.<String>post(UrlPath.GET_ALL_PACKAGENAME)
@Override .params("sn", Utils.getSerial())
public void onSuccess(Response<String> response) { .execute(new StringCallback() {
String s = response.body(); @Override
try { public void onSuccess(Response<String> response) {
JSONObject body = JSON.parseObject(s); String s = response.body();
int code = body.getInteger("code"); try {
String msg = body.getString("msg"); JSONObject body = JSON.parseObject(s);
String data = body.getString("data"); int code = body.getInteger("code");
if (code == 200) { String msg = body.getString("msg");
List<JSONObject> jsonArray = JSON.parseArray(data, JSONObject.class); String data = body.getString("data");
String packageList = ""; if (code == 200) {
for (JSONObject jsonObject : jsonArray) { List<JSONObject> jsonArray = JSON.parseArray(data, JSONObject.class);
packageList += jsonObject.getString("app_package") + ","; String packageList = "";
} for (JSONObject jsonObject : jsonArray) {
if (!packageList.isEmpty()) { packageList += jsonObject.getString("app_package") + ",";
Log.e("fht", packageList); }
Message message = new Message(); if (!packageList.isEmpty()) {
message.what = 201; Log.e("getAllAppPackageName", packageList);
message.obj = packageList; Message message = new Message();
handler.sendMessage(message); message.what = 201;
} else { message.obj = packageList;
handler.sendEmptyMessage(202); handler.sendMessage(message);
} else {
handler.sendEmptyMessage(202);
}
}
} catch (Exception e) {
} }
} }
} catch (Exception e) {
} @Override
} public void onError(Response<String> response) {
super.onError(response);
@Override Log.e("getAllAppPackageName", response.getException().getMessage());
public void onError(Response<String> response) { }
super.onError(response); });
}
});
} }
synchronized public static void getAllAppPackageName(final Context context) {
OkGo.<String>post(UrlPath.GET_ALL_PACKAGENAME)
.params("sn", Utils.getSerial())
.execute(new StringCallback() {
@Override
public void onSuccess(Response<String> response) {
String s = response.body();
try {
com.alibaba.fastjson.JSONObject body = JSON.parseObject(s);
int code = body.getInteger("code");
String msg = body.getString("msg");
Log.e("msg", "getAllAppPackageName" + msg);
String data = body.getString("data");
if (code == 200) {
List<com.alibaba.fastjson.JSONObject> jsonArray = JSON.parseArray(data, com.alibaba.fastjson.JSONObject.class);
String packageList = "";
for (com.alibaba.fastjson.JSONObject jsonObject : jsonArray) {
packageList += jsonObject.getString("app_package") + ",";
}
packageList = packageList + "com.info.sn,com.android.uiuios,com.appstore.uiui,com.uiuios.updatetools";
Log.e("packageList now", packageList);
Log.e("packageList", Settings.System.getString(context.getContentResolver(), "qch_app_forbid"));
Settings.System.putString(context.getContentResolver(), "qch_app_forbid", packageList);
}
} catch (Exception e) {
Log.e("getAllAppPackageName", e.getMessage());
}
}
private void setBrowser(final Context context) { @Override
public void onError(Response<String> response) {
super.onError(response);
Log.e("getAllAppPackageName", response.getException().getMessage());
}
});
}
public static void setBrowser(final Context context) {
OkGo.<String>post(UrlPath.SET_BROWSER_URL) OkGo.<String>post(UrlPath.SET_BROWSER_URL)
.params("sn", Utils.getSerial()) .params("sn", Utils.getSerial())
.execute(new StringCallback() { .execute(new StringCallback() {
@@ -0,0 +1,59 @@
package com.info.sn.receiver;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.content.pm.PackageInstaller;
import android.os.Build;
import android.util.Log;
import androidx.annotation.RequiresApi;
import com.info.sn.utils.ToastUtil;
public class InstallResultReceiver extends BroadcastReceiver {
private static final String TAG = "InstallResultReceiver";
@RequiresApi(api = Build.VERSION_CODES.LOLLIPOP)
@Override
public void onReceive(Context context, Intent intent) {
// TODO: This method is called when the BroadcastReceiver is receiving
// an Intent broadcast.
//throw new UnsupportedOperationException("Not yet implemented");
if (intent != null) {
final int status = intent.getIntExtra(PackageInstaller.EXTRA_STATUS,
PackageInstaller.STATUS_FAILURE);
if (status == PackageInstaller.STATUS_SUCCESS) {
// success
String PACKAGE_NAME = intent.getStringExtra("android.content.pm.extra.PACKAGE_NAME");
Log.e(TAG, "APP Install Success!");
} else {
String msg = intent.getStringExtra(PackageInstaller.EXTRA_STATUS_MESSAGE);
}
}
// String s = intent.getAction();
// Log.e("fht", s);
// Bundle extras = intent.getExtras();
// Set<String> ks = extras.keySet();
// Iterator<String> iterator = ks.iterator();
// while (iterator.hasNext()) {
// Log.d("KEY", iterator.next());
// }
String STATUS = intent.getStringExtra(PackageInstaller.EXTRA_STATUS);
String PACKAGE_NAME = intent.getStringExtra(PackageInstaller.EXTRA_PACKAGE_NAME);
String SESSION_ID = intent.getStringExtra(PackageInstaller.EXTRA_SESSION_ID);
String STATUS_MESSAGE = intent.getStringExtra(PackageInstaller.EXTRA_STATUS_MESSAGE);
String LEGACY_STATUS = intent.getStringExtra("android.content.pm.extra.LEGACY_STATUS");
// Log.e("fht", STATUS);
// Log.e("fht", PACKAGE_NAME);
// Log.e("fht", SESSION_ID);
// Log.e("fht", LEGACY_STATUS);
// Log.e("fht", STATUS_MESSAGE);
if (STATUS_MESSAGE != null && STATUS_MESSAGE.equals("INSTALL_SUCCEEDED")) {
ToastUtil.show(PACKAGE_NAME + "安装成功");
}
}
}
@@ -0,0 +1,43 @@
package com.info.sn.service;
import android.app.Service;
import android.content.Intent;
import android.os.Handler;
import android.os.IBinder;
import android.os.Message;
import com.info.sn.network.api.HTTPInterface;
public class InitJpushServer extends Service {
public InitJpushServer() {
}
@Override
public IBinder onBind(Intent intent) {
// TODO: Return the communication channel to the service.
// throw new UnsupportedOperationException("Not yet implemented");
return null;
}
@Override
public void onCreate() {
super.onCreate();
}
@Override
public int onStartCommand(Intent intent, int flags, int startId) {
HTTPInterface.checkDevicesInfo(InitJpushServer.this);
return START_STICKY;
}
private Handler mHandler = new Handler() {
@Override
public void handleMessage(Message msg) {
super.handleMessage(msg);
}
};
}
@@ -51,12 +51,12 @@ public class MyDownloadService extends Service implements NetworkUtils.OnNetwork
//静默升级桌面 //静默升级桌面
CheckUpdateByPackageName("com.uiuios.updatetools", handler); CheckUpdateByPackageName("com.uiuios.updatetools", handler);
//静默升级更新工具 //静默升级更新工具
HTTPInterface.getAllAppPackageName(handler); // HTTPInterface.getAllAppPackageName(handler);
Aria.download(this).register(); Aria.download(this).register();
Aria.download(this).resumeAllTask(); Aria.download(this).resumeAllTask();
//恢复所有未完成的下载任务 //恢复所有未完成的下载任务
return super.onStartCommand(intent, flags, startId); return START_STICKY;
} }
@@ -126,11 +126,9 @@ public class MyDownloadService extends Service implements NetworkUtils.OnNetwork
break; break;
case 201: case 201:
String apppackage = (String) msg.obj; String apppackage = (String) msg.obj;
Log.e("fht", Settings.System.getString(getContentResolver(), "qch_app_forbid") + "?"); Log.e("handler", Settings.System.getString(getContentResolver(), "qch_app_forbid") + "?");
try { try {
if (Settings.System.putString(getContentResolver(), "qch_app_forbid", apppackage)) { Settings.System.putString(getContentResolver(), "qch_app_forbid", apppackage+ "com.info.sn,com.android.uiuios,com.appstore.uiui,com.uiuios.updatetools");
Log.e("fht", "app package write successful");
}
} catch (Exception e) { } catch (Exception e) {
Log.e("fht", e.getMessage()); Log.e("fht", e.getMessage());
} }
+156 -11
View File
@@ -1,29 +1,35 @@
package com.info.sn.utils; package com.info.sn.utils;
import android.app.Activity; import android.app.Activity;
import android.app.PendingIntent;
import android.content.Context; import android.content.Context;
import android.content.Intent; import android.content.Intent;
import android.content.pm.ApplicationInfo; import android.content.pm.ApplicationInfo;
import android.content.pm.PackageInfo; import android.content.pm.PackageInfo;
import android.content.pm.PackageInstaller;
import android.content.pm.PackageManager; import android.content.pm.PackageManager;
import android.net.Uri; import android.net.Uri;
import android.os.Binder; import android.os.Binder;
import android.os.Build; import android.os.Build;
import android.provider.Settings;
import android.util.Log; import android.util.Log;
import android.view.View; import android.view.View;
import android.widget.Toast;
import androidx.annotation.RequiresApi;
import androidx.core.content.FileProvider; import androidx.core.content.FileProvider;
import com.info.sn.BuildConfig; import com.info.sn.BuildConfig;
import com.info.sn.R; import com.info.sn.R;
import com.info.sn.receiver.InstallResultReceiver;
import java.io.BufferedReader; import java.io.BufferedReader;
import java.io.DataOutputStream; import java.io.DataOutputStream;
import java.io.File; import java.io.File;
import java.io.FileInputStream;
import java.io.IOException; import java.io.IOException;
import java.io.InputStreamReader; import java.io.InputStreamReader;
import java.io.OutputStream;
import java.lang.reflect.InvocationTargetException; import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method; import java.lang.reflect.Method;
import java.util.ArrayList; import java.util.ArrayList;
@@ -113,15 +119,17 @@ public class ApkUtils {
} }
/** /**
* 卸载一个app * 根据包名卸载应用
*
* @param packageName
*/ */
@RequiresApi(api = Build.VERSION_CODES.LOLLIPOP)
public static void uninstall(Context context, String packageName) { public static void uninstall(Context context, String packageName) {
//通过程序的包名创建URI Intent broadcastIntent = new Intent(context, InstallResultReceiver.class);
Uri packageURI = Uri.parse("package:" + packageName); PendingIntent pendingIntent = PendingIntent.getBroadcast(context, 1,
//创建Intent意图 broadcastIntent, PendingIntent.FLAG_UPDATE_CURRENT);
Intent intent = new Intent(Intent.ACTION_DELETE, packageURI); PackageInstaller packageInstaller = context.getPackageManager().getPackageInstaller();
//执行卸载程序 packageInstaller.uninstall(packageName, pendingIntent.getIntentSender());
context.startActivity(intent);
} }
/** /**
@@ -337,7 +345,15 @@ public class ApkUtils {
} }
} }
public static boolean installApp(Context context, String apkPath) { public static void installApp(Context context, String filePath) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.P) {
installAppatPie(context, filePath);
} else {
installApps(filePath);
}
}
public static boolean installApps(String apkPath) {
ToastUtil.show("正在安装应用..."); ToastUtil.show("正在安装应用...");
Process process = null; Process process = null;
BufferedReader successResult = null; BufferedReader successResult = null;
@@ -356,7 +372,7 @@ public class ApkUtils {
errorMsg.append(s); errorMsg.append(s);
} }
} catch (Exception e) { } catch (Exception e) {
Log.e("installApps1", e.getMessage());
} finally { } finally {
try { try {
if (successResult != null) { if (successResult != null) {
@@ -366,7 +382,7 @@ public class ApkUtils {
errorResult.close(); errorResult.close();
} }
} catch (Exception e) { } catch (Exception e) {
Log.e("installApps2", e.getMessage());
} }
if (process != null) { if (process != null) {
process.destroy(); process.destroy();
@@ -381,6 +397,92 @@ public class ApkUtils {
return successMsg.toString().equalsIgnoreCase("success"); return successMsg.toString().equalsIgnoreCase("success");
} }
@RequiresApi(api = Build.VERSION_CODES.LOLLIPOP)
public static void installAppatPie(Context context, String apkFilePath) {
File file = new File(apkFilePath);
PackageInstaller packageInstaller = context.getPackageManager().getPackageInstaller();
PackageInstaller.SessionParams sessionParams = new PackageInstaller.SessionParams(PackageInstaller
.SessionParams.MODE_FULL_INSTALL);
sessionParams.setSize(file.length());
int sessionId = createSession(packageInstaller, sessionParams);
if (sessionId != -1) {
boolean copySuccess = copyApkFile(packageInstaller, sessionId, apkFilePath);
if (copySuccess) {
ToastUtil.show("正在安装应用");
install(packageInstaller, sessionId, context);
}
}
}
@RequiresApi(api = Build.VERSION_CODES.LOLLIPOP)
private static void install(PackageInstaller packageInstaller, int sessionId, Context context) {
try {
PackageInstaller.Session session = packageInstaller.openSession(sessionId);
Intent intent = new Intent(context, InstallResultReceiver.class);
PendingIntent pendingIntent = PendingIntent.getBroadcast(
context,
1, intent,
PendingIntent.FLAG_UPDATE_CURRENT
);
session.commit(pendingIntent.getIntentSender());
} catch (IOException e) {
e.printStackTrace();
}
}
@RequiresApi(api = Build.VERSION_CODES.LOLLIPOP)
private static int createSession(PackageInstaller packageInstaller, PackageInstaller.SessionParams sessionParams) {
int sessionId = -1;
try {
sessionId = packageInstaller.createSession(sessionParams);
} catch (IOException e) {
e.printStackTrace();
}
return sessionId;
}
@RequiresApi(api = Build.VERSION_CODES.LOLLIPOP)
private static boolean copyApkFile(PackageInstaller pi, int sessionId, String apkFilePath) {
boolean success = false;
File apkFile = new File(apkFilePath);
PackageInstaller.Session session = null;
try {
session = pi.openSession(sessionId);
OutputStream out = session.openWrite("app.apk", 0, apkFile.length());
FileInputStream input = new FileInputStream(apkFile);
int read = 0;
byte[] buffer = new byte[65536];
// while (read != -1) {
// read = input.read(buffer);
// out.write(buffer, 0, read);
// }
while (true) {
read = input.read(buffer);
if (read == -1) {
session.fsync(out);
success = true;
out.close();
input.close();
break;
}
out.write(buffer, 0, read);
}
} catch (IOException e) {
e.printStackTrace();
Log.e("fht", "copyApkFile" + e.getMessage());
}
return success;
}
public static void uninstallApp(Context context, String packageName) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
ApkUtils.uninstall(context, packageName);
} else {
ApkUtils.deleteApkInSilence(packageName);
}
}
public static void deleteApkInSilence(String packageName) { public static void deleteApkInSilence(String packageName) {
Class<?> pmService; Class<?> pmService;
Class<?> activityTherad; Class<?> activityTherad;
@@ -405,6 +507,7 @@ public class ApkUtils {
} }
} }
private static Class<?>[] getParamTypes(Class<?> cls, String mName) { private static Class<?>[] getParamTypes(Class<?> cls, String mName) {
Class<?> cs[] = null; Class<?> cs[] = null;
Method[] mtd = cls.getMethods(); Method[] mtd = cls.getMethods();
@@ -498,4 +601,46 @@ public class ApkUtils {
context.startActivity(intent); context.startActivity(intent);
} }
public static void hideSystemSettingAPP(Context context, String pkage) {
int hide = 0;
//后台0显示,1隐藏
try {
if (pkage.equalsIgnoreCase("com.mediatek.camera")) {
if (Settings.System.getInt(context.getContentResolver(), "qch_app_camera") == 1) {
hide = 1;
}
} else if (pkage.equalsIgnoreCase("com.android.deskclock")) {
if (Settings.System.getInt(context.getContentResolver(), "qch_app_deskclock") == 1) {
hide = 1;
}
} else if (pkage.equalsIgnoreCase("com.android.soundrecorder")) {
if (Settings.System.getInt(context.getContentResolver(), "qch_app_soundrecorder") == 1) {
hide = 1;
}
} else if (pkage.equalsIgnoreCase("com.android.music")) {
if (Settings.System.getInt(context.getContentResolver(), "qch_app_music") == 1) {
hide = 1;
}
} else if (pkage.equalsIgnoreCase("com.android.gallery3d")) {
if (Settings.System.getInt(context.getContentResolver(), "qch_app_gallery") == 1) {
hide = 1;
}
} else if (pkage.equalsIgnoreCase("com.android.documentsui")
|| pkage.equalsIgnoreCase("com.mediatek.filemanager")) {
if (Settings.System.getInt(context.getContentResolver(), "qch_app_filemanager") == 1) {
hide = 1;
}
}
} catch (Settings.SettingNotFoundException e) {
e.printStackTrace();
}
PackageManager pm = context.getPackageManager();
if (hide == 0) {
pm.setApplicationEnabledSetting(pkage, PackageManager.COMPONENT_ENABLED_STATE_DEFAULT, 0);
} else {
pm.setApplicationEnabledSetting(pkage, PackageManager.COMPONENT_ENABLED_STATE_DISABLED, 0);
}
}
} }