version: cude 6.1
fix: update:增加短信管控
This commit is contained in:
@@ -80,16 +80,16 @@ android {
|
||||
//酷比魔方
|
||||
cube {
|
||||
flavorDimensions "default"
|
||||
versionCode 50
|
||||
versionName "5.9"
|
||||
versionCode 52
|
||||
versionName "6.1"
|
||||
buildConfigField "String", "platform", '"ZhanRuiCube"'
|
||||
}
|
||||
|
||||
//MTK
|
||||
MTKnewly {
|
||||
flavorDimensions "default"
|
||||
versionCode 25
|
||||
versionName "3.4"
|
||||
versionCode 26
|
||||
versionName "3.5"
|
||||
buildConfigField "String", "platform", '"MTK"'
|
||||
}
|
||||
}
|
||||
|
||||
@@ -100,6 +100,7 @@ import com.aoleyun.sn.utils.CacheUtils;
|
||||
import com.aoleyun.sn.utils.ForegroundAppUtil;
|
||||
import com.aoleyun.sn.utils.GsonUtils;
|
||||
import com.aoleyun.sn.utils.JGYUtils;
|
||||
import com.aoleyun.sn.utils.MD5Util;
|
||||
import com.aoleyun.sn.utils.NetworkUtils;
|
||||
import com.aoleyun.sn.utils.SPUtils;
|
||||
import com.aoleyun.sn.utils.TimeUtils;
|
||||
@@ -119,6 +120,8 @@ import com.tencent.mmkv.MMKV;
|
||||
import com.trello.rxlifecycle4.RxLifecycle;
|
||||
import com.trello.rxlifecycle4.android.ActivityEvent;
|
||||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.lang.reflect.Type;
|
||||
@@ -129,6 +132,7 @@ import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import io.reactivex.rxjava3.android.schedulers.AndroidSchedulers;
|
||||
@@ -145,6 +149,7 @@ import okhttp3.Interceptor;
|
||||
import okhttp3.MediaType;
|
||||
import okhttp3.MultipartBody;
|
||||
import okhttp3.OkHttpClient;
|
||||
import okhttp3.Protocol;
|
||||
import okhttp3.Request;
|
||||
import okhttp3.RequestBody;
|
||||
import okhttp3.Response;
|
||||
@@ -169,18 +174,73 @@ public class NetInterfaceManager {
|
||||
private static final int OK = 200;
|
||||
private static final int NOTFOUND = -300;
|
||||
|
||||
private final ConcurrentHashMap<String, Long> requestIdsMap = new ConcurrentHashMap<>();
|
||||
|
||||
//超时时间
|
||||
private static int timeOut = 5;
|
||||
// 缓存大小
|
||||
private static long cacheSize = 1024 * 1024 * 64;
|
||||
|
||||
public static final String HTTP_KEY = "YTM3YTAxNTJmMmZmNzkyM2E2YzIwZjlhZTc0NzNmMGI=";
|
||||
public static final String CUSTOM_REPEAT_REQ_PROTOCOL = "MY_CUSTOM_REPEAT_REQ_PROTOCOL";
|
||||
|
||||
private NetInterfaceManager(Context context) {
|
||||
this.mContext = context;
|
||||
this.cacheHelper = new CacheHelper(mContext);
|
||||
|
||||
if (okHttpClient == null) {
|
||||
Interceptor myHttpInterceptor = new Interceptor() {
|
||||
@NotNull
|
||||
@Override
|
||||
public Response intercept(@NotNull Chain chain) throws IOException {
|
||||
Request request = chain.request();
|
||||
String requestKey = MD5Util.getUpperMD5Str(request.method() + request.url().toString());
|
||||
Response response = chain.proceed(request); //准备返回Response
|
||||
// try {
|
||||
// response.close();
|
||||
// response = chain.proceed(request);
|
||||
// } catch (Exception e) {
|
||||
// //异常的返回也是完成Http请求。在这里移除请求登记
|
||||
// if (!TextUtils.isEmpty(e.toString()) && e.toString().contains(NetInterfaceManager.CUSTOM_REPEAT_REQ_PROTOCOL)) {
|
||||
// Log.e("REPEAT-REQUEST", "intercept: " + e.getMessage());
|
||||
// Log.e("REPEAT-REQUEST", "移除请求1:" + requestKey + " --- " + Thread.currentThread().getName() + " URL = " + request.url());
|
||||
// } else {
|
||||
// requestIdsMap.remove(requestKey);
|
||||
// }
|
||||
// throw e;
|
||||
// }
|
||||
synchronized (requestIdsMap) {
|
||||
requestIdsMap.remove(requestKey); //在这里移除正常的请求登记
|
||||
Log.e("REPEAT-REQUEST", "移除请求2:" + requestKey + " --- " + Thread.currentThread().getName() + " URL = " + request.url());
|
||||
}
|
||||
return response;
|
||||
}
|
||||
};
|
||||
Interceptor mRequestInterceptor = new Interceptor() {
|
||||
@NotNull
|
||||
@Override
|
||||
public Response intercept(@NotNull Chain chain) throws IOException {
|
||||
Request request = chain.request();
|
||||
//拦截处理重复的HTTP 请求,类似 防止快速点击按钮去重 可以不去处理了,全局统一处理
|
||||
String requestKey = MD5Util.getUpperMD5Str(request.method() + request.url().toString());
|
||||
synchronized (requestIdsMap) {
|
||||
if (requestIdsMap.get(requestKey) == null) {
|
||||
// Log.e("REPEAT-REQUEST", "intercept: " + requestIdsMap);
|
||||
requestIdsMap.put(requestKey, System.currentTimeMillis());
|
||||
Log.e("REPEAT-REQUEST", "注册请求:" + requestKey + " --- " + Thread.currentThread().getName() + " URL = " + request.url());
|
||||
} else {
|
||||
//如果是重复的请求,抛出一个自定义的错误,这个错误大家根据自己的业务定义吧
|
||||
Log.e("REPEAT-REQUEST", "重复请求:" + requestKey + " --- " + Thread.currentThread().getName() + " URL = " + request.url());
|
||||
return new Response.Builder()
|
||||
.protocol(Protocol.get(CUSTOM_REPEAT_REQ_PROTOCOL))
|
||||
.request(request) //multi thread
|
||||
.build();
|
||||
}
|
||||
}
|
||||
Response response = chain.proceed(request);
|
||||
return response;
|
||||
}
|
||||
};
|
||||
/**
|
||||
* 有网时候的缓存
|
||||
*/
|
||||
|
||||
@@ -480,6 +480,7 @@ public class MessageReceiver extends XGPushBaseReceiver {
|
||||
ToastUtil.betaShow("收到管控:系统设置");
|
||||
if (!TextUtils.isEmpty(extras)) {
|
||||
JGYUtils.getInstance().SettingSysData(extras);
|
||||
JGYUtils.getInstance().removeAllTask();
|
||||
}
|
||||
break;
|
||||
case MSG_BROWSER:
|
||||
|
||||
@@ -1759,22 +1759,37 @@ public class JGYUtils {
|
||||
/**
|
||||
* 清除所有最近记录
|
||||
*/
|
||||
public void removeAllTask(Context context) {
|
||||
List<ActivityManager.RecentTaskInfo> list = getRecentTasks(ActivityManager.getMaxRecentTasksStatic(), getCurrentUserId());
|
||||
// public void removeAllTask() {
|
||||
// List<ActivityManager.RecentTaskInfo> list = getRecentTasks(ActivityManager.getMaxRecentTasksStatic(), getCurrentUserId());
|
||||
//
|
||||
// for (ActivityManager.RecentTaskInfo info : list) {
|
||||
// if (info.realActivity != null) {
|
||||
// Log.e(TAG, "removeAllTask: " + info.realActivity.getPackageName());
|
||||
// //排除自身
|
||||
// if (BuildConfig.APPLICATION_ID.equals(info.realActivity.getPackageName())) {
|
||||
// continue;
|
||||
// }
|
||||
// }
|
||||
// try {
|
||||
// ActivityManagerNative.getDefault().removeTask(info.id);
|
||||
// } catch (RemoteException e) {
|
||||
// e.printStackTrace();
|
||||
// Log.e(TAG, "removeAllTask: " + e.getMessage());
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
|
||||
public void removeAllTask() {
|
||||
List<ActivityManager.RecentTaskInfo> list = getRecentTasks(ActivityManager.getMaxRecentTasksStatic(), getCurrentUserId());
|
||||
for (ActivityManager.RecentTaskInfo info : list) {
|
||||
if (info.realActivity != null) {
|
||||
Log.e(TAG, "removeAllTask: " + info.realActivity.getPackageName());
|
||||
//排除自身
|
||||
if (BuildConfig.APPLICATION_ID.equals(info.realActivity.getPackageName())) {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
try {
|
||||
ActivityManagerNative.getDefault().removeTask(info.id);
|
||||
Log.e(TAG, "removeAllTask: " + info.id);
|
||||
} catch (RemoteException e) {
|
||||
e.printStackTrace();
|
||||
Log.e(TAG, "removeAllTask: " + e.getMessage());
|
||||
Log.e(TAG, "removeTask: " + e.getMessage());
|
||||
} catch (NullPointerException e) {
|
||||
Log.e(TAG, "removeTask: " + e.getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -2033,7 +2048,7 @@ public class JGYUtils {
|
||||
|
||||
private void openLauncher3() {
|
||||
setDefaultDesktop(Launcher3, Launcher3Class);
|
||||
ApkUtils.openPackage(mContext, Launcher3);
|
||||
// ApkUtils.openPackage(mContext, Launcher3);
|
||||
}
|
||||
|
||||
public String getStartClassName(String pkg) {
|
||||
@@ -2092,7 +2107,7 @@ public class JGYUtils {
|
||||
Log.e(TAG, "setDefaultDesktop: MTK");
|
||||
//爱华定制
|
||||
intent.setComponent(new ComponentName("com.android.settings", "com.android.settings.AoleReceiver"));
|
||||
// TODO: 2022/7/6 有问题
|
||||
// TODO: 2022/7/6 MTK有问题
|
||||
setDefaultLauncher(mContext, "com.android.transfer", "com.android.transfer.MainActivity");
|
||||
SystemProperties.set("persist.sys.launcher.pkgname", pkg);
|
||||
SystemProperties.set("persist.sys.launcher.classname", className);
|
||||
|
||||
@@ -594,7 +594,10 @@ public class SysSettingUtils {
|
||||
int browser = changeNum(jsonObject.getInteger("setting_browser"));
|
||||
Settings.System.putInt(context.getContentResolver(), "qch_app_browser", browser);
|
||||
Log.e(TAG, "qch_app_browser" + browser);
|
||||
|
||||
//短信
|
||||
int setting_sms = changeNum(jsonObject.getInteger("setting_sms"));
|
||||
Settings.System.putInt(context.getContentResolver(), "qch_app_sms", setting_sms);
|
||||
Log.e(TAG, "qch_app_sms" + setting_sms);
|
||||
} catch (Exception e) {
|
||||
Log.e(TAG, "setIcon: " + e.getMessage());
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user