1.4.0529 第一次联网打开默认桌面,默认桌面不允许退出

This commit is contained in:
2024-05-30 10:31:55 +08:00
parent 2f8a9e6f07
commit 7a07105d15
6 changed files with 41 additions and 27 deletions

View File

@@ -73,6 +73,9 @@ public class CommonConfig {
public static final String DEFAULT_DESKTOP_PACKAGE_NAME = "aoleyun_default_desktop_key";
/*默认应用桌面 单独设置*/
public static final String DEFAULT_LAUNCHER_PACKAGE_NAME = "aoleyun_default_launcher_key";
/*首次请求成功打开默认app*/
public static final String OPEN_LAUNCHER_STATUS = "frist_open_default_launcher";
/**
* 管控系统指令

View File

@@ -4,10 +4,13 @@ import android.app.IActivityController;
import android.content.Intent;
import android.util.Log;
import com.aoleyun.sn.comm.CommonConfig;
import com.aoleyun.sn.utils.JGYUtils;
import com.tencent.mmkv.MMKV;
public class AoleyunActivityController extends IActivityController.Stub {
private static final String TAG = AoleyunActivityController.class.getSimpleName();
private MMKV mMMKV = MMKV.mmkvWithID(CommonConfig.MMKV_ID, MMKV.MULTI_PROCESS_MODE);
@Override
public boolean activityStarting(Intent intent, String pkg) {
@@ -23,6 +26,10 @@ public class AoleyunActivityController extends IActivityController.Stub {
@Override
public boolean activityResuming(String pkg) {
Log.e(TAG, "activityResuming: " + pkg);
String default_launcher = mMMKV.decodeString(CommonConfig.DEFAULT_LAUNCHER_PACKAGE_NAME, "");
if (default_launcher.equals(pkg)) {
return false;
}
return true;
}

View File

@@ -4,6 +4,7 @@ import android.annotation.SuppressLint;
import android.app.AlarmManager;
import android.app.PendingIntent;
import android.app.StatusBarManager;
import android.content.ComponentName;
import android.content.Context;
import android.content.Intent;
import android.content.pm.PackageInfo;
@@ -2134,12 +2135,25 @@ public class NetInterfaceManager {
Log.e(TAG, "setDefaultApp: default_IME is empty");
}
JGYUtils.getInstance().setDefaultBrowser(default_IME);
String default_launcher = defaultApp.getDefault_launcher();
String default_launcher = defaultApp.getDefault_launcher();
if (!TextUtils.isEmpty(default_launcher)) {
Log.e(TAG, "setDefaultApp: default_launcher = " + default_launcher);
mMMKV.encode(CommonConfig.DEFAULT_LAUNCHER_PACKAGE_NAME, default_launcher);
JGYUtils.getInstance().setDefaultDesktop(default_launcher);
if (!mMMKV.decodeBool(CommonConfig.OPEN_LAUNCHER_STATUS, false)) {
ComponentName cn = new ComponentName(default_launcher, JGYUtils.getInstance().getStartClassName(default_launcher));
Intent intent = new Intent();
intent.setComponent(cn);
intent.addCategory(Intent.CATEGORY_LAUNCHER);
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
try {
mContext.startActivity(intent);
} catch (Exception e) {
Log.e(TAG, "setDefaultApp: " + e.getMessage());
}
mMMKV.encode(CommonConfig.OPEN_LAUNCHER_STATUS, true);
}
} else {
Log.e(TAG, "setDefaultApp: default_launcher is empty");
String desktop = mMMKV.decodeString(CommonConfig.DEFAULT_DESKTOP_PACKAGE_NAME);

View File

@@ -1094,29 +1094,20 @@ public class PushManager {
} else {
JsonObject jsonObject = GsonUtils.getJsonObject(extras);
JsonElement launcherElement = jsonObject.get("default_launcher");
if (launcherElement.isJsonNull()) {
if (launcherElement.isJsonNull() || TextUtils.isEmpty(launcherElement.getAsString())) {
JGYUtils.getInstance().setDefaultDesktop("");
mMMKV.encode(CommonConfig.DEFAULT_LAUNCHER_PACKAGE_NAME, "");
JGYUtils.getInstance().openLauncher3();
// SPUtils.put(mContext, "default_launcher", "");
} else {
String default_launcher = launcherElement.getAsString();
if (TextUtils.isEmpty(default_launcher)) {
JGYUtils.getInstance().setDefaultDesktop("");
mMMKV.encode(CommonConfig.DEFAULT_LAUNCHER_PACKAGE_NAME, "");
JGYUtils.getInstance().openLauncher3();
// SPUtils.put(mContext, "default_launcher", "");
} else {
JGYUtils.getInstance().setDefaultDesktop(default_launcher);
ComponentName cn = new ComponentName(default_launcher, JGYUtils.getInstance().getStartClassName(default_launcher));
Intent intent = new Intent();
intent.setComponent(cn);
intent.addCategory(Intent.CATEGORY_LAUNCHER);
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
mContext.startActivity(intent);
mMMKV.encode(CommonConfig.DEFAULT_LAUNCHER_PACKAGE_NAME, default_launcher);
// SPUtils.put(mContext, "default_launcher", default_launcher);
}
JGYUtils.getInstance().setDefaultDesktop(default_launcher);
ComponentName cn = new ComponentName(default_launcher, JGYUtils.getInstance().getStartClassName(default_launcher));
Intent intent = new Intent();
intent.setComponent(cn);
intent.addCategory(Intent.CATEGORY_LAUNCHER);
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
mContext.startActivity(intent);
mMMKV.encode(CommonConfig.DEFAULT_LAUNCHER_PACKAGE_NAME, default_launcher);
}
}
}

View File

@@ -648,8 +648,8 @@ public class SysSettingUtils {
}
private static void setCanReset(Context context, int state) {
boolean aole_restore_forbid_on = Settings.System.putInt(context.getContentResolver(), CommonConfig.AOLE_ACTION_RESTORE_FORBID_ON, state);
Log.e(TAG, "aole_restore_forbid_on: " + aole_restore_forbid_on);
Log.e(TAG, "setCanReset: state = " + state);
Settings.System.putInt(context.getContentResolver(), CommonConfig.AOLE_ACTION_RESTORE_FORBID_ON, state);
//默认打开
}
@@ -657,12 +657,11 @@ public class SysSettingUtils {
//aole_restore_forbid_on=0允许恢复出厂设置
private static void setCanReset(Context context, JsonObject jsonObject) {
int mode = jsonObject.get("qch_restore").getAsInt();
Log.e(TAG, "setCanReset: mode = " + mode);
if (mode == 1) {
boolean aole_restore_forbid_on = Settings.System.putInt(context.getContentResolver(), CommonConfig.AOLE_ACTION_RESTORE_FORBID_ON, 0);
Log.e(TAG, "aole_restore_forbid_on: " + aole_restore_forbid_on);
Settings.System.putInt(context.getContentResolver(), CommonConfig.AOLE_ACTION_RESTORE_FORBID_ON, 0);
} else {
boolean aole_restore_forbid_on = Settings.System.putInt(context.getContentResolver(), CommonConfig.AOLE_ACTION_RESTORE_FORBID_ON, 1);
Log.e(TAG, "aole_restore_forbid_on: " + aole_restore_forbid_on);
Settings.System.putInt(context.getContentResolver(), CommonConfig.AOLE_ACTION_RESTORE_FORBID_ON, 1);
}
}