refactor code that move get weahter info from coreservice to api helper.
authorTrillGates <williamtrillgates@gmail.com>
Fri, 2 Jul 2021 02:35:26 +0000 (10:35 +0800)
committerTrillGates <williamtrillgates@gmail.com>
Fri, 2 Jul 2021 02:35:26 +0000 (10:35 +0800)
12 files changed:
app/build.gradle
app/src/main/AndroidManifest.xml
app/src/main/aidl/com/ic/s123/GenericWeatherInfo.aidl [new file with mode: 0644]
app/src/main/aidl/com/ic/s123/IS123WeatherCallback.aidl
app/src/main/aidl/com/ic/s123/S123WeatherInfo.aidl [deleted file]
app/src/main/java/com/enqualcomm/support/CoreService.java
app/src/main/java/com/enqualcomm/support/bean/ICLocation.java
app/src/main/java/com/enqualcomm/support/bean/Runtime.java
app/src/main/java/com/ic/protocols/protocolAPIHelper.java
app/src/main/java/com/ic/protocols/protocol_anan.java
app/src/main/java/com/ic/protocols/protocol_s123.java
app/src/main/java/com/ic/s123/GenericWeatherInfo.java [moved from app/src/main/java/com/ic/s123/S123WeatherInfo.java with 75% similarity]

index 658d872..b84b7c4 100644 (file)
@@ -89,7 +89,7 @@ dependencies {
 
     implementation 'com.android.support.constraint:constraint-layout:1.1.3'
     //compile fileTree(include: ['*.jar', '*.aar'], dir: 'libs')
-    androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
+    androidTestImplementation('com.android.support.test.espresso:espresso-core:2.2.2', {
         exclude group: 'com.android.support', module: 'support-annotations'
     })
     implementation 'com.android.support:appcompat-v7:25.1.0'
index 5561b10..7491307 100644 (file)
                 <action android:name="com.enqualcomm.support.OTHER_ALARM_START" />
                 <action android:name="com.ic.action.VIDEO_CALL" />
                 <action android:name="com.ic.fzd.action.WEATHER" />
-                <action android:name="com.ic.s123.action.WEATHER" />
+                <action android:name="com.ic.generic.action.WEATHER" />
                 <action android:name="com.ic.power.ACTION_ALARM_POWER_OFF" />
             </intent-filter>
         </service>
diff --git a/app/src/main/aidl/com/ic/s123/GenericWeatherInfo.aidl b/app/src/main/aidl/com/ic/s123/GenericWeatherInfo.aidl
new file mode 100644 (file)
index 0000000..870647a
--- /dev/null
@@ -0,0 +1,4 @@
+
+package com.ic.s123;
+
+parcelable GenericWeatherInfo;
\ No newline at end of file
index f18dec9..5206ac4 100644 (file)
@@ -1,8 +1,8 @@
 
 package com.ic.s123;
 
-import com.ic.s123.S123WeatherInfo;
+import com.ic.s123.GenericWeatherInfo;
 
 interface IS123WeatherCallback {
-    void onWeatherLoaded(in List<S123WeatherInfo> resultList);
+    void onWeatherLoaded(in List<GenericWeatherInfo> resultList);
 }
\ No newline at end of file
diff --git a/app/src/main/aidl/com/ic/s123/S123WeatherInfo.aidl b/app/src/main/aidl/com/ic/s123/S123WeatherInfo.aidl
deleted file mode 100644 (file)
index 260aafe..0000000
+++ /dev/null
@@ -1,4 +0,0 @@
-
-package com.ic.s123;
-
-parcelable S123WeatherInfo;
\ No newline at end of file
index 39a80e9..b8f0b89 100644 (file)
@@ -70,7 +70,6 @@ import com.ic.fzd.weather.IFZDWeatherService;
 import com.ic.jni.ICJniUtils;
 import com.ic.protocols.protocolAPIHelper;
 import com.ic.protocols.protocol_fzd;
-import com.ic.protocols.protocol_s123;
 import com.ic.s123.IS123WeatherCallback;
 import com.ic.s123.IS123WeatherService;
 
@@ -1626,9 +1625,9 @@ public class CoreService extends Service {
             return mFZDService;
         } else if ("com.ic.fzd.action.WEATHER".equals(action)) {
             return mFZDWeatherService;
-        } else if ("com.ic.s123.action.WEATHER".equals(action)) {
+        } else if ("com.ic.generic.action.WEATHER".equals(action)) {
             //S123获取天气
-            return mS123WeatherService;
+            return mGenericWeatherService;
         }
         return this.mMessenger.getBinder();
     }
