version:1.5.0705
bugfixes:优化报错和网络优化
This commit is contained in:
@@ -25,6 +25,7 @@ import android.net.NetworkInfo;
|
||||
import android.net.Uri;
|
||||
import android.os.BatteryManager;
|
||||
import android.os.Build;
|
||||
import android.os.Debug;
|
||||
import android.os.Environment;
|
||||
import android.os.IBinder;
|
||||
import android.os.PowerManager;
|
||||
@@ -35,6 +36,8 @@ import android.os.UserHandle;
|
||||
import android.provider.Settings;
|
||||
import android.text.TextUtils;
|
||||
import android.util.Log;
|
||||
import android.view.inputmethod.InputMethodInfo;
|
||||
import android.view.inputmethod.InputMethodManager;
|
||||
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.annotation.RequiresApi;
|
||||
@@ -69,6 +72,7 @@ import com.bumptech.glide.request.target.SimpleTarget;
|
||||
import com.bumptech.glide.request.transition.Transition;
|
||||
import com.google.gson.Gson;
|
||||
import com.google.gson.JsonObject;
|
||||
import com.google.gson.JsonParser;
|
||||
import com.google.gson.reflect.TypeToken;
|
||||
import com.google.zxing.BarcodeFormat;
|
||||
import com.google.zxing.EncodeHintType;
|
||||
@@ -100,6 +104,7 @@ import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Optional;
|
||||
import java.util.Set;
|
||||
import java.util.concurrent.Executor;
|
||||
import java.util.function.BiConsumer;
|
||||
@@ -833,6 +838,7 @@ public class JgyUtils {
|
||||
this.add("com.aoleyunos.dop8");
|
||||
this.add("com.aoleyunos.dop9");
|
||||
this.add("com.aoleyunos.dop10");
|
||||
this.add("com.schoolos.cmcc");
|
||||
}};
|
||||
|
||||
public void setAppNetwork(HashSet<String> blackList, HashSet<String> whiteList) {
|
||||
@@ -861,6 +867,15 @@ public class JgyUtils {
|
||||
}
|
||||
}
|
||||
|
||||
if (blackList != null) {
|
||||
List<String> installedBlackApps = blackList.stream().filter(s -> ApkUtils.isAvailable(mContext, s)).collect(Collectors.toList());
|
||||
Log.e(TAG, "setAppNetwork: installedBlackApps = " + installedBlackApps);
|
||||
if (JgyUtils.isAllWinnerDevice()) {
|
||||
CubeMdmManager cubeMdmManager = (CubeMdmManager) mContext.getSystemService("cube_mdm");
|
||||
cubeMdmManager.setBlackNetApp(installedBlackApps);
|
||||
}
|
||||
}
|
||||
|
||||
mMMKV.encode(CommonConfig.AOLE_ACTION_NETWORK_ALLOW, whiteList);
|
||||
Set<String> pkgs;
|
||||
int is_app_install = Settings.System.getInt(crv, CommonConfig.AOLE_APP_ALLOW_INSTALL, 0);
|
||||
@@ -884,6 +899,7 @@ public class JgyUtils {
|
||||
Settings.System.putString(crv, CommonConfig.AOLE_ACTION_NETWORK_ALLOW, String.join(",", filterList));
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1404,6 +1420,7 @@ public class JgyUtils {
|
||||
this.add("com.aoleyunos.dop8");
|
||||
this.add("com.aoleyunos.dop9");
|
||||
this.add("com.aoleyunos.dop10");
|
||||
this.add("com.schoolos.cmcc");
|
||||
this.add("com.aoleyun.info");
|
||||
this.add("com.calculator.uiui");
|
||||
this.add("com.notepad.uiui");
|
||||
@@ -1464,12 +1481,19 @@ public class JgyUtils {
|
||||
pkgSet.addAll(pkgs);
|
||||
pkgSet.addAll(getWhitePkgList());
|
||||
pkgSet.removeIf(TextUtils::isEmpty);
|
||||
String aole_app_forbid = String.join(",", pkgSet);
|
||||
Log.e(TAG, "writeAppPackageList: " + aole_app_forbid);
|
||||
boolean b = Settings.System.putString(crv, CommonConfig.AOLE_ACTION_APP_FORBID, aole_app_forbid);
|
||||
setAppRestriction(2);
|
||||
addAppInstallWhiteList(new ArrayList<>(pkgSet));
|
||||
Log.e("writeAppPackageList: ", "aole_app_forbid: " + b + " " + Settings.System.getString(crv, CommonConfig.AOLE_ACTION_APP_FORBID));
|
||||
|
||||
if (JgyUtils.isAllWinnerDevice()) {
|
||||
CubeMdmManager cubeMdmManager = (CubeMdmManager) mContext.getSystemService("cube_mdm");
|
||||
cubeMdmManager.setInstallPackageWhiteList(new ArrayList<>(pkgSet));
|
||||
Log.e(TAG, "setInstallPackageWhiteList: " + pkgSet);
|
||||
} else {
|
||||
String aole_app_forbid = String.join(",", pkgSet);
|
||||
Log.e(TAG, "writeAppPackageList: " + aole_app_forbid);
|
||||
boolean b = Settings.System.putString(crv, CommonConfig.AOLE_ACTION_APP_FORBID, aole_app_forbid);
|
||||
setAppRestriction(2);
|
||||
addAppInstallWhiteList(new ArrayList<>(pkgSet));
|
||||
Log.e("writeAppPackageList: ", "aole_app_forbid: " + b + " " + Settings.System.getString(crv, CommonConfig.AOLE_ACTION_APP_FORBID));
|
||||
}
|
||||
}
|
||||
|
||||
public void writeAppPackageList() {
|
||||
@@ -1482,9 +1506,16 @@ public class JgyUtils {
|
||||
pkgSet.addAll(getWhitePkgList());
|
||||
pkgSet.removeIf(TextUtils::isEmpty);
|
||||
|
||||
String aole_app_forbid = String.join(",", pkgSet);
|
||||
Log.e(TAG, "writeAppPackageList: " + aole_app_forbid);
|
||||
Settings.System.putString(crv, CommonConfig.AOLE_ACTION_APP_FORBID, aole_app_forbid);
|
||||
if (JgyUtils.isAllWinnerDevice()) {
|
||||
CubeMdmManager cubeMdmManager = (CubeMdmManager) mContext.getSystemService("cube_mdm");
|
||||
cubeMdmManager.setInstallPackageWhiteList(new ArrayList<>(pkgSet));
|
||||
Log.e(TAG, "setInstallPackageWhiteList: " + pkgSet);
|
||||
|
||||
} else {
|
||||
String aole_app_forbid = String.join(",", pkgSet);
|
||||
Log.e(TAG, "writeAppPackageList: " + aole_app_forbid);
|
||||
Settings.System.putString(crv, CommonConfig.AOLE_ACTION_APP_FORBID, aole_app_forbid);
|
||||
}
|
||||
}
|
||||
|
||||
public void checkForceDownload() {
|
||||
@@ -1801,7 +1832,7 @@ public class JgyUtils {
|
||||
this.add("com.aoleyunos.dop8");
|
||||
this.add("com.aoleyunos.dop9");
|
||||
this.add("com.aoleyunos.dop10");
|
||||
|
||||
this.add("com.schoolos.cmcc");
|
||||
}};
|
||||
|
||||
HashSet<String> aihuaAppList = new HashSet<String>() {{
|
||||
@@ -2061,18 +2092,19 @@ public class JgyUtils {
|
||||
|
||||
Log.e(TAG, "setDeveloperOptions: DEVELOPMENT_SETTINGS_ENABLED = " + Settings.Global.getInt(crv, Settings.Global.DEVELOPMENT_SETTINGS_ENABLED, 0));
|
||||
Log.e(TAG, "setDeveloperOptions: ADB_ENABLED = " + Settings.Global.getInt(crv, Settings.Global.ADB_ENABLED, 0));
|
||||
if (!BuildConfig.DEBUG) {
|
||||
if (Settings.Global.getInt(crv, Settings.Global.DEVELOPMENT_SETTINGS_ENABLED, 0) != state) {
|
||||
Settings.Global.putInt(crv, Settings.Global.DEVELOPMENT_SETTINGS_ENABLED, state);
|
||||
}
|
||||
if (Settings.Global.getInt(crv, Settings.Global.ADB_ENABLED, 0) != state) {
|
||||
Settings.Global.putInt(crv, Settings.Global.ADB_ENABLED, state);
|
||||
}
|
||||
if (JgyUtils.isAllWinnerDevice()) {
|
||||
CubeMdmManager cubeMdmManager = (CubeMdmManager) mContext.getSystemService("cube_mdm");
|
||||
cubeMdmManager.setDeveloperEnable(state == 1);
|
||||
}
|
||||
// if (!BuildConfig.DEBUG) {
|
||||
if (Settings.Global.getInt(crv, Settings.Global.DEVELOPMENT_SETTINGS_ENABLED, 0) != state) {
|
||||
Settings.Global.putInt(crv, Settings.Global.DEVELOPMENT_SETTINGS_ENABLED, state);
|
||||
}
|
||||
if (Settings.Global.getInt(crv, Settings.Global.ADB_ENABLED, 0) != state) {
|
||||
Settings.Global.putInt(crv, Settings.Global.ADB_ENABLED, state);
|
||||
}
|
||||
if (JgyUtils.isAllWinnerDevice()) {
|
||||
CubeMdmManager cubeMdmManager = (CubeMdmManager) mContext.getSystemService("cube_mdm");
|
||||
cubeMdmManager.setDeveloperEnable(state == 1);
|
||||
Log.e(TAG, "setDeveloperEnable: " + (state == 1));
|
||||
}
|
||||
// }
|
||||
}
|
||||
|
||||
private String chromium_pkg = "org.chromium.browser";
|
||||
@@ -2487,6 +2519,9 @@ public class JgyUtils {
|
||||
private String AiUDuOs = "com.aoleyun.audos";
|
||||
private String AiUDuOsClass = "com.aoleyun.audos.Launcher";
|
||||
|
||||
private String schoolosOs = "com.schoolos.cmcc";
|
||||
private String schoolosClass = "com.schoolos.cmcc.activity.main.MainActivity";
|
||||
|
||||
public void setDefaultLauncher(Context context, String defPackageName, String defClassName) {
|
||||
try {
|
||||
if (!TextUtils.isEmpty(defPackageName) && !TextUtils.isEmpty(defClassName)) {
|
||||
@@ -2523,23 +2558,23 @@ public class JgyUtils {
|
||||
boolean add = true;
|
||||
int flags = 0;
|
||||
UserHandle user = Process.myUserHandle();
|
||||
Log.i("settingssssssstemf", (add ? "Adding" : "Removing") + " package as role holder, role: "
|
||||
Log.i("setRoleHolderAsUser", (add ? "Adding" : "Removing") + " package as role holder, role: "
|
||||
+ roleName + ", package: " + packageName);
|
||||
if (JgyUtils.getInstance().checkAppPlatform() != JgyUtils.MTKPlatform) {
|
||||
RoleManager roleManager = context.getSystemService(RoleManager.class);
|
||||
Executor executor = context.getMainExecutor();
|
||||
Consumer<Boolean> callback = successful -> {
|
||||
if (successful) {
|
||||
Log.d("settingssssssstemf", "Package " + (add ? "added" : "removed")
|
||||
Log.d("setRoleHolderAsUser", "Package " + (add ? "added" : "removed")
|
||||
+ " as role holder, role: " + roleName + ", package: " + packageName);
|
||||
} else {
|
||||
Log.d("settingssssssstemf", "Failed to " + (add ? "add" : "remove")
|
||||
Log.d("setRoleHolderAsUser", "Failed to " + (add ? "add" : "remove")
|
||||
+ " package as role holder, role: " + roleName + ", package: "
|
||||
+ packageName);
|
||||
}
|
||||
};
|
||||
roleManager.addRoleHolderAsUser(roleName, packageName, flags, user, executor, callback);
|
||||
Log.i("settingssssssstemf", "addRoleHolderAsUser done");
|
||||
Log.i("setRoleHolderAsUser", "addRoleHolderAsUser done");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -2656,6 +2691,8 @@ public class JgyUtils {
|
||||
setDefaultDesktop(AoleyunOs, AoleyunOsClass);
|
||||
} else if (JgyUtils.getInstance().isAiuduPlatform()) {
|
||||
setDefaultDesktop(AiUDuOs, AiUDuOsClass);
|
||||
} else if (JgyUtils.isAllWinnerDevice()) {
|
||||
setDefaultDesktop(schoolosOs, schoolosClass);
|
||||
} else {
|
||||
if (Build.VERSION.SDK_INT > Build.VERSION_CODES.Q) {
|
||||
setDefaultDesktop(Launcher3, Launcher3QuickstepClass);
|
||||
@@ -2671,6 +2708,8 @@ public class JgyUtils {
|
||||
ApkUtils.openPackage(mContext, AoleyunOs, AoleyunOsClass);
|
||||
} else if (JgyUtils.getInstance().isAiuduPlatform()) {
|
||||
setDefaultDesktop(AiUDuOs, AiUDuOsClass);
|
||||
} else if (JgyUtils.isAllWinnerDevice()) {
|
||||
setDefaultDesktop(schoolosOs, schoolosClass);
|
||||
} else {
|
||||
ApkUtils.openPackage(mContext, Launcher3, Launcher3Class);
|
||||
}
|
||||
@@ -2741,8 +2780,13 @@ public class JgyUtils {
|
||||
intent.setPackage("com.android.settings");
|
||||
mContext.sendBroadcast(intent);
|
||||
if (JgyUtils.isAllWinnerDevice()) {
|
||||
if (!ApkUtils.isAvailable(mContext, pkg)) {
|
||||
Log.e(TAG, "cubeMdmManager setDefaultLauncher: " + pkg + " is not installed");
|
||||
return;
|
||||
}
|
||||
CubeMdmManager cubeMdmManager = (CubeMdmManager) mContext.getSystemService("cube_mdm");
|
||||
cubeMdmManager.setDefaultLauncher(pkg);
|
||||
Log.e(TAG, "cubeMdmManager setDefaultLauncher: " + pkg);
|
||||
}
|
||||
|
||||
// ApkUtils.openPackage(mContext, pkg);
|
||||
@@ -3083,11 +3127,17 @@ public class JgyUtils {
|
||||
Gson gson = new Gson();
|
||||
Type listType = new TypeToken<List<Long>>() {
|
||||
}.getType();
|
||||
List<Long> longList = gson.fromJson(jsonString, listType);
|
||||
if (longList == null) {
|
||||
try {
|
||||
List<Long> longList = gson.fromJson(jsonString, listType);
|
||||
if (longList == null) {
|
||||
connectedTime = new ArrayList<>();
|
||||
} else {
|
||||
connectedTime = longList;
|
||||
}
|
||||
} catch (Exception e) {
|
||||
Log.e(TAG, "initConnectedTimeCache: " + e.getMessage());
|
||||
cacheHelper.remove(CONNECTED_TIME_KEY);
|
||||
connectedTime = new ArrayList<>();
|
||||
} else {
|
||||
connectedTime = longList;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3341,7 +3391,9 @@ public class JgyUtils {
|
||||
if (C2Tag.equals(BuildConfig.platform)) {
|
||||
Log.e("ITools", "addAppInstallWhiteList: " + packageNameList);
|
||||
try {
|
||||
mITools.addAppInstallWhiteList(packageNameList);
|
||||
if (mITools!=null) {
|
||||
mITools.addAppInstallWhiteList(packageNameList);
|
||||
}
|
||||
} catch (RemoteException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
@@ -3616,4 +3668,139 @@ public class JgyUtils {
|
||||
|
||||
}
|
||||
|
||||
public void setAllwinnerDefaulInputMeth(String pkg) {
|
||||
if (!ApkUtils.isAvailable(mContext, pkg)) {
|
||||
Log.e(TAG, "cubeMdmManager setDefaultInputMethod: " + pkg + " is not installed");
|
||||
return;
|
||||
}
|
||||
CubeMdmManager cubeMdmManager = (CubeMdmManager) mContext.getSystemService("cube_mdm");
|
||||
String componentName = JgyUtils.getInstance().getInputMethComponentName(pkg);
|
||||
Log.e(TAG, "setDefaultInputMethod: " + componentName);
|
||||
cubeMdmManager.setDefaultInputMethod(componentName);
|
||||
Log.e(TAG, "cubeMdmManager setDefaultInputMethod: " + componentName);
|
||||
}
|
||||
|
||||
public String getInputMethComponentName(String pkg) {
|
||||
InputMethodManager imeManager = (InputMethodManager) mContext.getSystemService(Context.INPUT_METHOD_SERVICE);
|
||||
List<InputMethodInfo> InputMethods = imeManager.getInputMethodList();
|
||||
Optional<InputMethodInfo> inputMethodInfoOptional = InputMethods.stream().filter(new Predicate<InputMethodInfo>() {
|
||||
@Override
|
||||
public boolean test(InputMethodInfo inputMethodInfo) {
|
||||
return pkg.equals(inputMethodInfo.getPackageName());
|
||||
}
|
||||
}).findAny();
|
||||
if (inputMethodInfoOptional.isPresent()) {
|
||||
InputMethodInfo inputMethodInfo = inputMethodInfoOptional.get();
|
||||
return inputMethodInfo.getComponent().toString();
|
||||
} else {
|
||||
return "";
|
||||
}
|
||||
}
|
||||
|
||||
public String getDefaultIme() {
|
||||
return mMMKV.decodeString(CommonConfig.DEFAULT_IME_PACKAGE_NAME_KEY, "");
|
||||
}
|
||||
|
||||
public void setAllwinnerDefaulBrowser(String pkg) {
|
||||
if (JgyUtils.isAllWinnerDevice()) {
|
||||
if (!ApkUtils.isAvailable(mContext, pkg)) {
|
||||
Log.e(TAG, "cubeMdmManager setAllwinnerDefaulBrowser: " + pkg + " is not installed");
|
||||
return;
|
||||
}
|
||||
CubeMdmManager cubeMdmManager = (CubeMdmManager) mContext.getSystemService("cube_mdm");
|
||||
Log.e(TAG, "setAllwinnerDefaulBrowser: " + pkg);
|
||||
cubeMdmManager.setDefaultInputMethod(pkg);
|
||||
Log.e(TAG, "cubeMdmManager setAllwinnerDefaulBrowser: " + pkg);
|
||||
}
|
||||
}
|
||||
|
||||
public List<ProcessInfo> getAllRunningAppProcessInfo() {
|
||||
ActivityManager am = (ActivityManager) mContext.getSystemService(Context.ACTIVITY_SERVICE);
|
||||
PackageManager pm = mContext.getPackageManager();
|
||||
List<ActivityManager.RunningAppProcessInfo> processes = am.getRunningAppProcesses();
|
||||
List<ProcessInfo> processList = new ArrayList<>();
|
||||
for (ActivityManager.RunningAppProcessInfo process : processes) {
|
||||
String[] pkgList = process.pkgList;
|
||||
for (String pkg : pkgList) {
|
||||
try {
|
||||
ApplicationInfo appInfo = pm.getApplicationInfo(pkg, 0);
|
||||
processList.add(new ProcessInfo(
|
||||
pkg,
|
||||
appInfo.loadLabel(pm).toString(),
|
||||
process.pid,
|
||||
getProcessMemory(am, process.pid),
|
||||
(appInfo.flags & ApplicationInfo.FLAG_SYSTEM) != 0
|
||||
));
|
||||
} catch (Exception ignored) {
|
||||
}
|
||||
}
|
||||
}
|
||||
String jsonString = GsonUtils.toJSONString(processList);
|
||||
Log.e(TAG, "getAllRunningAppProcessInfo: " + jsonString);
|
||||
return processList;
|
||||
}
|
||||
|
||||
// 获取进程内存占用(KB)
|
||||
private static long getProcessMemory(ActivityManager am, int pid) {
|
||||
Debug.MemoryInfo[] memoryInfo = am.getProcessMemoryInfo(new int[]{pid});
|
||||
return memoryInfo[0].getTotalPss();
|
||||
}
|
||||
|
||||
public static class ProcessInfo {
|
||||
public String packageName, appName;
|
||||
public int pid;
|
||||
public long memory;
|
||||
public boolean isSystem;
|
||||
|
||||
public ProcessInfo(String pkg, String name, int pid, long memory, boolean isSystem) {
|
||||
this.packageName = pkg;
|
||||
this.appName = name;
|
||||
this.pid = pid;
|
||||
this.memory = memory;
|
||||
this.isSystem = isSystem;
|
||||
}
|
||||
|
||||
@androidx.annotation.NonNull
|
||||
@Override
|
||||
public String toString() {
|
||||
return JsonParser.parseString(new Gson().toJson(this)).getAsJsonObject().toString();
|
||||
}
|
||||
}
|
||||
|
||||
// 获取所有正在运行的服务
|
||||
public List<ServiceInfo> getAllRunningServices() {
|
||||
ActivityManager am = (ActivityManager) mContext.getSystemService(Context.ACTIVITY_SERVICE);
|
||||
List<ActivityManager.RunningServiceInfo> runningServices = am.getRunningServices(Integer.MAX_VALUE);
|
||||
List<ServiceInfo> serviceList = new ArrayList<>();
|
||||
for (ActivityManager.RunningServiceInfo service : runningServices) {
|
||||
serviceList.add(new ServiceInfo(
|
||||
service.service.getClassName(),
|
||||
service.service.getPackageName(),
|
||||
service.pid,
|
||||
service.uid
|
||||
));
|
||||
}
|
||||
String jsonString = GsonUtils.toJSONString(serviceList);
|
||||
Log.e(TAG, "getAllRunningServices: " + jsonString);
|
||||
return serviceList;
|
||||
}
|
||||
|
||||
|
||||
public static class ServiceInfo {
|
||||
public String className, packageName;
|
||||
public int pid, uid;
|
||||
|
||||
public ServiceInfo(String cls, String pkg, int pid, int uid) {
|
||||
this.className = cls;
|
||||
this.packageName = pkg;
|
||||
this.pid = pid;
|
||||
this.uid = uid;
|
||||
}
|
||||
|
||||
@androidx.annotation.NonNull
|
||||
@Override
|
||||
public String toString() {
|
||||
return JsonParser.parseString(new Gson().toJson(this)).getAsJsonObject().toString();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user