diff --git a/app/build.gradle b/app/build.gradle index c14ca4d..f2da1ec 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -18,8 +18,8 @@ android { defaultConfig { applicationId "com.aoleyun.sn" - versionCode 257 - versionName "1.6.1027" + versionCode 259 + versionName "1.6.1105" //There are no CERT files because If the mini sdk version is 23+, the AGP will ignore the V1 scheme signature. minSdkVersion 24 diff --git a/app/src/main/java/com/aoleyun/sn/activity/debug/DebugActivity.java b/app/src/main/java/com/aoleyun/sn/activity/debug/DebugActivity.java index bdfa585..04dfcce 100644 --- a/app/src/main/java/com/aoleyun/sn/activity/debug/DebugActivity.java +++ b/app/src/main/java/com/aoleyun/sn/activity/debug/DebugActivity.java @@ -24,6 +24,7 @@ import androidx.core.graphics.drawable.IconCompat; import com.aoleyun.sn.BuildConfig; import com.aoleyun.sn.R; import com.aoleyun.sn.base.mvvm.BaseMvvmActivity; +import com.aoleyun.sn.comm.CommonConfig; import com.aoleyun.sn.databinding.ActivityDebugBinding; import com.aoleyun.sn.manager.AllwinnerCubeMdmManager; import com.aoleyun.sn.receiver.ShortcutReceiver; @@ -33,9 +34,7 @@ import com.aoleyun.sn.utils.JgyUtils; import com.hjq.toast.Toaster; import java.util.ArrayList; -import java.util.HashMap; import java.util.List; -import java.util.Map; import java.util.Random; public class DebugActivity extends BaseMvvmActivity { @@ -96,18 +95,6 @@ public class DebugActivity extends BaseMvvmActivity InputMethods = imeManager.getInputMethodList(); - Map inputMap = new HashMap<>(); - for (InputMethodInfo inputMethodInfo : InputMethods) { - inputMap.put(inputMethodInfo.getPackageName(), inputMethodInfo.getId()); - } - String id = inputMap.get(pkg); - Log.e(TAG, "getInputMethodId: " + id); - return id; - } - public static void addShortCutCompact(Context context) { if (ShortcutManagerCompat.isRequestPinShortcutSupported(context)) { Intent shortcutInfoIntent = new Intent(context, DebugActivity.class); @@ -565,7 +552,7 @@ public class DebugActivity extends BaseMvvmActivity InputMethods = imeManager.getInputMethodList(); - Map inputMap = new HashMap<>(); - for (InputMethodInfo inputMethodInfo : InputMethods) { - inputMap.put(inputMethodInfo.getPackageName(), inputMethodInfo.getId()); - } - String id = inputMap.get(pkg); - Log.e(TAG, "getInputMethodId: " + id); - return id; - } - /** * 设置默认简易桌面或学习桌面 * diff --git a/app/src/main/java/com/aoleyun/sn/push/PushManager.java b/app/src/main/java/com/aoleyun/sn/push/PushManager.java index a95c2ec..44e70d4 100644 --- a/app/src/main/java/com/aoleyun/sn/push/PushManager.java +++ b/app/src/main/java/com/aoleyun/sn/push/PushManager.java @@ -1134,25 +1134,10 @@ public class PushManager { } JsonElement keyboardElement = jsonObject.get("default_IME"); if (keyboardElement.isJsonNull() || TextUtils.isEmpty(keyboardElement.getAsString())) { - Intent intent = new Intent("setDefaultInputMethod"); - if (JgyUtils.getInstance().checkAppPlatform() == JgyUtils.QualcommPlatform) { - intent.putExtra("package", "com.onyx.kime"); - intent.setPackage("com.onyx.neoservice"); - } else { - intent.putExtra("package", "com.android.inputmethod.latin"); - intent.setPackage("com.android.settings"); - } - mContext.sendBroadcast(intent); + JgyUtils.getInstance().sendInputBroadcast(""); } else { String default_IME = jsonObject.get("default_IME").getAsString(); - Intent intent = new Intent("setDefaultInputMethod"); - intent.putExtra("package", default_IME); - if (JgyUtils.getInstance().checkAppPlatform() == JgyUtils.QualcommPlatform) { - intent.setPackage("com.onyx.neoservice"); - } else { - intent.setPackage("com.android.settings"); - } - mContext.sendBroadcast(intent); + JgyUtils.getInstance().sendInputBroadcast(default_IME); } String default_browser = jsonObject.get("default_browser").getAsString(); diff --git a/app/src/main/java/com/aoleyun/sn/utils/AndroidSettingsWriter.java b/app/src/main/java/com/aoleyun/sn/utils/AndroidSettingsWriter.java index 41f2cd7..d44dbbc 100644 --- a/app/src/main/java/com/aoleyun/sn/utils/AndroidSettingsWriter.java +++ b/app/src/main/java/com/aoleyun/sn/utils/AndroidSettingsWriter.java @@ -10,6 +10,9 @@ import android.text.TextUtils; import android.util.Log; import java.lang.reflect.Method; +import java.util.ArrayList; +import java.util.Comparator; +import java.util.List; /** * 以 "android" 包名记账写 Settings.System/Secure/Global(system uid + platform 签名前提), @@ -53,10 +56,7 @@ public final class AndroidSettingsWriter { } public static boolean putString(Context context, String namespace, String name, String value) { - Context targetContext = context; - if (targetContext == null) { - targetContext = sAppContext; - } + Context targetContext = context != null ? context : sAppContext; if (targetContext == null) { Log.e(TAG, "putString: Context is null"); return false; @@ -71,23 +71,31 @@ public final class AndroidSettingsWriter { // _user 是 SettingsProvider 定位落库用户的必填项,与包名伪装无关;只管主用户 arg.putInt(CALL_METHOD_USER_KEY, 0); - // 注意:发起方进程绝不能 clearCallingIdentity——它会篡改本进程事务携带的 - // 调用身份,SettingsProvider 侧校验 calling pid 会直接拒绝("doesn't match source pid")。 - // 那个手法只适用于服务端(代理进程处理入站 binder 调用时)。 + // 1. 优先尝试伪装 "android" 包名调用 SettingsProvider 的 call 接口 Bundle result = callSettingsPut(targetContext, namespace, arg, name); - boolean bundleOk = isOk(result); - // 该厂商 SettingsProvider 对 PUT_* 静默返回 null(不抛异常也不回 Bundle), - // 成败以写后读回为准。 - String readBack = readSetting(targetContext.getContentResolver(), namespace, name); - boolean verified = TextUtils.equals(readBack, value); - if (bundleOk || verified) { - Log.d(TAG, "putString succeeded for " + namespace + "/" + name - + " (bundleOk=" + bundleOk + ", verified=" + verified + ")"); + + // 2. 直接查询 SettingsProvider 服务端数据库校验(绕过本进程 sNameValueCache 本地内存缓存) + String serverValue = callSettingsGet(targetContext, namespace, name); + boolean serverVerified = TextUtils.equals(serverValue, value); + + if (serverVerified) { + Log.d(TAG, "putString succeeded via SettingsProvider for " + namespace + "/" + name + + " (serverVerified=true)"); return true; } - Log.w(TAG, "putString failed for " + namespace + "/" + name - + " (result=" + result + ", readBack=" + readBack + "), fallback to direct put"); - return directPutString(targetContext.getContentResolver(), namespace, name, value); + + // 3. 服务端校验未通过或 result 为空时,退回 directPutString 直接写入 + Log.w(TAG, "putString via provider failed for " + namespace + "/" + name + + " (result=" + result + ", serverValue=" + serverValue + "), fallback to direct put"); + boolean directOk = directPutString(targetContext.getContentResolver(), namespace, name, value); + + // 4. 读取校验 + String readBackDirect = readSetting(targetContext.getContentResolver(), namespace, name); + boolean directVerified = TextUtils.equals(readBackDirect, value); + + Log.d(TAG, "directPutString for " + namespace + "/" + name + " (directOk=" + directOk + + ", verified=" + directVerified + ")"); + return directOk || directVerified; } /** @@ -126,68 +134,103 @@ public final class AndroidSettingsWriter { } } - /** - * 直路一条:反射 acquireExistingProvider 拿 ContentProviderProxy, - * 用伪造的 AttributionSource(uid=1000, package="android") 调其 call。 - * 事务由设备框架自己生成的 Proxy 写出,事务码/布局永远和 ROM 匹配。 - * 前提:android.uid.system + platform 签名。 - */ private static Bundle callSettingsPut(Context context, String namespace, Bundle arg, String name) { Object provider = getSettingsProvider(context); - if (provider == null) { - return null; + Bundle result = null; + if (provider != null) { + result = invokeProviderCall(provider, "PUT_" + namespace, arg, name); + if (result == null) { + // 可能 binder 已死亡,清缓存重取再试一次 + sSettingsProvider = null; + provider = getSettingsProvider(context); + if (provider != null) { + result = invokeProviderCall(provider, "PUT_" + namespace, arg, name); + } + } } - Bundle result = invokeProviderCall(provider, namespace, arg, name); - if (result == null) { - // 可能 binder 已死亡,清缓存重取再试一次 - sSettingsProvider = null; - provider = getSettingsProvider(context); - if (provider != null) { - result = invokeProviderCall(provider, namespace, arg, name); + if (result == null && context != null) { + try { + result = context.getContentResolver().call(SETTINGS_URI, "PUT_" + namespace, name, arg); + } catch (Throwable t) { + Log.w(TAG, "callSettingsPut ContentResolver.call failed: " + t); } } return result; } - /** - * S+ 的 ContentProviderProxy 记账包名取自 AttributionSource: - * 伪造 AttributionSource(uid=1000, packageName="android") 调 - * call(AttributionSource, authority, method, arg, extras)。 - * 本 App 就是 uid 1000,enforceCallingUid 校验通过;"android" 包属于 uid 1000, - * attribution 链校验也通过。旧 4 参 call 无包名槽位(会记真实包名),不用。 - */ - private static Bundle invokeProviderCall(Object provider, String namespace, Bundle arg, - String name) { - Object attribution = buildAndroidAttributionSource(); - if (attribution == null) { - Log.e(TAG, "putString: attribution source is null, abort"); - return null; + private static String callSettingsGet(Context context, String namespace, String name) { + Bundle arg = new Bundle(); + arg.putInt(CALL_METHOD_USER_KEY, 0); + + Object provider = getSettingsProvider(context); + Bundle result = null; + if (provider != null) { + result = invokeProviderCall(provider, "GET_" + namespace, arg, name); } - String callMethod = "PUT_" + namespace; + if (result == null && context != null) { + try { + result = context.getContentResolver().call(SETTINGS_URI, "GET_" + namespace, name, arg); + } catch (Throwable t) { + Log.w(TAG, "callSettingsGet ContentResolver.call failed: " + t); + } + } + if (result != null) { + return result.getString(Settings.NameValueTable.VALUE); + } + return null; + } + + /** + * 多版本兼容的 ContentProvider.call 调用支持: + * 针对 Android 12+(AttributionSource)、Android 11(6参)、Android 10(5参)、Android 9及更低(4参/3参)逐个适配 + */ + private static Bundle invokeProviderCall(Object provider, String callMethod, Bundle arg, String name) { + Object attribution = buildAndroidAttributionSource(); + for (Method m : provider.getClass().getMethods()) { if (!"call".equals(m.getName())) { continue; } Class[] p = m.getParameterTypes(); - if (p.length == 5 && p[1] == String.class && p[4] == Bundle.class - && p[0].getName().equals("android.content.AttributionSource")) { - try { - Bundle r = (Bundle) m.invoke(provider, attribution, SETTINGS_AUTHORITY, - callMethod, name, arg); - Log.d(TAG, "putString: invoked " + callMethod + " " - + java.util.Arrays.toString(p) + " -> " - + (r == null ? "null" : r.toString())); - return r; - } catch (Throwable t) { - Throwable root = t instanceof java.lang.reflect.InvocationTargetException - && t.getCause() != null ? t.getCause() : t; - Log.w(TAG, "putString: provider call failed: " + root); - return null; + try { + // 1. Android 12+ (5 params: AttributionSource, String, String, String, Bundle) + if (p.length == 5 && p[0].getName().equals("android.content.AttributionSource") + && p[1] == String.class && p[2] == String.class && p[3] == String.class && p[4] == Bundle.class) { + if (attribution != null) { + Bundle r = (Bundle) m.invoke(provider, attribution, SETTINGS_AUTHORITY, callMethod, name, arg); + return r != null ? r : new Bundle(); + } } + // 2. Android 11 (6 params: String callingPkg, String featureId, String authority, String method, String request, Bundle extras) + else if (p.length == 6 && p[0] == String.class && p[1] == String.class && p[2] == String.class + && p[3] == String.class && p[4] == String.class && p[5] == Bundle.class) { + Bundle r = (Bundle) m.invoke(provider, "android", null, SETTINGS_AUTHORITY, callMethod, name, arg); + return r != null ? r : new Bundle(); + } + // 3. Android 10 (5 params: String callingPkg, String authority, String method, String request, Bundle extras) + else if (p.length == 5 && p[0] == String.class && p[1] == String.class && p[2] == String.class + && p[3] == String.class && p[4] == Bundle.class) { + Bundle r = (Bundle) m.invoke(provider, "android", SETTINGS_AUTHORITY, callMethod, name, arg); + return r != null ? r : new Bundle(); + } + // 4. Android 9 / earlier (4 params: String callingPkg, String method, String request, Bundle extras) + else if (p.length == 4 && p[0] == String.class && p[1] == String.class + && p[2] == String.class && p[3] == Bundle.class) { + Bundle r = (Bundle) m.invoke(provider, "android", callMethod, name, arg); + return r != null ? r : new Bundle(); + } + // 5. 3 params: String method, String request, Bundle extras + else if (p.length == 3 && p[0] == String.class && p[1] == String.class && p[2] == Bundle.class) { + Bundle r = (Bundle) m.invoke(provider, callMethod, name, arg); + return r != null ? r : new Bundle(); + } + } catch (Throwable t) { + Throwable root = t instanceof java.lang.reflect.InvocationTargetException + && t.getCause() != null ? t.getCause() : t; + Log.w(TAG, "invokeProviderCall " + callMethod + " failed via " + m.getName() + ": " + root); } } - Log.w(TAG, "putString: no AttributionSource call overload on " - + provider.getClass().getName()); + Log.w(TAG, "invokeProviderCall: no matching call overload on " + provider.getClass().getName()); return null; } @@ -201,19 +244,12 @@ public final class AndroidSettingsWriter { builder.getMethod("setPackageName", String.class).invoke(b, "android"); return builder.getMethod("build").invoke(b); } catch (Throwable t) { - Log.e(TAG, "putString: build AttributionSource failed: " + t); return null; } } - private static boolean isOk(Bundle result) { - return result != null && !"error".equals(result.getString("tag")); - } - /** - * 反射 ContentResolver.acquireProvider / acquireExistingProvider(各 ROM 签名不同, - * 扫描方法名+按参数类型填槽,String 槽位两种顺序都试),返回并缓存 IContentProvider 代理。 - * 调用者是 android.uid.system,hidden API 豁免生效。 + * 反射 ContentResolver.acquireProvider / acquireExistingProvider,返回并缓存 IContentProvider 代理。 */ private static Object getSettingsProvider(Context context) { Object cached = sSettingsProvider; @@ -225,7 +261,7 @@ public final class AndroidSettingsWriter { return sSettingsProvider; } ContentResolver cr = context.getContentResolver(); - java.util.List candidates = new java.util.ArrayList<>(); + List candidates = new ArrayList<>(); for (Method m : ContentResolver.class.getDeclaredMethods()) { String n = m.getName(); if (("acquireProvider".equals(n) || "acquireExistingProvider".equals(n)) @@ -233,8 +269,7 @@ public final class AndroidSettingsWriter { candidates.add(m); } } - java.util.Collections.sort(candidates, - (a, b) -> a.getParameterCount() - b.getParameterCount()); + candidates.sort(Comparator.comparingInt(Method::getParameterCount)); for (Method m : candidates) { Object provider = tryAcquire(cr, m); if (provider != null) { @@ -249,10 +284,6 @@ public final class AndroidSettingsWriter { } } - /** - * 3 参版是 (authority, name, ...),5 参版是 (config, name, userId, authority, stable), - * String 槽位顺序在不同 API 上相反,猜错会 NPE,两组组合都试。 - */ private static Object tryAcquire(ContentResolver cr, Method m) { Class[] types = m.getParameterTypes(); String[][] slotCombos = { @@ -273,9 +304,8 @@ public final class AndroidSettingsWriter { } else if (t == boolean.class) { args[i] = false; // stable / tryLocal:走 binder 路径 } else if (t == int.class) { - args[i] = 0; // userId / pid(0 会让 ActivityThread 用 myPid) + args[i] = 0; // userId / pid } - // IBinder、Intent 等保持 null } m.setAccessible(true); Object provider = m.invoke(cr, args); diff --git a/app/src/main/java/com/aoleyun/sn/utils/ApkUtils.java b/app/src/main/java/com/aoleyun/sn/utils/ApkUtils.java index 2aec203..9933b35 100644 --- a/app/src/main/java/com/aoleyun/sn/utils/ApkUtils.java +++ b/app/src/main/java/com/aoleyun/sn/utils/ApkUtils.java @@ -548,6 +548,38 @@ public class ApkUtils { this.add("com.jxw.xdfzq"); }}; + public static final Set JxwApp2026 = new HashSet() {{ + this.add("com.jxw.aixhb"); + this.add("com.jxw.bdc"); + this.add("com.jxw.dcttl"); + this.add("com.jxw.download"); + this.add("com.jxw.flch"); + this.add("com.jxw.hzdcg"); + this.add("com.jxw.hzjc"); + this.add("com.jxw.jpkc"); + this.add("com.jxw.kcb"); + this.add("com.jxw.ksdcg"); + this.add("com.jxw.lccj"); + this.add("com.jxw.mathgame"); + this.add("com.jxw.share"); + this.add("com.jxw.music"); + this.add("com.jxw.qjdh"); + this.add("com.jxw.qkxx"); + this.add("com.jxw.qwpy"); + this.add("com.jxwgb.qxpy"); + this.add("com.jxw.instruction"); + this.add("com.jxw.sjzx"); + this.add("com.jxw.tbfd"); + this.add("com.jxw.tbgs"); + this.add("com.jxw.txrw"); + this.add("com.jxw.yszqb"); + this.add("com.jxw.zcdtz"); + this.add("com.jxw.zhbd"); + this.add("com.jxwgb.zhtsg"); + this.add("com.jxw.maidain"); + }}; + + public static final Set G11Pkgs = new HashSet() {{ /*G11 平台*/ this.add("com.lhcx.drawing"); @@ -1765,6 +1797,7 @@ public class ApkUtils { && !dongwa.contains(packageName) && !yixuepaiApp.contains(packageName) && !mJxwApp.contains(packageName) + && !JxwApp2026.contains(packageName) && !G30_APP.contains(packageName) && !DX11App.contains(packageName) && !MX11App.contains(packageName) @@ -1808,20 +1841,40 @@ public class ApkUtils { } public static void RemoveTask(final Context context, final String packageName) { - if (TextUtils.isEmpty(packageName)) { + if (context == null || TextUtils.isEmpty(packageName)) { return; } Observable.create(new ObservableOnSubscribe() { @Override public void subscribe(ObservableEmitter e) throws Exception { List list = Aria.download(context).getTaskList(); - for (DownloadEntity entity : list) { - long id = entity.getId(); - String extendField = Aria.download(this).load(id).getExtendField(); - JsonObject jsonObject = GsonUtils.getJsonObject(extendField); - if (packageName.equals(jsonObject.get("app_package").getAsString())) { - Log.e("RemoveTask", "subscribe: " + "删除文件:" + entity.getFilePath()); - Aria.download(this).load(id).cancel(true); + if (list != null && !list.isEmpty()) { + for (DownloadEntity entity : list) { + if (entity == null) { + continue; + } + long id = entity.getId(); + String extendField = null; + if (Aria.download(context).load(id) != null) { + extendField = Aria.download(context).load(id).getExtendField(); + } + if (TextUtils.isEmpty(extendField)) { + continue; + } + try { + JsonObject jsonObject = GsonUtils.getJsonObject(extendField); + if (jsonObject != null && jsonObject.has("app_package") && !jsonObject.get("app_package").isJsonNull()) { + String appPackage = jsonObject.get("app_package").getAsString(); + if (packageName.equals(appPackage)) { + Log.e("RemoveTask", "subscribe: " + "删除文件:" + entity.getFilePath()); + if (Aria.download(context).load(id) != null) { + Aria.download(context).load(id).cancel(true); + } + } + } + } catch (Exception ex) { + Log.e("RemoveTask", "parse extendField error: " + ex.getMessage()); + } } } e.onComplete(); diff --git a/app/src/main/java/com/aoleyun/sn/utils/JgyUtils.java b/app/src/main/java/com/aoleyun/sn/utils/JgyUtils.java index 043e5ff..8c0bf23 100644 --- a/app/src/main/java/com/aoleyun/sn/utils/JgyUtils.java +++ b/app/src/main/java/com/aoleyun/sn/utils/JgyUtils.java @@ -865,6 +865,7 @@ public class JgyUtils { this.add("com.aoleyun.calculator"); this.add("com.aoleyun.gallery3d"); this.addAll(ApkUtils.mJxwApp); + this.addAll(ApkUtils.JxwApp2026); this.addAll(ApkUtils.desktopAPP); this.add("com.android.settings"); this.add("com.aoleyunos.dop"); @@ -1582,6 +1583,9 @@ public class JgyUtils { pkgSet.addAll(ApkUtils.desktopAPP); pkgSet.addAll(ApkUtils.aoleyunAPP); pkgSet.addAll(ApkUtils.mJxwApp); + + pkgSet.addAll(ApkUtils.JxwApp2026); + if (G128T_TAG.equals(BuildConfig.platform)) { pkgSet.add("com.dmjc.xinhuo"); } @@ -1956,6 +1960,9 @@ public class JgyUtils { if (ApkUtils.mJxwApp.contains(packageName)) { continue; } + if (ApkUtils.JxwApp2026.contains(packageName)) { + continue; + } if (JgyUtils.DX11_TAG.equals(Build.MODEL)) { if (ApkUtils.DX11App.contains(packageName)) { continue; @@ -2072,6 +2079,10 @@ public class JgyUtils { public void hideApp(String pkg) { Log.e(TAG, "hideApp: " + pkg); + if (BuildConfig.APPLICATION_ID.equals(pkg)) { + Log.e(TAG, "hideApp: " + "not hide self"); + return; + } PackageManager pm = mContext.getPackageManager(); try { pm.setApplicationEnabledSetting(pkg, PackageManager.COMPONENT_ENABLED_STATE_DISABLED, 0); @@ -2269,7 +2280,7 @@ public class JgyUtils { public void setDeveloperOptions(int state) { Log.e(TAG, "setDeveloperOptions: state = " + state); - int oldStatu = Settings.System.getInt(crv, CommonConfig.AOLE_ACTION_DEVELOPER_OPTIONS, 0); + int oldStatu = Settings.System.getInt(crv, CommonConfig.AOLE_ACTION_DEVELOPER_OPTIONS, 1); if (oldStatu == (state ^ 1)) { Log.e(TAG, "setDeveloperOptions: oldStatu = " + oldStatu + " no changed"); } @@ -2277,7 +2288,12 @@ public class JgyUtils { if (MT8768Tag.equalsIgnoreCase(BuildConfig.platform) || G128T_TAG.equalsIgnoreCase(BuildConfig.platform) ) { - AndroidSettingsWriter.putInt(mContext, AndroidSettingsWriter.NAMESPACE_SYSTEM, CommonConfig.AOLE_ACTION_DEVELOPER_OPTIONS, state); + // TODO: 2026/11/3 Ebox201w型号单独区分 + if ("Ebox201w".equals(Build.MODEL)) { + AndroidSettingsWriter.putInt(mContext, AndroidSettingsWriter.NAMESPACE_SYSTEM, CommonConfig.AOLE_ACTION_DEVELOPER_OPTIONS, state ^ 1); + } else { + AndroidSettingsWriter.putInt(mContext, AndroidSettingsWriter.NAMESPACE_SYSTEM, CommonConfig.AOLE_ACTION_DEVELOPER_OPTIONS, state); + } } else { //这个需要反着来 AndroidSettingsWriter.putInt(mContext, AndroidSettingsWriter.NAMESPACE_SYSTEM, CommonConfig.AOLE_ACTION_DEVELOPER_OPTIONS, state ^ 1); @@ -3514,7 +3530,7 @@ public class JgyUtils { String apkPath = aolePath + File.separator + fileName; Log.e(TAG, "subscribe: " + apkPath); String pkg = ApkUtils.getPackageName(mContext, apkPath); - if (ApkUtils.mJxwApp.contains(pkg)) { + if (ApkUtils.mJxwApp.contains(pkg) || ApkUtils.JxwApp2026.contains(pkg)) { packageListMap.put(pkg, apkPath); } else { Log.e(TAG, "checkLocalAppInstall: skip: " + pkg + " fileName: " + fileName); @@ -3785,6 +3801,9 @@ public class JgyUtils { if (ApkUtils.mJxwApp.contains(pkg)) { return true; } + if (ApkUtils.JxwApp2026.contains(pkg)) { + return true; + } if (mLessonJson == null) return true; if (mLessonJson.getIs_lesson() == 1) { @@ -3960,22 +3979,60 @@ public class JgyUtils { } public String getInputMethComponentName(String pkg) { + if (TextUtils.isEmpty(pkg)) { + return ""; + } InputMethodManager imeManager = (InputMethodManager) mContext.getSystemService(Context.INPUT_METHOD_SERVICE); + if (imeManager == null) { + return ""; + } List InputMethods = imeManager.getInputMethodList(); Optional inputMethodInfoOptional = InputMethods.stream().filter(new Predicate() { @Override public boolean test(InputMethodInfo inputMethodInfo) { return pkg.equals(inputMethodInfo.getPackageName()); } - }).findAny(); + }).findFirst(); if (inputMethodInfoOptional.isPresent()) { InputMethodInfo inputMethodInfo = inputMethodInfoOptional.get(); - return inputMethodInfo.getComponent().toString(); + return inputMethodInfo.getComponent().flattenToShortString(); } else { + Log.e(TAG, "getInputMethComponentName: no IME found for " + pkg); return ""; } } + /** + * @param imePkg secure default_input_method + */ + public void sendInputBroadcast(String imePkg) { + Intent intent = new Intent("setDefaultInputMethod"); + if (TextUtils.isEmpty(imePkg)) { + if (JgyUtils.getInstance().checkAppPlatform() == JgyUtils.QualcommPlatform) { + intent.putExtra("package", "com.onyx.kime"); + intent.setPackage("com.onyx.neoservice"); + } else if (JgyUtils.getInstance().checkAppPlatform() == JgyUtils.TDT65Platform || "TDT65".equals(Build.MODEL)) { + intent.putExtra("package", JgyUtils.getInstance().getInputMethComponentName("com.google.android.inputmethod.latin")); + intent.setPackage("com.android.settings"); + } else { + intent.putExtra("package", "com.android.inputmethod.latin"); + intent.setPackage("com.android.settings"); + } + } else { + if (JgyUtils.getInstance().checkAppPlatform() == JgyUtils.QualcommPlatform) { + intent.putExtra("package", imePkg); + intent.setPackage("com.onyx.neoservice"); + } else if (JgyUtils.getInstance().checkAppPlatform() == JgyUtils.TDT65Platform || "TDT65".equals(Build.MODEL)) { + intent.putExtra("package", JgyUtils.getInstance().getInputMethComponentName(imePkg)); + intent.setPackage("com.android.settings"); + } else { + intent.putExtra("package", imePkg); + intent.setPackage("com.android.settings"); + } + } + mContext.sendBroadcast(intent); + } + public String getDefaultIme() { return mMMKV.decodeString(CommonConfig.DEFAULT_IME_PACKAGE_NAME_KEY, ""); } @@ -4219,5 +4276,4 @@ public class JgyUtils { } } - } diff --git a/app/src/main/java/com/aoleyun/sn/utils/SysSettingUtils.java b/app/src/main/java/com/aoleyun/sn/utils/SysSettingUtils.java index e5b745d..a662ab3 100644 --- a/app/src/main/java/com/aoleyun/sn/utils/SysSettingUtils.java +++ b/app/src/main/java/com/aoleyun/sn/utils/SysSettingUtils.java @@ -400,6 +400,8 @@ public class SysSettingUtils { if (JgyUtils.getInstance().checkAppPlatform() == JgyUtils.TeclastP20sPlatform || JgyUtils.getInstance().checkAppPlatform() == JgyUtils.AH6016Platform || JgyUtils.getInstance().checkAppPlatform() == JgyUtils.DX11Platform + || JgyUtils.getInstance().checkAppPlatform() == JgyUtils.TDT65Platform + || "AOSP".equals(BuildConfig.platform) ) { usbIntent.setPackage("com.android.settings"); } @@ -641,7 +643,11 @@ public class SysSettingUtils { default: } Intent navIntent = new Intent(navigationStatus); -// Intent navIntent = new Intent(navigationStatus).setPackage("com.android.systemui"); + if (JgyUtils.getInstance().checkAppPlatform() == JgyUtils.TDT65Platform + || "AOSP".equals(BuildConfig.platform) + ) { + navIntent.setPackage("com.android.systemui"); + } if (JgyUtils.getInstance().checkAppPlatform() == JgyUtils.QualcommPlatform) { navIntent.setPackage("com.onyx"); } @@ -666,7 +672,11 @@ public class SysSettingUtils { default: } Intent statusIntent = new Intent(statusbarStatus); -// Intent statusIntent = new Intent(statusbarStatus).setPackage("com.android.systemui"); + if (JgyUtils.getInstance().checkAppPlatform() == JgyUtils.TDT65Platform + || "AOSP".equals(BuildConfig.platform) + ) { + statusIntent.setPackage("com.android.systemui"); + } context.sendBroadcast(statusIntent); } } @@ -689,8 +699,13 @@ public class SysSettingUtils { break; default: } -// Intent navIntent = new Intent(navigationStatus).setPackage("com.android.systemui"); Intent navIntent = new Intent(navigationStatus); + if (JgyUtils.getInstance().checkAppPlatform() == JgyUtils.TDT65Platform + || "AOSP".equals(BuildConfig.platform) + ) { + navIntent.setPackage("com.android.systemui"); + } + if (JgyUtils.getInstance().checkAppPlatform() == JgyUtils.QualcommPlatform) { navIntent.setPackage("com.onyx"); } @@ -720,7 +735,11 @@ public class SysSettingUtils { default: } Intent statusIntent = new Intent(statusbarStatus); -// Intent statusIntent = new Intent(statusbarStatus).setPackage("com.android.systemui"); + if (JgyUtils.getInstance().checkAppPlatform() == JgyUtils.TDT65Platform + || "AOSP".equals(BuildConfig.platform) + ) { + statusIntent.setPackage("com.android.systemui"); + } context.sendBroadcast(statusIntent); // } @@ -1263,7 +1282,11 @@ public class SysSettingUtils { default: } Intent statusIntent = new Intent(statusbarStatus); -// Intent statusIntent = new Intent(statusbarStatus).setPackage("com.android.systemui"); + if (JgyUtils.getInstance().checkAppPlatform() == JgyUtils.TDT65Platform + || "AOSP".equals(BuildConfig.platform) + ) { + statusIntent.setPackage("com.android.systemui"); + } context.sendBroadcast(statusIntent); } } @@ -1284,7 +1307,11 @@ public class SysSettingUtils { default: } Intent navIntent = new Intent(navigationStatus); -// Intent navIntent = new Intent(navigationStatus).setPackage("com.android.systemui"); + if (JgyUtils.getInstance().checkAppPlatform() == JgyUtils.TDT65Platform + || "AOSP".equals(BuildConfig.platform) + ) { + navIntent.setPackage("com.android.systemui"); + } context.sendBroadcast(navIntent); } @@ -1495,7 +1522,7 @@ public class SysSettingUtils { if (app_management_control == 0) { // menus.add("apps_management"); // menus.add("apps_honor_tips"); - menus.add("apps"); +// menus.add("apps"); } // 儿童 (默认禁止) diff --git a/app/src/main/java/com/aoleyun/sn/utils/Utils.java b/app/src/main/java/com/aoleyun/sn/utils/Utils.java index e3fcc00..14358db 100644 --- a/app/src/main/java/com/aoleyun/sn/utils/Utils.java +++ b/app/src/main/java/com/aoleyun/sn/utils/Utils.java @@ -789,6 +789,9 @@ public class Utils { if (JgyUtils.getInstance().checkAppPlatform() == JgyUtils.HL500Platform) { return getIMEI(context); } + if (JgyUtils.getInstance().checkAppPlatform() == JgyUtils.TDT65Platform || "TDT65".equals(Build.MODEL)) { + return getSn(); + } if (TECLAST_BRAND.equalsIgnoreCase(Build.BRAND)) { return getPushMac(context); } else { @@ -801,7 +804,7 @@ public class Utils { } public static String getPushMac(Context context) { - String macaddr = Utils.getMacAddrFromNvram(); + String macaddr = getAndroid10MAC(context); return macaddr.replace(":", "").toUpperCase().trim(); } @@ -1256,14 +1259,14 @@ public class Utils { public static void shotScreen(final Context context) { //adb截图方法 Observable.create(new ObservableOnSubscribe() { - @Override - public void subscribe(ObservableEmitter e) throws Exception { - String filepath = context.getCacheDir().getAbsolutePath(); - long time = System.currentTimeMillis(); - int n = CmdUtil.execute("screencap -p " + filepath + File.separator + time + ".db").code; - e.onNext(n); - } - }).subscribeOn(Schedulers.io()) + @Override + public void subscribe(ObservableEmitter e) throws Exception { + String filepath = context.getCacheDir().getAbsolutePath(); + long time = System.currentTimeMillis(); + int n = CmdUtil.execute("screencap -p " + filepath + File.separator + time + ".db").code; + e.onNext(n); + } + }).subscribeOn(Schedulers.io()) .observeOn(AndroidSchedulers.mainThread()) .subscribe(new Observer() { @Override