更换包名

This commit is contained in:
2022-09-27 19:11:46 +08:00
parent 35c747a334
commit 4f671a3b75
148 changed files with 585 additions and 630 deletions

View File

@@ -0,0 +1,104 @@
package com.fuying.sn.service;
import android.app.Service;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
import android.hardware.usb.UsbManager;
import android.hardware.usb.UsbPortStatus;
import android.os.Bundle;
import android.os.IBinder;
import android.util.Log;
public class ControlPanelService extends Service {
private static final String TAG = ControlPanelService.class.getSimpleName();
public ControlPanelService() {
}
@Override
public IBinder onBind(Intent intent) {
return null;
}
@Override
public void onCreate() {
super.onCreate();
registerUsbConnectionReceiver();
}
@Override
public int onStartCommand(Intent intent, int flags, int startId) {
return super.onStartCommand(intent, flags, startId);
}
@Override
public void onDestroy() {
super.onDestroy();
}
private void registerUsbConnectionReceiver() {
if (mUsbConnectionReceiver == null) {
mUsbConnectionReceiver = new UsbConnectionReceiver();
}
IntentFilter filter = new IntentFilter();
filter.addAction(UsbManager.ACTION_USB_STATE);
filter.addAction(UsbManager.ACTION_USB_PORT_CHANGED);
registerReceiver(mUsbConnectionReceiver, filter);
}
UsbConnectionReceiver mUsbConnectionReceiver;
private boolean mConnected;
private long mFunctions;
// private int mDataRole;
// private int mPowerRole;
public class UsbConnectionReceiver extends BroadcastReceiver {
@Override
public void onReceive(Context context, Intent intent) {
Log.e(TAG, "onReceive: " + intent.getAction());
Bundle bundle = intent.getExtras();
if (UsbManager.ACTION_USB_STATE.equals(intent.getAction())) {
mConnected = intent.getExtras().getBoolean(UsbManager.USB_CONNECTED)
|| intent.getExtras().getBoolean(UsbManager.USB_HOST_CONNECTED);
long functions = UsbManager.FUNCTION_NONE;
if (intent.getExtras().getBoolean(UsbManager.USB_FUNCTION_MTP)
&& intent.getExtras().getBoolean(UsbManager.USB_DATA_UNLOCKED, false)) {
functions |= UsbManager.FUNCTION_MTP;
}
if (intent.getExtras().getBoolean(UsbManager.USB_FUNCTION_PTP)
&& intent.getExtras().getBoolean(UsbManager.USB_DATA_UNLOCKED, false)) {
functions |= UsbManager.FUNCTION_PTP;
}
if (intent.getExtras().getBoolean(UsbManager.USB_FUNCTION_MIDI)) {
functions |= UsbManager.FUNCTION_MIDI;
}
if (intent.getExtras().getBoolean(UsbManager.USB_FUNCTION_RNDIS)) {
functions |= UsbManager.FUNCTION_RNDIS;
}
if (intent.getExtras().getBoolean(UsbManager.USB_FUNCTION_ACCESSORY)) {
functions |= UsbManager.FUNCTION_ACCESSORY;
}
mFunctions = functions;
// mDataRole = mUsbBackend.getDataRole();
// mPowerRole = mUsbBackend.getPowerRole();
} else if (UsbManager.ACTION_USB_PORT_CHANGED.equals(intent.getAction())) {
UsbPortStatus portStatus = intent.getExtras()
.getParcelable(UsbManager.EXTRA_PORT_STATUS);
if (portStatus != null) {
// mDataRole = portStatus.getCurrentDataRole();
// mPowerRole = portStatus.getCurrentPowerRole();
}
}
// if (mUsbConnectionListener != null) {
// mUsbConnectionListener.onUsbConnectionChanged(mConnected, mFunctions, mPowerRole,
// mDataRole);
// }
}
}
}

View File

@@ -0,0 +1,166 @@
package com.fuying.sn.service;
import android.app.AlertDialog;
import android.app.Service;
import android.content.DialogInterface;
import android.content.Intent;
import android.os.Bundle;
import android.os.Environment;
import android.os.IBinder;
import android.text.TextUtils;
import android.util.Log;
import android.view.WindowManager;
import androidx.annotation.Nullable;
import com.arialyy.annotations.Download;
import com.arialyy.aria.core.Aria;
import com.arialyy.aria.core.task.DownloadTask;
import com.blankj.utilcode.util.ToastUtils;
import com.google.gson.JsonObject;
import com.fuying.sn.KeepAliveConnection;
import com.fuying.sn.R;
import com.fuying.sn.service.main.MainService;
import com.fuying.sn.utils.ApkUtils;
import com.fuying.sn.gson.GsonUtils;
import java.io.File;
// 下载管理服务
public class DownloadService extends Service {
private static final String TAG = DownloadService.class.getSimpleName();
@Override
public int onStartCommand(Intent intent, int flags, int startId) {
startService(new Intent(this, StepService.class));
startService(new Intent(this, GuardService.class));
startService(new Intent(this, MainService.class));
startService(new Intent(this, ManagerService.class));
startService(new Intent(this, ControlPanelService.class));
Aria.download(this).register();
//恢复所有未完成的下载任务
Aria.download(this).resumeAllTask();
return START_STICKY;
}
@Override
public void onCreate() {
super.onCreate();
}
@Override
public void onDestroy() {
super.onDestroy();
}
@Nullable
@Override
public IBinder onBind(Intent intent) {
return new KeepAliveConnection.Stub() {
};
}
private void getFile(final Bundle bundle) {
String url = bundle.getString("url");
final File path = new File(Environment.getExternalStoragePublicDirectory("Download") + "/Sninfo/");
path.mkdirs();
final File file = new File(Environment.getExternalStoragePublicDirectory("Download") + "/Sninfo/" + url.substring(url.lastIndexOf("/") + 1));
if (file.exists() && file.isFile()) {
// AlertDialog.Builder builder = new AlertDialog.Builder(this)
// .setTitle("软件更新")
// .setIcon(R.mipmap.ic_launcher)
// .setCancelable(false)
// .setMessage("发现新版本,点击确定更新\n" + "更新内容:" + bundle.getString("content"))
// .setPositiveButton("确定", new DialogInterface.OnClickListener() {
// @Override
// public void onClick(DialogInterface dialogInterface, int i) {
ApkUtils.installApp(DownloadService.this, file.getAbsolutePath());
// dialogInterface.dismiss();
// }
// });
// AlertDialog ad = builder.create();
// ad.getWindow().setType(WindowManager.LayoutParams.TYPE_SYSTEM_ALERT);
// ad.setCanceledOnTouchOutside(false); //点击外面区域不会让dialog消失
// ad.show();
} else {
}
}
private void update(final Bundle bundle) {
String url = bundle.getString("url");
final File path = new File(Environment.getExternalStoragePublicDirectory("Download") + "/Sninfo/");
path.mkdirs();
final File file = new File(Environment.getExternalStoragePublicDirectory("Download") + "/Sninfo/" + url.substring(url.lastIndexOf("/") + 1));
if (file.exists() && file.isFile()) {
AlertDialog.Builder builder = new AlertDialog.Builder(this)
.setTitle("软件更新")
.setIcon(R.mipmap.ic_launcher)
.setCancelable(false)
.setMessage("发现新版本,点击确定更新\n" + "更新内容:" + bundle.getString("content"))
.setPositiveButton("确定", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialogInterface, int i) {
ApkUtils.installApk(DownloadService.this, file);
dialogInterface.dismiss();
}
});
AlertDialog ad = builder.create();
ad.getWindow().setType(WindowManager.LayoutParams.TYPE_SYSTEM_ALERT);
ad.setCanceledOnTouchOutside(false); //点击外面区域不会让dialog消失
ad.show();
} else {
}
}
//在这里处理任务执行中的状态,如进度进度条的刷新
@Download.onTaskRunning
void running(DownloadTask task) {
Log.e("aria running", "正在下载:" + task.getState() + "-" + task.getPercent() + "--" + task.getExtendField());
String appName = "";
try {
String jsonString = task.getExtendField();
JsonObject jsonObject = GsonUtils.getJsonObject(jsonString);
if (!TextUtils.isEmpty(jsonString) && jsonObject != null) {
appName = jsonObject.get("app_name").getAsString();
}
} catch (Exception e) {
Log.e("running", "running: " + e.getMessage());
}
ToastUtils.showShort("正在下载:" + appName + "-" + task.getPercent() + "%");
}
@Download.onTaskComplete
void taskComplete(DownloadTask task) {
//在这里处理任务完成的状态
ApkUtils.installApp(DownloadService.this, task.getFilePath());
Log.e("taskComplete", task.getExtendField());
Aria.download(this).load(task.getDownloadEntity().getId()).cancel();
}
@Download.onTaskFail
void taskFail(DownloadTask task, Exception e) {
// Aria.download(this).resumeAllTask();
final String filepath = task.getFilePath();
final String packageName = task.getExtendField();
try {
Log.e(TAG, "taskFail: " + "Exception: " + e.getMessage());
} catch (Exception ex) {
Log.e(TAG, "taskFail: Exception = " + e.getMessage());
}
Log.e(TAG, "taskFail: " + packageName + "filepath: " + filepath);
Aria.download(this).load(task.getDownloadEntity().getId()).cancel(true);
// Aria.download(this)
// .load(task.getDownloadEntity().getRealUrl()) //读取下载地址
// .setFilePath(task.getFilePath())
// .ignoreFilePathOccupy()
// .setExtendField(task.getExtendField())
// .create(); //启动下载}
}
}

