Merge branch 'master' into allwinner

# Conflicts:
#	app/src/main/java/com/aoleyun/sn/network/NetInterfaceManager.java
#	app/src/main/java/com/aoleyun/sn/push/PushManager.java
This commit is contained in:
2025-06-16 10:46:41 +08:00
14 changed files with 474 additions and 113 deletions

View File

@@ -26,6 +26,7 @@ import android.view.WindowManager;
import com.aoleyun.sn.R;
import com.aoleyun.sn.activity.main.MainActivity;
import com.aoleyun.sn.bean.ApkInfoPush;
import com.aoleyun.sn.bean.BaseResponse;
import com.aoleyun.sn.bean.BatteryInfo;
import com.aoleyun.sn.bean.DownloadInfo;
@@ -267,12 +268,19 @@ public class PushManager {
private static final String GROUP_APP_INSTALL = "80";
/*分组应用卸载*/
private static final String GROUP_APP_UNINSTALL = "81";
/*电子围栏*/
private static final String ELECTRONIC_FENCE = "82";
public void setPushContent(String title, String extras) {
switch (title) {
case MSG_DELETE:
Toaster.debugShow("收到管控:应用删除");
deleteApp(extras);
if (!TextUtils.isEmpty(extras)) {
JsonObject jsonObject = GsonUtils.getJsonObject(extras);
String pkg = jsonObject.get("package_name").getAsString();
deleteApp(pkg);
}
break;
case MSG_SETTING:
Toaster.debugShow("收到管控:系统设置");
@@ -342,26 +350,9 @@ public class PushManager {
NetInterfaceManager.getInstance().sendAppUsedTime(random, sendType);
break;
case GET_FORCEDOWNLOADURL:
case GROUP_APP_INSTALL:
Toaster.debugShow("收到管控:应用强制安装");
File file = new File(JgyUtils.getInstance().getDownLoadPath());
if (!file.exists()) {
file.mkdirs();
}
if (TextUtils.isEmpty(extras)) {
Log.e(TAG, "settingNetControl extras is null");
return;
}
JsonObject extra = GsonUtils.getJsonObject(extras);
String app_name = extra.get("app_name").getAsString();
String app_package = extra.get("package").getAsString();
String url = extra.get("url").getAsString();
int versionCode = extra.get("version_code").getAsInt();
String app_id = extra.get("app_id").getAsString();
JsonObject packageObj = new JsonObject();
packageObj.addProperty("app_name", app_name);
packageObj.addProperty("app_package", app_package);
packageObj.addProperty("app_id", app_id);
Utils.ariaDownload(mContext, url, packageObj);
downloadForceInstallApk(extras);
break;
case SET_HOMEPAG_TAG:
Handler.getMain().postDelayed(new Runnable() {
@@ -559,6 +550,7 @@ public class PushManager {
NetInterfaceManager.getInstance().getAppLimit();
break;
case UPDATE_BATCH:
case UPDATE_CHILD_BATCH:
Toaster.debugShow("收到管控:更换批次不恢复出厂设置");
NetInterfaceManager.getInstance().setPushTags();
Aria.download(this).removeAllTask(true);
@@ -687,11 +679,33 @@ public class PushManager {
case GROUP_APP_INSTALL:
break;
case GROUP_APP_UNINSTALL:
Toaster.debugShow("收到管控:应用删除");
if (!TextUtils.isEmpty(extras)) {
JsonObject jsonObject = GsonUtils.getJsonObject(extras);
String pkg = jsonObject.get("app_package").getAsString();
deleteApp(pkg);
}
case ELECTRONIC_FENCE:
break;
default:
}
}
private void downloadForceInstallApk(String extras) {
File file = new File(JgyUtils.getInstance().getDownLoadPath());
if (!file.exists()) {
file.mkdirs();
}
if (TextUtils.isEmpty(extras)) {
Log.e(TAG, "settingNetControl extras is null");
return;
}
ApkInfoPush apkInfoPush = GsonUtils.toJavaObject(extras, ApkInfoPush.class);
JsonObject packageObj = GsonUtils.getJsonObject(GsonUtils.toJSONString(apkInfoPush));
Utils.ariaDownload(mContext, apkInfoPush.getApp_url(), packageObj);
}
private void setWallpaper(String extras) {
NetInterfaceManager.getInstance().getWallpaper();
}
@@ -706,31 +720,20 @@ public class PushManager {
NetInterfaceManager.getInstance().getCloudLessonSettings();
}
private void deleteApp(String extras) {
if (!TextUtils.isEmpty(extras)) {
JsonObject jsonObject = GsonUtils.getJsonObject(extras);
String pkg = jsonObject.get("package_name").getAsString();
if (TextUtils.isEmpty(pkg)) return;
String forceApp = Settings.System.getString(mContext.getContentResolver(), CommonConfig.AOLE_ACTION_FORCE_APP);
if (!TextUtils.isEmpty(forceApp)) {
List<String> forceAppList = new ArrayList<>(Arrays.asList(forceApp.split(",")));
forceAppList.remove(pkg);
if (forceAppList.size() != 0) {
if (JgyUtils.isAllWinnerDevice()) {
CubeMdmManager cubeMdmManager = (CubeMdmManager) mContext.getSystemService("cube_mdm");
cubeMdmManager.setForbidUnInstallPackageList(forceAppList);
}
Settings.System.putString(mContext.getContentResolver(), CommonConfig.AOLE_ACTION_FORCE_APP, String.join(",", forceAppList));
} else {
Settings.System.putString(mContext.getContentResolver(), CommonConfig.AOLE_ACTION_FORCE_APP, "");
if (JgyUtils.isAllWinnerDevice()) {
CubeMdmManager cubeMdmManager = (CubeMdmManager) mContext.getSystemService("cube_mdm");
cubeMdmManager.setForbidUnInstallPackageList(new ArrayList<>());
}
}
private void deleteApp(String pkg) {
Log.e(TAG, "deleteApp: " + pkg);
if (TextUtils.isEmpty(pkg)) return;
String forceApp = Settings.System.getString(mContext.getContentResolver(), CommonConfig.AOLE_ACTION_FORCE_APP);
if (!TextUtils.isEmpty(forceApp)) {
List<String> forceAppList = new ArrayList<>(Arrays.asList(forceApp.split(",")));
forceAppList.remove(pkg);
if (forceAppList.size() != 0) {
Settings.System.putString(mContext.getContentResolver(), CommonConfig.AOLE_ACTION_FORCE_APP, String.join(",", forceAppList));
} else {
Settings.System.putString(mContext.getContentResolver(), CommonConfig.AOLE_ACTION_FORCE_APP, "");
}
ApkUtils.UninstallAPP(mContext, pkg);
}
ApkUtils.UninstallAPP(mContext, pkg);
Handler.getMain().postDelayed(new Runnable() {
@Override
public void run() {