1.4.0429 修改一键加速界面,去掉ToastUtil,对接权限和通知

This commit is contained in:
2024-05-08 14:33:06 +08:00
parent 08f5867864
commit 004de0cc2e
32 changed files with 885 additions and 527 deletions

View File

@@ -70,6 +70,7 @@ import com.google.zxing.WriterException;
import com.google.zxing.common.BitMatrix;
import com.google.zxing.qrcode.QRCodeWriter;
import com.google.zxing.qrcode.decoder.ErrorCorrectionLevel;
import com.hjq.toast.Toaster;
import com.kte.interfacesettings.aidl.ITools;
import com.tencent.mmkv.MMKV;
@@ -146,6 +147,7 @@ public class JGYUtils {
public static final int C2Platform = 13;
public static final int YXPD1Platform = 15;
public static final int G11Platform = 16;
public static final int MT8768Platform = 17;
public static final String Other = "其他";
@@ -161,6 +163,7 @@ public class JGYUtils {
public static final String C2Tag = "MTK8183";
public static final String YXPD1TAG = "YXPD1";
public static final String G11TAG = "MTKG11";
public static final String MT8768Tag = "MT8768";
private CacheHelper cacheHelper;
@@ -283,6 +286,9 @@ public class JGYUtils {
} else if (G11TAG.equalsIgnoreCase(platform)) {
Log.i(TAG, "checkAppPlatform: " + "MTKG11");
return G11Platform;
} else if (MT8768Tag.equalsIgnoreCase(platform)) {
Log.i(TAG, "checkAppPlatform: " + "MT8768");
return MT8768Platform;
} else {
Log.i(TAG, "checkAppPlatform: " + "没有数据");
return UnknowPlatform;
@@ -329,6 +335,8 @@ public class JGYUtils {
getAppPlatformCallback.AppPlatform(YXPD1Platform);
} else if (G11TAG.equalsIgnoreCase(platform)) {
getAppPlatformCallback.AppPlatform(G11Platform);
} else if (MT8768Tag.equalsIgnoreCase(platform)) {
getAppPlatformCallback.AppPlatform(MT8768Platform);
} else {
getAppPlatformCallback.AppPlatform(UnknowPlatform);
}
@@ -585,7 +593,7 @@ public class JGYUtils {
}
public void onBootOpenApp() {
String qch_app_power_on = Settings.System.getString(mContext.getContentResolver(), CommonConfig.AOLE_ACTION_APP_POWER_ON);
String qch_app_power_on = Settings.System.getString(crv, CommonConfig.AOLE_ACTION_APP_POWER_ON);
if (TextUtils.isEmpty(qch_app_power_on)) {
return;
}
@@ -651,6 +659,9 @@ public class JGYUtils {
HashSet<String> disallowUpgrade = new HashSet<>();//禁止升级
HashSet<String> allowSlide = new HashSet<>();//允许滑动
HashSet<String> disallowSlide = new HashSet<>();//禁止滑动
HashSet<String> disallowNotification = new HashSet<>();//禁止通知栏显示通知
HashSet<String> allowPermissions = new HashSet<>();//默认给所有权限
List<NetAndLaunchData> data = netAndLaunchBean.getData();
for (NetAndLaunchData netAndLaunchData : data) {
@@ -659,6 +670,8 @@ public class JGYUtils {
int is_network = netAndLaunchData.getIs_network();
int is_upgrade = netAndLaunchData.getIs_upgrade();
int is_slide = netAndLaunchData.getIs_slide();
int is_notification = netAndLaunchData.getIs_notification();
int is_dynamic_perm = netAndLaunchData.getIs_dynamic_perm();
if (is_auto == 1) {
autoLaunchApp.add(app_package);
@@ -678,6 +691,13 @@ public class JGYUtils {
} else {
disallowSlide.add(app_package);
}
if (is_notification == 0) {
disallowNotification.add(app_package);
}
if (is_dynamic_perm == 1) {
allowPermissions.add(app_package);
}
}
if (disallowSlide.size() != 0) {
@@ -711,6 +731,29 @@ public class JGYUtils {
// Log.e(TAG, "setNetAndlaunch: 测试写入: " + w);
// }
setAppNetwork(mContext, disallowNetApp, allowNetApp);
setDisallowNotificationPackage(mContext, disallowNotification);
mMMKV.encode("aole_app_privilege", allowPermissions);
setAllowPermissionsPackage(mContext);
}
private void setDisallowNotificationPackage(Context context, HashSet<String> pkgSet) {
Log.e(TAG, "setDisallowNotificationPackage: " + pkgSet);
if (pkgSet.size() == 0) {
Settings.System.putString(context.getContentResolver(), "aole_app_info", "");
} else {
Settings.System.putString(context.getContentResolver(), "aole_app_info", String.join(",", pkgSet));
}
}
public void setAllowPermissionsPackage(Context context) {
Set<String> privilegeApp = mMMKV.decodeStringSet("aole_app_privilege", new HashSet<>());
Set<String> pkgSet = privilegeApp.stream().filter(s -> ApkUtils.isAvailable(mContext, s)).collect(Collectors.toSet());
Log.e(TAG, "setAllowPermissionsPackage: " + pkgSet);
if (pkgSet.size() == 0) {
Settings.System.putString(context.getContentResolver(), "aole_app_privilege", "");
} else {
Settings.System.putString(context.getContentResolver(), "aole_app_privilege", String.join(",", pkgSet));
}
}
@SuppressLint("NewApi")
@@ -884,7 +927,7 @@ public class JGYUtils {
//列表为空的情况
sendAllweb(mContext);
sendwebUrl(mContext);
//ToastUtil.show(msg);
//Toaster.show(msg);
Log.e("setAppinsideWeb", "setAppinsideWeb: " + response.msg);
}
}
@@ -921,7 +964,7 @@ public class JGYUtils {
setWhiteApp(whiteApp);
sendAllweb(mContext);
sendwebUrl(mContext);
//ToastUtil.show(msg);
//Toaster.show(msg);
Log.e("setAppinsideWeb", "setAppinsideWeb: " + response.msg);
}
}
@@ -1236,19 +1279,13 @@ public class JGYUtils {
this.add("com.ygyb.yischool");
}};
@SuppressLint("NewApi")
public void writeAppPackageList(String packageList) {
if (isUnlocked(mContext)) {
addAppInstallWhiteList(new ArrayList<>());
setAppRestriction(0);
return;
}
ApkUtils.addShortcut(mContext);
HashSet<String> pkgSet = new HashSet<>(Arrays.asList(packageList.split(",")));
pkgSet.addAll(defaultPackages);
private Set<String> getWhitePkgList() {
HashSet<String> pkgSet = new HashSet<>(defaultPackages);
pkgSet.addAll(showAppList);
pkgSet.addAll(ApkUtils.desktopAPP);
pkgSet.addAll(ApkUtils.aoleyunAPP);
pkgSet.addAll(ApkUtils.jxwApp);
pkgSet.addAll(ApkUtils.mJxwApp);
if ("AS001".equals(Build.MODEL)) {
pkgSet.addAll(ApkUtils.aihuaApp);
}
@@ -1264,10 +1301,23 @@ public class JGYUtils {
if (JGYUtils.getInstance().checkAppPlatform() == JGYUtils.G10PPlatform) {
pkgSet.add("com.gaomuxuexi34");
}
pkgSet.removeIf(TextUtils::isEmpty);
if (JGYUtils.C2Tag.equalsIgnoreCase(JGYUtils.getInstance().getAppPlatform())) {
pkgSet.remove("com.tencent.mm");
}
return pkgSet;
}
@SuppressLint("NewApi")
public void writeAppPackageList(String packageList) {
if (isUnlocked(mContext)) {
addAppInstallWhiteList(new ArrayList<>());
setAppRestriction(0);
return;
}
ApkUtils.addShortcut(mContext);
HashSet<String> pkgSet = new HashSet<>(Arrays.asList(packageList.split(",")));
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);
@@ -1283,27 +1333,9 @@ public class JGYUtils {
return;
}
HashSet<String> pkgSet = new HashSet<>(defaultPackages);
pkgSet.addAll(ApkUtils.desktopAPP);
pkgSet.addAll(ApkUtils.aoleyunAPP);
pkgSet.addAll(ApkUtils.jxwApp);
if ("AS001".equals(Build.MODEL)) {
pkgSet.addAll(ApkUtils.aihuaApp);
}
if ("D1".equals(Build.MODEL)) {
pkgSet.addAll(ApkUtils.dongwa);
}
if ("G23".equals(Build.MODEL)) {
pkgSet.addAll(ApkUtils.zhengwu);
}
if (JGYUtils.getInstance().checkAppPlatform() == JGYUtils.YXPD1Platform) {
pkgSet.add("com.tencent.wemeet.app");
}
if (JGYUtils.getInstance().checkAppPlatform() == JGYUtils.G10PPlatform) {
pkgSet.add("com.gaomuxuexi34");
}
if (JGYUtils.C2Tag.equalsIgnoreCase(JGYUtils.getInstance().getAppPlatform())) {
pkgSet.remove("com.tencent.mm");
}
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);
@@ -1523,7 +1555,7 @@ public class JGYUtils {
if (isUnlocked(mContext)) {
return;
}
int aihuaUnlock = Settings.System.getInt(mContext.getContentResolver(), CommonConfig.AIHUA_UNLOCK, 0);
int aihuaUnlock = Settings.System.getInt(crv, CommonConfig.AIHUA_UNLOCK, 0);
if (aihuaUnlock == 1) {
return;
}
@@ -1568,7 +1600,7 @@ public class JGYUtils {
if (ApkUtils.aihuaApp.contains(packageName)) {
continue;
}
if (ApkUtils.jxwApp.contains(packageName)) {
if (ApkUtils.mJxwApp.contains(packageName)) {
continue;
}
if (PackageNames.DEVICE_INFO.equals(packageName) || PackageNames.APPSTORE.equals(packageName)
@@ -1652,17 +1684,13 @@ public class JGYUtils {
} else {
continue;
}
if (!showAppList.contains(pkg)
&& !ApkUtils.aoleyunAPP.contains(pkg)
&& !ApkUtils.desktopAPP.contains(pkg)
&& !ApkUtils.aihuaApp.contains(pkg)
) {
pm.setApplicationEnabledSetting(pkg, PackageManager.COMPONENT_ENABLED_STATE_DISABLED, 0);
Log.e(TAG, "hideSystemAPP: " + "disable: " + pkg);
} else {
pm.setApplicationEnabledSetting(pkg, PackageManager.COMPONENT_ENABLED_STATE_DEFAULT, 0);
Log.e(TAG, "hideSystemAPP: " + "enable: " + pkg);
}
// if (!getWhitePkgList().contains(pkg)) {
// pm.setApplicationEnabledSetting(pkg, PackageManager.COMPONENT_ENABLED_STATE_DISABLED, 0);
// Log.e(TAG, "hideSystemAPP: " + "disable: " + pkg);
// } else {
// pm.setApplicationEnabledSetting(pkg, PackageManager.COMPONENT_ENABLED_STATE_DEFAULT, 0);
// Log.e(TAG, "hideSystemAPP: " + "enable: " + pkg);
// }
}
}
@@ -1713,7 +1741,11 @@ public class JGYUtils {
String oldMd5 = FileUtils.getFileMD5ToString(bootFile);
if (!TextUtils.isEmpty(oldMd5) && oldMd5.equalsIgnoreCase(MD5)) {
Log.e(TAG, "checkBootFile: Bootanimation file exists");
setBootanimation(bootFile.getAbsolutePath());
if (JGYUtils.getInstance().checkAppPlatform() == JGYUtils.MT8768Platform) {
JGYUtils.getInstance().setBootanimationG10J(bootFile.getAbsolutePath());
} else {
JGYUtils.getInstance().setBootanimation(bootFile.getAbsolutePath());
}
} else {
JsonObject jsonObject = new JsonObject();
jsonObject.addProperty("MD5", MD5);
@@ -1779,8 +1811,44 @@ public class JGYUtils {
}
}
private static final String BOOTANIMATION_PATH_G10J = "/storage/emulated/0/Download/bootanimation.zip";
public void setBootanimationG10J(String filePath) {
File newFile = new File(filePath);
if (!newFile.exists()) {
Log.e(TAG, "setBootanimationG10J: file not exists");
return;
}
File file = new File(BOOTANIMATION_PATH_G10J);
String oldMD5 = FileUtils.getFileMD5ToString(file);
String newMD5 = FileUtils.getFileMD5ToString(newFile);
if (oldMD5.equals(newMD5)) {
Log.e(TAG, "setBootanimationG10J: file md5 is the same");
} else {
if (file.exists() && !file.isDirectory()) {
if (file.delete()) {
Log.e(TAG, "setBootanimationG10J: delete old Bootanimation file successful");
} else {
Toaster.show("删除动画文件失败");
}
}
if (FileUtils.copy(newFile, file)) {
Log.e(TAG, "setBootanimationG10J: set Bootanimation successful");
} else {
Log.e(TAG, "setBootanimationG10J: set Bootanimation failed");
}
}
Intent intent = new Intent("com.hra.setBootanimation");
mContext.sendBroadcast(intent);
}
public void removeBootanimation() {
File systemFile = new File(BOOTANIMATION_PATH);
File systemFile;
if (JGYUtils.getInstance().checkAppPlatform() == JGYUtils.MT8768Platform) {
systemFile = new File(BOOTANIMATION_PATH_G10J);
} else {
systemFile = new File(BOOTANIMATION_PATH);
}
if (systemFile.exists()) {
if (systemFile.delete()) {
Log.e(TAG, "removeBootanimation: delete: " + "ture");
@@ -1788,6 +1856,10 @@ public class JGYUtils {
Log.e(TAG, "removeBootanimation: delete: " + "false");
}
}
if (JGYUtils.getInstance().checkAppPlatform() == JGYUtils.MT8768Platform) {
Intent intent = new Intent("com.hra.setBootanimation");
mContext.sendBroadcast(intent);
}
}
public void copy(String oldPath, String newPath) {
@@ -1813,10 +1885,25 @@ public class JGYUtils {
}
}
private static int changeNum(int status) {
return status == 0 ? 1 : 0;
}
/**
* @param state 1打开 0关闭
*/
public void setDeveloperOptions(int state) {
Log.e(TAG, "getDeveloper: " + state);
int newStatu = changeNum(state);
int oldStatu = Settings.System.getInt(crv, CommonConfig.AOLE_ACTION_DEVELOPER_OPTIONS, 1);
if (oldStatu == newStatu) {
Log.e(TAG, "setDeveloperOptions: oldStatu = " + oldStatu + " no changed");
return;
}
Log.e(TAG, "getDeveloper: state = " + state);
Log.e(TAG, "setDeveloperOptions: " + JGYUtils.getInstance().checkAppPlatform());
if (!BuildConfig.DEBUG) {
Settings.System.putInt(crv, CommonConfig.AOLE_ACTION_DEVELOPER_OPTIONS, state);
//这个需要反着来
Settings.System.putInt(crv, CommonConfig.AOLE_ACTION_DEVELOPER_OPTIONS, newStatu);
if (JGYUtils.getInstance().checkAppPlatform() == JGYUtils.ZhanruiPlatform
|| JGYUtils.getInstance().checkAppPlatform() == JGYUtils.CubePlatform
|| JGYUtils.getInstance().checkAppPlatform() == JGYUtils.AH6016Platform
@@ -1826,11 +1913,14 @@ public class JGYUtils {
|| JGYUtils.getInstance().checkAppPlatform() == JGYUtils.C2Platform
|| JGYUtils.getInstance().checkAppPlatform() == JGYUtils.YXPD1Platform
|| JGYUtils.getInstance().checkAppPlatform() == JGYUtils.G11Platform
|| JGYUtils.getInstance().checkAppPlatform() == JGYUtils.MT8768Platform
) {
Settings.Global.putInt(crv, Settings.Global.DEVELOPMENT_SETTINGS_ENABLED, state == 1 ? 0 : 1);
Settings.Global.putInt(crv, Settings.Global.ADB_ENABLED, state == 1 ? 0 : 1);
Settings.Global.putInt(crv, Settings.Global.DEVELOPMENT_SETTINGS_ENABLED, state);
Settings.Global.putInt(crv, Settings.Global.ADB_ENABLED, state);
}
if (state == 1) {
/*已废弃 为1关闭为0打开*/
if (newStatu == 1) {
Intent intent = new Intent();
intent.setAction("qch_developeroptions_close");
intent.setPackage("com.android.settings");
@@ -1838,8 +1928,8 @@ public class JGYUtils {
Log.e(TAG, "getDeveloper: " + "关闭开发者模式");
} else {
Log.e(TAG, "getDeveloper: " + "打开开发者模式");
// ToastUtil.show("打开开发者模式");
}
}
}
@@ -2557,64 +2647,64 @@ public class JGYUtils {
case "com.mediatek.camera":
case "com.android.camera2":
if (Settings.System.getInt(crv, "qch_app_camera", 0) == 1) {
ToastUtil.show("摄像头已禁止使用");
return false;
Toaster.show("摄像头已禁止使用");
return true;
}
break;
case "com.android.dialer":
if (Settings.System.getInt(crv, "qch_call_forbid", 0) == 1) {
ToastUtil.show("电话已禁止使用");
return false;
Toaster.show("电话已禁止使用");
return true;
}
break;
case "com.android.gallery3d":
if (Settings.System.getInt(crv, "qch_app_gallery", 1) == 1) {
ToastUtil.show("图库已禁止使用");
return false;
Toaster.show("图库已禁止使用");
return true;
}
break;
case "com.android.documentsui":
if (Settings.System.getInt(crv, "qch_app_filemanager", 1) == 1) {
ToastUtil.show("文件已禁止使用");
return false;
Toaster.show("文件已禁止使用");
return true;
}
break;
case "com.android.deskclock":
if (Settings.System.getInt(crv, "qch_app_deskclock", 0) == 1) {
ToastUtil.show("时钟已禁止使用");
return false;
Toaster.show("时钟已禁止使用");
return true;
}
break;
case "com.android.music":
if (Settings.System.getInt(crv, "qch_app_music", 1) == 1) {
ToastUtil.show("音乐已禁止使用");
return false;
Toaster.show("音乐已禁止使用");
return true;
}
break;
case "com.android.soundrecorder":
if (Settings.System.getInt(crv, "qch_app_soundrecorder", 1) == 1) {
ToastUtil.show("录音机已禁止使用");
return false;
Toaster.show("录音机已禁止使用");
return true;
}
break;
case "com.aoleyun.browser":
case "com.android.browser":
if (Settings.System.getInt(crv, "qch_app_browser", 1) == 1) {
ToastUtil.show("浏览器已禁止使用");
return false;
Toaster.show("浏览器已禁止使用");
return true;
}
break;
case "com.android.messaging":
case "com.android.mms":
if (Settings.System.getInt(crv, "qch_app_sms", 1) == 1) {
ToastUtil.show("短信已禁止使用");
return false;
Toaster.show("短信已禁止使用");
return true;
}
break;
default:
return true;
return false;
}
return true;
return false;
}
@@ -2818,7 +2908,7 @@ public class JGYUtils {
String apkPath = aolePath + File.separator + fileName;
Log.e(TAG, "subscribe: " + apkPath);
String pkg = ApkUtils.getPackageName(mContext, apkPath);
if (mJxwApps.contains(pkg)) {
if (ApkUtils.mJxwApp.contains(pkg)) {
packageListMap.put(pkg, apkPath);
} else {
Log.e(TAG, "checkLocalAppInstall: skip: " + pkg + " fileName: " + fileName);
@@ -2863,62 +2953,6 @@ public class JGYUtils {
}
}
/**
*
*/
private Set<String> mJxwApps = new HashSet<String>() {{
this.add("air.com.zhihuiyoujiao.flashplayer");
this.add("com.example.arithmeticformula");
this.add("com.example.elementcycleapp");
this.add("com.example.pianpangbushou");
this.add("com.iflytek.cyber.iot.show.core");
this.add("com.iflytek.speechcloud");
this.add("com.jxw.bihuamingcheng");
this.add("com.jxw.bishunguize");
this.add("com.jxw.characterlearning");
this.add("com.jxw.dmxcy");
this.add("com.jxw.englishsoundmark");
this.add("com.jxw.examsystem");
this.add("com.jxw.game");
this.add("com.jxw.gb.zwpg");
this.add("com.jxw.handwrite");
this.add("com.jxw.jinfangyici");
this.add("com.jxw.jxwbook");
this.add("com.jxw.jxwcalculator");
this.add("com.jxw.laboratory");
this.add("com.jxw.learnchinesepinyin");
this.add("com.jxw.letterstudynew");
this.add("com.jxw.liancichengju");
this.add("com.jxw.mskt.video");
this.add("com.jxw.newyouer.video");
this.add("com.jxw.online_study");
this.add("com.jxw.question");
this.add("com.jxw.schultegrid");
this.add("com.jxw.singsound");
this.add("com.jxw.studydigital");
this.add("com.jxw.teacher.video");
this.add("com.jxw.wuweijidanci");
this.add("com.jxw.youer.video");
this.add("com.jxw.yuwenxiezuo");
this.add("com.jxw.yyhb");
this.add("com.jxw.zncd");
this.add("com.jxw.souti");
this.add("com.jxw.xdfzq");
this.add("com.oirsdfg89.flg");
this.add("com.study.flashplayer");
this.add("com.tech.translate");
this.add("com.uiui.zybrowser");
this.add("com.uiui.zysn ");
this.add("com.jxw.launcher");
this.add("com.uiui.zyappstore");
this.add("com.uiui.zy");
this.add("com.uiui.zyos");
this.add("com.teclast.zyos");
this.add("com.teclast.zybrowser");
this.add("com.teclast.zyappstore");
this.add("com.teclast.zy");
}};
public static boolean isUnlocked(Context context) {
int locked = Settings.System.getInt(context.getContentResolver(), JGYActions.ACTION_QCH_UNLOCK_IPAD, JGYActions.FRAME_CODE_LOCKED);
@@ -3106,7 +3140,7 @@ public class JGYUtils {
public void setTongyiAppTop() {
if (ApkUtils.isAvailable(mContext, "com.tongyi.aistudent")) {
ForegroundAppUtil.setTopAppClass(mContext, "com.tongyi.aistudent");
Settings.Global.putString(mContext.getContentResolver(), ForegroundAppUtil.TOPAPP_KEY, "com.tongyi.aistudent");
Settings.Global.putString(crv, ForegroundAppUtil.TOPAPP_KEY, "com.tongyi.aistudent");
ForegroundAppUtil.openTopApp(mContext);
}
}
@@ -3133,11 +3167,14 @@ public class JGYUtils {
* @return true为能打开
*/
public boolean isCloudLessonMod(String pkg) {
if (JGYUtils.getInstance().isForbid(pkg)) {
return false;
}
if (ApkUtils.isSystemApp(mContext, pkg)) {
Log.e(TAG, "isCloudLessonMod: is system app");
return true;
}
if (mJxwApps.contains(pkg)) {
if (ApkUtils.mJxwApp.contains(pkg)) {
return true;
}
if (mLessonJson == null)
@@ -3150,6 +3187,7 @@ public class JGYUtils {
if (mContralTime.inControlTime()) {
return pkgs.contains(pkg);
} else {
Toaster.show("专注模式只允许使用指定应用");
return false;
}
}
@@ -3157,4 +3195,19 @@ public class JGYUtils {
return true;
}
}
public String getAppName(String pkg) {
PackageManager pm = mContext.getPackageManager();
PackageInfo info = null;
try {
info = pm.getPackageInfo(pkg, 0);
} catch (PackageManager.NameNotFoundException e) {
e.printStackTrace();
}
if (info == null) {
return "未知";
} else {
return info.applicationInfo.loadLabel(pm).toString();
}
}
}