Util.turnOnWifiForConnect(runtime.getContextProxy().context, runtime);\r
}\r
} else if ("android.intent.action.SCREEN_OFF".equals(param1Intent.getAction()) && Util.isWifiIsOpen(runtime.getContextProxy().context,runtime)) {\r
- CoreService.is_wifi_network_ok = true;\r
+ // CoreService.is_wifi_network_ok = true;\r
if (!runtime.isNoTurnOffWifiOnScreenOff()) {\r
//不关闭wifi when ScreenOff\r
Util.turnOffWifiForSleep(runtime.getContextProxy().context, runtime);\r
needCheckAgain=false;\r
isLocating = false;\r
startCheckTime=0L;\r
-\r
+ isWifiScanning=false;\r
// ICLogger.i(" stopCheckLocationResult Done ");\r
}\r
\r
try {
if (showmessage) {
- sb.append(CoreService.getInstance().getServerAlive());
+ if (CoreService.getInstance()!=null)
+ sb.append(CoreService.getInstance().getServerAlive());
tv.setText(sb.toString());
}
// }
// });
- startService(new Intent(this,CoreService.class));// protocol service
+// startService(new Intent(this,CoreService.class));// protocol service
// double longitude=113.878339f;
// double latitude=22.580827f;
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<Long>() {
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<Long>() {
+ 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;
}
import java.util.concurrent.TimeUnit;\r
\r
import rx.Observable;\r
+import rx.Single;\r
+import rx.android.schedulers.AndroidSchedulers;\r
import rx.functions.Action1;\r
\r
import static android.net.wifi.WifiManager.WIFI_STATE_DISABLED;\r
if (mMyWifiListener != null) {\r
mMyWifiListener.getWifiInfoCallBack(wifiInfoResult);\r
// mMyWifiListener.getWifiInfoCallBack(null);\r
- Observable.timer(500L, TimeUnit.MILLISECONDS).subscribe(new Action1<Long>() {\r
+\r
+// Single.just(null).observeOn(AndroidSchedulers.mainThread()).subscribe(new Action1<Object>() {\r
+// public void call(Object param1Object) {\r
+\r
+ Observable.timer(500L, TimeUnit.MILLISECONDS).observeOn(AndroidSchedulers.mainThread()).subscribe(new Action1<Long>() {\r
public void call(Long param1Long) {\r
+\r
//由于wifi状态不好确认客户是如何设置的,干脆只有屏幕灭的时候才考虑关闭wifi ,防止在开启屏幕用来视频的时候被后台关掉\r
ICLogger.i("setWifiEnabled false");\r
- if(SimSignalUtil.isScreenON(runtime.getContextProxy().context)==false) {\r
+// if(SimSignalUtil.isScreenON(runtime.getContextProxy().context)==false) {\r
if (runtime.isNoTurnOffWifiOnScreenOff() || DeviceInfoUtil.isFactoryTestTopActivity(runtime.getContextProxy().context)) {\r
//如果 NoTurnOffWifiOnScreenOff 开关 开启,且是屏灭,或者是在工厂测试模式,则原来什么状态就什么状态。\r
+ ICLogger.i("isNoTurnOffWifiOnScreenOff or In Factory Mode");\r
if (!IS_HASOPEN && IS_OPEN) {\r
- wifiManager.setWifiEnabled(false);\r
+// wifiManager.setWifiEnabled(false);\r
IS_OPEN = false;\r
}\r
- } else if (!runtime.isNoTurnOffWifiOnScreenOff()) {\r
+ } else {\r
//如果 NoTurnOffWifiOnScreenOff 开关 关闭,且是屏灭,则关闭wifi省电\r
+ ICLogger.i("isTurnOffWifiOnScreenOff");\r
wifiManager.setWifiEnabled(false);\r
IS_OPEN = false;\r
IS_HASOPEN = false;\r
\r
}\r
- }\r
+// }else{\r
+// ICLogger.i("isTurnOffWifiOnScreenOff");\r
+// wifiManager.setWifiEnabled(false);\r
+// IS_OPEN = false;\r
+// IS_HASOPEN = false;\r
+// }\r
ICLogger.i("setWifiEnabled done");\r
\r
\r
.append(" at ").append(runtime.getHRS().getTestTime())\r
.append("\nrealimei:").append(PhoneUtils.getIMEI(runtime.getContextProxy().context))\r
.append("\n").append(runtime.getLBSMultiStationData())\r
+ .append("\nWiFi Status ").append(Util.isWifiIsOpen(runtime.getContextProxy().context,runtime))\r
.toString();\r
}\r
public static String getShortDeviceInfo(Runtime runtime){\r