version:beta
fix: update:增加锁屏密码
This commit is contained in:
17
app/src/main/java/com/fuying/sn/bean/ScreenPassword.java
Normal file
17
app/src/main/java/com/fuying/sn/bean/ScreenPassword.java
Normal file
@@ -0,0 +1,17 @@
|
||||
package com.fuying.sn.bean;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
public class ScreenPassword implements Serializable {
|
||||
private static final long serialVersionUID = 4417211558962408699L;
|
||||
|
||||
String pwd;
|
||||
|
||||
public String getPwd() {
|
||||
return pwd;
|
||||
}
|
||||
|
||||
public void setPwd(String pwd) {
|
||||
this.pwd = pwd;
|
||||
}
|
||||
}
|
||||
@@ -27,6 +27,7 @@ import com.fuying.sn.bean.CloudLessonSetting;
|
||||
import com.fuying.sn.bean.Label;
|
||||
import com.fuying.sn.bean.MyAppUsageBean;
|
||||
import com.fuying.sn.bean.OverallAppBean;
|
||||
import com.fuying.sn.bean.ScreenPassword;
|
||||
import com.fuying.sn.bean.SnInfo;
|
||||
import com.fuying.sn.bean.SystemSettingsSet;
|
||||
import com.fuying.sn.bean.UserAvatarInfo;
|
||||
@@ -55,6 +56,7 @@ import com.fuying.sn.network.api.GetAdminAppApi;
|
||||
import com.fuying.sn.network.api.GetBatchApi;
|
||||
import com.fuying.sn.network.api.GetControlScreenshotApi;
|
||||
import com.fuying.sn.network.api.GetGuideApi;
|
||||
import com.fuying.sn.network.api.GetLockScreenPwdApi;
|
||||
import com.fuying.sn.network.api.GetPublicIPApi;
|
||||
import com.fuying.sn.network.api.MachineTimeControlApi;
|
||||
import com.fuying.sn.network.api.MyAppListApi;
|
||||
@@ -502,6 +504,13 @@ public class NetInterfaceManager {
|
||||
.observeOn(AndroidSchedulers.mainThread());
|
||||
}
|
||||
|
||||
public Observable<BaseResponse<ScreenPassword>> getLockScreenPwdObservable() {
|
||||
return mRetrofit.create(GetLockScreenPwdApi.class)
|
||||
.getLockScreenPwd(Utils.getSerial())
|
||||
.subscribeOn(Schedulers.io())
|
||||
.observeOn(AndroidSchedulers.mainThread());
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
*
|
||||
@@ -682,9 +691,9 @@ public class NetInterfaceManager {
|
||||
* @param callback
|
||||
*/
|
||||
public void setPushTags(boolean refresh, BehaviorSubject<ActivityEvent> lifecycle, CompleteCallback callback) {
|
||||
ConnectMode connectMode = ConnectMode.SIX_HOUR;
|
||||
ConnectMode connectMode = ConnectMode.ONE_DAY;
|
||||
if (refresh) {
|
||||
connectMode = ConnectMode.ONE_HOUR;
|
||||
connectMode = ConnectMode.SIX_HOUR;
|
||||
}
|
||||
if (ConnectManager.getInstance().isNeedConnect(UrlAddress.GET_BATCH, connectMode)) {
|
||||
setPushTags(lifecycle, callback);
|
||||
@@ -703,7 +712,7 @@ public class NetInterfaceManager {
|
||||
}
|
||||
|
||||
public void setPushTags(BehaviorSubject<ActivityEvent> lifecycle, CompleteCallback callback) {
|
||||
Set set = new HashSet();
|
||||
Set<String> set = new HashSet<>();
|
||||
JGYUtils.getInstance().getAppPlatform(platform -> {
|
||||
if (platform == JGYUtils.MTKPlatform) {
|
||||
set.add(JGYUtils.MTKTag);
|
||||
@@ -2133,6 +2142,8 @@ public class NetInterfaceManager {
|
||||
|
||||
public void sendRunningApp() {
|
||||
String packageName = AppUsedTimeUtils.getInstance().getApp_package();
|
||||
if (TextUtils.isEmpty(packageName))
|
||||
return;
|
||||
long time = AppUsedTimeUtils.getInstance().getStart_time();
|
||||
JsonObject jsonObject = new JsonObject();
|
||||
jsonObject.addProperty("app_package", packageName);
|
||||
@@ -2610,31 +2621,50 @@ public class NetInterfaceManager {
|
||||
}
|
||||
|
||||
public void getMyAppList(MyAppListCallback callback) {
|
||||
getMyAppListObservable()
|
||||
.subscribe(new Observer<BaseResponse<List<MyAppUsageBean>>>() {
|
||||
@Override
|
||||
public void onSubscribe(@NonNull Disposable d) {
|
||||
Log.e("getMyAppList", "onSubscribe: ");
|
||||
}
|
||||
if (ConnectManager.getInstance().isNeedConnect(UrlAddress.GE_TOVERALL_APPBYPLATFORM, ConnectMode.ONE_HOUR)) {
|
||||
getMyAppListObservable()
|
||||
.subscribe(getMyAppListObservable(callback));
|
||||
} else {
|
||||
String jsonString = mCacheHelper.getAsString(UrlAddress.GE_TOVERALL_APPBYPLATFORM);
|
||||
//为 "" 是已经请求成功的
|
||||
if (jsonString == null) {
|
||||
getMyAppListObservable()
|
||||
.subscribe(getMyAppListObservable(callback));
|
||||
} else {
|
||||
Gson gson = new Gson();
|
||||
Type type = new TypeToken<List<MyAppUsageBean>>() {
|
||||
}.getType();
|
||||
List<MyAppUsageBean> myAppUsageBeans = gson.fromJson(jsonString, type);
|
||||
callback.setMyAppList(myAppUsageBeans);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNext(@NonNull BaseResponse<List<MyAppUsageBean>> listBaseResponse) {
|
||||
Log.e("getMyAppList", "onNext: " + listBaseResponse);
|
||||
List<MyAppUsageBean> myAppUsageBeanList = listBaseResponse.data;
|
||||
callback.setMyAppList(myAppUsageBeanList);
|
||||
}
|
||||
public Observer<BaseResponse<List<MyAppUsageBean>>> getMyAppListObservable(MyAppListCallback callback) {
|
||||
return new Observer<BaseResponse<List<MyAppUsageBean>>>() {
|
||||
@Override
|
||||
public void onSubscribe(@NonNull Disposable d) {
|
||||
Log.e("getMyAppList", "onSubscribe: ");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(@NonNull Throwable e) {
|
||||
Log.e("getMyAppList", "onError: " + e.getMessage());
|
||||
onComplete();
|
||||
}
|
||||
@Override
|
||||
public void onNext(@NonNull BaseResponse<List<MyAppUsageBean>> listBaseResponse) {
|
||||
Log.e("getMyAppList", "onNext: " + listBaseResponse);
|
||||
List<MyAppUsageBean> myAppUsageBeanList = listBaseResponse.data;
|
||||
callback.setMyAppList(myAppUsageBeanList);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onComplete() {
|
||||
Log.e("getMyAppList", "onComplete: ");
|
||||
}
|
||||
});
|
||||
@Override
|
||||
public void onError(@NonNull Throwable e) {
|
||||
Log.e("getMyAppList", "onError: " + e.getMessage());
|
||||
onComplete();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onComplete() {
|
||||
Log.e("getMyAppList", "onComplete: ");
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
public void getAppJump(CompleteCallback completeCallback) {
|
||||
@@ -2773,4 +2803,80 @@ public class NetInterfaceManager {
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public void getLockScreenPwd(boolean refresh, BehaviorSubject<ActivityEvent> lifecycle, CompleteCallback callback) {
|
||||
ConnectMode connectMode = ConnectMode.ONE_MINUTE;
|
||||
if (refresh) {
|
||||
connectMode = ConnectMode.DEFAULT;
|
||||
}
|
||||
if (ConnectManager.getInstance().isNeedConnect(UrlAddress.LOCK_SCREEN_PWD, connectMode)) {
|
||||
getLockScreenPwd(lifecycle, callback);
|
||||
} else {
|
||||
String jsonString = mCacheHelper.getAsString(UrlAddress.LOCK_SCREEN_PWD);
|
||||
//为 "" 是已经请求成功的
|
||||
if (jsonString == null) {
|
||||
getLockScreenPwd(lifecycle, callback);
|
||||
} else {
|
||||
Gson gson = new Gson();
|
||||
Type type = new TypeToken<ScreenPassword>() {
|
||||
}.getType();
|
||||
ScreenPassword screenPassword = gson.fromJson(jsonString, type);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void getLockScreenPwd(BehaviorSubject<ActivityEvent> lifecycle, CompleteCallback callback) {
|
||||
getLockScreenPwdObservable()
|
||||
.compose(RxLifecycle.bindUntilEvent(lifecycle, ActivityEvent.DESTROY))
|
||||
.subscribe(getLockScreenPwdObserver(callback));
|
||||
}
|
||||
|
||||
private void getLockScreenPwd(CompleteCallback callback) {
|
||||
getLockScreenPwdObservable()
|
||||
.subscribe(getLockScreenPwdObserver(callback));
|
||||
}
|
||||
|
||||
private void getLockScreenPwd() {
|
||||
getLockScreenPwdObservable()
|
||||
.subscribe(getLockScreenPwdObserver(null));
|
||||
}
|
||||
|
||||
private Observer<BaseResponse<ScreenPassword>> getLockScreenPwdObserver(CompleteCallback callback) {
|
||||
return new Observer<BaseResponse<ScreenPassword>>() {
|
||||
@Override
|
||||
public void onSubscribe(@NonNull Disposable d) {
|
||||
Log.e("getLockScreenPwdObserver", "onSubscribe: ");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNext(@NonNull BaseResponse<ScreenPassword> screenPasswordBaseResponse) {
|
||||
Log.e("getLockScreenPwdObserver", "onSubscribe: " + screenPasswordBaseResponse);
|
||||
if (screenPasswordBaseResponse.code == 200) {
|
||||
ScreenPassword screenPassword = screenPasswordBaseResponse.data;
|
||||
if (screenPassword == null || TextUtils.isEmpty(screenPassword.getPwd())) {
|
||||
mCacheHelper.put(UrlAddress.LOCK_SCREEN_PWD, "");
|
||||
} else {
|
||||
mCacheHelper.put(UrlAddress.LOCK_SCREEN_PWD, GsonUtils.toJSONString(screenPassword));
|
||||
SPUtils.put(mContext, UrlAddress.LOCK_SCREEN_PWD, screenPassword.getPwd());
|
||||
}
|
||||
} else {
|
||||
mCacheHelper.put(UrlAddress.LOCK_SCREEN_PWD, "");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(@NonNull Throwable e) {
|
||||
Log.e("getLockScreenPwdObserver", "onError: " + e.getMessage());
|
||||
onComplete();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onComplete() {
|
||||
Log.e("getLockScreenPwdObserver", "onComplete: ");
|
||||
if (callback != null) {
|
||||
callback.onComplete();
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,7 +2,27 @@ package com.fuying.sn.network;
|
||||
|
||||
public class UrlAddress {
|
||||
/*主页接口*/
|
||||
public static final String ROOT_URL = "https://as.fuyingy.com/android/";
|
||||
static final String ROOT_URL = "https://as.fuyingy.com/android/";
|
||||
|
||||
//不需要做缓存的接口
|
||||
|
||||
/*获取app桌面管控配置*/
|
||||
public final static String GET_APP_TIME_CONTROL = "Control/getAppTimeControl";
|
||||
/*获取整机管控配置*/
|
||||
public final static String GET_SN_TIME_CONTROL = "Control/getSnTimeControl";
|
||||
/*获取所有应用时间*/
|
||||
public final static String GET_MY_APP_LIST = "app/myAppList";
|
||||
|
||||
//不需要在后台添加sn的接口
|
||||
/*获取所有全局更新*/
|
||||
public final static String GE_TOVERALL_APPBYPLATFORM = "app/overallAppByPlatform";
|
||||
/*获取管理员上传的应用*/
|
||||
public final static String GET_ADMIN_APP = "getAdminApp";
|
||||
/*根据包名获取更新*/
|
||||
public final static String GET_NEWESTAPPUPDATE = "app/newestAppUpdate";
|
||||
|
||||
|
||||
|
||||
/*获取批次*/
|
||||
public static final String GET_BATCH = "sn/getBatch";
|
||||
/*设备信息接口*/
|
||||
@@ -11,26 +31,12 @@ public class UrlAddress {
|
||||
public static final String APPLOG = "App/getApplog";
|
||||
/*获取正在运行的app*/
|
||||
public static final String RUN_NEW_APP = "app/runNewApp";
|
||||
/*根据包名获取更新*/
|
||||
public final static String GET_APP_UPDATE = "Update/update";
|
||||
/*获取当前最顶层应用和电量*/
|
||||
public final static String SEND_RUNINGAPPINFO = "Monitoring/getAppNow";
|
||||
/*在线状态*/
|
||||
public final static String SEND_DRIVE_STATE = "Online/online";
|
||||
/*获取所有应用*/
|
||||
public final static String GET_ALL_PACKAGE = "app/queryAllApp";
|
||||
/*获取管理员上传的应用*/
|
||||
public final static String GET_ADMIN_APP = "getAdminApp";
|
||||
/*绑定设备消息*/
|
||||
public final static String BIND_DEVICES = "sn/bindSn";
|
||||
/*获取系统设置*/
|
||||
public final static String GET_SETTINGS = "control/getSetting";
|
||||
/*获取app桌面管控配置*/
|
||||
public final static String GET_APP_TIME_CONTROL = "Control/getAppTimeControl";
|
||||
/*获取整机管控配置*/
|
||||
public final static String GET_SN_TIME_CONTROL = "Control/getSnTimeControl";
|
||||
/*获取所有应用时间*/
|
||||
public final static String GET_MY_APP_LIST = "app/myAppList";
|
||||
/*浏览器网址管控*/
|
||||
public final static String SET_BROWSER_URL = "control/getBrowser";
|
||||
/*浏览器书签管控*/
|
||||
@@ -47,10 +53,6 @@ public class UrlAddress {
|
||||
public final static String SEND_INSTALLEDORREMOVED = "app/addAppInstall";
|
||||
/*发送设备基本信息*/
|
||||
public final static String UPDATE_SNINFO = "sn/updateAdminSn";
|
||||
/*根据包名获取更新*/
|
||||
public final static String GET_NEWESTAPPUPDATE = "app/newestAppUpdate";
|
||||
/*获取所有全局更新*/
|
||||
public final static String GE_TOVERALL_APPBYPLATFORM = "app/overallAppByPlatform";
|
||||
/*上传屏幕截图*/
|
||||
public final static String UPLOAD_SCREEN_SNAPSHOT = "sn/uploadScreenshot";
|
||||
/*获取屏幕管控*/
|
||||
@@ -65,13 +67,27 @@ public class UrlAddress {
|
||||
public static final String GET_OPERATION_GUIDE = "file/getFiles";
|
||||
/*上传控制面版截图*/
|
||||
public static final String UPLOAD_CONTROL_SCREENSHOT = "sn/uploadControlScreenshot";
|
||||
/*获取应用白名单*/
|
||||
public static final String GET_APP_AND_WHITE = "getAppAndWhite";
|
||||
/*获取是否为网课模式*/
|
||||
public static final String GET_CLOUD_LESSON_SETTING = "Control/getCloudLessonSetting";
|
||||
|
||||
/*应用使用记录*/
|
||||
public static final String APP_USAGE_RECORD = "appUsageRecord";
|
||||
/*获取锁屏密码*/
|
||||
public static final String LOCK_SCREEN_PWD = "sn/getLockScreenPwd";
|
||||
|
||||
|
||||
|
||||
/*根据包名获取更新*/
|
||||
@Deprecated
|
||||
public final static String GET_APP_UPDATE = "Update/update";
|
||||
/*获取当前最顶层应用和电量*/
|
||||
@Deprecated
|
||||
public final static String SEND_RUNINGAPPINFO = "Monitoring/getAppNow";
|
||||
/*在线状态*/
|
||||
@Deprecated
|
||||
public final static String SEND_DRIVE_STATE = "Online/online";
|
||||
/*获取应用白名单*/
|
||||
@Deprecated
|
||||
public static final String GET_APP_AND_WHITE = "getAppAndWhite";
|
||||
|
||||
/*获取公网IP*/
|
||||
public static final String SHOUHU_CITYJSON = "http://pv.sohu.com/cityjson/";
|
||||
|
||||
@@ -0,0 +1,16 @@
|
||||
package com.fuying.sn.network.api;
|
||||
|
||||
import com.fuying.sn.bean.BaseResponse;
|
||||
import com.fuying.sn.bean.ScreenPassword;
|
||||
import com.fuying.sn.network.UrlAddress;
|
||||
|
||||
import io.reactivex.rxjava3.core.Observable;
|
||||
import retrofit2.http.GET;
|
||||
import retrofit2.http.Query;
|
||||
|
||||
public interface GetLockScreenPwdApi {
|
||||
@GET(UrlAddress.LOCK_SCREEN_PWD)
|
||||
Observable<BaseResponse<ScreenPassword>> getLockScreenPwd(
|
||||
@Query("sn") String sn
|
||||
);
|
||||
}
|
||||
@@ -17,20 +17,23 @@ import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.WindowManager;
|
||||
import android.widget.Button;
|
||||
import android.widget.EditText;
|
||||
import android.widget.TextView;
|
||||
|
||||
import com.blankj.utilcode.util.NetworkUtils;
|
||||
import com.google.gson.JsonObject;
|
||||
import com.fuying.sn.R;
|
||||
import com.fuying.sn.bean.BaseResponse;
|
||||
import com.fuying.sn.config.CommonConfig;
|
||||
import com.fuying.sn.gson.GsonUtils;
|
||||
import com.fuying.sn.network.NetInterfaceManager;
|
||||
import com.fuying.sn.network.UrlAddress;
|
||||
import com.fuying.sn.receiver.APKinstallReceiver;
|
||||
import com.fuying.sn.receiver.BootReceiver;
|
||||
import com.fuying.sn.gson.GsonUtils;
|
||||
import com.fuying.sn.utils.SPUtils;
|
||||
import com.fuying.sn.utils.TimeUtils;
|
||||
import com.fuying.sn.utils.ToastUtil;
|
||||
import com.fuying.sn.utils.Utils;
|
||||
import com.google.gson.JsonObject;
|
||||
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
@@ -49,9 +52,9 @@ import io.reactivex.rxjava3.schedulers.Schedulers;
|
||||
public class ManagerService extends Service implements NetworkUtils.OnNetworkStatusChangedListener {
|
||||
private String TAG = ManagerService.class.getSimpleName();
|
||||
|
||||
public static String ACTION_LOCK = "LockScreenReceiver_lockscreen";
|
||||
public static String ACTION_UNLOCK = "LockScreenReceiver_unlockscreen";
|
||||
public static String ACTION_UPDATE = "TimeChangedReceiver_update";
|
||||
public static final String ACTION_LOCK = "LockScreenReceiver_lockscreen";
|
||||
public static final String ACTION_UNLOCK = "LockScreenReceiver_unlockscreen";
|
||||
public static final String ACTION_UPDATE = "TimeChangedReceiver_update";
|
||||
private WindowManager windowManager;
|
||||
private View topView;
|
||||
private boolean screenlocked = false;
|
||||
@@ -196,7 +199,7 @@ public class ManagerService extends Service implements NetworkUtils.OnNetworkSta
|
||||
}
|
||||
}
|
||||
|
||||
public static String LOCK_STATE = "SCRENN_LOOCKED_STATE";
|
||||
public static final String LOCK_STATE = "SCRENN_LOOCKED_STATE";
|
||||
|
||||
private void showFloatingWindow(String name) {
|
||||
if (Settings.canDrawOverlays(this)) {
|
||||
@@ -223,10 +226,39 @@ public class ManagerService extends Service implements NetworkUtils.OnNetworkSta
|
||||
topView = LayoutInflater.from(getApplicationContext()).inflate(R.layout.activity_screen_lock, null);
|
||||
TextView textView = topView.findViewById(R.id.textView);
|
||||
textView.setText(name);
|
||||
EditText et_password = topView.findViewById(R.id.et_password);
|
||||
TextView tv_confirm = topView.findViewById(R.id.tv_confirm);
|
||||
tv_confirm.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
String password = (String) SPUtils.get(ManagerService.this, UrlAddress.LOCK_SCREEN_PWD, "");
|
||||
String pwd = et_password.getText().toString();
|
||||
if (!TextUtils.isEmpty(pwd) && !TextUtils.isEmpty(password) && password.equals(pwd)) {
|
||||
hideFloatingWindow();
|
||||
}else {
|
||||
ToastUtil.show("密码错误");
|
||||
}
|
||||
}
|
||||
});
|
||||
} else {
|
||||
if ("added".equals(topView.getTag())) {
|
||||
TextView textView = topView.findViewById(R.id.textView);
|
||||
textView.setText(name);
|
||||
EditText et_password = topView.findViewById(R.id.et_password);
|
||||
TextView tv_confirm = topView.findViewById(R.id.tv_confirm);
|
||||
tv_confirm.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
String password = (String) SPUtils.get(ManagerService.this, UrlAddress.LOCK_SCREEN_PWD, "");
|
||||
String pwd = et_password.getText().toString();
|
||||
if (!TextUtils.isEmpty(pwd) && !TextUtils.isEmpty(password) && password.equals(pwd)) {
|
||||
hideFloatingWindow();
|
||||
}else {
|
||||
ToastUtil.show("密码错误");
|
||||
}
|
||||
}
|
||||
});
|
||||
} else {
|
||||
return;
|
||||
}
|
||||
}
|
||||
@@ -286,6 +318,7 @@ public class ManagerService extends Service implements NetworkUtils.OnNetworkSta
|
||||
@Override
|
||||
public void onReceive(Context context, Intent intent) {
|
||||
String action = intent.getAction();
|
||||
Log.e("LockScreenReceiver", "onReceive: " + action);
|
||||
if (TextUtils.isEmpty(action)) {
|
||||
getScreenLockState();
|
||||
return;
|
||||
|
||||
@@ -25,23 +25,26 @@ public class MainSContact {
|
||||
void setSnTimeControl();
|
||||
void setMyAppList();
|
||||
void setScreenLock();
|
||||
void setLockScreenPwd();
|
||||
}
|
||||
|
||||
interface Presenter extends BasePresenter<MainView> {
|
||||
|
||||
//获取所有app包名
|
||||
void getAllApp();
|
||||
//检查更新
|
||||
void checkUpdate();
|
||||
//检查扶小鹰App更新
|
||||
void checkFXYUpdate();
|
||||
/*获取所有全局更新*/
|
||||
void getOverallApp();
|
||||
|
||||
//获取设备信息
|
||||
void getSnInfo();
|
||||
//获取锁定状态
|
||||
void getLocked();
|
||||
//上传设备信息
|
||||
void updateDeviceInfo();
|
||||
//检查更新
|
||||
void checkUpdate();
|
||||
//检查扶小鹰App更新
|
||||
void checkFXYUpdate();
|
||||
//获取所有app包名
|
||||
void getAllApp();
|
||||
/*获取所有全局更新*/
|
||||
void getOverallApp();
|
||||
//获取id管控
|
||||
void getAppInside();
|
||||
//获取强制下载
|
||||
@@ -64,6 +67,7 @@ public class MainSContact {
|
||||
void getMyAppList();
|
||||
//获取锁屏管控
|
||||
void getScreenLock();
|
||||
|
||||
//获取锁屏密码
|
||||
void getLockScreenPwd();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -8,11 +8,7 @@ import android.provider.Settings;
|
||||
import android.text.TextUtils;
|
||||
import android.util.Log;
|
||||
|
||||
import com.google.gson.Gson;
|
||||
import com.google.gson.JsonObject;
|
||||
import com.tencent.mmkv.MMKV;
|
||||
import com.trello.rxlifecycle4.RxLifecycle;
|
||||
import com.trello.rxlifecycle4.android.ActivityEvent;
|
||||
import com.fuying.sn.BuildConfig;
|
||||
import com.fuying.sn.bean.AppStart;
|
||||
import com.fuying.sn.bean.BaseResponse;
|
||||
import com.fuying.sn.bean.Label;
|
||||
@@ -23,15 +19,20 @@ import com.fuying.sn.bean.browser.BrowserBean;
|
||||
import com.fuying.sn.config.CommonConfig;
|
||||
import com.fuying.sn.desktop.RunningAppManager;
|
||||
import com.fuying.sn.disklrucache.CacheHelper;
|
||||
import com.fuying.sn.gson.GsonUtils;
|
||||
import com.fuying.sn.manager.ControlManager;
|
||||
import com.fuying.sn.network.NetInterfaceManager;
|
||||
import com.fuying.sn.service.ManagerService;
|
||||
import com.fuying.sn.gson.GsonUtils;
|
||||
import com.fuying.sn.utils.JGYUtils;
|
||||
import com.fuying.sn.utils.SPUtils;
|
||||
import com.fuying.sn.utils.ServiceAliveUtils;
|
||||
import com.fuying.sn.utils.URLUtils;
|
||||
import com.fuying.sn.utils.Utils;
|
||||
import com.google.gson.Gson;
|
||||
import com.google.gson.JsonObject;
|
||||
import com.tencent.mmkv.MMKV;
|
||||
import com.trello.rxlifecycle4.RxLifecycle;
|
||||
import com.trello.rxlifecycle4.android.ActivityEvent;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
@@ -42,8 +43,6 @@ import io.reactivex.rxjava3.disposables.Disposable;
|
||||
import io.reactivex.rxjava3.schedulers.Schedulers;
|
||||
import io.reactivex.rxjava3.subjects.BehaviorSubject;
|
||||
|
||||
import static com.fuying.sn.service.ManagerService.LOCK_STATE;
|
||||
|
||||
/**
|
||||
* @author jgy02
|
||||
*/
|
||||
@@ -507,6 +506,7 @@ public class MainSPresenter implements MainSContact.Presenter {
|
||||
@Override
|
||||
public void setMyAppList(List<MyAppUsageBean> myAppList) {
|
||||
RunningAppManager.getInstance().syncAllAppUsageTime(myAppList);
|
||||
mView.setMyAppList();
|
||||
}
|
||||
});
|
||||
}
|
||||
@@ -536,7 +536,7 @@ public class MainSPresenter implements MainSContact.Presenter {
|
||||
if (!ServiceAliveUtils.isServiceAlice(mContext, ManagerService.class.getName())) {
|
||||
mContext.startService(new Intent(mContext, ManagerService.class));
|
||||
}
|
||||
SPUtils.put(mContext, LOCK_STATE, is_screen_lock);
|
||||
SPUtils.put(mContext, ManagerService.LOCK_STATE, is_screen_lock);
|
||||
Intent intent = new Intent();
|
||||
// intent.putExtra("name", name);
|
||||
if (1 == is_screen_lock) {
|
||||
@@ -545,18 +545,37 @@ public class MainSPresenter implements MainSContact.Presenter {
|
||||
intent.setAction(ManagerService.ACTION_UNLOCK);
|
||||
}
|
||||
mContext.sendBroadcast(intent);
|
||||
} else {
|
||||
// if (BuildConfig.DEBUG) {
|
||||
// SPUtils.put(mContext, ManagerService.LOCK_STATE, 1);
|
||||
// Intent intent = new Intent();
|
||||
// intent.setAction(ManagerService.ACTION_LOCK);
|
||||
// mContext.sendBroadcast(intent);
|
||||
// }
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(Throwable e) {
|
||||
Log.e("getScreenLock", "onError: " + e.getMessage());
|
||||
onComplete();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onComplete() {
|
||||
Log.e("getScreenLock", "onComplete: ");
|
||||
mView.setScreenLock();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getLockScreenPwd() {
|
||||
NetInterfaceManager.getInstance().getLockScreenPwd(true, lifecycle, new NetInterfaceManager.CompleteCallback() {
|
||||
@Override
|
||||
public void onComplete() {
|
||||
mView.setLockScreenPwd();
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package com.fuying.sn.service.main;
|
||||
|
||||
import android.annotation.SuppressLint;
|
||||
import android.app.AlarmManager;
|
||||
import android.app.Service;
|
||||
import android.content.BroadcastReceiver;
|
||||
@@ -66,12 +67,11 @@ import io.reactivex.rxjava3.subjects.BehaviorSubject;
|
||||
public class MainService extends Service implements MainSContact.MainView, NetworkUtils.OnNetworkStatusChangedListener, LifecycleProvider<ActivityEvent> {
|
||||
private String TAG = MainService.class.getSimpleName();
|
||||
|
||||
@SuppressLint("StaticFieldLeak")
|
||||
public static MainSPresenter mPresenter;
|
||||
private MMKV mMMKV = MMKV.defaultMMKV();
|
||||
|
||||
//执行所有请求的时间
|
||||
long runningTime;
|
||||
|
||||
//MainService上次执行时间
|
||||
long startCommandTime = 0;
|
||||
|
||||
@@ -106,7 +106,7 @@ public class MainService extends Service implements MainSContact.MainView, Netwo
|
||||
Log.e(TAG, "网络已连接");
|
||||
ToastUtil.show("网络已连接");
|
||||
String WiFiAlias = Utils.getWifiAlias(this);
|
||||
Log.e("OnNetworkStatusChanged", "onConnected: " + WiFiAlias);
|
||||
Log.e(TAG, "onConnected: WiFiAlias = " + WiFiAlias);
|
||||
Utils.getPublicIP(this);
|
||||
if (ConnectManager.getInstance().isWiFiFistConnect()) {
|
||||
start.onstar(ConnectManager.WIFI_LAST_CONNECT_TIME);
|
||||
@@ -122,7 +122,7 @@ public class MainService extends Service implements MainSContact.MainView, Netwo
|
||||
}
|
||||
mPresenter.checkUpdate();
|
||||
mPresenter.getAllApp();
|
||||
TimeTask task = new TimeTask();
|
||||
NTPTimeTask task = new NTPTimeTask();
|
||||
task.execute("ntp.aliyun.com");
|
||||
NetInterfaceManager.getInstance().SendAppInstallInfo();
|
||||
}
|
||||
@@ -152,7 +152,7 @@ public class MainService extends Service implements MainSContact.MainView, Netwo
|
||||
mPresenter.setLifecycle(lifecycleSubject);
|
||||
mPresenter.attachView(this);
|
||||
|
||||
TimeTask task = new TimeTask();
|
||||
NTPTimeTask task = new NTPTimeTask();
|
||||
task.execute("ntp.aliyun.com");
|
||||
|
||||
Log.e(TAG, "onCreate: IMEI = " + Utils.getIMEI(MainService.this));
|
||||
@@ -178,6 +178,14 @@ public class MainService extends Service implements MainSContact.MainView, Netwo
|
||||
if ((int) SPUtils.get(this, CommonConfig.JGY_FIRST_CONNECT, 0) == 0) {
|
||||
start.onstar(ConnectManager.REBOOT_LAST_ONNECT_TIME);
|
||||
}
|
||||
versionIsUpdate();
|
||||
registerReceivers();
|
||||
NetworkUtils.registerNetworkStatusChangedListener(this);
|
||||
// ControlManager.getInstance().setDefaultUSBstate();
|
||||
NetInterfaceManager.getInstance().SendAppInstallInfo();
|
||||
}
|
||||
|
||||
private void versionIsUpdate() {
|
||||
int oldVersionCode = (int) SPUtils.get(this, CommonConfig.SN_VERSIONCODE, 0);
|
||||
if (oldVersionCode < BuildConfig.VERSION_CODE) {
|
||||
Log.e(TAG, "onCreate: " + "upgrade successful");
|
||||
@@ -197,10 +205,6 @@ public class MainService extends Service implements MainSContact.MainView, Netwo
|
||||
}
|
||||
}
|
||||
SPUtils.put(this, CommonConfig.SN_VERSIONCODE, BuildConfig.VERSION_CODE);
|
||||
registerReceivers();
|
||||
NetworkUtils.registerNetworkStatusChangedListener(this);
|
||||
// ControlManager.getInstance().setDefaultUSBstate();
|
||||
NetInterfaceManager.getInstance().SendAppInstallInfo();
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -228,7 +232,7 @@ public class MainService extends Service implements MainSContact.MainView, Netwo
|
||||
startService(new Intent(this, DownloadService.class));
|
||||
}
|
||||
|
||||
private class TimeTask extends AsyncTask<String, Long, Long> {
|
||||
private class NTPTimeTask extends AsyncTask<String, Long, Long> {
|
||||
@Override
|
||||
protected Long doInBackground(String... strings) {
|
||||
return TimeUtils.getTimeFromNtpServer(strings[0]);
|
||||
@@ -239,14 +243,8 @@ public class MainService extends Service implements MainSContact.MainView, Netwo
|
||||
super.onPostExecute(aLong);
|
||||
AlarmManager am = (AlarmManager) getSystemService(Context.ALARM_SERVICE);
|
||||
am.setTime(aLong);
|
||||
tPushInit();
|
||||
NetInterfaceManager.getInstance().setPushTags(true, lifecycleSubject, new NetInterfaceManager.CompleteCallback() {
|
||||
@Override
|
||||
public void onComplete() {
|
||||
Log.e("TimeTask", "onComplete: ");
|
||||
}
|
||||
});
|
||||
Log.e(TAG, "getTimeFromNtpServer: " + aLong);
|
||||
tPushInit();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -263,6 +261,12 @@ public class MainService extends Service implements MainSContact.MainView, Netwo
|
||||
@Override
|
||||
public void onSuccess(Object data, int flag) {
|
||||
Log.e("TPush", "onSuccess, data:" + data + ", flag:" + flag);
|
||||
NetInterfaceManager.getInstance().setPushTags(true, lifecycleSubject, new NetInterfaceManager.CompleteCallback() {
|
||||
@Override
|
||||
public void onComplete() {
|
||||
Log.e("TimeTask", "onComplete: ");
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -563,6 +567,13 @@ public class MainService extends Service implements MainSContact.MainView, Netwo
|
||||
|
||||
@Override
|
||||
public void setScreenLock() {
|
||||
mPresenter.getLockScreenPwd();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setLockScreenPwd() {
|
||||
Log.e(TAG, "SettingFinish: " + (SystemClock.elapsedRealtime() - runningTime) + " ms");
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
22
app/src/main/java/com/fuying/sn/utils/StringUtils.java
Normal file
22
app/src/main/java/com/fuying/sn/utils/StringUtils.java
Normal file
@@ -0,0 +1,22 @@
|
||||
package com.fuying.sn.utils;
|
||||
|
||||
import android.os.Build;
|
||||
|
||||
import java.util.StringJoiner;
|
||||
|
||||
public class StringUtils {
|
||||
public static String join(CharSequence delimiter, Iterable<? extends CharSequence> elements) {
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
|
||||
return String.join(delimiter, elements);
|
||||
} else {
|
||||
if (elements == null) {
|
||||
return "";
|
||||
}
|
||||
StringJoiner joiner = new StringJoiner(delimiter);
|
||||
for (CharSequence cs : elements) {
|
||||
joiner.add(cs);
|
||||
}
|
||||
return joiner.toString();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,21 +1,46 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:background="@color/float_window_color"
|
||||
tools:context=".activity.ScreenLockActivity">
|
||||
android:background="@color/float_window_color">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/textView"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="屏幕已锁定"
|
||||
android:textSize="24sp"
|
||||
android:textColor="@color/white"
|
||||
android:textSize="24sp"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent" />
|
||||
|
||||
<EditText
|
||||
android:id="@+id/et_password"
|
||||
android:layout_width="@dimen/dp_200"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="@dimen/dp_16"
|
||||
android:background="@drawable/edit_background"
|
||||
android:gravity="center"
|
||||
android:hint="请输入密码解锁"
|
||||
android:maxEms="20"
|
||||
android:maxLines="1"
|
||||
android:singleLine="true"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@+id/textView" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tv_confirm"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="@dimen/dp_16"
|
||||
android:text="确定"
|
||||
android:textColor="@color/white"
|
||||
android:textSize="24sp"
|
||||
app:layout_constraintEnd_toEndOf="@+id/et_password"
|
||||
app:layout_constraintStart_toStartOf="@+id/et_password"
|
||||
app:layout_constraintTop_toBottomOf="@+id/et_password" />
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
|
||||
@@ -1,21 +1,46 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:background="@color/float_window_color"
|
||||
tools:context=".activity.ScreenLockActivity">
|
||||
android:background="@color/float_window_color">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/textView"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="屏幕已锁定"
|
||||
android:textSize="24sp"
|
||||
android:textColor="@color/white"
|
||||
android:textSize="24sp"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent" />
|
||||
|
||||
<EditText
|
||||
android:id="@+id/et_password"
|
||||
android:layout_width="@dimen/dp_200"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="@dimen/dp_16"
|
||||
android:background="@drawable/edit_background"
|
||||
android:gravity="center"
|
||||
android:hint="请输入密码解锁"
|
||||
android:maxEms="20"
|
||||
android:maxLines="1"
|
||||
android:singleLine="true"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@+id/textView" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tv_confirm"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="@dimen/dp_16"
|
||||
android:text="确定"
|
||||
android:textColor="@color/white"
|
||||
android:textSize="24sp"
|
||||
app:layout_constraintEnd_toEndOf="@+id/et_password"
|
||||
app:layout_constraintStart_toStartOf="@+id/et_password"
|
||||
app:layout_constraintTop_toBottomOf="@+id/et_password" />
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
|
||||
Reference in New Issue
Block a user