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

@@ -29,8 +29,8 @@ android {
defaultConfig { defaultConfig {
applicationId "com.aoleyun.sn" applicationId "com.aoleyun.sn"
versionCode 133 versionCode 134
versionName "1.4.0521" versionName "1.4.0529"
//There are no CERT files because If the mini sdk version is 23+, the AGP will ignore the V1 scheme signature. //There are no CERT files because If the mini sdk version is 23+, the AGP will ignore the V1 scheme signature.
minSdkVersion 24 minSdkVersion 24

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_DESKTOP_PACKAGE_NAME = "aoleyun_default_desktop_key";
/*默认应用桌面 单独设置*/ /*默认应用桌面 单独设置*/
public static final String DEFAULT_LAUNCHER_PACKAGE_NAME = "aoleyun_default_launcher_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.content.Intent;
import android.util.Log; import android.util.Log;
import com.aoleyun.sn.comm.CommonConfig;
import com.aoleyun.sn.utils.JGYUtils; import com.aoleyun.sn.utils.JGYUtils;
import com.tencent.mmkv.MMKV;
public class AoleyunActivityController extends IActivityController.Stub { public class AoleyunActivityController extends IActivityController.Stub {
private static final String TAG = AoleyunActivityController.class.getSimpleName(); private static final String TAG = AoleyunActivityController.class.getSimpleName();
private MMKV mMMKV = MMKV.mmkvWithID(CommonConfig.MMKV_ID, MMKV.MULTI_PROCESS_MODE);
@Override @Override
public boolean activityStarting(Intent intent, String pkg) { public boolean activityStarting(Intent intent, String pkg) {
@@ -23,6 +26,10 @@ public class AoleyunActivityController extends IActivityController.Stub {
@Override @Override
public boolean activityResuming(String pkg) { public boolean activityResuming(String pkg) {
Log.e(TAG, "activityResuming: " + 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; return true;
} }

View File

@@ -4,6 +4,7 @@ import android.annotation.SuppressLint;
import android.app.AlarmManager; import android.app.AlarmManager;
import android.app.PendingIntent; import android.app.PendingIntent;
import android.app.StatusBarManager; import android.app.StatusBarManager;
import android.content.ComponentName;
import android.content.Context; import android.content.Context;
import android.content.Intent; import android.content.Intent;
import android.content.pm.PackageInfo; import android.content.pm.PackageInfo;
@@ -2134,12 +2135,25 @@ public class NetInterfaceManager {
Log.e(TAG, "setDefaultApp: default_IME is empty"); Log.e(TAG, "setDefaultApp: default_IME is empty");
} }
JGYUtils.getInstance().setDefaultBrowser(default_IME); JGYUtils.getInstance().setDefaultBrowser(default_IME);
String default_launcher = defaultApp.getDefault_launcher();
String default_launcher = defaultApp.getDefault_launcher();
if (!TextUtils.isEmpty(default_launcher)) { if (!TextUtils.isEmpty(default_launcher)) {
Log.e(TAG, "setDefaultApp: default_launcher = " + default_launcher); Log.e(TAG, "setDefaultApp: default_launcher = " + default_launcher);
mMMKV.encode(CommonConfig.DEFAULT_LAUNCHER_PACKAGE_NAME, default_launcher); mMMKV.encode(CommonConfig.DEFAULT_LAUNCHER_PACKAGE_NAME, default_launcher);
JGYUtils.getInstance().setDefaultDesktop(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 { } else {
Log.e(TAG, "setDefaultApp: default_launcher is empty"); Log.e(TAG, "setDefaultApp: default_launcher is empty");
String desktop = mMMKV.decodeString(CommonConfig.DEFAULT_DESKTOP_PACKAGE_NAME); String desktop = mMMKV.decodeString(CommonConfig.DEFAULT_DESKTOP_PACKAGE_NAME);

View File

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

View File

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