From e06e81ecca822a4c8daaa1f6daf64251f74c25e2 Mon Sep 17 00:00:00 2001 From: snicker Date: Mon, 13 Apr 2020 08:20:38 +0800 Subject: [PATCH] =?utf8?q?1=E3=80=81UI=E7=95=8C=E9=9D=A2=E4=B8=8D=E5=BC=BA?= =?utf8?q?=E5=88=B6=E9=87=8D=E5=90=AF=E6=9C=8D=E5=8A=A1=EF=BC=8C=E6=9F=A5?= =?utf8?q?=E7=9C=8B=E7=8A=B6=E6=80=81=E4=B8=8D=E4=BC=9A=E5=BD=B1=E5=93=8D?= =?utf8?q?=E6=9C=8D=E5=8A=A1=E5=90=AF=E5=8A=A8=E6=83=85=E5=86=B5=E6=A3=80?= =?utf8?q?=E6=9F=A5=E3=80=82=202=E3=80=81=E6=B7=BB=E5=8A=A0WiFi=E7=8A=B6?= =?utf8?q?=E6=80=81=E6=A3=80=E6=9F=A5=203=E3=80=81=E5=BC=BA=E5=88=B6?= =?utf8?q?=E6=AF=8F=E6=AC=A1=E6=90=9C=E7=B4=A2WiFi=E7=BD=91=E7=BB=9C?= =?utf8?q?=E5=90=8E=E5=BF=85=E7=84=B6=E5=85=B3=E9=97=ADWiFi=EF=BC=8C?= =?utf8?q?=E6=9A=82=E6=97=B6=E5=85=88=E7=A1=AE=E4=BF=9D=E5=8A=9F=E8=80=97?= =?utf8?q?=E9=97=AE=E9=A2=98=E3=80=82=E4=BA=AE=E5=B1=8F=E4=BD=BF=E7=94=A8W?= =?utf8?q?iFi=E7=9A=84=E4=BA=8B=E6=83=85=EF=BC=8C=E5=90=8E=E9=9D=A2?= =?utf8?q?=E6=9C=89=E9=9C=80=E8=A6=81=E6=97=B6=E5=9C=A8=E8=B0=83=E8=AF=95?= =?utf8?q?=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- .../com/enqualcomm/support/CoreService.java | 2 +- .../enqualcomm/support/LocationClient.java | 2 +- .../com/enqualcomm/support/MainActivity.java | 22 ++++++++++------- .../enqualcomm/support/adapter/LBSHelper.java | 24 +++++++++++++++---- .../support/utils/DeviceInfoUtil.java | 1 + 5 files changed, 36 insertions(+), 15 deletions(-) diff --git a/app/src/main/java/com/enqualcomm/support/CoreService.java b/app/src/main/java/com/enqualcomm/support/CoreService.java index 213626a3..ad6766c2 100644 --- a/app/src/main/java/com/enqualcomm/support/CoreService.java +++ b/app/src/main/java/com/enqualcomm/support/CoreService.java @@ -333,7 +333,7 @@ public class CoreService extends Service { Util.turnOnWifiForConnect(runtime.getContextProxy().context, runtime); } } else if ("android.intent.action.SCREEN_OFF".equals(param1Intent.getAction()) && Util.isWifiIsOpen(runtime.getContextProxy().context,runtime)) { - CoreService.is_wifi_network_ok = true; + // CoreService.is_wifi_network_ok = true; if (!runtime.isNoTurnOffWifiOnScreenOff()) { //不关闭wifi when ScreenOff Util.turnOffWifiForSleep(runtime.getContextProxy().context, runtime); diff --git a/app/src/main/java/com/enqualcomm/support/LocationClient.java b/app/src/main/java/com/enqualcomm/support/LocationClient.java index 8c91a442..6b39500e 100644 --- a/app/src/main/java/com/enqualcomm/support/LocationClient.java +++ b/app/src/main/java/com/enqualcomm/support/LocationClient.java @@ -491,7 +491,7 @@ public class LocationClient { needCheckAgain=false; isLocating = false; startCheckTime=0L; - + isWifiScanning=false; // ICLogger.i(" stopCheckLocationResult Done "); } diff --git a/app/src/main/java/com/enqualcomm/support/MainActivity.java b/app/src/main/java/com/enqualcomm/support/MainActivity.java index e2786413..a6feb668 100644 --- a/app/src/main/java/com/enqualcomm/support/MainActivity.java +++ b/app/src/main/java/com/enqualcomm/support/MainActivity.java @@ -46,7 +46,8 @@ public class MainActivity extends AppCompatActivity { try { if (showmessage) { - sb.append(CoreService.getInstance().getServerAlive()); + if (CoreService.getInstance()!=null) + sb.append(CoreService.getInstance().getServerAlive()); tv.setText(sb.toString()); } @@ -91,7 +92,7 @@ public class MainActivity extends AppCompatActivity { // } // }); - startService(new Intent(this,CoreService.class));// protocol service +// startService(new Intent(this,CoreService.class));// protocol service // double longitude=113.878339f; // double latitude=22.580827f; @@ -153,18 +154,23 @@ public class MainActivity extends AppCompatActivity { switch (view.getId()) { case R.id.btnConnect: //进行连接Socket:这里使用的是,在本地上开启了一个服务器。 - Util.ShowToast(CoreService.getInstance().runtime,"Stop ProtocolService!"); - stopService(new Intent(MainActivity.this,CoreService.class));// protocol service - - //delay 5秒再重启 + if (CoreService.getInstance()!=null) + Util.ShowToast(CoreService.getInstance().runtime,"Start ProtocolService!"); + startService(new Intent(MainActivity.this,CoreService.class));// protocol service Observable.timer(5000L, TimeUnit.MILLISECONDS).subscribe(new Action1() { public void call(Long param1Long) { - Util.ShowToast(CoreService.getInstance().runtime,"Start ProtocolService!"); + if (CoreService.getInstance()!=null) Util.ShowToast(CoreService.getInstance().runtime,"Stop ProtocolService!"); + stopService(new Intent(MainActivity.this,CoreService.class));// protocol service + } + }); + //delay 5秒再重启 + Observable.timer(10000L, TimeUnit.MILLISECONDS).subscribe(new Action1() { + public void call(Long param1Long) { + if (CoreService.getInstance()!=null) Util.ShowToast(CoreService.getInstance().runtime,"Start ProtocolService!"); startService(new Intent(MainActivity.this,CoreService.class));// protocol service } }); - break; } diff --git a/app/src/main/java/com/enqualcomm/support/adapter/LBSHelper.java b/app/src/main/java/com/enqualcomm/support/adapter/LBSHelper.java index 52086628..f20c1754 100644 --- a/app/src/main/java/com/enqualcomm/support/adapter/LBSHelper.java +++ b/app/src/main/java/com/enqualcomm/support/adapter/LBSHelper.java @@ -39,6 +39,8 @@ import java.util.List; import java.util.concurrent.TimeUnit; import rx.Observable; +import rx.Single; +import rx.android.schedulers.AndroidSchedulers; import rx.functions.Action1; import static android.net.wifi.WifiManager.WIFI_STATE_DISABLED; @@ -133,25 +135,37 @@ public class LBSHelper { if (mMyWifiListener != null) { mMyWifiListener.getWifiInfoCallBack(wifiInfoResult); // mMyWifiListener.getWifiInfoCallBack(null); - Observable.timer(500L, TimeUnit.MILLISECONDS).subscribe(new Action1() { + +// Single.just(null).observeOn(AndroidSchedulers.mainThread()).subscribe(new Action1() { +// public void call(Object param1Object) { + + Observable.timer(500L, TimeUnit.MILLISECONDS).observeOn(AndroidSchedulers.mainThread()).subscribe(new Action1() { public void call(Long param1Long) { + //由于wifi状态不好确认客户是如何设置的,干脆只有屏幕灭的时候才考虑关闭wifi ,防止在开启屏幕用来视频的时候被后台关掉 ICLogger.i("setWifiEnabled false"); - if(SimSignalUtil.isScreenON(runtime.getContextProxy().context)==false) { +// if(SimSignalUtil.isScreenON(runtime.getContextProxy().context)==false) { if (runtime.isNoTurnOffWifiOnScreenOff() || DeviceInfoUtil.isFactoryTestTopActivity(runtime.getContextProxy().context)) { //如果 NoTurnOffWifiOnScreenOff 开关 开启,且是屏灭,或者是在工厂测试模式,则原来什么状态就什么状态。 + ICLogger.i("isNoTurnOffWifiOnScreenOff or In Factory Mode"); if (!IS_HASOPEN && IS_OPEN) { - wifiManager.setWifiEnabled(false); +// wifiManager.setWifiEnabled(false); IS_OPEN = false; } - } else if (!runtime.isNoTurnOffWifiOnScreenOff()) { + } else { //如果 NoTurnOffWifiOnScreenOff 开关 关闭,且是屏灭,则关闭wifi省电 + ICLogger.i("isTurnOffWifiOnScreenOff"); wifiManager.setWifiEnabled(false); IS_OPEN = false; IS_HASOPEN = false; } - } +// }else{ +// ICLogger.i("isTurnOffWifiOnScreenOff"); +// wifiManager.setWifiEnabled(false); +// IS_OPEN = false; +// IS_HASOPEN = false; +// } ICLogger.i("setWifiEnabled done"); diff --git a/app/src/main/java/com/enqualcomm/support/utils/DeviceInfoUtil.java b/app/src/main/java/com/enqualcomm/support/utils/DeviceInfoUtil.java index 66ad5baf..cab7a3bb 100644 --- a/app/src/main/java/com/enqualcomm/support/utils/DeviceInfoUtil.java +++ b/app/src/main/java/com/enqualcomm/support/utils/DeviceInfoUtil.java @@ -244,6 +244,7 @@ public class DeviceInfoUtil { .append(" at ").append(runtime.getHRS().getTestTime()) .append("\nrealimei:").append(PhoneUtils.getIMEI(runtime.getContextProxy().context)) .append("\n").append(runtime.getLBSMultiStationData()) + .append("\nWiFi Status ").append(Util.isWifiIsOpen(runtime.getContextProxy().context,runtime)) .toString(); } public static String getShortDeviceInfo(Runtime runtime){ -- 2.17.1