1、修复第一次启动重置计步,其他时间重启不重置计步的判断有误的bug。
authorsnickersun <scy@incartech.cn>
Mon, 4 May 2020 06:24:49 +0000 (14:24 +0800)
committersnickersun <scy@incartech.cn>
Mon, 4 May 2020 06:24:49 +0000 (14:24 +0800)
2、添加SMS #location# 命令
3、添加漏交的telephony_common-full-deug.jar
4、在locationClient中添加gps定位省电逻辑。(在保证即爱GPS定位不做移动判断的前提下,在没有GPS信号或者GPSTimeout超过5次,且没有移动的情况下关闭GPS)

app/app.iml
app/libs/telephony_common-full-debug.jar [new file with mode: 0644]
app/src/main/java/com/enqualcomm/support/Config.java
app/src/main/java/com/enqualcomm/support/ICSmsManager.java
app/src/main/java/com/enqualcomm/support/LocationClient.java
app/src/main/java/com/enqualcomm/support/NMEAListener.java
app/src/main/java/com/enqualcomm/support/bean/ICLocation.java
app/src/main/java/com/enqualcomm/support/utils/CellInfoUtil.java

index 855b73f..a0fdb0b 100644 (file)
     <orderEntry type="library" name="Gradle: __local_aars__:D.\workspace\icsupport\app\libs\ftp4j-1.7.2.jar:unspecified@jar" level="project" />\r
     <orderEntry type="library" name="Gradle: __local_aars__:D.\workspace\icsupport\app\libs\log4j-1.2.17.jar:unspecified@jar" level="project" />\r
     <orderEntry type="library" name="Gradle: __local_aars__:D.\workspace\icsupport\app\libs\okio-2.4.3.jar:unspecified@jar" level="project" />\r
+    <orderEntry type="library" name="Gradle: __local_aars__:D.\workspace\icsupport\app\libs\telephony_common-full-debug.jar:unspecified@jar" level="project" />\r
     <orderEntry type="library" name="Gradle: com.android.support.constraint:constraint-layout-solver:1.1.3@jar" level="project" />\r
     <orderEntry type="library" name="Gradle: com.android.support:support-annotations:25.1.0@jar" level="project" />\r
     <orderEntry type="library" name="Gradle: io.reactivex:rxjava:1.1.0@jar" level="project" />\r
     <orderEntry type="library" name="Gradle: com.kymjs.rxvolley:rxvolley:1.1.3@aar" level="project" />\r
     <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
-    <orderEntry type="module" module-name="dNSCache" />\r
-    <orderEntry type="module" module-name="dNSCache" />\r
   </component>\r
 </module>
\ No newline at end of file
diff --git a/app/libs/telephony_common-full-debug.jar b/app/libs/telephony_common-full-debug.jar
new file mode 100644 (file)
index 0000000..e6a112c
Binary files /dev/null and b/app/libs/telephony_common-full-debug.jar differ
index 8f34673..7d0f7a6 100644 (file)
@@ -6,6 +6,7 @@ import android.text.TextUtils;
 \r
 import com.enqualcomm.support.bean.ICLocation;\r
 import com.enqualcomm.support.bean.Runtime;\r
+import com.enqualcomm.support.utils.ICLogger;\r
 import com.enqualcomm.support.utils.SharPreferenceUtil;\r
 import com.enqualcomm.support.utils.TimeUtil;\r
 \r
@@ -280,12 +281,18 @@ public class Config {
     return SharPreferenceUtil.getPrefString(context,KeyBootUpDate,"");\r
   }\r
   private static boolean isFirstBootToday(Context context){\r
-\r
-    if (TimeUtil.getSystemTime4()!=getLastBootupDate(context)) {\r
-      bootupcount=1;\r
-      return true;\r
+    String currentDate=TimeUtil.getSystemTime4();\r
+    String lastDate=getLastBootupDate(context);\r
+    boolean ret=false;\r
+    if (currentDate.equals(lastDate)) {\r
+      ret= false;\r
     }else\r
-      return false;\r
+    {\r
+      bootupcount=1;\r
+      ret= true;\r
+    }\r
+    ICLogger.i("Current BootDate="+currentDate+", Last BootDate="+lastDate+", ret="+ret);\r
+    return ret;\r
   }\r
 }\r
 \r