View File

@@ -0,0 +1,66 @@
package com.fuying.sn.service;
/**
* 作者 mjsheng
* 日期 2019/4/1 10:58
* 邮箱 501802639@qq.com
* 来自:
*/
import android.app.Service;
import android.content.ComponentName;
import android.content.Context;
import android.content.Intent;
import android.content.ServiceConnection;
import android.os.IBinder;
import android.util.Log;
import androidx.annotation.Nullable;
import com.fuying.sn.KeepAliveConnection;
import com.fuying.sn.utils.ServiceAliveUtils;
/**
* 守护进程 双进程通讯
*
* @author LiGuangMin
* @time Created by 2018/8/17 11:27
*/
public class GuardService extends Service {
private final static String TAG = GuardService.class.getSimpleName();
private ServiceConnection mServiceConnection = new ServiceConnection() {
@Override
public void onServiceConnected(ComponentName componentName, IBinder iBinder) {
Log.e(TAG, "GuardService:建立链接");
boolean isServiceRunning = ServiceAliveUtils.isServiceAlice(GuardService.this, getClass().getName());
if (!isServiceRunning) {
Intent i = new Intent(GuardService.this, DownloadService.class);
startService(i);
}
}
@Override
public void onServiceDisconnected(ComponentName componentName) {
// 断开链接
startService(new Intent(GuardService.this, StepService.class));
// 重新绑定
bindService(new Intent(GuardService.this, StepService.class), mServiceConnection, Context.BIND_IMPORTANT);
}
};
@Nullable
@Override
public IBinder onBind(Intent intent) {
return new KeepAliveConnection.Stub() {
};
}
@Override
public int onStartCommand(Intent intent, int flags, int startId) {
// 绑定建立链接
bindService(new Intent(this, StepService.class), mServiceConnection, Context.BIND_IMPORTANT);
return START_STICKY;
}
}

View File

