Merge branch 'mqtt_test' into sl8541_common
authorSnickerSun <scy@incartech.cn>
Fri, 6 Aug 2021 09:58:11 +0000 (17:58 +0800)
committerSnickerSun <scy@incartech.cn>
Fri, 6 Aug 2021 09:58:11 +0000 (17:58 +0800)
# Conflicts:
# app/src/main/java/com/enqualcomm/support/CoreService.java
# app/src/main/java/com/enqualcomm/support/utils/CellInfoUtil.java

1  2 
app/src/main/AndroidManifest.xml
app/src/main/java/com/enqualcomm/support/CoreService.java
app/src/main/java/com/enqualcomm/support/service/HeartRateManager.java
app/src/main/java/com/enqualcomm/support/utils/CellInfoUtil.java

Simple merge
@@@ -32,6 -30,6 +33,7 @@@ import android.widget.Toast
  
  import com.enqualcomm.support.adapter.LBSHelper;
  import com.enqualcomm.support.bean.Contact;
++import com.enqualcomm.support.bean.ICLocation;
  import com.enqualcomm.support.bean.Runtime;
  import com.enqualcomm.support.bean.SleepInfo;
  import com.enqualcomm.support.bean.SleepRecord;
@@@ -1001,15 -1000,31 +1016,37 @@@ public class CoreService extends Servic
          //观察微聊消息变化
          //有新消息就发送出去
          ContentResolver resolver = runtime.getContextProxy().getResolver();
-         WeTalkMsgObserver weTalkMsgObserver = new WeTalkMsgObserver(mHandler, resolver);
++
+         weTalkMsgObserver = new WeTalkMsgObserver(mHandler, resolver);
 -        resolver.registerContentObserver(
 -                Uri.parse(WeTalkMessageProvider.MESSAGES_SEND), true, weTalkMsgObserver
 -        );
 +        try {
 +            resolver.registerContentObserver(
 +                    Uri.parse(WeTalkMessageProvider.MESSAGES_SEND), true, weTalkMsgObserver
 +            );
++
 +        }catch (Exception e){
 +            ICLogger.e(e.getMessage(),e);
 +        }
  
+         shutdownFlagObserver = new ShutdownFlagObserver(mHandler, resolver);
+         resolver.registerContentObserver(Uri.parse(SETTINGS + ".shutdown_action_flag"),
+                 true,
+                 shutdownFlagObserver);
+ 
+         airplaneModeObserver = new AirplaneModeObserver(mHandler, resolver);
+         resolver.registerContentObserver(Uri.parse(SETTINGS + ".fly_mode_action_flag"),
+                 true,
+                 airplaneModeObserver);
+ 
+         SignFlagObserver signFlagObserver = new SignFlagObserver(mHandler, resolver);
+         resolver.registerContentObserver(Uri.parse(SETTINGS + ".sign_action_flag"),
+                 true,
+                 signFlagObserver);
+ 
+         WebMsgStateObserver webMsgStateObserver = new WebMsgStateObserver(mHandler, resolver);
+         resolver.registerContentObserver(Uri.parse(SETTINGS + ".web_msg_read_state_flag"),
+                 true,
+                 webMsgStateObserver);
+ 
          //启动结束设置标志位,让心率和体温检测可以正常执行。
          server_starting = false;
  
@@@ -79,194 -78,206 +79,185 @@@ public class CellInfoUtil 
  //          ICLogger.PrintExceptionStackTrace(e);
  //        }
  //      }
