<orderEntry type="library" name="Gradle: io.reactivex:rxandroid:1.1.0@aar" level="project" />\r
<orderEntry type="module" module-name="dNSCache" />\r
<orderEntry type="module" module-name="dNSCache" />\r
- <orderEntry type="module" module-name="dNSCache" />\r
</component>\r
</module>
\ No newline at end of file
runtime.setBattery(String.format("%03d",batlevel));\r
ICLogger.i("Battery get from api "+batlevel);\r
\r
+\r
+ boolean charging = batteryUtil.isPowerConnected(this);\r
+ runtime.setPowerConnected(charging);\r
+ ICLogger.i("Charging "+charging);\r
+\r
//api直接获取batterylevel取消注册 receiver, 需要重新注册一下。\r
\r
batteryUtil.registerBroadReceiver();\r
} else {\r
sendSMS(phonenumber, "TP cmd format error!");\r
}\r
+ }else if (sms.startsWith("#USB#=")) {\r
+ String tmp[] = sms.split("=");\r
+ if (tmp.length == 2) {\r
+ if(tmp[1].equals("current"))\r
+ {\r
+ String conf= Util.getSystemProperties("persist.sys.usb.config");\r
+ sendSMS(phonenumber, "Current USB config is "+conf+"!");\r
+ }else if(tmp[1].equals("mtp")||tmp[1].equals("adb")||tmp[1].equals("mtp,adb")||tmp[1].equals("adb,mtp")||tmp[1].equals("none")) {\r
+ sendSMS(phonenumber, "Set USB config to "+tmp[1]+"!");\r
+ Util.setSystemProperties("persist.sys.usb.config", "none");\r
+ Util.setSystemProperties("persist.sys.usb.config", tmp[1]);\r
+\r
+ }else{\r
+ sendSMS(phonenumber, "USB cmd format error only support current|adb|mtp|adb,mtp|mtp,adb|none !");\r
+ }\r
+ } else {\r
+ sendSMS(phonenumber, "USB cmd format error!");\r
+ }\r
}else {\r
return false;\r
}\r
private boolean shutdown;\r
\r
\r
+ private boolean PowerConnected=false;\r
\r
+ public void setPowerConnected(boolean connected){\r
+ PowerConnected=connected;\r
+ }\r
+ public boolean isPowerConnected(){\r
+ return PowerConnected;\r
+ }\r
private DnsUtil dnsUtil=null;\r
\r
public void initDnsUtil(Context context){\r
public class BatteryUtil {\r
private BroadcastReceiver batteryChangedReceiver = new BroadcastReceiver() {\r
public void onReceive(Context param1Context, Intent param1Intent) {\r
- if ("android.intent.action.BATTERY_CHANGED".equals(param1Intent.getAction())) {\r
+ if (Intent.ACTION_BATTERY_CHANGED.equals(param1Intent.getAction())) {\r
if (param1Intent.getIntExtra("status", 1) == 2) {\r
BatteryUtil.this.mRuntime.setBatterychanging(true);\r
BatteryUtil.this.mRuntime.setBatteryLow(false);\r
BatteryUtil.this.mRuntime.setHaveBatteryChange(true);\r
}\r
BatteryUtil.this.mBuffer.setLength(0);\r
- }\r
- if ("android.intent.action.BATTERY_LOW".equals(param1Intent.getAction())) {\r
+ }else if (Intent.ACTION_BATTERY_LOW.equals(param1Intent.getAction())) {\r
BatteryUtil.this.mRuntime.setBatteryLow(true);\r
ICLogger.i("lowbattery finish video_end_call");\r
+ if (Config.LOG_TOFILE) FileOutputUtil.fileOutput(mRuntime.getCacheDir(),"Battery","BatteryLow !");\r
\r
mRuntime.setAlarmType(false,mRuntime.getBatteryLow(),false,false);\r
//trigger AP10 报警定位\r
connection.send(protocolAPIHelper.genStringMessage("AP10",protocolAPIHelper.AP10(mRuntime)));\r
\r
+ }else if (Intent.ACTION_BATTERY_OKAY.equals(param1Intent.getAction())){\r
+\r
+ ICLogger.i("Battery OKAY !");\r
+ if (Config.LOG_TOFILE) FileOutputUtil.fileOutput(mRuntime.getCacheDir(),"Battery","Battery OKAY !");\r
+\r
+ }else if (Intent.ACTION_POWER_CONNECTED.equals(param1Intent.getAction())){\r
+ ICLogger.i("ACTION_POWER_CONNECTED !");\r
+ mRuntime.setPowerConnected(true);\r
+ if (Config.LOG_TOFILE) FileOutputUtil.fileOutput(mRuntime.getCacheDir(),"Battery","ACTION_POWER_CONNECTED!");\r
+\r
+ }else if (Intent.ACTION_POWER_DISCONNECTED.equals(param1Intent.getAction())){\r
+ ICLogger.i("ACTION_POWER_DISCONNECTED!");\r
+ mRuntime.setPowerConnected(false);\r
+ if (Config.LOG_TOFILE) FileOutputUtil.fileOutput(mRuntime.getCacheDir(),"Battery","ACTION_POWER_DISCONNECTED !");\r
+\r
}\r
}\r
};\r
public void registerBroadReceiver() {\r
this.mBuffer = new StringBuffer();\r
IntentFilter intentFilter = new IntentFilter();\r
- intentFilter.addAction("android.intent.action.BATTERY_CHANGED");\r
- intentFilter.addAction("android.intent.action.BATTERY_LOW");\r
+ intentFilter.addAction(Intent.ACTION_BATTERY_CHANGED);\r
+ intentFilter.addAction(Intent.ACTION_BATTERY_LOW);\r
+ intentFilter.addAction(Intent.ACTION_POWER_CONNECTED);\r
+ intentFilter.addAction(Intent.ACTION_POWER_DISCONNECTED);\r
(this.mRuntime.getContextProxy()).context.registerReceiver(this.batteryChangedReceiver, intentFilter);\r
}\r
\r
intent.getIntExtra(BatteryManager.EXTRA_SCALE, -1);\r
}\r
}\r
+\r
+\r
+ public boolean isPowerConnected(Context context){\r
+\r
+ IntentFilter ifilter = new IntentFilter(Intent.ACTION_BATTERY_CHANGED);\r
+ Intent batteryStatus = context.registerReceiver(null, ifilter);\r
+//你可以读到充电状态,如果在充电,可以读到是usb还是交流电\r
+\r
+// 是否在充电\r
+ int status = batteryStatus.getIntExtra(BatteryManager.EXTRA_STATUS, -1);\r
+ boolean isCharging = status == BatteryManager.BATTERY_STATUS_CHARGING ;//|| status == BatteryManager.BATTERY_STATUS_FULL;\r
+\r
+ return isCharging;\r
+ }\r
public void unregisterBroadReceiver() { (this.mRuntime.getContextProxy()).context.unregisterReceiver(this.batteryChangedReceiver); }\r
}\r
\r
.append("\n SocketConnection ").append(KeepAlive.isConnected).append(" , HBcycle ").append(runtime.getHeartBeatCycle())\r
.append("\n ServerConnected is ").append(runtime.isServerProtocolConnected())\r
.append(" \n Bat ").append(runtime.getBattery()).append(",").append(runtime.getBatteryVotage())\r
+ .append(" charged ").append(runtime.isPowerConnected())\r
.append(" StepCount ").append(runtime.getTotalStepCount())\r
.append( "\n Working Mode ").append(runtime.getLocationInstance().getWorkingMod())\r
.append(" \n Location Cycle ").append(runtime.getLocationInstance().getLocation_cycle())\r
.append("[").append(runtime.getSignalStrength()).append("]")\r
.append("\nHeartbeat[").append(runtime.getSrvIP()).append(":").append(runtime.getPort()).append(",").append(runtime.isServerProtocolConnected()).append(",").append(runtime.getHeartBeatCycle())\r
.append("]\nBat").append(runtime.getBattery()).append(",").append(runtime.getBatteryVotage())\r
+ .append(" charged ").append(runtime.isPowerConnected())\r
.append(",Step").append(runtime.getTotalStepCount())\r
.append( "\nLocation[M").append(runtime.getLocationInstance().getWorkingMod())\r
.append(",C").append(runtime.getLocationInstance().getLocation_cycle())\r
}\r
return str;\r
}\r
+ static public void setSystemProperties(String key, String defaultValue) {\r
\r
+ String value = defaultValue;\r
+\r
+ try {\r
+\r
+ Class<?> c = Class.forName("android.os.SystemProperties");\r
+\r
+ Method get = c.getMethod("set", String.class, String.class );\r
+\r
+ get.invoke(c, key, value );\r
+\r
+ } catch (Exception e) {\r
+\r
+ e.printStackTrace();\r
+\r
+ }\r
+ }\r
public static WifiConfiguration GetconfigWifiInfo(Context context, String ssid, String pwd, String encryptType) {\r
WifiConfiguration wifiConfiguration=null;\r
StringBuilder stringBuilder;\r
-#Thu Mar 05 19:33:06 CST 2020\r
-VERSION_CODE=370\r
+#Fri Mar 06 15:30:32 CST 2020\r
+VERSION_CODE=371\r