@@ -0,0 +1,535 @@
package com.fuying.sn.service;
import android.app.Service;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
import android.graphics.Color;
import android.graphics.PixelFormat;
import android.os.Build;
import android.os.IBinder;
import android.provider.Settings;
import android.text.TextUtils;
import android.util.DisplayMetrics;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.WindowManager;
import android.widget.Button;
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.network.NetInterfaceManager;
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.Utils;
import java.util.concurrent.TimeUnit;
import io.reactivex.rxjava3.android.schedulers.AndroidSchedulers;
import io.reactivex.rxjava3.core.Observable;
import io.reactivex.rxjava3.core.ObservableEmitter;
import io.reactivex.rxjava3.core.ObservableOnSubscribe;
import io.reactivex.rxjava3.core.Observer;
import io.reactivex.rxjava3.disposables.Disposable;
import io.reactivex.rxjava3.schedulers.Schedulers;
/**
* @author jgy02
*/
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";
private WindowManager windowManager;
private View topView;
private boolean screenlocked = false;
private boolean timelocked = false;
@Override
public void onDisconnected() {
}
@Override
public void onConnected(NetworkUtils.NetworkType networkType) {
getScreenLockState();
}
private interface Start {
void onstar(long time);
}
private Start start;
private final ObservableOnSubscribe<Long> subscribe = new ObservableOnSubscribe<Long>() {
@Override
public void subscribe(ObservableEmitter emitter) throws Exception {
start = new Start() {
@Override
public void onstar(long time) {
emitter.onNext(time);
}
};
}
};
private Observer<Long> timeObserver = new Observer<Long>() {
@Override
public void onSubscribe(Disposable d) {
}
@Override
public void onNext(Long aLong) {
Log.e("TimeObserver", "onNext: " + aLong);
int isLogined = (int) SPUtils.get(ManagerService.this, CommonConfig.isLogined, 2);
if (isLogined == 2) {
}
}
@Override
public void onError(Throwable e) {
}
@Override
public void onComplete() {
}
};
@Override
public IBinder onBind(Intent intent) {
return null;
}
@Override
public void onCreate() {
super.onCreate();
NetworkUtils.registerNetworkStatusChangedListener(this);
registLockReceiver();
registerTimeReceiver();
registerScreenLockReceiver();
registAppReceive();
registBootReceive();
registerBatteryReceiver();
setFloatingWindow();
Observable.create(subscribe)
.throttleFirst(3, TimeUnit.HOURS)
.subscribe(timeObserver);
}
@Override
public int onStartCommand(Intent intent, int flags, int startId) {
start.onstar(System.currentTimeMillis());
return START_STICKY;
}
private void getScreenLockState() {
NetInterfaceManager.getInstance()
.getScreenLockControl()
.getScreenshot(Utils.getSerial())
.subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread())
.subscribe(new Observer<BaseResponse>() {
@Override
public void onSubscribe(Disposable d) {
Log.e("getScreenLockState", "onSubscribe: ");
}
@Override
public void onNext(BaseResponse baseResponse) {
Log.e("getScreenLockState", "onNext: ");
int code = baseResponse.code;
if (code == 200) {
JsonObject jsonObject = GsonUtils.getJsonObject(GsonUtils.toJSONString(baseResponse.data));
int is_screen_lock = jsonObject.get("is_screen_lock").getAsInt();
setLockedState(is_screen_lock);
} else {
if (!timelocked) {
hideFloatingWindow();
}
screenlocked = false;
SPUtils.put(ManagerService.this, LOCK_STATE, 0);
}
}
@Override
public void onError(Throwable e) {
Log.e("getScreenLockState", "onError: " + e.getMessage());
}
@Override
public void onComplete() {
Log.e("getScreenLockState", "onComplete: ");
}
});
}
private void setLockedState(int lockedState) {
if (lockedState == 1) {
if (!timelocked) {
showFloatingWindow("屏幕已锁定");
}
screenlocked = true;
SPUtils.put(ManagerService.this, LOCK_STATE, 1);
} else {
if (!timelocked) {
hideFloatingWindow();
}
screenlocked = false;
SPUtils.put(ManagerService.this, LOCK_STATE, 0);
}
}
public static String LOCK_STATE = "SCRENN_LOOCKED_STATE";
private void showFloatingWindow(String name) {
if (Settings.canDrawOverlays(this)) {
// 获取WindowManager服务
if (null == windowManager) {
windowManager = (WindowManager) getSystemService(WINDOW_SERVICE);
}
DisplayMetrics dm = new DisplayMetrics();
windowManager.getDefaultDisplay().getRealMetrics(dm);
int width = dm.widthPixels; // 屏幕宽度(像素)
int height = dm.heightPixels; // 屏幕高度(像素)
// 新建悬浮窗控件
final Button button = new Button(getApplicationContext());
button.setText("霸屏测试");
button.setAlpha(0.9f);
button.setBackgroundColor(Color.BLACK);
button.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
// windowManager.removeView(button);
}
});
if (null == topView) {
topView = LayoutInflater.from(getApplicationContext()).inflate(R.layout.activity_screen_lock, null);
TextView textView = topView.findViewById(R.id.textView);
textView.setText(name);
} else {
if ("added".equals(topView.getTag())) {
TextView textView = topView.findViewById(R.id.textView);
textView.setText(name);
return;
}
}
// topView.setAlpha(0.8f);
// 设置LayoutParam
WindowManager.LayoutParams layoutParams = new WindowManager.LayoutParams();
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
layoutParams.type = WindowManager.LayoutParams.TYPE_KEYGUARD_DIALOG;
//TYPE_SYSTEM_OVERLAY可以下滑通知栏
// layoutParams.type = WindowManager.LayoutParams.TYPE_SYSTEM_OVERLAY;
} else {
layoutParams.type = WindowManager.LayoutParams.TYPE_PHONE;
}
layoutParams.flags |= WindowManager.LayoutParams.FLAG_BLUR_BEHIND
| WindowManager.LayoutParams.FLAG_SHOW_WHEN_LOCKED
| WindowManager.LayoutParams.FLAG_LAYOUT_IN_SCREEN;
layoutParams.format = PixelFormat.RGBA_8888;
layoutParams.width = WindowManager.LayoutParams.MATCH_PARENT;
layoutParams.height = WindowManager.LayoutParams.MATCH_PARENT;
//systemUiVisibility 关闭通知栏和导航栏
layoutParams.systemUiVisibility =
View.SYSTEM_UI_FLAG_HIDE_NAVIGATION
| View.SYSTEM_UI_FLAG_IMMERSIVE
| View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN;
layoutParams.x = 0;
layoutParams.y = 0;
// 将悬浮窗控件添加到WindowManager
windowManager.addView(topView, layoutParams);
topView.setTag("added");
}
}
private void hideFloatingWindow() {
if (null == windowManager) {
return;
}
if (null != topView) {
windowManager.removeView(topView);
topView = null;
}
}
private LockScreenReceiver lockScreenReceiver;
private void registLockReceiver() {
if (null == lockScreenReceiver) {
lockScreenReceiver = new LockScreenReceiver();
IntentFilter filter = new IntentFilter();
filter.setPriority(IntentFilter.SYSTEM_HIGH_PRIORITY);
filter.addAction(ACTION_LOCK);
filter.addAction(ACTION_UNLOCK);
registerReceiver(lockScreenReceiver, filter);
}
}
private class LockScreenReceiver extends BroadcastReceiver {
@Override
public void onReceive(Context context, Intent intent) {
String action = intent.getAction();
if (TextUtils.isEmpty(action)) {
getScreenLockState();
return;
}
if (ACTION_LOCK.equals(action)) {
// String name = intent.getStringExtra("name");
String name = "屏幕已锁定";
if (!timelocked) {
showFloatingWindow(name);
}
screenlocked = true;
} else if (ACTION_UNLOCK.equals(action)) {
if (!timelocked) {
hideFloatingWindow();
}
screenlocked = false;
}
}
}
private TimeChangedReceiver mTimeChangedReceiver;
/**
* 监听时间和日期变化
*/
private void registerTimeReceiver() {
mTimeChangedReceiver = new TimeChangedReceiver();
IntentFilter filter = new IntentFilter();
filter.setPriority(IntentFilter.SYSTEM_HIGH_PRIORITY);
filter.addAction(Intent.ACTION_DATE_CHANGED);
filter.addAction(Intent.ACTION_TIME_CHANGED);
filter.addAction(Intent.ACTION_TIMEZONE_CHANGED);
filter.addAction(Intent.ACTION_TIME_TICK);
filter.addAction(ACTION_UPDATE);
registerReceiver(mTimeChangedReceiver, filter);
}
private class TimeChangedReceiver extends BroadcastReceiver {
@Override
public void onReceive(Context context, Intent intent) {
String action = intent.getAction();
if (Intent.ACTION_DATE_CHANGED.equals(action)) {
Log.e(TAG, "TimeChangedReceiver:" + "data changed");
} else if (Intent.ACTION_TIME_CHANGED.equals(action)) {
Log.e(TAG, "TimeChangedReceiver:" + "time changed");
} else if (Intent.ACTION_TIMEZONE_CHANGED.equals(action)) {
Log.e(TAG, "TimeChangedReceiver:" + "timezone changed");
} else if (Intent.ACTION_TIME_TICK.equals(action)) {
Log.e(TAG, "TimeChangedReceiver:" + "time tick");
setFloatingWindow();
} else if (ACTION_UPDATE.equals(action)) {
Log.e(TAG, "TimeChangedReceiver:" + "date update");
setFloatingWindow();
}
// String packages = ForegroundAppUtil.getForegroundPackageName(context);
// if (!packages.equals("com.estrongs.android.pop")) {
// ApkUtils.openApp(context, "com.estrongs.android.pop");
// }
// Log.e("TimeChangedReceiver", "packages:" + packages);
}
}
private void setFloatingWindow() {
TimeUtils.ContralTime workingContralTime = TimeUtils.getWorkingDayContralTime(ManagerService.this);
TimeUtils.ContralTime weekContralTime = TimeUtils.getWeekDayContralTime(ManagerService.this);
// if (null != workingContralTime) {
if (TimeUtils.inContralTime(workingContralTime, weekContralTime)) {
if (!screenlocked) {
showFloatingWindow("可用时间:\n" + TimeUtils.getNowTimeString(ManagerService.this));
} else {
TextView textView = topView.findViewById(R.id.textView);
textView.setText("可用时间:\n" + TimeUtils.getNowTimeString(ManagerService.this));
}
timelocked = true;
} else {
// getScreenLockState();
int is_screen_lock = (int) SPUtils.get(ManagerService.this, LOCK_STATE, 0);
setLockedState(is_screen_lock);
if (!screenlocked) {
hideFloatingWindow();
}
timelocked = false;
}
// } else {
// if (!screenlocked) {
// hideFloatingWindow()
// }
// getScreenLockState()
// timelocked = false
// }
}
private ScreenLockReceiver screenLockReceiver;
private void registerScreenLockReceiver() {
if (null == screenLockReceiver) {
screenLockReceiver = new ScreenLockReceiver();
}
IntentFilter filter = new IntentFilter();
filter.setPriority(IntentFilter.SYSTEM_HIGH_PRIORITY);
filter.addAction(Intent.ACTION_SCREEN_OFF);
filter.addAction(Intent.ACTION_SCREEN_ON);
filter.addAction(Intent.ACTION_BOOT_COMPLETED);
filter.addAction(Intent.ACTION_USER_PRESENT);
filter.addAction(Intent.ACTION_SHUTDOWN);
filter.addAction(Intent.ACTION_FACTORY_RESET);
filter.addAction(Intent.ACTION_MASTER_CLEAR);
registerReceiver(screenLockReceiver, filter);
}
private class ScreenLockReceiver extends BroadcastReceiver {
@Override
public void onReceive(Context context, Intent intent) {
String action = intent.getAction();
Log.e(TAG, "onReceive:" + action);
if (TextUtils.isEmpty(action)) {
Log.e(TAG, "onReceive: is NULL");
return;
}
switch (action) {
case Intent.ACTION_USER_PRESENT:
case Intent.ACTION_SCREEN_ON:
sendScreenState(1);
break;
case Intent.ACTION_SCREEN_OFF:
case Intent.ACTION_SHUTDOWN:
case Intent.ACTION_FACTORY_RESET:
case Intent.ACTION_MASTER_CLEAR:
sendScreenState(0);
break;
default:
break;
}
}
}
private void sendScreenState(int stateCode) {
Log.e(TAG, "sendScreenState: code:" + stateCode);
// Log.e(TAG, "sendScreenState: sn: " + Utils.getSerial());
NetInterfaceManager.getInstance().setScreen()
.setScreenState(Utils.getSerial(), stateCode)
.subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread())
.subscribe(new Observer<BaseResponse>() {
@Override
public void onSubscribe(Disposable d) {
Log.e("sendScreenState", "onSubscribe: ");
}
@Override
public void onNext(BaseResponse baseResponse) {
Log.e("sendScreenState", "onNext: " + baseResponse.msg);
}
@Override
public void onError(Throwable e) {
// TODO: 2022/7/11 接口本身问题
// Log.e("sendScreenState", "onError: " + e.getMessage());
}
@Override
public void onComplete() {
Log.e("sendScreenState", "onComplete: ");
}
});
}
private APKinstallReceiver apKinstallReceiver;
private void registAppReceive() {
if (null == apKinstallReceiver) {
apKinstallReceiver = new APKinstallReceiver();
}
IntentFilter filter = new IntentFilter();
filter.setPriority(IntentFilter.SYSTEM_HIGH_PRIORITY);
filter.addAction(Intent.ACTION_PACKAGE_ADDED);
filter.addAction(Intent.ACTION_PACKAGE_REPLACED);
filter.addAction(Intent.ACTION_PACKAGE_REMOVED);
filter.addDataScheme("package");
registerReceiver(apKinstallReceiver, filter);
}
private BootReceiver bootReceiver;
private void registBootReceive() {
if (null == bootReceiver) {
bootReceiver = new BootReceiver();
IntentFilter filter = new IntentFilter();
filter.setPriority(IntentFilter.SYSTEM_HIGH_PRIORITY);
filter.addAction(Intent.ACTION_USER_PRESENT);
registerReceiver(bootReceiver, filter);
}
}
private BatteryReceiver batteryReceiver;
private void registerBatteryReceiver() {
if (null == batteryReceiver) {
batteryReceiver = new BatteryReceiver();
}
IntentFilter filter = new IntentFilter();
filter.setPriority(IntentFilter.SYSTEM_HIGH_PRIORITY);
filter.addAction(Intent.ACTION_POWER_DISCONNECTED);
registerReceiver(batteryReceiver, filter);
}
private class BatteryReceiver extends BroadcastReceiver {
@Override
public void onReceive(Context context, Intent intent) {
String action = intent.getAction();
if (Intent.ACTION_BATTERY_CHANGED.equals(action)) {
} else if (Intent.ACTION_POWER_CONNECTED.equals(action) || Intent.ACTION_POWER_DISCONNECTED.equals(action)) {
// ControlManager.getInstance().setDefaultUSBstate();
} else if (Intent.ACTION_BATTERY_LOW.equals(action) || Intent.ACTION_BATTERY_OKAY.equals(action)) {
}
}
}
@Override
public void onDestroy() {
super.onDestroy();
NetworkUtils.unregisterNetworkStatusChangedListener(this);
if (null != mTimeChangedReceiver) {
unregisterReceiver(mTimeChangedReceiver);
}
if (null != lockScreenReceiver) {
unregisterReceiver(lockScreenReceiver);
}
if (null != screenLockReceiver) {
unregisterReceiver(screenLockReceiver);
}
if (null != apKinstallReceiver) {
unregisterReceiver(apKinstallReceiver);
}
if (null != bootReceiver) {
unregisterReceiver(bootReceiver);
}
}
}

View File

