version:3.9
fix:修复解锁后无限重置的bug update:更换图标,增加解锁后显示所有app
This commit is contained in:
1 parent
8d8271901b
commit
9f6c360a9a
46 files changed
+2320
-77
No files matched your search
@@ -2,9 +2,16 @@ package com.aoleyun.os.network;
|
||||
|
||||
import android.content.Context;
|
||||
import android.os.Environment;
|
||||
import android.text.TextUtils;
|
||||
import android.util.Log;
|
||||
|
||||
import com.aoleyun.os.disklrucache.CacheHelper;
|
||||
import com.aoleyun.os.manager.ConnectManager;
|
||||
import com.aoleyun.os.manager.ConnectMode;
|
||||
import com.aoleyun.os.network.bean.AppPasswdBean;
|
||||
import com.aoleyun.os.network.bean.BaseResponse;
|
||||
import com.aoleyun.os.network.bean.Batch;
|
||||
import com.aoleyun.os.uiuiutils.JGYUtils;
|
||||
import com.aoleyun.os.uiuiutils.Utils;
|
||||
import com.aoleyun.os.network.api.AddAppLog;
|
||||
import com.aoleyun.os.network.api.AppUsageRecordApi;
|
||||
@@ -13,13 +20,24 @@ import com.aoleyun.os.network.api.GetAppPassword;
|
||||
import com.aoleyun.os.network.api.GetJpushTagsApi;
|
||||
import com.aoleyun.os.network.api.RunningApp;
|
||||
import com.aoleyun.os.network.api.SendScreenshotApi;
|
||||
import com.google.gson.Gson;
|
||||
import com.google.gson.JsonObject;
|
||||
import com.google.gson.JsonParser;
|
||||
import com.tencent.android.tpush.XGIOperateCallback;
|
||||
import com.tencent.android.tpush.XGPushManager;
|
||||
import com.tencent.mmkv.MMKV;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import io.reactivex.Observable;
|
||||
import io.reactivex.Observer;
|
||||
import io.reactivex.android.schedulers.AndroidSchedulers;
|
||||
import io.reactivex.annotations.NonNull;
|
||||
import io.reactivex.disposables.Disposable;
|
||||
import io.reactivex.schedulers.Schedulers;
|
||||
import okhttp3.Cache;
|
||||
import okhttp3.OkHttpClient;
|
||||
@@ -32,10 +50,15 @@ import retrofit2.converter.gson.GsonConverterFactory;
|
||||
public class NetworkManager {
|
||||
private static NetworkManager sInstance;
|
||||
private Context mContext;
|
||||
private MMKV mMMKV = MMKV.defaultMMKV();
|
||||
private CacheHelper cacheHelper;
|
||||
|
||||
private static Retrofit mRetrofit;
|
||||
|
||||
private NetworkManager(Context context) {
|
||||
this.mContext = context;
|
||||
this.cacheHelper = new CacheHelper(mContext);
|
||||
|
||||
if (null == mRetrofit) {
|
||||
mRetrofit = new Retrofit.Builder()
|
||||
.client(okHttpClient)
|
||||
@@ -109,7 +132,7 @@ public class NetworkManager {
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public Observable<BaseResponse> getJpushTagsObservable() {
|
||||
public Observable<BaseResponse<Batch>> getJpushTagsObservable() {
|
||||
return mRetrofit.create(GetJpushTagsApi.class)
|
||||
.getJpushTags(Utils.getSerial())
|
||||
.subscribeOn(Schedulers.io())
|
||||
@@ -117,7 +140,6 @@ public class NetworkManager {
|
||||
}
|
||||
|
||||
|
||||
|
||||
public AppUsageRecordApi getAppUsageRecordControl() {
|
||||
return mRetrofit.create(AppUsageRecordApi.class);
|
||||
}
|
||||
@@ -127,4 +149,94 @@ public class NetworkManager {
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
public interface onCompleteCallback {
|
||||
void onComplete();
|
||||
}
|
||||
|
||||
public void setPushTag(boolean refresh, onCompleteCallback callback) {
|
||||
ConnectMode connectMode = ConnectMode.ONE_DAY;
|
||||
if (refresh) {
|
||||
connectMode = ConnectMode.FIFTEEN_MINUTES;
|
||||
}
|
||||
if (ConnectManager.getInstance().isNeedConnect(URLPath.GET_DEVICES_TAGS, connectMode)) {
|
||||
setPushTag(callback);
|
||||
} else {
|
||||
String jsonString = cacheHelper.getAsString(URLPath.GET_DEVICES_TAGS);
|
||||
//为 "" 是已经请求成功的
|
||||
if (jsonString == null) {
|
||||
setPushTag(callback);
|
||||
} else {
|
||||
Set tagSets = mMMKV.decodeStringSet(URLPath.GET_DEVICES_TAGS);
|
||||
Log.e("setPushTags", "tagSets: " + tagSets);
|
||||
clearAndAppendTags(tagSets);
|
||||
callback.onComplete();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public void setPushTag(onCompleteCallback callback) {
|
||||
Set set = new HashSet();
|
||||
JGYUtils.getInstance().getAppPlatform(new JGYUtils.GetAppPlatformCallback() {
|
||||
@Override
|
||||
public void AppPlatform(int platform) {
|
||||
if (platform == JGYUtils.MTKPlatform) {
|
||||
set.add(JGYUtils.MTKTag);
|
||||
} else if (platform == JGYUtils.ZhanruiPlatform) {
|
||||
set.add(JGYUtils.ZhanruiTag);
|
||||
}
|
||||
}
|
||||
});
|
||||
getJpushTagsObservable()
|
||||
.subscribe(new Observer<BaseResponse<Batch>>() {
|
||||
@Override
|
||||
public void onSubscribe(@NonNull Disposable d) {
|
||||
Log.e("setPushTag", "onSubscribe: ");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNext(@NonNull BaseResponse<Batch> response) {
|
||||
Log.e("setPushTag", "onNext: " + response);
|
||||
if (response.code == 200) {
|
||||
String batch = response.data.getBatch();
|
||||
cacheHelper.put(URLPath.GET_DEVICES_TAGS, batch);
|
||||
if (!TextUtils.isEmpty(batch)) {
|
||||
set.add(batch);
|
||||
} else {
|
||||
Log.e("setPushTag", "onNext: " + "batch empty");
|
||||
}
|
||||
} else {
|
||||
cacheHelper.put(URLPath.GET_DEVICES_TAGS, "");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(@NonNull Throwable e) {
|
||||
Log.e("setPushTag", "onError: " + e.getMessage());
|
||||
onComplete();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onComplete() {
|
||||
Log.e("setPushTag", "onComplete: ");
|
||||
mMMKV.encode(URLPath.GET_DEVICES_TAGS, set);
|
||||
clearAndAppendTags(set);
|
||||
callback.onComplete();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
synchronized private void clearAndAppendTags(Set tagSets) {
|
||||
XGPushManager.clearAndAppendTags(mContext, "clearAndAppendTags :" + System.currentTimeMillis(), tagSets, new XGIOperateCallback() {
|
||||
@Override
|
||||
public void onSuccess(Object o, int i) {
|
||||
Log.e("clearAndAppendTags", "onSuccess: " + o);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFail(Object o, int i, String s) {
|
||||
Log.e("clearAndAppendTags", "onFail: " + o);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -3,6 +3,7 @@ package com.aoleyun.os.network.api;
|
||||
|
||||
import com.aoleyun.os.network.bean.BaseResponse;
|
||||
import com.aoleyun.os.network.URLPath;
|
||||
import com.aoleyun.os.network.bean.Batch;
|
||||
|
||||
import io.reactivex.Observable;
|
||||
import retrofit2.http.GET;
|
||||
@@ -10,7 +11,7 @@ import retrofit2.http.Query;
|
||||
|
||||
public interface GetJpushTagsApi {
|
||||
@GET(URLPath.GET_DEVICES_TAGS)
|
||||
Observable<BaseResponse> getJpushTags(
|
||||
Observable<BaseResponse<Batch>> getJpushTags(
|
||||
@Query("sn") String sn
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
package com.aoleyun.os.network.bean;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
public class Batch implements Serializable {
|
||||
private static final long serialVersionUID = 4284402995241045670L;
|
||||
|
||||
String batch;
|
||||
|
||||
public String getBatch() {
|
||||
return batch;
|
||||
}
|
||||
|
||||
public void setBatch(String batch) {
|
||||
this.batch = batch;
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user