diff --git a/app/build.gradle b/app/build.gradle index 29cd4b0..7c83740 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -15,8 +15,8 @@ android { minSdkVersion 20 targetSdkVersion 29 - versionCode 148 - versionName "3.0.5"//测试jiaoguanyi.cn + versionCode 140 + versionName "3.0.1"//测试jiaoguanyi.cn // versionCode 1002 // versionName "2.0.1.2"// 正式jiaoguanyi.com 双数正式 单数测试 multiDexEnabled true @@ -133,7 +133,7 @@ dependencies { // implementation 'com.github.bumptech.glide:glide:4.0.0' // annotationProcessor 'com.github.bumptech.glide:compiler:4.0.0' - implementation 'com.alibaba:fastjson:1.2.18' + implementation 'com.alibaba:fastjson:1.2.70' implementation 'com.lzy.net:okgo:2.1.4' implementation 'com.lzy.net:okrx:0.1.2' diff --git a/app/src/main/java/com/mjsheng/myappstore/MyApplication.java b/app/src/main/java/com/mjsheng/myappstore/MyApplication.java index c2cd495..124b4e5 100644 --- a/app/src/main/java/com/mjsheng/myappstore/MyApplication.java +++ b/app/src/main/java/com/mjsheng/myappstore/MyApplication.java @@ -206,28 +206,27 @@ 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_SCREEN_ON) - || action.equals(Intent.ACTION_USER_PRESENT) - ) { - time2 = System.currentTimeMillis(); - if ((time2 - time1) > 60 * 1000) { - //可能会多次触发,1分钟之内不执行 - //application中启动服务,startcommand执行会两次 - startService(new Intent(context, InitJpushServer.class)); - startService(new Intent(context, StepService.class)); - startService(new Intent(context, GuardService.class)); - time1 = time2; - } else { - - } + if (action.equals(Intent.ACTION_SCREEN_ON)) { long time = System.currentTimeMillis(); getLockState("2", String.valueOf(time)); - + } else if (action.equals(Intent.ACTION_USER_PRESENT)) { + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) { + time2 = System.currentTimeMillis(); + if ((time2 - time1) > 60 * 1000) { + //可能会多次触发,1分钟之内不执行 + //application中启动服务,startcommand执行会两次 + startService(new Intent(context, InitJpushServer.class)); + startService(new Intent(context, StepService.class)); + startService(new Intent(context, GuardService.class)); + time1 = time2; + } + } } else if (action.equals(Intent.ACTION_SCREEN_OFF)) { long time = System.currentTimeMillis(); getLockState("1", String.valueOf(time)); } } + } private void getLockState(String status, String time) { diff --git a/app/src/main/java/com/mjsheng/myappstore/receiver/BootReceiver.java b/app/src/main/java/com/mjsheng/myappstore/receiver/BootReceiver.java index 07daeb9..e45ef4c 100644 --- a/app/src/main/java/com/mjsheng/myappstore/receiver/BootReceiver.java +++ b/app/src/main/java/com/mjsheng/myappstore/receiver/BootReceiver.java @@ -26,7 +26,7 @@ public class BootReceiver extends BroadcastReceiver { || intent.getAction().equals("android.intent.action.ACTION_POWER_CONNECTED") || intent.getAction().equals("android.intent.action.DATE_CHANGED") || intent.getAction().equals("android.intent.action.TIME_TICK") -// || intent.getAction().equals("android.intent.action.USER_PRESENT") + || intent.getAction().equals("android.intent.action.USER_PRESENT") || intent.getAction().equals("android.intent.action.SCREEN_ON") || intent.getAction().equals("android.intent.action.SCREEN_OFF") ) { diff --git a/app/src/main/java/com/mjsheng/myappstore/receiver/MyJPushReceiver.java b/app/src/main/java/com/mjsheng/myappstore/receiver/MyJPushReceiver.java index 141a60a..e4bbb00 100644 --- a/app/src/main/java/com/mjsheng/myappstore/receiver/MyJPushReceiver.java +++ b/app/src/main/java/com/mjsheng/myappstore/receiver/MyJPushReceiver.java @@ -219,8 +219,8 @@ public class MyJPushReceiver extends BroadcastReceiver { return; } com.alibaba.fastjson.JSONObject extra = JSON.parseObject(extras); - String app_name=extra.getString("app_name"); - String app_package=extra.getString("package"); + String app_name = extra.getString("app_name"); + String app_package = extra.getString("package"); String url = extra.getString("url"); int versionCode = extra.getInteger("version_code"); @@ -398,8 +398,10 @@ public class MyJPushReceiver extends BroadcastReceiver { i++; } stringBuffer.deleteCharAt(stringBuffer.length() - 1); - Settings.System.putString(this.mContext.getContentResolver(), "qch_tfmedia_filetypes", stringBuffer.toString());//影音管控 - Log.e("SystemSetting", "qch_tfmedia_filetypes---------" + stringBuffer.toString()); + String s = Settings.System.getString(this.mContext.getContentResolver(), "qch_tfmedia_filetypes");//影音管控 + Log.e("SystemSetting", "qch_tfmedia_filetypes old" + s); + boolean b = Settings.System.putString(this.mContext.getContentResolver(), "qch_tfmedia_filetypes", stringBuffer.toString());//影音管控 + Log.e("SystemSetting", "qch_tfmedia_filetypes---------" + b + ":" + stringBuffer.toString()); } catch (JSONException e) { Log.e("SystemSetting", "qch_tfmedia_filetypes---------" + e.getMessage()); @@ -906,7 +908,6 @@ public class MyJPushReceiver extends BroadcastReceiver { } - public void settingLock(String s) { if (TextUtils.isEmpty(s)) { Log.e("mjsheng", "settingLock extras is null"); diff --git a/app/src/main/java/com/mjsheng/myappstore/server/StepService.java b/app/src/main/java/com/mjsheng/myappstore/server/StepService.java index f6f745e..da6d21a 100644 --- a/app/src/main/java/com/mjsheng/myappstore/server/StepService.java +++ b/app/src/main/java/com/mjsheng/myappstore/server/StepService.java @@ -130,8 +130,8 @@ public class StepService extends Service { public void onClose(int code, String reason, boolean remote) { super.onClose(code, reason, remote); Log.i("JWebSocketClientService", "websocket连接关闭"); - client = null; - initSocketClient(); +// client.close(); +// initSocketClient(); mHandler.postDelayed(heartBeatRunnable, HEART_BEAT_RATE);//开启心跳检测 } @@ -140,8 +140,8 @@ public class StepService extends Service { public void onError(Exception ex) { super.onError(ex); Log.i("JWebSocketClientService", "websocket连接错误"); - client = null; - initSocketClient(); +// client.close(); +// initSocketClient(); mHandler.postDelayed(heartBeatRunnable, HEART_BEAT_RATE);//开启心跳检测 }