@@ -0,0 +1,66 @@
package com.fuying.sn.service;
import android.app.Service;
import android.content.Intent;
import android.os.IBinder;
import android.os.RemoteException;
import android.provider.Settings;
import android.util.Log;
import com.fuying.sn.BuildConfig;
import com.fuying.sn.IGetInfoInterface;
import com.fuying.sn.config.CommonConfig;
import com.fuying.sn.desktop.RunningAppManager;
public class RemoteService extends Service {
private String TAG = RemoteService.class.getSimpleName();
public RemoteService() {
}
@Override
public IBinder onBind(Intent intent) {
Log.e(TAG, "onBind: ");
return mBinde;
}
@Override
public void onCreate() {
Log.e(TAG, "onCreate: ");
super.onCreate();
}
@Override
public int onStartCommand(Intent intent, int flags, int startId) {
Log.e(TAG, "onStartCommand: ");
return super.onStartCommand(intent, flags, startId);
}
private IBinder mBinde = new IGetInfoInterface.Stub() {
@Override
public void basicTypes(int anInt, long aLong, boolean aBoolean, float aFloat, double aDouble, String aString) throws RemoteException {
}
@Override
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 boolean inControl(String pkg) throws RemoteException {
return RunningAppManager.getInstance().inControlTime(pkg);
}
@Override
public String getDisableContent(String pkg) throws RemoteException {
String content = RunningAppManager.getInstance().getDisableContent(pkg);
if (BuildConfig.DEBUG) {
Log.e(TAG, "getDisableContent: " + content);
}
return content;
}
};
}

View File

@@ -0,0 +1,323 @@
package com.fuying.sn.service;
/**
* 作者 mjsheng
* 日期 2019/4/1 10:57
* 邮箱 501802639@qq.com
* 来自:
*/
import android.app.Service;
import android.content.BroadcastReceiver;
import android.content.ComponentName;
import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
import android.content.ServiceConnection;
import android.os.Binder;
import android.os.Handler;
import android.os.IBinder;
import android.os.PowerManager;
import android.text.TextUtils;
import android.util.Log;
import androidx.annotation.Nullable;
import com.blankj.utilcode.util.NetworkUtils;
import com.google.gson.JsonObject;
import com.fuying.sn.BuildConfig;
import com.fuying.sn.KeepAliveConnection;
import com.fuying.sn.utils.ServiceAliveUtils;
import com.fuying.sn.utils.Utils;
import com.fuying.sn.websocket.JWebSocketClient;
import org.java_websocket.handshake.ServerHandshake;
import java.net.URI;
/**
* 主进程 双进程通讯
*
* @author LiGuangMin
* @time Created by 2018/8/17 11:26
*/
public class StepService extends Service implements NetworkUtils.OnNetworkStatusChangedListener {
private final static String TAG = StepService.class.getSimpleName();
public JWebSocketClient client;
private JWebSocketClientBinder mBinder = new JWebSocketClientBinder();
@Override
public void onDisconnected() {
Log.i("JWebSocketClientService", "网络断开连接");
}
@Override
public void onConnected(NetworkUtils.NetworkType networkType) {
Log.i("JWebSocketClientService", "网络已连接");
connect();
}
//用于Activity和service通讯
public class JWebSocketClientBinder extends Binder {
public StepService getService() {
return StepService.this;
}
}
private ServiceConnection mServiceConnection = new ServiceConnection() {
@Override
public void onServiceConnected(ComponentName componentName, IBinder iBinder) {
Log.w(TAG, "StepService:建立链接");
boolean isServiceRunning = ServiceAliveUtils.isServiceAlice(StepService.this, GuardService.class.getName());
if (!isServiceRunning) {
Intent i = new Intent(StepService.this, GuardService.class);
startService(i);
}
}
@Override
public void onServiceDisconnected(ComponentName componentName) {
// 断开链接
startService(new Intent(StepService.this, GuardService.class));
// 重新绑定
bindService(new Intent(StepService.this, GuardService.class), mServiceConnection, Context.BIND_IMPORTANT);
}
};
@Nullable
@Override
public IBinder onBind(Intent intent) {
return new KeepAliveConnection.Stub() {
};
}
@Override
public void onCreate() {
super.onCreate();
NetworkUtils.registerNetworkStatusChangedListener(this);
registerScreenLockReceiver();
//初始化websocket
initSocketClient();
mHandler.postDelayed(heartBeatRunnable, HEART_BEAT_RATE);//开启心跳检测
}
@Override
public int onStartCommand(Intent intent, int flags, int startId) {
// 绑定建立链接
Log.e("JWebSocketClientService", "onStartCommand: ");
bindService(new Intent(this, GuardService.class), mServiceConnection, Context.BIND_IMPORTANT);
return START_STICKY;
}
private ScreenLockReceiver screenLockReceiver;
private void registerScreenLockReceiver() {
if (null == screenLockReceiver) {
screenLockReceiver = new ScreenLockReceiver();
}
IntentFilter filter = new IntentFilter();
filter.setPriority(IntentFilter.SYSTEM_HIGH_PRIORITY);
filter.addAction(Intent.ACTION_SCREEN_OFF);
filter.addAction(Intent.ACTION_SCREEN_ON);
filter.addAction(Intent.ACTION_BOOT_COMPLETED);
filter.addAction(Intent.ACTION_USER_PRESENT);
filter.addAction(Intent.ACTION_SHUTDOWN);
filter.addAction(Intent.ACTION_FACTORY_RESET);
filter.addAction(Intent.ACTION_MASTER_CLEAR);
registerReceiver(screenLockReceiver, filter);
}
private class ScreenLockReceiver extends BroadcastReceiver {
@Override
public void onReceive(Context context, Intent intent) {
String action = intent.getAction();
Log.e(TAG, "onReceive:" + action);
if (TextUtils.isEmpty(action)) {
Log.e(TAG, "onReceive: is NULL");
return;
}
switch (action) {
case Intent.ACTION_BOOT_COMPLETED:
case Intent.ACTION_USER_PRESENT:
case Intent.ACTION_SCREEN_ON:
sendMsg(1);
break;
case Intent.ACTION_SCREEN_OFF:
case Intent.ACTION_SHUTDOWN:
case Intent.ACTION_FACTORY_RESET:
case Intent.ACTION_MASTER_CLEAR:
sendMsg(0);
break;
default:
break;
}
}
}
@Override
public void onDestroy() {
super.onDestroy();
NetworkUtils.unregisterNetworkStatusChangedListener(this);
closeConnect();
if (screenLockReceiver != null) {
unregisterReceiver(screenLockReceiver);
}
}
/**
* 初始化websocket连接
*/
private void initSocketClient() {
URI uri = URI.create(BuildConfig.WEBSOCKET_URL);
// URI uri = URI.create("ws://echo.websocket.org");
// URI uri = URI.create("ws://123.207.136.134:9010/ajaxchattest");
client = new JWebSocketClient(uri) {
@Override
public void onMessage(String message) {
Log.i("JWebSocketClientService", "收到服务器发来的消息:" + message);
}
@Override
public void onOpen(ServerHandshake handshakedata) {
super.onOpen(handshakedata);
Log.i("JWebSocketClientService", "websocket连接成功");
sendMsg(1);
}
@Override
public void onClose(int code, String reason, boolean remote) {
super.onClose(code, reason, remote);
Log.i("JWebSocketClientService", "websocket连接关闭:" + reason);
// client.close();
// initSocketClient();
mHandler.postDelayed(heartBeatRunnable, HEART_BEAT_RATE);//开启心跳检测
}
@Override
public void onError(Exception ex) {
super.onError(ex);
Log.i("JWebSocketClientService", "websocket连接错误:" + ex.getMessage());
// client.close();
// initSocketClient();
mHandler.postDelayed(heartBeatRunnable, HEART_BEAT_RATE);//开启心跳检测
}
};
connect();
}
/**
* 连接websocket
*/
private void connect() {
new Thread() {
@Override
public void run() {
try {
//connectBlocking多出一个等待操作,会先连接再发送,否则未连接发送会报错
Log.i("JWebSocketClientService", "websocket链接中");
client.connectBlocking();
} catch (Exception e) {
Log.i("JWebSocketClientService", e.getMessage());
// e.printStackTrace();
}
}
}.start();
}
/**
* 发送消息
*/
public void sendMsg() {
JsonObject jsonObject = new JsonObject();
jsonObject.addProperty("sn", Utils.getSerial());
PowerManager pm = (PowerManager) getSystemService(Context.POWER_SERVICE);
if (!pm.isScreenOn()) {
jsonObject.addProperty("online", 0);
//熄屏状态
} else {
jsonObject.addProperty("online", 1);
}
if (null != client) {
Log.i("JWebSocketClientService", "发送的消息:" + jsonObject.toString());
client.send(jsonObject.toString());
}
}
public void sendMsg(int state) {
JsonObject jsonObject = new JsonObject();
jsonObject.addProperty("sn", Utils.getSerial());
jsonObject.addProperty("online", state);
if (null != client) {
Log.i("JWebSocketClientService", "发送的消息:" + jsonObject.toString());
try {
client.send(jsonObject.toString());
} catch (Exception e) {
Log.i(TAG, "sendMsg :" + e.getLocalizedMessage());
}
} else {
Log.i("JWebSocketClientService", "未连接");
}
}
/**
* 断开连接
*/
private void closeConnect() {
try {
if (null != client) {
client.close();
}
} catch (Exception e) {
e.printStackTrace();
} finally {
client = null;
}
}
// -------------------------------------websocket心跳检测------------------------------------------------
private static final long HEART_BEAT_RATE = 30 * 1000;//每隔50秒进行一次对长连接的心跳检测
private Handler mHandler = new Handler();
private Runnable heartBeatRunnable = new Runnable() {
@Override
public void run() {
Log.i("JWebSocketClientService", "心跳包检测websocket连接状态");
if (client != null) {
if (client.isOpen()) {
Log.i("JWebSocketClientService", "websocket已连接");
sendMsg();
} else if (client.isClosed()) {
Log.i("JWebSocketClientService", "websocket重连中");
reconnectWs();
}
} else {
//如果client已为空,重新初始化连接
client = null;
initSocketClient();
}
//每隔一定的时间,对长连接进行一次心跳检测
mHandler.postDelayed(this, HEART_BEAT_RATE);
}
};
/**
* 开启重连
*/
private void reconnectWs() {
mHandler.removeCallbacks(heartBeatRunnable);
new Thread() {
@Override
public void run() {
try {
Log.i("JWebSocketClientService", "开启重连");
client.reconnectBlocking();
} catch (InterruptedException e) {
e.printStackTrace();
}
}
}.start();
}
}