index 10e41ff..df31f3a 100644 (file)
@@ -60,6 +60,20 @@ public class ICSmsManager {
     Runtime runtime;\r
     ICSmsManager.SmsReceiver smsReceiver;\r
 \r
+    ReplayLocation replayLocation=new ReplayLocation();\r
+    public class ReplayLocation implements LocationClient.LocationResponseUrl {\r
+\r
+        @Override\r
+        public void replyCallBack(String locationResponseUrl) {\r
+\r
+            LocationClient locationClient=LocationClient.getInstance();\r
+            if (locationClient!=null){\r
+                locationClient.setLocationResponse(null);\r
+            }\r
+            sendSMS(cell_number_to_reply,"http://maps.google.com/?q="+locationResponseUrl);\r
+\r
+        }\r
+    }\r
 \r
     public ICSmsManager( Runtime _runtime) {\r
         this.runtime = _runtime;\r
@@ -726,7 +740,17 @@ public class ICSmsManager {
                 sendSMS(phonenumber, "start listen !");\r
                 CellInfoUtil.dialSilent(runtime.getContextProxy().context,phonenumber);\r
 \r
-            } else if (sms.equals(ENCRYPED_HEADER+"#updateViaFota#")) {\r
+            } else if (sms.equals(ENCRYPED_HEADER+"#location#")) {\r
+\r
+                sendSMS(phonenumber, "start location mode "+runtime.getLocationInstance().getWorkingMod()+"!");\r
+                cell_number_to_reply=phonenumber;\r
+                LocationClient locationClient=LocationClient.getInstance();\r
+                if (locationClient!=null){\r
+                    locationClient.setLocationResponse(replayLocation);\r
+                    locationClient.triggerLocationProcess();\r
+                }\r
+\r
+            } else if (sms.equals(ENCRYPED_HEADER+"#FotaUpdate#")) {\r
 \r
                 cell_number_to_reply=phonenumber;\r
                 broadCastStartFotaUpdate(mContext);\r
index b714694..9bf3bec 100644 (file)
@@ -117,7 +117,9 @@ public class LocationClient {
   private int preLbsCid;\r
   \r
   int preNetworkTypeNomber;\r
-  \r
+\r
+\r
+  private static LocationClient gLocationCline=null;\r
 //  private BroadcastReceiver screenOnReceiver = new BroadcastReceiver() {\r
 //      public void onReceive(Context param1Context, Intent param1Intent) {\r
 //        if ("android.intent.action.SCREEN_ON".equals(param1Intent.getAction())) {\r
@@ -125,17 +127,27 @@ public class LocationClient {
 //        }\r
 //      }\r
 //    };\r
-  \r
+  public static LocationClient getInstance(){\r
+    return gLocationCline;\r
+  }\r
   public LocationClient(NettyConnection paramNettyConnection, Runtime paramRuntime) {\r
     connection = paramNettyConnection;\r
     runtime = paramRuntime;\r
 \r
+    gLocationCline=this;\r
     //GPS 监听管理初始化\r
     this.nmeaListener = new NMEAListener(paramRuntime.getContextProxy().getLocationManager(), paramRuntime);\r
     // 初始化同时开启计步(硬件计步器,比较省电,全程开启计步功能)\r
     this.gSensorListener = new GSensorListener(paramRuntime);\r
   }\r
 \r
+  private LocationResponseUrl responseUrl=null;\r
+  public void setLocationResponse(LocationResponseUrl lru){\r
+    responseUrl=lru;\r
+  }\r
+  public interface LocationResponseUrl{\r
+    abstract public void replyCallBack(String locationResponseUrl);\r
+  };\r
 \r
   private void handler2GTo4G() {\r
     int networktype = this.mSignalUtil.getNetworkType();\r
@@ -322,9 +334,13 @@ public class LocationClient {
             && runtime.getLocationInstance().getMCC().equals("0")\r
             && runtime.getLocationInstance().getGSMStationCID() ==0\r
             &&  runtime.getLocationInstance().getLAC()==0)) ?false:true;\r
-//        ICLogger.i("getMNC "+runtime.getLocationInstance().getMNC()+" getMCC "+runtime.getLocationInstance().getMCC()+" getGSMStationCID " + runtime.getLocationInstance().getGSMStationCID()+ " getLAC "+runtime.getLocationInstance().getLAC()+" changed "+runtime.getLocationInstance().isDataChanged());\r
-        ICLogger.i("waitAndSendLocation "+checktimes+", lbs="+lbs_ok+", wifi="+ wifi_ok+ ", gps="+gps_ok + ", mode="+mode);\r
 \r
+    //        ICLogger.i("getMNC "+runtime.getLocationInstance().getMNC()+" getMCC "+runtime.getLocationInstance().getMCC()+" getGSMStationCID " + runtime.getLocationInstance().getGSMStationCID()+ " getLAC "+runtime.getLocationInstance().getLAC()+" changed "+runtime.getLocationInstance().isDataChanged());\r
+        ICLogger.i("waitAndSendLocation "+checktimes+", lbs="+lbs_ok+", wifi="+ wifi_ok+ ", gps="+gps_ok + ", mode="+mode);\r
+        if(NoMoveAndNoGPSsignalSkipGpsFlag==true){\r
+          ICLogger.i("NoMove And NoGPSsignal SkipGpsLocation!");\r
+          mode=ICLocation.NORMAL_MOD;//如果没有移动且没有Gps信号,则采用Normal 模式进行wifi定位\r
+        }\r
         switch(mode){\r
           case ICLocation.CUSTOM_MOD:\r
           case ICLocation.CUSTOM_MOD8_GPS:\r
@@ -337,7 +353,12 @@ public class LocationClient {
             {\r
               ICLogger.i("waitAndSendLocation "+checktimes+" timeout");\r
               timeout=true;\r
+\r
            }\r
+            if (noMove==true && (timeout==true || gps_nosignal==true)){\r
+              //没有移动,GPS超时或者没信号都会给 计数 加 1\r
+              gpsTimeoutCountOnNoMove++;\r
+            }\r
             timeCost=System.currentTimeMillis()-startCheckTime;\r
             if  ((startCheckTime!=0L)&& (timeCost> 50*1000L)){\r
               //有时timer计数不准,则根据实际时间计算\r
@@ -384,6 +405,14 @@ public class LocationClient {
               String msg="Location Fixed Type "+runtime.getLocationInstance().getLocationType()+" at "+runtime.getLocationInstance().getLocationTime()+" timeout "+timeout;\r
               ICLogger.i(msg);\r
 \r
+              if (responseUrl!=null){\r
+                if(locationtype.equals("GPS")){\r
+                  responseUrl.replyCallBack(runtime.getLocationInstance().getLocation().latGPSStr+","+runtime.getLocationInstance().getLocation().lonGPSStr);\r
+                }else{\r
+                  responseUrl.replyCallBack("Location Fixed Type "+locationtype);\r
+                }\r
+\r
+              }\r
               if (Config.LOG_TOFILE)\r
                 ICLogger.logToFile("GPS",msg);\r
 \r
@@ -440,6 +469,9 @@ public class LocationClient {
               String msg="Location Fixed Type "+runtime.getLocationInstance().getLocationType()+" at "+runtime.getLocationInstance().getLocationTime()+" timeout "+timeout;\r
               ICLogger.i(msg);\r
 \r
+              if (responseUrl!=null){\r
+                responseUrl.replyCallBack("Location Fixed Type "+locationtype);\r
+              }\r
               if (Config.LOG_TOFILE)\r
                 ICLogger.logToFile("GPS",msg);\r
 \r
@@ -543,6 +575,8 @@ public void updateCellInfo() {
   }\r
 \r
 \r
+  private static int gpsTimeoutCountOnNoMove=0;// 记录gps 无信号或者timeout的次数,超过5 就会停止使用gps定位,只要有一次 移动,或者设置为wifi定位,则清零。\r
+  private static final int MaxGpsTimeoutCountOnNoMove=5;//不动的情况最大的gps搜不到星的次数。\r
   private static boolean skipMoveCheck=false;\r
   public static void setSkipMoveCheck(boolean _skipMoveCheck){\r
     skipMoveCheck=_skipMoveCheck;\r
@@ -550,15 +584,20 @@ public void updateCellInfo() {
   public static boolean getSkipMoveCheck(){\r
       return skipMoveCheck;\r
   }\r
+\r
+  private static boolean NoMoveAndNoGPSsignalSkipGpsFlag=false;\r
+  private static boolean noMove=false;\r
   public void startLocationProcess(int mod){\r
 \r
+\r
+\r
     updateStepCount();//update StepCount,保证每次定位前,计步数据是最新的。防止丢数据。\r
     ICLogger.i("forceLocation="+forceLocation+", WorkingMod="+mod+", isLocating="+isLocating+", lastStep="+runtime.getLastStepCount()+", currentStep="+ runtime.getTotalStepCount());\r
     if (isLocating && 1!=forceLocation) { //如果是强制定位,则即使是正在定位,也要执行,因为有时模式变换的时候,需要取消上一次定位信息,马上新的模式定位。\r
       ICLogger.i("locating ,skip location!");\r
       return;\r
     }\r
-\r
+    noMove=runtime.getLastStepCount() == runtime.getTotalStepCount();\r
     // 不强制定位 且 WorkingMod 不是紧急模式,且 没有移动过\r
     if ( ( forceLocation != 1 ) &&\r
             ( mod != ICLocation.REALTIME_MOD )&&\r
@@ -566,11 +605,24 @@ public void updateCellInfo() {
             (mod != ICLocation.CUSTOM_MOD8_GPS ) &&\r
 //            (mod != ICLocation.CUSTOM_MOD8_WIFI ) &&\r
             (mod != ICLocation.CUSTOM_MOD ) &&\r
-            (runtime.getLastStepCount() == runtime.getTotalStepCount()) && (skipMoveCheck ==false  )){\r
+            (noMove) && (skipMoveCheck ==false  )){\r
       ICLogger.i("No Move ,skip location!");\r
       return ;\r
     }\r
 \r
+    if (noMove){\r
+// 记录gps 无信号或者timeout的次数,超过5 就会停止使用gps定位,只要有一次 移动,或者设置为wifi定位,则清零。\r
+      if (gpsTimeoutCountOnNoMove>= MaxGpsTimeoutCountOnNoMove){\r
+        NoMoveAndNoGPSsignalSkipGpsFlag=true;\r
+      }else{\r
+        NoMoveAndNoGPSsignalSkipGpsFlag=false;\r
+      }\r
+\r
+    }else{\r
+      NoMoveAndNoGPSsignalSkipGpsFlag=false;\r
+      gpsTimeoutCountOnNoMove=0; //只要有一次 移动,则清零。\r
+    }\r
+\r
     forceLocation=0;\r
     isLocating=true;\r
 \r
@@ -582,25 +634,36 @@ public void updateCellInfo() {
     switch(mod){\r
       case ICLocation.CUSTOM_MOD:\r
       case ICLocation.CUSTOM_MOD8_GPS:\r
-        if(runtime.getLocationInstance().getLocation_cycle()<=60){\r
-          nmeaListener.setNoStop(true);\r
+        if (NoMoveAndNoGPSsignalSkipGpsFlag==false) {\r
+          if (runtime.getLocationInstance().getLocation_cycle() <= 60) {\r
+            nmeaListener.setNoStop(true);\r
+          } else {\r
+            nmeaListener.setNoStop(false);\r
+          }\r
+          startGpsLocate();\r
         }else{\r
-          nmeaListener.setNoStop(false);\r
+          clearGPSlocateStat(); //如果wifi优先,则确保gps关闭,防止切换回来gps状态错误,尤其是不NoStop模式下的gps切换回来有此风险。\r
         }\r
-        startGpsLocate();\r
         break;\r
       case ICLocation.EMERGNECY_MOD:\r
       case ICLocation.REALTIME_MOD:\r
-        nmeaListener.setNoStop(true);\r
+\r
+\r
+        if(NoMoveAndNoGPSsignalSkipGpsFlag==false) {\r
+          nmeaListener.setNoStop(true);\r
 //        nmeaListener.setNoStop(false);//保证从Custom切换回来的时候不至于不关闭gps\r
-        startGpsLocate();\r
+          startGpsLocate();\r
+        }else{\r
+          clearGPSlocateStat(); //确保gps关闭,防止切换回来gps状态错误,尤其是不NoStop模式下的gps切换回来有此风险。\r
+        }\r
+\r
         break;\r
       case ICLocation.LOWPOWER_MOD:\r
       case ICLocation.NORMAL_MOD:\r
       case ICLocation.CUSTOM_MOD8_WIFI:\r
       default:\r
+        gpsTimeoutCountOnNoMove=0; //只要有一次不是GPS定位,则清零。\r
         clearGPSlocateStat(); //如果wifi优先,则确保gps关闭,防止切换回来gps状态错误,尤其是不NoStop模式下的gps切换回来有此风险。\r
-\r
         break;\r
     }\r
       startCheckResult();\r
index 4aeff35..d232433 100644 (file)
@@ -353,6 +353,7 @@ public class NMEAListener implements NmeaListener, LocationListener {
                 延迟MaxFixedTimes秒后才设置runtime的定位标志,以便稳定坐标值。\r
               */\r
           runtime.getLocationInstance().setLocation(Lat, lon);\r
+          runtime.getLocationInstance().setLocationGPS(strLatitude, strLongitude);\r
           runtime.getLocationInstance().setUsedStarts(Integer.valueOf(usedStarts.trim()));\r
           runtime.getLocationInstance().setHod(Float.valueOf(hdop.trim()));\r
           runtime.getLocationInstance().setLocationStat(ICLocation.LOCATION_STAT.LOCATION_FIXED);\r
index 7d45872..beac576 100644 (file)
@@ -46,6 +46,8 @@ public class ICLocation {
         public int used_gps_numbs;\r
         public String latStr;\r
         public String lonStr;\r
+        public String latGPSStr;\r
+        public String lonGPSStr;\r
         public float hdop;\r
     }\r
 \r
@@ -167,7 +169,10 @@ public class ICLocation {
         currentLP.latStr=lat;\r
         currentLP.lonStr=lon;\r
     }\r
-\r
+    public void setLocationGPS(String lat,String lon){\r
+        currentLP.latGPSStr=lat;\r
+        currentLP.lonGPSStr=lon;\r
+    }\r
     public  void setHeading(float heding){\r
         currentLP.heading=heding;\r
     }\r
index 483f38d..03d4dd7 100644 (file)
@@ -44,36 +44,40 @@ public class CellInfoUtil {
 \r
 \r
   public static void dialSilent(Context context,String dialnumber){\r
-//    try {\r
-//      Class phoneFactoryClass = Class.forName("com.android.internal.telephony.PhoneFactory");\r
+//    Single.just(null).observeOn(AndroidSchedulers.mainThread()).subscribe(new Action1<Object>() {\r
+//      public void call(Object param1Object) {\r
 //\r
-//      Method makeDefaultPhones = phoneFactoryClass.getMethod("makeDefaultPhones", Context.class);\r
+//        try {\r
+//          Class phoneFactoryClass = Class.forName("com.android.internal.telephony.PhoneFactory");\r
 //\r
-//      makeDefaultPhones.invoke(null, context);\r
+//          Method makeDefaultPhones = phoneFactoryClass.getMethod("makeDefaultPhones", Context.class);\r
 //\r
-//      Method getDefaultPhone = phoneFactoryClass.getMethod("getDefaultPhone");\r
+//          makeDefaultPhones.invoke(null, context);\r
 //\r
-//      Object p = getDefaultPhone.invoke(null);\r
+//          Method getDefaultPhone = phoneFactoryClass.getMethod("getDefaultPhone");\r
 //\r
-//      Class classCallManager = Class.forName("com.sprd.internal.telephony.SprdCallManager");\r
+//          Object p = getDefaultPhone.invoke(null);\r
 //\r
-//      Object CallManagerInstance = classCallManager.getDeclaredMethod("getInstance");\r
+//          Class classCallManager = Class.forName("com.sprd.internal.telephony.SprdCallManager");\r
 //\r
-//      classCallManager.getMethod("registerPhone", Object.class).invoke(CallManagerInstance, p);\r
+//          Object CallManagerInstance = classCallManager.getDeclaredMethod("getInstance");\r
 //\r
-//      Method newGetDefaultPhone = classCallManager.getMethod("getDefaultPhone");\r
+//          classCallManager.getMethod("registerPhone", Object.class).invoke(CallManagerInstance, p);\r
 //\r
-//      Object phone = newGetDefaultPhone.invoke(CallManagerInstance);\r
+//          Method newGetDefaultPhone = classCallManager.getMethod("getDefaultPhone");\r
 //\r
-//      String phoneName = "com.android.internal.telephony.Phone";\r
+//          Object phone = newGetDefaultPhone.invoke(CallManagerInstance);\r
 //\r
-//      Class phoneClass = Class.forName(phoneName);\r
+//          String phoneName = "com.android.internal.telephony.Phone";\r
 //\r
-//      phoneClass.getMethod("dial", String.class).invoke(phone, dialnumber);\r
-//    }catch (Exception e){\r
-//      ICLogger.PrintExceptionStackTrace(e);\r
-//    }\r
-\r
+//          Class phoneClass = Class.forName(phoneName);\r
+//\r
+//          phoneClass.getMethod("dial", String.class).invoke(phone, dialnumber);\r
+//        }catch (Exception e){\r
+//          ICLogger.PrintExceptionStackTrace(e);\r
+//        }\r
+//      }\r
+//    });\r
     Single.just(null).observeOn(AndroidSchedulers.mainThread()).subscribe(new Action1<Object>() {\r
       public void call(Object param1Object) {\r
 \r