- //    });
- //    Single.just(null).observeOn(AndroidSchedulers.mainThread()).subscribe(new Action1<Object>() {
- //      public void call(Object param1Object) {
- //
- //        PhoneFactory.makeDefaultPhones(context);
- //
- //        Phone p = PhoneFactory.getDefaultPhone();
- //
- //        SprdCallManager cm = (SprdCallManager)SprdCallManager.getInstance();
- //
- //        cm.registerPhone(p);
- //
- //        Phone phone = cm.getDefaultPhone();
- //
- //        try {
- //          phone.dial(dialnumber);
- //        } catch (Exception e) {
- //          ICLogger.PrintExceptionStackTrace(e);
- //          ICLogger.e(e.getMessage(),e);
- //        }
- //      }
  //    });
 -        Single.just(null).observeOn(AndroidSchedulers.mainThread()).subscribe(new Action1<Object>() {
 -            public void call(Object param1Object) {
 -
 -                PhoneFactory.makeDefaultPhones(context);
 -
 -                Phone p = PhoneFactory.getDefaultPhone();
 -
 -                SprdCallManager cm = (SprdCallManager) SprdCallManager.getInstance();
 -
 -                cm.registerPhone(p);
 -
 -                Phone phone = cm.getDefaultPhone();
 -
 -                try {
 -                    phone.dial(dialnumber);
 -                } catch (Exception e) {
 -                    ICLogger.PrintExceptionStackTrace(e);
 -                    ICLogger.e(e.getMessage(), e);
 -                }
 -            }
 -        });
 -
 -    }
  