View File

@@ -0,0 +1,69 @@
package com.fuying.sn.service.main;
import com.fuying.sn.base.BasePresenter;
import com.fuying.sn.base.BaseView;
import com.fuying.sn.bean.BaseResponse;
import com.fuying.sn.bean.SnInfo;
public class MainSContact {
public interface MainView extends BaseView {
void setSnInfo(BaseResponse<SnInfo> response);
void setLocked(int lockedStatus);
void updateInfoFinish();
void checkUpdateFinish();
void checkFXYUpdateFinish();
void getAllAppFinish();
void setOverallApp();
void setAppInside();
void setForceInstall();
void setSystemSettings();
void setBrowserLabel();
void setBrowserWhiteList();
void setAppJump();
void setAppStart();
void setAppTimeControl();
void setSnTimeControl();
void setMyAppList();
void setScreenLock();
}
interface Presenter extends BasePresenter<MainView> {
//获取设备信息
void getSnInfo();
//获取锁定状态
void getLocked();
//上传设备信息
void updateDeviceInfo();
//检查更新
void checkUpdate();
//检查扶小鹰App更新
void checkFXYUpdate();
//获取所有app包名
void getAllApp();
/*获取所有全局更新*/
void getOverallApp();
//获取id管控
void getAppInside();
//获取强制下载
void getForceInstall();
//获取系统设置
void getSystemSettings();
//获取浏览器书签
void getBrowserLabel();
//获取浏览器黑白名单
void getBrowserWhiteList();
//获取内部网址管控
void getAppJump();
//应用自启
void getAppStart();
//获取时间管控
void getAppTimeControl();
//获取整机管控
void getSnTimeControl();
//获取所有应用使用时间
void getMyAppList();
//获取锁屏管控
void getScreenLock();
}
}

View File

