version:3.0.5_beta
update:2020.06.23 fix:加入锁屏息屏发送时间,加入电池优化 add:
This commit is contained in:
@@ -7,7 +7,6 @@ import android.content.Intent;
|
||||
import android.content.IntentFilter;
|
||||
import android.content.res.Configuration;
|
||||
import android.net.ConnectivityManager;
|
||||
import android.net.Network;
|
||||
import android.net.NetworkInfo;
|
||||
import android.net.Uri;
|
||||
import android.net.wifi.WifiInfo;
|
||||
@@ -38,6 +37,8 @@ import com.mjsheng.myappstore.activity.MainActivity;
|
||||
import com.mjsheng.myappstore.comm.CommonDatas;
|
||||
import com.mjsheng.myappstore.jpush.TagAliasOperatorHelper;
|
||||
import com.mjsheng.myappstore.network.HTTPInterface;
|
||||
import com.mjsheng.myappstore.network.Network;
|
||||
import com.mjsheng.myappstore.network.api.newapi.GetLockState;
|
||||
import com.mjsheng.myappstore.server.GuardService;
|
||||
import com.mjsheng.myappstore.server.InitJpushServer;
|
||||
import com.mjsheng.myappstore.server.StepService;
|
||||
@@ -53,6 +54,7 @@ import org.lzh.framework.updatepluginlib.UpdateConfig;
|
||||
import org.lzh.framework.updatepluginlib.base.UpdateParser;
|
||||
import org.lzh.framework.updatepluginlib.model.CheckEntity;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Calendar;
|
||||
@@ -66,8 +68,14 @@ import java.util.logging.Level;
|
||||
|
||||
import cn.jpush.android.api.JPushInterface;
|
||||
import cn.jpush.android.api.JPushMessage;
|
||||
import io.reactivex.Observer;
|
||||
import io.reactivex.Scheduler;
|
||||
import io.reactivex.android.schedulers.AndroidSchedulers;
|
||||
import io.reactivex.disposables.Disposable;
|
||||
import io.reactivex.schedulers.Schedulers;
|
||||
import okhttp3.Call;
|
||||
import okhttp3.Response;
|
||||
import okhttp3.ResponseBody;
|
||||
import rx.Observable;
|
||||
import rx.functions.Action1;
|
||||
import uk.co.chrisjenx.calligraphy.CalligraphyConfig;
|
||||
@@ -148,10 +156,10 @@ public class MyApplication extends MultiDexApplication {
|
||||
if (!BuildConfig.DEBUG) {
|
||||
catchException();
|
||||
}
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
|
||||
//8.0之后需要在
|
||||
registerTimeReceiver();
|
||||
}
|
||||
// if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
|
||||
//8.0之后需要在
|
||||
registerTimeReceiver();
|
||||
// }
|
||||
ignoreBatteryOptimization(this);
|
||||
|
||||
}
|
||||
@@ -198,9 +206,8 @@ public class MyApplication extends MultiDexApplication {
|
||||
public void onReceive(Context context, Intent intent) {
|
||||
String action = intent.getAction();
|
||||
Log.e("fht", "receiver action:" + action);
|
||||
if (action.equals(Intent.ACTION_USER_PRESENT)
|
||||
|| action.equals(Intent.ACTION_SCREEN_ON)
|
||||
|| action.equals(Intent.ACTION_SCREEN_OFF)
|
||||
if (action.equals(Intent.ACTION_SCREEN_ON)
|
||||
|| action.equals(Intent.ACTION_USER_PRESENT)
|
||||
) {
|
||||
time2 = System.currentTimeMillis();
|
||||
if ((time2 - time1) > 60 * 1000) {
|
||||
@@ -210,15 +217,53 @@ public class MyApplication extends MultiDexApplication {
|
||||
startService(new Intent(context, StepService.class));
|
||||
startService(new Intent(context, GuardService.class));
|
||||
time1 = time2;
|
||||
Log.e("fht", "onReceive");
|
||||
} else {
|
||||
|
||||
}
|
||||
long time = System.currentTimeMillis();
|
||||
getLockState("2", String.valueOf(time));
|
||||
|
||||
} else if (action.equals(Intent.ACTION_SCREEN_OFF)) {
|
||||
long time = System.currentTimeMillis();
|
||||
getLockState("1", String.valueOf(time));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void getLockState(String status, String time) {
|
||||
GetLockState getLockState = Network.getLockState();
|
||||
getLockState.getLockState(Utils.getSerial(), status, time)
|
||||
.subscribeOn(Schedulers.io())
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.subscribe(new Observer<ResponseBody>() {
|
||||
@Override
|
||||
public void onSubscribe(Disposable d) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNext(ResponseBody responseBody) {
|
||||
try {
|
||||
com.alibaba.fastjson.JSONObject jsonObject = JSON.parseObject(responseBody.string());
|
||||
int code = jsonObject.getInteger("code");
|
||||
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(Throwable e) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onComplete() {
|
||||
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
public void onTagOperatorResult(JPushMessage jPushMessage) {
|
||||
if (jPushMessage == null) {
|
||||
|
||||
Reference in New Issue
Block a user