version:MTK 2.3
fix:优化解锁后不能打开管控app update:解锁后显示应用市场等
This commit is contained in:
29
build.gradle
29
build.gradle
@@ -66,12 +66,12 @@ android {
|
||||
minSdkVersion 26
|
||||
targetSdkVersion 28
|
||||
|
||||
// //MTK
|
||||
// versionCode 13
|
||||
// versionName "2.2"
|
||||
//cube
|
||||
versionCode 37
|
||||
versionName "4.6"
|
||||
//MTK
|
||||
versionCode 14
|
||||
versionName "2.3"
|
||||
// //cube
|
||||
// versionCode 54
|
||||
// versionName "6.2"
|
||||
|
||||
ndk {
|
||||
//选择要添加的对应 cpu 类型的 .so 库。
|
||||
@@ -133,17 +133,12 @@ android {
|
||||
signingConfig signingConfigs.zhanRui
|
||||
}
|
||||
|
||||
alldocubeDebug.initWith(debug)
|
||||
alldocubeDebug {
|
||||
buildConfigField "String", "platform", '"ZhanRuiCube"'
|
||||
debuggable true
|
||||
//userdebug rom使用这个版本
|
||||
zhanRuiUserdebug.initWith(zhanRuiDebug)
|
||||
zhanRuiUserdebug {
|
||||
versionNameSuffix "-debug"
|
||||
signingConfig signingConfigs.zhanRuiUserdebug
|
||||
}
|
||||
|
||||
alldocubeDebugReleas.initWith(release)
|
||||
alldocubeDebugReleas {
|
||||
buildConfigField "String", "platform", '"ZhanRuiCube"'
|
||||
buildConfigField "String", "platform", '"ZhanRui"'
|
||||
debuggable true
|
||||
signingConfig signingConfigs.zhanRuiUserdebug
|
||||
}
|
||||
|
||||
@@ -334,7 +329,7 @@ dependencies {
|
||||
androidTestImplementation 'com.android.support.test.uiautomator:uiautomator-v18:2.1.2'
|
||||
androidTestImplementation "androidx.annotation:annotation:${ANDROID_X_VERSION}"
|
||||
//OkHttp
|
||||
implementation 'com.squareup.okhttp3:okhttp:4.9.1'
|
||||
implementation 'com.squareup.okhttp3:okhttp:4.9.2'
|
||||
//RxJava和Retrofit
|
||||
implementation 'io.reactivex.rxjava2:rxjava:2.2.21'
|
||||
implementation 'io.reactivex.rxjava2:rxandroid:2.1.1'
|
||||
|
||||
@@ -105,7 +105,7 @@ import com.aoleyun.os.model.ModelWriter;
|
||||
import com.aoleyun.os.network.bean.AppPasswdBean;
|
||||
import com.aoleyun.os.network.bean.BaseResponse;
|
||||
import com.aoleyun.os.network.HTTPInterface;
|
||||
import com.aoleyun.os.network.NetworkManager;
|
||||
import com.aoleyun.os.network.NetInterfaceManager;
|
||||
import com.aoleyun.os.network.bean.NewestAppUpdateResult;
|
||||
import com.aoleyun.os.notification.NotificationListener;
|
||||
import com.aoleyun.os.pageindicators.PageIndicatorDots;
|
||||
@@ -167,7 +167,6 @@ import java.util.Collection;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Random;
|
||||
import java.util.concurrent.Executor;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import java.util.function.Consumer;
|
||||
@@ -1157,7 +1156,7 @@ public class Launcher extends BaseDraggingActivity implements LauncherExterns,
|
||||
String app_name = APKUtils.getAppNameByPackage(Launcher.this, packageName);
|
||||
long openTime = TimeUtils.getInstance().getStartTime() / 1000;
|
||||
long closeTime = TimeUtils.getInstance().getEndTime() / 1000;
|
||||
NetworkManager.getInstance()
|
||||
NetInterfaceManager.getInstance()
|
||||
.getAppUsageRecordControl()
|
||||
.sendAppUsageRecord(Utils.getSerial(), packageName, app_name, openTime, closeTime)
|
||||
.subscribeOn(Schedulers.io())
|
||||
@@ -1371,7 +1370,7 @@ public class Launcher extends BaseDraggingActivity implements LauncherExterns,
|
||||
};
|
||||
|
||||
private void checkUpdate() {
|
||||
NetworkManager.getInstance()
|
||||
NetInterfaceManager.getInstance()
|
||||
.getCheckUpdateObservable()
|
||||
.getCheckUpdate(BuildConfig.APPLICATION_ID,
|
||||
BuildConfig.VERSION_CODE,
|
||||
|
||||
@@ -8,8 +8,8 @@ import android.util.Log;
|
||||
import com.aoleyun.os.manager.ConnectManager;
|
||||
import com.aoleyun.os.uiuiutils.ToastUtil;
|
||||
import com.aoleyun.os.uiuiutils.Utils;
|
||||
import com.aoleyun.os.network.NetworkManager;
|
||||
import com.aoleyun.os.network.URLPath;
|
||||
import com.aoleyun.os.network.NetInterfaceManager;
|
||||
import com.aoleyun.os.network.UrlAddress;
|
||||
import com.aoleyun.os.uiuiutils.JGYUtils;
|
||||
import com.aoleyun.os.uiuiutils.TimeUtils;
|
||||
import com.arialyy.aria.core.Aria;
|
||||
@@ -59,7 +59,7 @@ public class BaseApplication extends Application {
|
||||
JGYUtils.init(this);
|
||||
TimeUtils.init(this);
|
||||
Aria.init(this);
|
||||
NetworkManager.init(this);
|
||||
NetInterfaceManager.init(this);
|
||||
ToastUtil.init(this);
|
||||
ConnectManager.init(this);
|
||||
|
||||
@@ -82,7 +82,7 @@ public class BaseApplication extends Application {
|
||||
Log.e("TPush", "注册失败,错误码:" + errCode + ",错误信息:" + msg);
|
||||
}
|
||||
});
|
||||
NetworkManager.getInstance().setPushTag(true, new NetworkManager.onCompleteCallback() {
|
||||
NetInterfaceManager.getInstance().setPushTag(true, new NetInterfaceManager.onCompleteCallback() {
|
||||
@Override
|
||||
public void onComplete() {
|
||||
|
||||
@@ -317,7 +317,7 @@ public class BaseApplication extends Application {
|
||||
//https://docs.jiguang.cn/jpush/server/push/rest_api_v3_device/#_5
|
||||
OkHttpClient client = new OkHttpClient();
|
||||
Request request = new Request.Builder()
|
||||
.url(URLPath.DELETE_JPUSH_ALIAS + Utils.getSerial())
|
||||
.url(UrlAddress.DELETE_JPUSH_ALIAS + Utils.getSerial())
|
||||
.header("Authorization", key)
|
||||
.delete()
|
||||
.build();
|
||||
@@ -339,7 +339,7 @@ public class BaseApplication extends Application {
|
||||
synchronized public void cleanJpushTag() {
|
||||
OkHttpClient client = new OkHttpClient();
|
||||
Request request = new Request.Builder()
|
||||
.url(URLPath.DELETE_JPUSH_TAG + Utils.getSerial())
|
||||
.url(UrlAddress.DELETE_JPUSH_TAG + Utils.getSerial())
|
||||
.header("Authorization", key)
|
||||
.delete()
|
||||
.build();
|
||||
|
||||
@@ -18,6 +18,9 @@ public class ConnectManager {
|
||||
public static final long SIX_HOUR_TIME = ONE_HOUR_TIME * 6;
|
||||
public static final long HALF_DAY_TIME = SIX_HOUR_TIME * 2;
|
||||
public static final long ONE_DAY_TIME = HALF_DAY_TIME * 2;
|
||||
public static final long TWO_DAY_TIME = ONE_DAY_TIME * 2;
|
||||
public static final long FOUR_DAY_TIME = TWO_DAY_TIME * 2;
|
||||
public static final long A_WEEK_TIME = ONE_DAY_TIME * 7;
|
||||
|
||||
/*重启后连接成功的时间*/
|
||||
public static final String REBOOT_LAST_ONNECT_TIME = "reboot_last_connect_time";
|
||||
@@ -37,7 +40,6 @@ public class ConnectManager {
|
||||
throw new RuntimeException("Context is NULL");
|
||||
}
|
||||
this.mContext = context;
|
||||
|
||||
}
|
||||
|
||||
public static void init(Context context) {
|
||||
@@ -81,12 +83,24 @@ public class ConnectManager {
|
||||
case ONE_DAY:
|
||||
time = ONE_DAY_TIME;
|
||||
break;
|
||||
case TWO_DAY:
|
||||
time = TWO_DAY_TIME;
|
||||
break;
|
||||
case FOUR_DAY:
|
||||
time = FOUR_DAY_TIME;
|
||||
break;
|
||||
case A_WEEK:
|
||||
time = A_WEEK_TIME;
|
||||
break;
|
||||
default:
|
||||
}
|
||||
return time;
|
||||
}
|
||||
|
||||
public boolean isNeedConnect(String key, ConnectMode connectMode) {
|
||||
if (connectMode == ConnectMode.ONCE) {
|
||||
return false;
|
||||
}
|
||||
long nowTime = System.currentTimeMillis();
|
||||
long lastTime = mMMKV.decodeLong(key, 0);
|
||||
long intervalTime = getConnectModeTime(connectMode);
|
||||
|
||||
@@ -9,4 +9,8 @@ public enum ConnectMode {
|
||||
SIX_HOUR,
|
||||
HALF_DAY,
|
||||
ONE_DAY,
|
||||
TWO_DAY,
|
||||
FOUR_DAY,
|
||||
A_WEEK,
|
||||
ONCE
|
||||
}
|
||||
@@ -319,7 +319,7 @@ public class LoaderTask implements Runnable {
|
||||
final List<UserHandle> profiles = mUserManager.getUserProfiles();
|
||||
String whiteList = Settings.System.getString(crv, JGYActions.ACTION_JGY_SHORTCUTLIST);
|
||||
Log.e("verifyApplications", "whiteList: " + whiteList);
|
||||
int aihuaUnlock = Settings.Global.getInt(context.getContentResolver(), "Aihua_unlock_state", 0);
|
||||
int aihuaUnlock = Settings.System.getInt(context.getContentResolver(), "Aihua_unlock_state", 0);
|
||||
Log.e(TAG, "verifyApplications: aihuaUnlock = " + aihuaUnlock);
|
||||
for (UserHandle user : profiles) {
|
||||
final List<LauncherActivityInfo> apps = mLauncherApps.getActivityList(null, user);
|
||||
|
||||
@@ -34,7 +34,7 @@ public class HTTPInterface {
|
||||
private static final String TAG = HTTPInterface.class.getSimpleName();
|
||||
|
||||
public static void getAppPasswd() {
|
||||
NetworkManager.getInstance().getAppPasswordObservable()
|
||||
NetInterfaceManager.getInstance().getAppPasswordObservable()
|
||||
.subscribe(new Observer<BaseResponse<List<AppPasswdBean>>>() {
|
||||
@Override
|
||||
public void onSubscribe(Disposable d) {
|
||||
@@ -67,7 +67,7 @@ public class HTTPInterface {
|
||||
}
|
||||
|
||||
synchronized public static void setJpushTags(final Context context) {
|
||||
NetworkManager.getInstance()
|
||||
NetInterfaceManager.getInstance()
|
||||
.getJpushTagsObservable()
|
||||
.subscribe(new Observer<BaseResponse>() {
|
||||
@Override
|
||||
@@ -132,7 +132,7 @@ public class HTTPInterface {
|
||||
jsonObject.addProperty("app_name", APKUtils.getAppNameByPackage(context, packageName));
|
||||
jsonObject.addProperty("status", 1);
|
||||
String jsonString = jsonObject.toString();
|
||||
NetworkManager.getInstance().getRunningAppObservable(jsonString)
|
||||
NetInterfaceManager.getInstance().getRunningAppObservable(jsonString)
|
||||
.subscribe(new Observer<BaseResponse>() {
|
||||
@Override
|
||||
public void onSubscribe(Disposable d) {
|
||||
|
||||
@@ -1,18 +1,13 @@
|
||||
package com.aoleyun.os.network;
|
||||
|
||||
import android.annotation.SuppressLint;
|
||||
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;
|
||||
import com.aoleyun.os.network.api.CheckUpdate;
|
||||
@@ -20,9 +15,12 @@ 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.aoleyun.os.network.bean.AppPasswdBean;
|
||||
import com.aoleyun.os.network.bean.BaseResponse;
|
||||
import com.aoleyun.os.network.bean.Batch;
|
||||
import com.aoleyun.os.network.interceptor.RepeatRequestInterceptor;
|
||||
import com.aoleyun.os.uiuiutils.JGYUtils;
|
||||
import com.aoleyun.os.uiuiutils.Utils;
|
||||
import com.tencent.android.tpush.XGIOperateCallback;
|
||||
import com.tencent.android.tpush.XGPushManager;
|
||||
import com.tencent.mmkv.MMKV;
|
||||
@@ -41,69 +39,75 @@ import io.reactivex.disposables.Disposable;
|
||||
import io.reactivex.schedulers.Schedulers;
|
||||
import okhttp3.Cache;
|
||||
import okhttp3.OkHttpClient;
|
||||
import retrofit2.CallAdapter;
|
||||
import retrofit2.Converter;
|
||||
import retrofit2.Retrofit;
|
||||
import retrofit2.adapter.rxjava2.RxJava2CallAdapterFactory;
|
||||
import retrofit2.converter.gson.GsonConverterFactory;
|
||||
|
||||
public class NetworkManager {
|
||||
private static NetworkManager sInstance;
|
||||
public class NetInterfaceManager {
|
||||
private static final String TAG = NetInterfaceManager.class.getSimpleName();
|
||||
|
||||
@SuppressLint("StaticFieldLeak")
|
||||
private static NetInterfaceManager sInstance;
|
||||
private Context mContext;
|
||||
private Retrofit mRetrofit;
|
||||
private OkHttpClient okHttpClient;
|
||||
private MMKV mMMKV = MMKV.defaultMMKV();
|
||||
private CacheHelper cacheHelper;
|
||||
|
||||
private static Retrofit mRetrofit;
|
||||
//超时时间
|
||||
private static int timeOut = 5;
|
||||
// 缓存大小
|
||||
private static long cacheSize = 1024 * 1024 * 64;
|
||||
|
||||
private NetworkManager(Context context) {
|
||||
private static final String ROOT_URL = UrlAddress.ROOT_URL;
|
||||
|
||||
private NetInterfaceManager(Context context) {
|
||||
this.mContext = context;
|
||||
this.cacheHelper = new CacheHelper(mContext);
|
||||
|
||||
if (okHttpClient == null) {
|
||||
//如果无法生存缓存文件目录,检测权限使用已经加上,检测手机是否把文件读写权限禁止了
|
||||
OkHttpClient.Builder builder = new OkHttpClient.Builder();
|
||||
builder.connectTimeout(timeOut, TimeUnit.SECONDS); // 设置连接超时时间
|
||||
builder.writeTimeout(timeOut, TimeUnit.SECONDS);// 设置写入超时时间
|
||||
builder.readTimeout(timeOut, TimeUnit.SECONDS);// 设置读取数据超时时间
|
||||
builder.retryOnConnectionFailure(true);// 设置进行连接失败重试
|
||||
builder.addInterceptor(new RepeatRequestInterceptor());
|
||||
|
||||
// 设置缓存文件路径
|
||||
String cacheDirectory = mContext.getExternalCacheDir().getAbsolutePath() + "/OkHttpCache";
|
||||
Cache cache = new Cache(new File(cacheDirectory), cacheSize);
|
||||
builder.cache(cache);// 设置缓存
|
||||
okHttpClient = builder.build();
|
||||
}
|
||||
|
||||
if (null == mRetrofit) {
|
||||
mRetrofit = new Retrofit.Builder()
|
||||
.client(okHttpClient)
|
||||
.baseUrl(ROOT_URL)
|
||||
.addConverterFactory(gsonConverterFactory)
|
||||
.addCallAdapterFactory(rxJavaCallAdapterFactory)
|
||||
.addConverterFactory(GsonConverterFactory.create())
|
||||
.addCallAdapterFactory(RxJava2CallAdapterFactory.create())
|
||||
.build();
|
||||
}
|
||||
}
|
||||
|
||||
public static void init(Context context) {
|
||||
if (sInstance == null) {
|
||||
sInstance = new NetworkManager(context);
|
||||
if (context == null) {
|
||||
throw new RuntimeException("Context is NULL");
|
||||
}
|
||||
if (sInstance == null) {
|
||||
sInstance = new NetInterfaceManager(context);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public static NetworkManager getInstance() {
|
||||
public static NetInterfaceManager getInstance() {
|
||||
if (sInstance == null) {
|
||||
throw new IllegalStateException("You must be init NetworkManager first");
|
||||
}
|
||||
return sInstance;
|
||||
}
|
||||
|
||||
private static final String ROOT_URL = URLPath.ROOT_URL;
|
||||
|
||||
private static final long CACHE_SIZE = 1024 * 1024 * 32;// 缓存文件最大限制大小20M
|
||||
private static String cacheDirectory = Environment.getExternalStorageDirectory() + "/okttpcaches"; // 设置缓存文件路径
|
||||
private static Cache cache = new Cache(new File(cacheDirectory), CACHE_SIZE); //
|
||||
private static final OkHttpClient okHttpClient;
|
||||
private static final int TIME_OUT = 5;
|
||||
|
||||
static {
|
||||
//如果无法生存缓存文件目录,检测权限使用已经加上,检测手机是否把文件读写权限禁止了
|
||||
OkHttpClient.Builder builder = new OkHttpClient.Builder();
|
||||
builder.connectTimeout(TIME_OUT, TimeUnit.SECONDS); // 设置连接超时时间
|
||||
builder.writeTimeout(TIME_OUT, TimeUnit.SECONDS);// 设置写入超时时间
|
||||
builder.readTimeout(TIME_OUT, TimeUnit.SECONDS);// 设置读取数据超时时间
|
||||
builder.retryOnConnectionFailure(true);// 设置进行连接失败重试
|
||||
builder.cache(cache);// 设置缓存
|
||||
okHttpClient = builder.build();
|
||||
}
|
||||
|
||||
private static CallAdapter.Factory rxJavaCallAdapterFactory = RxJava2CallAdapterFactory.create();
|
||||
private static Converter.Factory gsonConverterFactory = GsonConverterFactory.create();
|
||||
|
||||
public Observable<BaseResponse> getRunningAppObservable(String json) {
|
||||
return mRetrofit.create(RunningApp.class)
|
||||
@@ -154,19 +158,19 @@ public class NetworkManager {
|
||||
}
|
||||
|
||||
public void setPushTag(boolean refresh, onCompleteCallback callback) {
|
||||
ConnectMode connectMode = ConnectMode.ONE_DAY;
|
||||
ConnectMode connectMode = ConnectMode.TWO_DAY;
|
||||
if (refresh) {
|
||||
connectMode = ConnectMode.FIFTEEN_MINUTES;
|
||||
connectMode = ConnectMode.ONE_DAY;
|
||||
}
|
||||
if (ConnectManager.getInstance().isNeedConnect(URLPath.GET_DEVICES_TAGS, connectMode)) {
|
||||
if (ConnectManager.getInstance().isNeedConnect(UrlAddress.GET_DEVICES_TAGS, connectMode)) {
|
||||
setPushTag(callback);
|
||||
} else {
|
||||
String jsonString = cacheHelper.getAsString(URLPath.GET_DEVICES_TAGS);
|
||||
String jsonString = cacheHelper.getAsString(UrlAddress.GET_DEVICES_TAGS);
|
||||
//为 "" 是已经请求成功的
|
||||
if (jsonString == null) {
|
||||
setPushTag(callback);
|
||||
} else {
|
||||
Set tagSets = mMMKV.decodeStringSet(URLPath.GET_DEVICES_TAGS);
|
||||
Set tagSets = mMMKV.decodeStringSet(UrlAddress.GET_DEVICES_TAGS);
|
||||
Log.e("setPushTags", "tagSets: " + tagSets);
|
||||
clearAndAppendTags(tagSets);
|
||||
callback.onComplete();
|
||||
@@ -199,14 +203,14 @@ public class NetworkManager {
|
||||
Log.e("setPushTag", "onNext: " + response);
|
||||
if (response.code == 200) {
|
||||
String batch = response.data.getBatch();
|
||||
cacheHelper.put(URLPath.GET_DEVICES_TAGS, batch);
|
||||
cacheHelper.put(UrlAddress.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, "");
|
||||
cacheHelper.put(UrlAddress.GET_DEVICES_TAGS, "");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -219,7 +223,7 @@ public class NetworkManager {
|
||||
@Override
|
||||
public void onComplete() {
|
||||
Log.e("setPushTag", "onComplete: ");
|
||||
mMMKV.encode(URLPath.GET_DEVICES_TAGS, set);
|
||||
mMMKV.encode(UrlAddress.GET_DEVICES_TAGS, set);
|
||||
clearAndAppendTags(set);
|
||||
callback.onComplete();
|
||||
}
|
||||
@@ -1,6 +1,6 @@
|
||||
package com.aoleyun.os.network;
|
||||
|
||||
public class URLPath {
|
||||
public class UrlAddress {
|
||||
public static final String ROOT_URL = "https://led.aoleyun.cn/api/";
|
||||
public static final String APP_LOG = "app/addAppLog";
|
||||
//获取正在运行的app
|
||||
@@ -1,7 +1,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.UrlAddress;
|
||||
|
||||
import io.reactivex.Observable;
|
||||
import retrofit2.http.Field;
|
||||
@@ -10,7 +10,7 @@ import retrofit2.http.POST;
|
||||
|
||||
public interface AddAppLog {
|
||||
@FormUrlEncoded
|
||||
@POST(URLPath.APP_LOG)
|
||||
@POST(UrlAddress.APP_LOG)
|
||||
Observable<BaseResponse> addLog(
|
||||
@Field("sn") String sn,
|
||||
@Field("packageName") String packageName,
|
||||
|
||||
@@ -1,7 +1,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.UrlAddress;
|
||||
|
||||
|
||||
import io.reactivex.Observable;
|
||||
@@ -11,7 +11,7 @@ import retrofit2.http.POST;
|
||||
|
||||
public interface AppUsageRecordApi {
|
||||
@FormUrlEncoded
|
||||
@POST(URLPath.SEND_APP_RECORD)
|
||||
@POST(UrlAddress.SEND_APP_RECORD)
|
||||
Observable<BaseResponse> sendAppUsageRecord(
|
||||
@Field("sn") String sn,
|
||||
@Field("app_package") String app_package,
|
||||
|
||||
@@ -2,7 +2,7 @@ package com.aoleyun.os.network.api;
|
||||
|
||||
import com.aoleyun.os.network.bean.BaseResponse;
|
||||
import com.aoleyun.os.network.bean.NewestAppUpdateResult;
|
||||
import com.aoleyun.os.network.URLPath;
|
||||
import com.aoleyun.os.network.UrlAddress;
|
||||
|
||||
import io.reactivex.Observable;
|
||||
import retrofit2.http.Field;
|
||||
@@ -11,7 +11,7 @@ import retrofit2.http.POST;
|
||||
|
||||
public interface CheckUpdate {
|
||||
@FormUrlEncoded
|
||||
@POST(URLPath.GET_NEWESTAPPUPDATE)
|
||||
@POST(UrlAddress.GET_NEWESTAPPUPDATE)
|
||||
Observable<BaseResponse<NewestAppUpdateResult>> getCheckUpdate(
|
||||
@Field("package")String packageName,
|
||||
@Field("versionCode")int versionCode,
|
||||
|
||||
@@ -2,7 +2,7 @@ package com.aoleyun.os.network.api;
|
||||
|
||||
import com.aoleyun.os.network.bean.AppPasswdBean;
|
||||
import com.aoleyun.os.network.bean.BaseResponse;
|
||||
import com.aoleyun.os.network.URLPath;
|
||||
import com.aoleyun.os.network.UrlAddress;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@@ -18,7 +18,7 @@ import retrofit2.http.Query;
|
||||
* version: 1.0
|
||||
*/
|
||||
public interface GetAppPassword {
|
||||
@GET(URLPath.GET_APP_PASSWD)
|
||||
@GET(UrlAddress.GET_APP_PASSWD)
|
||||
Observable<BaseResponse<List<AppPasswdBean>>> getAppPasswd(
|
||||
@Query("sn") String sn
|
||||
);
|
||||
|
||||
@@ -2,7 +2,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.UrlAddress;
|
||||
import com.aoleyun.os.network.bean.Batch;
|
||||
|
||||
import io.reactivex.Observable;
|
||||
@@ -10,7 +10,7 @@ import retrofit2.http.GET;
|
||||
import retrofit2.http.Query;
|
||||
|
||||
public interface GetJpushTagsApi {
|
||||
@GET(URLPath.GET_DEVICES_TAGS)
|
||||
@GET(UrlAddress.GET_DEVICES_TAGS)
|
||||
Observable<BaseResponse<Batch>> getJpushTags(
|
||||
@Query("sn") String sn
|
||||
);
|
||||
|
||||
@@ -1,7 +1,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.UrlAddress;
|
||||
|
||||
import io.reactivex.Observable;
|
||||
import retrofit2.http.Field;
|
||||
@@ -10,7 +10,7 @@ import retrofit2.http.POST;
|
||||
|
||||
public interface RunningApp {
|
||||
@FormUrlEncoded
|
||||
@POST(URLPath.RUN_NEW_APP)
|
||||
@POST(UrlAddress.RUN_NEW_APP)
|
||||
Observable<BaseResponse> sendRunningInfo(
|
||||
@Field("sn") String sn,
|
||||
@Field("app") String app
|
||||
|
||||
@@ -1,7 +1,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.UrlAddress;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
@@ -14,7 +14,7 @@ import retrofit2.http.QueryMap;
|
||||
|
||||
public interface SendScreenshotApi {
|
||||
@Multipart
|
||||
@POST(URLPath.SEND_SCREENSHOT)
|
||||
@POST(UrlAddress.SEND_SCREENSHOT)
|
||||
Observable<BaseResponse> sendScreenshot(
|
||||
@QueryMap Map<String, String> params,
|
||||
@Part MultipartBody.Part body
|
||||
|
||||
@@ -0,0 +1,107 @@
|
||||
package com.aoleyun.os.network.interceptor;
|
||||
|
||||
import android.util.Log;
|
||||
|
||||
import com.aoleyun.os.BuildConfig;
|
||||
import com.aoleyun.os.uiuiutils.MD5Util;
|
||||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
|
||||
import okhttp3.Interceptor;
|
||||
import okhttp3.Protocol;
|
||||
import okhttp3.Request;
|
||||
import okhttp3.RequestBody;
|
||||
import okhttp3.Response;
|
||||
import okhttp3.ResponseBody;
|
||||
import okio.Buffer;
|
||||
|
||||
/**
|
||||
* v1.0 2022-07-15 16:16:52
|
||||
*/
|
||||
public class RepeatRequestInterceptor implements Interceptor {
|
||||
private static final String TAG = RepeatRequestInterceptor.class.getSimpleName();
|
||||
|
||||
private final ConcurrentHashMap<String, Long> requestIdsMap = new ConcurrentHashMap<>();
|
||||
public static final String REPEAT_REQUEST_PROTOCOL = "OKHTTP_REPEAT_REQUEST_PROTOCOL";
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public Response intercept(@NotNull Chain chain) throws IOException {
|
||||
Request request = chain.request();
|
||||
Response response = chain.proceed(request);
|
||||
ResponseBody responseBody = response.body();
|
||||
|
||||
//会消费请求,导致请求多次
|
||||
String content = responseBody.string();
|
||||
// Response copy = response.newBuilder().body(responseBody).build();
|
||||
ResponseBody copy = ResponseBody.create(responseBody.contentType(), content);
|
||||
if (BuildConfig.DEBUG) {
|
||||
Log.e(TAG, "请求体返回:| Response: " + request.url().encodedPath() + "\t body: " + content);
|
||||
}
|
||||
//相同的请求
|
||||
String requestKey = MD5Util.getUpperMD5Str(request.method() + request.url().toString() + requestBodyToString(request.body()));
|
||||
long time = System.currentTimeMillis();//请求时间
|
||||
try {
|
||||
if (requestIdsMap.size() > 0 && requestIdsMap.containsKey(requestKey)) {
|
||||
log("重复请求:", requestKey, request);
|
||||
//下面这行写了不会抛出onerror
|
||||
// chain.call().cancel();
|
||||
return new Response.Builder()
|
||||
.protocol(Protocol.get(REPEAT_REQUEST_PROTOCOL))
|
||||
.request(request) //multi thread
|
||||
.build();
|
||||
}
|
||||
requestIdsMap.put(requestKey, time);
|
||||
log("注册请求:", requestKey, request);
|
||||
// RepeatRequestInterceptor.Builder builder = request.newBuilder();
|
||||
// builder.addHeader("header", jsonObject.toString());
|
||||
return response.newBuilder().body(copy).build();
|
||||
} catch (IOException e) {
|
||||
Log.e(TAG, "intercept: " + e.getMessage());
|
||||
throw e;
|
||||
} finally {
|
||||
if (requestIdsMap.containsKey(requestKey) && requestIdsMap.containsValue(time)) {//请求任务完成删除map中的数据
|
||||
requestIdsMap.remove(requestKey);
|
||||
log("移除请求:", requestKey, request);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void log(String action, String requestKey, Request request) {
|
||||
if (BuildConfig.DEBUG) {
|
||||
Log.e("REPEAT-REQUEST", action + requestKey + " Method @" + request.method() + " --- " + " URL = " + request.url().encodedPath() + "\t" + bodyToString(request));
|
||||
} else {
|
||||
Log.e("REPEAT-REQUEST", action + requestKey + " Method @" + request.method());
|
||||
}
|
||||
}
|
||||
|
||||
private static String bodyToString(final Request request) {
|
||||
try {
|
||||
final Request copy = request.newBuilder().build();
|
||||
final Buffer buffer = new Buffer();
|
||||
copy.body().writeTo(buffer);
|
||||
if (buffer.size() > 4096) {
|
||||
return "-too long";
|
||||
}
|
||||
return buffer.readUtf8();
|
||||
} catch (Exception e) {
|
||||
return "-";
|
||||
}
|
||||
}
|
||||
|
||||
private static String requestBodyToString(RequestBody body) {
|
||||
try {
|
||||
final Buffer buffer = new Buffer();
|
||||
body.writeTo(buffer);
|
||||
if (buffer.size() > 4096) {
|
||||
return "-too long";
|
||||
}
|
||||
return buffer.readUtf8();
|
||||
} catch (Exception e) {
|
||||
return "-";
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -11,7 +11,7 @@ import android.text.TextUtils;
|
||||
import android.util.Log;
|
||||
|
||||
import com.aoleyun.os.BuildConfig;
|
||||
import com.aoleyun.os.network.NetworkManager;
|
||||
import com.aoleyun.os.network.NetInterfaceManager;
|
||||
import com.aoleyun.os.network.bean.BaseResponse;
|
||||
import com.aoleyun.os.uiuiutils.APKUtils;
|
||||
import com.aoleyun.os.uiuiutils.CmdUtil;
|
||||
@@ -185,7 +185,7 @@ public class MainService extends Service {
|
||||
Map<String, String> params = new HashMap<>();
|
||||
params.put("sn", Utils.getSerial());
|
||||
params.put("createtime", String.valueOf(time));
|
||||
NetworkManager.getInstance().getScreenshotApi()
|
||||
NetInterfaceManager.getInstance().getScreenshotApi()
|
||||
.sendScreenshot(params, body)
|
||||
.subscribeOn(Schedulers.io())
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
|
||||
@@ -45,6 +45,7 @@ import com.aoleyun.os.Launcher;
|
||||
import com.aoleyun.os.LauncherAppWidgetInfo;
|
||||
import com.aoleyun.os.LauncherAppWidgetProviderInfo;
|
||||
import com.aoleyun.os.uiuiutils.CustomDialog;
|
||||
import com.aoleyun.os.uiuiutils.JGYUtils;
|
||||
import com.aoleyun.os.uiuiutils.ToastUtil;
|
||||
import com.aoleyun.os.base.BaseApplication;
|
||||
import com.aoleyun.os.PromiseAppInfo;
|
||||
@@ -162,7 +163,7 @@ public class ItemClickHandler {
|
||||
//写入正在运行的app的包名和时间
|
||||
TimeUtils.getInstance().setAppPackageName(packageName);
|
||||
TimeUtils.getInstance().setStartTime(System.currentTimeMillis());
|
||||
HTTPInterface.sendRunningApp(BaseApplication.getContext());
|
||||
// HTTPInterface.sendRunningApp(BaseApplication.getContext());
|
||||
} else if (tag instanceof FolderInfo) {
|
||||
if (v instanceof FolderIcon) {
|
||||
onClickFolderIcon(v);
|
||||
@@ -182,6 +183,9 @@ public class ItemClickHandler {
|
||||
}
|
||||
|
||||
private static boolean is_forbid(Context context, String pkg) {
|
||||
if (JGYUtils.isUnlocked(context)) {
|
||||
return false;
|
||||
}
|
||||
switch (pkg) {
|
||||
case "com.mediatek.camera":
|
||||
case "com.android.camera2":
|
||||
|
||||
@@ -257,5 +257,11 @@ public class JGYUtils {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
public static boolean isUnlocked(Context context) {
|
||||
int locked = Settings.System.getInt(context.getContentResolver(), "qch_unlock_ipad", 0);
|
||||
int aihuaUnlock = Settings.System.getInt(context.getContentResolver(), "Aihua_unlock_state", 0);
|
||||
return locked == 1 || aihuaUnlock == 1;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
112
src/com/aoleyun/os/uiuiutils/MD5Util.java
Normal file
112
src/com/aoleyun/os/uiuiutils/MD5Util.java
Normal file
@@ -0,0 +1,112 @@
|
||||
package com.aoleyun.os.uiuiutils;
|
||||
|
||||
import android.annotation.SuppressLint;
|
||||
|
||||
import java.io.UnsupportedEncodingException;
|
||||
import java.security.MessageDigest;
|
||||
import java.security.NoSuchAlgorithmException;
|
||||
|
||||
public class MD5Util {
|
||||
|
||||
public static String packetMD5(String str) {
|
||||
MessageDigest messageDigest = null;
|
||||
try {
|
||||
messageDigest = MessageDigest.getInstance("MD5");
|
||||
|
||||
messageDigest.reset();
|
||||
|
||||
messageDigest.update(str.getBytes("UTF-8"));
|
||||
} catch (NoSuchAlgorithmException e) {
|
||||
System.out.println("NoSuchAlgorithmException caught!");
|
||||
System.exit(-1);
|
||||
} catch (UnsupportedEncodingException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
byte[] byteArray = messageDigest.digest();
|
||||
|
||||
StringBuffer md5StrBuff = new StringBuffer();
|
||||
|
||||
for (int i = 0; i < byteArray.length; i++) {
|
||||
if (Integer.toHexString(0xFF & byteArray[i]).length() == 1)
|
||||
md5StrBuff.append("0").append(
|
||||
Integer.toHexString(0xFF & byteArray[i]));
|
||||
else
|
||||
md5StrBuff.append(Integer.toHexString(0xFF & byteArray[i]));
|
||||
}
|
||||
|
||||
return md5StrBuff.toString();
|
||||
}
|
||||
|
||||
@SuppressLint("DefaultLocale")
|
||||
public static String getUpperMD5Str(String str) {
|
||||
MessageDigest messageDigest = null;
|
||||
|
||||
try {
|
||||
messageDigest = MessageDigest.getInstance("MD5");
|
||||
|
||||
messageDigest.reset();
|
||||
|
||||
messageDigest.update(str.getBytes("UTF-8"));
|
||||
} catch (NoSuchAlgorithmException e) {
|
||||
System.out.println("NoSuchAlgorithmException caught!");
|
||||
System.exit(-1);
|
||||
} catch (UnsupportedEncodingException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
byte[] byteArray = messageDigest.digest();
|
||||
|
||||
StringBuffer md5StrBuff = new StringBuffer();
|
||||
|
||||
for (int i = 0; i < byteArray.length; i++) {
|
||||
if (Integer.toHexString(0xFF & byteArray[i]).length() == 1)
|
||||
md5StrBuff.append("0").append(
|
||||
Integer.toHexString(0xFF & byteArray[i]));
|
||||
else
|
||||
md5StrBuff.append(Integer.toHexString(0xFF & byteArray[i]));
|
||||
}
|
||||
|
||||
return md5StrBuff.toString().toUpperCase();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 获取16位的MD5 值得
|
||||
*
|
||||
* @param str
|
||||
* @return
|
||||
*/
|
||||
@SuppressLint("DefaultLocale")
|
||||
public static String getUpperMD5Str16(String str) {
|
||||
MessageDigest messageDigest = null;
|
||||
|
||||
try {
|
||||
messageDigest = MessageDigest.getInstance("MD5");
|
||||
|
||||
messageDigest.reset();
|
||||
|
||||
messageDigest.update(str.getBytes("UTF-8"));
|
||||
} catch (NoSuchAlgorithmException e) {
|
||||
System.out.println("NoSuchAlgorithmException caught!");
|
||||
System.exit(-1);
|
||||
} catch (UnsupportedEncodingException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
byte[] byteArray = messageDigest.digest();
|
||||
|
||||
StringBuffer md5StrBuff = new StringBuffer();
|
||||
|
||||
for (int i = 0; i < byteArray.length; i++) {
|
||||
if (Integer.toHexString(0xFF & byteArray[i]).length() == 1)
|
||||
md5StrBuff.append("0").append(
|
||||
Integer.toHexString(0xFF & byteArray[i]));
|
||||
else
|
||||
md5StrBuff.append(Integer.toHexString(0xFF & byteArray[i]));
|
||||
}
|
||||
|
||||
return md5StrBuff.toString().toUpperCase().substring(8, 24);
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user