update:2020.12.26

fix:增加强制应用禁止删除
add:
This commit is contained in:
2020-12-26 18:18:38 +08:00
parent 79ea8888c1
commit e17935ad76
11 changed files with 285 additions and 119 deletions

View File

@@ -12,6 +12,7 @@ import android.net.Uri;
import android.os.Binder;
import android.os.Build;
import android.provider.Settings;
import android.text.TextUtils;
import android.util.Log;
import android.view.View;
@@ -33,6 +34,7 @@ import java.io.OutputStream;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Enumeration;
import java.util.List;
import java.util.zip.ZipEntry;
@@ -659,4 +661,69 @@ public class ApkUtils {
}
}
public static void addShortcut(Context context, String packageList) {
if (TextUtils.isEmpty(packageList)) {
return;
}
String[] stringList = packageList.split(",");
List<String> packages = new ArrayList<>(Arrays.asList(stringList));
String installedList = "";
for (String s : packages) {
if (s.equals("com.jiaoguanyi.store") || s.equals("com.jiaoguanyi.appstore")) {
continue;
}
if (!ApkUtils.isAvailable(context, s)) {
continue;
}
// ApkUtils.getStartActivityName(context, s);
installedList += s + ",";
Log.e("addShortcut", s);
}
if (installedList.length() != 0) {
installedList = installedList.substring(0, installedList.length() - 1);
} else {
Log.e("addShortcut", installedList);
}
boolean qch_force_app = Settings.System.putString(context.getContentResolver(), "qch_launcher_icon_app", installedList);
// String old = Settings.System.getString(context.getContentResolver(), "qch_launcher_icon_app");
// Log.e("addShortcut", old);
Log.e("addShortcut", "putstring:" + qch_force_app);
}
public static void writeAppPackageList(Context context, String result) {
ApkUtils.addShortcut(context, result);//开机之后添加图标到桌面
String appstore = "com.jiaoguanyi.appstore";
String store = "com.jiaoguanyi.store";
String infosn = "com.info.sn";
String appstoreuiui = "com.appstore.uiui";
String jgy1 = "com.uiuios.jgy1";
String jgy2 = "com.uiuios.jgy2";
if (!TextUtils.isEmpty(result)) {
if (!result.contains(appstore)) {
result = result + "," + appstore;
}
if (!result.contains(store)) {
result = result + "," + store;
}
if (!result.contains(jgy1)) {
result = result + "," + jgy1;
}
if (!result.contains(jgy2)) {
result = result + "," + jgy2;
}
if (!result.contains(infosn)) {
result = result + "," + infosn;
}
if (!result.contains(appstoreuiui)) {
result = result + "," + appstoreuiui;
}
boolean qch_app_forbid = Settings.System.putString(context.getContentResolver(), "qch_app_forbid", result);
Log.e("fht", "qch_app_forbid :" + result + ":" + qch_app_forbid);
} else {
Log.e("fht", "writeAppPackageList is null:");
}
}
}

View File

@@ -1371,6 +1371,10 @@ public class Utils {
}
public static void rebootDevices(Context context) {
if (BuildConfig.DEBUG) {
ToastUtil.show("收到重启设备推送消息");
return;
}
Intent iReboot = new Intent(Intent.ACTION_REBOOT);
iReboot.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
context.startActivity(iReboot);