feat(platform): 优化设备适配与抖动检测逻辑
- 新增DX11平台强制安装应用白名单 - 优化加速度传感器选择策略,优先使用TYPE_ACCELEROMETER - 分离普通加速度计与线性加速度计检测算法,调整方差阈值参数 - 增加默认输入法和默认浏览器设置广播 - 扩展USB广播兼容DX11平台 - 移除已废弃的ActivityController和重复代码 - 统一强制安装应用设置逻辑
This commit is contained in:
@@ -18,8 +18,8 @@ android {
|
||||
|
||||
defaultConfig {
|
||||
applicationId "com.aoleyun.sn"
|
||||
versionCode 229
|
||||
versionName "1.6.0711"
|
||||
versionCode 233
|
||||
versionName "1.6.0805"
|
||||
|
||||
//There are no CERT files because If the mini sdk version is 23+, the AGP will ignore the V1 scheme signature.
|
||||
minSdkVersion 24
|
||||
@@ -286,9 +286,32 @@ android {
|
||||
v1SigningEnabled true
|
||||
v2SigningEnabled true
|
||||
}
|
||||
|
||||
DX11 {
|
||||
storeFile file("keystore/DX11.p12")
|
||||
storePassword "123456"
|
||||
keyAlias "dx11"
|
||||
keyPassword "123456"
|
||||
v1SigningEnabled true
|
||||
v2SigningEnabled true
|
||||
}
|
||||
}
|
||||
|
||||
buildTypes {
|
||||
DX11Debug.initWith(debug)
|
||||
DX11Debug {
|
||||
buildConfigField "String", "platform", '"DX11"'
|
||||
versionNameSuffix "-debug"
|
||||
debuggable true
|
||||
signingConfig signingConfigs.DX11
|
||||
}
|
||||
|
||||
DX11Release.initWith(release)
|
||||
DX11Release {
|
||||
buildConfigField "String", "platform", '"DX11"'
|
||||
signingConfig signingConfigs.DX11
|
||||
}
|
||||
|
||||
G122Debug.initWith(debug)
|
||||
G122Debug {
|
||||
buildConfigField "String", "platform", '"MT6765"'
|
||||
|
||||
BIN
app/keystore/DX11.p12
Normal file
BIN
app/keystore/DX11.p12
Normal file
Binary file not shown.
@@ -11,6 +11,7 @@ import android.util.Log;
|
||||
import java.util.ArrayList;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
import java.util.Queue;
|
||||
|
||||
/**
|
||||
@@ -26,22 +27,31 @@ public class ShakeDetectionManager implements SensorEventListener {
|
||||
|
||||
// --- 方案一:步数检测相关参数 ---
|
||||
private final List<Long> stepTimestamps = new ArrayList<>();
|
||||
// 判定为“正在走路”的阈值:5秒内走了 4 步以上
|
||||
// 判定为“正在走路”的阈值:5秒内走了 6 步以上
|
||||
private static final long STEP_TIME_WINDOW = 5000;
|
||||
private static final int STEP_THRESHOLD = 4;
|
||||
private static final int STEP_THRESHOLD = 6;
|
||||
|
||||
// --- 方案二:加速度方差相关参数 ---
|
||||
private final Queue<Float> magnitudeWindow = new LinkedList<>();
|
||||
// --- 方案二:普通加速度计(TYPE_ACCELEROMETER)使用方差算法 ---
|
||||
private final Queue<Float> accelWindow = new LinkedList<>();
|
||||
// 采样窗口大小:约 1 秒(SENSOR_DELAY_UI 约 60Hz)
|
||||
private static final int ACCEL_WINDOW_SIZE = 60;
|
||||
// 加速度方差阈值:用于判定持续抖动。方差能有效过滤静态重力偏移。
|
||||
private static final float ACCEL_VARIANCE_THRESHOLD = 0.3f;
|
||||
|
||||
// --- 方案三:线性加速度计(TYPE_LINEAR_ACCELERATION)使用方差算法(原始逻辑)---
|
||||
private final Queue<Float> linearWindow = new LinkedList<>();
|
||||
// 采样窗口大小:1.5 秒大约需要 25 个样本
|
||||
private static final int VARIANCE_WINDOW_SIZE = 25;
|
||||
// 提高方差阈值:正常的拿起放下抖动通常在 1.0~1.8 之间,我们将阈值提高到 2.0
|
||||
private static final float VARIANCE_THRESHOLD = 2.0f;
|
||||
// 增加评估频率控制:每 400ms 评估一次方差
|
||||
private static final int LINEAR_WINDOW_SIZE = 25;
|
||||
// 方差阈值:正常的拿起放下抖动通常在 1.0~1.8 之间,我们将阈值提高到 3.5 以减少误判
|
||||
private static final float LINEAR_VARIANCE_THRESHOLD = 3.5f;
|
||||
|
||||
// --- 公共评估参数 ---
|
||||
// 增加评估频率控制:每 400ms 评估一次窗口
|
||||
private long lastVarianceEvalTime = 0;
|
||||
private static final long VARIANCE_EVAL_INTERVAL = 400;
|
||||
// 持续检测到抖动的评估次数:连续 4 次评估达标才判定(400ms * 4 = 1.6秒的持续抖动)
|
||||
// 持续检测到抖动的评估次数:连续 5 次评估达标才判定(400ms * 5 = 2.0秒的持续抖动)
|
||||
private int consecutiveShakeCount = 0;
|
||||
private static final int CONSECUTIVE_THRESHOLD = 4;
|
||||
private static final int CONSECUTIVE_THRESHOLD = 5;
|
||||
|
||||
public interface OnShakeListener {
|
||||
/**
|
||||
@@ -91,12 +101,24 @@ public class ShakeDetectionManager implements SensorEventListener {
|
||||
public void start() {
|
||||
if (sensorManager == null) return;
|
||||
|
||||
// 优先使用步数检测
|
||||
// 优先使用步数检测(最精准、最省电,且不依赖设备是否晃动)
|
||||
if (stepSensor != null) {
|
||||
Log.i(TAG, "启动检测:优先模式 [步数检测器]");
|
||||
sensorManager.registerListener(this, stepSensor, SensorManager.SENSOR_DELAY_NORMAL);
|
||||
} else if (accelSensor != null) {
|
||||
Log.i(TAG, "启动检测:回退模式 [加速度方差算法]");
|
||||
}
|
||||
|
||||
// 加速度传感器作为抖动检测的补充:无论如何都要注册一个可靠的加速度源。
|
||||
// 注意:TYPE_LINEAR_ACCELERATION 在设备静止时返回近似 0(已扣除重力),
|
||||
// 某些设备上甚至始终返回 0 导致无法检测抖动,因此优先使用普通加速度计,
|
||||
// 仅在普通加速度计不可用时才回退到线性加速度计。
|
||||
Sensor reliableAccel = sensorManager.getDefaultSensor(Sensor.TYPE_ACCELEROMETER);
|
||||
if (reliableAccel == null) {
|
||||
reliableAccel = accelSensor; // 退回之前已探测到的线性加速度计
|
||||
}
|
||||
if (reliableAccel != null) {
|
||||
accelSensor = reliableAccel;
|
||||
Log.i(TAG, "启动检测:加速度补充模式 [" + accelSensor.getName()
|
||||
+ ", type=" + accelSensor.getType() + "]");
|
||||
sensorManager.registerListener(this, accelSensor, SensorManager.SENSOR_DELAY_UI);
|
||||
}
|
||||
}
|
||||
@@ -107,17 +129,19 @@ public class ShakeDetectionManager implements SensorEventListener {
|
||||
sensorManager.unregisterListener(this);
|
||||
}
|
||||
stepTimestamps.clear();
|
||||
magnitudeWindow.clear();
|
||||
accelWindow.clear();
|
||||
linearWindow.clear();
|
||||
consecutiveShakeCount = 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onSensorChanged(SensorEvent event) {
|
||||
int sensorType = event.sensor.getType();
|
||||
|
||||
Log.e(TAG, "onSensorChanged: sensorType = " + sensorType + ", values=" + event.values[0] + "," + event.values[1] + "," + event.values[2]);
|
||||
if (sensorType == Sensor.TYPE_STEP_DETECTOR) {
|
||||
handleStepDetection();
|
||||
} else if (sensorType == Sensor.TYPE_LINEAR_ACCELERATION || sensorType == Sensor.TYPE_ACCELEROMETER) {
|
||||
} else if (sensorType == Sensor.TYPE_LINEAR_ACCELERATION
|
||||
|| sensorType == Sensor.TYPE_ACCELEROMETER) {
|
||||
handleAccelDetection(event);
|
||||
}
|
||||
}
|
||||
@@ -154,45 +178,101 @@ public class ShakeDetectionManager implements SensorEventListener {
|
||||
}
|
||||
|
||||
/**
|
||||
* 方案二:基于加速度方差的算法
|
||||
* 方案二/三入口:按传感器类型分发到各自的检测算法
|
||||
*/
|
||||
private void handleAccelDetection(SensorEvent event) {
|
||||
// Log.d(TAG, "handleAccelDetection: type=" + event.sensor.getType()
|
||||
// + ", " + event.values[0] + "," + event.values[1] + "," + event.values[2]);
|
||||
int sensorType = event.sensor.getType();
|
||||
if (sensorType == Sensor.TYPE_ACCELEROMETER) {
|
||||
// 普通加速度计:含重力,用"峰值占比"算法(去重力后判定活跃抖动)
|
||||
handleAccelerometerDetection(event);
|
||||
} else if (sensorType == Sensor.TYPE_LINEAR_ACCELERATION) {
|
||||
// 线性加速度计:已扣除重力,沿用原始"方差"算法
|
||||
handleLinearAccelDetection(event);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 方案二:普通加速度计(TYPE_ACCELEROMETER)使用方差算法
|
||||
* 相比于减去固定的 9.8,计算方差对重力偏移(不同设备、不同角度)更具鲁棒性。
|
||||
*/
|
||||
private void handleAccelerometerDetection(SensorEvent event) {
|
||||
float x = event.values[0];
|
||||
float y = event.values[1];
|
||||
float z = event.values[2];
|
||||
|
||||
// 计算合加速度模长
|
||||
float magnitude;
|
||||
if (event.sensor.getType() == Sensor.TYPE_LINEAR_ACCELERATION) {
|
||||
magnitude = (float) Math.sqrt(x * x + y * y + z * z);
|
||||
} else {
|
||||
// 普通加速度计减去重力近似值
|
||||
magnitude = (float) Math.abs(Math.sqrt(x * x + y * y + z * z) - 9.8);
|
||||
// 计算合加速度模长(包含重力)
|
||||
float magnitude = (float) Math.sqrt(x * x + y * y + z * z);
|
||||
|
||||
accelWindow.add(magnitude);
|
||||
if (accelWindow.size() > ACCEL_WINDOW_SIZE) {
|
||||
accelWindow.poll();
|
||||
}
|
||||
|
||||
magnitudeWindow.add(magnitude);
|
||||
if (magnitudeWindow.size() > VARIANCE_WINDOW_SIZE) {
|
||||
magnitudeWindow.poll();
|
||||
}
|
||||
|
||||
// 窗口填满后按固定频率计算方差
|
||||
// 窗口填满后按固定频率评估方差
|
||||
long currentTime = System.currentTimeMillis();
|
||||
if (magnitudeWindow.size() == VARIANCE_WINDOW_SIZE && (currentTime - lastVarianceEvalTime > VARIANCE_EVAL_INTERVAL)) {
|
||||
if (accelWindow.size() == ACCEL_WINDOW_SIZE && (currentTime - lastVarianceEvalTime > VARIANCE_EVAL_INTERVAL)) {
|
||||
lastVarianceEvalTime = currentTime;
|
||||
double variance = calculateVariance(magnitudeWindow);
|
||||
|
||||
if (variance > VARIANCE_THRESHOLD) {
|
||||
double variance = calculateVariance(accelWindow);
|
||||
Log.e(TAG, "handleAccelerometerDetection: variance = " + variance);
|
||||
if (variance > ACCEL_VARIANCE_THRESHOLD) {
|
||||
consecutiveShakeCount++;
|
||||
String info = String.format("抖动方差: %.2f, 连续计数: %d", variance, consecutiveShakeCount);
|
||||
Log.d(TAG, info);
|
||||
String info = String.format(Locale.US, "加速方差: %.2f, 连续计数: %d",
|
||||
variance, consecutiveShakeCount);
|
||||
Log.e(TAG, info);
|
||||
if (listener != null) {
|
||||
listener.onStatusUpdate(info);
|
||||
}
|
||||
if (consecutiveShakeCount >= CONSECUTIVE_THRESHOLD) {
|
||||
Log.w(TAG, "检测到用户正在走路 (加速度方差模式)");
|
||||
Log.w(TAG, "检测到用户正在走路 (加速度模式)");
|
||||
triggerCallback();
|
||||
consecutiveShakeCount = 0;
|
||||
magnitudeWindow.clear();
|
||||
accelWindow.clear();
|
||||
}
|
||||
} else {
|
||||
// 没达到阈值时,清空计数
|
||||
consecutiveShakeCount = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 方案三:线性加速度计(TYPE_LINEAR_ACCELERATION)使用方差算法(原始逻辑)
|
||||
* 传感器已扣除重力,输出即净加速度,直接对模长计算方差来判定抖动。
|
||||
*/
|
||||
private void handleLinearAccelDetection(SensorEvent event) {
|
||||
float x = event.values[0];
|
||||
float y = event.values[1];
|
||||
float z = event.values[2];
|
||||
|
||||
// 线性加速度计已扣除重力,直接使用合加速度模长
|
||||
float magnitude = (float) Math.sqrt(x * x + y * y + z * z);
|
||||
|
||||
linearWindow.add(magnitude);
|
||||
if (linearWindow.size() > LINEAR_WINDOW_SIZE) {
|
||||
linearWindow.poll();
|
||||
}
|
||||
|
||||
// 窗口填满后按固定频率计算方差
|
||||
long currentTime = System.currentTimeMillis();
|
||||
if (linearWindow.size() == LINEAR_WINDOW_SIZE && (currentTime - lastVarianceEvalTime > VARIANCE_EVAL_INTERVAL)) {
|
||||
lastVarianceEvalTime = currentTime;
|
||||
double variance = calculateVariance(linearWindow);
|
||||
|
||||
if (variance > LINEAR_VARIANCE_THRESHOLD) {
|
||||
consecutiveShakeCount++;
|
||||
String info = String.format(Locale.US, "抖动方差: %.2f, 连续计数: %d", variance, consecutiveShakeCount);
|
||||
Log.e(TAG, info);
|
||||
if (listener != null) {
|
||||
listener.onStatusUpdate(info);
|
||||
}
|
||||
if (consecutiveShakeCount >= CONSECUTIVE_THRESHOLD) {
|
||||
Log.w(TAG, "检测到用户正在走路 (线性加速度方差模式)");
|
||||
triggerCallback();
|
||||
consecutiveShakeCount = 0;
|
||||
linearWindow.clear();
|
||||
}
|
||||
} else {
|
||||
// 没达到阈值时,清空计数,要求必须是连续的抖动
|
||||
|
||||
@@ -1787,6 +1787,10 @@ public class NetInterfaceManager {
|
||||
if (!TextUtils.isEmpty(default_IME)) {
|
||||
mMMKV.encode(CommonConfig.DEFAULT_IME_PACKAGE_NAME_KEY, default_IME);
|
||||
if (JgyUtils.isAllWinnerDevice()) {
|
||||
Intent intent = new Intent("setDefaultInputMethod");
|
||||
intent.putExtra("package", "com.android.inputmethod.latin");
|
||||
intent.setPackage("com.android.settings");
|
||||
mContext.sendBroadcast(intent);
|
||||
JgyUtils.getInstance().setAllwinnerDefaulInputMeth(default_IME);
|
||||
} else {
|
||||
Intent intent = new Intent("setDefaultInputMethod");
|
||||
@@ -2937,14 +2941,12 @@ public class NetInterfaceManager {
|
||||
Aria.download(this).resumeAllTask();
|
||||
JgyUtils.getInstance().forceDownload(forceDownloadBean);
|
||||
List<String> forceApp = forceDownloadBean.stream().map(ForceDownloadData::getApp_package).collect(Collectors.toList());
|
||||
boolean aole_force_app = Settings.System.putString(mContext.getContentResolver(), CommonConfig.AOLE_ACTION_FORCE_APP, String.join(",", forceApp));
|
||||
Log.e("getForceDownload", "aole_force_app:" + aole_force_app);
|
||||
setForceInstall(forceApp);
|
||||
if (JgyUtils.isAllWinnerDevice()) {
|
||||
AllwinnerCubeMdmManager.getInstance().setForbidUnInstallPackageList(forceApp);
|
||||
}
|
||||
} else {
|
||||
boolean aole_force_app = Settings.System.putString(mContext.getContentResolver(), CommonConfig.AOLE_ACTION_FORCE_APP, "invalid");
|
||||
Log.e("getForceDownload", "aole_force_app:" + aole_force_app);
|
||||
setForceInstall(null);
|
||||
if (JgyUtils.isAllWinnerDevice()) {
|
||||
AllwinnerCubeMdmManager.getInstance().setForbidUnInstallPackageList(new ArrayList<>());
|
||||
}
|
||||
@@ -2969,52 +2971,19 @@ public class NetInterfaceManager {
|
||||
};
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
private Observer<BaseResponse<List<ForceDownloadData>>> getForceDownloadObserver(onCompleteCallback callback) {
|
||||
return new Observer<BaseResponse<List<ForceDownloadData>>>() {
|
||||
@Override
|
||||
public void onSubscribe(@NonNull Disposable d) {
|
||||
Log.e("getForceDownload", "onSubscribe: ");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNext(@NonNull BaseResponse<List<ForceDownloadData>> forceDownloadBean) {
|
||||
Log.e("getForceDownload", "onNext: " + forceDownloadBean);
|
||||
if (forceDownloadBean.isSuccess()) {
|
||||
List<ForceDownloadData> forceDownloadData = forceDownloadBean.data;
|
||||
Aria.download(this).resumeAllTask();
|
||||
JgyUtils.getInstance().forceDownload(forceDownloadData);
|
||||
List<String> forceApp = forceDownloadData.stream().map(ForceDownloadData::getApp_package).collect(Collectors.toList());
|
||||
Settings.System.putString(mContext.getContentResolver(), CommonConfig.AOLE_ACTION_FORCE_APP, String.join(",", forceApp));
|
||||
if (JgyUtils.isAllWinnerDevice()) {
|
||||
AllwinnerCubeMdmManager.getInstance().setForbidUnInstallPackageList(forceApp);
|
||||
}
|
||||
} else if (forceDownloadBean.code == -200) {
|
||||
Settings.System.putString(mContext.getContentResolver(), CommonConfig.AOLE_ACTION_FORCE_APP, "invalid");
|
||||
if (JgyUtils.isAllWinnerDevice()) {
|
||||
AllwinnerCubeMdmManager.getInstance().setForbidUnInstallPackageList(new ArrayList<>());
|
||||
}
|
||||
} else {
|
||||
Log.e("getForceDownload", forceDownloadBean.msg);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(@NonNull Throwable e) {
|
||||
Log.e("getForceDownload", "onError: " + e.getMessage());
|
||||
onComplete();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onComplete() {
|
||||
Log.e("getForceDownload", "onComplete: ");
|
||||
if (callback != null) {
|
||||
callback.onComplete();
|
||||
}
|
||||
}
|
||||
};
|
||||
private void setForceInstall(List<String> forceApp) {
|
||||
Set<String> forceAppSet = new HashSet<>();
|
||||
if (JgyUtils.getInstance().checkAppPlatform() == JgyUtils.DX11Platform) {
|
||||
forceAppSet.addAll(ApkUtils.DX11App);
|
||||
}
|
||||
if (forceApp != null) {
|
||||
forceAppSet.addAll(forceApp);
|
||||
}
|
||||
boolean aole_force_app = Settings.System.putString(mContext.getContentResolver(), CommonConfig.AOLE_ACTION_FORCE_APP, String.join(",", forceAppSet));
|
||||
Log.e("getForceDownload", "aole_force_app:" + aole_force_app);
|
||||
}
|
||||
|
||||
|
||||
private Observable<List<String>> getAllAppObservable() {
|
||||
return Observable.zip(getAppLimitObservable(), getAdminAppObservable(), getRankCommonAppObservable(), getGroupForceDownloadObservable(), getBiFunction())
|
||||
.subscribeOn(Schedulers.io())
|
||||
|
||||
@@ -1053,13 +1053,13 @@ public class PushManager {
|
||||
|
||||
public void doscreenshot(final long time) {
|
||||
Observable.create(new ObservableOnSubscribe<Integer>() {
|
||||
@Override
|
||||
public void subscribe(ObservableEmitter<Integer> e) throws Exception {
|
||||
String filepath = mContext.getExternalFilesDir("db").getAbsolutePath();
|
||||
int n = CmdUtil.execute("screencap -p " + filepath + File.separator + time + ".db").code;
|
||||
e.onNext(n);
|
||||
}
|
||||
}).subscribeOn(Schedulers.io())
|
||||
@Override
|
||||
public void subscribe(ObservableEmitter<Integer> e) throws Exception {
|
||||
String filepath = mContext.getExternalFilesDir("db").getAbsolutePath();
|
||||
int n = CmdUtil.execute("screencap -p " + filepath + File.separator + time + ".db").code;
|
||||
e.onNext(n);
|
||||
}
|
||||
}).subscribeOn(Schedulers.io())
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.subscribe(new Observer<Integer>() {
|
||||
@Override
|
||||
@@ -1210,6 +1210,25 @@ public class PushManager {
|
||||
mContext.startActivity(intent);
|
||||
|
||||
}
|
||||
JsonElement keyboardElement = jsonObject.get("default_IME");
|
||||
if (keyboardElement.isJsonNull() || TextUtils.isEmpty(keyboardElement.getAsString())) {
|
||||
Intent intent = new Intent("setDefaultInputMethod");
|
||||
intent.putExtra("package", "com.android.inputmethod.latin");
|
||||
intent.setPackage("com.android.settings");
|
||||
mContext.sendBroadcast(intent);
|
||||
} else {
|
||||
String default_IME = jsonObject.get("default_IME").getAsString();
|
||||
Intent intent = new Intent("setDefaultInputMethod");
|
||||
intent.putExtra("package", default_IME);
|
||||
intent.setPackage("com.android.settings");
|
||||
mContext.sendBroadcast(intent);
|
||||
}
|
||||
|
||||
String default_browser = jsonObject.get("default_browser").getAsString();
|
||||
Intent intent = new Intent("setDefaultBrowser");
|
||||
intent.putExtra("package", default_browser);
|
||||
intent.setPackage("com.android.settings");
|
||||
mContext.sendBroadcast(intent);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -802,7 +802,9 @@ public class GuardService extends Service {
|
||||
}
|
||||
}
|
||||
Intent usbIntent = new Intent(usbStatus);
|
||||
if (JgyUtils.getInstance().checkAppPlatform() == JgyUtils.TeclastP20sPlatform) {
|
||||
if (JgyUtils.getInstance().checkAppPlatform() == JgyUtils.TeclastP20sPlatform
|
||||
|| JgyUtils.getInstance().checkAppPlatform() == JgyUtils.DX11Platform
|
||||
) {
|
||||
usbIntent.setPackage("com.android.settings");
|
||||
}
|
||||
sendBroadcast(usbIntent);
|
||||
|
||||
@@ -1,9 +1,7 @@
|
||||
package com.aoleyun.sn.service.main;
|
||||
|
||||
import android.annotation.SuppressLint;
|
||||
import android.app.ActivityManagerNative;
|
||||
import android.app.AlarmManager;
|
||||
import android.app.IActivityManager;
|
||||
import android.app.NotificationChannel;
|
||||
import android.app.NotificationManager;
|
||||
import android.content.BroadcastReceiver;
|
||||
@@ -23,7 +21,6 @@ import android.os.Build;
|
||||
import android.os.Handler;
|
||||
import android.os.IBinder;
|
||||
import android.os.Looper;
|
||||
import android.os.RemoteException;
|
||||
import android.provider.Settings;
|
||||
import android.text.TextUtils;
|
||||
import android.util.DisplayMetrics;
|
||||
@@ -51,7 +48,6 @@ import com.aoleyun.sn.comm.JGYActions;
|
||||
import com.aoleyun.sn.comm.PackageNames;
|
||||
import com.aoleyun.sn.detection.SensorCheckUtil;
|
||||
import com.aoleyun.sn.gson.GsonUtils;
|
||||
import com.aoleyun.sn.hook.AoleyunActivityController;
|
||||
import com.aoleyun.sn.network.NetInterfaceManager;
|
||||
import com.aoleyun.sn.rlog.LogDBManager;
|
||||
import com.aoleyun.sn.service.DetectionService;
|
||||
@@ -460,13 +456,13 @@ public class MainService extends BaseService implements NetworkUtils.OnNetworkSt
|
||||
|
||||
// aliyunPushInit();
|
||||
|
||||
IActivityManager activityManager = ActivityManagerNative.getDefault();
|
||||
try {
|
||||
activityManager.setActivityController(new AoleyunActivityController(), false);
|
||||
} catch (RemoteException e) {
|
||||
Log.e(TAG, "setActivityController: " + e.getMessage());
|
||||
e.printStackTrace();
|
||||
}
|
||||
// IActivityManager activityManager = ActivityManagerNative.getDefault();
|
||||
// try {
|
||||
// activityManager.setActivityController(new AoleyunActivityController(), false);
|
||||
// } catch (RemoteException e) {
|
||||
// Log.e(TAG, "setActivityController: " + e.getMessage());
|
||||
// e.printStackTrace();
|
||||
// }
|
||||
|
||||
mMMKV.encode(CommonConfig.DEVICES_FRIST_START, 1);
|
||||
Observable.create(killSubscribe)
|
||||
|
||||
@@ -546,6 +546,17 @@ public class ApkUtils {
|
||||
this.add("com.android.stk");
|
||||
}};
|
||||
|
||||
public static final Set<String> DX11App = new HashSet<String>() {{
|
||||
this.add("com.eswi.launcher");
|
||||
this.add("com.eswi.errorscollection");
|
||||
this.add("com.eswi.homework");
|
||||
this.add("com.eswi.android.expand");
|
||||
this.add("com.eswi.learnpackage");
|
||||
this.add("com.example.abc_qq_app");
|
||||
this.add("com.yangcong345.onionschool");
|
||||
this.add("com.yangcong345.zhike");
|
||||
}};
|
||||
|
||||
public static void HideAiUDuApp() {
|
||||
Log.e(TAG, "HideAiUDuApp: ");
|
||||
MMKV mmkv = MMKV.mmkvWithID(CommonConfig.MMKV_ID, MMKV.MULTI_PROCESS_MODE);
|
||||
@@ -795,64 +806,64 @@ public class ApkUtils {
|
||||
|
||||
public static void installRx(final Context context, final String packageName, final String filePath) {
|
||||
Observable.create(new ObservableOnSubscribe<Integer>() {
|
||||
@Override
|
||||
public void subscribe(ObservableEmitter<Integer> emitter) throws Exception {
|
||||
File file = new File(filePath);
|
||||
if (TextUtils.isEmpty(filePath) || !file.exists()) {
|
||||
Log.e("installRx", "filePath is empty");
|
||||
emitter.onNext(0);
|
||||
return;
|
||||
}
|
||||
// String[] args = { "pm", "install", "-r", filePath };
|
||||
String[] args = {"pm", "install", "-i", "com.colorflykids", "--user", "0", filePath};
|
||||
// String argss = "pm install -i " + "com.colorflykids" + " --user 0 " + filePath;
|
||||
Log.e("installRx", "argss====" + args);
|
||||
ProcessBuilder processBuilder = new ProcessBuilder(args);
|
||||
Process process = null;
|
||||
BufferedReader successResult = null;
|
||||
BufferedReader errorResult = null;
|
||||
StringBuilder successMsg = new StringBuilder();
|
||||
StringBuilder errorMsg = new StringBuilder();
|
||||
try {
|
||||
process = processBuilder.start();
|
||||
successResult = new BufferedReader(new InputStreamReader(process.getInputStream()));
|
||||
errorResult = new BufferedReader(new InputStreamReader(process.getErrorStream()));
|
||||
String s;
|
||||
while ((s = successResult.readLine()) != null) {
|
||||
Log.e("mjhseng", "successResult----------" + s);
|
||||
successMsg.append(s);
|
||||
}
|
||||
while ((s = errorResult.readLine()) != null) {
|
||||
Log.e("mjhseng", "errorResult----------" + s);
|
||||
errorMsg.append(s);
|
||||
}
|
||||
} catch (IOException e1) {
|
||||
Log.e("installRx", "IOException e1)----------" + e1.toString());
|
||||
e1.printStackTrace();
|
||||
} finally {
|
||||
try {
|
||||
if (successResult != null) {
|
||||
successResult.close();
|
||||
@Override
|
||||
public void subscribe(ObservableEmitter<Integer> emitter) throws Exception {
|
||||
File file = new File(filePath);
|
||||
if (TextUtils.isEmpty(filePath) || !file.exists()) {
|
||||
Log.e("installRx", "filePath is empty");
|
||||
emitter.onNext(0);
|
||||
return;
|
||||
}
|
||||
if (errorResult != null) {
|
||||
errorResult.close();
|
||||
// String[] args = { "pm", "install", "-r", filePath };
|
||||
String[] args = {"pm", "install", "-i", "com.colorflykids", "--user", "0", filePath};
|
||||
// String argss = "pm install -i " + "com.colorflykids" + " --user 0 " + filePath;
|
||||
Log.e("installRx", "argss====" + args);
|
||||
ProcessBuilder processBuilder = new ProcessBuilder(args);
|
||||
Process process = null;
|
||||
BufferedReader successResult = null;
|
||||
BufferedReader errorResult = null;
|
||||
StringBuilder successMsg = new StringBuilder();
|
||||
StringBuilder errorMsg = new StringBuilder();
|
||||
try {
|
||||
process = processBuilder.start();
|
||||
successResult = new BufferedReader(new InputStreamReader(process.getInputStream()));
|
||||
errorResult = new BufferedReader(new InputStreamReader(process.getErrorStream()));
|
||||
String s;
|
||||
while ((s = successResult.readLine()) != null) {
|
||||
Log.e("mjhseng", "successResult----------" + s);
|
||||
successMsg.append(s);
|
||||
}
|
||||
while ((s = errorResult.readLine()) != null) {
|
||||
Log.e("mjhseng", "errorResult----------" + s);
|
||||
errorMsg.append(s);
|
||||
}
|
||||
} catch (IOException e1) {
|
||||
Log.e("installRx", "IOException e1)----------" + e1.toString());
|
||||
e1.printStackTrace();
|
||||
} finally {
|
||||
try {
|
||||
if (successResult != null) {
|
||||
successResult.close();
|
||||
}
|
||||
if (errorResult != null) {
|
||||
errorResult.close();
|
||||
}
|
||||
} catch (IOException e1) {
|
||||
Log.e("installRx", "IOException e11)---------" + e1.toString());
|
||||
e1.printStackTrace();
|
||||
}
|
||||
if (process != null) {
|
||||
process.destroy();
|
||||
}
|
||||
}
|
||||
if (successMsg.toString().contains("Success") || successMsg.toString().contains("success")) {
|
||||
emitter.onNext(2);
|
||||
} else {
|
||||
Log.e("installRx", "errormesg :" + errorMsg.toString());
|
||||
emitter.onNext(1);
|
||||
}
|
||||
} catch (IOException e1) {
|
||||
Log.e("installRx", "IOException e11)---------" + e1.toString());
|
||||
e1.printStackTrace();
|
||||
}
|
||||
if (process != null) {
|
||||
process.destroy();
|
||||
}
|
||||
}
|
||||
if (successMsg.toString().contains("Success") || successMsg.toString().contains("success")) {
|
||||
emitter.onNext(2);
|
||||
} else {
|
||||
Log.e("installRx", "errormesg :" + errorMsg.toString());
|
||||
emitter.onNext(1);
|
||||
}
|
||||
}
|
||||
}).subscribeOn(Schedulers.io())
|
||||
}).subscribeOn(Schedulers.io())
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.subscribe(new Observer<Integer>() {
|
||||
@Override
|
||||
@@ -1085,17 +1096,17 @@ public class ApkUtils {
|
||||
*/
|
||||
public static void UninstallAPP(Context context, String pkg) {
|
||||
Observable.create(new ObservableOnSubscribe<String>() {
|
||||
@Override
|
||||
public void subscribe(ObservableEmitter<String> emitter) throws Exception {
|
||||
@Override
|
||||
public void subscribe(ObservableEmitter<String> emitter) throws Exception {
|
||||
// Log.e("UninstallAPP", "call: " + Thread.currentThread().getName());
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
|
||||
ApkUtils.uninstall(context, pkg);
|
||||
} else {
|
||||
ApkUtils.deleteApkInSilence(pkg);
|
||||
}
|
||||
emitter.onNext(pkg);
|
||||
}
|
||||
}).subscribeOn(Schedulers.io())
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
|
||||
ApkUtils.uninstall(context, pkg);
|
||||
} else {
|
||||
ApkUtils.deleteApkInSilence(pkg);
|
||||
}
|
||||
emitter.onNext(pkg);
|
||||
}
|
||||
}).subscribeOn(Schedulers.io())
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.subscribe(new Observer<String>() {
|
||||
@Override
|
||||
@@ -1484,21 +1495,21 @@ public class ApkUtils {
|
||||
return;
|
||||
}
|
||||
Observable.create(new ObservableOnSubscribe<String>() {
|
||||
@Override
|
||||
public void subscribe(ObservableEmitter<String> e) throws Exception {
|
||||
List<DownloadEntity> 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);
|
||||
@Override
|
||||
public void subscribe(ObservableEmitter<String> e) throws Exception {
|
||||
List<DownloadEntity> 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);
|
||||
}
|
||||
}
|
||||
e.onComplete();
|
||||
}
|
||||
}
|
||||
e.onComplete();
|
||||
}
|
||||
}).subscribeOn(Schedulers.io())
|
||||
}).subscribeOn(Schedulers.io())
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.subscribe(new Observer<String>() {
|
||||
@Override
|
||||
|
||||
@@ -176,6 +176,7 @@ public class JgyUtils {
|
||||
public static final int MT6765Platform = 28;
|
||||
public static final int G128TPlatform = 29;
|
||||
public static final int QualcommTPlatform = 30;
|
||||
public static final int DX11Platform = 31;
|
||||
|
||||
|
||||
public static final String Other = "其他";
|
||||
@@ -202,6 +203,7 @@ public class JgyUtils {
|
||||
public static final String MT6765_TAG = "MT6765";
|
||||
public static final String G128T_TAG = "G128T";
|
||||
public static final String Qualcomm_TAG = "QualcommA";
|
||||
public static final String DX11_TAG = "DX11";
|
||||
|
||||
|
||||
private CacheHelper cacheHelper;
|
||||
@@ -361,6 +363,9 @@ public class JgyUtils {
|
||||
} else if (Qualcomm_TAG.equalsIgnoreCase(platform)) {
|
||||
Log.i(TAG, "checkAppPlatform: " + "QualcommA");
|
||||
return QualcommTPlatform;
|
||||
} else if (DX11_TAG.equalsIgnoreCase(platform)) {
|
||||
Log.i(TAG, "checkAppPlatform: " + "DX11");
|
||||
return DX11Platform;
|
||||
} else {
|
||||
Log.i(TAG, "checkAppPlatform: " + "没有数据");
|
||||
return UnknowPlatform;
|
||||
@@ -429,6 +434,8 @@ public class JgyUtils {
|
||||
getAppPlatformCallback.AppPlatform(G128TPlatform);
|
||||
} else if (Qualcomm_TAG.equalsIgnoreCase(platform)) {
|
||||
getAppPlatformCallback.AppPlatform(QualcommTPlatform);
|
||||
} else if (DX11_TAG.equalsIgnoreCase(platform)) {
|
||||
getAppPlatformCallback.AppPlatform(DX11Platform);
|
||||
} else {
|
||||
getAppPlatformCallback.AppPlatform(UnknowPlatform);
|
||||
}
|
||||
@@ -1476,6 +1483,9 @@ public class JgyUtils {
|
||||
if (JgyUtils.getInstance().checkAppPlatform() == JgyUtils.G11Platform) {
|
||||
pkgSet.addAll(ApkUtils.G11Pkgs);
|
||||
}
|
||||
if (JgyUtils.getInstance().checkAppPlatform() == JgyUtils.DX11Platform) {
|
||||
pkgSet.addAll(ApkUtils.DX11App);
|
||||
}
|
||||
if (JgyUtils.getInstance().checkAppPlatform() == JgyUtils.YXPD1Platform) {
|
||||
pkgSet.add("com.tencent.wemeet.app");
|
||||
}
|
||||
@@ -1510,10 +1520,14 @@ public class JgyUtils {
|
||||
|
||||
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);
|
||||
try {
|
||||
boolean b = Settings.System.putString(crv, CommonConfig.AOLE_ACTION_APP_FORBID, aole_app_forbid);
|
||||
Log.e("writeAppPackageList: ", "aole_app_forbid: " + b + " " + Settings.System.getString(crv, CommonConfig.AOLE_ACTION_APP_FORBID));
|
||||
} catch (Exception e) {
|
||||
Log.e(TAG, "writeAppPackageList: Settings.System.putString failed", e);
|
||||
}
|
||||
setAppRestriction(2);
|
||||
addAppInstallWhiteList(new ArrayList<>(pkgSet));
|
||||
Log.e("writeAppPackageList: ", "aole_app_forbid: " + b + " " + Settings.System.getString(crv, CommonConfig.AOLE_ACTION_APP_FORBID));
|
||||
}
|
||||
|
||||
public void writeAppPackageList() {
|
||||
@@ -1536,7 +1550,11 @@ public class JgyUtils {
|
||||
|
||||
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);
|
||||
try {
|
||||
Settings.System.putString(crv, CommonConfig.AOLE_ACTION_APP_FORBID, aole_app_forbid);
|
||||
} catch (Exception e) {
|
||||
Log.e(TAG, "writeAppPackageList: Settings.System.putString failed", e);
|
||||
}
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
@@ -1812,6 +1830,11 @@ public class JgyUtils {
|
||||
if (ApkUtils.mJxwApp.contains(packageName)) {
|
||||
continue;
|
||||
}
|
||||
if (JgyUtils.getInstance().checkAppPlatform() == JgyUtils.DX11Platform) {
|
||||
if (ApkUtils.DX11App.contains(packageName)) {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
if (PackageNames.DEVICE_INFO.equals(packageName) || PackageNames.APPSTORE.equals(packageName)
|
||||
) {
|
||||
continue;
|
||||
|
||||
@@ -147,6 +147,12 @@ public class SysSettingUtils {
|
||||
public static void openMtp(Context context) {
|
||||
String usbStatus = CommonConfig.AOLE_ACTION_USB_USB_MTP;
|
||||
Intent usbIntent = new Intent(usbStatus);
|
||||
if (JgyUtils.getInstance().checkAppPlatform() == JgyUtils.TeclastP20sPlatform
|
||||
|| JgyUtils.getInstance().checkAppPlatform() == JgyUtils.AH6016Platform
|
||||
|| JgyUtils.getInstance().checkAppPlatform() == JgyUtils.DX11Platform
|
||||
) {
|
||||
usbIntent.setPackage("com.android.settings");
|
||||
}
|
||||
context.sendBroadcast(usbIntent);
|
||||
}
|
||||
|
||||
@@ -247,6 +253,7 @@ public class SysSettingUtils {
|
||||
if (JgyUtils.getInstance().checkAppPlatform() == JgyUtils.TeclastP20sPlatform
|
||||
|| JgyUtils.getInstance().checkAppPlatform() == JgyUtils.AH6016Platform
|
||||
|| JgyUtils.getInstance().checkAppPlatform() == JgyUtils.seewoPlatform
|
||||
|| JgyUtils.getInstance().checkAppPlatform() == JgyUtils.DX11Platform
|
||||
) {
|
||||
usbIntent.setPackage("com.android.settings");
|
||||
}
|
||||
@@ -316,6 +323,7 @@ public class SysSettingUtils {
|
||||
Intent usbIntent = new Intent(usbStatus);
|
||||
if (JgyUtils.getInstance().checkAppPlatform() == JgyUtils.TeclastP20sPlatform
|
||||
|| JgyUtils.getInstance().checkAppPlatform() == JgyUtils.AH6016Platform
|
||||
|| JgyUtils.getInstance().checkAppPlatform() == JgyUtils.DX11Platform
|
||||
) {
|
||||
usbIntent.setPackage("com.android.settings");
|
||||
}
|
||||
@@ -1204,6 +1212,7 @@ public class SysSettingUtils {
|
||||
Intent usbIntent = new Intent(usbStatus);
|
||||
if (JgyUtils.getInstance().checkAppPlatform() == JgyUtils.TeclastP20sPlatform
|
||||
|| JgyUtils.getInstance().checkAppPlatform() == JgyUtils.AH6016Platform
|
||||
|| JgyUtils.getInstance().checkAppPlatform() == JgyUtils.DX11Platform
|
||||
) {
|
||||
usbIntent.setPackage("com.android.settings");
|
||||
}
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
package com.aoleyun.sn.utils;
|
||||
|
||||
import static android.content.Context.WIFI_SERVICE;
|
||||
|
||||
import android.annotation.SuppressLint;
|
||||
import android.app.ActivityManager;
|
||||
import android.bluetooth.BluetoothAdapter;
|
||||
@@ -109,8 +111,6 @@ import io.reactivex.rxjava3.disposables.Disposable;
|
||||
import io.reactivex.rxjava3.schedulers.Schedulers;
|
||||
import vendor.mediatek.hardware.nvram.V1_0.INvram;
|
||||
|
||||
import static android.content.Context.WIFI_SERVICE;
|
||||
|
||||
|
||||
public class Utils {
|
||||
private static final String TAG = "Utils";
|
||||
@@ -1838,6 +1838,7 @@ public class Utils {
|
||||
|| JgyUtils.getInstance().checkAppPlatform() == JgyUtils.MT6765Platform
|
||||
|| JgyUtils.getInstance().checkAppPlatform() == JgyUtils.G128TPlatform
|
||||
|| JgyUtils.getInstance().checkAppPlatform() == JgyUtils.QualcommTPlatform
|
||||
|| JgyUtils.getInstance().checkAppPlatform() == JgyUtils.DX11Platform
|
||||
) {
|
||||
return Utils.getProperty("ro.build.display.id", "获取失败");
|
||||
} else {
|
||||
|
||||
Reference in New Issue
Block a user