version:1.4

update:2021-10-21 10:14:40
fix:
add:增加浏览器桌面检测升级,修复重复请求
This commit is contained in:
2021-12-03 14:33:03 +08:00
parent 768519e14e
commit 34fa9fcdb7
70 changed files with 3189 additions and 1503 deletions

View File

@@ -12,6 +12,7 @@ import androidx.multidex.MultiDexApplication;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.aoleyun.sn.bean.BaseResponse;
import com.aoleyun.sn.utils.WiFiUtils;
import com.arialyy.aria.core.Aria;
import com.arialyy.aria.core.download.DownloadEntity;
import com.aoleyun.sn.BuildConfig;
@@ -25,7 +26,6 @@ import com.aoleyun.sn.statistics.AppInformation;
import com.aoleyun.sn.statistics.StatisticsInfo;
import com.aoleyun.sn.utils.ApkUtils;
import com.aoleyun.sn.utils.JGYUtils;
import com.aoleyun.sn.utils.Logutils;
import com.aoleyun.sn.utils.SystemUtils;
import com.aoleyun.sn.utils.ToastUtil;
import com.aoleyun.sn.utils.Utils;
@@ -77,7 +77,7 @@ public class BaseApplication extends MultiDexApplication {
@Override
public void onCreate() {
super.onCreate();
context = getApplicationContext();
context = this;
if (SystemUtils.isMainProcessName(this, Process.myPid())) {
//非主进程不初始化
init();
@@ -86,10 +86,11 @@ public class BaseApplication extends MultiDexApplication {
private void init() {
String rootDir = MMKV.initialize(this);
Logutils.e(TAG, "mmkv root: " + rootDir);
Log.e(TAG, "mmkv root: " + rootDir);
ToastUtil.init(this);
NetInterfaceManager.init(this);
JGYUtils.init(this);
WiFiUtils.init(this);
XAPKUtils.init(this);
FileManager.init(this);
AmapManager.init(this);
@@ -112,7 +113,7 @@ public class BaseApplication extends MultiDexApplication {
}
// Configuration config = getResources().getConfiguration();
// int smallestScreenWidthDp = config.smallestScreenWidthDp;
// Logutils.e("init", "smallestScreenWidthDp=" + smallestScreenWidthDp);
// Log.e("init", "smallestScreenWidthDp=" + smallestScreenWidthDp);
// CalligraphyConfig.initDefault(new CalligraphyConfig.Builder()
// .setDefaultFontPath("fonts/1234.ttf")
// .setDefaultFontPath("fonts/Roboto-RobotoRegular.ttf")
@@ -128,7 +129,7 @@ public class BaseApplication extends MultiDexApplication {
new Thread.UncaughtExceptionHandler() {
@Override
public void uncaughtException(Thread t, Throwable e) {
Logutils.e("捕获异常子线程:", Thread.currentThread().getName() +
Log.e("捕获异常子线程:", Thread.currentThread().getName() +
"在:" + e.getStackTrace()[0].getClassName());
}
}
@@ -141,7 +142,7 @@ public class BaseApplication extends MultiDexApplication {
try {
Looper.loop(); //会先执行这个方法,然后在执行下面的异常捕获方法!
} catch (Exception e) {
Logutils.e("捕获异常主线程:", Thread.currentThread().getName() + "在:" + e.getStackTrace()[0].getClassName());
Log.e("捕获异常主线程:", Thread.currentThread().getName() + "在:" + e.getStackTrace()[0].getClassName());
e.printStackTrace();
}
}
@@ -149,43 +150,15 @@ public class BaseApplication extends MultiDexApplication {
});
}
public void onAliasOperatorResult(JPushMessage jPushMessage) {
if (jPushMessage == null) {
return;
}
int errorCode = jPushMessage.getErrorCode();
onAliasResult.onResult(errorCode);
}
public static void setJpushAlias() {
Logutils.e("jiguangInterface", "30s后重新设置alias");
JPushInterface.setAlias(context, TagAliasOperatorHelper.sequence++, Utils.getSerial());
}
public void onTagOperatorResult(JPushMessage jPushMessage) {
if (jPushMessage == null) {
return;
}
int errorCode = jPushMessage.getErrorCode();
onTagResult.onResult(errorCode);
}
public static void setJpushTags() {
Logutils.e(TAG, "30s后重新设置tags");
HTTPInterface.setJpushTags(context);
}
private static void initAliasObservable() {
Logutils.e(TAG, "initAliasObservable: ");
Log.e(TAG, "initAliasObservable: ");
Observable.create(new ObservableOnSubscribe<Integer>() {
@Override
public void subscribe(ObservableEmitter<Integer> emitter) throws Exception {
onAliasResult = new OnAliasResult() {
@Override
public void onResult(int code) {
Logutils.e("initAliasObservable", "onResult: " + code);
Log.e("initAliasObservable", "onResult: " + code);
emitter.onNext(code);
}
};
@@ -199,45 +172,45 @@ public class BaseApplication extends MultiDexApplication {
@Override
public void onNext(Integer integer) {
Logutils.e("initAliasObservable", "onNext: " + integer);
Log.e("initAliasObservable", "onNext: " + integer);
String s = "alias:\t";
switch (integer) {
case 0:
Logutils.e("jiguangInterface", s + "Alias绑定成功");
Log.e("jiguangInterface", s + "Alias绑定成功");
break;
case 6001:
Logutils.e("jiguangInterface", s + "无效的设置");
Log.e("jiguangInterface", s + "无效的设置");
break;
case 6011:
Logutils.e("jiguangInterface", s + "短时间内操作过于频繁");
Log.e("jiguangInterface", s + "短时间内操作过于频繁");
break;
case 6013:
Logutils.e("jiguangInterface", s + "用户设备时间轴异常");
Log.e("jiguangInterface", s + "用户设备时间轴异常");
ToastUtil.show("用户设备时间轴异常,修改后重新登陆\t" + s + "code:6013");
break;
case 6022:
Logutils.e("jiguangInterface", s + "alias 操作正在进行中");
Log.e("jiguangInterface", s + "alias 操作正在进行中");
break;
//需要重新设置
case 6002:
Logutils.e("jiguangInterface", s + "设置超时,请重试");
Log.e("jiguangInterface", s + "设置超时,请重试");
setJpushAlias();
break;
case 6014:
Logutils.e("jiguangInterface", s + "服务器繁忙,建议重试");
Log.e("jiguangInterface", s + "服务器繁忙,建议重试");
setJpushAlias();
break;
case 6020:
Logutils.e("jiguangInterface", s + "建议过一段时间再设置");
Log.e("jiguangInterface", s + "建议过一段时间再设置");
setJpushAlias();
break;
case 6024:
Logutils.e("jiguangInterface", s + "服务器内部错误");
Log.e("jiguangInterface", s + "服务器内部错误");
setJpushAlias();
break;
case 6017:
case 6027:
Logutils.e("jiguangInterface", s + "别名绑定的设备数超过限制");
Log.e("jiguangInterface", s + "别名绑定的设备数超过限制");
cleanJpushAlias();
setJpushAlias();
break;
@@ -259,6 +232,140 @@ public class BaseApplication extends MultiDexApplication {
});
}
public void onAliasOperatorResult(JPushMessage jPushMessage) {
if (jPushMessage == null) {
return;
}
int errorCode = jPushMessage.getErrorCode();
onAliasResult.onResult(errorCode);
}
public static void setJpushAlias() {
Log.e("jiguangInterface", "30s后重新设置alias");
JPushInterface.setAlias(context, TagAliasOperatorHelper.sequence++, Utils.getSerial());
}
private static void initTagObservable() {
Log.e(TAG, "initTagObservable: ");
Observable.create(new ObservableOnSubscribe<Integer>() {
@Override
public void subscribe(ObservableEmitter<Integer> emitter) {
onTagResult = new OnTagResult() {
@Override
public void onResult(int code) {
Log.e("initTagObservable", "onResult: " + code);
emitter.onNext(code);
}
};
}
}).throttleLast(1, TimeUnit.HOURS)
.subscribe(new Observer<Integer>() {
@Override
public void onSubscribe(Disposable d) {
}
@Override
public void onNext(Integer integer) {
Log.e("initTagObservable", "onNext: " + integer);
String s = "tags:\t";
switch (integer) {
case 0:
Log.e("jiguangInterface", s + "Tag绑定成功");
break;
case 6001:
Log.e("jiguangInterface", s + "无效的设置");
break;
case 6005:
Log.e("jiguangInterface", s + "某一个 tag 字符串不合法");
ToastUtil.show("设备标签不合法,联系管理员修改\t" + "code:6005");
break;
case 6006:
Log.e("jiguangInterface", s + "某一个 tag 超长");
ToastUtil.show("设备标签过长,联系管理员修改\t" + "code:6006");
break;
case 6007:
Log.e("jiguangInterface", s + "tags 数量超出限制");
ToastUtil.show("设备标签数量超出限制,联系管理员修改\t" + "code:6007");
break;
case 6008:
Log.e("jiguangInterface", s + "tag 超出总长度限制");
ToastUtil.show("设备标签超出总长度限制,联系管理员修改\t" + "code:6008");
break;
case 6011:
Log.e("jiguangInterface", s + "短时间内操作过于频繁");
break;
case 6013:
Log.e("jiguangInterface", s + "用户设备时间轴异常");
ToastUtil.show("用户设备时间轴异常,修改后重新登陆\t" + "code:6013");
break;
case 6018:
Log.e("jiguangInterface", s + "Tags 过多");
cleanJpushTag();
ToastUtil.show("设备标签数量超出限制,联系管理员修改\t" + "code:6018");
break;
case 6021:
Log.e("jiguangInterface", s + "tags 操作正在进行中");
break;
//需要重新设置
case 6002:
Log.e("jiguangInterface", s + "设置超时,请重试");
setJpushTags();
break;
case 6014:
Log.e("jiguangInterface", s + "服务器繁忙,建议重试");
setJpushTags();
break;
case 6020:
Log.e("jiguangInterface", s + "建议过一段时间再设置");
setJpushTags();
break;
case 6024:
Log.e("jiguangInterface", s + "服务器内部错误");
setJpushTags();
break;
default:
break;
}
}
@Override
public void onError(Throwable e) {
}
@Override
public void onComplete() {
}
});
}
public void onTagOperatorResult(JPushMessage jPushMessage) {
if (jPushMessage == null) {
return;
}
int errorCode = jPushMessage.getErrorCode();
onTagResult.onResult(errorCode);
}
public static void setJpushTags() {
Log.e(TAG, "30s后重新设置tags");
HTTPInterface.setJpushTags(context);
}
private static OnAliasResult onAliasResult;
interface OnAliasResult {
void onResult(int code);
}
private static OnTagResult onTagResult;
interface OnTagResult {
void onResult(int code);
}
synchronized public static void cleanJpushAlias() {
//alias的绑定的设备超过10个但是alias应该是一个设备对应一个在重置设备后jpush的regid会变动所以需要清除
//https://docs.jiguang.cn/jpush/server/push/rest_api_v3_device/#_5
@@ -305,114 +412,6 @@ public class BaseApplication extends MultiDexApplication {
});
}
private static void initTagObservable() {
Logutils.e(TAG, "initTagObservable: ");
Observable.create(new ObservableOnSubscribe<Integer>() {
@Override
public void subscribe(ObservableEmitter<Integer> emitter) {
onTagResult = new OnTagResult() {
@Override
public void onResult(int code) {
Logutils.e("initTagObservable", "onResult: " + code);
emitter.onNext(code);
}
};
}
}).throttleLast(1, TimeUnit.HOURS)
.subscribe(new Observer<Integer>() {
@Override
public void onSubscribe(Disposable d) {
}
@Override
public void onNext(Integer integer) {
Logutils.e("initTagObservable", "onNext: " + integer);
String s = "tags:\t";
switch (integer) {
case 0:
Logutils.e("jiguangInterface", s + "Tag绑定成功");
break;
case 6001:
Logutils.e("jiguangInterface", s + "无效的设置");
break;
case 6005:
Logutils.e("jiguangInterface", s + "某一个 tag 字符串不合法");
ToastUtil.show("设备标签不合法,联系管理员修改\t" + "code:6005");
break;
case 6006:
Logutils.e("jiguangInterface", s + "某一个 tag 超长");
ToastUtil.show("设备标签过长,联系管理员修改\t" + "code:6006");
break;
case 6007:
Logutils.e("jiguangInterface", s + "tags 数量超出限制");
ToastUtil.show("设备标签数量超出限制,联系管理员修改\t" + "code:6007");
break;
case 6008:
Logutils.e("jiguangInterface", s + "tag 超出总长度限制");
ToastUtil.show("设备标签超出总长度限制,联系管理员修改\t" + "code:6008");
break;
case 6011:
Logutils.e("jiguangInterface", s + "短时间内操作过于频繁");
break;
case 6013:
Logutils.e("jiguangInterface", s + "用户设备时间轴异常");
ToastUtil.show("用户设备时间轴异常,修改后重新登陆\t" + "code:6013");
break;
case 6018:
Logutils.e("jiguangInterface", s + "Tags 过多");
cleanJpushTag();
ToastUtil.show("设备标签数量超出限制,联系管理员修改\t" + "code:6018");
break;
case 6021:
Logutils.e("jiguangInterface", s + "tags 操作正在进行中");
break;
//需要重新设置
case 6002:
Logutils.e("jiguangInterface", s + "设置超时,请重试");
setJpushTags();
break;
case 6014:
Logutils.e("jiguangInterface", s + "服务器繁忙,建议重试");
setJpushTags();
break;
case 6020:
Logutils.e("jiguangInterface", s + "建议过一段时间再设置");
setJpushTags();
break;
case 6024:
Logutils.e("jiguangInterface", s + "服务器内部错误");
setJpushTags();
break;
default:
break;
}
}
@Override
public void onError(Throwable e) {
}
@Override
public void onComplete() {
}
});
}
private static OnAliasResult onAliasResult;
interface OnAliasResult {
void onResult(int code);
}
private static OnTagResult onTagResult;
interface OnTagResult {
void onResult(int code);
}
private boolean finished = false;
public boolean isFinished() {
@@ -442,10 +441,10 @@ public class BaseApplication extends MultiDexApplication {
}
}
} else {
Logutils.e("fht", "今日没有打开的应用");
Log.e("fht", "今日没有打开的应用");
}
} else {
Logutils.e("fht", "获取信息失败");
Log.e("fht", "获取信息失败");
}
JSONObject data = new JSONObject();
@@ -462,7 +461,7 @@ public class BaseApplication extends MultiDexApplication {
data.put("data", appinfo);
}
} catch (Exception e) {
Logutils.e("sendAppUsedTime", e.getMessage());
Log.e("sendAppUsedTime", e.getMessage());
}
NetInterfaceManager.getInstance()
@@ -481,7 +480,7 @@ public class BaseApplication extends MultiDexApplication {
Log.e("sendAppUsedTime", "onNext: ");
int code = baseResponse.code;
String msg = baseResponse.msg;
Logutils.e("sendAppUsedTime", "onSubscribe:" + msg);
Log.e("sendAppUsedTime", "onSubscribe:" + msg);
}
@Override
@@ -545,6 +544,6 @@ public class BaseApplication extends MultiDexApplication {
} else {
BaseApplication.getInstance().setDownloadState(true);
}
Logutils.e(TAG, "isDownloading=" + BaseApplication.getInstance().isDownloading());
Log.e(TAG, "isDownloading=" + BaseApplication.getInstance().isDownloading());
}
}