@@ -0,0 +1,559 @@
package com.fuying.sn.service.main;
import android.annotation.SuppressLint;
import android.content.Context;
import android.content.Intent;
import android.os.Build;
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.bean.AppInfo;
import com.fuying.sn.bean.AppStart;
import com.fuying.sn.bean.BaseResponse;
import com.fuying.sn.bean.Label;
import com.fuying.sn.bean.MyAppUsageBean;
import com.fuying.sn.bean.SystemSettingsSet;
import com.fuying.sn.bean.browser.BrowserApiData;
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.manager.ControlManager;
import com.fuying.sn.network.NetInterfaceManager;
import com.fuying.sn.network.UrlAddress;
import com.fuying.sn.service.ManagerService;
import com.fuying.sn.utils.ApkUtils;
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 java.util.HashSet;
import java.util.List;
import java.util.stream.Collectors;
import io.reactivex.rxjava3.android.schedulers.AndroidSchedulers;
import io.reactivex.rxjava3.core.Observer;
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
*/
public class MainSPresenter implements MainSContact.Presenter {
private String TAG = MainSPresenter.class.getSimpleName();
private MainSContact.MainView mView;
private Context mContext;
private CacheHelper mCacheHelper;
private MMKV mMMKV = MMKV.defaultMMKV();
public MainSPresenter(Context context) {
this.mContext = context;
this.mCacheHelper = new CacheHelper(context);
}
private BehaviorSubject<ActivityEvent> lifecycle;
public void setLifecycle(BehaviorSubject<ActivityEvent> lifecycle) {
this.lifecycle = lifecycle;
}
public BehaviorSubject<ActivityEvent> getLifecycle() {
return lifecycle;
}
@Override
public void attachView(MainSContact.MainView view) {
this.mView = view;
}
@Override
public void detachView() {
this.mView = null;
}
@Override
public void getSnInfo() {
NetInterfaceManager.getInstance()
.getSnInfo(true, getLifecycle(), new NetInterfaceManager.ObserverCallback() {
@Override
public void onSubscribe(Disposable d) {
Log.e("getSnInfo", "onSubscribe: ");
}
@Override
public void onNext(BaseResponse response) {
Log.e("getSnInfo", "onNext: ");
mView.setSnInfo(response);
}
@Override
public void onError(Throwable e) {
Log.e("getSnInfo", "onError: " + e.getMessage());
}
@Override
public void onComplete() {
Log.e("getSnInfo", "onComplete: ");
}
});
}
@Override
public void getLocked() {
int statu = (int) SPUtils.get(mContext, CommonConfig.isLogined, 0);
mView.setLocked(statu);
}
@Override
public void updateDeviceInfo() {
NetInterfaceManager.getInstance().updateAdminInfo();
mView.updateInfoFinish();
}
@Override
public void checkUpdate() {
NetInterfaceManager.getInstance().checkAllAppUpdate(true, getLifecycle(), new NetInterfaceManager.CompleteCallback() {
@Override
public void onComplete() {
mView.checkUpdateFinish();
}
});
}
@Override
public void checkFXYUpdate() {
NetInterfaceManager.getInstance().checkFXYAppUpdate(true, getLifecycle(), new NetInterfaceManager.CompleteCallback() {
@Override
public void onComplete() {
mView.checkFXYUpdateFinish();
}
});
}
@Override
@SuppressLint("NewApi")
public void getAllApp() {
NetInterfaceManager.getInstance()
.getQueryAllAppControl()
.compose(RxLifecycle.bindUntilEvent(getLifecycle(), ActivityEvent.DESTROY))
.subscribe(new Observer<BaseResponse<List<AppInfo>>>() {
@Override
public void onSubscribe(Disposable d) {
Log.e("getAllApp", "onSubscribe: ");
}
@Override
public void onNext(BaseResponse<List<AppInfo>> listBaseResponse) {
Log.e("getAllApp", "onNext: " + listBaseResponse);
int code = listBaseResponse.code;
if (code == 200) {
List<AppInfo> appInfoList = listBaseResponse.data;
if (appInfoList == null || appInfoList.size() == 0) {
mMMKV.encode(UrlAddress.GET_ALL_PACKAGE, "");
ApkUtils.writeAppPackageList(mContext, "");
} else {
mMMKV.encode(UrlAddress.GET_ALL_PACKAGE, GsonUtils.toJSONString(appInfoList));
HashSet allPkgSet = new HashSet<String>();
for (AppInfo pkg : appInfoList) {
allPkgSet.add(pkg.getApp_package());
}
String allPkgString = String.join(",", allPkgSet);
Settings.System.putString(mContext.getContentResolver(), CommonConfig.ONLY_SHORTCUT_LIST, allPkgString);
Log.e("getAllApp", "onNext: " + allPkgString);
ApkUtils.writeAppPackageList(mContext, allPkgString);
NetInterfaceManager.getInstance().getAppStart(appInfoList);
}
JGYUtils.getInstance().deleteOtherApp();
} else {
mMMKV.encode(UrlAddress.GET_ALL_PACKAGE, "");
ApkUtils.writeAppPackageList(mContext, "");
}
}
@Override
public void onError(Throwable e) {
Log.e("getAllApp", "onError: " + e.getMessage());
onComplete();
}
@Override
public void onComplete() {
Log.e("getAllApp", "onComplete: ");
mView.getAllAppFinish();
}
});
}
@Override
public void getOverallApp() {
NetInterfaceManager.getInstance().getOverallApp(true, getLifecycle(), new NetInterfaceManager.CompleteCallback() {
@Override
public void onComplete() {
mView.setOverallApp();
}
});
}
@Override
public void getAppInside() {
NetInterfaceManager.getInstance()
.getAppInsideControl()
.compose(RxLifecycle.bindUntilEvent(getLifecycle(), ActivityEvent.DESTROY))
.subscribe(new Observer<BaseResponse>() {
@Override
public void onSubscribe(Disposable d) {
Log.e("getAppInside", "onSubscribe: ");
}
@Override
public void onNext(BaseResponse baseResponse) {
String jsonString = GsonUtils.toJSONString(baseResponse.data);
Log.e("getAppInside", "onNext: " + jsonString);
if (baseResponse.code == 200) {
JsonObject jsonObject = GsonUtils.getJsonObject(jsonString);
String ids = jsonObject.get("ids").getAsString();
String packages = jsonObject.get("package").getAsString();
JGYUtils.getInstance().writeDeselectIDtoSystem(ids, packages);
} else {
Log.e("getAppInside", "onNext: " + baseResponse.msg);
Settings.System.putString(mContext.getContentResolver(), CommonConfig.AOLE_ACTION_APP_FORBID_ID, " ");
Settings.System.putString(mContext.getContentResolver(), CommonConfig.AOLE_ACTION_APP_FORBID_ARRAY, " ");
}
}
@Override
public void onError(Throwable e) {
Log.e("getAppInside", "onError: " + e.getMessage());
onComplete();
}
@Override
public void onComplete() {
Log.e("getAppInside", "onComplete: ");
mView.setAppInside();
}
});
}
@Override
public void getForceInstall() {
NetInterfaceManager.getInstance().getForceInstall(true, getLifecycle(), new NetInterfaceManager.CompleteCallback() {
@Override
public void onComplete() {
mView.setForceInstall();
Log.e("getForceInstall", "onComplete: ");
}
});
}
@Override
public void getSystemSettings() {
NetInterfaceManager.getInstance()
.getsettingControl()
.compose(RxLifecycle.bindUntilEvent(getLifecycle(), ActivityEvent.DESTROY))
.subscribe(new Observer<BaseResponse<SystemSettingsSet>>() {
@Override
public void onSubscribe(Disposable d) {
Log.e("getSystemSettings", "onSubscribe: ");
}
@Override
public void onNext(BaseResponse<SystemSettingsSet> systemSettingsBaseResponse) {
Log.e("getSystemSettings", "onNext: " + systemSettingsBaseResponse);
SPUtils.put(mContext, "is_first_connection", 0);
int code = systemSettingsBaseResponse.code;
if (code == 200) {
String data = new Gson().toJson(systemSettingsBaseResponse.data.getUser());
ControlManager.getInstance().setSystemSetting(data);
} else {
ControlManager.getInstance().setDisableSetting();
}
}
@Override
public void onError(Throwable e) {
if ((int) SPUtils.get(mContext, "is_first_connection", 1) == 1) {
ControlManager.getInstance().setDisableSetting();
}
Log.e("getSystemSettings", "onError: " + e.getMessage());
onComplete();
}
@Override
public void onComplete() {
Log.e("getSystemSettings", "onComplete: ");
mView.setSystemSettings();
}
});
}
@Override
public void getBrowserLabel() {
NetInterfaceManager.getInstance().getLabelControl()
.compose(RxLifecycle.bindUntilEvent(getLifecycle(), ActivityEvent.DESTROY))
.subscribe(new Observer<BaseResponse<Label>>() {
@Override
public void onSubscribe(Disposable d) {
Log.e("getBrowserLabel", "onSubscribe: ");
}
@Override
public void onNext(BaseResponse<Label> labelBaseResponse) {
Log.e("getBrowserLabel", "onNext: " + labelBaseResponse);
if (labelBaseResponse.code == 200) {
String home_page = labelBaseResponse.data.getHome_page();
Settings.System.putString(mContext.getContentResolver(), "homepagURL", home_page);
//主页
Intent homepag = new Intent("qch_app_brower_homepage");
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
homepag.setPackage("com.android.settings")
.setPackage("com.android.browser");
}
if (!TextUtils.isEmpty(home_page)) {
homepag.putExtra("homepage", home_page);
} else {
homepag.putExtra("homepage", "");
}
mContext.sendBroadcast(homepag);
//书签
String label_page = labelBaseResponse.data.getLabel_page();
Intent websiteBookMark = new Intent("qch_app_brower_website");
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
websiteBookMark.setPackage("com.android.settings")
.setPackage("com.android.browser");
}
if (!TextUtils.isEmpty(label_page)) {
websiteBookMark.putExtra("websiteBookMark", label_page);
} else {
websiteBookMark.putExtra("websiteBookMark", "");
}
mContext.sendBroadcast(websiteBookMark);
} else {
Intent intent1 = new Intent("qch_app_brower_homepage");
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
intent1.setPackage("com.android.settings")
.setPackage("com.android.browser");
}
intent1.putExtra("homepage", "");
mContext.sendBroadcast(intent1);
Intent intent2 = new Intent("qch_app_brower_website");
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
intent2.setPackage("com.android.settings")
.setPackage("com.android.browser");
}
intent2.putExtra("websiteBookMark", "");
mContext.sendBroadcast(intent2);
}
}
@Override
public void onError(Throwable e) {
Log.e("getBrowserLabel", "onError: " + e.getMessage());
onComplete();
}
@Override
public void onComplete() {
Log.e("getBrowserLabel", "onComplete: ");
mView.setBrowserLabel();
}
});
}
/**
* 浏览器黑白名单
*/
@Override
public void getBrowserWhiteList() {
NetInterfaceManager.getInstance().getBrowserControl()
.compose(RxLifecycle.bindUntilEvent(getLifecycle(), ActivityEvent.DESTROY))
.subscribe(new Observer<BaseResponse<BrowserApiData>>() {
@Override
public void onSubscribe(Disposable d) {
Log.e("getBrowserWhiteList", "onSubscribe: ");
}
@Override
public void onNext(BaseResponse<BrowserApiData> response) {
Log.e("getBrowserWhiteList", "onNext: " + response);
if (response.code == 200) {
//白名单
List<BrowserBean> white = response.data.getWhiteList();
if (null != white && white.size() != 0) {
boolean whiteList = Settings.System.putString(mContext.getContentResolver(), "DeselectBrowserArray",
white.stream().map(BrowserBean::getAddress).collect(Collectors.joining(",")));
Log.e("getBrowserWhiteList", "setBrowserList_white:" + white + ":" + whiteList);
} else {
Settings.System.putString(mContext.getContentResolver(), "DeselectBrowserArray", " ");
}
//黑名单
List<BrowserBean> black = response.data.getBlackList();
if (null != black && black.size() != 0) {
boolean blackList = Settings.System.putString(mContext.getContentResolver(), "qch_webblack_url",
black.stream().map(BrowserBean::getAddress).collect(Collectors.joining(",")));
Log.e("getBrowserWhiteList", "setBrowserList_black:" + black + ":" + blackList);
} else {
Settings.System.putString(mContext.getContentResolver(), "qch_webblack_url", " ");
}
} else {
Settings.System.putString(mContext.getContentResolver(), "DeselectBrowserArray", " ");
Settings.System.putString(mContext.getContentResolver(), "qch_webblack_url", " ");
}
}
@Override
public void onError(Throwable e) {
Log.e("getBrowserWhiteList", "onError: " + e.getMessage());
onComplete();
}
@Override
public void onComplete() {
new URLUtils(mContext).setBrowserList();
mView.setBrowserWhiteList();
Log.e("getBrowserWhiteList", "onComplete: ");
}
});
}
@Override
public void getAppJump() {
NetInterfaceManager.getInstance().getAppJump(new NetInterfaceManager.CompleteCallback() {
@Override
public void onComplete() {
mView.setAppJump();
}
});
}
@Override
public void getAppStart() {
NetInterfaceManager.getInstance()
.getAppStartControl()
.compose(RxLifecycle.bindUntilEvent(getLifecycle(), ActivityEvent.DESTROY))
.subscribe(new Observer<BaseResponse<List<AppStart>>>() {
@Override
public void onSubscribe(Disposable d) {
Log.e("getAppStart", "onSubscribe: ");
}
@Override
public void onNext(BaseResponse<List<AppStart>> listBaseResponse) {
Log.e("getAppStart", "onNext: ");
int code = listBaseResponse.code;
if (code == 200) {
List<AppStart> list = listBaseResponse.data;
NetInterfaceManager.getInstance().setAppState(list);
} else {
NetInterfaceManager.getInstance().setInvalid();
}
}
@Override
public void onError(Throwable e) {
Log.e("getAppStart", "onError: " + e.getMessage());
onComplete();
}
@Override
public void onComplete() {
Log.e("getAppStart", "onComplete: ");
mView.setAppStart();
}
});
}
@Override
public void getAppTimeControl() {
NetInterfaceManager.getInstance().getAppTimeControl(true, getLifecycle(), new NetInterfaceManager.CompleteCallback() {
@Override
public void onComplete() {
mView.setAppTimeControl();
}
});
}
@Override
public void getSnTimeControl() {
NetInterfaceManager.getInstance().getSnTimeControl(true, getLifecycle(), new NetInterfaceManager.CompleteCallback() {
@Override
public void onComplete() {
mView.setSnTimeControl();
}
});
}
@Override
public void getMyAppList() {
NetInterfaceManager.getInstance().getMyAppList(new NetInterfaceManager.MyAppListCallback() {
@Override
public void setMyAppList(List<MyAppUsageBean> myAppList) {
RunningAppManager.getInstance().syncAllAppUsageTime(myAppList);
}
});
}
@Override
public void getScreenLock() {
NetInterfaceManager.getInstance()
.getScreenLockControl()
.getScreenshot(Utils.getSerial())
.subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread())
.compose(RxLifecycle.bindUntilEvent(getLifecycle(), ActivityEvent.DESTROY))
.subscribe(new Observer<BaseResponse>() {
@Override
public void onSubscribe(Disposable d) {
Log.e("getScreenLock", "onSubscribe: ");
}
@Override
public void onNext(BaseResponse baseResponse) {
Log.e("getScreenLock", "onNext: " + baseResponse);
int code = baseResponse.code;
if (code == 200) {
JsonObject jsonObject = GsonUtils.getJsonObject(GsonUtils.toJSONString(baseResponse.data));
int is_screen_lock = jsonObject.get("is_screen_lock").getAsInt();
if (!ServiceAliveUtils.isServiceAlice(mContext, ManagerService.class.getName())) {
mContext.startService(new Intent(mContext, ManagerService.class));
}
SPUtils.put(mContext, LOCK_STATE, is_screen_lock);
Intent intent = new Intent();
// intent.putExtra("name", name);
if (1 == is_screen_lock) {
intent.setAction(ManagerService.ACTION_LOCK);
} else if (0 == is_screen_lock) {
intent.setAction(ManagerService.ACTION_UNLOCK);
}
mContext.sendBroadcast(intent);
}
}
@Override
public void onError(Throwable e) {
Log.e("getScreenLock", "onError: " + e.getMessage());
}
@Override
public void onComplete() {
Log.e("getScreenLock", "onComplete: ");
}
});
}
}

