version:2.3

fix:增加上传日志功能,优化一键加速功能
update:
This commit is contained in:
2022-02-11 09:53:30 +08:00
parent edf23945b5
commit 61ef0d7bfa
57 changed files with 4290 additions and 925 deletions

View File

@@ -18,7 +18,6 @@ import android.graphics.Bitmap;
import android.net.ConnectivityManager;
import android.net.NetworkInfo;
import android.net.Uri;
import android.net.wifi.WifiManager;
import android.os.BatteryManager;
import android.os.Build;
import android.os.Environment;
@@ -28,13 +27,15 @@ import android.provider.Settings;
import android.text.TextUtils;
import android.util.Log;
import androidx.annotation.RequiresApi;
import androidx.core.content.ContextCompat;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.aoleyun.sn.comm.CommonConfig;
import com.aoleyun.sn.comm.JGYActions;
import com.aoleyun.sn.comm.PackageNames;
import com.blankj.utilcode.util.FileUtils;
import com.blankj.utilcode.util.PathUtils;
import com.google.gson.Gson;
import com.google.gson.JsonObject;
import com.google.gson.reflect.TypeToken;
@@ -45,7 +46,6 @@ import com.google.zxing.common.BitMatrix;
import com.google.zxing.qrcode.QRCodeWriter;
import com.google.zxing.qrcode.decoder.ErrorCorrectionLevel;
import com.aoleyun.sn.BuildConfig;
import com.aoleyun.sn.action.JGYActions;
import com.aoleyun.sn.base.BaseApplication;
import com.aoleyun.sn.bean.AppListInfo;
import com.aoleyun.sn.bean.Appground;
@@ -54,10 +54,9 @@ import com.aoleyun.sn.bean.ForceDownloadData;
import com.aoleyun.sn.bean.NetAndLaunchBean;
import com.aoleyun.sn.bean.NetAndLaunchData;
import com.aoleyun.sn.bean.TTAppground;
import com.aoleyun.sn.comm.CommonDatas;
import com.aoleyun.sn.service.GuardService;
import com.aoleyun.sn.service.LogcatService;
import com.aoleyun.sn.service.MainService;
import com.aoleyun.sn.service.main.MainService;
import com.aoleyun.sn.service.StepService;
import java.io.File;
@@ -160,10 +159,10 @@ public class JGYUtils {
}
public void resetDevice() {
boolean isReset = MySQLData.GetBooleanData(mContext, CommonDatas.IS_RESET);
boolean isReset = MySQLData.GetBooleanData(mContext, CommonConfig.IS_RESET);
int batteryLevel = getBatteryLevel();
Log.e(TAG, "batteryLevel:" + batteryLevel + " isReset" + isReset);
if (isReset && batteryLevel >= CommonDatas.MIN_POWER) {
if (isReset && batteryLevel >= CommonConfig.MIN_POWER) {
Utils.doMasterClear(mContext);
}
}
@@ -173,7 +172,7 @@ public class JGYUtils {
return path + File.separator;
}
private int getBatteryLevel() {
public int getBatteryLevel() {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
BatteryManager batteryManager = (BatteryManager) mContext.getSystemService(Context.BATTERY_SERVICE);
return batteryManager.getIntProperty(BatteryManager.BATTERY_PROPERTY_CAPACITY);
@@ -398,19 +397,19 @@ 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_HR_RECEIVER_JGY_DIS);
String not = Settings.System.getString(context.getContentResolver(), JGYActions.ACTION_HR_RECEIVER_JGY);
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 = " + dis);
Settings.System.putString(context.getContentResolver(), JGYActions.ACTION_HR_RECEIVER_JGY_DIS, "Invalid");
Settings.System.putString(context.getContentResolver(), JGYActions.ACTION_HRRECEIVER_JGY_DIS, "Invalid");
}
if (!TextUtils.isEmpty(not)) {
Log.e(TAG, "setAppNetwork: not = " + not);
Settings.System.putString(context.getContentResolver(), JGYActions.ACTION_HR_RECEIVER_JGY, "Invalid");
Settings.System.putString(context.getContentResolver(), JGYActions.ACTION_HRRECEIVER_JGY, "Invalid");
}
String oldBlackList = (String) SPUtils.get(context, JGYActions.ACTION_HR_RECEIVER_JGY_DIS, "");
String oldBlackList = (String) SPUtils.get(context, JGYActions.ACTION_HRRECEIVER_JGY_DIS, "");
HashSet<String> oldBlackListSet = new HashSet<>(Arrays.asList(oldBlackList.split(",")));
oldBlackListSet.removeIf(s -> TextUtils.isEmpty(s.trim()));
//之前禁止上网得列表
@@ -427,7 +426,7 @@ public class JGYUtils {
} else {
Log.e(TAG, "setAppNetwork: " + pkg + " 已安装");
}
Intent netControlNotIntent = new Intent(JGYActions.ACTION_HR_RECEIVER_JGY_DIS);
Intent netControlNotIntent = new Intent(JGYActions.ACTION_HRRECEIVER_JGY_DIS);
netControlNotIntent.putExtra("package_name", pkg);
netControlNotIntent.setPackage("com.android.settings");
context.sendBroadcast(netControlNotIntent);
@@ -450,7 +449,7 @@ public class JGYUtils {
Log.e(TAG, "setAppNetwork: addedNet: " + addedNet);
for (String pkg : removedNet) {
if (TextUtils.isEmpty(pkg)) continue;
Intent netControlNotIntent = new Intent(JGYActions.ACTION_HR_RECEIVER_JGY);
Intent netControlNotIntent = new Intent(JGYActions.ACTION_HRRECEIVER_JGY);
netControlNotIntent.putExtra("package_name", pkg);
netControlNotIntent.setPackage("com.android.settings");
context.sendBroadcast(netControlNotIntent);
@@ -464,7 +463,7 @@ public class JGYUtils {
} else {
Log.e(TAG, "setAppNetwork: " + pkg + " 已安装");
}
Intent netControlNotIntent = new Intent(JGYActions.ACTION_HR_RECEIVER_JGY_DIS);
Intent netControlNotIntent = new Intent(JGYActions.ACTION_HRRECEIVER_JGY_DIS);
netControlNotIntent.putExtra("package_name", pkg);
netControlNotIntent.setPackage("com.android.settings");
context.sendBroadcast(netControlNotIntent);
@@ -472,7 +471,7 @@ public class JGYUtils {
}
String net_not = String.join(",", blackList);
SPUtils.put(context, JGYActions.ACTION_HR_RECEIVER_JGY_DIS, net_not);
SPUtils.put(context, JGYActions.ACTION_HRRECEIVER_JGY_DIS, net_not);
//Settings.System.putString(mContext.getContentResolver(), JGYActions.ACTION_HrReceiver_JGY_DIS, net_not);
Log.e("fht", "not::" + net_not);
@@ -487,7 +486,7 @@ public class JGYUtils {
@SuppressLint("NewApi")
synchronized public void onBootSendNetwork() {
String oldBlackListString = (String) SPUtils.get(mContext, JGYActions.ACTION_HR_RECEIVER_JGY_DIS, "");
String oldBlackListString = (String) SPUtils.get(mContext, JGYActions.ACTION_HRRECEIVER_JGY_DIS, "");
HashSet<String> oldBlackListSet = new HashSet<>(Arrays.asList(oldBlackListString.split(",")));
Log.e(TAG, "setAppNetwork: oldBlackListSet: " + oldBlackListSet);
oldBlackListSet.removeIf(new Predicate<String>() {
@@ -502,7 +501,7 @@ public class JGYUtils {
Log.e(TAG, "setAppNetwork: skip: " + pkg);
continue;
}
Intent netControlNotIntent = new Intent(JGYActions.ACTION_HR_RECEIVER_JGY_DIS);
Intent netControlNotIntent = new Intent(JGYActions.ACTION_HRRECEIVER_JGY_DIS);
netControlNotIntent.putExtra("package_name", pkg);
netControlNotIntent.setPackage("com.android.settings");
mContext.sendBroadcast(netControlNotIntent);
@@ -1556,11 +1555,26 @@ public class JGYUtils {
}
}
public void killBackgroundProcesses(Context context, String processName) {
@RequiresApi(api = Build.VERSION_CODES.M)
public void cleanBackgroundMemory() {
ActivityManager manager = (ActivityManager) mContext.getSystemService(Context.ACTIVITY_SERVICE);
for (ActivityManager.RunningServiceInfo service : manager.getRunningServices(Integer.MAX_VALUE)) {
String pkg = service.service.getPackageName();
Log.i("cleanBackgroundMemory", pkg);
if (ApkUtils.isSystemApp(mContext, pkg)) continue;
if (ApkUtils.desktopAPP.contains(pkg) || ApkUtils.aoleyunAPP.contains(pkg)) {
continue;
}
manager.forceStopPackage(service.service.getPackageName());
Log.e("cleanBackgroundMemory", "kill :" + pkg);
}
}
public void killBackgroundProcesses(String processName) {
gotoLauncher();
// mIsScanning = true;
removeTask(processName);
ActivityManager activityManager = (ActivityManager) context.getSystemService(Context.ACTIVITY_SERVICE);
ActivityManager activityManager = (ActivityManager) mContext.getSystemService(Context.ACTIVITY_SERVICE);
String packageName = null;
try {
if (processName.indexOf(":") == -1) {