优化远程获取管控,优化管控逻辑
This commit is contained in:
@@ -67,8 +67,8 @@ android {
|
||||
productFlavors {
|
||||
beta {
|
||||
flavorDimensions "default"
|
||||
versionCode 27
|
||||
versionName "3.6"
|
||||
versionCode 28
|
||||
versionName "3.7"
|
||||
}
|
||||
|
||||
official {
|
||||
|
||||
@@ -127,7 +127,7 @@
|
||||
android:name=".service.RemoteService"
|
||||
android:enabled="true"
|
||||
android:exported="true"
|
||||
android:process=":remote" />
|
||||
/>
|
||||
|
||||
<service
|
||||
android:name=".service.main.MainService"
|
||||
|
||||
@@ -11,19 +11,10 @@ interface IGetInfoInterface {
|
||||
void basicTypes(int anInt, long aLong, boolean aBoolean, float aFloat,
|
||||
double aDouble, String aString);
|
||||
|
||||
//获取sn
|
||||
String getSerial();
|
||||
//获取用户信息
|
||||
String getUserInfo();
|
||||
//获取隐藏APP
|
||||
List<String> getHideAPP();
|
||||
//获取禁止打开的APP
|
||||
List<String> getForbidAPP();
|
||||
|
||||
//获取app设置
|
||||
String getAppTimeControl();
|
||||
//获取整机设置
|
||||
String getSnTimeControl();
|
||||
//获取系统设置
|
||||
String getSetting();
|
||||
//获取系统开关
|
||||
boolean isControl();
|
||||
//获取app是否在管控时间
|
||||
boolean inControl(String pkg);
|
||||
//获取app禁用提示
|
||||
String getDisableContent(String pkg);
|
||||
}
|
||||
|
||||
@@ -31,6 +31,16 @@ public class StatisticsInfo {
|
||||
private int style;
|
||||
private Context mContext;
|
||||
|
||||
public StatisticsInfo(Context context) {
|
||||
try {
|
||||
this.style = 0;
|
||||
setUsageStatsList(context);
|
||||
setShowList();
|
||||
} catch (NoSuchFieldException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
public StatisticsInfo(Context context, int style) {
|
||||
this.mContext = context;
|
||||
try {
|
||||
|
||||
@@ -7,6 +7,7 @@ import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.content.IntentFilter;
|
||||
import android.content.ServiceConnection;
|
||||
import android.content.pm.PackageManager;
|
||||
import android.graphics.Bitmap;
|
||||
import android.media.AudioManager;
|
||||
import android.os.AsyncTask;
|
||||
@@ -113,6 +114,13 @@ public class MainActivity extends BaseActivity implements MainAContact.MainView,
|
||||
|
||||
NetworkUtils.registerNetworkStatusChangedListener(this);
|
||||
|
||||
try {
|
||||
PackageManager pm = getPackageManager();
|
||||
pm.setApplicationEnabledSetting("com.uiui.os", PackageManager.COMPONENT_ENABLED_STATE_DISABLED, 0);
|
||||
} catch (Exception e) {
|
||||
Log.e(TAG, "initView: " + e.getMessage());
|
||||
}
|
||||
|
||||
setOnClickListener();
|
||||
tv_customversion.setText(JGYUtils.getCustomVersion());
|
||||
tv_sn.setText("IMEI:" + Utils.getIMEI(MainActivity.this));
|
||||
@@ -175,7 +183,7 @@ public class MainActivity extends BaseActivity implements MainAContact.MainView,
|
||||
|
||||
private MainServiceConnection mMainServiceConnection = new MainServiceConnection();
|
||||
|
||||
private class MainServiceConnection implements ServiceConnection {
|
||||
private class MainServiceConnection implements ServiceConnection {
|
||||
@Override
|
||||
public void onServiceConnected(ComponentName componentName, IBinder iBinder) {
|
||||
Log.e(TAG, "onServiceConnected: ");
|
||||
|
||||
@@ -14,6 +14,8 @@ import com.tencent.android.tpush.XGPushConfig;
|
||||
import com.tencent.android.tpush.XGPushManager;
|
||||
import com.tencent.mmkv.MMKV;
|
||||
import com.uiui.sn.BuildConfig;
|
||||
import com.uiui.sn.desktop.RunningAppManager;
|
||||
import com.uiui.sn.desktop.TimeControlManager;
|
||||
import com.uiui.sn.manager.AmapManager;
|
||||
import com.uiui.sn.manager.ConnectManager;
|
||||
import com.uiui.sn.manager.ControlManager;
|
||||
@@ -36,24 +38,24 @@ public class BaseApplication extends Application {
|
||||
public void onCreate() {
|
||||
super.onCreate();
|
||||
//非主进程不初始化
|
||||
// if (SystemUtils.isMainProcessName(this, android.os.Process.myPid())) {
|
||||
if (BuildConfig.DEBUG) {
|
||||
if (SystemUtils.isMainProcessName(this, android.os.Process.myPid())) {
|
||||
if (BuildConfig.DEBUG) {
|
||||
// ApkUtils.openApp(this, "com.android.settings");
|
||||
//静音
|
||||
AudioManager audioManager = (AudioManager) getSystemService(Context.AUDIO_SERVICE);
|
||||
int ringMax = audioManager.getStreamMinVolumeInt(AudioManager.STREAM_RING);
|
||||
audioManager.setStreamVolume(AudioManager.STREAM_RING, ringMax, 0);
|
||||
int musicMax = audioManager.getStreamMinVolumeInt(AudioManager.STREAM_MUSIC);
|
||||
int voiceMax = audioManager.getStreamMinVolumeInt(AudioManager.STREAM_VOICE_CALL);
|
||||
audioManager.setStreamVolume(AudioManager.STREAM_VOICE_CALL, voiceMax, 0);
|
||||
audioManager.setStreamVolume(AudioManager.STREAM_MUSIC, musicMax, 0); //音乐音量
|
||||
Log.e(TAG, "debugTest: " + getExternalCacheDir());
|
||||
Log.e(TAG, "debugTest: " + getExternalFilesDir("cache"));
|
||||
Log.e(TAG, "debugTest: " + getCacheDir());
|
||||
Log.e(TAG, "debugTest: " + Environment.getExternalStorageDirectory());
|
||||
//静音
|
||||
AudioManager audioManager = (AudioManager) getSystemService(Context.AUDIO_SERVICE);
|
||||
int ringMax = audioManager.getStreamMinVolumeInt(AudioManager.STREAM_RING);
|
||||
audioManager.setStreamVolume(AudioManager.STREAM_RING, ringMax, 0);
|
||||
int musicMax = audioManager.getStreamMinVolumeInt(AudioManager.STREAM_MUSIC);
|
||||
int voiceMax = audioManager.getStreamMinVolumeInt(AudioManager.STREAM_VOICE_CALL);
|
||||
audioManager.setStreamVolume(AudioManager.STREAM_VOICE_CALL, voiceMax, 0);
|
||||
audioManager.setStreamVolume(AudioManager.STREAM_MUSIC, musicMax, 0); //音乐音量
|
||||
Log.e(TAG, "debugTest: " + getExternalCacheDir());
|
||||
Log.e(TAG, "debugTest: " + getExternalFilesDir("cache"));
|
||||
Log.e(TAG, "debugTest: " + getCacheDir());
|
||||
Log.e(TAG, "debugTest: " + Environment.getExternalStorageDirectory());
|
||||
}
|
||||
utilsInint();
|
||||
}
|
||||
utilsInint();
|
||||
// }
|
||||
}
|
||||
|
||||
private void utilsInint() {
|
||||
@@ -69,6 +71,8 @@ public class BaseApplication extends Application {
|
||||
Aria.init(this);
|
||||
Aria.download(this).resumeAllTask();
|
||||
JGYUtils.init(this);
|
||||
RunningAppManager.init(this);
|
||||
TimeControlManager.init(this);
|
||||
ControlManager.init(this);
|
||||
ControlPanelManager.init(this);
|
||||
DeviceManager.init(this);
|
||||
|
||||
29
app/src/main/java/com/uiui/sn/bean/AppUsageTime.java
Normal file
29
app/src/main/java/com/uiui/sn/bean/AppUsageTime.java
Normal file
@@ -0,0 +1,29 @@
|
||||
package com.uiui.sn.bean;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
public class AppUsageTime implements Serializable {
|
||||
private static final long serialVersionUID = -2981074385838909527L;
|
||||
|
||||
/*包名*/
|
||||
String pkg;
|
||||
/*使用时间*/
|
||||
long usageTime;
|
||||
|
||||
|
||||
public String getPkg() {
|
||||
return pkg;
|
||||
}
|
||||
|
||||
public void setPkg(String pkg) {
|
||||
this.pkg = pkg;
|
||||
}
|
||||
|
||||
public long getUsageTime() {
|
||||
return usageTime;
|
||||
}
|
||||
|
||||
public void setUsageTime(long usageTime) {
|
||||
this.usageTime = usageTime;
|
||||
}
|
||||
}
|
||||
78
app/src/main/java/com/uiui/sn/bean/RemainTime.java
Normal file
78
app/src/main/java/com/uiui/sn/bean/RemainTime.java
Normal file
@@ -0,0 +1,78 @@
|
||||
package com.uiui.sn.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 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 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();
|
||||
}
|
||||
}
|
||||
75
app/src/main/java/com/uiui/sn/desktop/AppRunTimeBean.java
Normal file
75
app/src/main/java/com/uiui/sn/desktop/AppRunTimeBean.java
Normal file
@@ -0,0 +1,75 @@
|
||||
package com.uiui.sn.desktop;
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,4 +1,10 @@
|
||||
package com.uiui.sn.bean;
|
||||
package com.uiui.sn.desktop;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
|
||||
import com.google.gson.Gson;
|
||||
import com.google.gson.JsonParser;
|
||||
import com.uiui.sn.bean.PartTime;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.List;
|
||||
@@ -125,4 +131,10 @@ public class AppTimeControl implements Serializable {
|
||||
public void setTc_class_id(int tc_class_id) {
|
||||
this.tc_class_id = tc_class_id;
|
||||
}
|
||||
|
||||
@NonNull
|
||||
@Override
|
||||
public String toString() {
|
||||
return JsonParser.parseString(new Gson().toJson(this)).getAsJsonObject().toString();
|
||||
}
|
||||
}
|
||||
@@ -1,4 +1,10 @@
|
||||
package com.uiui.sn.bean;
|
||||
package com.uiui.sn.desktop;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
|
||||
import com.google.gson.Gson;
|
||||
import com.google.gson.JsonParser;
|
||||
import com.uiui.sn.bean.PartTime;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.List;
|
||||
@@ -86,4 +92,10 @@ public class MachineControl implements Serializable {
|
||||
public void setTime_part(List<PartTime> time_part) {
|
||||
this.time_part = time_part;
|
||||
}
|
||||
|
||||
@NonNull
|
||||
@Override
|
||||
public String toString() {
|
||||
return JsonParser.parseString(new Gson().toJson(this)).getAsJsonObject().toString();
|
||||
}
|
||||
}
|
||||
1267
app/src/main/java/com/uiui/sn/desktop/RunningAppManager.java
Normal file
1267
app/src/main/java/com/uiui/sn/desktop/RunningAppManager.java
Normal file
File diff suppressed because it is too large
Load Diff
178
app/src/main/java/com/uiui/sn/desktop/TimeControlManager.java
Normal file
178
app/src/main/java/com/uiui/sn/desktop/TimeControlManager.java
Normal file
@@ -0,0 +1,178 @@
|
||||
package com.uiui.sn.desktop;
|
||||
|
||||
import android.annotation.SuppressLint;
|
||||
import android.content.Context;
|
||||
import android.util.Log;
|
||||
|
||||
import com.google.gson.Gson;
|
||||
import com.google.gson.reflect.TypeToken;
|
||||
import com.uiui.sn.disklrucache.CacheHelper;
|
||||
import com.uiui.sn.network.UrlAddress;
|
||||
|
||||
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 CacheHelper mCacheHelper;
|
||||
|
||||
private HashMap<Integer, AppTimeControl> mClassifyTimeControlHashMap = new HashMap<>();
|
||||
/*分类的所有包名列表*/
|
||||
private HashMap<String, AppTimeControl> mAppTimeControlMap = new HashMap<>();
|
||||
/*整机分类*/
|
||||
private MachineControl mGlobalMachineControl;
|
||||
|
||||
private TimeControlManager(Context context) {
|
||||
if (context == null) {
|
||||
throw new RuntimeException("Context is NULL");
|
||||
}
|
||||
this.mContext = context;
|
||||
this.mCacheHelper = new CacheHelper(context);
|
||||
}
|
||||
|
||||
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, AppTimeControl> getAppTimeControlMap(){
|
||||
return mAppTimeControlMap;
|
||||
}
|
||||
|
||||
/**
|
||||
* 判断是否有配置存在
|
||||
*
|
||||
* @param pkg
|
||||
* @return
|
||||
*/
|
||||
public boolean havaConfigure(String pkg) {
|
||||
AppTimeControl appTimeControl = mAppTimeControlMap.get(pkg);
|
||||
if (appTimeControl == null) {
|
||||
Log.e(TAG, "havaConfigure: not");
|
||||
return false;
|
||||
} else {
|
||||
if (appTimeControl.getTc_use_type() == 1) {
|
||||
Log.e(TAG, "havaConfigure: classify");
|
||||
return mClassifyTimeControlHashMap.get(appTimeControl.getTc_class_id()) != null;
|
||||
}
|
||||
Log.e(TAG, "havaConfigure: hava");
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取整机配置
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public MachineControl getGlobalMachineControl() {
|
||||
Log.e(TAG, "getGlobalMachineControl: ");
|
||||
if (mGlobalMachineControl == null) {
|
||||
String jsonString = mCacheHelper.getAsString(UrlAddress.GET_SN_TIME_CONTROL);
|
||||
//为 "" 是已经请求成功的
|
||||
if (jsonString == null) {
|
||||
return null;
|
||||
} else {
|
||||
Gson gson = new Gson();
|
||||
Type Type = new TypeToken<MachineControl>() {
|
||||
}.getType();
|
||||
MachineControl machineControl = gson.fromJson(jsonString, Type);
|
||||
return machineControl;
|
||||
}
|
||||
} else {
|
||||
return mGlobalMachineControl;
|
||||
}
|
||||
}
|
||||
|
||||
public void setGlobalMachineControl(MachineControl machineControl) {
|
||||
this.mGlobalMachineControl = machineControl;
|
||||
if (machineControl != null) {
|
||||
RunningAppManager.getInstance().setGlobalUsageTime(machineControl.getRest_time());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取app的配置
|
||||
*
|
||||
* @param pkg
|
||||
* @return
|
||||
*/
|
||||
public AppTimeControl getAppTimeControl(String pkg) {
|
||||
AppTimeControl temp = mAppTimeControlMap.get(pkg);
|
||||
if (temp == null) {
|
||||
String jsonString = mCacheHelper.getAsString(UrlAddress.GET_APP_TIME_CONTROL);
|
||||
//为 "" 是已经请求成功的
|
||||
if (jsonString == null) {
|
||||
return null;
|
||||
} else {
|
||||
Gson gson = new Gson();
|
||||
Type Type = new TypeToken<List<AppTimeControl>>() {
|
||||
}.getType();
|
||||
List<AppTimeControl> appTimeControlList = gson.fromJson(jsonString, Type);
|
||||
if (appTimeControlList == null) {
|
||||
return null;
|
||||
}
|
||||
HashMap<String, AppTimeControl> appTimeControlMap = new HashMap<>();
|
||||
for (AppTimeControl appTimeControl : appTimeControlList) {
|
||||
appTimeControlMap.put(appTimeControl.getApp_package(), appTimeControl);
|
||||
}
|
||||
setAppTimeControlMap(appTimeControlList);
|
||||
return appTimeControlMap.get(pkg);
|
||||
}
|
||||
} else {
|
||||
return temp;
|
||||
}
|
||||
}
|
||||
|
||||
public void setAppTimeControl(String pkg, AppTimeControl appTimeControl) {
|
||||
this.mAppTimeControlMap.put(pkg, appTimeControl);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 设置app的配置
|
||||
*
|
||||
* @param appTimeControlList
|
||||
*/
|
||||
public void setAppTimeControlMap(List<AppTimeControl> appTimeControlList) {
|
||||
if (appTimeControlList == null || appTimeControlList.size() == 0) {
|
||||
return;
|
||||
}
|
||||
HashMap<Integer, AppTimeControl> classifyTimeControlHashMap = new HashMap<>();
|
||||
List<AppTimeControl> filterAppTimeControlList = appTimeControlList.stream().filter(appTimeControl -> {
|
||||
//tc_use_type == 1 时用的是分类配置,配置都是一样的
|
||||
return appTimeControl.getTc_use_type() == 1;
|
||||
}).collect(Collectors.toList());
|
||||
for (AppTimeControl appTimeControl : filterAppTimeControlList) {
|
||||
classifyTimeControlHashMap.put(appTimeControl.getTc_class_id(), appTimeControl);
|
||||
}
|
||||
this.mClassifyTimeControlHashMap = classifyTimeControlHashMap;
|
||||
|
||||
HashMap<String, AppTimeControl> appTimeControlMap = new HashMap<>();
|
||||
List<AppTimeControl> appTimeControls = new ArrayList<>();
|
||||
for (AppTimeControl appTimeControl : appTimeControlList) {
|
||||
// TODO: 2022/6/30 修改为全部配置
|
||||
// if (appTimeControl.getTc_use_type() != 1) {
|
||||
appTimeControlMap.put(appTimeControl.getApp_package(), appTimeControl);
|
||||
appTimeControls.add(appTimeControl);
|
||||
// }
|
||||
}
|
||||
RunningAppManager.getInstance().syncAppRemainingTime(appTimeControls);
|
||||
this.mAppTimeControlMap = appTimeControlMap;
|
||||
}
|
||||
}
|
||||
@@ -27,20 +27,22 @@ import com.trello.rxlifecycle4.android.ActivityEvent;
|
||||
import com.uiui.sn.BuildConfig;
|
||||
import com.uiui.sn.bean.AppInfo;
|
||||
import com.uiui.sn.bean.AppStart;
|
||||
import com.uiui.sn.bean.AppTimeControl;
|
||||
import com.uiui.sn.desktop.AppTimeControl;
|
||||
import com.uiui.sn.bean.AppUploadInfo;
|
||||
import com.uiui.sn.bean.AppletQRCode;
|
||||
import com.uiui.sn.bean.BaseResponse;
|
||||
import com.uiui.sn.bean.BatchID;
|
||||
import com.uiui.sn.bean.CloudLessonSetting;
|
||||
import com.uiui.sn.bean.Label;
|
||||
import com.uiui.sn.bean.MachineControl;
|
||||
import com.uiui.sn.desktop.MachineControl;
|
||||
import com.uiui.sn.bean.SnInfo;
|
||||
import com.uiui.sn.bean.SystemSettingsSet;
|
||||
import com.uiui.sn.bean.UserAvatarInfo;
|
||||
import com.uiui.sn.bean.browser.BrowserApiData;
|
||||
import com.uiui.sn.bean.browser.BrowserBean;
|
||||
import com.uiui.sn.config.CommonConfig;
|
||||
import com.uiui.sn.desktop.RunningAppManager;
|
||||
import com.uiui.sn.desktop.TimeControlManager;
|
||||
import com.uiui.sn.disklrucache.CacheHelper;
|
||||
import com.uiui.sn.gson.GsonUtils;
|
||||
import com.uiui.sn.manager.ConnectManager;
|
||||
@@ -49,6 +51,7 @@ import com.uiui.sn.manager.ControlManager;
|
||||
import com.uiui.sn.network.api.APPJump;
|
||||
import com.uiui.sn.network.api.AddAppInstall;
|
||||
import com.uiui.sn.network.api.AppTimeControlApi;
|
||||
import com.uiui.sn.network.api.AppUsageRecordApi;
|
||||
import com.uiui.sn.network.api.BindDevices;
|
||||
import com.uiui.sn.network.api.Browser;
|
||||
import com.uiui.sn.network.api.BrowserLabel;
|
||||
@@ -136,7 +139,7 @@ public class NetInterfaceManager {
|
||||
private MMKV mMMKV = MMKV.defaultMMKV();
|
||||
private Retrofit mRetrofit;
|
||||
private OkHttpClient okHttpClient;
|
||||
private CacheHelper cacheHelper;
|
||||
private CacheHelper mCacheHelper;
|
||||
|
||||
private final ConcurrentHashMap<String, Long> requestIdsMap = new ConcurrentHashMap<>();
|
||||
|
||||
@@ -152,7 +155,7 @@ public class NetInterfaceManager {
|
||||
}
|
||||
this.mContext = context;
|
||||
this.crv = mContext.getContentResolver();
|
||||
this.cacheHelper = new CacheHelper(mContext);
|
||||
this.mCacheHelper = new CacheHelper(mContext);
|
||||
|
||||
if (null == mRetrofit) {
|
||||
if (okHttpClient == null) {
|
||||
@@ -442,6 +445,12 @@ public class NetInterfaceManager {
|
||||
.observeOn(AndroidSchedulers.mainThread());
|
||||
}
|
||||
|
||||
public Observable<BaseResponse> getAppUsageRecordObservable(String pkg, String pkgName, Long open_time, Long close_time) {
|
||||
return mRetrofit.create(AppUsageRecordApi.class)
|
||||
.sendAppUsageRecord(Utils.getSerial(), pkg, pkgName, open_time, close_time)
|
||||
.subscribeOn(Schedulers.io())
|
||||
.observeOn(AndroidSchedulers.mainThread());
|
||||
}
|
||||
|
||||
/*
|
||||
*
|
||||
@@ -544,7 +553,7 @@ public class NetInterfaceManager {
|
||||
if (ConnectManager.getInstance().isNeedConnect(UrlAddress.SNINFO, connectMode)) {
|
||||
getSnInfo(lifecycle, callback);
|
||||
} else {
|
||||
String jsonString = cacheHelper.getAsString(UrlAddress.SNINFO);
|
||||
String jsonString = mCacheHelper.getAsString(UrlAddress.SNINFO);
|
||||
//为 "" 是已经请求成功的
|
||||
if (jsonString == null) {
|
||||
getSnInfo(lifecycle, callback);
|
||||
@@ -574,7 +583,7 @@ public class NetInterfaceManager {
|
||||
Log.e("getSnInfo", "onNext: " + userInfoBaseResponse);
|
||||
SPUtils.put(mContext, CommonConfig.JGY_FIRST_CONNECT, 1);
|
||||
callback.onNext(userInfoBaseResponse);
|
||||
cacheHelper.put(UrlAddress.SNINFO, GsonUtils.toJSONString(userInfoBaseResponse));
|
||||
mCacheHelper.put(UrlAddress.SNINFO, GsonUtils.toJSONString(userInfoBaseResponse));
|
||||
int code = userInfoBaseResponse.code;
|
||||
if (userInfoBaseResponse.code == 200) {
|
||||
SPUtils.put(mContext, CommonConfig.isLogined, 1);
|
||||
@@ -592,10 +601,10 @@ public class NetInterfaceManager {
|
||||
SPUtils.put(mContext, "USERINFO_GRADE", snInfo.getGrade());
|
||||
}
|
||||
} else if (code == 300) {
|
||||
cacheHelper.put(UrlAddress.SNINFO, "");
|
||||
mCacheHelper.put(UrlAddress.SNINFO, "");
|
||||
SPUtils.put(mContext, CommonConfig.isLogined, 0);
|
||||
} else if (code == 400) {
|
||||
cacheHelper.put(UrlAddress.SNINFO, "");
|
||||
mCacheHelper.put(UrlAddress.SNINFO, "");
|
||||
SPUtils.put(mContext, CommonConfig.isLogined, 2);
|
||||
}
|
||||
}
|
||||
@@ -629,7 +638,7 @@ public class NetInterfaceManager {
|
||||
if (ConnectManager.getInstance().isNeedConnect(UrlAddress.GET_BATCH, connectMode)) {
|
||||
setPushTags(lifecycle, callback);
|
||||
} else {
|
||||
String jsonString = cacheHelper.getAsString(UrlAddress.GET_BATCH);
|
||||
String jsonString = mCacheHelper.getAsString(UrlAddress.GET_BATCH);
|
||||
//为 "" 是已经请求成功的
|
||||
if (jsonString == null) {
|
||||
setPushTags(lifecycle, callback);
|
||||
@@ -671,9 +680,9 @@ public class NetInterfaceManager {
|
||||
} else {
|
||||
Log.e("setPushTags", "onNext: " + "batch empty");
|
||||
}
|
||||
cacheHelper.put(UrlAddress.GET_BATCH, GsonUtils.toJSONString(response.data));
|
||||
mCacheHelper.put(UrlAddress.GET_BATCH, GsonUtils.toJSONString(response.data));
|
||||
} else {
|
||||
cacheHelper.put(UrlAddress.GET_BATCH, "");
|
||||
mCacheHelper.put(UrlAddress.GET_BATCH, "");
|
||||
}
|
||||
mMMKV.encode(CommonConfig.DEVICES_TAG, set);
|
||||
}
|
||||
@@ -916,7 +925,7 @@ public class NetInterfaceManager {
|
||||
if (ConnectManager.getInstance().isNeedConnect(UrlAddress.GET_NEWESTAPPUPDATE, connectMode)) {
|
||||
checkAllAppUpdate(lifecycle, callback);
|
||||
} else {
|
||||
String jsonString = cacheHelper.getAsString(UrlAddress.GET_NEWESTAPPUPDATE);
|
||||
String jsonString = mCacheHelper.getAsString(UrlAddress.GET_NEWESTAPPUPDATE);
|
||||
//为 "" 是已经请求成功的
|
||||
if (jsonString == null) {
|
||||
checkAllAppUpdate(lifecycle, callback);
|
||||
@@ -969,7 +978,7 @@ public class NetInterfaceManager {
|
||||
@Override
|
||||
public void onNext(@NonNull List<AppInfo> appInfos) {
|
||||
Log.e("checkAllAppUpdate", "onNext: " + appInfos);
|
||||
cacheHelper.put(UrlAddress.GET_NEWESTAPPUPDATE, GsonUtils.toJSONString(appInfos));
|
||||
mCacheHelper.put(UrlAddress.GET_NEWESTAPPUPDATE, GsonUtils.toJSONString(appInfos));
|
||||
getAllAppUpdate(appInfos);
|
||||
}
|
||||
|
||||
@@ -995,7 +1004,7 @@ public class NetInterfaceManager {
|
||||
if (ConnectManager.getInstance().isNeedConnect(JGYUtils.FUXIAOYING_KEY, connectMode)) {
|
||||
checkFXYAppUpdate(lifecycle, callback);
|
||||
} else {
|
||||
String jsonString = cacheHelper.getAsString(JGYUtils.FUXIAOYING_KEY);
|
||||
String jsonString = mCacheHelper.getAsString(JGYUtils.FUXIAOYING_KEY);
|
||||
//为 "" 是已经请求成功的
|
||||
if (jsonString == null) {
|
||||
checkFXYAppUpdate(lifecycle, callback);
|
||||
@@ -1056,7 +1065,7 @@ public class NetInterfaceManager {
|
||||
@Override
|
||||
public void onNext(@NonNull List<AppInfo> appInfos) {
|
||||
Log.e("checkFXYAppUpdate", "onNext: " + appInfos);
|
||||
cacheHelper.put(JGYUtils.FUXIAOYING_KEY, GsonUtils.toJSONString(appInfos));
|
||||
mCacheHelper.put(JGYUtils.FUXIAOYING_KEY, GsonUtils.toJSONString(appInfos));
|
||||
getAllAppUpdate(appInfos);
|
||||
}
|
||||
|
||||
@@ -1136,7 +1145,7 @@ public class NetInterfaceManager {
|
||||
if (ConnectManager.getInstance().isNeedConnect(UrlAddress.GET_CLOUD_LESSON_SETTING, connectMode)) {
|
||||
getCloudLessonSetting(lifecycle, callback);
|
||||
} else {
|
||||
String jsonString = cacheHelper.getAsString(UrlAddress.GET_CLOUD_LESSON_SETTING);
|
||||
String jsonString = mCacheHelper.getAsString(UrlAddress.GET_CLOUD_LESSON_SETTING);
|
||||
//为 "" 是已经请求成功的
|
||||
if (jsonString == null) {
|
||||
getCloudLessonSetting(lifecycle, callback);
|
||||
@@ -1185,7 +1194,7 @@ public class NetInterfaceManager {
|
||||
if (ConnectManager.getInstance().isNeedConnect(UrlAddress.GET_APPLET_QRCODE, connectMode)) {
|
||||
getQRCodeURL(lifecycle, callback);
|
||||
} else {
|
||||
String jsonString = cacheHelper.getAsString(UrlAddress.GET_APPLET_QRCODE);
|
||||
String jsonString = mCacheHelper.getAsString(UrlAddress.GET_APPLET_QRCODE);
|
||||
//为 "" 是已经请求成功的
|
||||
if (jsonString == null) {
|
||||
getQRCodeURL(lifecycle, callback);
|
||||
@@ -1217,11 +1226,11 @@ public class NetInterfaceManager {
|
||||
Log.e("getQRCodeURL", "onNext: ");
|
||||
if (baseResponse.code == 200) {
|
||||
AppletQRCode appletQRCode = baseResponse.data;
|
||||
cacheHelper.put(UrlAddress.GET_APPLET_QRCODE, GsonUtils.toJSONString(appletQRCode));
|
||||
mCacheHelper.put(UrlAddress.GET_APPLET_QRCODE, GsonUtils.toJSONString(appletQRCode));
|
||||
String url = appletQRCode.getFile();
|
||||
callback.onNext(url);
|
||||
} else {
|
||||
cacheHelper.put(UrlAddress.GET_APPLET_QRCODE, "");
|
||||
mCacheHelper.put(UrlAddress.GET_APPLET_QRCODE, "");
|
||||
callback.onNext("");
|
||||
}
|
||||
}
|
||||
@@ -1858,7 +1867,7 @@ public class NetInterfaceManager {
|
||||
if (ConnectManager.getInstance().isNeedConnect(UrlAddress.GET_FORCE_INSTALL, connectMode)) {
|
||||
getForceInstall(lifecycle, callback);
|
||||
} else {
|
||||
String jsonString = cacheHelper.getAsString(UrlAddress.GET_FORCE_INSTALL);
|
||||
String jsonString = mCacheHelper.getAsString(UrlAddress.GET_FORCE_INSTALL);
|
||||
//为 "" 是已经请求成功的
|
||||
if (jsonString == null) {
|
||||
getForceInstall(lifecycle, callback);
|
||||
@@ -1901,13 +1910,13 @@ public class NetInterfaceManager {
|
||||
int code = listBaseResponse.code;
|
||||
if (code == 200) {
|
||||
List<AppInfo> appInfos = listBaseResponse.data;
|
||||
cacheHelper.put(UrlAddress.GET_FORCE_INSTALL, GsonUtils.toJSONString(appInfos));
|
||||
mCacheHelper.put(UrlAddress.GET_FORCE_INSTALL, GsonUtils.toJSONString(appInfos));
|
||||
if (null != appInfos && appInfos.size() != 0) {
|
||||
getForceInstallState(appInfos);
|
||||
}
|
||||
// JGYUtils.getInstance().deleteOtherApp();
|
||||
} else {
|
||||
cacheHelper.put(UrlAddress.GET_FORCE_INSTALL, "");
|
||||
mCacheHelper.put(UrlAddress.GET_FORCE_INSTALL, "");
|
||||
boolean aole_force_app = Settings.System.putString(crv, CommonConfig.AOLE_ACTION_FORCE_APP, "");
|
||||
Log.e(TAG, "aole_force_app:" + aole_force_app + ":" + "");
|
||||
}
|
||||
@@ -1982,10 +1991,10 @@ public class NetInterfaceManager {
|
||||
String data = new Gson().toJson(BaseResponse.data.getAdmin());
|
||||
Log.e("getSystemSettings", "onNext: " + data);
|
||||
ControlManager.getInstance().setSystemSetting(data);
|
||||
cacheHelper.put(UrlAddress.GET_SETTINGS, GsonUtils.toJSONString(BaseResponse.data.getAdmin()));
|
||||
mCacheHelper.put(UrlAddress.GET_SETTINGS, GsonUtils.toJSONString(BaseResponse.data.getAdmin()));
|
||||
} else {
|
||||
ControlManager.getInstance().setDisableSetting();
|
||||
cacheHelper.put(UrlAddress.GET_SETTINGS, "");
|
||||
mCacheHelper.put(UrlAddress.GET_SETTINGS, "");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2003,7 +2012,7 @@ public class NetInterfaceManager {
|
||||
}
|
||||
|
||||
public String getSystemSettingsJson() {
|
||||
return cacheHelper.getAsString(UrlAddress.GET_SETTINGS);
|
||||
return mCacheHelper.getAsString(UrlAddress.GET_SETTINGS);
|
||||
}
|
||||
|
||||
public void getTimeControl() {
|
||||
@@ -2210,6 +2219,9 @@ public class NetInterfaceManager {
|
||||
});
|
||||
}
|
||||
|
||||
public static final String APP_TIME_CONTROL_UPDATE = "APP_TIME_CONTROL_UPDATE";
|
||||
public static final String SN_TIME_CONTROL_UPDATE = "SN_TIME_CONTROL_UPDATE";
|
||||
|
||||
public void getAppTimeControl(boolean refresh, BehaviorSubject<ActivityEvent> lifecycle, onCompleteCallback callback) {
|
||||
ConnectMode connectMode = ConnectMode.ONE_MINUTE;
|
||||
if (refresh) {
|
||||
@@ -2218,7 +2230,7 @@ public class NetInterfaceManager {
|
||||
if (ConnectManager.getInstance().isNeedConnect(UrlAddress.GET_APP_TIME_CONTROL, connectMode)) {
|
||||
getAppTimeControl(lifecycle, callback);
|
||||
} else {
|
||||
String jsonString = cacheHelper.getAsString(UrlAddress.GET_APP_TIME_CONTROL);
|
||||
String jsonString = mCacheHelper.getAsString(UrlAddress.GET_APP_TIME_CONTROL);
|
||||
//为 "" 是已经请求成功的
|
||||
if (jsonString == null) {
|
||||
getAppTimeControl(lifecycle, callback);
|
||||
@@ -2233,7 +2245,7 @@ public class NetInterfaceManager {
|
||||
}
|
||||
|
||||
public String getAppTimeControlJson() {
|
||||
return cacheHelper.getAsString(UrlAddress.GET_APP_TIME_CONTROL);
|
||||
return mCacheHelper.getAsString(UrlAddress.GET_APP_TIME_CONTROL);
|
||||
}
|
||||
|
||||
public void getAppTimeControl(BehaviorSubject<ActivityEvent> lifecycle, onCompleteCallback callback) {
|
||||
@@ -2261,13 +2273,22 @@ public class NetInterfaceManager {
|
||||
|
||||
@Override
|
||||
public void onNext(@NonNull BaseResponse<List<AppTimeControl>> listBaseResponse) {
|
||||
Log.e("getAppTimeControlObserver", "onNext: ");
|
||||
Log.e("getAppTimeControlObserver", "onNext: " + listBaseResponse);
|
||||
if (listBaseResponse.code == 200) {
|
||||
List<AppTimeControl> appTimeControls = listBaseResponse.data;
|
||||
cacheHelper.put(UrlAddress.GET_APP_TIME_CONTROL, GsonUtils.toJSONString(appTimeControls));
|
||||
// TODO: 2022/6/21 后台没数据时也返回200
|
||||
if (appTimeControls == null || appTimeControls.size() == 0) {
|
||||
mCacheHelper.put(UrlAddress.GET_APP_TIME_CONTROL, "");
|
||||
} else {
|
||||
TimeControlManager.getInstance().setAppTimeControlMap(appTimeControls);
|
||||
mCacheHelper.put(UrlAddress.GET_APP_TIME_CONTROL, GsonUtils.toJSONString(appTimeControls));
|
||||
}
|
||||
} else {
|
||||
cacheHelper.put(UrlAddress.GET_APP_TIME_CONTROL, "");
|
||||
mCacheHelper.put(UrlAddress.GET_APP_TIME_CONTROL, "");
|
||||
}
|
||||
Intent intent = new Intent(APP_TIME_CONTROL_UPDATE);
|
||||
intent.putExtra("jsonString", GsonUtils.toJSONString(listBaseResponse.data));
|
||||
mContext.sendBroadcast(intent);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -2295,7 +2316,7 @@ public class NetInterfaceManager {
|
||||
if (ConnectManager.getInstance().isNeedConnect(UrlAddress.GET_SN_TIME_CONTROL, connectMode)) {
|
||||
getSnTimeControl(lifecycle, callback);
|
||||
} else {
|
||||
String jsonString = cacheHelper.getAsString(UrlAddress.GET_SN_TIME_CONTROL);
|
||||
String jsonString = mCacheHelper.getAsString(UrlAddress.GET_SN_TIME_CONTROL);
|
||||
//为 "" 是已经请求成功的
|
||||
if (jsonString == null) {
|
||||
getSnTimeControl(lifecycle, callback);
|
||||
@@ -2310,7 +2331,7 @@ public class NetInterfaceManager {
|
||||
}
|
||||
|
||||
public String getSnTimeControllJson() {
|
||||
return cacheHelper.getAsString(UrlAddress.GET_SN_TIME_CONTROL);
|
||||
return mCacheHelper.getAsString(UrlAddress.GET_SN_TIME_CONTROL);
|
||||
}
|
||||
|
||||
public void getSnTimeControl(BehaviorSubject<ActivityEvent> lifecycle, onCompleteCallback callback) {
|
||||
@@ -2341,10 +2362,14 @@ public class NetInterfaceManager {
|
||||
Log.e("getSnTimeControlObserver", "onNext: ");
|
||||
if (machineControlBaseResponse.code == 200) {
|
||||
MachineControl machineControl = machineControlBaseResponse.data;
|
||||
cacheHelper.put(UrlAddress.GET_SN_TIME_CONTROL, GsonUtils.toJSONString(machineControl));
|
||||
TimeControlManager.getInstance().setGlobalMachineControl(machineControl);
|
||||
mCacheHelper.put(UrlAddress.GET_SN_TIME_CONTROL, GsonUtils.toJSONString(machineControl));
|
||||
} else {
|
||||
cacheHelper.put(UrlAddress.GET_SN_TIME_CONTROL, "");
|
||||
mCacheHelper.put(UrlAddress.GET_SN_TIME_CONTROL, "");
|
||||
}
|
||||
Intent intent = new Intent(SN_TIME_CONTROL_UPDATE);
|
||||
intent.putExtra("jsonString", GsonUtils.toJSONString(machineControlBaseResponse.data));
|
||||
mContext.sendBroadcast(intent);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -2363,4 +2388,44 @@ public class NetInterfaceManager {
|
||||
};
|
||||
}
|
||||
|
||||
public void sendCloseApp(String packageName, onCompleteCallback completeCallback) {
|
||||
PackageManager pm = mContext.getPackageManager();
|
||||
PackageInfo appInfo = null;
|
||||
try {
|
||||
appInfo = pm.getPackageInfo(packageName, 0);
|
||||
} catch (PackageManager.NameNotFoundException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
if (null != appInfo) {
|
||||
String label = appInfo.applicationInfo.loadLabel(pm).toString();
|
||||
long openTime = RunningAppManager.getInstance().getOnClickTime();
|
||||
long closeTime = System.currentTimeMillis() / 1000;
|
||||
NetInterfaceManager.getInstance().getAppUsageRecordObservable(packageName, label, openTime, closeTime)
|
||||
.subscribe(new Observer<BaseResponse>() {
|
||||
@Override
|
||||
public void onSubscribe(@NonNull Disposable d) {
|
||||
Log.e("SendcloseApp", "onSubscribe: ");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNext(@NonNull BaseResponse baseResponse) {
|
||||
Log.e("SendcloseApp", "onNext: " + baseResponse);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(@NonNull Throwable e) {
|
||||
Log.e("SendcloseApp", "onError: " + e.getMessage());
|
||||
onComplete();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onComplete() {
|
||||
Log.e("SendcloseApp", "onComplete: ");
|
||||
completeCallback.onComplete();
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -64,6 +64,8 @@ public class UrlAddress {
|
||||
/*获取是否为网课模式*/
|
||||
public static final String GET_CLOUD_LESSON_SETTING = "Control/getCloudLessonSetting";
|
||||
|
||||
/*应用使用记录*/
|
||||
public static final String APP_USAGE_RECORD = "appUsageRecord";
|
||||
|
||||
/*获取公网IP*/
|
||||
public static final String SHOUHU_CITYJSON = "http://pv.sohu.com/cityjson/";
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
package com.uiui.sn.network.api;
|
||||
|
||||
|
||||
import com.uiui.sn.bean.AppTimeControl;
|
||||
import com.uiui.sn.desktop.AppTimeControl;
|
||||
import com.uiui.sn.bean.BaseResponse;
|
||||
import com.uiui.sn.network.UrlAddress;
|
||||
|
||||
|
||||
@@ -0,0 +1,22 @@
|
||||
package com.uiui.sn.network.api;
|
||||
|
||||
|
||||
import com.uiui.sn.bean.BaseResponse;
|
||||
import com.uiui.sn.network.UrlAddress;
|
||||
|
||||
import io.reactivex.rxjava3.core.Observable;
|
||||
import retrofit2.http.Field;
|
||||
import retrofit2.http.FormUrlEncoded;
|
||||
import retrofit2.http.POST;
|
||||
|
||||
public interface AppUsageRecordApi {
|
||||
@FormUrlEncoded
|
||||
@POST(UrlAddress.APP_USAGE_RECORD)
|
||||
Observable<BaseResponse> sendAppUsageRecord(
|
||||
@Field("sn") String sn,
|
||||
@Field("app_package") String app_package,
|
||||
@Field("app_name") String app_name,
|
||||
@Field("open_time") Long open_time,
|
||||
@Field("close_time") Long close_time
|
||||
);
|
||||
}
|
||||
@@ -1,7 +1,7 @@
|
||||
package com.uiui.sn.network.api;
|
||||
|
||||
import com.uiui.sn.bean.BaseResponse;
|
||||
import com.uiui.sn.bean.MachineControl;
|
||||
import com.uiui.sn.desktop.MachineControl;
|
||||
import com.uiui.sn.network.UrlAddress;
|
||||
|
||||
import io.reactivex.rxjava3.core.Observable;
|
||||
|
||||
@@ -9,6 +9,8 @@ import android.util.Log;
|
||||
|
||||
import com.google.gson.JsonObject;
|
||||
import com.uiui.sn.IGetInfoInterface;
|
||||
import com.uiui.sn.config.CommonConfig;
|
||||
import com.uiui.sn.desktop.RunningAppManager;
|
||||
import com.uiui.sn.network.NetInterfaceManager;
|
||||
import com.uiui.sn.service.main.MainService;
|
||||
import com.uiui.sn.utils.JGYUtils;
|
||||
@@ -48,52 +50,20 @@ public class RemoteService extends Service {
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getSerial() throws RemoteException {
|
||||
return Utils.getSerial();
|
||||
public boolean isControl() throws RemoteException {
|
||||
int is_control = Settings.System.getInt(getContentResolver(), CommonConfig.KEY_IS_CONTROL, 1);
|
||||
Log.e(TAG, "inControlTime: is_control = " + is_control);
|
||||
return is_control == 1;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getUserInfo() throws RemoteException {
|
||||
if (MainService.getPresenter() != null) {
|
||||
// MainService.getPresenter().getUserInfo();
|
||||
}
|
||||
String username = Settings.System.getString(getContentResolver(), "UserInfo_username");
|
||||
String avatar = Settings.System.getString(getContentResolver(), "UserInfo_avatar");
|
||||
int gread = (int) SPUtils.get(RemoteService.this, "int_grade", 0);
|
||||
String gankaoUID = Settings.System.getString(getContentResolver(), "gankaoUID");
|
||||
JsonObject jsonObject = new JsonObject();
|
||||
jsonObject.addProperty("username", username);
|
||||
jsonObject.addProperty("avatar", avatar);
|
||||
jsonObject.addProperty("grade", gread);
|
||||
jsonObject.addProperty("userid", gankaoUID);
|
||||
jsonObject.addProperty("sn", Utils.getSerial());
|
||||
Log.e(TAG, "getUserInfo:" + jsonObject.toString());
|
||||
return jsonObject.toString();
|
||||
public boolean inControl(String pkg) throws RemoteException {
|
||||
return RunningAppManager.getInstance().inControlTime(pkg);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getHideAPP() throws RemoteException {
|
||||
return JGYUtils.getInstance().getHideList();
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getForbidAPP() throws RemoteException {
|
||||
return JGYUtils.getInstance().getForbidList();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getAppTimeControl() throws RemoteException {
|
||||
return NetInterfaceManager.getInstance().getAppTimeControlJson();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getSnTimeControl() throws RemoteException {
|
||||
return NetInterfaceManager.getInstance().getSnTimeControllJson();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getSetting() throws RemoteException {
|
||||
return NetInterfaceManager.getInstance().getSystemSettingsJson();
|
||||
public String getDisableContent(String pkg) throws RemoteException {
|
||||
return RunningAppManager.getInstance().getDisableContent(pkg);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
@@ -478,6 +478,10 @@ public class MessageReceiver extends XGPushBaseReceiver {
|
||||
private static final String ACTION_DEFAULT_INPUT_METHOD = "78";
|
||||
/*家长管控开关*/
|
||||
private static final String ACTION_PARENTAL_CONTROL = "79";
|
||||
/*整机管控配置*/
|
||||
private static final String ACTION_WHOLE_MACHINE_QUOTA = "80";
|
||||
/*APP管控配置*/
|
||||
private static final String ACTION_APP_CONTROL = "81";
|
||||
/*更新白名单*/
|
||||
private static final String UPDATE_WHITE_LIST = "83";
|
||||
|
||||
@@ -780,6 +784,13 @@ public class MessageReceiver extends XGPushBaseReceiver {
|
||||
case ACTION_PARENTAL_CONTROL:
|
||||
NetInterfaceManager.getInstance().getSystemSettings();
|
||||
break;
|
||||
case ACTION_WHOLE_MACHINE_QUOTA:
|
||||
NetInterfaceManager.getInstance().getAppTimeControl();
|
||||
NetInterfaceManager.getInstance().getSnTimeControl();
|
||||
break;
|
||||
case ACTION_APP_CONTROL:
|
||||
NetInterfaceManager.getInstance().getAppTimeControl();
|
||||
break;
|
||||
case UPDATE_WHITE_LIST:
|
||||
NetInterfaceManager.getInstance().getAllappPackage();
|
||||
break;
|
||||
|
||||
@@ -109,6 +109,7 @@ public class JGYUtils {
|
||||
}};
|
||||
|
||||
private HashSet<String> fuxiaoyingApp = new HashSet<String>() {{
|
||||
this.add(fxyywgj);
|
||||
this.add(gkwxhd);
|
||||
this.add(fuxiaoying);
|
||||
this.add(moshujia);
|
||||
@@ -118,6 +119,7 @@ public class JGYUtils {
|
||||
this.add(growthspace);
|
||||
}};
|
||||
|
||||
public static final String fxyywgj = "com.fuying.chinese";
|
||||
public static final String gkwxhd = "com.gankao.gkwxhd";
|
||||
public static final String fuxiaoying = "com.fuying.fuxiaoying";
|
||||
public static final String moshujia = "com.moshujiamm.moshujia";
|
||||
|
||||
Reference in New Issue
Block a user