View File

@@ -0,0 +1,556 @@
package com.fuying.sn.service.main;
import android.app.AlarmManager;
import android.app.Service;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
import android.content.pm.PackageManager;
import android.net.ConnectivityManager;
import android.net.NetworkInfo;
import android.net.wifi.WifiInfo;
import android.net.wifi.WifiManager;
import android.os.AsyncTask;
import android.os.Binder;
import android.os.IBinder;
import android.os.SystemClock;
import android.text.TextUtils;
import android.util.Log;
import com.blankj.utilcode.util.NetworkUtils;
import com.tencent.android.tpush.XGIOperateCallback;
import com.tencent.android.tpush.XGPushConfig;
import com.tencent.android.tpush.XGPushManager;
import com.tencent.mmkv.MMKV;
import com.trello.rxlifecycle4.LifecycleProvider;
import com.trello.rxlifecycle4.LifecycleTransformer;
import com.trello.rxlifecycle4.RxLifecycle;
import com.trello.rxlifecycle4.android.ActivityEvent;
import com.trello.rxlifecycle4.android.RxLifecycleAndroid;
import com.fuying.sn.BuildConfig;
import com.fuying.sn.bean.BaseResponse;
import com.fuying.sn.bean.SnInfo;
import com.fuying.sn.config.CommonConfig;
import com.fuying.sn.manager.ConnectManager;
import com.fuying.sn.manager.ControlManager;
import com.fuying.sn.network.NetInterfaceManager;
import com.fuying.sn.rlog.LogDBManager;
import com.fuying.sn.service.DownloadService;
import com.fuying.sn.service.GuardService;
import com.fuying.sn.service.StepService;
import com.fuying.sn.utils.ApkUtils;
import com.fuying.sn.utils.CacheUtils;
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 org.jetbrains.annotations.NotNull;
import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.TimeUnit;
import io.reactivex.rxjava3.core.Observable;
import io.reactivex.rxjava3.core.ObservableEmitter;
import io.reactivex.rxjava3.core.ObservableOnSubscribe;
import io.reactivex.rxjava3.core.Observer;
import io.reactivex.rxjava3.disposables.Disposable;
import io.reactivex.rxjava3.subjects.BehaviorSubject;
/**
* @author jgy02
*/
public class MainService extends Service implements MainSContact.MainView, NetworkUtils.OnNetworkStatusChangedListener, LifecycleProvider<ActivityEvent> {
private String TAG = MainService.class.getSimpleName();
public static MainSPresenter mPresenter;
private MMKV mMMKV = MMKV.defaultMMKV();
//执行所有请求的时间
long runningTime;
//MainService上次执行时间
long startCommandTime = 0;
private final BehaviorSubject<ActivityEvent> lifecycleSubject = BehaviorSubject.create();
@NotNull
@Override
public Observable<ActivityEvent> lifecycle() {
return lifecycleSubject.hide();
}
@NotNull
@Override
public <T> LifecycleTransformer<T> bindUntilEvent(@NotNull ActivityEvent event) {
return RxLifecycle.bindUntilEvent(lifecycleSubject, event);
}
@NotNull
@Override
public <T> LifecycleTransformer<T> bindToLifecycle() {
return RxLifecycleAndroid.bindActivity(lifecycleSubject);
}
@Override
public void onDisconnected() {
Log.e(TAG, "网络未连接");
ToastUtil.show("网络未连接");
}
@Override
public void onConnected(NetworkUtils.NetworkType networkType) {
ToastUtil.show("网络已连接");
String WiFiAlias = Utils.getWifiAlias(this);
Log.e("OnNetworkStatusChanged", "onConnected: " + WiFiAlias);
Utils.getPublicIP(this);
if (ConnectManager.getInstance().isWiFiFistConnect()) {
start.onstar(ConnectManager.WIFI_LAST_CONNECT_TIME);
} else {
if (ConnectManager.getInstance().isWiFiCutoverFistConnect(WiFiAlias)) {
start.onstar(WiFiAlias);
}
}
//第一次开机联网后直接连接
if ((int) SPUtils.get(this, CommonConfig.JGY_FIRST_BOOT, 0) == 0) {
mPresenter.getSnInfo();
SPUtils.put(this, CommonConfig.JGY_FIRST_BOOT, 1);
}
mPresenter.checkUpdate();
mPresenter.getAllApp();
TimeTask task = new TimeTask();
task.execute("ntp.aliyun.com");
NetInterfaceManager.getInstance().SendAppInstallInfo();
}
@Override
public IBinder onBind(Intent intent) {
return mMainBinder;
}
public MainBinder mMainBinder = new MainBinder();
public class MainBinder extends Binder {
public MainService getService() {
return MainService.this;
}
}
public void getLocked() {
mPresenter.getLocked();
}
@Override
public void onCreate() {
super.onCreate();
lifecycleSubject.onNext(ActivityEvent.CREATE);
mPresenter = new MainSPresenter(this);
mPresenter.setLifecycle(lifecycleSubject);
mPresenter.attachView(this);
TimeTask task = new TimeTask();
task.execute("ntp.aliyun.com");
ApkUtils.UninstallAPP(this, "com.joytv.live");
ApkUtils.UninstallAPP(this, "com.tencent.android.qqdownloader");
try {
getPackageManager().setApplicationEnabledSetting("com.android.email", PackageManager.COMPONENT_ENABLED_STATE_DISABLED, 0);
} catch (Exception e) {
Log.e(TAG, "onCreate: " + e.getMessage());
}
Observable.create(subscribe)
.throttleFirst(1, TimeUnit.MINUTES)
.subscribe(timeObserver);
if ((int) SPUtils.get(this, CommonConfig.JGY_FIRST_CONNECT, 0) == 0) {
start.onstar(ConnectManager.REBOOT_LAST_ONNECT_TIME);
}
int oldVersionCode = (int) SPUtils.get(this, CommonConfig.SN_VERSIONCODE, 0);
if (oldVersionCode < BuildConfig.VERSION_CODE) {
Log.e(TAG, "onCreate: " + "upgrade successful");
try {
new CacheUtils().cleanApplicationUserData(this, "com.aoleyun.os");
} catch (Exception e) {
Log.e(TAG, "onReceive: " + e.getMessage());
e.printStackTrace();
}
} else {
if (ConnectManager.getInstance().isRebootFistConnect()) {
start.onstar(ConnectManager.REBOOT_LAST_ONNECT_TIME);
runningTime = SystemClock.elapsedRealtime();
} else {
Log.e(TAG, "onCreate: " + "Service Reboot");
// mPresenter.getLockedState();
}
}
SPUtils.put(this, CommonConfig.SN_VERSIONCODE, BuildConfig.VERSION_CODE);
registerReceivers();
NetworkUtils.registerNetworkStatusChangedListener(this);
// ControlManager.getInstance().setDefaultUSBstate();
NetInterfaceManager.getInstance().SendAppInstallInfo();
}
@Override
public int onStartCommand(Intent intent, int flags, int startId) {
Log.e(TAG, "onStartCommand: " + System.currentTimeMillis());
return START_STICKY;
}
@Override
public void onDestroy() {
super.onDestroy();
lifecycleSubject.onNext(ActivityEvent.DESTROY);
NetworkUtils.unregisterNetworkStatusChangedListener(this);
mPresenter.detachView();
unregisterReceivers();
}
public static MainSPresenter getPresenter() {
return mPresenter;
}
private void startService() {
startService(new Intent(this, GuardService.class));
startService(new Intent(this, StepService.class));
startService(new Intent(this, DownloadService.class));
}
private class TimeTask extends AsyncTask<String, Long, Long> {
@Override
protected Long doInBackground(String... strings) {
return TimeUtils.getTimeFromNtpServer(strings[0]);
}
@Override
protected void onPostExecute(Long aLong) {
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);
}
}
private void tPushInit() {
XGPushConfig.enableDebug(this, true);
XGPushManager.registerPush(this, new XGIOperateCallback() {
@Override
public void onSuccess(Object data, int flag) {
//token在设备卸载重装的时候有可能会变
Log.e("TPush", "注册成功,设备token为:" + data);
List<XGPushManager.AccountInfo> accountInfoList = new ArrayList<>();
accountInfoList.add(new XGPushManager.AccountInfo(XGPushManager.AccountType.CUSTOM.getValue(), Utils.getSerial()));
XGPushManager.upsertAccounts(MainService.this, accountInfoList, new XGIOperateCallback() {
@Override
public void onSuccess(Object data, int flag) {
Log.e("TPush", "onSuccess, data:" + data + ", flag:" + flag);
}
@Override
public void onFail(Object data, int errCode, String msg) {
Log.e("TPush", "onFail, data:" + data + ", code:" + errCode + ", msg:" + msg);
}
});
}
@Override
public void onFail(Object data, int errCode, String msg) {
Log.e("TPush", "注册失败,错误码:" + errCode + ",错误信息:" + msg);
}
});
}
private void registerReceivers() {
registerWiFiReceiver();
registerScreenReceiver();
}
private void unregisterReceivers() {
if (mWifiReceiver != null) {
unregisterReceiver(mWifiReceiver);
}
if (mScreenReceiver != null) {
unregisterReceiver(mScreenReceiver);
}
}
private WifiReceiver mWifiReceiver;
private void registerWiFiReceiver() {
if (mWifiReceiver == null) {
mWifiReceiver = new WifiReceiver();
}
IntentFilter filter = new IntentFilter();
filter.addAction(WifiManager.NETWORK_STATE_CHANGED_ACTION);
filter.addAction(WifiManager.WIFI_STATE_CHANGED_ACTION);
filter.addAction(WifiManager.RSSI_CHANGED_ACTION);
filter.addAction(WifiManager.NETWORK_IDS_CHANGED_ACTION);
filter.addAction(WifiManager.SCAN_RESULTS_AVAILABLE_ACTION);
filter.addAction(WifiManager.CONFIGURED_NETWORKS_CHANGED_ACTION);
filter.addAction(WifiManager.LINK_CONFIGURATION_CHANGED_ACTION);
filter.addAction(WifiManager.SUPPLICANT_STATE_CHANGED_ACTION);
filter.addAction(ConnectivityManager.CONNECTIVITY_ACTION);
registerReceiver(mWifiReceiver, filter);
}
public class WifiReceiver extends BroadcastReceiver {
private static final String TAG = "wifiReceiver";
@Override
public void onReceive(Context context, Intent intent) {
switch (intent.getAction()) {
case WifiManager.RSSI_CHANGED_ACTION:
Log.e(TAG, "wifi信号强度变化");
break;
//wifi连接上与否
case WifiManager.NETWORK_STATE_CHANGED_ACTION:
NetworkInfo info = intent.getParcelableExtra(WifiManager.EXTRA_NETWORK_INFO);
if (info.getState().equals(NetworkInfo.State.DISCONNECTED)) {
Log.e(TAG, "wifi断开");
LogDBManager.getInstance().creatNetChangeLog("wifi断开", TimeUtils.transferLongToDate(System.currentTimeMillis()));
} else if (info.getState().equals(NetworkInfo.State.CONNECTED)) {
WifiManager wifiManager = (WifiManager) context.getSystemService(Context.WIFI_SERVICE);
WifiInfo wifiInfo = wifiManager.getConnectionInfo();
//获取当前wifi名称
String oldSSID = mMMKV.decodeString("WiFiSSID", "");
Log.e(TAG, "oldSSID " + oldSSID);
String newSSID = wifiInfo.getSSID();
Log.e(TAG, "连接到网络 " + newSSID);
if (!oldSSID.equals(newSSID)) {
LogDBManager.getInstance().creatNetChangeLog("", oldSSID + " change to: " + newSSID);
//直接获取数据
if (ConnectManager.getInstance().isWiFiCutoverFistConnect(newSSID)) {
start.onstar(newSSID);
}
} else {
LogDBManager.getInstance().creatNetChangeLog("接入WiFi",
"connect to: " + newSSID + " time: "
+ TimeUtils.transferLongToDate(System.currentTimeMillis()));
}
mMMKV.encode("WiFiSSID", Utils.getWifiAlias(context));
}
break;
//wifi打开与否
case WifiManager.WIFI_STATE_CHANGED_ACTION:
int wifistate = intent.getIntExtra(WifiManager.EXTRA_WIFI_STATE, WifiManager.WIFI_STATE_DISABLED);
if (wifistate == WifiManager.WIFI_STATE_DISABLED) {
Log.e(TAG, "系统关闭wifi");
} else if (wifistate == WifiManager.WIFI_STATE_ENABLED) {
Log.e(TAG, "系统开启wifi");
}
break;
default:
}
}
}
private ScreenReceiver mScreenReceiver;
private void registerScreenReceiver() {
if (mScreenReceiver == null) {
mScreenReceiver = new ScreenReceiver();
}
IntentFilter filter = new IntentFilter();
filter.setPriority(IntentFilter.SYSTEM_HIGH_PRIORITY);
filter.addAction(Intent.ACTION_USER_PRESENT);
filter.addAction(Intent.ACTION_SCREEN_ON);
filter.addAction(Intent.ACTION_SCREEN_OFF);
filter.addAction(Intent.ACTION_USER_UNLOCKED);
registerReceiver(mScreenReceiver, filter);
}
private class ScreenReceiver extends BroadcastReceiver {
@Override
public void onReceive(Context context, Intent intent) {
String action = intent.getAction();
Log.e(TAG, "onReceive: " + action);
if (TextUtils.isEmpty(action)) {
Log.e(TAG, "onReceive: action is NULL");
return;
}
switch (action) {
case Intent.ACTION_USER_PRESENT:
mPresenter.getAppTimeControl();
break;
case Intent.ACTION_SCREEN_ON:
break;
case Intent.ACTION_SCREEN_OFF:
break;
case Intent.ACTION_USER_UNLOCKED:
break;
default:
break;
}
}
}
private interface Start {
void onstar(String key);
}
private Start start;
private ObservableOnSubscribe<String> subscribe = new ObservableOnSubscribe<String>() {
@Override
public void subscribe(ObservableEmitter<String> emitter) throws Exception {
start = emitter::onNext;
}
};
private Observer<String> timeObserver = new Observer<String>() {
@Override
public void onSubscribe(Disposable d) {
}
@Override
public void onNext(String string) {
Log.e("TimeObserver", "onNext: " + string);
startCommandTime = runningTime = SystemClock.elapsedRealtime();
mPresenter.getSnInfo();
startService();
}
@Override
public void onError(Throwable e) {
}
@Override
public void onComplete() {
}
};
@Override
public void setSnInfo(BaseResponse<SnInfo> response) {
if (response != null) {
int code = response.code;
//设备已经绑定
if (code == 200) {
mPresenter.getLocked();
SnInfo snInfo = response.data;
NetInterfaceManager.getInstance().checkDeviceType(snInfo.getType_id());
}
//设备没有绑定
else if (code == 300) {
ControlManager.getInstance().setDisableSetting();
}
//没有授权的设备
else if (code == 400) {
ControlManager.getInstance().setDisableSetting();
}
}
}
@Override
public void setLocked(int lockedStatus) {
Log.e(TAG, "setLocked: ");
switch (lockedStatus) {
case 0:
ControlManager.getInstance().setDisableSetting();
break;
case 1:
break;
case 2:
ControlManager.getInstance().setDisableSetting();
break;
default:
}
mPresenter.updateDeviceInfo();
}
@Override
public void updateInfoFinish() {
mPresenter.checkUpdate();
}
@Override
public void checkUpdateFinish() {
mPresenter.checkFXYUpdate();
}
@Override
public void checkFXYUpdateFinish() {
mPresenter.getAllApp();
}
@Override
public void getAllAppFinish() {
mPresenter.getOverallApp();
}
@Override
public void setOverallApp() {
mPresenter.getAppInside();
}
@Override
public void setAppInside() {
mPresenter.getForceInstall();
}
@Override
public void setForceInstall() {
mPresenter.getSystemSettings();
}
@Override
public void setSystemSettings() {
mPresenter.getBrowserLabel();
}
@Override
public void setBrowserLabel() {
mPresenter.getBrowserWhiteList();
}
@Override
public void setBrowserWhiteList() {
mPresenter.getAppJump();
}
@Override
public void setAppJump() {
mPresenter.getAppStart();
}
@Override
public void setAppStart() {
mPresenter.getAppTimeControl();
}
@Override
public void setAppTimeControl() {
mPresenter.getSnTimeControl();
}
@Override
public void setSnTimeControl() {
mPresenter.getMyAppList();
}
@Override
public void setMyAppList() {
mPresenter.getScreenLock();
}
@Override
public void setScreenLock() {
Log.e(TAG, "SettingFinish: " + (SystemClock.elapsedRealtime() - runningTime) + " ms");
}
}