修改了电池的低电提示
authorTrillGates <williamtrillgates@gmail.com>
Mon, 6 Dec 2021 07:53:11 +0000 (15:53 +0800)
committerTrillGates <williamtrillgates@gmail.com>
Mon, 6 Dec 2021 07:53:11 +0000 (15:53 +0800)
app/src/main/java/com/enqualcomm/support/utils/BatteryUtil.java
app/src/main/java/com/ic/protocols/protocol_s123.java
app/src/main/java/com/ic/view/battery/BatteryLowLevTipsView.java

index 0bf6655..f889cbd 100644 (file)
@@ -136,6 +136,11 @@ public class BatteryUtil {
 
     //根据电池电压进行低电报警等状态处理
     public void process_battery_level(Context param1Context, int batLevel) {
+        //只要是充电了
+        if (mRuntime.getHaveBatteryChange()) {
+            ICLogger.d("充电了,隐藏低电提示.");
+            BatteryLowLevTipsView.getInstance().dismiss();
+        }
         if (batLevel >= 100) {
             mRuntime.setBattery(String.format("%03d", 100));
             mRuntime.setBattery(100);
@@ -166,6 +171,7 @@ public class BatteryUtil {
             intent.putExtra("openOrClose", "open");
             mRuntime.getContextProxy().sendBroadcast("com.ic.action.TOAST_CHARGE_TIPS", intent);
             //以上在Launcher接收,然后弹出
+            ICLogger.d("电量大于10%了,可以隐藏低电提示了.");
             BatteryLowLevTipsView.getInstance().dismiss();
             ICLogger.d("on lower power please get charge...");
             if (Config.LOG_TOFILE) ICLogger.logToFile("Battery", "BatteryLow  less than 15%!");
@@ -182,11 +188,15 @@ public class BatteryUtil {
             mRuntime.setHaveBatteryChange(true);
             mRuntime.setBatteryLow(true);
         } else {
-            ChargeTipsView.getInstance().dismiss();
-            BatteryLowLevTipsView.getInstance().showDialog();
-            //这里则会显示可能会关机
-            ICLogger.d("on lower then 5 percent..." + batLevel);
-            if (Config.LOG_TOFILE) ICLogger.logToFile("Battery", "BatteryLow less than 5% !");
+            //ChargeTipsView.getInstance().dismiss();
+            //如果不有充电,那么就显示
+            //如果已经插上电了就不显示了
+            if (!mRuntime.getHaveBatteryChange()) {
+                BatteryLowLevTipsView.getInstance().showDialog();
+                //这里则会显示可能会关机
+                ICLogger.d("on lower then 5 percent..." + batLevel);
+                if (Config.LOG_TOFILE) ICLogger.logToFile("Battery", "BatteryLow less than 5% !");
+            }
             checkAndSendBatteryEvent(param1Context, mRuntime);
             mRuntime.setBattery(String.format("%03d", batLevel));
             mRuntime.setBattery(batLevel);
@@ -211,7 +221,6 @@ public class BatteryUtil {
             warningMsgValues.put(ICDatabaseHelper.warning_msg_create_time, System.currentTimeMillis());
             runtime.getContextProxy().getResolver().insert(Uri.parse(WarningItemProvider.WARNING_MSG),
                     warningMsgValues);
-            //TODO:低电的通知
         }
         //add by TrillGates======end
         ICLogger.d("runtime.getBatteryLevel()==> " + runtime.getBatteryLevel());
index 38ac2c9..41e29cc 100644 (file)
@@ -162,7 +162,7 @@ public class protocol_s123 {
                         .append(CMDSPLIT).append(mRuntime.getS123GpsData())
                         .append(CMDSPLIT).append("wgs84")//原始经纬度
                         .append(CMDSPLIT).append(mRuntime.getSignalStrength())
-                        .append(CMDSPLIT).append(mRuntime.getBatteryLevel())
+                        .append(CMDSPLIT).append(batteryLev)
                         .append(CMDSPLIT).append(mRuntime.getLBSData())
                         .append(CMDSPLIT).append(mRuntime.getWifiInfo())
                         .append(CMDEND).toString());
index 5bac70a..586a756 100644 (file)
@@ -56,6 +56,9 @@ public class BatteryLowLevTipsView {
 
 
     public void dismiss() {
+        if (!this.isShow) {
+            return;
+        }
         this.isShow = false;
         if (windowManager != null) {
             windowManager.removeView(view);