feat: 网络请求增加内存缓存,修改MainService为mvvm模式
This commit is contained in:
@@ -16,6 +16,7 @@ import android.media.MediaPlayer;
|
||||
import android.os.BatteryManager;
|
||||
import android.os.Build;
|
||||
import android.os.Handler;
|
||||
import android.os.Looper;
|
||||
import android.os.PowerManager;
|
||||
import android.provider.Settings;
|
||||
import android.text.TextUtils;
|
||||
@@ -35,13 +36,11 @@ import com.aoleyun.sn.bean.ScreenLockState;
|
||||
import com.aoleyun.sn.comm.CommonConfig;
|
||||
import com.aoleyun.sn.comm.JGYActions;
|
||||
import com.aoleyun.sn.dialog.CustomDialog;
|
||||
import com.aoleyun.sn.disklrucache.CacheHelper;
|
||||
import com.aoleyun.sn.gson.GsonUtils;
|
||||
import com.aoleyun.sn.gson.NullStringToEmptyAdapterFactory;
|
||||
import com.aoleyun.sn.manager.MapManager;
|
||||
import com.aoleyun.sn.network.NetInterfaceManager;
|
||||
import com.aoleyun.sn.network.RetryCallback;
|
||||
import com.aoleyun.sn.network.UrlAddress;
|
||||
import com.aoleyun.sn.service.main.MainService;
|
||||
import com.aoleyun.sn.utils.ApkUtils;
|
||||
import com.aoleyun.sn.utils.BatteryUtils;
|
||||
@@ -96,8 +95,8 @@ import retrofit2.Response;
|
||||
public class PushManager {
|
||||
private static final String TAG = "PushManager";
|
||||
|
||||
public static final String ACTION_REFRESH_BINDING_STATUS = "RefreshBindingStatus";
|
||||
public static final String AOLEYUN_REFRESH_DESKTOP = "aoleyun_refresh_desktop_action";
|
||||
private static final String ACTION_REFRESH_BINDING_STATUS = "RefreshBindingStatus";
|
||||
private static final String AOLEYUN_REFRESH_DESKTOP = "aoleyun_refresh_desktop_action";
|
||||
|
||||
|
||||
@SuppressLint("StaticFieldLeak")
|
||||
@@ -105,7 +104,6 @@ public class PushManager {
|
||||
private Context mContext;
|
||||
private PackageManager mPackageManager;
|
||||
private ContentResolver mResolver;
|
||||
private CacheHelper mCacheHelper;
|
||||
private MMKV mMMKV = MMKV.mmkvWithID(CommonConfig.MMKV_ID, MMKV.MULTI_PROCESS_MODE);
|
||||
|
||||
private PushManager(Context context) {
|
||||
@@ -114,7 +112,6 @@ public class PushManager {
|
||||
}
|
||||
this.mContext = context;
|
||||
this.mResolver = context.getContentResolver();
|
||||
this.mCacheHelper = new CacheHelper(context);
|
||||
this.mPackageManager = mContext.getPackageManager();
|
||||
}
|
||||
|
||||
@@ -320,7 +317,7 @@ public class PushManager {
|
||||
case MSG_INSTALL:
|
||||
Toaster.debugShow("收到管控:应用安装");
|
||||
doDownloadAndInstall(extras);
|
||||
Handler.getMain().postDelayed(new Runnable() {
|
||||
new Handler(Looper.getMainLooper()).postDelayed(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
NetInterfaceManager.getInstance().getDesktopIcon();
|
||||
@@ -355,7 +352,7 @@ public class PushManager {
|
||||
downloadForceInstallApk(extras);
|
||||
break;
|
||||
case SET_HOMEPAG_TAG:
|
||||
Handler.getMain().postDelayed(new Runnable() {
|
||||
new Handler(Looper.getMainLooper()).postDelayed(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
try {
|
||||
@@ -380,7 +377,7 @@ public class PushManager {
|
||||
break;
|
||||
case HIDE_DESKTOP_ICON:
|
||||
Toaster.debugShow("收到管控:隐藏应用设置");
|
||||
Handler.getMain().postDelayed(() -> {
|
||||
new Handler(Looper.getMainLooper()).postDelayed(() -> {
|
||||
//后台发送时数据库未改变,有时候可能获取到的数据时上一次的
|
||||
Log.e(TAG, "run: HIDE_DESKTOP_ICON ");
|
||||
NetInterfaceManager.getInstance().getDesktopIcon();
|
||||
@@ -732,7 +729,7 @@ public class PushManager {
|
||||
}
|
||||
}
|
||||
ApkUtils.UninstallAPP(mContext, pkg);
|
||||
Handler.getMain().postDelayed(new Runnable() {
|
||||
new Handler(Looper.getMainLooper()).postDelayed(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
NetInterfaceManager.getInstance().getDesktopIcon();
|
||||
@@ -757,7 +754,7 @@ public class PushManager {
|
||||
} catch (Exception e) {
|
||||
Log.e(TAG, "disableApp: " + e.getMessage());
|
||||
}
|
||||
Handler.getMain().postDelayed(() -> NetInterfaceManager.getInstance().getSnAppAttr(), 1234);
|
||||
new Handler(Looper.getMainLooper()).postDelayed(() -> NetInterfaceManager.getInstance().getSnAppAttr(), 1234);
|
||||
}
|
||||
|
||||
private void setLock_screen(int state, String name) {
|
||||
@@ -767,7 +764,6 @@ public class PushManager {
|
||||
ScreenLockState screenLockState = new ScreenLockState();
|
||||
screenLockState.setIs_screen_lock(state);
|
||||
screenLockState.setName(name);
|
||||
mCacheHelper.put(UrlAddress.GET_LOCK_SCREEN_STATE, GsonUtils.toJSONString(screenLockState));
|
||||
Intent intent = new Intent();
|
||||
intent.putExtra("name", name);
|
||||
if (state == 1) {
|
||||
@@ -1000,7 +996,7 @@ public class PushManager {
|
||||
JgyUtils.release(mWakeLock);
|
||||
if (createTime != 0) {
|
||||
Log.e("createTime", String.valueOf(createTime));
|
||||
Handler.getMain().postDelayed(new Runnable() {
|
||||
new Handler(Looper.getMainLooper()).postDelayed(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
doscreenshot(createTime);
|
||||
@@ -1118,7 +1114,6 @@ public class PushManager {
|
||||
|
||||
private void getTopApp(String extras) {
|
||||
JsonObject jsonObject = GsonUtils.getJsonObject(extras);
|
||||
mCacheHelper.put(UrlAddress.GET_TOP_APP_CONTROL, extras);
|
||||
|
||||
String packageName = jsonObject.get("app_package").getAsString();
|
||||
if (TextUtils.isEmpty(packageName)) {
|
||||
|
||||
Reference in New Issue
Block a user