-   public static int getSignal(TelephonyManager tm , Runtime runtime){
- 
-     if(tm==null)
-       return 5;
-     try {
-       CellLocation celllocation = tm.getCellLocation();
-       if (celllocation == null) {
-         ICLogger.i("cellLocation = null");
-         return 1;
-       } else {
-         if (celllocation instanceof GsmCellLocation) {
-           for (CellInfo cinfo : tm.getAllCellInfo()) {
-             if (cinfo instanceof CellInfoGsm) {
-               CellSignalStrengthGsm cigsm = ((CellInfoGsm) cinfo).getCellSignalStrength();
-               ICLogger.i("gsm signal dbm =" + cigsm.getDbm() + ",level=" + cigsm.getLevel());
-               runtime.setSignalInfo("gsm signal dbm =" + cigsm.getDbm() + ",level=" + cigsm.getLevel());
-               return cigsm.getDbm();
-             } else if (cinfo instanceof CellInfoLte) {
-               CellSignalStrengthLte cigsm = ((CellInfoLte) cinfo).getCellSignalStrength();
-               //ICLogger.i("lte signal dbm =" + cigsm.getDbm() + ",level=" + cigsm.getLevel());
-               runtime.setSignalInfo("lte signal dbm =" + cigsm.getDbm() + ",level=" + cigsm.getLevel());
-               return cigsm.getDbm();
-             } else if (cinfo instanceof CellInfoWcdma) {
-               CellSignalStrengthWcdma cicdma = ((CellInfoWcdma) cinfo).getCellSignalStrength();
-              // ICLogger.i("wcdma signal dbm =" + cicdma.getDbm() + ",level=" + cicdma.getLevel());
-               runtime.setSignalInfo("wcdma signal dbm =" + cicdma.getDbm() + ",level=" + cicdma.getLevel());
-               return cicdma.getDbm();
-             }
-           }
-           return 2;
-         } else if (celllocation instanceof CdmaCellLocation) {
-           for (CellInfo cinfo : tm.getAllCellInfo()) {
-             if (cinfo instanceof CellInfoCdma) {
-               CellSignalStrengthCdma cicdma = ((CellInfoCdma) cinfo).getCellSignalStrength();
-               ICLogger.i("cdma signal dbm =" + cicdma.getDbm() + ",level=" + cicdma.getLevel());
-               runtime.setSignalInfo("cdma signal dbm =" + cicdma.getDbm() + ",level=" + cicdma.getLevel());
-               return cicdma.getDbm();
 +  }
+     public static int getSignal(TelephonyManager tm, Runtime runtime) {
+ 
+         if (tm == null)
+             return 5;
+         try {
+             CellLocation celllocation = tm.getCellLocation();
+             if (celllocation == null) {
+                 ICLogger.i("cellLocation = null");
+                 return 1;
+             } else {
+                 if (celllocation instanceof GsmCellLocation) {
+                     for (CellInfo cinfo : tm.getAllCellInfo()) {
+                         if (cinfo instanceof CellInfoGsm) {
+                             CellSignalStrengthGsm cigsm = ((CellInfoGsm) cinfo).getCellSignalStrength();
+                             ICLogger.i("gsm signal dbm =" + cigsm.getDbm() + ",level=" + cigsm.getLevel());
+                             runtime.setSignalInfo("gsm signal dbm =" + cigsm.getDbm() + ",level=" + cigsm.getLevel());
+                             return cigsm.getDbm();
+                         } else if (cinfo instanceof CellInfoLte) {
+                             CellSignalStrengthLte cigsm = ((CellInfoLte) cinfo).getCellSignalStrength();
+                             //ICLogger.i("lte signal dbm =" + cigsm.getDbm() + ",level=" + cigsm.getLevel());
+                             runtime.setSignalInfo("lte signal dbm =" + cigsm.getDbm() + ",level=" + cigsm.getLevel());
+                             return cigsm.getDbm();
+                         } else if (cinfo instanceof CellInfoWcdma) {
+                             CellSignalStrengthWcdma cicdma = ((CellInfoWcdma) cinfo).getCellSignalStrength();
+                             // ICLogger.i("wcdma signal dbm =" + cicdma.getDbm() + ",level=" + cicdma.getLevel());
+                             runtime.setSignalInfo("wcdma signal dbm =" + cicdma.getDbm() + ",level=" + cicdma.getLevel());
+                             return cicdma.getDbm();
+                         }
+                     }
+                     return 2;
+                 } else if (celllocation instanceof CdmaCellLocation) {
+                     for (CellInfo cinfo : tm.getAllCellInfo()) {
+                         if (cinfo instanceof CellInfoCdma) {
+                             CellSignalStrengthCdma cicdma = ((CellInfoCdma) cinfo).getCellSignalStrength();
+                             ICLogger.i("cdma signal dbm =" + cicdma.getDbm() + ",level=" + cicdma.getLevel());
+                             runtime.setSignalInfo("cdma signal dbm =" + cicdma.getDbm() + ",level=" + cicdma.getLevel());
+                             return cicdma.getDbm();
+                         }
+                     }
+                     return 3;
+                 }
+                 return 4;
              }
-           }
-           return 3;
+         } catch (Exception e) {
+             ICLogger.e(e.getMessage());
+             ICLogger.PrintExceptionStackTrace(e);
+             return 6;
          }
-         return 4;
-       }
-     }catch (Exception e){
-       ICLogger.e(e.getMessage());
-       ICLogger.PrintExceptionStackTrace(e);
-       return 6;
-     }
-   }
-   public static String getCellInfo(TelephonyManager telephonyManager, Runtime runtime) {
-     ICLogger.i("LBS 延时获取基站信息");
-     /***
-      * MCC,Mobile Country Code,移动国家代码(中国的为460)。
-      * MNC,Mobile Network Code,移动网络号码(中国移动为0,中国联通为1,中国电信为2)。
-      * LAC,Location Area Code,位置区域码。
-      * CID,Cell Identity,基站编号。
-      * BSSS,Base station signal strength,基站信号强度。
-      */
-     int maxstationCount = 0;
-     String mccmnc;
-     if (Build.VERSION.SDK_INT > 23) {
-       mccmnc = telephonyManager.getSimOperator();
-       if (mccmnc == null) {
-         ICLogger.i("LBS operator == null");
-         return null;
-       }
- 
-       mccmnc = mccmnc.substring(0, 5);
-     } else {
-       mccmnc = telephonyManager.getNetworkOperator();
      }
  
-     if(mccmnc==null|| (mccmnc!=null && mccmnc.trim().isEmpty()))
-     {
-       ICLogger.i("LBS retry get MCCMNC");
-       telephonyManager=((TelephonyManager) runtime.getContextProxy().context.getSystemService(Context.TELEPHONY_SERVICE));
-       Util.mSleep(5000);
-       mccmnc=telephonyManager.getSimOperator();
-     }
-     ICLogger.i("LBS mccmnc "+mccmnc);
-     runtime.setmccmnc(mccmnc);
- 
-     if (mccmnc != null && mccmnc.length() > 3) {
- 
-       //==========清除Runtime中lbs数据,暂时没有使用此lbs数据
-       runtime.getLocationInstance().clearLBSdata();
-       runtime.setLBSMultiStationData("");
-       runtime.setFZDLBSMultiStationData("");
-       runtime.setGatorLBSMultiStationData("");
- 
-       //如果没插卡,后面数据会获取不到,以上数据也就为空了
-       CellLocation celllocation = telephonyManager.getCellLocation();
-       if (celllocation == null) {
-         ICLogger.i("LBS cellLocation = null");
-         return null;
-       } else {
-         StringBuilder gsmSb = new StringBuilder(mccmnc);
-         gsmSb.insert(3, ",");
- 
-         StringBuilder cdmaSB = new StringBuilder();
-         runtime.setMccAndMnc(gsmSb.toString());
-         int mcc=0;
-         int mnc=0;
-         try {
-           mcc = Integer.parseInt(runtime.getLocationInstance().getMCC());
-           mnc = Integer.parseInt(runtime.getLocationInstance().getMNC());
-         }catch (Exception e){
-           ICLogger.e(e.getMessage(),e);
+     public static String getCellInfo(TelephonyManager telephonyManager, Runtime runtime) {
+         ICLogger.i("LBS 延时获取基站信息");
+         /***
+          * MCC,Mobile Country Code,移动国家代码(中国的为460)。
+          * MNC,Mobile Network Code,移动网络号码(中国移动为0,中国联通为1,中国电信为2)。
+          * LAC,Location Area Code,位置区域码。
+          * CID,Cell Identity,基站编号。
+          * BSSS,Base station signal strength,基站信号强度。
+          */
+         int maxstationCount = 0;
+         String mccmnc;
+         if (Build.VERSION.SDK_INT > 23) {
+             mccmnc = telephonyManager.getSimOperator();
+             if (mccmnc == null) {
+                 ICLogger.i("LBS operator == null");
+                 return null;
+             }
+ 
+             mccmnc = mccmnc.substring(0, 5);
+         } else {
+             mccmnc = telephonyManager.getNetworkOperator();
+         }
+ 
+         if (mccmnc == null || (mccmnc != null && mccmnc.trim().isEmpty())) {
+             ICLogger.i("LBS retry get MCCMNC");
+             telephonyManager = ((TelephonyManager) runtime.getContextProxy().context.getSystemService(Context.TELEPHONY_SERVICE));
+             Util.mSleep(5000);
+             mccmnc = telephonyManager.getSimOperator();
          }
-         if (celllocation instanceof GsmCellLocation) {
-           GsmCellLocation gsmCell = (GsmCellLocation)celllocation;
-             runtime.setCdmaInfo(null);
-           //AP01 Single GSM Station
-           gsmSb.append(",");
-           gsmSb.append(gsmCell.getLac());
-           gsmSb.append(",");
-           gsmSb.append(gsmCell.getCid());
-           gsmSb.append(",");
-           gsmSb.append(150-Math.abs(getSignal(telephonyManager,runtime)));
-           runtime.setCellinfo(gsmSb.toString());
-           runtime.getLocationInstance().setCID(gsmCell.getCid());
-           runtime.getLocationInstance().setLAC(gsmCell.getLac());
-           runtime.getLocationInstance().setRxlevel(150-Math.abs(getSignal(telephonyManager,runtime)));
-           ICLogger.i("LBS GsmCellLocation "+ gsmSb.toString());
-           if (Config.LOG_TOFILE) ICLogger.logToFile("LBS", gsmSb.toString());
- 
-           //===添加gsm station到Runtime全局变量
-           runtime.getLocationInstance().append_gsmstation(gsmCell.getLac()+","+gsmCell.getCid(),150-Math.abs(getSignal(telephonyManager,runtime)));
- 
-           List neighboringCell_list = telephonyManager.getNeighboringCellInfo();
-             //AP02 Multi GSM Station
-           StringBuilder gsmSbMulti = new StringBuilder(); //头
-           StringBuilder gsmSbMulti_data = new StringBuilder(); //内容
- 
-           StringBuilder gsmSbMultiFZD = new StringBuilder();//头
-           StringBuilder gsmSbMultiFZD_data = new StringBuilder();//内容
- 
-           StringBuilder gsmSbMultiGator = new StringBuilder(); //头
-           StringBuilder gsmSbMultiGator_data = new StringBuilder(); //内容
- 
-           int size=1;
-             if (neighboringCell_list != null && !neighboringCell_list.isEmpty()) {
-               sortByRssi(neighboringCell_list);
-               ICLogger.i("signal CellInfo size "+neighboringCell_list.size());
-               Iterator cell = neighboringCell_list.iterator();
- 
-               while(cell.hasNext()) {
-                NeighboringCellInfo mNeighboringCellInfo = (NeighboringCellInfo)cell.next();
-                 if (mNeighboringCellInfo.getLac() == -1) {
-                   break;
++
+         ICLogger.i("LBS mccmnc " + mccmnc);
+         runtime.setmccmnc(mccmnc);
+ 
+         if (mccmnc != null && mccmnc.length() > 3) {
+ 
+             //==========清除Runtime中lbs数据,暂时没有使用此lbs数据
+             runtime.getLocationInstance().clearLBSdata();
+             runtime.setLBSMultiStationData("");
+             runtime.setFZDLBSMultiStationData("");
+             runtime.setGatorLBSMultiStationData("");
+ 
+             //如果没插卡,后面数据会获取不到,以上数据也就为空了
+             CellLocation celllocation = telephonyManager.getCellLocation();
+             if (celllocation == null) {
+                 ICLogger.i("LBS cellLocation = null");
+                 return null;
+             } else {
+                 StringBuilder gsmSb = new StringBuilder(mccmnc);
+                 gsmSb.insert(3, ",");
+ 
+                 StringBuilder cdmaSB = new StringBuilder();
+                 runtime.setMccAndMnc(gsmSb.toString());
+                 int mcc = 0;
+                 int mnc = 0;
+                 try {
+                     mcc = Integer.parseInt(runtime.getLocationInstance().getMCC());
+                     mnc = Integer.parseInt(runtime.getLocationInstance().getMNC());
+                 } catch (Exception e) {
+                     ICLogger.e(e.getMessage(), e);
                  }
-                 gsmSbMulti_data.append(",");
-                 gsmSbMulti_data.append(mNeighboringCellInfo.getLac());
-                 gsmSbMulti_data.append("|");
-                 gsmSbMulti_data.append(mNeighboringCellInfo.getCid());
-                 gsmSbMulti_data.append("|");
-                 gsmSbMulti_data.append( 150-Math.abs(mNeighboringCellInfo.getRssi()));
- 
-                 gsmSbMultiFZD_data.append(",");
-                 gsmSbMultiFZD_data.append(mNeighboringCellInfo.getLac());
-                 gsmSbMultiFZD_data.append(",");
-                 gsmSbMultiFZD_data.append(mNeighboringCellInfo.getCid());
-                 gsmSbMultiFZD_data.append(",");
-                 gsmSbMultiFZD_data.append( 150-Math.abs(mNeighboringCellInfo.getRssi()));
+                 if (celllocation instanceof GsmCellLocation) {
+                     GsmCellLocation gsmCell = (GsmCellLocation) celllocation;
+                     runtime.setCdmaInfo(null);
+                     //AP01 Single GSM Station
+                     gsmSb.append(",");
+                     gsmSb.append(gsmCell.getLac());
+                     gsmSb.append(",");
+                     gsmSb.append(gsmCell.getCid());
+                     gsmSb.append(",");
+                     gsmSb.append(150 - Math.abs(getSignal(telephonyManager, runtime)));
+                     runtime.setCellinfo(gsmSb.toString());
+                     runtime.getLocationInstance().setCID(gsmCell.getCid());
+                     runtime.getLocationInstance().setLAC(gsmCell.getLac());
+                     runtime.getLocationInstance().setRxlevel(150 - Math.abs(getSignal(telephonyManager, runtime)));
+                     ICLogger.i("LBS GsmCellLocation " + gsmSb.toString());
+                     if (Config.LOG_TOFILE) ICLogger.logToFile("LBS", gsmSb.toString());
+ 
+                     //===添加gsm station到Runtime全局变量
+                     runtime.getLocationInstance().append_gsmstation(gsmCell.getLac() + "," + gsmCell.getCid(), 150 - Math.abs(getSignal(telephonyManager, runtime)));
+ 
+                     List neighboringCell_list = telephonyManager.getNeighboringCellInfo();
+                     //AP02 Multi GSM Station
+                     StringBuilder gsmSbMulti = new StringBuilder(); //头
+                     StringBuilder gsmSbMulti_data = new StringBuilder(); //内容
+ 
+                     StringBuilder gsmSbMultiFZD = new StringBuilder();//头
+                     StringBuilder gsmSbMultiFZD_data = new StringBuilder();//内容
+ 
+                     StringBuilder gsmSbMultiGator = new StringBuilder(); //头
+                     StringBuilder gsmSbMultiGator_data = new StringBuilder(); //内容
+ 
+                     StringBuilder gsmSbMultiANAN = new StringBuilder();//头
+                     StringBuilder gsmSbMultiANAN_data = new StringBuilder();//内容
+ 
+                     int size = 1;
+                     if (neighboringCell_list != null && !neighboringCell_list.isEmpty()) {
+                         sortByRssi(neighboringCell_list);
+ 
+                         Iterator cell = neighboringCell_list.iterator();
+ 
+ 
+                         while (cell.hasNext()) {
+                             NeighboringCellInfo mNeighboringCellInfo = (NeighboringCellInfo) cell.next();
+                             if (mNeighboringCellInfo.getLac() == -1) {
+                                 break;
+                             }
+                             gsmSbMulti_data.append(",");
+                             gsmSbMulti_data.append(mNeighboringCellInfo.getLac());
+                             gsmSbMulti_data.append("|");
+                             gsmSbMulti_data.append(mNeighboringCellInfo.getCid());
+                             gsmSbMulti_data.append("|");
+                             gsmSbMulti_data.append(150 - Math.abs(mNeighboringCellInfo.getRssi()));
+ 
+                             gsmSbMultiFZD_data.append(",");
+                             gsmSbMultiFZD_data.append(mNeighboringCellInfo.getLac());
+                             gsmSbMultiFZD_data.append(",");
+                             gsmSbMultiFZD_data.append(mNeighboringCellInfo.getCid());
+                             gsmSbMultiFZD_data.append(",");
+                             gsmSbMultiFZD_data.append(150 - Math.abs(mNeighboringCellInfo.getRssi()));
+ 
+                           gsmSbMultiANAN_data.append(",");
+                           gsmSbMultiANAN_data.append(mNeighboringCellInfo.getLac());
+                           gsmSbMultiANAN_data.append(",");
+                           gsmSbMultiANAN_data.append(mNeighboringCellInfo.getCid());
+                           gsmSbMultiANAN_data.append(",");
+                           gsmSbMultiANAN_data.append(150 - Math.abs(mNeighboringCellInfo.getRssi()));
  
  // Gator         MCC(%03d)+MNC(%03d)+LACID(%04X)+CELLID(%07X)+RX LEVEL(%02X)