version:1.0.8
fix: update:优化管控
This commit is contained in:
@@ -55,6 +55,7 @@
|
||||
<uses-permission android:name="android.permission.RECEIVE_USER_PRESENT" />
|
||||
<uses-permission android:name="android.permission.READ_PHONE_STATE" />
|
||||
<uses-permission android:name="android.permission.GET_TASKS" />
|
||||
<uses-permission android:name="android.permission.KILL_BACKGROUND_PROCESSES" />
|
||||
|
||||
|
||||
<!--
|
||||
|
||||
47
build.gradle
47
build.gradle
@@ -50,8 +50,8 @@ android {
|
||||
minSdkVersion 26
|
||||
targetSdkVersion 28
|
||||
|
||||
versionCode 3
|
||||
versionName "1.0.2"
|
||||
versionCode 9
|
||||
versionName "1.0.8"
|
||||
|
||||
ndk {
|
||||
//选择要添加的对应 cpu 类型的 .so 库。
|
||||
@@ -77,6 +77,15 @@ android {
|
||||
keyPassword "123456"
|
||||
v2SigningEnabled false
|
||||
}
|
||||
|
||||
iPlay50SE {
|
||||
storeFile file("src/doc/iPlay50SE.keystore")
|
||||
storePassword "123456"
|
||||
keyAlias "iplay50se"
|
||||
keyPassword "123456"
|
||||
v1SigningEnabled true
|
||||
v2SigningEnabled true
|
||||
}
|
||||
}
|
||||
|
||||
buildTypes {
|
||||
@@ -94,6 +103,20 @@ android {
|
||||
signingConfig signingConfigs.U807
|
||||
}
|
||||
|
||||
iPlay50SEDebug.initWith(debug)
|
||||
iPlay50SEDebug {
|
||||
buildConfigField "String", "platform", '"iPaly50SE"'
|
||||
versionNameSuffix "-debug"
|
||||
debuggable true
|
||||
signingConfig signingConfigs.iPlay50SE
|
||||
}
|
||||
|
||||
iPlay50SERelease.initWith(release)
|
||||
iPlay50SERelease {
|
||||
buildConfigField "String", "platform", '"iPaly50SE"'
|
||||
signingConfig signingConfigs.iPlay50SE
|
||||
}
|
||||
|
||||
debug {
|
||||
buildConfigField "String", "platform", '"MTK"'
|
||||
debuggable true
|
||||
@@ -286,12 +309,22 @@ dependencies {
|
||||
androidTestImplementation "androidx.annotation:annotation:${ANDROID_X_VERSION}"
|
||||
//OkHttp
|
||||
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'
|
||||
//RxJava
|
||||
implementation 'io.reactivex.rxjava3:rxjava:3.0.0'
|
||||
implementation 'io.reactivex.rxjava3:rxandroid:3.0.0'
|
||||
//Retrofit
|
||||
implementation 'com.squareup.retrofit2:retrofit:2.9.0'
|
||||
implementation 'com.squareup.retrofit2:adapter-rxjava3:2.9.0'
|
||||
// gson converter
|
||||
implementation 'com.squareup.retrofit2:converter-gson:2.9.0'
|
||||
implementation 'com.squareup.retrofit2:adapter-rxjava2:2.9.0'
|
||||
// 标准转换器,去掉 Retrofit以Mutipart上传参数时,String参数会多一对双引号
|
||||
implementation 'com.squareup.retrofit2:converter-scalars:2.3.0'
|
||||
//生命周期管理
|
||||
implementation 'com.trello.rxlifecycle4:rxlifecycle:4.0.2'
|
||||
implementation 'com.trello.rxlifecycle4:rxlifecycle-android:4.0.2'
|
||||
implementation 'com.trello.rxlifecycle4:rxlifecycle-components:4.0.2'
|
||||
implementation 'com.trello.rxlifecycle4:rxlifecycle-components-preference:4.0.2'
|
||||
implementation 'com.trello.rxlifecycle4:rxlifecycle-android-lifecycle:4.0.2'
|
||||
//gson
|
||||
implementation 'com.google.code.gson:gson:2.9.0'
|
||||
//磁盘缓存
|
||||
@@ -305,6 +338,8 @@ dependencies {
|
||||
annotationProcessor 'me.laoyuyu.aria:compiler:3.8.16'
|
||||
//工具类
|
||||
implementation 'com.blankj:utilcodex:1.31.0'
|
||||
implementation 'com.tencent.bugly:crashreport:4.1.9.2'
|
||||
implementation 'com.iqiyi.xcrash:xcrash-android-lib:3.0.0'
|
||||
}
|
||||
|
||||
preBuild {
|
||||
|
||||
@@ -15,18 +15,8 @@ android {
|
||||
buildTypes {
|
||||
U807Debug {}
|
||||
U807Release {}
|
||||
G10PDebug {}
|
||||
G10PRelease {}
|
||||
zhanRuiDebug {}
|
||||
zhanRuiRelease {}
|
||||
zhanRui12Debug {}
|
||||
zhanRui12Release {}
|
||||
alldocubeDebug {}
|
||||
alldocubeDebugReleas {}
|
||||
TeclastP20SDebug {}
|
||||
TeclastP20SRelease {}
|
||||
zhanruiG10ZDebug {}
|
||||
zhanruiG10ZRelease {}
|
||||
iPlay50SEDebug {}
|
||||
iPlay50SERelease {}
|
||||
debug {}
|
||||
release {}
|
||||
}
|
||||
|
||||
@@ -217,14 +217,12 @@
|
||||
launcher:x="1"
|
||||
launcher:y="0" />
|
||||
|
||||
<favorite
|
||||
launcher:className="com.cube.setlauncherdef.MainActivity"
|
||||
launcher:icon="@drawable/system_switch"
|
||||
launcher:packageName="com.cube.setlauncherdef"
|
||||
launcher:screen="0"
|
||||
launcher:x="2"
|
||||
launcher:y="0" />
|
||||
|
||||
<!-- <favorite-->
|
||||
<!-- launcher:className="com.cube.setlauncherdef.MainActivity"-->
|
||||
<!-- launcher:icon="@drawable/system_switch"-->
|
||||
<!-- launcher:packageName="com.cube.setlauncherdef"-->
|
||||
<!-- launcher:screen="0"-->
|
||||
<!-- launcher:x="2"-->
|
||||
<!-- launcher:y="0" />-->
|
||||
</folder>
|
||||
|
||||
</favorites>
|
||||
@@ -135,8 +135,8 @@
|
||||
launcher:name="Large Phone"
|
||||
launcher:minWidthDps="406"
|
||||
launcher:minHeightDps="694"
|
||||
launcher:iconImageSize="90"
|
||||
launcher:iconTextSize="16"
|
||||
launcher:iconImageSize="80"
|
||||
launcher:iconTextSize="14.4"
|
||||
launcher:canBeDefault="true" />
|
||||
|
||||
<!-- <display-option-->
|
||||
|
||||
@@ -34,8 +34,8 @@ import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.content.IntentFilter;
|
||||
import android.content.IntentSender;
|
||||
import android.content.ServiceConnection;
|
||||
import android.content.SharedPreferences;
|
||||
import android.content.pm.PackageInfo;
|
||||
import android.content.pm.PackageManager;
|
||||
import android.content.pm.ResolveInfo;
|
||||
import android.content.res.Configuration;
|
||||
@@ -45,8 +45,8 @@ import android.graphics.Point;
|
||||
import android.graphics.Rect;
|
||||
import android.os.Build;
|
||||
import android.os.Bundle;
|
||||
import android.os.Environment;
|
||||
import android.os.Handler;
|
||||
import android.os.IBinder;
|
||||
import android.os.Parcelable;
|
||||
import android.os.Process;
|
||||
import android.os.StrictMode;
|
||||
@@ -69,13 +69,14 @@ import android.view.animation.OvershootInterpolator;
|
||||
import android.widget.Toast;
|
||||
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.core.content.ContextCompat;
|
||||
|
||||
import com.alibaba.sdk.android.push.CloudPushService;
|
||||
import com.alibaba.sdk.android.push.CommonCallback;
|
||||
import com.alibaba.sdk.android.push.noonesdk.PushServiceFactory;
|
||||
import com.uiuipad.os.DropTarget.DragObject;
|
||||
import com.uiuipad.os.uiuiutils.APKUtils;
|
||||
import com.uiuipad.os.network.bean.TimeManageApp;
|
||||
import com.uiuipad.os.network.bean.TimeManageSn;
|
||||
import com.uiuipad.os.uiuiutils.ApkUtils;
|
||||
import com.uiuipad.os.uiuiutils.Utils;
|
||||
import com.uiuipad.os.accessibility.LauncherAccessibilityDelegate;
|
||||
import com.uiuipad.os.allapps.AllAppsContainerView;
|
||||
@@ -106,7 +107,6 @@ import com.uiuipad.os.model.ModelWriter;
|
||||
import com.uiuipad.os.network.bean.AppPasswdBean;
|
||||
import com.uiuipad.os.network.bean.BaseResponse;
|
||||
import com.uiuipad.os.network.NetInterfaceManager;
|
||||
import com.uiuipad.os.network.bean.NewestAppUpdateResult;
|
||||
import com.uiuipad.os.notification.NotificationListener;
|
||||
import com.uiuipad.os.pageindicators.PageIndicatorDots;
|
||||
import com.uiuipad.os.popup.PopupContainerWithArrow;
|
||||
@@ -152,12 +152,10 @@ import com.uiuipad.os.widget.WidgetHostViewLoader;
|
||||
import com.uiuipad.os.widget.WidgetListRowEntry;
|
||||
import com.uiuipad.os.widget.WidgetsFullSheet;
|
||||
import com.uiuipad.os.widget.custom.CustomWidgetParser;
|
||||
import com.arialyy.aria.core.Aria;
|
||||
import com.google.gson.Gson;
|
||||
import com.google.gson.reflect.TypeToken;
|
||||
import com.tencent.mmkv.MMKV;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileDescriptor;
|
||||
import java.io.IOException;
|
||||
import java.io.PrintWriter;
|
||||
@@ -167,18 +165,18 @@ import java.util.Collection;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.Executor;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import java.util.function.Consumer;
|
||||
import java.util.function.Predicate;
|
||||
|
||||
import io.reactivex.Observable;
|
||||
import io.reactivex.ObservableEmitter;
|
||||
import io.reactivex.ObservableOnSubscribe;
|
||||
import io.reactivex.Observer;
|
||||
import io.reactivex.android.schedulers.AndroidSchedulers;
|
||||
import io.reactivex.disposables.Disposable;
|
||||
import io.reactivex.schedulers.Schedulers;
|
||||
import io.reactivex.rxjava3.core.Observable;
|
||||
import io.reactivex.rxjava3.core.ObservableEmitter;
|
||||
import io.reactivex.rxjava3.core.ObservableOnSubscribe;
|
||||
import io.reactivex.rxjava3.core.Observer;
|
||||
import io.reactivex.rxjava3.disposables.Disposable;
|
||||
import okhttp3.RequestBody;
|
||||
|
||||
import static android.content.pm.ActivityInfo.CONFIG_LOCALE;
|
||||
import static android.content.pm.ActivityInfo.CONFIG_ORIENTATION;
|
||||
@@ -344,7 +342,11 @@ public class Launcher extends BaseDraggingActivity implements LauncherExterns,
|
||||
Observable.create(updateSubscribe)
|
||||
.throttleFirst(6, TimeUnit.HOURS)
|
||||
.subscribe(updateObserver);
|
||||
startService(new Intent(Launcher.this, MainService.class));
|
||||
|
||||
Intent intent = new Intent(Launcher.this, MainService.class);
|
||||
bindService(intent, serviceConnect, BIND_AUTO_CREATE);
|
||||
startService(intent);
|
||||
|
||||
if (DEBUG_STRICT_MODE) {
|
||||
StrictMode.setThreadPolicy(new StrictMode.ThreadPolicy.Builder()
|
||||
.detectDiskReads()
|
||||
@@ -426,7 +428,7 @@ public class Launcher extends BaseDraggingActivity implements LauncherExterns,
|
||||
|
||||
if (!isDefaultHome()) {
|
||||
// setDefaultL();
|
||||
// setRoleHolderAsUser(this, BuildConfig.APPLICATION_ID);
|
||||
setRoleHolderAsUser(this, BuildConfig.APPLICATION_ID);
|
||||
}
|
||||
SharedPreferences sharedPref = getPreferences(MODE_PRIVATE);
|
||||
int i = sharedPref.getInt("SetWallPaper", 0);
|
||||
@@ -521,6 +523,23 @@ public class Launcher extends BaseDraggingActivity implements LauncherExterns,
|
||||
});
|
||||
}
|
||||
|
||||
MainService.MainBinder mMainBinder;
|
||||
private ServiceConnect serviceConnect = new ServiceConnect();
|
||||
|
||||
private class ServiceConnect implements ServiceConnection {
|
||||
@Override
|
||||
public void onServiceConnected(ComponentName name, IBinder service) {
|
||||
Log.e(TAG, "onServiceConnected: ");
|
||||
mMainBinder = (MainService.MainBinder) service;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onServiceDisconnected(ComponentName name) {
|
||||
Log.e(TAG, "onServiceDisconnected: ");
|
||||
mMainBinder = null;
|
||||
}
|
||||
}
|
||||
|
||||
private void SetWallPaper() {
|
||||
//利用WallpaparManager,添加权限set_wallpaper
|
||||
WallpaperManager wallpaperManager = WallpaperManager.getInstance(this);
|
||||
@@ -1150,8 +1169,47 @@ public class Launcher extends BaseDraggingActivity implements LauncherExterns,
|
||||
Log.e("onStart", "app = null" + packageName);
|
||||
return;
|
||||
}
|
||||
sendAppUsageRecord(packageName);
|
||||
|
||||
}
|
||||
|
||||
private void sendAppUsageRecord(String packageName) {
|
||||
Log.e("sendAppUsageRecord", "packageName: " + packageName);
|
||||
String app_name = ApkUtils.getAppNameByPackage(Launcher.this, packageName);
|
||||
long openTime = TimeUtils.getInstance().getStartTime() / 1000;
|
||||
long closeTime = TimeUtils.getInstance().getEndTime() / 1000;
|
||||
Map<String, RequestBody> params = new HashMap<>();
|
||||
params.put("sn", NetInterfaceManager.convertToRequestBody(Utils.getSerial(this)));
|
||||
params.put("app_name", NetInterfaceManager.convertToRequestBody(app_name));
|
||||
params.put("app_package", NetInterfaceManager.convertToRequestBody(packageName));
|
||||
params.put("open_time", NetInterfaceManager.convertToRequestBody(openTime));
|
||||
params.put("close_time", NetInterfaceManager.convertToRequestBody(closeTime));
|
||||
NetInterfaceManager.getInstance()
|
||||
.getUploadAppUseLogObservable(params)
|
||||
.subscribe(new Observer<BaseResponse>() {
|
||||
@Override
|
||||
public void onSubscribe(Disposable d) {
|
||||
Log.e("sendAppUsageRecord", "onSubscribe: ");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNext(BaseResponse baseResponse) {
|
||||
Log.e("sendAppUsageRecord", "onNext: " + baseResponse);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(Throwable e) {
|
||||
Log.e("sendAppUsageRecord", "onError: " + e.getMessage());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onComplete() {
|
||||
Log.e("sendAppUsageRecord", "onComplete: ");
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
private void handleDeferredResume() {
|
||||
if (hasBeenResumed() && !mStateManager.getState().disableInteraction) {
|
||||
getUserEventDispatcher().logActionCommand(Action.Command.RESUME,
|
||||
@@ -1223,7 +1281,7 @@ public class Launcher extends BaseDraggingActivity implements LauncherExterns,
|
||||
/*打开霸屏应用*/
|
||||
String always_top_packagename = Settings.System.getString(getContentResolver(), "always_top_packagename");
|
||||
if (!TextUtils.isEmpty(always_top_packagename)) {
|
||||
APKUtils.openPackage(Launcher.this, always_top_packagename);
|
||||
ApkUtils.openPackage(Launcher.this, always_top_packagename);
|
||||
}
|
||||
mUpdate.checkUpdate(System.currentTimeMillis());
|
||||
mPasswd.getPassword(System.currentTimeMillis());
|
||||
@@ -1231,6 +1289,14 @@ public class Launcher extends BaseDraggingActivity implements LauncherExterns,
|
||||
JGYUtils.getInstance().wakeUpAppstore();
|
||||
JGYUtils.getInstance().wakeUpDeviceInfo();
|
||||
checkIsRest();
|
||||
|
||||
if (mMainBinder != null) {
|
||||
mMainBinder.getService().mPresenter.getTimeManageSn();
|
||||
}else {
|
||||
Log.e(TAG, "onResume: mMainBinder is null" );
|
||||
Intent intent = new Intent(Launcher.this, MainService.class);
|
||||
bindService(intent, serviceConnect, BIND_AUTO_CREATE);
|
||||
}
|
||||
}
|
||||
|
||||
private void checkIsRest() {
|
||||
|
||||
@@ -309,8 +309,7 @@ public class LauncherModel extends BroadcastReceiver
|
||||
UserHandle myUser = Process.myUserHandle();
|
||||
changedData(myUser);
|
||||
changedTime(myUser);
|
||||
} else if (Intent.ACTION_TIME_TICK.equals(action)//时钟更新
|
||||
) {
|
||||
} else if (Intent.ACTION_TIME_TICK.equals(action)) {//时钟更新
|
||||
UserHandle myUser = Process.myUserHandle();
|
||||
changedTime(myUser);
|
||||
}
|
||||
@@ -336,6 +335,8 @@ public class LauncherModel extends BroadcastReceiver
|
||||
new PackageUpdatedTask(PackageUpdatedTask.OP_UPDATE, user, deskclock));
|
||||
}
|
||||
|
||||
|
||||
|
||||
public void forceReload() {
|
||||
forceReload(-1);
|
||||
}
|
||||
|
||||
@@ -3,7 +3,11 @@ package com.uiuipad.os.base;
|
||||
import android.app.Application;
|
||||
import android.util.Log;
|
||||
|
||||
import com.tencent.bugly.crashreport.CrashReport;
|
||||
import com.uiuipad.os.manager.AppUsedTimeUtils;
|
||||
import com.uiuipad.os.manager.ConnectManager;
|
||||
import com.uiuipad.os.manager.RunningAppManager;
|
||||
import com.uiuipad.os.manager.TimeControlManager;
|
||||
import com.uiuipad.os.network.NetInterfaceManager;
|
||||
import com.uiuipad.os.push.PushManager;
|
||||
import com.uiuipad.os.uiuiutils.JGYUtils;
|
||||
@@ -11,6 +15,7 @@ import com.uiuipad.os.uiuiutils.TimeUtils;
|
||||
import com.uiuipad.os.uiuiutils.ToastUtil;
|
||||
import com.arialyy.aria.core.Aria;
|
||||
import com.tencent.mmkv.MMKV;
|
||||
import com.uiuipad.os.uiuiutils.Utils;
|
||||
|
||||
public class BaseApplication extends Application {
|
||||
private static final String TAG = BaseApplication.class.getSimpleName();
|
||||
@@ -28,5 +33,13 @@ public class BaseApplication extends Application {
|
||||
NetInterfaceManager.init(this);
|
||||
ToastUtil.init(this);
|
||||
ConnectManager.init(this);
|
||||
|
||||
AppUsedTimeUtils.init(this);
|
||||
RunningAppManager.init(this);
|
||||
TimeControlManager.init(this);
|
||||
|
||||
CrashReport.initCrashReport(getApplicationContext(), "55d55ba689", false);
|
||||
CrashReport.setDeviceId(this, Utils.getSerial(this));
|
||||
xcrash.XCrash.init(this);
|
||||
}
|
||||
}
|
||||
|
||||
7
src/com/uiuipad/os/base/BasePresenter.java
Normal file
7
src/com/uiuipad/os/base/BasePresenter.java
Normal file
@@ -0,0 +1,7 @@
|
||||
package com.uiuipad.os.base;
|
||||
|
||||
public interface BasePresenter<V extends BaseView> {
|
||||
void attachView(V view);
|
||||
|
||||
void detachView();
|
||||
}
|
||||
4
src/com/uiuipad/os/base/BaseView.java
Normal file
4
src/com/uiuipad/os/base/BaseView.java
Normal file
@@ -0,0 +1,4 @@
|
||||
package com.uiuipad.os.base;
|
||||
|
||||
public interface BaseView {
|
||||
}
|
||||
@@ -6,7 +6,7 @@ public class ClippedFolderIconLayoutRule {
|
||||
static final int MAX_NUM_ITEMS_IN_PREVIEW = Integer.MAX_VALUE;
|
||||
private static final int MIN_NUM_ITEMS_IN_PREVIEW = 2;
|
||||
|
||||
private static final float MIN_SCALE = 0.22f;
|
||||
private static final float MIN_SCALE = 0.20f;
|
||||
private static final float MAX_SCALE = 0.58f;
|
||||
private static final float MAX_RADIUS_DILATION = 0.15f;
|
||||
private static final float ITEM_RADIUS_SCALE_FACTOR = 1.33f;
|
||||
|
||||
144
src/com/uiuipad/os/gson/GsonUtils.java
Normal file
144
src/com/uiuipad/os/gson/GsonUtils.java
Normal file
@@ -0,0 +1,144 @@
|
||||
package com.uiuipad.os.gson;
|
||||
|
||||
import com.google.gson.Gson;
|
||||
import com.google.gson.GsonBuilder;
|
||||
import com.google.gson.JsonArray;
|
||||
import com.google.gson.JsonElement;
|
||||
import com.google.gson.JsonObject;
|
||||
import com.google.gson.JsonParser;
|
||||
import com.google.gson.reflect.TypeToken;
|
||||
|
||||
import java.lang.reflect.Type;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
|
||||
|
||||
public class GsonUtils {
|
||||
//https://blog.csdn.net/zte1055889498/article/details/122400299
|
||||
|
||||
public static JsonObject getJsonObject(String jsonString) {
|
||||
JsonObject jsonObject = JsonParser.parseString(jsonString).getAsJsonObject();
|
||||
return jsonObject;
|
||||
}
|
||||
|
||||
private static final Gson gson;
|
||||
|
||||
static {
|
||||
GsonBuilder builder = new GsonBuilder();
|
||||
builder.registerTypeAdapterFactory(new NullStringToEmptyAdapterFactory());
|
||||
builder.registerTypeAdapter(Integer.class, new IntegerDefault0Adapter());
|
||||
builder.registerTypeAdapter(int.class, new IntegerDefault0Adapter());
|
||||
builder.disableHtmlEscaping();
|
||||
builder.enableComplexMapKeySerialization();
|
||||
// builder.excludeFieldsWithoutExposeAnnotation();
|
||||
builder.setDateFormat("yyyy-MM-dd HH:mm:ss");
|
||||
gson = builder.create();
|
||||
}
|
||||
|
||||
public static Type makeJavaType(Type rawType, Type... typeArguments) {
|
||||
return TypeToken.getParameterized(rawType, typeArguments).getType();
|
||||
}
|
||||
|
||||
public static String toString(Object value) {
|
||||
if (Objects.isNull(value)) {
|
||||
return null;
|
||||
}
|
||||
if (value instanceof String) {
|
||||
return (String) value;
|
||||
}
|
||||
return toJSONString(value);
|
||||
}
|
||||
|
||||
public static String toJSONString(Object value) {
|
||||
return gson.toJson(value);
|
||||
}
|
||||
|
||||
public static String toPrettyString(Object value) {
|
||||
return gson.newBuilder().setPrettyPrinting().create().toJson(value);
|
||||
}
|
||||
|
||||
public static JsonElement fromJavaObject(Object value) {
|
||||
JsonElement result = null;
|
||||
if (Objects.nonNull(value) && (value instanceof String)) {
|
||||
result = parseObject((String) value);
|
||||
} else {
|
||||
result = gson.toJsonTree(value);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
public static JsonElement parseObject(String content) {
|
||||
return JsonParser.parseString(content);
|
||||
}
|
||||
|
||||
public static JsonElement getJsonElement(JsonObject node, String name) {
|
||||
return node.get(name);
|
||||
}
|
||||
|
||||
public static JsonElement getJsonElement(JsonArray node, int index) {
|
||||
return node.get(index);
|
||||
}
|
||||
|
||||
public static <T> T toJavaObject(JsonElement node, Class<T> clazz) {
|
||||
return gson.fromJson(node, clazz);
|
||||
}
|
||||
|
||||
public static <T> T toJavaObject(JsonElement node, Type type) {
|
||||
return gson.fromJson(node, type);
|
||||
}
|
||||
|
||||
public static <T> T toJavaObject(JsonElement node, TypeToken<?> typeToken) {
|
||||
return toJavaObject(node, typeToken.getType());
|
||||
}
|
||||
|
||||
public static <E> List<E> toJavaList(JsonElement node, Class<E> clazz) {
|
||||
return toJavaObject(node, makeJavaType(List.class, clazz));
|
||||
}
|
||||
|
||||
public static List<Object> toJavaList(JsonElement node) {
|
||||
return toJavaObject(node, new TypeToken<List<Object>>() {
|
||||
}.getType());
|
||||
}
|
||||
|
||||
public static <V> Map<String, V> toJavaMap(JsonElement node, Class<V> clazz) {
|
||||
return toJavaObject(node, makeJavaType(Map.class, String.class, clazz));
|
||||
}
|
||||
|
||||
public static Map<String, Object> toJavaMap(JsonElement node) {
|
||||
return toJavaObject(node, new TypeToken<Map<String, Object>>() {
|
||||
}.getType());
|
||||
}
|
||||
|
||||
public static <T> T toJavaObject(String content, Class<T> clazz) {
|
||||
JsonObject jsonObject = getJsonObject(content);
|
||||
String jsonString = jsonObject.toString();
|
||||
return gson.fromJson(jsonString, clazz);
|
||||
}
|
||||
|
||||
public static <T> T toJavaObject(String content, Type type) {
|
||||
return gson.fromJson(content, type);
|
||||
}
|
||||
|
||||
public static <T> T toJavaObject(String content, TypeToken<?> typeToken) {
|
||||
return toJavaObject(content, typeToken.getType());
|
||||
}
|
||||
|
||||
public static <E> List<E> toJavaList(String content, Class<E> clazz) {
|
||||
return toJavaObject(content, makeJavaType(List.class, clazz));
|
||||
}
|
||||
|
||||
public static List<Object> toJavaList(String content) {
|
||||
return toJavaObject(content, new TypeToken<List<Object>>() {
|
||||
}.getType());
|
||||
}
|
||||
|
||||
public static <V> Map<String, V> toJavaMap(String content, Class<V> clazz) {
|
||||
return toJavaObject(content, makeJavaType(Map.class, String.class, clazz));
|
||||
}
|
||||
|
||||
public static Map<String, Object> toJavaMap(String content) {
|
||||
return toJavaObject(content, new TypeToken<Map<String, Object>>() {
|
||||
}.getType());
|
||||
}
|
||||
}
|
||||
35
src/com/uiuipad/os/gson/IntegerDefault0Adapter.java
Normal file
35
src/com/uiuipad/os/gson/IntegerDefault0Adapter.java
Normal file
@@ -0,0 +1,35 @@
|
||||
package com.uiuipad.os.gson;
|
||||
|
||||
import com.google.gson.JsonDeserializationContext;
|
||||
import com.google.gson.JsonDeserializer;
|
||||
import com.google.gson.JsonElement;
|
||||
import com.google.gson.JsonParseException;
|
||||
import com.google.gson.JsonPrimitive;
|
||||
import com.google.gson.JsonSerializationContext;
|
||||
import com.google.gson.JsonSerializer;
|
||||
import com.google.gson.JsonSyntaxException;
|
||||
|
||||
import java.lang.reflect.Type;
|
||||
|
||||
public class IntegerDefault0Adapter implements JsonSerializer<Integer>, JsonDeserializer<Integer> {
|
||||
@Override
|
||||
public Integer deserialize(JsonElement json, Type typeOfT, JsonDeserializationContext context)
|
||||
throws JsonParseException {
|
||||
try {
|
||||
if (json.getAsString().equals("")) {
|
||||
return 0;
|
||||
}
|
||||
} catch (Exception ignore) {
|
||||
}
|
||||
try {
|
||||
return json.getAsInt();
|
||||
} catch (NumberFormatException e) {
|
||||
throw new JsonSyntaxException(e);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public JsonElement serialize(Integer src, Type typeOfSrc, JsonSerializationContext context) {
|
||||
return new JsonPrimitive(src);
|
||||
}
|
||||
}
|
||||
45
src/com/uiuipad/os/gson/NullStringToEmptyAdapterFactory.java
Normal file
45
src/com/uiuipad/os/gson/NullStringToEmptyAdapterFactory.java
Normal file
@@ -0,0 +1,45 @@
|
||||
package com.uiuipad.os.gson;
|
||||
|
||||
import com.google.gson.Gson;
|
||||
import com.google.gson.TypeAdapter;
|
||||
import com.google.gson.TypeAdapterFactory;
|
||||
import com.google.gson.reflect.TypeToken;
|
||||
import com.google.gson.stream.JsonReader;
|
||||
import com.google.gson.stream.JsonToken;
|
||||
import com.google.gson.stream.JsonWriter;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
public class NullStringToEmptyAdapterFactory<T> implements TypeAdapterFactory {
|
||||
@Override
|
||||
public <T> TypeAdapter<T> create(Gson gson, TypeToken<T> type) {
|
||||
|
||||
Class<T> rawType = (Class<T>) type.getRawType();
|
||||
if (rawType != String.class) {
|
||||
return null;
|
||||
}
|
||||
return (TypeAdapter<T>) new StringAdapter();
|
||||
}
|
||||
|
||||
public static class StringAdapter extends TypeAdapter<String> {
|
||||
@Override
|
||||
public String read(JsonReader reader) throws IOException {
|
||||
if (reader.peek() == JsonToken.NULL) {
|
||||
reader.nextNull();
|
||||
return "";
|
||||
}
|
||||
return reader.nextString();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void write(JsonWriter writer, String value) throws IOException {
|
||||
if (value == null) {
|
||||
writer.nullValue();
|
||||
return;
|
||||
}
|
||||
writer.value(value);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -322,7 +322,8 @@ public class IconCache extends BaseIconCache {
|
||||
String name = info.getComponentName().getClassName();
|
||||
Log.e("getFullResIcon", "getDeskClockIcon: " + name);
|
||||
if (appClassNameList.indexOf(info.getComponentName().getClassName()) == -1) {
|
||||
icon = BitmapUtils.getRoundedBitmap(mIconProvider.getIcon(info, mIconDpi, flattenDrawable), mContext);
|
||||
icon = mIconProvider.getIcon(info, mIconDpi, flattenDrawable);
|
||||
// icon = BitmapUtils.getRoundedBitmap(mIconProvider.getIcon(info, mIconDpi, flattenDrawable), mContext);
|
||||
} else {
|
||||
// if ("com.android.calendar.AllInOneActivity".equals(name)) {
|
||||
// icon = BitmapUtils.createCalendarIconBitmap(mContext.getResources().getDrawable(R.drawable.mask), mContext);
|
||||
|
||||
47
src/com/uiuipad/os/manager/AppUsedTimeUtils.java
Normal file
47
src/com/uiuipad/os/manager/AppUsedTimeUtils.java
Normal file
@@ -0,0 +1,47 @@
|
||||
package com.uiuipad.os.manager;
|
||||
|
||||
import android.annotation.SuppressLint;
|
||||
import android.content.Context;
|
||||
|
||||
public class AppUsedTimeUtils {
|
||||
private static final String TAG = AppUsedTimeUtils.class.getSimpleName();
|
||||
|
||||
@SuppressLint("StaticFieldLeak")
|
||||
private static AppUsedTimeUtils sInstance;
|
||||
private Context mContext;
|
||||
private String app_package;
|
||||
private long start_time;
|
||||
|
||||
private AppUsedTimeUtils(Context context) {
|
||||
this.mContext = context;
|
||||
}
|
||||
|
||||
public static void init(Context context) {
|
||||
if (sInstance == null) {
|
||||
sInstance = new AppUsedTimeUtils(context);
|
||||
}
|
||||
}
|
||||
|
||||
public static AppUsedTimeUtils getInstance() {
|
||||
if (sInstance == null) {
|
||||
throw new IllegalStateException("You must be init AppUsedTimeUtils first");
|
||||
}
|
||||
return sInstance;
|
||||
}
|
||||
|
||||
public String getApp_package() {
|
||||
return app_package;
|
||||
}
|
||||
|
||||
public void setApp_package(String app_package) {
|
||||
this.app_package = app_package;
|
||||
}
|
||||
|
||||
public long getStart_time() {
|
||||
return start_time;
|
||||
}
|
||||
|
||||
public void setStart_time(long start_time) {
|
||||
this.start_time = start_time;
|
||||
}
|
||||
}
|
||||
73
src/com/uiuipad/os/manager/MyAppUsageBean.java
Normal file
73
src/com/uiuipad/os/manager/MyAppUsageBean.java
Normal file
@@ -0,0 +1,73 @@
|
||||
package com.uiuipad.os.manager;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
|
||||
import com.google.gson.Gson;
|
||||
import com.google.gson.JsonParser;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
public class MyAppUsageBean implements Serializable {
|
||||
private static final long serialVersionUID = 5340688429095924160L;
|
||||
|
||||
int id;
|
||||
String app_name;
|
||||
String app_package;
|
||||
String app_img;
|
||||
String class_name;
|
||||
long use_time;//s
|
||||
|
||||
public int getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(int id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public String getApp_name() {
|
||||
return app_name;
|
||||
}
|
||||
|
||||
public void setApp_name(String app_name) {
|
||||
this.app_name = app_name;
|
||||
}
|
||||
|
||||
public String getApp_package() {
|
||||
return app_package;
|
||||
}
|
||||
|
||||
public void setApp_package(String app_package) {
|
||||
this.app_package = app_package;
|
||||
}
|
||||
|
||||
public String getApp_img() {
|
||||
return app_img;
|
||||
}
|
||||
|
||||
public void setApp_img(String app_img) {
|
||||
this.app_img = app_img;
|
||||
}
|
||||
|
||||
public String getClass_name() {
|
||||
return class_name;
|
||||
}
|
||||
|
||||
public void setClass_name(String class_name) {
|
||||
this.class_name = class_name;
|
||||
}
|
||||
|
||||
public long getUse_time() {
|
||||
return use_time;
|
||||
}
|
||||
|
||||
public void setUse_time(long use_time) {
|
||||
this.use_time = use_time;
|
||||
}
|
||||
|
||||
@NonNull
|
||||
@Override
|
||||
public String toString() {
|
||||
return JsonParser.parseString(new Gson().toJson(this)).getAsJsonObject().toString();
|
||||
}
|
||||
}
|
||||
1491
src/com/uiuipad/os/manager/RunningAppManager.java
Normal file
1491
src/com/uiuipad/os/manager/RunningAppManager.java
Normal file
File diff suppressed because it is too large
Load Diff
191
src/com/uiuipad/os/manager/TimeControlManager.java
Normal file
191
src/com/uiuipad/os/manager/TimeControlManager.java
Normal file
@@ -0,0 +1,191 @@
|
||||
package com.uiuipad.os.manager;
|
||||
|
||||
import android.annotation.SuppressLint;
|
||||
import android.content.Context;
|
||||
import android.text.TextUtils;
|
||||
import android.util.Log;
|
||||
|
||||
import com.google.gson.Gson;
|
||||
import com.google.gson.reflect.TypeToken;
|
||||
import com.tencent.mmkv.MMKV;
|
||||
import com.uiuipad.os.comm.CommonConfig;
|
||||
import com.uiuipad.os.disklrucache.CacheHelper;
|
||||
import com.uiuipad.os.network.UrlAddress;
|
||||
import com.uiuipad.os.network.bean.TimeManageApp;
|
||||
import com.uiuipad.os.network.bean.TimeManageSn;
|
||||
|
||||
import java.lang.reflect.Type;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
public class TimeControlManager {
|
||||
private static final String TAG = TimeControlManager.class.getSimpleName();
|
||||
|
||||
@SuppressLint("StaticFieldLeak")
|
||||
private static TimeControlManager mTimeControlManager;
|
||||
private Context mContext;
|
||||
private MMKV mMMKV = MMKV.mmkvWithID(CommonConfig.MMKV_ID, MMKV.MULTI_PROCESS_MODE);
|
||||
|
||||
private HashMap<Integer, TimeManageApp> mClassifyTimeControlHashMap = new HashMap<>();
|
||||
/*分类的所有包名列表*/
|
||||
private HashMap<String, TimeManageApp> mAppTimeControlMap = new HashMap<>();
|
||||
/*整机分类*/
|
||||
private TimeManageSn mGlobalMachineControl;
|
||||
|
||||
private TimeControlManager(Context context) {
|
||||
if (context == null) {
|
||||
throw new RuntimeException("Context is NULL");
|
||||
}
|
||||
this.mContext = context;
|
||||
String appTimeControlJson = mMMKV.decodeString(UrlAddress.GET_TIME_MANAGE_APP, "");
|
||||
if (!TextUtils.isEmpty(appTimeControlJson)) {
|
||||
Gson gson = new Gson();
|
||||
Type type = new TypeToken<List<TimeManageApp>>() {
|
||||
}.getType();
|
||||
try {
|
||||
List<TimeManageApp> appTimeControls = gson.fromJson(appTimeControlJson, type);
|
||||
setAppTimeControlMap(appTimeControls);
|
||||
} catch (Exception e) {
|
||||
Log.e(TAG, "TimeControlManager: " + e.getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static void init(Context context) {
|
||||
if (mTimeControlManager == null) {
|
||||
mTimeControlManager = new TimeControlManager(context);
|
||||
}
|
||||
}
|
||||
|
||||
public static TimeControlManager getInstance() {
|
||||
if (mTimeControlManager == null) {
|
||||
throw new IllegalStateException("You must be init TimeControlManager first");
|
||||
}
|
||||
return mTimeControlManager;
|
||||
}
|
||||
|
||||
public HashMap<String, TimeManageApp> getAppTimeControlMap() {
|
||||
return mAppTimeControlMap;
|
||||
}
|
||||
|
||||
/**
|
||||
* 判断是否有配置存在
|
||||
*
|
||||
* @param pkg
|
||||
* @return
|
||||
*/
|
||||
public boolean havaConfigure(String pkg) {
|
||||
TimeManageApp appTimeControl = mAppTimeControlMap.get(pkg);
|
||||
if (appTimeControl == null) {
|
||||
Log.e(TAG, "havaConfigure: not");
|
||||
return false;
|
||||
} else {
|
||||
if (appTimeControl.getUse_type() == 1) {
|
||||
//根据分类
|
||||
Log.e(TAG, "havaConfigure: classify");
|
||||
return mClassifyTimeControlHashMap.get(appTimeControl.getClass_id()) != null;
|
||||
}
|
||||
Log.e(TAG, "havaConfigure: hava");
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取整机配置
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public TimeManageSn getGlobalMachineControl() {
|
||||
if (mGlobalMachineControl == null) {
|
||||
String jsonString = mMMKV.decodeString(UrlAddress.GET_TIME_MANAGE_SN, "");
|
||||
//为 "" 是已经请求成功的
|
||||
if (jsonString == null) {
|
||||
return null;
|
||||
} else {
|
||||
Gson gson = new Gson();
|
||||
Type Type = new TypeToken<TimeManageSn>() {
|
||||
}.getType();
|
||||
TimeManageSn machineControl = gson.fromJson(jsonString, Type);
|
||||
return machineControl;
|
||||
}
|
||||
} else {
|
||||
return mGlobalMachineControl;
|
||||
}
|
||||
}
|
||||
|
||||
public void setGlobalMachineControl(TimeManageSn machineControl) {
|
||||
this.mGlobalMachineControl = machineControl;
|
||||
if (machineControl != null) {
|
||||
RunningAppManager.getInstance().setGlobalUsageTime(machineControl.getToday_time());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取app的配置
|
||||
*
|
||||
* @param pkg
|
||||
* @return
|
||||
*/
|
||||
public TimeManageApp getAppTimeControl(String pkg) {
|
||||
TimeManageApp temp = mAppTimeControlMap.get(pkg);
|
||||
if (temp == null) {
|
||||
String jsonString = mMMKV.decodeString(UrlAddress.GET_TIME_MANAGE_APP, "");
|
||||
//为 "" 是已经请求成功的
|
||||
if (jsonString == null) {
|
||||
return null;
|
||||
} else {
|
||||
Gson gson = new Gson();
|
||||
Type Type = new TypeToken<List<TimeManageApp>>() {
|
||||
}.getType();
|
||||
List<TimeManageApp> appTimeControlList = gson.fromJson(jsonString, Type);
|
||||
if (appTimeControlList == null) {
|
||||
return null;
|
||||
}
|
||||
HashMap<String, TimeManageApp> appTimeControlMap = new HashMap<>();
|
||||
for (TimeManageApp appTimeControl : appTimeControlList) {
|
||||
appTimeControlMap.put(appTimeControl.getApp_package(), appTimeControl);
|
||||
}
|
||||
setAppTimeControlMap(appTimeControlList);
|
||||
return appTimeControlMap.get(pkg);
|
||||
}
|
||||
} else {
|
||||
return temp;
|
||||
}
|
||||
}
|
||||
|
||||
public void setAppTimeControl(String pkg, TimeManageApp appTimeControl) {
|
||||
this.mAppTimeControlMap.put(pkg, appTimeControl);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 设置app的配置
|
||||
*
|
||||
* @param appTimeControlList
|
||||
*/
|
||||
public void setAppTimeControlMap(List<TimeManageApp> appTimeControlList) {
|
||||
if (appTimeControlList == null || appTimeControlList.size() == 0) {
|
||||
return;
|
||||
}
|
||||
HashMap<Integer, TimeManageApp> classifyTimeControlHashMap = new HashMap<>();
|
||||
List<TimeManageApp> filterAppTimeControlList = appTimeControlList.stream().filter(appTimeControl -> {
|
||||
//tc_use_type == 1 时用的是分类配置,配置都是一样的
|
||||
return appTimeControl.getUse_type() == 1;
|
||||
}).collect(Collectors.toList());
|
||||
for (TimeManageApp appTimeControl : filterAppTimeControlList) {
|
||||
classifyTimeControlHashMap.put(appTimeControl.getClass_id(), appTimeControl);
|
||||
}
|
||||
this.mClassifyTimeControlHashMap = classifyTimeControlHashMap;
|
||||
|
||||
HashMap<String, TimeManageApp> appTimeControlMap = new HashMap<>();
|
||||
List<TimeManageApp> appTimeControls = new ArrayList<>();
|
||||
for (TimeManageApp appTimeControl : appTimeControlList) {
|
||||
appTimeControlMap.put(appTimeControl.getApp_package(), appTimeControl);
|
||||
appTimeControls.add(appTimeControl);
|
||||
}
|
||||
RunningAppManager.getInstance().syncAppRemainingTime(appTimeControls);
|
||||
this.mAppTimeControlMap = appTimeControlMap;
|
||||
}
|
||||
}
|
||||
75
src/com/uiuipad/os/manager/bean/AppRunTimeBean.java
Normal file
75
src/com/uiuipad/os/manager/bean/AppRunTimeBean.java
Normal file
@@ -0,0 +1,75 @@
|
||||
package com.uiuipad.os.manager.bean;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
|
||||
import com.google.gson.Gson;
|
||||
import com.google.gson.JsonObject;
|
||||
import com.google.gson.JsonParser;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
public class AppRunTimeBean implements Serializable {
|
||||
private static final long serialVersionUID = 3699088127005434759L;
|
||||
|
||||
String packageName;
|
||||
Long appRunTime;
|
||||
|
||||
AppRunTimeBean() {
|
||||
this.appRunTime = 0L;
|
||||
}
|
||||
|
||||
public AppRunTimeBean(String pkg) {
|
||||
this.packageName = pkg;
|
||||
this.appRunTime = 0L;
|
||||
}
|
||||
|
||||
AppRunTimeBean(String pkg, long time) {
|
||||
this.packageName = pkg;
|
||||
this.appRunTime = time;
|
||||
}
|
||||
|
||||
public String getPackageName() {
|
||||
return packageName;
|
||||
}
|
||||
|
||||
public void setPackageName(String packageName) {
|
||||
this.packageName = packageName;
|
||||
}
|
||||
|
||||
public void reduceTime(Long time) {
|
||||
this.appRunTime -= time;
|
||||
}
|
||||
|
||||
public Long getAppRunTime() {
|
||||
return appRunTime;
|
||||
}
|
||||
|
||||
public void setAppRunTime(Long appRunTime) {
|
||||
this.appRunTime = appRunTime;
|
||||
}
|
||||
|
||||
@NonNull
|
||||
@Override
|
||||
public String toString() {
|
||||
Gson gson = new Gson();
|
||||
JsonObject jsonObject = JsonParser.parseString(gson.toJson(this)).getAsJsonObject();
|
||||
return jsonObject.toString();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return super.hashCode();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(@Nullable Object obj) {
|
||||
if (obj instanceof AppRunTimeBean) {
|
||||
AppRunTimeBean appRunTimeBean = (AppRunTimeBean) obj;
|
||||
return appRunTimeBean.packageName.equals(packageName)
|
||||
&& appRunTimeBean.appRunTime.equals(appRunTime);
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
50
src/com/uiuipad/os/manager/bean/AppUsageTime.java
Normal file
50
src/com/uiuipad/os/manager/bean/AppUsageTime.java
Normal file
@@ -0,0 +1,50 @@
|
||||
package com.uiuipad.os.manager.bean;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
|
||||
import com.google.gson.Gson;
|
||||
import com.google.gson.JsonParser;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
public class AppUsageTime implements Serializable {
|
||||
private static final long serialVersionUID = -2981074385838909527L;
|
||||
|
||||
/*包名*/
|
||||
String pkg;
|
||||
/*应用名*/
|
||||
String appName;
|
||||
/*使用时间*/
|
||||
long usageTime;
|
||||
|
||||
|
||||
public String getPkg() {
|
||||
return pkg;
|
||||
}
|
||||
|
||||
public void setPkg(String pkg) {
|
||||
this.pkg = pkg;
|
||||
}
|
||||
|
||||
public String getAppName() {
|
||||
return appName;
|
||||
}
|
||||
|
||||
public void setAppName(String appName) {
|
||||
this.appName = appName;
|
||||
}
|
||||
|
||||
public long getUsageTime() {
|
||||
return usageTime;
|
||||
}
|
||||
|
||||
public void setUsageTime(long usageTime) {
|
||||
this.usageTime = usageTime;
|
||||
}
|
||||
|
||||
@NonNull
|
||||
@Override
|
||||
public String toString() {
|
||||
return JsonParser.parseString(new Gson().toJson(this)).getAsJsonObject().toString();
|
||||
}
|
||||
}
|
||||
88
src/com/uiuipad/os/manager/bean/RemainTime.java
Normal file
88
src/com/uiuipad/os/manager/bean/RemainTime.java
Normal file
@@ -0,0 +1,88 @@
|
||||
package com.uiuipad.os.manager.bean;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
|
||||
import com.google.gson.Gson;
|
||||
import com.google.gson.JsonParser;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.List;
|
||||
|
||||
public class RemainTime implements Serializable {
|
||||
private static final long serialVersionUID = 5651493620850107410L;
|
||||
|
||||
/*包名*/
|
||||
String pkg;
|
||||
/**
|
||||
* 禁用类型
|
||||
* 1 应用已被禁用
|
||||
* 2 该应用今日可使用时间已用完
|
||||
* 3 APP设置了禁用时间段
|
||||
* 4 该应用跟随整机使用,整机剩余时间不足
|
||||
* 5 该应用跟随分类使用,分类剩余时间不足
|
||||
*/
|
||||
int disableType;
|
||||
/*禁用提示*/
|
||||
String content;
|
||||
/*总时间*/
|
||||
long totalTime;
|
||||
/*应用设置的可用时间*/
|
||||
long availableTime;
|
||||
/*app使用时间*/
|
||||
List<AppUsageTime> mAppUsageTimes;
|
||||
|
||||
|
||||
public String getPkg() {
|
||||
return pkg;
|
||||
}
|
||||
|
||||
public void setPkg(String pkg) {
|
||||
this.pkg = pkg;
|
||||
}
|
||||
|
||||
public int getDisableType() {
|
||||
return disableType;
|
||||
}
|
||||
|
||||
public void setDisableType(int disableType) {
|
||||
this.disableType = disableType;
|
||||
}
|
||||
|
||||
public String getContent() {
|
||||
return content;
|
||||
}
|
||||
|
||||
public void setContent(String content) {
|
||||
this.content = content;
|
||||
}
|
||||
|
||||
public long getTotalTime() {
|
||||
return totalTime;
|
||||
}
|
||||
|
||||
public void setTotalTime(long totalTime) {
|
||||
this.totalTime = totalTime;
|
||||
}
|
||||
|
||||
public long getAvailableTime() {
|
||||
return availableTime;
|
||||
}
|
||||
|
||||
public void setAvailableTime(long availableTime) {
|
||||
this.availableTime = availableTime;
|
||||
}
|
||||
|
||||
public List<AppUsageTime> getAppUsageTimes() {
|
||||
return mAppUsageTimes;
|
||||
}
|
||||
|
||||
public void setAppUsageTimes(List<AppUsageTime> appUsageTimes) {
|
||||
this.mAppUsageTimes = appUsageTimes;
|
||||
}
|
||||
|
||||
@NonNull
|
||||
@Override
|
||||
public String toString() {
|
||||
return JsonParser.parseString(new Gson().toJson(this)).getAsJsonObject().toString();
|
||||
}
|
||||
}
|
||||
@@ -307,6 +307,8 @@ public class LoaderTask implements Runnable {
|
||||
Log.e("verifyApplications", "whiteList: " + whiteList);
|
||||
int aihuaUnlock = Settings.System.getInt(context.getContentResolver(), "Aihua_unlock_state", 0);
|
||||
Log.e(TAG, "verifyApplications: aihuaUnlock = " + aihuaUnlock);
|
||||
int is_control = Settings.Global.getInt(crv, "is_control", 0);
|
||||
Log.e(TAG, "verifyApplications: is_control = " + is_control);
|
||||
for (UserHandle user : profiles) {
|
||||
final List<LauncherActivityInfo> apps = mLauncherApps.getActivityList(null, user);
|
||||
ArrayList<InstallShortcutReceiver.PendingInstallShortcutInfo> added = new ArrayList<InstallShortcutReceiver.PendingInstallShortcutInfo>();
|
||||
@@ -315,8 +317,17 @@ public class LoaderTask implements Runnable {
|
||||
Log.e("verifyApplications", "AllAPP: " + app.getApplicationInfo().packageName);
|
||||
if (BuildConfig.APPLICATION_ID.equals(app.getApplicationInfo().packageName)
|
||||
|| "com.ygyb.yischool".equals(app.getApplicationInfo().packageName)
|
||||
|| "com.cube.setlauncherdef".equals(app.getApplicationInfo().packageName)
|
||||
|| "com.iflytek.speechcloud".equals(app.getApplicationInfo().packageName)
|
||||
|| "com.oirsdfg89.flg".equals(app.getApplicationInfo().packageName)
|
||||
)
|
||||
continue;
|
||||
if (is_control == 1) {
|
||||
if ("org.chromium.chrome".equals(app.getApplicationInfo().packageName)
|
||||
|| "org.chromium.webview_shell".equals(app.getApplicationInfo().packageName)) {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
/*系统应用*/
|
||||
// if (JGYUtils.getInstance().getDeviceIsLocked() && aihuaUnlock != 1) {
|
||||
// if ((app.getApplicationFlags() & ApplicationInfo.FLAG_SYSTEM) == 1) {
|
||||
|
||||
@@ -21,13 +21,15 @@ import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import io.reactivex.Observable;
|
||||
import io.reactivex.android.schedulers.AndroidSchedulers;
|
||||
import io.reactivex.schedulers.Schedulers;
|
||||
import io.reactivex.rxjava3.core.Observable;
|
||||
import io.reactivex.rxjava3.android.schedulers.AndroidSchedulers;
|
||||
import io.reactivex.rxjava3.schedulers.Schedulers;
|
||||
import okhttp3.Cache;
|
||||
import okhttp3.MediaType;
|
||||
import okhttp3.OkHttpClient;
|
||||
import okhttp3.RequestBody;
|
||||
import retrofit2.Retrofit;
|
||||
import retrofit2.adapter.rxjava2.RxJava2CallAdapterFactory;
|
||||
import retrofit2.adapter.rxjava3.RxJava3CallAdapterFactory;
|
||||
import retrofit2.converter.gson.GsonConverterFactory;
|
||||
|
||||
public class NetInterfaceManager {
|
||||
@@ -73,7 +75,7 @@ public class NetInterfaceManager {
|
||||
.client(okHttpClient)
|
||||
.baseUrl(ROOT_URL)
|
||||
.addConverterFactory(GsonConverterFactory.create())
|
||||
.addCallAdapterFactory(RxJava2CallAdapterFactory.create())
|
||||
.addCallAdapterFactory(RxJava3CallAdapterFactory.create())
|
||||
.build();
|
||||
}
|
||||
}
|
||||
@@ -94,6 +96,21 @@ public class NetInterfaceManager {
|
||||
return sInstance;
|
||||
}
|
||||
|
||||
public static RequestBody convertToRequestBody(String param) {
|
||||
RequestBody requestBody = RequestBody.create(MediaType.parse("text/plain"), param);
|
||||
return requestBody;
|
||||
}
|
||||
|
||||
public static RequestBody convertToRequestBody(int param) {
|
||||
RequestBody requestBody = RequestBody.create(MediaType.parse("text/plain"), String.valueOf(param));
|
||||
return requestBody;
|
||||
}
|
||||
|
||||
public static RequestBody convertToRequestBody(long param) {
|
||||
RequestBody requestBody = RequestBody.create(MediaType.parse("text/plain"), String.valueOf(param));
|
||||
return requestBody;
|
||||
}
|
||||
|
||||
public Observable<BaseResponse> getCloudLessonSettingObservable() {
|
||||
return mRetrofit.create(CloudLessonSettingApi.class)
|
||||
.getCloudLessonSetting(Utils.getSerial(mContext))
|
||||
@@ -108,7 +125,7 @@ public class NetInterfaceManager {
|
||||
.observeOn(AndroidSchedulers.mainThread());
|
||||
}
|
||||
|
||||
public Observable<BaseResponse> getUploadAppUseLogObservable(Map<String, String> params) {
|
||||
public Observable<BaseResponse> getUploadAppUseLogObservable(Map<String, RequestBody> params) {
|
||||
return mRetrofit.create(UploadAppUseLogApi.class)
|
||||
.uploadAppUseLog(params)
|
||||
.subscribeOn(Schedulers.io())
|
||||
@@ -124,7 +141,7 @@ public class NetInterfaceManager {
|
||||
|
||||
public Observable<BaseResponse<List<TimeManageApp>>> getTimeManageAppObservable() {
|
||||
return mRetrofit.create(TimeManageAppApi.class)
|
||||
.getTimeManageSn(Utils.getSerial(mContext))
|
||||
.getTimeManageApp(Utils.getSerial(mContext))
|
||||
.subscribeOn(Schedulers.io())
|
||||
.observeOn(AndroidSchedulers.mainThread());
|
||||
}
|
||||
|
||||
@@ -3,6 +3,7 @@ package com.uiuipad.os.network;
|
||||
public class UrlAddress {
|
||||
public static final String ROOT_URL = "https://kxapi.uiuios.com/android/";
|
||||
|
||||
|
||||
/*上传应用使用记录*/
|
||||
public static final String UPLOAD_APP_USE_LOG = "app/app/uploadAppUseLog";
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@ package com.uiuipad.os.network.api;
|
||||
import com.uiuipad.os.network.UrlAddress;
|
||||
import com.uiuipad.os.network.bean.BaseResponse;
|
||||
|
||||
import io.reactivex.Observable;
|
||||
import io.reactivex.rxjava3.core.Observable;
|
||||
import retrofit2.http.GET;
|
||||
import retrofit2.http.Query;
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@ package com.uiuipad.os.network.api;
|
||||
import com.uiuipad.os.network.UrlAddress;
|
||||
import com.uiuipad.os.network.bean.BaseResponse;
|
||||
|
||||
import io.reactivex.Observable;
|
||||
import io.reactivex.rxjava3.core.Observable;
|
||||
import retrofit2.http.GET;
|
||||
import retrofit2.http.Query;
|
||||
|
||||
|
||||
@@ -6,13 +6,13 @@ import com.uiuipad.os.network.bean.TimeManageApp;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import io.reactivex.Observable;
|
||||
import io.reactivex.rxjava3.core.Observable;
|
||||
import retrofit2.http.GET;
|
||||
import retrofit2.http.Query;
|
||||
|
||||
public interface TimeManageAppApi {
|
||||
@GET(UrlAddress.GET_TIME_MANAGE_APP)
|
||||
Observable<BaseResponse<List<TimeManageApp>>> getTimeManageSn(
|
||||
Observable<BaseResponse<List<TimeManageApp>>> getTimeManageApp(
|
||||
@Query("sn") String sn
|
||||
);
|
||||
}
|
||||
|
||||
@@ -4,7 +4,7 @@ import com.uiuipad.os.network.UrlAddress;
|
||||
import com.uiuipad.os.network.bean.BaseResponse;
|
||||
import com.uiuipad.os.network.bean.TimeManageSn;
|
||||
|
||||
import io.reactivex.Observable;
|
||||
import io.reactivex.rxjava3.core.Observable;
|
||||
import retrofit2.http.GET;
|
||||
import retrofit2.http.Query;
|
||||
|
||||
|
||||
@@ -5,16 +5,16 @@ import com.uiuipad.os.network.bean.BaseResponse;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
import io.reactivex.Observable;
|
||||
import retrofit2.http.Field;
|
||||
import retrofit2.http.FormUrlEncoded;
|
||||
import io.reactivex.rxjava3.core.Observable;
|
||||
import okhttp3.RequestBody;
|
||||
import retrofit2.http.Multipart;
|
||||
import retrofit2.http.POST;
|
||||
import retrofit2.http.PartMap;
|
||||
|
||||
public interface UploadAppUseLogApi {
|
||||
@FormUrlEncoded
|
||||
@Multipart
|
||||
@POST(UrlAddress.UPLOAD_APP_USE_LOG)
|
||||
Observable<BaseResponse> uploadAppUseLog(
|
||||
@PartMap Map<String, String> params
|
||||
@PartMap Map<String, RequestBody> params
|
||||
);
|
||||
}
|
||||
|
||||
@@ -1,18 +1,16 @@
|
||||
package com.uiuipad.os.network.bean;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.List;
|
||||
import androidx.annotation.NonNull;
|
||||
|
||||
public class TimeManageApp implements Serializable {
|
||||
import com.google.gson.Gson;
|
||||
import com.google.gson.JsonParser;
|
||||
|
||||
public class TimeManageApp extends TimeManageSn {
|
||||
private static final long serialVersionUID = 8994636991878020624L;
|
||||
|
||||
String app_package;
|
||||
int class_id;
|
||||
int use_type;
|
||||
long work_time;
|
||||
long rest_time;
|
||||
long today_time;
|
||||
List<TimeManagePart> time_part;
|
||||
int class_id;//分类id
|
||||
int use_type;//控制方式 0 始终可用 1分类 2整机 3自由
|
||||
|
||||
public String getApp_package() {
|
||||
return app_package;
|
||||
@@ -38,35 +36,9 @@ public class TimeManageApp implements Serializable {
|
||||
this.use_type = use_type;
|
||||
}
|
||||
|
||||
public long getWork_time() {
|
||||
return work_time;
|
||||
}
|
||||
|
||||
public void setWork_time(long work_time) {
|
||||
this.work_time = work_time;
|
||||
}
|
||||
|
||||
public long getRest_time() {
|
||||
return rest_time;
|
||||
}
|
||||
|
||||
public void setRest_time(long rest_time) {
|
||||
this.rest_time = rest_time;
|
||||
}
|
||||
|
||||
public long getToday_time() {
|
||||
return today_time;
|
||||
}
|
||||
|
||||
public void setToday_time(long today_time) {
|
||||
this.today_time = today_time;
|
||||
}
|
||||
|
||||
public List<TimeManagePart> getTime_part() {
|
||||
return time_part;
|
||||
}
|
||||
|
||||
public void setTime_part(List<TimeManagePart> time_part) {
|
||||
this.time_part = time_part;
|
||||
@NonNull
|
||||
@Override
|
||||
public String toString() {
|
||||
return JsonParser.parseString(new Gson().toJson(this)).getAsJsonObject().toString();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,12 @@
|
||||
package com.uiuipad.os.network.bean;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
|
||||
import com.google.gson.Gson;
|
||||
import com.google.gson.JsonObject;
|
||||
import com.google.gson.JsonParser;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
public class TimeManagePart implements Serializable {
|
||||
@@ -7,7 +14,7 @@ public class TimeManagePart implements Serializable {
|
||||
|
||||
String start_time;
|
||||
String end_time;
|
||||
int day_type;
|
||||
int day_type;//0上学日 1休息日
|
||||
|
||||
public String getStart_time() {
|
||||
return start_time;
|
||||
@@ -32,4 +39,29 @@ public class TimeManagePart implements Serializable {
|
||||
public void setDay_type(int day_type) {
|
||||
this.day_type = day_type;
|
||||
}
|
||||
|
||||
@NonNull
|
||||
@Override
|
||||
public String toString() {
|
||||
Gson gson = new Gson();
|
||||
JsonObject jsonObject = JsonParser.parseString(gson.toJson(this)).getAsJsonObject();
|
||||
return jsonObject.toString();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return super.hashCode();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(@Nullable Object obj) {
|
||||
if (obj instanceof TimeManagePart) {
|
||||
TimeManagePart partTime = (TimeManagePart) obj;
|
||||
return start_time.equals(partTime.start_time)
|
||||
&& end_time.equals(partTime.end_time)
|
||||
&& day_type == partTime.day_type;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,14 +1,19 @@
|
||||
package com.uiuipad.os.network.bean;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
|
||||
import com.google.gson.Gson;
|
||||
import com.google.gson.JsonParser;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.List;
|
||||
|
||||
public class TimeManageSn implements Serializable {
|
||||
private static final long serialVersionUID = 7571406354160374162L;
|
||||
|
||||
long work_time;
|
||||
long rest_time;
|
||||
long today_time;
|
||||
long work_time;//上学日额度 单位秒
|
||||
long rest_time;//休息日额度 单位秒
|
||||
long today_time;//今日剩余时间 单位秒
|
||||
List<TimeManagePart> time_part;
|
||||
|
||||
public long getWork_time() {
|
||||
@@ -42,4 +47,10 @@ public class TimeManageSn implements Serializable {
|
||||
public void setTime_part(List<TimeManagePart> time_part) {
|
||||
this.time_part = time_part;
|
||||
}
|
||||
|
||||
@NonNull
|
||||
@Override
|
||||
public String toString() {
|
||||
return JsonParser.parseString(new Gson().toJson(this)).getAsJsonObject().toString();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -39,7 +39,7 @@ public class RepeatRequestInterceptor implements Interceptor {
|
||||
// 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);
|
||||
Log.e(TAG, "请求体返回:| Response: " + request.url() + "\t body: " + content);
|
||||
}
|
||||
//相同的请求
|
||||
String requestKey = MD5Util.getUpperMD5Str(request.method() + request.url().toString() + requestBodyToString(request.body()));
|
||||
|
||||
17
src/com/uiuipad/os/service/MainSContact.java
Normal file
17
src/com/uiuipad/os/service/MainSContact.java
Normal file
@@ -0,0 +1,17 @@
|
||||
package com.uiuipad.os.service;
|
||||
|
||||
import com.uiuipad.os.base.BasePresenter;
|
||||
import com.uiuipad.os.base.BaseView;
|
||||
|
||||
|
||||
public class MainSContact {
|
||||
interface Presenter extends BasePresenter<MainView> {
|
||||
void getTimeManageSn();
|
||||
void getTimeManageApp();
|
||||
}
|
||||
|
||||
public interface MainView extends BaseView {
|
||||
void getTimeManageSnFinish();
|
||||
void getTimeManageAppFinish();
|
||||
}
|
||||
}
|
||||
131
src/com/uiuipad/os/service/MainSPresenter.java
Normal file
131
src/com/uiuipad/os/service/MainSPresenter.java
Normal file
@@ -0,0 +1,131 @@
|
||||
package com.uiuipad.os.service;
|
||||
|
||||
import android.content.Context;
|
||||
import android.util.Log;
|
||||
|
||||
import com.tencent.mmkv.MMKV;
|
||||
|
||||
import com.trello.rxlifecycle4.RxLifecycle;
|
||||
import com.trello.rxlifecycle4.android.ActivityEvent;
|
||||
import com.uiuipad.os.comm.CommonConfig;
|
||||
import com.uiuipad.os.gson.GsonUtils;
|
||||
import com.uiuipad.os.manager.TimeControlManager;
|
||||
import com.uiuipad.os.network.NetInterfaceManager;
|
||||
import com.uiuipad.os.network.UrlAddress;
|
||||
import com.uiuipad.os.network.bean.BaseResponse;
|
||||
import com.uiuipad.os.network.bean.TimeManageApp;
|
||||
import com.uiuipad.os.network.bean.TimeManageSn;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import io.reactivex.rxjava3.core.Observer;
|
||||
import io.reactivex.rxjava3.disposables.Disposable;
|
||||
import io.reactivex.rxjava3.subjects.BehaviorSubject;
|
||||
|
||||
/**
|
||||
* @author fanhuitong
|
||||
*/
|
||||
public class MainSPresenter implements MainSContact.Presenter {
|
||||
private static final String TAG = MainSPresenter.class.getSimpleName();
|
||||
|
||||
private MainSContact.MainView mView;
|
||||
private Context mContext;
|
||||
|
||||
private MMKV mMMKV = MMKV.mmkvWithID(CommonConfig.MMKV_ID, MMKV.MULTI_PROCESS_MODE);
|
||||
|
||||
public MainSPresenter(Context context) {
|
||||
this.mContext = context;
|
||||
}
|
||||
|
||||
private BehaviorSubject<ActivityEvent> lifecycle;
|
||||
|
||||
public void setLifecycle(BehaviorSubject<ActivityEvent> lifecycle) {
|
||||
this.lifecycle = lifecycle;
|
||||
}
|
||||
|
||||
public BehaviorSubject<ActivityEvent> getLifecycle() {
|
||||
return lifecycle;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void attachView(MainSContact.MainView view) {
|
||||
this.mView = view;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void detachView() {
|
||||
this.mView = null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getTimeManageSn() {
|
||||
NetInterfaceManager.getInstance().getTimeManageSnObservable()
|
||||
.compose(RxLifecycle.bindUntilEvent(getLifecycle(), ActivityEvent.DESTROY))
|
||||
.safeSubscribe(new Observer<BaseResponse<TimeManageSn>>() {
|
||||
@Override
|
||||
public void onSubscribe(Disposable d) {
|
||||
Log.e("getTimeManageSn", "onSubscribe: ");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNext(BaseResponse<TimeManageSn> timeManageSnBaseResponse) {
|
||||
Log.e("getTimeManageSn", "onNext: " + timeManageSnBaseResponse);
|
||||
if (timeManageSnBaseResponse.code == 200) {
|
||||
TimeManageSn timeManageSn = timeManageSnBaseResponse.data;
|
||||
TimeControlManager.getInstance().setGlobalMachineControl(timeManageSn);
|
||||
mMMKV.encode(UrlAddress.GET_TIME_MANAGE_SN, GsonUtils.toJSONString(timeManageSn));
|
||||
} else {
|
||||
mMMKV.encode(UrlAddress.GET_TIME_MANAGE_SN, GsonUtils.toJSONString(""));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(Throwable e) {
|
||||
Log.e("getTimeManageSn", "onError: " + e.getMessage());
|
||||
onComplete();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onComplete() {
|
||||
Log.e("getTimeManageSn", "onComplete: ");
|
||||
mView.getTimeManageSnFinish();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getTimeManageApp() {
|
||||
NetInterfaceManager.getInstance().getTimeManageAppObservable()
|
||||
.compose(RxLifecycle.bindUntilEvent(getLifecycle(), ActivityEvent.DESTROY))
|
||||
.subscribe(new Observer<BaseResponse<List<TimeManageApp>>>() {
|
||||
@Override
|
||||
public void onSubscribe(Disposable d) {
|
||||
Log.e("getTimeManageApp", "onSubscribe: ");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNext(BaseResponse<List<TimeManageApp>> listBaseResponse) {
|
||||
Log.e("getTimeManageApp", "onNext: " + listBaseResponse);
|
||||
if (listBaseResponse.code == 200) {
|
||||
List<TimeManageApp> timeManageApps = listBaseResponse.data;
|
||||
TimeControlManager.getInstance().setAppTimeControlMap(timeManageApps);
|
||||
mMMKV.encode(UrlAddress.GET_TIME_MANAGE_APP, GsonUtils.toJSONString(timeManageApps));
|
||||
} else {
|
||||
mMMKV.encode(UrlAddress.GET_TIME_MANAGE_APP, GsonUtils.toJSONString(""));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(Throwable e) {
|
||||
Log.e("getTimeManageApp", "onError: " + e.getMessage());
|
||||
onComplete();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onComplete() {
|
||||
Log.e("getTimeManageApp", "onComplete: ");
|
||||
mView.getTimeManageAppFinish();
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -5,55 +5,82 @@ import android.content.BroadcastReceiver;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.content.IntentFilter;
|
||||
import android.os.Binder;
|
||||
import android.os.IBinder;
|
||||
import android.os.PowerManager;
|
||||
import android.text.TextUtils;
|
||||
import android.util.Log;
|
||||
|
||||
import com.uiuipad.os.BuildConfig;
|
||||
import com.uiuipad.os.network.NetInterfaceManager;
|
||||
import com.uiuipad.os.network.bean.BaseResponse;
|
||||
import com.uiuipad.os.uiuiutils.APKUtils;
|
||||
import com.uiuipad.os.uiuiutils.CmdUtil;
|
||||
import com.uiuipad.os.uiuiutils.ForegroundAppUtil;
|
||||
import com.uiuipad.os.uiuiutils.TimeUtils;
|
||||
import com.uiuipad.os.uiuiutils.Utils;
|
||||
import com.blankj.utilcode.util.NetworkUtils;
|
||||
import com.trello.rxlifecycle4.LifecycleProvider;
|
||||
import com.trello.rxlifecycle4.LifecycleTransformer;
|
||||
import com.trello.rxlifecycle4.RxLifecycle;
|
||||
import com.trello.rxlifecycle4.android.ActivityEvent;
|
||||
import com.trello.rxlifecycle4.android.RxLifecycleAndroid;
|
||||
import com.uiuipad.os.uiuiutils.ApkUtils;
|
||||
import com.arialyy.annotations.Download;
|
||||
import com.arialyy.aria.core.Aria;
|
||||
import com.arialyy.aria.core.task.DownloadTask;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import io.reactivex.Observable;
|
||||
import io.reactivex.ObservableEmitter;
|
||||
import io.reactivex.ObservableOnSubscribe;
|
||||
import io.reactivex.Observer;
|
||||
import io.reactivex.android.schedulers.AndroidSchedulers;
|
||||
import io.reactivex.disposables.Disposable;
|
||||
import io.reactivex.schedulers.Schedulers;
|
||||
import okhttp3.MediaType;
|
||||
import okhttp3.MultipartBody;
|
||||
import okhttp3.RequestBody;
|
||||
import io.reactivex.rxjava3.core.Observable;
|
||||
import io.reactivex.rxjava3.subjects.BehaviorSubject;
|
||||
|
||||
public class MainService extends Service {
|
||||
public class MainService extends Service implements MainSContact.MainView , LifecycleProvider<ActivityEvent> {
|
||||
private String TAG = MainService.class.getSimpleName();
|
||||
|
||||
|
||||
|
||||
public MainSPresenter mPresenter;
|
||||
|
||||
|
||||
public MainService() {
|
||||
}
|
||||
|
||||
private BehaviorSubject<ActivityEvent> lifecycleSubject = BehaviorSubject.create();
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public Observable<ActivityEvent> lifecycle() {
|
||||
return lifecycleSubject.hide();
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public <T> LifecycleTransformer<T> bindUntilEvent(@NotNull ActivityEvent event) {
|
||||
return RxLifecycle.bindUntilEvent(lifecycleSubject, event);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public <T> LifecycleTransformer<T> bindToLifecycle() {
|
||||
return RxLifecycleAndroid.bindActivity(lifecycleSubject);
|
||||
}
|
||||
|
||||
@Override
|
||||
public IBinder onBind(Intent intent) {
|
||||
return null;
|
||||
return mMainBinder;
|
||||
}
|
||||
|
||||
public MainBinder mMainBinder = new MainBinder();
|
||||
|
||||
public class MainBinder extends Binder {
|
||||
public MainService getService() {
|
||||
return MainService.this;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCreate() {
|
||||
super.onCreate();
|
||||
Log.e(TAG, "onCreate: ");
|
||||
registerTimeReceiver();
|
||||
Aria.download(this).register();
|
||||
super.onCreate();
|
||||
|
||||
lifecycleSubject.onNext(ActivityEvent.CREATE);
|
||||
mPresenter = new MainSPresenter(this);
|
||||
mPresenter.setLifecycle(lifecycleSubject);
|
||||
mPresenter.attachView(this);
|
||||
mPresenter.getTimeManageSn();
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -75,6 +102,16 @@ public class MainService extends Service {
|
||||
|
||||
private TimeChangedReceiver mTimeChangedReceiver;
|
||||
|
||||
@Override
|
||||
public void getTimeManageSnFinish() {
|
||||
mPresenter.getTimeManageApp();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getTimeManageAppFinish() {
|
||||
|
||||
}
|
||||
|
||||
private class TimeChangedReceiver extends BroadcastReceiver {
|
||||
|
||||
@Override
|
||||
@@ -96,6 +133,8 @@ public class MainService extends Service {
|
||||
@Override
|
||||
public void onDestroy() {
|
||||
super.onDestroy();
|
||||
lifecycleSubject.onNext(ActivityEvent.DESTROY);
|
||||
mPresenter.detachView();
|
||||
if (mTimeChangedReceiver != null) {
|
||||
unregisterReceiver(mTimeChangedReceiver);
|
||||
}
|
||||
@@ -108,7 +147,7 @@ public class MainService extends Service {
|
||||
|
||||
@Download.onTaskComplete
|
||||
void taskComplete(DownloadTask task) {
|
||||
APKUtils.installApp(MainService.this, task.getFilePath());
|
||||
ApkUtils.installApp(MainService.this, task.getFilePath());
|
||||
Aria.download(this).load(task.getDownloadEntity().getId()).cancel();
|
||||
}
|
||||
|
||||
|
||||
@@ -44,6 +44,7 @@ import com.uiuipad.os.ItemInfo;
|
||||
import com.uiuipad.os.Launcher;
|
||||
import com.uiuipad.os.LauncherAppWidgetInfo;
|
||||
import com.uiuipad.os.LauncherAppWidgetProviderInfo;
|
||||
import com.uiuipad.os.manager.RunningAppManager;
|
||||
import com.uiuipad.os.uiuiutils.CustomDialog;
|
||||
import com.uiuipad.os.uiuiutils.JGYUtils;
|
||||
import com.uiuipad.os.uiuiutils.ToastUtil;
|
||||
@@ -112,6 +113,10 @@ public class ItemClickHandler {
|
||||
// if (is_forbid(v.getContext(), packageName)) {
|
||||
// return;
|
||||
// }
|
||||
if (RunningAppManager.getInstance().inControlTime(packageName)){
|
||||
ToastUtil.show(RunningAppManager.getInstance().getDisableContent(packageName));
|
||||
return;
|
||||
}
|
||||
//获取本地密码
|
||||
String ApplicationLock = MMKV.defaultMMKV().decodeString("ApplicationLock");
|
||||
Log.e("onClick", "onClick: " + ApplicationLock);
|
||||
|
||||
@@ -26,7 +26,7 @@ import java.io.InputStreamReader;
|
||||
import java.io.OutputStream;
|
||||
import java.util.List;
|
||||
|
||||
public class APKUtils {
|
||||
public class ApkUtils {
|
||||
public static boolean openPackage(Context context, String packageName) {
|
||||
Context pkgContext = getPackageContext(context, packageName);
|
||||
Intent intent = getAppOpenIntentByPackageName(context, packageName);
|
||||
@@ -1,29 +0,0 @@
|
||||
package com.uiuipad.os.uiuiutils;
|
||||
|
||||
import com.google.gson.Gson;
|
||||
import com.google.gson.JsonObject;
|
||||
import com.google.gson.JsonParser;
|
||||
import com.google.gson.reflect.TypeToken;
|
||||
|
||||
import java.lang.reflect.Type;
|
||||
|
||||
|
||||
public class GsonUtils {
|
||||
public static JsonObject getJsonObject(String jsonString) {
|
||||
JsonObject jsonObject = JsonParser.parseString(jsonString).getAsJsonObject();
|
||||
return jsonObject;
|
||||
}
|
||||
|
||||
// TODO: 2022/3/31 暂时没有实现
|
||||
public static <E> E getJsonFromType(String jsonString) {
|
||||
Gson gson = new Gson();
|
||||
Type Type = new TypeToken<E>() {
|
||||
}.getType();
|
||||
E e = gson.fromJson(jsonString, Type);
|
||||
return e;
|
||||
}
|
||||
|
||||
public static String toJsonString(Object o) {
|
||||
return new Gson().toJson(o);
|
||||
}
|
||||
}
|
||||
BIN
src/doc/iPlay50SE.keystore
Normal file
BIN
src/doc/iPlay50SE.keystore
Normal file
Binary file not shown.
Reference in New Issue
Block a user