@@ -1637,28 +1636,26 @@ public class CoreService extends Service {
         this.connection.close();
     }
 
-    private final IS123WeatherService.Stub mS123WeatherService = new IS123WeatherService.Stub() {
+    private final IS123WeatherService.Stub mGenericWeatherService = new IS123WeatherService.Stub() {
         @Override
         public void registerCallback(IS123WeatherCallback callback) {
-            runtime.registerS123WeatherCallback(callback);
+            runtime.registerGenericWeatherCallback(callback);
         }
 
         @Override
         public void unRegisterCallback(IS123WeatherCallback callback) {
-            runtime.registerS123WeatherCallback(null);
+            runtime.registerGenericWeatherCallback(null);
         }
 
         @Override
         public void getWeatherInfo() {
             //获取一下数据
-            getS123WeatherInfo();
+            getGenericWeatherInfo();
         }
     };
 
-    private void getS123WeatherInfo() {
-        //获取天气信息
-        StringMessage wt = protocol_s123.APTQ(runtime);
-        connection.send(wt);
+    private void getGenericWeatherInfo() {
+        protocolAPIHelper.doWeatherGet(connection, runtime);
     }
 
     private final IFZDWeatherService.Stub mFZDWeatherService = new IFZDWeatherService.Stub() {
@@ -1681,11 +1678,7 @@ public class CoreService extends Service {
     };
 
     private void getFZDWeatherInfo() {
-        //获取天气信息
-        StringMessage wt = protocol_fzd.WT(runtime);
-        connection.send(wt);
-        StringMessage wt2 = protocol_fzd.WT2(runtime);
-        connection.send(wt2);
+        protocolAPIHelper.doWeatherGet(connection, runtime);
     }
 
 
index 46aac2f..45ee3d8 100644 (file)
@@ -1,44 +1,51 @@
 package com.enqualcomm.support.bean;\r
 \r
+import com.enqualcomm.support.utils.ICLogger;\r
+\r
 import java.util.ArrayList;\r
 import java.util.HashMap;\r
 import java.util.List;\r
 \r
 public class ICLocation {\r
 \r
-    public static class  GpsSatellitePriv {\r
+    public static class GpsSatellitePriv {\r
         int prn;\r
         float snr;\r
+\r
         public GpsSatellitePriv(int _prn, float _snr) {\r
-            prn=_prn;\r
-            snr=_snr;\r
+            prn = _prn;\r
+            snr = _snr;\r
         }\r
+\r
         public int getPrn() {\r
             return prn;\r
         }\r
+\r
         public float getSnr() {\r
             return snr;\r
         }\r
     }\r
+\r
     public List<GpsSatellitePriv> numSatelliteList = new ArrayList<GpsSatellitePriv>(); // 卫星信号\r
     public List<GpsSatellitePriv> max3Satellite = new ArrayList<GpsSatellitePriv>(); // 卫星信号\r
-    private static boolean adding_satlite_flag=false;\r
-    public void set_adding_satlite_flag(boolean flag){\r
-        adding_satlite_flag=flag;\r
+    private static boolean adding_satlite_flag = false;\r
+\r
+    public void set_adding_satlite_flag(boolean flag) {\r
+        adding_satlite_flag = flag;\r
     }\r
 \r
-    public List<GpsSatellitePriv> getNumSatelliteList(){\r
+    public List<GpsSatellitePriv> getNumSatelliteList() {\r
         if (adding_satlite_flag)\r
             return null;\r
         return numSatelliteList;\r
     }\r
 \r
 \r
-\r
     private LOCATION_STAT currentStat;\r
-    private GPS_LocationPoint currentLP=null;\r
-    private LBS_Data currentLBS=null;\r
-    public class GPS_LocationPoint{\r
+    private GPS_LocationPoint currentLP = null;\r
+    private LBS_Data currentLBS = null;\r
+\r
+    public class GPS_LocationPoint {\r
         public double lat;\r
         public double lon;\r
         public float speed;\r
@@ -54,7 +61,7 @@ public class ICLocation {
     }\r
 \r
 \r
-    public static class GPS_locationStatus{\r
+    public static class GPS_locationStatus {\r
         public List<GpsSatellitePriv> numSatelliteList = new ArrayList<GpsSatellitePriv>(); // 卫星信号\r
         public int used_gps_numbs;\r
         public float hdop;\r
@@ -62,11 +69,13 @@ public class ICLocation {
         public int search_time_cost;\r
         public int locating_status;\r
     }\r
-    public class LBS_Data{\r
-        HashMap<String ,Integer> wifi_aps=null;\r
-        HashMap<String , Integer> gsm_stations=null;\r
+\r
+    public class LBS_Data {\r
+        HashMap<String, Integer> wifi_aps = null;\r
+        HashMap<String, Integer> gsm_stations = null;\r
     }\r
-    public enum LOCATION_STAT{\r
+\r
+    public enum LOCATION_STAT {\r
         LOCATION_OPEN,\r
         LOCATION_FIXED,\r
         LOCATION_SEARCHING,\r
@@ -77,44 +86,57 @@ public class ICLocation {
     }\r
 \r
 \r
-    public static final int NORMAL_MOD=1;     //location rate 1 time per 15 minutes\r
-    public static final int LOWPOWER_MOD=2;   // location rate 1 time per hour\r
-    public static final int REALTIME_MOD=3; //location rate 1 time per minutes\r
-    public static final int EMERGNECY_MOD=4; //location rate 1 time per minutes com.ic.work 5 minutes\r
-    public static final int CUSTOM_MOD=5; //location rate 1 time per minutes\r
-    public static final int CUSTOM_MOD8_GPS=8; //location rate 1 time per minutes\r
-    public static final int CUSTOM_MOD8_WIFI=9; //location rate 1 time per minutes\r
+    public static final int NORMAL_MOD = 1;     //location rate 1 time per 15 minutes\r
+    public static final int LOWPOWER_MOD = 2;   // location rate 1 time per hour\r
+    public static final int REALTIME_MOD = 3; //location rate 1 time per minutes\r
+    public static final int EMERGNECY_MOD = 4; //location rate 1 time per minutes com.ic.work 5 minutes\r
+    public static final int CUSTOM_MOD = 5; //location rate 1 time per minutes\r
+    public static final int CUSTOM_MOD8_GPS = 8; //location rate 1 time per minutes\r
+    public static final int CUSTOM_MOD8_WIFI = 9; //location rate 1 time per minutes\r
 \r
     private int mworkingMod;\r
     private int location_cycle;\r
 \r
-    public static final float MAX_HDOP=10.0f;\r
-    public static final int MAX_GPS_NOSIGNAL_COUNT=15;\r
-    public static final int MAX_GPS_SEARCH_TIMEOUT=120;\r
-    public void setWorkingMod(int wkmod){ mworkingMod=wkmod;}\r
-    public void setLocation_cycle(int _locatCycle){ location_cycle=_locatCycle;}\r
-    public int getWorkingMod(){return mworkingMod;}\r
-    public int getLocation_cycle(){return location_cycle;}\r
+    public static final float MAX_HDOP = 10.0f;\r
+    public static final int MAX_GPS_NOSIGNAL_COUNT = 15;\r
+    public static final int MAX_GPS_SEARCH_TIMEOUT = 120;\r
+\r
+    public void setWorkingMod(int wkmod) {\r
+        mworkingMod = wkmod;\r
+    }\r
+\r
+    public void setLocation_cycle(int _locatCycle) {\r
+        location_cycle = _locatCycle;\r
+    }\r
 \r
-    public ICLocation(){\r
+    public int getWorkingMod() {\r
+        return mworkingMod;\r
+    }\r
+\r
+    public int getLocation_cycle() {\r
+        return location_cycle;\r
+    }\r
+\r
+    public ICLocation() {\r
         if (currentLP == null)\r
-            currentLP=new GPS_LocationPoint();\r
+            currentLP = new GPS_LocationPoint();\r
 \r
         currentStat = LOCATION_STAT.LOCATION_CLOSED;\r
         if (currentLBS == null)\r
             currentLBS = new LBS_Data();\r
-        if (currentLBS.gsm_stations==null)\r
-            currentLBS.gsm_stations=new HashMap<String,Integer>();\r
-        if (currentLBS.wifi_aps==null)\r
-            currentLBS.wifi_aps=new HashMap<String,Integer>();\r
+        if (currentLBS.gsm_stations == null)\r
+            currentLBS.gsm_stations = new HashMap<String, Integer>();\r
+        if (currentLBS.wifi_aps == null)\r
+            currentLBS.wifi_aps = new HashMap<String, Integer>();\r
 \r
         init_data();\r
     }\r
 \r
-    public void setLocationStat(LOCATION_STAT stat){\r
+    public void setLocationStat(LOCATION_STAT stat) {\r
         this.currentStat = stat;\r
     }\r
-    private void init_data(){\r
+\r
+    private void init_data() {\r
 //        currentLP.lat=2232.9806f;\r
 //        currentLP.lon=11404.9355f;\r
 //        currentLP.speed=000.1f;\r
@@ -125,110 +147,125 @@ public class ICLocation {
 \r
 \r
     }\r
-    public LOCATION_STAT getLocationStat(){\r
+\r
+    public LOCATION_STAT getLocationStat() {\r
         return currentStat;\r
     }\r
+\r
     private String LocationTime;\r
-    public void setLocationTime(String time){\r
 \r
-        LocationTime=time;\r
+    public void setLocationTime(String time) {\r
+\r
+        LocationTime = time;\r
     }\r
-    public String getLocationTime(){\r
+\r
+    public String getLocationTime() {\r
         return LocationTime;\r
     }\r
+\r
     private String LocationType;\r
-    public void setLocationType(String type){\r
 \r
-        LocationType=type;\r
+    public void setLocationType(String type) {\r
+\r
+        LocationType = type;\r
     }\r
-    public String getLocationType(){\r
+\r
+    public String getLocationType() {\r
         return LocationType;\r
     }\r
-    public GPS_LocationPoint  getLocation(){\r
+\r
+    public GPS_LocationPoint getLocation() {\r
         return currentLP;\r
     }\r
 \r
-    public void setHod(float _hot){\r
-        currentLP.hdop=_hot;\r
+    public void setHod(float _hot) {\r
+        currentLP.hdop = _hot;\r
     }\r
 \r
-    public float getHdop(){\r
+    public float getHdop() {\r
         return currentLP.hdop;\r
     }\r
 \r
-    public void setSpeed( float _speed){\r
-        currentLP.speed=_speed;\r
+    public void setSpeed(float _speed) {\r
+        currentLP.speed = _speed;\r
     }\r
-    public float getSpeed(){\r
+\r
+    public float getSpeed() {\r
         return currentLP.speed;\r
     }\r
 \r
-    public void setLocation(double lat,double lon){\r
-        currentLP.lat=lat;\r
-        currentLP.lon=lon;\r
+    public void setLocation(double lat, double lon) {\r
+        currentLP.lat = lat;\r
+        currentLP.lon = lon;\r
     }\r
 \r
-    public void setLocationlatlonName(String latname,String lonname){\r
-        currentLP.lat_name=latname;\r
-        currentLP.lon_name=lonname;\r
+    public void setLocationlatlonName(String latname, String lonname) {\r
+        currentLP.lat_name = latname;\r
+        currentLP.lon_name = lonname;\r
     }\r
-    public void setLocation(String lat,String lon){\r
-        currentLP.latStr=lat;\r
-        currentLP.lonStr=lon;\r
+\r
+    public void setLocation(String lat, String lon) {\r
+        currentLP.latStr = lat;\r
+        currentLP.lonStr = lon;\r
     }\r
-    public void setLocationGPS(String lat,String lon){\r
-        currentLP.latGPSStr=lat;\r
-        currentLP.lonGPSStr=lon;\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
+    public void setHeading(float heding) {\r
+        currentLP.heading = heding;\r
     }\r
 \r
-    public float getheading(){\r
+    public float getheading() {\r
         return currentLP.heading;\r
     }\r
 \r
-    public void setUsedStarts(int starts){\r
-        currentLP.used_gps_numbs=starts;\r
+    public void setUsedStarts(int starts) {\r
+        currentLP.used_gps_numbs = starts;\r
     }\r
 \r
-    public int getUsedStarts(){\r
+    public int getUsedStarts() {\r
         return currentLP.used_gps_numbs;\r
     }\r
 \r
-    public void setLocation(double lat,double lon,float speed,float heading,int userdgpsnumbers,float hdop){\r
-        currentLP.lat=lat;\r
-        currentLP.lon=lon;\r
-        currentLP.speed=speed;\r
-        currentLP.heading=heading;\r
+    public void setLocation(double lat, double lon, float speed, float heading, int userdgpsnumbers, float hdop) {\r
+        currentLP.lat = lat;\r
+        currentLP.lon = lon;\r
+        currentLP.speed = speed;\r
+        currentLP.heading = heading;\r
         currentLP.used_gps_numbs = userdgpsnumbers;\r
-        currentLP.latStr="";\r
-        currentLP.lonStr="";\r
-        currentLP.hdop=hdop;\r
-    }\r
-    public void setLocation(String lat,String lon,float speed,float heading,int userdgpsnumbers,float hdop){\r
-        currentLP.lat=0;\r
-        currentLP.lon=0;\r
-        currentLP.speed=speed;\r
-        currentLP.heading=heading;\r
+        currentLP.latStr = "";\r
+        currentLP.lonStr = "";\r
+        currentLP.hdop = hdop;\r
+    }\r
+\r
+    public void setLocation(String lat, String lon, float speed, float heading, int userdgpsnumbers, float hdop) {\r
+        currentLP.lat = 0;\r
+        currentLP.lon = 0;\r
+        currentLP.speed = speed;\r
+        currentLP.heading = heading;\r
         currentLP.used_gps_numbs = userdgpsnumbers;\r
-        currentLP.latStr=lat;\r
-        currentLP.lonStr=lon;\r
-        currentLP.hdop=99.9f;\r
+        currentLP.latStr = lat;\r
+        currentLP.lonStr = lon;\r
+        currentLP.hdop = 99.9f;\r
     }\r
 \r
-    public void clearLBSdata(){\r
+    public void clearLBSdata() {\r
         currentLBS.gsm_stations.clear();\r
     }\r
-    public void clearWiFidata(){\r
+\r
+    public void clearWiFidata() {\r
         currentLBS.wifi_aps.clear();\r
     }\r
 \r
-    public void append_gsmstation(String station,int rssi){\r
-        currentLBS.gsm_stations.put(station,rssi);\r
+    public void append_gsmstation(String station, int rssi) {\r
+        currentLBS.gsm_stations.put(station, rssi);\r
     }\r
-    public void append_wifiap(String wifi,int rssi){\r
-        currentLBS.wifi_aps.put(wifi,rssi);\r
+\r
+    public void append_wifiap(String wifi, int rssi) {\r
+        currentLBS.wifi_aps.put(wifi, rssi);\r
     }\r
 \r
 \r
@@ -238,34 +275,63 @@ public class ICLocation {
 //        CID,Cell Identity,基站编号,是个16位的数据(范围是0到65535)。\r
 \r
 \r
-    private String MCC="0";\r
-    private String MNC="0";\r
-    private int LAC=0;\r
-    private int CID=0;\r
-    private int rxlevel=0;\r
-    private boolean datachanged=false;\r
-    public void setMCC(String mcc){ MCC=mcc;datachanged=true;}\r
-    public void setMNC(String mnc){MNC = mnc;datachanged=true;}\r
-    public void setLAC(int  lac){LAC=lac;datachanged=true;}\r
-    public void setCID(int cid) { CID=cid;datachanged=true;}\r
-    public void setRxlevel(int level) {rxlevel=level;}\r
-    public boolean isDataChanged(){return datachanged;}\r
-    public String getMCC(){\r
+    private String MCC = "0";\r
+    private String MNC = "0";\r
+    private int LAC = 0;\r
+    private int CID = 0;\r
+    private int rxlevel = 0;\r
+    private boolean datachanged = false;\r
+\r
+    public void setMCC(String mcc) {\r
+        MCC = mcc;\r
+        datachanged = true;\r
+    }\r
+\r
+    public void setMNC(String mnc) {\r
+        ICLogger.d("MNC==> " + mnc);\r
+        MNC = mnc;\r
+        datachanged = true;\r
+    }\r
+\r
+    public void setLAC(int lac) {\r
+        LAC = lac;\r
+        datachanged = true;\r
+    }\r
+\r
+    public void setCID(int cid) {\r
+        CID = cid;\r
+        datachanged = true;\r
+    }\r
+\r
+    public void setRxlevel(int level) {\r
+        rxlevel = level;\r
+    }\r
+\r
+    public boolean isDataChanged() {\r
+        return datachanged;\r
+    }\r
+\r
+    public String getMCC() {\r
         return MCC;\r
     }\r
-    public String getMNC(){\r
+\r
+    public String getMNC() {\r
         return MNC;\r
     }\r
-    public int getRxlevel(){\r
+\r
+    public int getRxlevel() {\r
         return rxlevel;\r
     }\r
-    public long getLAC(){\r
+\r
+    public long getLAC() {\r
         return LAC;\r
     }\r
-    public long getGSMStationCID(){\r
+\r
+    public long getGSMStationCID() {\r
         return CID;\r
     }\r
-    public LBS_Data getLBSdata(){\r
+\r
+    public LBS_Data getLBSdata() {\r
         return currentLBS;\r
     }\r
 \r
index 98f6549..e6d38d4 100644 (file)
@@ -18,8 +18,8 @@ import com.enqualcomm.support.utils.ICLogger;
 import com.enqualcomm.support.utils.LanguageUtils;
 import com.enqualcomm.support.utils.TimeUtil;
 import com.ic.fzd.weather.IFZDWeatherCallback;
+import com.ic.s123.GenericWeatherInfo;
 import com.ic.s123.IS123WeatherCallback;
-import com.ic.s123.S123WeatherInfo;
 
 import java.io.File;
 import java.util.List;
@@ -234,11 +234,11 @@ public class Runtime {
 
     public IS123WeatherCallback mS123WeatherCallback = null;
 
-    public void registerS123WeatherCallback(IS123WeatherCallback callback) {
+    public void registerGenericWeatherCallback(IS123WeatherCallback callback) {
         mS123WeatherCallback = callback;
     }
 
-    public void updateS123Weather(List<S123WeatherInfo> S123WeatherInfo) {
+    public void updateS123Weather(List<GenericWeatherInfo> S123WeatherInfo) {
         if (mS123WeatherCallback != null) {
             try {
                 mS123WeatherCallback.onWeatherLoaded(S123WeatherInfo);
index 0e0a62e..90c6a2c 100644 (file)
@@ -67,6 +67,34 @@ public class protocolAPIHelper {
         );
     }
 
+    public static void doWeatherGet(Connection connection, Runtime runtime) {
+        switch (Config.protocol_no) {
+            case Config.PROTOCOL_JIAI:
+                break;
+            case Config.PROTOCOL_BEEHOME:
+                break;
+            case Config.PROTOCOL_IC:
+                break;
+            case Config.PROTOCOL_FZD:
+                //获取天气信息
+                connection.send(protocol_fzd.WT(runtime));
+                connection.send(protocol_fzd.WT2(runtime));
+                break;
+            case Config.PROTOCOL_MQTT:
+                break;
+            case PROTOCOL_ANAN:
+                //获取天气信息
+                connection.send(protocol_anan.APTQ(runtime));
+                break;
+            case Config.PROTOCOL_S123:
+                //获取天气信息
+                connection.send(protocol_s123.APTQ(runtime));
+                break;
+            case Config.PROTOCOL_GATOR:
+                break;
+        }
+    }
+
     /*
        返回true 表示 cmd 全部解析成功
        返回false表示 cmd至少有一条解析失败,失败的数据归入buffer,下一次识别接着使用
@@ -531,7 +559,7 @@ public class protocolAPIHelper {
                 ret = protocol_s123.AP02(runtime);
                 break;
             case Config.PROTOCOL_GATOR:
-                ret =  protocol_gator.BP30(runtime);
+                ret = protocol_gator.BP30(runtime);
                 break;
         }
         return ret;
index 2c04e0d..d2e8d07 100644 (file)
@@ -43,12 +43,14 @@ import com.enqualcomm.support.utils.TemperatureUtil;
 import com.enqualcomm.support.utils.TimeUtil;
 import com.enqualcomm.support.utils.Util;
 import com.enqualcomm.support.utils.VibrateUtil;
+import com.ic.s123.GenericWeatherInfo;
 
 import java.io.File;
 import java.text.SimpleDateFormat;
 import java.util.ArrayList;
 import java.util.Date;
 import java.util.HashMap;
+import java.util.List;
 import java.util.Locale;
 
 import static com.enqualcomm.support.Constants.FROM_SERVER;
@@ -426,9 +428,10 @@ public class protocol_anan {
         if (!lang.contains("zh")) {
             language = 1;
         }
+        String mnc = runtime.getLocationInstance().getMNC();
         return genStringMessage("APTQ", new StringBuffer(CMDHEADER).append(cmdMap.get(CMD_TYPE.APTQ))
                 .append(CMDSPLIT).append(runtime.getLocationInstance().getMCC())
-                .append(CMDSPLIT).append(runtime.getLocationInstance().getMNC())
+                .append(CMDSPLIT).append("00".equals(mnc) ? "0" : mnc)
                 .append(CMDSPLIT).append(runtime.getLocationInstance().getLAC())
                 .append(CMDSPLIT).append(runtime.getLocationInstance().getGSMStationCID())
                 .append(CMDSPLIT).append(language)
@@ -914,6 +917,9 @@ public class protocol_anan {
 
             StringBuilder sb = new StringBuilder();
             StringBuilder msg = new StringBuilder();
+            List<GenericWeatherInfo> weatherInfo = new ArrayList<>();
+            String City = Util.decodeUnicode2Utf8(cmdlist[22]);
+            ICLogger.i(City + " \n" + sb.toString());
             for (int i = 0; i < 3; i++) {
                 String DayTime = cmdlist[1 + i * 7] + " " + cmdlist[2 + i * 7];
                 String date = "20" + cmdlist[1 + i * 7].trim();
@@ -938,11 +944,16 @@ public class protocol_anan {
                 msg.append("," + temp_high);
                 msg.append("," + temp_low);
                 msg.append(";");
-            }
-            String City = Util.decodeUnicode2Utf8(cmdlist[22]);
 
-            ICLogger.i(City + " \n" + sb.toString());
 
+                //返回数据给UI
+                GenericWeatherInfo itemFirst = new GenericWeatherInfo(DayTime,
+                        weather_name, weather_id, temp_current, temp_low, temp_high, City);
+                //封装数据
+                ICLogger.d("itemFirst == > " + itemFirst);
+                weatherInfo.add(itemFirst);
+
+            }
             msg.insert(0, City + ";");
             String weatherstr = msg.toString();
             if (weatherstr.endsWith(";")) {
@@ -952,7 +963,7 @@ public class protocol_anan {
             intent.putExtra(Constants.KEY_Weather, weatherstr);
             ICLogger.i("send Broadcast " + Constants.ACTION_WEATHER_RECEIVED + "\n" + weatherstr + "\n");
             CoreService.getInstance().sendBroadcast(intent);
-
+            mRuntime.updateS123Weather(weatherInfo);
         } else {
             ICLogger.i(" BPTQ Format error!");
         }
index 1580699..96a5d49 100644 (file)
@@ -36,7 +36,7 @@ import com.enqualcomm.support.utils.TimeUtil;
 import com.enqualcomm.support.utils.Util;
 import com.enqualcomm.support.utils.VibrateUtil;
 import com.enqualcomm.support.utils.WakeLockUtil;
-import com.ic.s123.S123WeatherInfo;
+import com.ic.s123.GenericWeatherInfo;
 import com.ic.view.msg.MsgMustReadDialog;
 
 import java.io.File;
@@ -2549,7 +2549,7 @@ public class protocol_s123 {
             StringBuilder sb = new StringBuilder();
             StringBuilder msg = new StringBuilder();
             String City = Util.decodeUnicode2Utf8(cmdlist[22]);
-            List<S123WeatherInfo> weatherInfo = new ArrayList<>();
+            List<GenericWeatherInfo> weatherInfo = new ArrayList<>();
             for (int i = 0; i < 3; i++) {
                 String DayTime = cmdlist[1 + i * 7] + " " + cmdlist[2 + i * 7];
                 String date = "20" + cmdlist[1 + i * 7].trim();
@@ -2576,7 +2576,7 @@ public class protocol_s123 {
                 msg.append(";");
 
                 //返回数据给UI
-                S123WeatherInfo itemFirst = new S123WeatherInfo(DayTime,
+                GenericWeatherInfo itemFirst = new GenericWeatherInfo(DayTime,
                         weather_name, weather_id, temp_current, temp_low, temp_high, City);
                 //封装数据
                 weatherInfo.add(itemFirst);
@@ -3,7 +3,7 @@ package com.ic.s123;
 import android.os.Parcel;
 import android.os.Parcelable;
 
-public class S123WeatherInfo implements Parcelable {
+public class GenericWeatherInfo implements Parcelable {
 
     private String time;
 
@@ -17,7 +17,7 @@ public class S123WeatherInfo implements Parcelable {
     private String lowTemp;
     private String cityName;
 
-    protected S123WeatherInfo(Parcel in) {
+    protected GenericWeatherInfo(Parcel in) {
         time = in.readString();
         description = in.readString();
         weatherCode = in.readString();
@@ -27,13 +27,13 @@ public class S123WeatherInfo implements Parcelable {
         cityName = in.readString();
     }
 
-    public S123WeatherInfo(String time,
-                           String description,
-                           String weatherCode,
-                           String currentTemp,
-                           String highTemp,
-                           String lowTemp,
-                           String cityName) {
+    public GenericWeatherInfo(String time,
+                              String description,
+                              String weatherCode,
+                              String currentTemp,
+                              String highTemp,
+                              String lowTemp,
+                              String cityName) {
         this.time = time;
         this.description = description;
         this.weatherCode = weatherCode;
@@ -43,19 +43,19 @@ public class S123WeatherInfo implements Parcelable {
         this.cityName = cityName;
     }
 
-    public S123WeatherInfo() {
+    public GenericWeatherInfo() {
 
     }
 
-    public static final Creator<S123WeatherInfo> CREATOR = new Creator<S123WeatherInfo>() {
+    public static final Creator<GenericWeatherInfo> CREATOR = new Creator<GenericWeatherInfo>() {
         @Override
-        public S123WeatherInfo createFromParcel(Parcel in) {
-            return new S123WeatherInfo(in);
+        public GenericWeatherInfo createFromParcel(Parcel in) {
+            return new GenericWeatherInfo(in);
         }
 
         @Override
-        public S123WeatherInfo[] newArray(int size) {
-            return new S123WeatherInfo[size];
+        public GenericWeatherInfo[] newArray(int size) {
+            return new GenericWeatherInfo[size];
         }
     };