version:beta
fix: update:增加锁屏密码
This commit is contained in:
@@ -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");
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user