768 lines
25 KiB
Java
768 lines
25 KiB
Java
package com.aoleyun.sn.service;
|
|
|
|
import android.annotation.SuppressLint;
|
|
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.graphics.Bitmap;
|
|
import android.graphics.Color;
|
|
import android.graphics.PixelFormat;
|
|
import android.os.Build;
|
|
import android.os.IBinder;
|
|
import android.os.SystemClock;
|
|
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.alibaba.fastjson.JSON;
|
|
import com.alibaba.fastjson.JSONObject;
|
|
import com.aoleyun.sn.comm.PackageNames;
|
|
import com.blankj.utilcode.util.NetworkUtils;
|
|
import com.google.gson.JsonObject;
|
|
import com.aoleyun.sn.R;
|
|
import com.aoleyun.sn.action.JGYActions;
|
|
import com.aoleyun.sn.activity.MainActivity;
|
|
import com.aoleyun.sn.activity.MainContact;
|
|
import com.aoleyun.sn.activity.MainPresenter;
|
|
import com.aoleyun.sn.receiver.BootReceiver;
|
|
import com.aoleyun.sn.utils.ApkUtils;
|
|
import com.aoleyun.sn.utils.ForegroundAppUtil;
|
|
import com.aoleyun.sn.utils.Logutils;
|
|
import com.aoleyun.sn.utils.SPUtils;
|
|
import com.aoleyun.sn.utils.SaveListUtils;
|
|
import com.aoleyun.sn.utils.SysSettingUtils;
|
|
import com.aoleyun.sn.utils.TimeUtils;
|
|
import com.aoleyun.sn.utils.ToastUtil;
|
|
import com.trello.rxlifecycle2.LifecycleProvider;
|
|
import com.trello.rxlifecycle2.LifecycleTransformer;
|
|
import com.trello.rxlifecycle2.RxLifecycle;
|
|
import com.trello.rxlifecycle2.android.ActivityEvent;
|
|
import com.trello.rxlifecycle2.android.RxLifecycleAndroid;
|
|
|
|
import java.util.Arrays;
|
|
import java.util.HashSet;
|
|
import java.util.concurrent.TimeUnit;
|
|
|
|
import cn.jpush.android.api.JPushInterface;
|
|
import io.reactivex.Observable;
|
|
import io.reactivex.ObservableEmitter;
|
|
import io.reactivex.ObservableOnSubscribe;
|
|
import io.reactivex.Observer;
|
|
import io.reactivex.disposables.Disposable;
|
|
import io.reactivex.subjects.BehaviorSubject;
|
|
|
|
public class MainService extends Service implements MainContact.MainView, NetworkUtils.OnNetworkStatusChangedListener, LifecycleProvider<ActivityEvent> {
|
|
@SuppressLint("StaticFieldLeak")
|
|
public static MainPresenter mPresenter;
|
|
private static final String TAG = MainService.class.getSimpleName();
|
|
public static boolean netWorkIsRunning = false;
|
|
|
|
@Override
|
|
public void onDisconnected() {
|
|
Log.e("OnNetworkStatusChangedListener", "onDisconnected: ");
|
|
ToastUtil.betaShow("网络断开连接");
|
|
}
|
|
|
|
@Override
|
|
public void onConnected(NetworkUtils.NetworkType networkType) {
|
|
Log.e("OnNetworkStatusChangedListener", "onConnected: ");
|
|
runningTime = SystemClock.elapsedRealtime();
|
|
//直接获取数据
|
|
ToastUtil.betaShow("网络已连接");
|
|
start.onstar(SystemClock.elapsedRealtime());
|
|
}
|
|
|
|
private final BehaviorSubject<ActivityEvent> lifecycleSubject = BehaviorSubject.create();
|
|
|
|
@Override
|
|
public Observable<ActivityEvent> lifecycle() {
|
|
return lifecycleSubject.hide();
|
|
}
|
|
|
|
@Override
|
|
public <T> LifecycleTransformer<T> bindUntilEvent(ActivityEvent event) {
|
|
return RxLifecycle.bindUntilEvent(lifecycleSubject, event);
|
|
}
|
|
|
|
@Override
|
|
public <T> LifecycleTransformer<T> bindToLifecycle() {
|
|
return RxLifecycleAndroid.bindActivity(lifecycleSubject);
|
|
}
|
|
|
|
private interface Start {
|
|
void onstar(long time);
|
|
}
|
|
|
|
private Start start;
|
|
|
|
private ObservableOnSubscribe<Long> subscribe = new ObservableOnSubscribe<Long>() {
|
|
@Override
|
|
public void subscribe(ObservableEmitter<Long> emitter) throws Exception {
|
|
start = emitter::onNext;
|
|
}
|
|
};
|
|
|
|
private Observer<Long> timeObserver = new Observer<Long>() {
|
|
@Override
|
|
public void onSubscribe(Disposable d) {
|
|
|
|
}
|
|
|
|
@Override
|
|
public void onNext(Long aLong) {
|
|
Logutils.e("TimeObserver", "onNext: " + aLong);
|
|
startCommandTime = runningTime = SystemClock.elapsedRealtime();
|
|
mPresenter.getFirstConnect();
|
|
mPresenter.getLockedState();
|
|
}
|
|
|
|
@Override
|
|
public void onError(Throwable e) {
|
|
|
|
}
|
|
|
|
@Override
|
|
public void onComplete() {
|
|
|
|
}
|
|
};
|
|
|
|
public MainService() {
|
|
|
|
}
|
|
|
|
@Override
|
|
public IBinder onBind(Intent intent) {
|
|
return null;
|
|
}
|
|
|
|
@Override
|
|
public void onCreate() {
|
|
lifecycleSubject.onNext(ActivityEvent.CREATE);
|
|
mPresenter = new MainPresenter(this);
|
|
mPresenter.attachView(this);
|
|
mPresenter.setProvider(this);
|
|
if ((int) SPUtils.get(this, "first_connect", 0) == 0) {
|
|
// TODO: 2021/5/26 待底层修改,临时解决办法
|
|
Logutils.e(TAG, "onCreate: " + "Disable All Settings");
|
|
mPresenter.setDisableSetting();
|
|
}
|
|
registerReceivers();
|
|
NetworkUtils.registerNetworkStatusChangedListener(this);
|
|
addShortcut();
|
|
Observable.create(subscribe)
|
|
.throttleFirst(3, TimeUnit.HOURS)
|
|
.subscribe(timeObserver);
|
|
Observable.create(timeChangedSubscribe)
|
|
.throttleFirst(3, TimeUnit.HOURS)
|
|
.subscribe(timeChangedObserver);
|
|
// cleanLauncherCache();
|
|
timeChangedStart.onstar(System.currentTimeMillis());
|
|
setStatusbar();
|
|
//发送设备mac地址和信息
|
|
mPresenter.sendMACAddress();
|
|
setFloatingWindow(this);
|
|
super.onCreate();
|
|
}
|
|
|
|
@Override
|
|
public void onDestroy() {
|
|
super.onDestroy();
|
|
unRegisterReceivers();
|
|
NetworkUtils.unregisterNetworkStatusChangedListener(this);
|
|
lifecycleSubject.onNext(ActivityEvent.DESTROY);
|
|
mPresenter.detachView();
|
|
}
|
|
|
|
//执行所有请求的时间
|
|
long runningTime;
|
|
|
|
//MainService上次执行时间
|
|
long startCommandTime = 0;
|
|
|
|
@Override
|
|
public int onStartCommand(Intent intent, int flags, int startId) {
|
|
Intent bootIntent = new Intent(BootReceiver.BOOT_COMPLETED);
|
|
bootIntent.setComponent(new ComponentName(PackageNames.APPSTORE, PackageNames.APP_STORE_BOOTRECEIVER));
|
|
sendBroadcast(bootIntent);
|
|
JPushInterface.init(this);
|
|
if (MainActivity.isForeground) {
|
|
Logutils.e(TAG, "onStartCommand: MainService: isForeground: " + MainActivity.isForeground);
|
|
} else {
|
|
// if (((SystemClock.elapsedRealtime() - startCommandTime) < 60000) && startCommandTime != 0) {
|
|
// Logutils.e(TAG, "onStartCommand: " + "启动时间过短");
|
|
// //一分钟内防止多次调用
|
|
// } else {
|
|
// mPresenter.getFirstConnect();
|
|
// mPresenter.getLockedState();
|
|
// startCommandTime = runningTime = SystemClock.elapsedRealtime();
|
|
// Logutils.e(TAG, "onStartCommand: isForeground: " + MainActivity.isForeground);
|
|
// Logutils.e(TAG, "onStartCommand: " + (SystemClock.elapsedRealtime() - startCommandTime));
|
|
// }
|
|
start.onstar(SystemClock.elapsedRealtime());
|
|
Logutils.e(TAG, "onStartCommand: " + (SystemClock.elapsedRealtime() - startCommandTime) + "ms");
|
|
}
|
|
return START_STICKY;
|
|
}
|
|
|
|
private void addShortcut() {
|
|
ApkUtils.addShortcut(MainService.this);
|
|
}
|
|
|
|
private void setStatusbar() {
|
|
String status = (String) SPUtils.get(this, JGYActions.ACTION_STATUS_BAR_STATUS, "");
|
|
Logutils.e(TAG, "setStatusbar: String: " + status);
|
|
if (TextUtils.isEmpty(status)) {
|
|
Logutils.e(TAG, "setStatusbar: " + "status is NULL");
|
|
return;
|
|
}
|
|
JSONObject jsonObject = JSON.parseObject(status);
|
|
SysSettingUtils.setStatusBar(this, jsonObject);
|
|
}
|
|
|
|
private void registerReceivers() {
|
|
registerLockScreenReceiver();
|
|
registerTimeReceiver();
|
|
registerInstallReceiver();
|
|
}
|
|
|
|
private void unRegisterReceivers() {
|
|
if (null != lockScreenReceiver) {
|
|
unregisterReceiver(lockScreenReceiver);
|
|
}
|
|
if (null != mTimeChangedReceiver) {
|
|
unregisterReceiver(mTimeChangedReceiver);
|
|
}
|
|
if (null != mInstallReceiver) {
|
|
unregisterReceiver(mInstallReceiver);
|
|
}
|
|
}
|
|
|
|
private static WindowManager windowManager;
|
|
private View topView;
|
|
boolean screenlocked = false;
|
|
boolean timelocked = false;
|
|
|
|
@SuppressLint("NewApi")
|
|
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.WHITE);
|
|
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_top, null);
|
|
TextView textView = topView.findViewById(R.id.textView);
|
|
textView.setText(name);
|
|
} else {
|
|
if (topView.getTag().equals("added")) {
|
|
TextView textView = topView.findViewById(R.id.textView);
|
|
textView.setText(name);
|
|
return;
|
|
}
|
|
}
|
|
// topView.setAlpha(0.8f);
|
|
TextView textView = topView.findViewById(R.id.textView);
|
|
textView.setText(name);
|
|
// 设置LayoutParam
|
|
WindowManager.LayoutParams layoutParams = new WindowManager.LayoutParams();
|
|
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
|
|
layoutParams.type = WindowManager.LayoutParams.TYPE_KEYGUARD_DIALOG;
|
|
} 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 registerLockScreenReceiver() {
|
|
if (null == lockScreenReceiver) {
|
|
lockScreenReceiver = new LockScreenReceiver();
|
|
IntentFilter filter = new IntentFilter();
|
|
filter.setPriority(IntentFilter.SYSTEM_HIGH_PRIORITY);
|
|
filter.addAction(LockScreenReceiver.action_lock);
|
|
filter.addAction(LockScreenReceiver.action_unlock);
|
|
registerReceiver(lockScreenReceiver, filter);
|
|
}
|
|
}
|
|
|
|
//锁屏管控广播
|
|
public class LockScreenReceiver extends BroadcastReceiver {
|
|
public static final String action_lock = "LockScreenReceiver_lockscreen";
|
|
public static final String action_unlock = "LockScreenReceiver_unlockscreen";
|
|
|
|
@Override
|
|
public void onReceive(Context context, Intent intent) {
|
|
String action = intent.getAction();
|
|
Logutils.e("LockScreenReceiver", "onReceive: " + action);
|
|
if (TextUtils.isEmpty(action)) {
|
|
return;
|
|
}
|
|
if (action_lock.equals(action)) {
|
|
String name = intent.getStringExtra("name");
|
|
if (!timelocked) {
|
|
showFloatingWindow(name);
|
|
}
|
|
screenlocked = true;
|
|
} else if (action_unlock.equals(action)) {
|
|
if (!timelocked) {
|
|
hideFloatingWindow();
|
|
}
|
|
screenlocked = false;
|
|
}
|
|
}
|
|
}
|
|
|
|
private interface TimeChangedStart {
|
|
void onstar(long time);
|
|
}
|
|
|
|
private TimeChangedStart timeChangedStart;
|
|
|
|
private ObservableOnSubscribe<Long> timeChangedSubscribe = new ObservableOnSubscribe<Long>() {
|
|
@Override
|
|
public void subscribe(ObservableEmitter<Long> emitter) throws Exception {
|
|
timeChangedStart = emitter::onNext;
|
|
}
|
|
};
|
|
|
|
private Observer<Long> timeChangedObserver = new Observer<Long>() {
|
|
@Override
|
|
public void onSubscribe(Disposable d) {
|
|
|
|
}
|
|
|
|
@Override
|
|
public void onNext(Long aLong) {
|
|
setFloatingWindow(MainService.this);
|
|
}
|
|
|
|
@Override
|
|
public void onError(Throwable e) {
|
|
|
|
}
|
|
|
|
@Override
|
|
public void onComplete() {
|
|
|
|
}
|
|
};
|
|
|
|
private TimeChangedReceiver mTimeChangedReceiver;
|
|
|
|
/**
|
|
* 监听时间变化
|
|
*/
|
|
public 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(TimeChangedReceiver.ACTION_UPDATE);
|
|
registerReceiver(mTimeChangedReceiver, filter);
|
|
}
|
|
|
|
public class TimeChangedReceiver extends BroadcastReceiver {
|
|
|
|
public static final String ACTION_UPDATE = "TimeChangedReceiver_update";
|
|
|
|
@SuppressLint("NewApi")
|
|
@Override
|
|
public void onReceive(Context context, Intent intent) {
|
|
Log.e(TAG, "onReceive: " + intent.getAction());
|
|
if (Intent.ACTION_DATE_CHANGED.equals(intent.getAction())) {
|
|
Logutils.e("TimeChangedReceiver", "onReceive:" + "data changed");
|
|
} else if (Intent.ACTION_TIME_CHANGED.equals(intent.getAction())) {
|
|
Logutils.e("TimeChangedReceiver", "onReceive:" + "time changed");
|
|
} else if (Intent.ACTION_TIMEZONE_CHANGED.equals(intent.getAction())) {
|
|
Logutils.e("TimeChangedReceiver", "onReceive:" + "timezone changed");
|
|
} else if (Intent.ACTION_TIME_TICK.equals(intent.getAction())) {
|
|
Logutils.e("TimeChangedReceiver", "onReceive:" + "time tick");
|
|
setFloatingWindow(MainService.this);
|
|
} else if (ACTION_UPDATE.equals(intent.getAction())) {
|
|
setFloatingWindow(MainService.this);
|
|
mPresenter.getScreenLockState();
|
|
Logutils.e("TimeChangedReceiver", "onReceive:" + "date update");
|
|
}
|
|
timeChangedStart.onstar(System.currentTimeMillis());
|
|
}
|
|
}
|
|
|
|
synchronized private void setFloatingWindow(Context context) {
|
|
ForegroundAppUtil.openTopApp(context);
|
|
long nowTime = System.currentTimeMillis();
|
|
TimeUtils.ContralTime contralTime = TimeUtils.getDefaltContralTime(MainService.this);
|
|
Log.e(TAG, "setFloatingWindow: screenlocked: " + screenlocked);
|
|
if (null != contralTime) {
|
|
if (contralTime.inControlTime(nowTime)) {
|
|
if (!screenlocked) {
|
|
showFloatingWindow("管控时间:" + contralTime.toString());
|
|
} else {
|
|
TextView textView = topView.findViewById(R.id.textView);
|
|
textView.setText("管控时间:" + contralTime.toString());
|
|
}
|
|
timelocked = true;
|
|
} else {
|
|
if (!screenlocked) {
|
|
hideFloatingWindow();
|
|
}
|
|
timelocked = false;
|
|
}
|
|
} else {
|
|
if (!screenlocked) {
|
|
hideFloatingWindow();
|
|
}
|
|
timelocked = false;
|
|
}
|
|
}
|
|
|
|
private void registerInstallReceiver() {
|
|
if (mInstallReceiver == null) {
|
|
mInstallReceiver = new InstallReceiver();
|
|
}
|
|
IntentFilter intentFilter = new IntentFilter(INSTALLAPK_ACTION);
|
|
registerReceiver(mInstallReceiver, intentFilter, INSTALLAPK_PREMISSIONS, null);
|
|
}
|
|
|
|
private String INSTALLAPK_ACTION = "JGY_INSTALLAPK_ACTION";
|
|
private String INSTALLAPK_PREMISSIONS = "com.aoleyun.sn.permissions.INSTALL_APK";
|
|
|
|
private InstallReceiver mInstallReceiver;
|
|
|
|
/**
|
|
* https://blog.csdn.net/jdsjlzx/article/details/82630113
|
|
*/
|
|
class InstallReceiver extends BroadcastReceiver {
|
|
|
|
@Override
|
|
public void onReceive(Context context, Intent intent) {
|
|
String action = intent.getAction();
|
|
if (TextUtils.isEmpty(action)) {
|
|
Logutils.e(TAG, "onReceive: " + "Action is NULL!");
|
|
return;
|
|
}
|
|
Logutils.e(TAG, "onReceive: " + "Sender is " + intent.getPackage());
|
|
String packageName = intent.getStringExtra("packageName");
|
|
String filePath = intent.getStringExtra("filePath");
|
|
if (!TextUtils.isEmpty(packageName) && !TextUtils.isEmpty(filePath)) {
|
|
Logutils.e(TAG, "onReceive: " + "packageName: " + packageName + "filePath: " + filePath);
|
|
installApkByPackage(filePath, packageName);
|
|
} else if (!TextUtils.isEmpty(filePath)) {
|
|
String pkg = ApkUtils.getPackageName(MainService.this, filePath);
|
|
if (TextUtils.isEmpty(pkg)) {
|
|
Logutils.e(TAG, "onReceive: " + "unknow packageName");
|
|
} else {
|
|
Logutils.e(TAG, "onReceive: " + "pkg: " + pkg + "\tfilePath: " + filePath);
|
|
installApkByPackage(filePath, pkg);
|
|
}
|
|
} else {
|
|
Logutils.e(TAG, "onReceive: " + "no filePath and packageName");
|
|
}
|
|
}
|
|
}
|
|
|
|
/**
|
|
* @param filePath 路径
|
|
* @param pkg 包名
|
|
*/
|
|
@SuppressLint("NewApi")
|
|
synchronized private void installApkByPackage(String filePath, String pkg) {
|
|
String oldListString = Settings.System.getString(getContentResolver(), "qch_app_forbid");
|
|
HashSet<String> packageList = new HashSet<>(Arrays.asList(oldListString.split(",")));
|
|
if (!packageList.contains(pkg)) {
|
|
Logutils.e(TAG, "installApkByPackage: " + "packageName: " + pkg + " not in whitelist");
|
|
} else {
|
|
Logutils.e(TAG, "installApkByPackage: " + "packageName: " + pkg);
|
|
ApkUtils.installApp(MainService.this, filePath);
|
|
}
|
|
}
|
|
|
|
@Override
|
|
public void setQRImage(Bitmap qrImage) {
|
|
|
|
}
|
|
|
|
@Override
|
|
public void setBatchText(String text, int visibility) {
|
|
|
|
}
|
|
|
|
@Override
|
|
public void setClassText(String text, int visibility) {
|
|
|
|
}
|
|
|
|
@Override
|
|
public void setNumberText(String text, int visibility) {
|
|
|
|
}
|
|
|
|
@Override
|
|
public void setNameText(String text, int visibility) {
|
|
|
|
}
|
|
|
|
@Override
|
|
public void setLockedState(boolean loocked) {
|
|
if (loocked) {
|
|
ToastUtil.betaShow("设备已上锁");
|
|
Logutils.e(TAG, "setLockedState: " + netWorkIsRunning);
|
|
//上传APP信息
|
|
ApkUtils.getAppInfo(this);
|
|
//发送设备mac地址和信息
|
|
mPresenter.sendMACAddress();
|
|
//设置极光推送别名
|
|
mPresenter.setJpushAlias();
|
|
//设置极光推送标签
|
|
SaveListUtils.getList();
|
|
if (netWorkIsRunning) {
|
|
//如果正在执行,不执行
|
|
// return;
|
|
}
|
|
//获取系统管控
|
|
mPresenter.setJpushTags();
|
|
netWorkIsRunning = true;
|
|
} else {
|
|
ToastUtil.betaShow("设备已解锁");
|
|
netWorkIsRunning = false;
|
|
SysSettingUtils.setEnableSetting(this);
|
|
}
|
|
}
|
|
|
|
/**
|
|
* 首次使用默认关闭所有功能
|
|
*
|
|
* @param state
|
|
*/
|
|
@Override
|
|
public void setFirstConnect(boolean state) {
|
|
Logutils.e(TAG, "isFirstConnect: " + "end request: " + state);
|
|
if (state) {
|
|
mPresenter.setDisableSetting();
|
|
} else {
|
|
|
|
}
|
|
}
|
|
|
|
@Override
|
|
public void sendMACFinished() {
|
|
mPresenter.updateDeviceInfo();
|
|
}
|
|
|
|
@Override
|
|
public void updateDeviceInfoFinished() {
|
|
mPresenter.getSnTimeControl();
|
|
}
|
|
|
|
@Override
|
|
public void getSnTimeControlFinished() {
|
|
mPresenter.getEBagCode();
|
|
}
|
|
|
|
@Override
|
|
public void getEBagCodeFinished() {
|
|
|
|
}
|
|
|
|
@Override
|
|
public void setAliasFinished() {
|
|
mPresenter.checkStoreUpdate();
|
|
}
|
|
|
|
@Override
|
|
public void setJpushPlatformTagsFinished() {
|
|
|
|
}
|
|
|
|
@Override
|
|
public void checkStoreUpdateFinished() {
|
|
mPresenter.checkInfoUpdate();
|
|
}
|
|
|
|
@Override
|
|
public void checkInfoUpdateFinished() {
|
|
mPresenter.checkTestUpdate();
|
|
}
|
|
|
|
@Override
|
|
public void checkTestUpdateFinished() {
|
|
|
|
}
|
|
|
|
@Override
|
|
public void buttonCheckUpdateFinished(boolean update, JsonObject jsonObject) {
|
|
|
|
}
|
|
|
|
@Override
|
|
public void setTagsFinished(boolean noTag) {
|
|
if (noTag) {
|
|
Log.e(TAG, "setTagsFinished: " + "not set tag");
|
|
netWorkIsRunning = false;
|
|
Log.e(TAG, "SettingFinished: " + (SystemClock.elapsedRealtime() - runningTime) + " ms");
|
|
} else {
|
|
mPresenter.getSystemSettingbegin();
|
|
}
|
|
}
|
|
|
|
@Override
|
|
public void getSystemSettingbegin() {
|
|
mPresenter.getAppLimit();
|
|
}
|
|
|
|
@Override
|
|
public void getAppLimitFinished(String packageList) {
|
|
mPresenter.getDeviceBatch(packageList);
|
|
}
|
|
|
|
@Override
|
|
public void getDeviceBatchFinished() {
|
|
mPresenter.getForceDownload();
|
|
}
|
|
|
|
@Override
|
|
public void getForceDownloadFinished() {
|
|
mPresenter.getBrowserList();
|
|
}
|
|
|
|
@Override
|
|
public void getBrowserListFinished(String whitelist) {
|
|
mPresenter.getBrowserBookmarks(whitelist);
|
|
}
|
|
|
|
@Override
|
|
public void getBrowserBookmarksFinished() {
|
|
mPresenter.getBrowserWhiteList();
|
|
mPresenter.getDesktopIcon();
|
|
}
|
|
|
|
@Override
|
|
public void getDesktopIconFinished() {
|
|
mPresenter.getAppAutoStartUpdateAndNet();
|
|
}
|
|
|
|
@Override
|
|
public void getAppAutoStartUpdateAndNetFinished() {
|
|
mPresenter.getAppIDControl();
|
|
}
|
|
|
|
@Override
|
|
public void getAppIDControlFinished() {
|
|
mPresenter.setAppinsideWeb();
|
|
}
|
|
|
|
@Override
|
|
public void setAppinsideWebFinished() {
|
|
mPresenter.setSystemSetting();
|
|
}
|
|
|
|
@Override
|
|
public void setSystemSettingFinished() {
|
|
mPresenter.getDefaultApp();
|
|
}
|
|
|
|
@Override
|
|
public void setDefaultAppFinished() {
|
|
mPresenter.getROMApp();
|
|
}
|
|
|
|
@Override
|
|
public void getROMAppFinished() {
|
|
mPresenter.getDeveloper();
|
|
}
|
|
|
|
@Override
|
|
public void getDeveloperFinished() {
|
|
mPresenter.setLogoImg();
|
|
}
|
|
|
|
@Override
|
|
public void setLogoImgFinished() {
|
|
mPresenter.setTopApp();
|
|
}
|
|
|
|
@Override
|
|
public void setTopAppFinished() {
|
|
mPresenter.getDefaultDesktop();
|
|
}
|
|
|
|
@Override
|
|
public void getDefaultDesktopFinished() {
|
|
netWorkIsRunning = false;
|
|
Log.e(TAG, "SettingFinished: " + (SystemClock.elapsedRealtime() - runningTime) + " ms");
|
|
}
|
|
|
|
@Override
|
|
public void setScreenLockStateFinished(boolean locked, String tips) {
|
|
if (locked) {
|
|
if (!timelocked) {
|
|
showFloatingWindow(tips);
|
|
}
|
|
screenlocked = true;
|
|
SPUtils.put(MainService.this, "is_screen_lock", true);
|
|
SPUtils.put(MainService.this, "screen_tips", tips);
|
|
} else {
|
|
if (!timelocked) {
|
|
hideFloatingWindow();
|
|
}
|
|
screenlocked = false;
|
|
SPUtils.put(MainService.this, "is_screen_lock", false);
|
|
SPUtils.put(MainService.this, "screen_tips", "");
|
|
}
|
|
}
|
|
}
|