version: cude 5.3 MTK 3.1
fix: update:彻底删除极光推送,以及高德地图sdk,优化百度sdk获取结果
This commit is contained in:
@@ -5,7 +5,6 @@ import android.content.Context;
|
||||
import android.os.Handler;
|
||||
import android.os.Looper;
|
||||
import android.os.Process;
|
||||
import android.text.TextUtils;
|
||||
import android.util.Log;
|
||||
|
||||
import androidx.multidex.MultiDexApplication;
|
||||
@@ -14,7 +13,7 @@ import com.alibaba.fastjson.JSONArray;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.aoleyun.sn.BuildConfig;
|
||||
import com.aoleyun.sn.bean.BaseResponse;
|
||||
import com.aoleyun.sn.manager.AmapManager;
|
||||
import com.aoleyun.sn.manager.MapManager;
|
||||
import com.aoleyun.sn.manager.ConnectManager;
|
||||
import com.aoleyun.sn.manager.FileManager;
|
||||
import com.aoleyun.sn.network.NetInterfaceManager;
|
||||
@@ -30,7 +29,6 @@ import com.aoleyun.sn.utils.Utils;
|
||||
import com.aoleyun.sn.utils.WiFiUtils;
|
||||
import com.aoleyun.sn.utils.XAPKUtils;
|
||||
import com.arialyy.aria.core.Aria;
|
||||
import com.arialyy.aria.core.download.DownloadEntity;
|
||||
import com.tencent.android.tpush.XGIOperateCallback;
|
||||
import com.tencent.android.tpush.XGPushConfig;
|
||||
import com.tencent.android.tpush.XGPushManager;
|
||||
@@ -59,24 +57,20 @@ import okhttp3.Response;
|
||||
public class BaseApplication extends MultiDexApplication {
|
||||
private static final String TAG = BaseApplication.class.getSimpleName();
|
||||
|
||||
@SuppressLint("StaticFieldLeak")
|
||||
public static Context context;
|
||||
|
||||
public static Context getAppContext() {
|
||||
return context;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCreate() {
|
||||
super.onCreate();
|
||||
context = this.getApplicationContext();
|
||||
// if (SystemUtils.isMainProcessName(this, Process.myPid())) {
|
||||
//非主进程不初始化
|
||||
init();
|
||||
// }
|
||||
if (SystemUtils.isMainProcessName(this, Process.myPid())) {
|
||||
//非主进程不初始化
|
||||
init();
|
||||
}
|
||||
}
|
||||
|
||||
private void init() {
|
||||
if (!BuildConfig.DEBUG) {
|
||||
catchException();
|
||||
}
|
||||
|
||||
String rootDir = MMKV.initialize(this);
|
||||
Log.e(TAG, "mmkv root: " + rootDir);
|
||||
|
||||
@@ -89,35 +83,12 @@ public class BaseApplication extends MultiDexApplication {
|
||||
LogDBManager.init(this);
|
||||
FileManager.init(this);
|
||||
ConnectManager.init(this);
|
||||
AmapManager.init(this);
|
||||
AmapManager.getInstance().initAmap();
|
||||
|
||||
MapManager.init(this);
|
||||
MapManager.getInstance().initMap();
|
||||
JGYUtils.getInstance().hookWebView();
|
||||
|
||||
// 设置开启日志,发布时请关闭日志
|
||||
// JPushInterface.setDebugMode(true);
|
||||
// JPushInterface.requestPermission(this);
|
||||
//解锁设备不需要初始化
|
||||
// 初始化 JPush
|
||||
//JPushInterface.init(this);
|
||||
Aria.init(this);
|
||||
Aria.get(this).getDownloadConfig().setMaxTaskNum(1);
|
||||
Aria.get(this).getDownloadConfig().setConvertSpeed(true);
|
||||
|
||||
if (!BuildConfig.DEBUG) {
|
||||
catchException();
|
||||
}
|
||||
// Configuration config = getResources().getConfiguration();
|
||||
// int smallestScreenWidthDp = config.smallestScreenWidthDp;
|
||||
// Log.e("init", "smallestScreenWidthDp=" + smallestScreenWidthDp);
|
||||
// CalligraphyConfig.initDefault(new CalligraphyConfig.Builder()
|
||||
// .setDefaultFontPath("fonts/1234.ttf")
|
||||
// .setDefaultFontPath("fonts/Roboto-RobotoRegular.ttf")
|
||||
// .setFontAttrId(R.attr.fontPath)
|
||||
// .build()
|
||||
// );
|
||||
initAliasObservable();
|
||||
initTagObservable();
|
||||
}
|
||||
|
||||
private void catchException() {
|
||||
@@ -179,362 +150,4 @@ public class BaseApplication extends MultiDexApplication {
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private static void 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) {
|
||||
Log.e("initAliasObservable", "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("initAliasObservable", "onNext: " + integer);
|
||||
String s = "alias:\t";
|
||||
switch (integer) {
|
||||
case 0:
|
||||
Log.e("jiguangInterface", s + "Alias绑定成功");
|
||||
break;
|
||||
case 6001:
|
||||
Log.e("jiguangInterface", s + "无效的设置");
|
||||
break;
|
||||
case 6011:
|
||||
Log.e("jiguangInterface", s + "短时间内操作过于频繁");
|
||||
break;
|
||||
case 6013:
|
||||
Log.e("jiguangInterface", s + "用户设备时间轴异常");
|
||||
ToastUtil.show("用户设备时间轴异常,修改后重新登陆\t" + s + "code:6013");
|
||||
break;
|
||||
case 6022:
|
||||
Log.e("jiguangInterface", s + "alias 操作正在进行中");
|
||||
break;
|
||||
//需要重新设置
|
||||
case 6002:
|
||||
Log.e("jiguangInterface", s + "设置超时,请重试");
|
||||
setJpushAlias();
|
||||
break;
|
||||
case 6014:
|
||||
Log.e("jiguangInterface", s + "服务器繁忙,建议重试");
|
||||
setJpushAlias();
|
||||
break;
|
||||
case 6020:
|
||||
Log.e("jiguangInterface", s + "建议过一段时间再设置");
|
||||
setJpushAlias();
|
||||
break;
|
||||
case 6024:
|
||||
Log.e("jiguangInterface", s + "服务器内部错误");
|
||||
setJpushAlias();
|
||||
break;
|
||||
case 6017:
|
||||
case 6027:
|
||||
Log.e("jiguangInterface", s + "别名绑定的设备数超过限制");
|
||||
// cleanJpushAlias();
|
||||
setJpushAlias();
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(Throwable e) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onComplete() {
|
||||
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
// 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(getAppContext(), 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 static void setJpushTags() {
|
||||
Log.e(TAG, "30s后重新设置tags");
|
||||
}
|
||||
|
||||
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
|
||||
OkHttpClient client = new OkHttpClient();
|
||||
Request request = new Request.Builder()
|
||||
.url(UrlAddress.DELETE_JPUSH_ALIAS + Utils.getSerial(getAppContext()))
|
||||
.header("Authorization", JGYUtils.getAuthorization())
|
||||
.delete()
|
||||
.build();
|
||||
Call call = client.newCall(request);
|
||||
call.enqueue(new Callback() {
|
||||
@Override
|
||||
public void onFailure(@NotNull Call call, @NotNull IOException e) {
|
||||
Log.e("cleanJpushAlias", "onFailure: " + e.getMessage());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException {
|
||||
Log.e("cleanJpushAlias", "onResponse: " + response.toString());
|
||||
Log.e(TAG, "onResponse: " + "清除Alias成功");
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
synchronized public static void cleanJpushTag() {
|
||||
OkHttpClient client = new OkHttpClient();
|
||||
Request request = new Request.Builder()
|
||||
.url(UrlAddress.DELETE_JPUSH_TAG + Utils.getSerial(getAppContext()))
|
||||
.header("Authorization", JGYUtils.getAuthorization())
|
||||
.delete()
|
||||
.build();
|
||||
Call call = client.newCall(request);
|
||||
call.enqueue(new Callback() {
|
||||
@Override
|
||||
public void onFailure(@NotNull Call call, @NotNull IOException e) {
|
||||
Log.e("cleanJpushTag", "onFailure: " + e.getMessage());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException {
|
||||
Log.e("cleanJpushTag", "onResponse: " + response.toString());
|
||||
Log.e(TAG, "onResponse: " + "清除Tag成功");
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public static void sendAppUsedTime(String random, String type) {
|
||||
StatisticsInfo statisticsInfo = null;
|
||||
if (type.equals("0")) {
|
||||
statisticsInfo = new StatisticsInfo(getAppContext());
|
||||
} else if (type.equals("1")) {
|
||||
statisticsInfo = new StatisticsInfo(getAppContext(), StatisticsInfo.WEEK);
|
||||
}
|
||||
List<AppInformation> list = null;
|
||||
List<AppInformation> localAppList = new ArrayList<>();
|
||||
|
||||
if (statisticsInfo != null) {
|
||||
list = statisticsInfo.getShowList();
|
||||
if (list != null && list.size() > 0) {
|
||||
for (AppInformation appInformation : list) {
|
||||
if (!ApkUtils.isSystemApp(getAppContext(), appInformation.getPackageName())) {
|
||||
localAppList.add(appInformation);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
Log.e("fht", "今日没有打开的应用");
|
||||
}
|
||||
} else {
|
||||
Log.e("fht", "获取信息失败");
|
||||
}
|
||||
|
||||
JSONObject data = new JSONObject();
|
||||
JSONArray appinfo = new JSONArray();
|
||||
try {
|
||||
if (localAppList.size() > 0) {
|
||||
for (int i = 0; i < 5; i++) {
|
||||
AppInformation information = localAppList.get(i);
|
||||
JSONObject jsonObject = new JSONObject();
|
||||
jsonObject.put("package", information.getPackageName());
|
||||
jsonObject.put("use_time", (int) information.getUsedTimebyDay() / 1000);
|
||||
appinfo.add(jsonObject);
|
||||
}
|
||||
data.put("data", appinfo);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
Log.e("sendAppUsedTime", e.getMessage());
|
||||
}
|
||||
|
||||
NetInterfaceManager.getInstance()
|
||||
.getAppLogApi()
|
||||
.getAppLog(Utils.getSerial(getAppContext()), random, data.toJSONString())
|
||||
.subscribeOn(Schedulers.io())
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.subscribe(new Observer<BaseResponse>() {
|
||||
@Override
|
||||
public void onSubscribe(Disposable d) {
|
||||
Log.e("sendAppUsedTime", "onSubscribe: ");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNext(BaseResponse baseResponse) {
|
||||
Log.e("sendAppUsedTime", "onNext: ");
|
||||
int code = baseResponse.code;
|
||||
String msg = baseResponse.msg;
|
||||
Log.e("sendAppUsedTime", "onSubscribe:" + msg);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(Throwable e) {
|
||||
Log.e("sendAppUsedTime", "onError: " + e.getMessage());
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onComplete() {
|
||||
Log.e("sendAppUsedTime", "onComplete: ");
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
}
|
||||
|
||||
private static long totalTime;
|
||||
private static int totalTimes;
|
||||
|
||||
synchronized public static void setAPPUsage() {
|
||||
StatisticsInfo statisticsInfo = new StatisticsInfo(getAppContext());
|
||||
totalTime = statisticsInfo.getTotalTime();//全部时间
|
||||
totalTimes = statisticsInfo.getTotalTimes();//全部次数
|
||||
}
|
||||
|
||||
synchronized public static void setAPPUsage( List<String> lists) {
|
||||
StatisticsInfo statisticsInfo = new StatisticsInfo(getAppContext());
|
||||
List<AppInformation> list = null;
|
||||
List<AppInformation> localAppList = new ArrayList<>();
|
||||
|
||||
totalTime = statisticsInfo.getTotalTime();//全部时间
|
||||
totalTimes = statisticsInfo.getTotalTimes();//全部次数
|
||||
|
||||
list = statisticsInfo.getShowList();
|
||||
if (list != null && list.size() > 0) {
|
||||
for (AppInformation appInformation : list) {
|
||||
if (lists.indexOf(appInformation.getPackageName()) != -1) {
|
||||
localAppList.add(appInformation);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user