version:4.3

fix:安装应用时不清除桌面缓存,锁定状态改变时不恢复出厂设置
update:在获取sn没有刷写的状态时,获取IMEI作为别名
This commit is contained in:
2022-04-19 09:24:45 +08:00
parent 2339e1484d
commit 69a8934bd4
24 changed files with 514 additions and 263 deletions

View File

@@ -5,6 +5,7 @@ import android.app.ActivityManager;
import android.app.ActivityManagerNative;
import android.app.ActivityTaskManager;
import android.content.ComponentName;
import android.content.ContentResolver;
import android.content.Context;
import android.content.ContextWrapper;
import android.content.Intent;
@@ -102,6 +103,8 @@ public class JGYUtils {
@SuppressLint("StaticFieldLeak")
private static JGYUtils sInstance;
private Context mContext;
private ContentResolver crv;
public static int MTKPlatform = 1;
public static int ZhanruiPlatform = 2;
public static int UnknowPlatform = 0;
@@ -121,6 +124,7 @@ public class JGYUtils {
throw new RuntimeException("Context is NULL");
}
this.mContext = context;
this.crv = context.getContentResolver();
this.cacheHelper = new CacheHelper(context);
}
@@ -180,7 +184,7 @@ public class JGYUtils {
}
public boolean getDeviceIsLocked() {
int locked = Settings.System.getInt(mContext.getContentResolver(), JGYActions.ACTION_QCH_UNLOCK_IPAD, JGYActions.FRAME_CODE_LOCKED);
int locked = Settings.System.getInt(crv, JGYActions.ACTION_QCH_UNLOCK_IPAD, JGYActions.FRAME_CODE_LOCKED);
return locked == JGYActions.FRAME_CODE_LOCKED;
}
@@ -265,11 +269,11 @@ public class JGYUtils {
if (disallowSlide.size() != 0) {
String slide_not = String.join(",", disallowSlide);
boolean writeSucceed = Settings.System.putString(mContext.getContentResolver(), "qch_disable_slide", slide_not);
boolean writeSucceed = Settings.System.putString(crv, "qch_disable_slide", slide_not);
Log.e("fht", "qch_disable_slide=" + writeSucceed + ":" + slide_not);
} else {
String slide_ok = String.join(",", allowSlide);
boolean writeSucceed = Settings.System.putString(mContext.getContentResolver(), "qch_disable_slide", "Invalid");
boolean writeSucceed = Settings.System.putString(crv, "qch_disable_slide", "Invalid");
Log.e("fht", "qch_disable_slide ok=" + writeSucceed + ":" + slide_ok);
}
@@ -283,19 +287,18 @@ public class JGYUtils {
Log.e(TAG, "setNetAndlaunch: qch_app_power_on: " + qch_app_power_on);
if (TextUtils.isEmpty(qch_app_power_on)) {
//当 qch_app_power_on 的值为空时,会造成系统所有应用断网
Settings.System.putString(mContext.getContentResolver(), "qch_app_power_on", "Invalid");
Settings.System.putString(crv, "qch_app_power_on", "Invalid");
Log.e(TAG, "setNetAndlaunch: qch_app_power_on: " + "Invalid");
} else {
Settings.System.putString(mContext.getContentResolver(), "qch_app_power_on", qch_app_power_on);
Settings.System.putString(crv, "qch_app_power_on", qch_app_power_on);
Log.e(TAG, "setNetAndlaunch: qch_app_power_on: " + qch_app_power_on);
}
// if (BuildConfig.DEBUG) {
// TODO: 2021/7/2 测试写入为空是否断网
// boolean w = Settings.System.putString(mContext.getContentResolver(), "qch_app_power_on", "");
// boolean w = Settings.System.putString(crv, "qch_app_power_on", "");
// Log.e(TAG, "setNetAndlaunch: 测试写入: " + w);
// }
setAppNetwork(mContext, disallowNetApp);
BaseApplication.getInstance().setFinished(true);
}
private void checkPackageAndVersion(HashSet<String> disallowUpgrade, List<AppListInfo> appListInfos) {
@@ -372,11 +375,11 @@ public class JGYUtils {
if (disallowSlide.size() != 0) {
String slide_not = String.join(",", disallowSlide);
boolean writeSucceed = Settings.System.putString(mContext.getContentResolver(), "qch_disable_slide", slide_not);
boolean writeSucceed = Settings.System.putString(crv, "qch_disable_slide", slide_not);
Log.e("fht", "qch_disable_slide=" + writeSucceed + ":" + slide_not);
} else {
String slide_ok = String.join(",", allowSlide);
boolean writeSucceed = Settings.System.putString(mContext.getContentResolver(), "qch_disable_slide", "Invalid");
boolean writeSucceed = Settings.System.putString(crv, "qch_disable_slide", "Invalid");
Log.e("fht", "qch_disable_slide ok=" + writeSucceed + ":" + slide_ok);
}
@@ -389,19 +392,18 @@ public class JGYUtils {
Log.e(TAG, "setNetAndlaunch: qch_app_power_on: " + qch_app_power_on);
if (TextUtils.isEmpty(qch_app_power_on)) {
//当 qch_app_power_on 的值为空时,会造成系统所有应用断网
Settings.System.putString(mContext.getContentResolver(), "qch_app_power_on", "Invalid");
Settings.System.putString(crv, "qch_app_power_on", "Invalid");
Log.e(TAG, "setNetAndlaunch: qch_app_power_on: " + "Invalid");
} else {
Settings.System.putString(mContext.getContentResolver(), "qch_app_power_on", qch_app_power_on);
Settings.System.putString(crv, "qch_app_power_on", qch_app_power_on);
Log.e(TAG, "setNetAndlaunch: qch_app_power_on: " + qch_app_power_on);
}
// if (BuildConfig.DEBUG) {
// TODO: 2021/7/2 测试写入为空是否断网
// boolean w = Settings.System.putString(mContext.getContentResolver(), "qch_app_power_on", "");
// boolean w = Settings.System.putString(crv, "qch_app_power_on", "");
// Log.e(TAG, "setNetAndlaunch: 测试写入: " + w);
// }
setAppNetwork(mContext, disallowNetApp);
BaseApplication.getInstance().setFinished(true);
}
@SuppressLint("NewApi")
@@ -482,7 +484,7 @@ public class JGYUtils {
String net_not = String.join(",", blackList);
SPUtils.put(context, JGYActions.ACTION_HRRECEIVER_JGY_DIS, net_not);
//Settings.System.putString(mContext.getContentResolver(), JGYActions.ACTION_HrReceiver_JGY_DIS, net_not);
//Settings.System.putString(crv, JGYActions.ACTION_HrReceiver_JGY_DIS, net_not);
Log.e("fht", "not::" + net_not);
//Intent netControlIntent = new Intent(CommonDatas.ACTION_HrReceiver_JGY_DIS);
@@ -546,17 +548,17 @@ public class JGYUtils {
}
String olddeselectViewArray = Settings.System.getString(mContext.getContentResolver(), "qch_app_forbid_id");
String olddeselectViewArray = Settings.System.getString(crv, "qch_app_forbid_id");
Log.e("writeDeselectIDtoSystem", "olddeselectViewArray: " + olddeselectViewArray);
Settings.System.putString(mContext.getContentResolver(), "qch_app_forbid_id", packageStringBuilder.toString());
Settings.System.putString(mContext.getContentResolver(), "DeselectViewArray", idStringBuilder.toString());
Settings.System.putString(crv, "qch_app_forbid_id", packageStringBuilder.toString());
Settings.System.putString(crv, "DeselectViewArray", idStringBuilder.toString());
Log.e("writeDeselectIDtoSystem", "qch_app_forbid_id: " + packageStringBuilder.toString());
Log.e("writeDeselectIDtoSystem", "deselectViewArray: " + idStringBuilder.toString());
} else {
Log.e("writeDeselectIDtoSystem", "writeDeselectIDtoSystem is null:");
Settings.System.putString(mContext.getContentResolver(), "qch_app_forbid_id", "");
Settings.System.putString(mContext.getContentResolver(), "DeselectViewArray", "");
Settings.System.putString(crv, "qch_app_forbid_id", "");
Settings.System.putString(crv, "DeselectViewArray", "");
}
}
@@ -963,8 +965,8 @@ public class JGYUtils {
pkgSet.removeIf(TextUtils::isEmpty);
String qch_app_forbid = String.join(",", pkgSet);
Log.e(TAG, "writeAppPackageList: " + qch_app_forbid);
boolean b = Settings.System.putString(mContext.getContentResolver(), "qch_app_forbid", qch_app_forbid);
Log.e("writeAppPackageList: ", "qch_app_forbid is :" + b + " " + Settings.System.getString(mContext.getContentResolver(), "qch_app_forbid"));
boolean b = Settings.System.putString(crv, "qch_app_forbid", qch_app_forbid);
Log.e("writeAppPackageList: ", "qch_app_forbid is :" + b + " " + Settings.System.getString(crv, "qch_app_forbid"));
}
public void checkForceDownload() {
@@ -1151,10 +1153,10 @@ public class JGYUtils {
versionCode = info.versionCode;
}
if (app_version_code > versionCode) {
Utils.ariaDownload(mContext, app_url, jsonObject);
Utils.ariaDownload(mContext, app_url, jsonObject);
}
} else {
Utils.ariaDownload(mContext, app_url, jsonObject);
Utils.ariaDownload(mContext, app_url, jsonObject);
}
}
@@ -1162,7 +1164,7 @@ public class JGYUtils {
//删除用户除了在应用市场的其他应用
public void deleteOtherApp() {
int locked = Settings.System.getInt(mContext.getContentResolver(), JGYActions.ACTION_QCH_UNLOCK_IPAD, 0);
int locked = Settings.System.getInt(crv, JGYActions.ACTION_QCH_UNLOCK_IPAD, 0);
if (locked == 1) {
return;
}
@@ -1170,12 +1172,12 @@ public class JGYUtils {
String[] result_white = new String[]{};
String[] result_forbid = new String[]{};
//获取后台应用白名单
String only_jgy_shortcut_list = Settings.System.getString(mContext.getContentResolver(), JGYActions.ACTION_JGY_SHORTCUTLIST);
String only_jgy_shortcut_list = Settings.System.getString(crv, JGYActions.ACTION_JGY_SHORTCUTLIST);
if (!TextUtils.isEmpty(only_jgy_shortcut_list)) {
result_white = only_jgy_shortcut_list.split(",");
}
//获取可以被安装的包名
String qch_app_forbid = Settings.System.getString(mContext.getContentResolver(), "qch_app_forbid");
String qch_app_forbid = Settings.System.getString(crv, "qch_app_forbid");
if (!TextUtils.isEmpty(qch_app_forbid)) {
result_forbid = qch_app_forbid.split(",");
}
@@ -1397,7 +1399,11 @@ public class JGYUtils {
public void setDeveloperOptions(int state) {
Log.e(TAG, "getDeveloper: " + state);
if (!BuildConfig.DEBUG) {
Settings.System.putInt(mContext.getContentResolver(), "qch_Developeroptions", state);
Settings.System.putInt(crv, "qch_Developeroptions", state);
if (JGYUtils.getInstance().checkAppPlatform() == JGYUtils.ZhanruiPlatform) {
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);
}
if (state == 1) {
Intent intent = new Intent();
intent.setAction("qch_developeroptions_close");
@@ -1411,8 +1417,13 @@ public class JGYUtils {
}
}
private String chromium_pkg = "org.chromium.browser";
public void hookWebView() {
int sdkInt = Build.VERSION.SDK_INT;
if (!ApkUtils.isAvailable(mContext, chromium_pkg)) {
return;
}
try {
Class<?> factoryClass = Class.forName("android.webkit.WebViewFactory");
Field field = factoryClass.getDeclaredField("sProviderInstance");
@@ -1463,7 +1474,7 @@ public class JGYUtils {
Log.i(TAG, "Hook failed!");
}
} catch (Throwable e) {
Log.w(TAG, e.getMessage());
Log.w(TAG, "hookWebView: " + e.getMessage());
}
}
@@ -1908,9 +1919,9 @@ public class JGYUtils {
Log.e(TAG, "setDefaultDesktop: " + pkg + ":" + className);
}
public String getMacJson() {
public String getMacJson(Context context) {
JsonObject jsonObject = new JsonObject();
jsonObject.addProperty("sn", Utils.getSerial());
jsonObject.addProperty("sn", Utils.getSerial(context));
jsonObject.addProperty("mac", Utils.getAndroid10MAC(mContext));
// jsonObject.addProperty("jpush_id", JPushInterface.getRegistrationID(mContext));
jsonObject.addProperty("jpush_id", "0000");
@@ -1937,28 +1948,6 @@ public class JGYUtils {
}
}
public static final String PACKAGE_DEVICEINFO = "com.aoleyun.sn";
public static final String PACKAGE_APPSTORE = "com.aoleyun.appstore";
public static final String CLASS_DEVICEINFO = "com.aoleyun.sn.receiver.BootReceiver";
public static final String CLASS_APPSTORE = "com.aoleyun.appstore.receiver.BootReceiver";
public void wakeUpDeviceInfo() {
//启动设备信息
Intent bootIntent = new Intent(BootReceiver.BOOT_COMPLETED);
bootIntent.setComponent(new ComponentName(PACKAGE_DEVICEINFO, CLASS_DEVICEINFO));
mContext.sendBroadcast(bootIntent);
}
public void wakeUpAppstore() {
//启动应用市场
Intent bootIntent = new Intent(BootReceiver.BOOT_COMPLETED);
bootIntent.setComponent(new ComponentName(PACKAGE_APPSTORE, CLASS_APPSTORE));
mContext.sendBroadcast(bootIntent);
}
/**
* 判断网络连接状态
*
@@ -1990,8 +1979,59 @@ public class JGYUtils {
try {
new CacheUtils().cleanApplicationUserData(mContext, "com.aoleyun.os");
} catch (Exception e) {
Log.e(TAG, "onReceive: " + e.getMessage());
Log.e(TAG, "cleanAoleLauncher3Cache: " + e.getMessage());
e.printStackTrace();
}
}
public void cleanAoleAppCache() {
try {
new CacheUtils().cleanApplicationUserData(mContext, "com.aoleyun.os");
new CacheUtils().cleanApplicationUserData(mContext, "com.aoleyun.appstore");
new CacheUtils().cleanApplicationUserData(mContext, "com.aoleyun.info");
new CacheUtils().cleanApplicationUserData(mContext, "com.aoleyun.browser");
} catch (Exception e) {
Log.e(TAG, "cleanAoleAppCache: " + e.getMessage());
e.printStackTrace();
}
}
public static final String PACKAGE_DEVICEINFO = "com.aoleyun.sn";
public static final String CLASS_DEVICEINFO = "com.aoleyun.sn.receiver.BootReceiver";
public void wakeUpDeviceInfo() {
Log.e(TAG, "wakeUpDeviceInfo: ");
//启动设备信息
Intent bootIntent = new Intent(BootReceiver.BOOT_COMPLETED);
bootIntent.setComponent(new ComponentName(PACKAGE_DEVICEINFO, CLASS_DEVICEINFO));
mContext.sendBroadcast(bootIntent);
}
public static final String PACKAGE_APPSTORE = "com.aoleyun.appstore";
public static final String CLASS_APPSTORE = "com.aoleyun.appstore.receiver.BootReceiver";
public void wakeUpAppstore() {
Log.e(TAG, "wakeUpAppstore: ");
//启动应用市场
Intent bootIntent = new Intent(BootReceiver.BOOT_COMPLETED);
bootIntent.setComponent(new ComponentName(PACKAGE_APPSTORE, CLASS_APPSTORE));
mContext.sendBroadcast(bootIntent);
}
public static final String PACKAGE_NOTIFY = "com.aoleyun.info";
public static final String CLASS_NOTIFY = "com.aoleyun.info.receiver.BootReceiver";
public void wakeUpNotify() {
Log.e(TAG, "wakeUpNotify: ");
//启动通知
Intent bootIntent = new Intent(BootReceiver.BOOT_COMPLETED);
bootIntent.setComponent(new ComponentName(PACKAGE_NOTIFY, CLASS_NOTIFY));
mContext.sendBroadcast(bootIntent);
}
public void wakeUpAoleyunAPP() {
wakeUpAppstore();
wakeUpNotify();
}
}