From: snickersun Date: Sat, 11 Apr 2020 07:12:59 +0000 (+0800) Subject: release V398 X-Git-Url: http://git.snicker.com.cn/sitemap.xml?a=commitdiff_plain;h=3d568eed8bd1510078b80994ae627d97c7381a6d;p=icsupport.git release V398 1、WiFi扫描直接采用检测结果的alarm,取消系统messageHandler。应该可以保证时序。 2、增加#packagevers#命令获取各个软件版本号 3、添加AP02 定位协议。在GPS定位失败,或者WiFi定位模式时采用AP02 定位。 4、为AP02协议增加 多基站扫描方法,并根据 协议里的要求把信号转为正整数上报。(150-abs(rssi)) --- diff --git a/app/app.iml b/app/app.iml index bbe6c1dc..855b73f4 100644 --- a/app/app.iml +++ b/app/app.iml @@ -105,7 +105,6 @@ - @@ -127,5 +126,9 @@ + + + + \ No newline at end of file diff --git a/app/release/ICSer_V397_2004101116_release.apk b/app/release/ICSer_V397_2004101116_release.apk deleted file mode 100644 index f32c78c8..00000000 Binary files a/app/release/ICSer_V397_2004101116_release.apk and /dev/null differ diff --git a/app/src/main/java/com/enqualcomm/support/ICSmsManager.java b/app/src/main/java/com/enqualcomm/support/ICSmsManager.java index af8ff33f..43ffc3ba 100644 --- a/app/src/main/java/com/enqualcomm/support/ICSmsManager.java +++ b/app/src/main/java/com/enqualcomm/support/ICSmsManager.java @@ -623,6 +623,8 @@ public class ICSmsManager { }else if (sms.startsWith("#poweroff#")) { sendSMS(phonenumber, "do poweroff!"); CoreService.DevliverStringMessage("poweroff"); + }else if (sms.startsWith("#packagevers#")) { + sendSMS(phonenumber, DeviceInfoUtil.getPackageVersions(mContext)); } else if (sms.startsWith("#showui#")) { Intent intent=new Intent(); // intent.setClassName(MainActivity.class.getPackage().getName(),MainActivity.class.getName()); diff --git a/app/src/main/java/com/enqualcomm/support/LocationClient.java b/app/src/main/java/com/enqualcomm/support/LocationClient.java index 6b23714e..038d1971 100644 --- a/app/src/main/java/com/enqualcomm/support/LocationClient.java +++ b/app/src/main/java/com/enqualcomm/support/LocationClient.java @@ -104,8 +104,6 @@ public class LocationClient { private LBSHelper mLbsHelper; - -// private ScheduledThreadPoolExecutor mTimer=null; private int mPedometer2; @@ -182,11 +180,11 @@ public class LocationClient { } private void performAlarm(PowerManager.WakeLock paramWakeLock) { - if (!runtime.isAirMode) { +// if (!runtime.isAirMode) { updateStepCount();//update StepCount // CellInfoUtil.triggerUpdateCellinfo(); //这个在locationClinet中也会执行更新 - sendBatteryNotification(); - } +// sendBatteryNotification(); +// } } public void triggerLocationProcess(){ mhandler.sendEmptyMessage(msgWhat_StartLocationProcess); @@ -268,26 +266,9 @@ public class LocationClient { timeout=false; startCheckTime= System.currentTimeMillis(); needCheckAgain=true; - //延时2秒执行发送“读取定位”消息 -// if (mTimer==null) { -// mTimer = new ScheduledThreadPoolExecutor(1); -// } - ICLogger.i("startCheckResult " ); -// mTimer.scheduleAtFixedRate(new Runnable() { -// @Override -// public void run() { -// try { -// waitAndSendLocation(); -// }catch (Exception e){ -// e.printStackTrace(); -// } -// //mhandler.sendEmptyMessage(msgWhat_WaitAndSendLocation); -// } -// }, 1000L, 1000L,TimeUnit.MILLISECONDS); - - AlarmHelper.setRealTimeAlarmInSeconds(runtime.getContextProxy().context,1,ACTION_CHECK_LOCATION_RESULT); + AlarmHelper.setRealTimeAlarmInSeconds(runtime.getContextProxy().context,1,ACTION_CHECK_LOCATION_RESULT); } @@ -320,12 +301,13 @@ public class LocationClient { private static boolean needCheckAgain=false; public void waitAndSendLocation(){ + this.mLbsHelper.getWifiResult(); + long timeCost=0L; wifi_ok=false; gps_ok=false; lbs_ok=false; gps_nosignal=false; - checktimes++; int mode=runtime.getLocationInstance().getWorkingMod(); if (runtime.getWifiInfo().length()>0 ) wifi_ok =true; @@ -371,8 +353,15 @@ public class LocationClient { Deliver.sendLocationMSG(AP10_CMD); startSOSLocation=false; }else { - String AP01_CMD = protocolAPIHelper.AP01(runtime); - Deliver.sendLocationMSG(AP01_CMD); + + if (gps_ok) { + String AP01_CMD = protocolAPIHelper.AP01(runtime); + Deliver.sendLocationMSG(AP01_CMD); + }else{ + String AP02_CMD = protocolAPIHelper.AP02(runtime); + Deliver.sendLocationMSG(AP02_CMD); + } + } @@ -431,8 +420,8 @@ public class LocationClient { startSOSLocation=false; }else { - String AP01_CMD = protocolAPIHelper.AP01(runtime); - Deliver.sendLocationMSG(AP01_CMD); + String AP02_CMD = protocolAPIHelper.AP02(runtime); + Deliver.sendLocationMSG(AP02_CMD); } stopCheckLocationResult(); @@ -529,9 +518,7 @@ public class LocationClient { public void updateCellInfo() { -// this.mLbsHelper.getAttchCellInfo(runtime.getContextProxy().getTelephonyManager()); -// CellInfoUtil.triggerUpdateCellinfo(); - CellInfoUtil.setCurrentAttachCellInfo(runtime, getLocationWakeLock()); + CellInfoUtil.setCurrentAttachCellInfo(runtime); } diff --git a/app/src/main/java/com/enqualcomm/support/adapter/LBSHelper.java b/app/src/main/java/com/enqualcomm/support/adapter/LBSHelper.java index e09917fd..e66fab5d 100644 --- a/app/src/main/java/com/enqualcomm/support/adapter/LBSHelper.java +++ b/app/src/main/java/com/enqualcomm/support/adapter/LBSHelper.java @@ -13,6 +13,8 @@ import android.os.Build; import android.os.Handler; import android.os.Message; import android.os.SystemClock; +import android.support.annotation.RequiresApi; +import android.telephony.CellInfo; import android.telephony.CellLocation; import android.telephony.NeighboringCellInfo; import android.telephony.PhoneStateListener; @@ -23,6 +25,7 @@ import android.telephony.gsm.GsmCellLocation; import com.enqualcomm.support.Config; import com.enqualcomm.support.bean.Runtime; +import com.enqualcomm.support.utils.CellInfoUtil; import com.enqualcomm.support.utils.DeviceInfoUtil; import com.enqualcomm.support.utils.FileOutputUtil; import com.enqualcomm.support.utils.ICLogger; @@ -63,7 +66,6 @@ public class LBSHelper { this.wifiManager = _wifiManager; this.context = _context; this.runtime = dev; - initHelper(); // registerWiFiBroadReceiver(); this.mMyPhoneListener = new LBSHelper.MyPhoneStateListener(); TelephonyManager tm = ((TelephonyManager) LBSHelper.this.context.getSystemService(Context.TELEPHONY_SERVICE)); @@ -71,62 +73,82 @@ public class LBSHelper { this.mNetworkType = tm.getNetworkType(); } - private void initHelper() { - this.mHandler = new Handler() { - @Override - public void handleMessage(Message msg) { - super.handleMessage(msg); - if (msg.what == MsgWhat_GetWifiResult) { - //停止扫描 - StringBuilder sb = handScanResults(); - if (sb != null){ - ICLogger.i("GetWifiScanResults "+sb.toString()); - if (Config.LOG_TOFILE) ICLogger.logToFile("LBS", "GetWifiScanResults "+sb.toString()); - }else{ - ICLogger.i("GetWifiScanResults null"); - if (Config.LOG_TOFILE) ICLogger.logToFile("LBS", "GetWifiScanResults null"); - } - if (sb == null) { - CurrentWiFiScanTimes++; - if (CurrentWiFiScanTimes< MaxWiFiScanRetryTimes) { - ICLogger.i("WiFi Scan get Result failed , retry scan "+CurrentWiFiScanTimes+ " times"); - wifiManager.startScan(); - delayedStopScan(); - return; - }else { - wifiInfoResult = null; - } - } else { - wifiInfoResult = sb.toString(); - } - if (mMyWifiListener != null) { - mMyWifiListener.getWifiInfoCallBack(wifiInfoResult); - - //由于wifi状态不好确认客户是如何设置的,干脆只有屏幕灭的时候才考虑关闭wifi ,防止在开启屏幕用来视频的时候被后台关掉 - if(SimSignalUtil.isScreenON(runtime.getContextProxy().context)==false) { - if (runtime.isNoTurnOffWifiOnScreenOff() || DeviceInfoUtil.isFactoryTestTopActivity(runtime.getContextProxy().context)) { - //如果 NoTurnOffWifiOnScreenOff 开关 开启,且是屏灭,或者是在工厂测试模式,则原来什么状态就什么状态。 - if (!IS_HASOPEN && IS_OPEN) { - wifiManager.setWifiEnabled(false); - IS_OPEN = false; - } - } else if (!runtime.isNoTurnOffWifiOnScreenOff()) { - //如果 NoTurnOffWifiOnScreenOff 开关 关闭,且是屏灭,则关闭wifi省电 - wifiManager.setWifiEnabled(false); - IS_OPEN = false; - IS_HASOPEN = false; - } - } - }else{ - ICLogger.i("mMyWifiListener is null skip callback"); - } + + + + public void getWifiResult(){ + + + //检查是否已经得到结果。 + if(runtime.getWifiInfo().length()==0){ + //还没有结果 + if (wifiManager.isWifiEnabled()){ + //wifi开着,可以开始检测扫描结果 + wait_count++; + if ( wait_count == 3){ + //3秒检查一次! + wait_count=0; + ICLogger.i("get WiFi Scan result !"); + }else{ + ICLogger.i("WiFi Wait "+wait_count+"!"); + return ; } + + }else{ + // ICLogger.i("WiFi is Not Open, skip check scan result!"); + return ; } - }; - } + }else{ + // ICLogger.i("WiFiScan is done, skip check scan result!"); + return; + } + //停止扫描 + StringBuilder sb = handleScanResults(); + if (sb != null){ + ICLogger.i("GetWifiScanResults "+sb.toString()); + if (Config.LOG_TOFILE) ICLogger.logToFile("LBS", "GetWifiScanResults "+sb.toString()); + }else{ + ICLogger.i("GetWifiScanResults null"); + if (Config.LOG_TOFILE) ICLogger.logToFile("LBS", "GetWifiScanResults null"); + } + if (sb == null) { + CurrentWiFiScanTimes++; + if (CurrentWiFiScanTimes< MaxWiFiScanRetryTimes) { + ICLogger.i("WiFi Scan get Result failed , retry scan "+CurrentWiFiScanTimes+ " times"); + wifiManager.startScan(); + delayedStopScan(); + return; + }else { + wifiInfoResult = null; + } + } else { + wifiInfoResult = sb.toString(); + } + if (mMyWifiListener != null) { + mMyWifiListener.getWifiInfoCallBack(wifiInfoResult); + + //由于wifi状态不好确认客户是如何设置的,干脆只有屏幕灭的时候才考虑关闭wifi ,防止在开启屏幕用来视频的时候被后台关掉 + if(SimSignalUtil.isScreenON(runtime.getContextProxy().context)==false) { + if (runtime.isNoTurnOffWifiOnScreenOff() || DeviceInfoUtil.isFactoryTestTopActivity(runtime.getContextProxy().context)) { + //如果 NoTurnOffWifiOnScreenOff 开关 开启,且是屏灭,或者是在工厂测试模式,则原来什么状态就什么状态。 + if (!IS_HASOPEN && IS_OPEN) { + wifiManager.setWifiEnabled(false); + IS_OPEN = false; + } + } else if (!runtime.isNoTurnOffWifiOnScreenOff()) { + //如果 NoTurnOffWifiOnScreenOff 开关 关闭,且是屏灭,则关闭wifi省电 + wifiManager.setWifiEnabled(false); + IS_OPEN = false; + IS_HASOPEN = false; + } + } + }else{ + ICLogger.i("mMyWifiListener is null skip callback"); + } - private StringBuilder handScanResults() { + } + private StringBuilder handleScanResults() { List aplist = this.wifiManager.getScanResults(); ICLogger.i("get Wifi Result "+aplist.size()); if (aplist.size() < 1) { @@ -169,121 +191,10 @@ public class LBSHelper { } private void delayedStopScan() { - mHandler.removeMessages(MsgWhat_GetWifiResult); - mHandler.sendEmptyMessageDelayed(MsgWhat_GetWifiResult,3000L); - } -// public void unRegisterWiFiBroadReceiver() { -// this.context.unregisterReceiver(this.wifiChangedReceiver); -// } - - public String getAttchCellInfo(TelephonyManager tm) { - return this.getCellInfo(tm); } - public String getCellInfo(TelephonyManager telephonyManager) { -// int var3 = Build.VERSION.SDK_INT; - int var2 = 0; - String var4; - if (Build.VERSION.SDK_INT > 23) { - var4 = telephonyManager.getSimOperator(); - if (var4 == null) { - ICLogger.i("operator == null"); - return null; - } - - var4 = var4.substring(0, 5); - } else { - var4 = telephonyManager.getNetworkOperator(); - } - - if (var4 != null && var4.length() > 3) { - - CellLocation celllocation = telephonyManager.getCellLocation(); - if (celllocation == null) { - ICLogger.i("cellLocation = null"); - return null; - } else { - StringBuilder gsmSb = new StringBuilder(var4); - StringBuilder mccmnc = new StringBuilder(var4); - StringBuilder cdmaSB = new StringBuilder(); - gsmSb.insert(3, "@"); - mccmnc.insert(3, "@"); - this.runtime.setMccAndMnc(mccmnc.toString()); - if (celllocation instanceof GsmCellLocation) { - GsmCellLocation gsmCell = (GsmCellLocation)celllocation; - gsmSb.append("@"); - gsmSb.append(gsmCell.getLac()); - gsmSb.append("@"); - gsmSb.append(gsmCell.getCid()); - gsmSb.append("@"); - gsmSb.append(this.mLastSignal); -// this.runtime.setCid(String.format("%03d",gsmCell.getCid())); -// this.runtime.setLAC(gsmCell.getLac()); - this.runtime.setCellinfo(gsmSb.toString()); - this.runtime.setCdmaInfo(null); - ICLogger.i("GsmCellLocation "+ gsmSb.toString()); - if (Config.LOG_TOFILE) ICLogger.logToFile("LBS", gsmSb.toString()); - - List neighboringCell_list = telephonyManager.getNeighboringCellInfo(); - if (neighboringCell_list != null && !neighboringCell_list.isEmpty()) { - Iterator cell = neighboringCell_list.iterator(); - - while(cell.hasNext()) { - NeighboringCellInfo mNeighboringCellInfo = (NeighboringCellInfo)cell.next(); - if (mNeighboringCellInfo.getLac() == -1) { - break; - } - - gsmSb.append("+"); - gsmSb.append(mccmnc); - gsmSb.append("@"); - gsmSb.append(mNeighboringCellInfo.getLac()); - gsmSb.append("@"); - gsmSb.append(mNeighboringCellInfo.getCid()); - gsmSb.append("@"); - gsmSb.append(mNeighboringCellInfo.getRssi() + 110); - var2 ++; - if (var2 == 5) { - break; - } - } - } - ICLogger.i("return "+ gsmSb.toString()); - return gsmSb.toString(); - } else if (celllocation instanceof CdmaCellLocation) { - CdmaCellLocation cdmaCelllocation = (CdmaCellLocation)celllocation; - cdmaSB.append(cdmaCelllocation.getSystemId()); - cdmaSB.append(","); - cdmaSB.append(cdmaCelllocation.getNetworkId()); - cdmaSB.append(","); - cdmaSB.append(cdmaCelllocation.getBaseStationId()); - cdmaSB.append(","); - cdmaSB.append(""); - cdmaSB.append(","); - cdmaSB.append(""); - cdmaSB.append(","); - cdmaSB.append(this.mLastSignal); - ICLogger.i("CdmaCellLocation"); - StringBuilder var8 = new StringBuilder(); - var8.append("CDMA_info="); - var8.append(cdmaSB.toString()); - ICLogger.i(var8.toString()); - this.runtime.setCellinfo(null); - this.runtime.setCdmaInfo(cdmaSB.toString()); - - if (Config.LOG_TOFILE) ICLogger.logToFile("LBS", var8.toString()); - return cdmaSB.toString(); - - } - - return null; - } - } else { - ICLogger.i("operator == null || operator.length() <= 3"); - return null; - } - } + private static int wait_count=0; public void getWifiInfo() { if (this.wifiManager.isWifiEnabled()) { @@ -297,10 +208,10 @@ public class LBSHelper { e.printStackTrace(); } } - + //wait_count=0; CurrentWiFiScanTimes=0; wifiManager.startScan(); - delayedStopScan(); +// delayedStopScan(); } @@ -320,17 +231,12 @@ public class LBSHelper { private MyPhoneStateListener() { } + @RequiresApi(api = Build.VERSION_CODES.M) public void onSignalStrengthsChanged(SignalStrength ss) { super.onSignalStrengthsChanged(ss); - if (((TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE)).getNetworkType() == NETWORK_TYPE_LTE) { - String[] siglist = ss.toString().split(" "); - mLastSignal = Integer.parseInt(siglist[9]) + 110; - } else { - mLastSignal = ss.getGsmSignalStrength() * 2 - 113 + 110; - } - runtime.setSignalStrength(mLastSignal - 110); -// mLastSignal = ss.getGsmSignalStrength();//ss.getDbm(); -// runtime.setSignalStrength(mLastSignal); + TelephonyManager tm=(TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE); + int gsmSignal= 150-Math.abs(CellInfoUtil.getSignal(tm,runtime)); + runtime.setSignalStrength(gsmSignal); } } diff --git a/app/src/main/java/com/enqualcomm/support/adapter/protocolAPIHelper.java b/app/src/main/java/com/enqualcomm/support/adapter/protocolAPIHelper.java index b3842f41..e3933c4f 100644 --- a/app/src/main/java/com/enqualcomm/support/adapter/protocolAPIHelper.java +++ b/app/src/main/java/com/enqualcomm/support/adapter/protocolAPIHelper.java @@ -401,11 +401,11 @@ public class protocolAPIHelper { // 9520|3671|10: LAC|CID|dbm表示一组基站信息,后面数量需和基站组数地应 10:dbm为信号强度多基站信号强度建议从高到低排列后上传,信号强度转正数:150 – abs(dbm) // 4: 表示WIFI组数, // 1|D8-24-BD-79-FA-1F|59: ssid|mac地址|信号强度,信号强度转正数:150 – abs(信号强度) - return new StringBuffer(CMDHEADER).append(cmdMap.get(CMD_TYPE.AP02)).append(TimeUtil.getShortDate()) - .append(ds.getGPSData()).append(TimeUtil.getShortTime()).append(ds.getGPSHeading()).append(String.format("%03d",abs(ds.getSignalStrength()))) - .append(ds.getGPSLocationStarNums()).append(ds.getBattery()).append("0") - .append(ds.getProtection()).append(ds.getWorkModeStr()).append(CMDSPLIT) - .append(ds.getLBSData()).append(CMDSPLIT).append(ds.getWifiInfo()).append(CMDEND).toString(); + return new StringBuffer(CMDHEADER).append(cmdMap.get(CMD_TYPE.AP02)).append(CMDSPLIT) + .append(ds.getLanguage()).append(CMDSPLIT) + .append(0).append(CMDSPLIT) //为0时不回复地址 + .append(ds.getLBSMultiStationData()).append(CMDSPLIT) //基站信息数据 + .append(4).append(CMDSPLIT).append(ds.getWifiInfo()).append(CMDEND).toString(); //wifi信息数据 } //处理 定位 BP01 diff --git a/app/src/main/java/com/enqualcomm/support/bean/Runtime.java b/app/src/main/java/com/enqualcomm/support/bean/Runtime.java index c6d820b9..38c9aa94 100644 --- a/app/src/main/java/com/enqualcomm/support/bean/Runtime.java +++ b/app/src/main/java/com/enqualcomm/support/bean/Runtime.java @@ -290,7 +290,11 @@ public class Runtime { public int getSignalStrength() { return this.SignalStrength; } - + private String SignalInfo=""; + public void setSignalInfo(String info){ + this.SignalInfo=info; + } + public String getSignalInfo() { return this.SignalInfo; } public long getTimestamp() { return this.timestamp; } public int getTotalStepCount() { return this.totalStepCount; } @@ -502,6 +506,19 @@ public class Runtime { return gpsStr; } + private static String mLBSMultiStationData=""; + public void setLBSMultiStationData(String data){ + mLBSMultiStationData=data; + } + //AP03 用的多基站定位数据 + public String getLBSMultiStationData(){ + // 7: 表示共有7组基站 +// 460: MCC 国家码 +// 0: MNC运营商代码 +// 9520|3671|10: LAC|CID|dbm表示一组基站信息,后面数量需和基站组数地应 10:dbm为信号强度多基站信号强度建议从高到低排列后上传,信号强度转正数:150 – abs(dbm) + return mLBSMultiStationData; + } + public String getLBSData(){ diff --git a/app/src/main/java/com/enqualcomm/support/utils/BatteryUtil.java b/app/src/main/java/com/enqualcomm/support/utils/BatteryUtil.java index b50756a1..4e0ad431 100644 --- a/app/src/main/java/com/enqualcomm/support/utils/BatteryUtil.java +++ b/app/src/main/java/com/enqualcomm/support/utils/BatteryUtil.java @@ -15,100 +15,94 @@ import com.enqualcomm.support.adapter.protocolAPIHelper; import com.enqualcomm.support.bean.Runtime; import static android.content.Context.BATTERY_SERVICE; +import static android.os.BatteryManager.BATTERY_STATUS_CHARGING; +import static android.os.BatteryManager.BATTERY_STATUS_DISCHARGING; +import static android.os.BatteryManager.BATTERY_STATUS_FULL; +import static android.os.BatteryManager.BATTERY_STATUS_NOT_CHARGING; +import static android.os.BatteryManager.BATTERY_STATUS_UNKNOWN; import static android.os.BatteryManager.EXTRA_LEVEL; import static android.os.BatteryManager.EXTRA_SCALE; +import static android.os.BatteryManager.EXTRA_STATUS; import static android.os.BatteryManager.EXTRA_VOLTAGE; import static com.enqualcomm.support.Constants.ACTION_BATTERY_LOW_MSG; public class BatteryUtil { private BroadcastReceiver batteryChangedReceiver = new BroadcastReceiver() { - public void onReceive(Context param1Context, Intent param1Intent) { - if (Intent.ACTION_BATTERY_CHANGED.equals(param1Intent.getAction())) { - if (param1Intent.getIntExtra("status", 1) == 2) { - BatteryUtil.this.mRuntime.setBatterychanging(true); - BatteryUtil.this.mRuntime.setBatteryLow(false); + public void onReceive(Context param1Context, Intent intent) { + if (Intent.ACTION_BATTERY_CHANGED.equals(intent.getAction())) { + int extra_status = intent.getIntExtra(EXTRA_STATUS , BATTERY_STATUS_UNKNOWN ); + StringBuilder msg=new StringBuilder("EXTRA_STATUS = "); + switch (extra_status){ + case BATTERY_STATUS_CHARGING: + msg.append("BATTERY_STATUS_CHARGING "); + break; + case BATTERY_STATUS_UNKNOWN: + msg.append("BATTERY_STATUS_UNKNOWN "); + break; + case BATTERY_STATUS_DISCHARGING: + msg.append("BATTERY_STATUS_DISCHARGING "); + break; + case BATTERY_STATUS_FULL: + msg.append("BATTERY_STATUS_FULL "); + break; + case BATTERY_STATUS_NOT_CHARGING: + msg.append("BATTERY_STATUS_NOT_CHARGING "); + break; + + } + msg.append("; "); + if (extra_status == BATTERY_STATUS_CHARGING) { + mRuntime.setBatterychanging(true); + mRuntime.setBatteryLow(false); } else { - BatteryUtil.this.mRuntime.setBatterychanging(false); + mRuntime.setBatterychanging(false); } - int i = param1Intent.getIntExtra(EXTRA_LEVEL, 0) * 100 / param1Intent.getIntExtra(EXTRA_SCALE, 100); + int batLevel = intent.getIntExtra(EXTRA_LEVEL, 0) * 100 / intent.getIntExtra(EXTRA_SCALE, 100); // 当前电池电压 - int batteryVolt = param1Intent.getIntExtra(EXTRA_VOLTAGE, -1); - BatteryUtil.this.mRuntime.setBatteryVoltage(batteryVolt); - ICLogger.i("BatteryLevel "+i + " BatteryVotage "+batteryVolt); - if (Config.LOG_TOFILE)ICLogger.logToFile("Battery","BatteryLevel "+i + " BatteryVotage "+batteryVolt); - if (i >= 100) { - Runtime runtime = BatteryUtil.this.mRuntime; - StringBuffer stringBuffer = BatteryUtil.this.mBuffer; - stringBuffer.append("005"); - stringBuffer.append(100); - runtime.setBattery(String.format("%03d",100)); - BatteryUtil.this.mRuntime.setHaveBatteryChange(false); - BatteryUtil.this.mRuntime.setBatteryLow(false); - } else if (i >= 75) { - Runtime runtime = BatteryUtil.this.mRuntime; - StringBuffer stringBuffer = BatteryUtil.this.mBuffer; -// stringBuffer.append("050"); -// stringBuffer.append(i); -// runtime.setBattery(stringBuffer.toString()); - runtime.setBattery(String.format("%03d",i)); - BatteryUtil.this.mRuntime.setHaveBatteryChange(false); - BatteryUtil.this.mRuntime.setBatteryLow(false); - } else if (i >= 50) { - Runtime runtime = BatteryUtil.this.mRuntime; - StringBuffer stringBuffer = BatteryUtil.this.mBuffer; -// stringBuffer.append("040"); -// stringBuffer.append(i); -// runtime.setBattery(stringBuffer.toString()); - runtime.setBattery(String.format("%03d",i)); - BatteryUtil.this.mRuntime.setHaveBatteryChange(false); - BatteryUtil.this.mRuntime.setBatteryLow(false); - } else if (i >= 25) { - Runtime runtime = BatteryUtil.this.mRuntime; - StringBuffer stringBuffer = BatteryUtil.this.mBuffer; -// stringBuffer.append("030"); -// stringBuffer.append(i); -// runtime.setBattery(stringBuffer.toString()); - runtime.setBattery(String.format("%03d",i)); - BatteryUtil.this.mRuntime.setHaveBatteryChange(false); - BatteryUtil.this.mRuntime.setBatteryLow(false); - } else if (i >= 10) { - Runtime runtime = BatteryUtil.this.mRuntime; - StringBuffer stringBuffer = BatteryUtil.this.mBuffer; -// stringBuffer.append("020"); -// stringBuffer.append(i); -// runtime.setBattery(stringBuffer.toString()); - runtime.setBattery(String.format("%03d",i)); - BatteryUtil.this.mRuntime.setHaveBatteryChange(true); + int batteryVolt = intent.getIntExtra(EXTRA_VOLTAGE, -1); + mRuntime.setBatteryVoltage(batteryVolt); + msg.append("BatteryLevel "+batLevel + " BatteryVotage "+batteryVolt+"; "); + if (Config.LOG_TOFILE)ICLogger.logToFile("Battery",msg.toString()); + ICLogger.i(msg.toString()); + if (batLevel >= 100) { + mRuntime.setBattery(String.format("%03d",100)); + mRuntime.setHaveBatteryChange(false); + mRuntime.setBatteryLow(false); + } else if (batLevel<100 && batLevel >= 25) { + mRuntime.setBattery(String.format("%03d",batLevel)); + mRuntime.setHaveBatteryChange(false); + mRuntime.setBatteryLow(false); + } else if (batLevel<25 && batLevel >= 5) { + mRuntime.setBattery(String.format("%03d",batLevel)); + mRuntime.setHaveBatteryChange(true); } else { - Runtime runtime = BatteryUtil.this.mRuntime; - StringBuffer stringBuffer = BatteryUtil.this.mBuffer; -// stringBuffer.append("100"); -// stringBuffer.append(i); -// runtime.setBattery(stringBuffer.toString()); - runtime.setBattery(String.format("%03d",i)); - BatteryUtil.this.mRuntime.setHaveBatteryChange(true); + mRuntime.setBattery(String.format("%03d",batLevel)); + mRuntime.setHaveBatteryChange(true); + mRuntime.setBatteryLow(true); + + if (Config.LOG_TOFILE) ICLogger.logToFile("Battery","BatteryLow !"); + mRuntime.setAlarmType(false,mRuntime.getBatteryLow(),false,false); + //trigger AP10 报警定位 + connection.send(protocolAPIHelper.genStringMessage("AP10",protocolAPIHelper.AP10(mRuntime))); } - BatteryUtil.this.mBuffer.setLength(0); - }else if (Intent.ACTION_BATTERY_LOW.equals(param1Intent.getAction())) { - BatteryUtil.this.mRuntime.setBatteryLow(true); - ICLogger.i("lowbattery finish video_end_call"); - if (Config.LOG_TOFILE) ICLogger.logToFile("Battery","BatteryLow !"); + }else if (Intent.ACTION_BATTERY_LOW.equals(intent.getAction())) { + mRuntime.setBatteryLow(true); + if (Config.LOG_TOFILE) ICLogger.logToFile("Battery","BatteryLow !"); mRuntime.setAlarmType(false,mRuntime.getBatteryLow(),false,false); //trigger AP10 报警定位 connection.send(protocolAPIHelper.genStringMessage("AP10",protocolAPIHelper.AP10(mRuntime))); - }else if (Intent.ACTION_BATTERY_OKAY.equals(param1Intent.getAction())){ - + }else if (Intent.ACTION_BATTERY_OKAY.equals(intent.getAction())){ ICLogger.i("Battery OKAY !"); if (Config.LOG_TOFILE) ICLogger.logToFile("Battery","Battery OKAY !"); - }else if (Intent.ACTION_POWER_CONNECTED.equals(param1Intent.getAction())){ + }else if (Intent.ACTION_POWER_CONNECTED.equals(intent.getAction())){ ICLogger.i("ACTION_POWER_CONNECTED !"); mRuntime.setPowerConnected(true); if (Config.LOG_TOFILE) ICLogger.logToFile("Battery","ACTION_POWER_CONNECTED!"); - }else if (Intent.ACTION_POWER_DISCONNECTED.equals(param1Intent.getAction())){ + }else if (Intent.ACTION_POWER_DISCONNECTED.equals(intent.getAction())){ ICLogger.i("ACTION_POWER_DISCONNECTED!"); mRuntime.setPowerConnected(false); if (Config.LOG_TOFILE) ICLogger.logToFile("Battery","ACTION_POWER_DISCONNECTED !"); @@ -127,10 +121,10 @@ public class BatteryUtil { } public void registerBroadReceiver() { - this.mBuffer = new StringBuffer(); IntentFilter intentFilter = new IntentFilter(); intentFilter.addAction(Intent.ACTION_BATTERY_CHANGED); intentFilter.addAction(Intent.ACTION_BATTERY_LOW); + intentFilter.addAction(Intent.ACTION_BATTERY_OKAY); intentFilter.addAction(Intent.ACTION_POWER_CONNECTED); intentFilter.addAction(Intent.ACTION_POWER_DISCONNECTED); (this.mRuntime.getContextProxy()).context.registerReceiver(this.batteryChangedReceiver, intentFilter); @@ -155,8 +149,8 @@ public class BatteryUtil { //你可以读到充电状态,如果在充电,可以读到是usb还是交流电 // 是否在充电 - int status = batteryStatus.getIntExtra(BatteryManager.EXTRA_STATUS, -1); - boolean isCharging = status == BatteryManager.BATTERY_STATUS_CHARGING ;//|| status == BatteryManager.BATTERY_STATUS_FULL; + int status = batteryStatus.getIntExtra(EXTRA_STATUS, -1); + boolean isCharging = status == BATTERY_STATUS_CHARGING ;//|| status == BatteryManager.BATTERY_STATUS_FULL; return isCharging; } diff --git a/app/src/main/java/com/enqualcomm/support/utils/CellInfoUtil.java b/app/src/main/java/com/enqualcomm/support/utils/CellInfoUtil.java index 67e6513c..a30ff016 100644 --- a/app/src/main/java/com/enqualcomm/support/utils/CellInfoUtil.java +++ b/app/src/main/java/com/enqualcomm/support/utils/CellInfoUtil.java @@ -1,155 +1,221 @@ package com.enqualcomm.support.utils; +import android.os.Build; import android.os.Handler; import android.os.Message; import android.os.PowerManager; +import android.telephony.CellInfo; +import android.telephony.CellInfoCdma; +import android.telephony.CellInfoGsm; +import android.telephony.CellInfoLte; +import android.telephony.CellInfoWcdma; +import android.telephony.CellLocation; +import android.telephony.CellSignalStrengthCdma; +import android.telephony.CellSignalStrengthGsm; +import android.telephony.CellSignalStrengthLte; +import android.telephony.CellSignalStrengthWcdma; +import android.telephony.NeighboringCellInfo; +import android.telephony.TelephonyManager; +import android.telephony.cdma.CdmaCellLocation; +import android.telephony.gsm.GsmCellLocation; import com.enqualcomm.support.Config; import com.enqualcomm.support.GSensorListener; import com.enqualcomm.support.bean.Runtime; -public class CellInfoUtil { - static int BSSS = 0; - - static int CELL_ID = 0; - - private static int IS2SECOND = 2; - - static int LAC = 0; - - static int MCC = 0; - - static int MNC = 0; - - - public static int getLAC(){return LAC;}; - public static int getBSSS(){return BSSS;}; - public static int getCELL_ID(){return CELL_ID;}; - public static int getMCC(){return MCC;}; - public static int getMNC(){return MNC;}; - public static boolean getCellInfoOver = false; - - private static String mCellInfo; - - public static String getCellInfo(){return mCellInfo;} - public static Handler mHandler = new Handler() { - public void handleMessage(Message param1Message) { - super.handleMessage(param1Message); - if (param1Message.what != 100) - return; - ICLogger.i("延时获取基站信息"); - - CellInfoUtil.setCurrentAttachCellInfo(mRuntime, mWakeLock); +import java.util.Collections; +import java.util.Comparator; +import java.util.Iterator; +import java.util.List; +public class CellInfoUtil { + public static int getSignal(TelephonyManager tm , Runtime runtime){ + 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; } - }; - - - public static void triggerUpdateCellinfo(){ - mHandler.sendEmptyMessageDelayed(100,2000); + return 4; + } } - private static Runtime mRuntime; - - private static PowerManager.WakeLock mWakeLock; - - private static void releaseWakeLock(PowerManager.WakeLock paramWakeLock) { - if (paramWakeLock == null) { - ICLogger.i("cellInfo 没有加锁"); - return; - } - if (GSensorListener.getStepCountOver) { - if (paramWakeLock.isHeld()) { - getCellInfoOver = false; - GSensorListener.getStepCountOver = false; - paramWakeLock.release(); - return; - } + public static String getCellInfo(TelephonyManager telephonyManager, Runtime runtime) { + ICLogger.i("LBS 延时获取基站信息"); + 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 { - getCellInfoOver = true; - } + mccmnc = telephonyManager.getNetworkOperator(); + } + ICLogger.i("LBS mccmnc "+mccmnc); + + if (mccmnc != null && mccmnc.length() > 3) { + + CellLocation celllocation = telephonyManager.getCellLocation(); + if (celllocation == null) { + ICLogger.i("LBS cellLocation = null"); + return null; + } else { + StringBuilder gsmSb = new StringBuilder(mccmnc); + + StringBuilder cdmaSB = new StringBuilder(); + gsmSb.insert(3, ","); + runtime.setMccAndMnc(gsmSb.toString()); + 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()); + + ICLogger.i("LBS GsmCellLocation "+ gsmSb.toString()); + if (Config.LOG_TOFILE) ICLogger.logToFile("LBS", gsmSb.toString()); + + List neighboringCell_list = telephonyManager.getNeighboringCellInfo(); + //AP02 Multi GSM Station + StringBuilder gsmSbMulti = new StringBuilder(); + int size=1; + if (neighboringCell_list != null && !neighboringCell_list.isEmpty()) + size +=neighboringCell_list.size(); + StringBuilder mmcmnc1 = new StringBuilder(mccmnc); + mmcmnc1.insert(3, ","); + gsmSbMulti.append(size); + gsmSbMulti.append(","); + gsmSbMulti.append(mmcmnc1); + gsmSbMulti.append(","); + gsmSbMulti.append(gsmCell.getLac()); + gsmSbMulti.append("|"); + gsmSbMulti.append(gsmCell.getCid()); + gsmSbMulti.append("|"); + gsmSbMulti.append(150-Math.abs(getSignal(telephonyManager,runtime))); + 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.append(","); + gsmSbMulti.append(mNeighboringCellInfo.getLac()); + gsmSbMulti.append("|"); + gsmSbMulti.append(mNeighboringCellInfo.getCid()); + gsmSbMulti.append("|"); + gsmSbMulti.append( 150-Math.abs(mNeighboringCellInfo.getRssi())); + maxstationCount ++; + if (maxstationCount == 5) { +// break; + } + } + } + ICLogger.i("LBS GsmCellLocation MultiStation "+ gsmSbMulti.toString()); + if (Config.LOG_TOFILE) ICLogger.logToFile("LBS", gsmSbMulti.toString()); + + runtime.setLBSMultiStationData(gsmSbMulti.toString()); + + return gsmSb.toString(); + } else if (celllocation instanceof CdmaCellLocation) { + CdmaCellLocation cdmaCelllocation = (CdmaCellLocation)celllocation; + cdmaSB.append(cdmaCelllocation.getSystemId()); + cdmaSB.append(","); + cdmaSB.append(cdmaCelllocation.getNetworkId()); + cdmaSB.append(","); + cdmaSB.append(cdmaCelllocation.getBaseStationId()); + cdmaSB.append(","); + cdmaSB.append(""); + cdmaSB.append(","); + cdmaSB.append(""); + cdmaSB.append(","); + cdmaSB.append(getSignal(telephonyManager,runtime)); + ICLogger.i("CdmaCellLocation"); + StringBuilder var8 = new StringBuilder(); + var8.append("CDMA_info="); + var8.append(cdmaSB.toString()); + ICLogger.i(var8.toString()); + runtime.setCellinfo(null); + runtime.setCdmaInfo(cdmaSB.toString()); + + if (Config.LOG_TOFILE) ICLogger.logToFile("LBS", var8.toString()); + return cdmaSB.toString(); + + } + + return null; + } + } else { + ICLogger.i("operator == null || operator.length() <= 3"); + return null; + } } - - public static void removeMessage() { mHandler.removeCallbacksAndMessages(null); } - - public static void setCurrentAttachCellInfo(Runtime dev, PowerManager.WakeLock paramWakeLock) { - mWakeLock = paramWakeLock; - mRuntime = dev; + private static void sortByRssi(List var1) { + Collections.sort(var1, new Comparator() { + public int compare(NeighboringCellInfo var1, NeighboringCellInfo var2) { + return var2.getRssi() - var1.getRssi(); + } + }); + } + public static void setCurrentAttachCellInfo(Runtime dev) { + (new Thread(new Runnable() { public void run() { - if (mRuntime !=null) { - + if (dev !=null) { //更新lbs信息 - CellInfoUtil.mCellInfo = mRuntime.getLbsHelper().getAttchCellInfo(mRuntime.getContextProxy().getTelephonyManager()); - - if (mCellInfo != null) { - String str1 = mRuntime.getCdmaInfo(); - String str2 = mRuntime.getMccAndMnc(); - if (str1 != null) { - String[] arrayOfString2 = str2.split("@"); - String[] arrayOfString1 = str1.split(","); - CellInfoUtil.MCC = Integer.parseInt(arrayOfString2[0]); - CellInfoUtil.MNC = Integer.parseInt(arrayOfString2[1]); - int i = Integer.parseInt(arrayOfString1[0]); - int j = Integer.parseInt(arrayOfString1[1]); - int k = Integer.parseInt(arrayOfString1[2]); - CellInfoUtil.BSSS = Integer.parseInt(arrayOfString1[5]); - - CellInfoUtil.releaseWakeLock(mWakeLock); - } else { - - String[] stationlist = mCellInfo.split("\\+"); - if (stationlist.length>0 ) { - String[] arrayOfString = stationlist[0].split("@"); - CellInfoUtil.MCC = Integer.parseInt(arrayOfString[0]); - CellInfoUtil.MNC = Integer.parseInt(arrayOfString[1]); - CellInfoUtil.LAC = Integer.parseInt(arrayOfString[2]); - CellInfoUtil.CELL_ID = Integer.parseInt(arrayOfString[3]); - CellInfoUtil.BSSS = Integer.parseInt(arrayOfString[4]); - CellInfoUtil.IS2SECOND = 2; - } - } - if (Config.LOG_TOFILE)ICLogger.logToFile("LBS", mCellInfo); - CellInfoUtil.releaseWakeLock(mWakeLock); - ICLogger.i(" setCurrentAttachCellInfo " + mCellInfo); - - } - if (IS2SECOND <= 0) { - CellInfoUtil.MCC = 0; - CellInfoUtil.MNC = 0; - CellInfoUtil.LAC = 0; - CellInfoUtil.CELL_ID = -1; - CellInfoUtil.BSSS = 0; -// CellInfoUtil.access$002(2); - CellInfoUtil.IS2SECOND = 2; - Runtime runtime = mRuntime; - StringBuilder stringBuilder = new StringBuilder(); - stringBuilder.append(CellInfoUtil.MCC); - stringBuilder.append("@"); - stringBuilder.append(CellInfoUtil.MNC); - stringBuilder.append("@"); - stringBuilder.append(CellInfoUtil.LAC); - stringBuilder.append("@"); - stringBuilder.append(CellInfoUtil.CELL_ID); - stringBuilder.append("@"); - stringBuilder.append(CellInfoUtil.BSSS); - - runtime.setCurrentCellInfo(stringBuilder.toString()); - -// EqcAlgorithmNative.native_EqcAlgorithmMethod4(1, 0, CellInfoUtil.BSSS, CellInfoUtil.MCC, CellInfoUtil.MNC, CellInfoUtil.LAC, CellInfoUtil.CELL_ID); - if (Config.LOG_TOFILE) ICLogger.logToFile("LBS", mRuntime.getCurrentCellInfo()); - - CellInfoUtil.releaseWakeLock(mWakeLock); - ICLogger.i(" setCurrentAttachCellInfo " + mCellInfo); + getCellInfo(dev.getContextProxy().getTelephonyManager(),dev); - } - mRuntime.getLocationInstance().setMNC(String.valueOf(CellInfoUtil.getMNC())); - mRuntime.getLocationInstance().setCID(CellInfoUtil.getCELL_ID()); - mRuntime.getLocationInstance().setMCC(String.valueOf(CellInfoUtil.getMCC())); - mRuntime.getLocationInstance().setLAC(CellInfoUtil.getLAC()); - mRuntime.preCellInfo = CellInfoUtil.getCellInfo(); } + } })).start(); } diff --git a/app/src/main/java/com/enqualcomm/support/utils/DeviceInfoUtil.java b/app/src/main/java/com/enqualcomm/support/utils/DeviceInfoUtil.java index 471b852b..66ad5baf 100644 --- a/app/src/main/java/com/enqualcomm/support/utils/DeviceInfoUtil.java +++ b/app/src/main/java/com/enqualcomm/support/utils/DeviceInfoUtil.java @@ -226,7 +226,7 @@ public class DeviceInfoUtil { .append(DeviceInfoUtil.getVersionCode(runtime.getContextProxy().context)) .append(SimSignalUtil.hasSimCard(runtime.getContextProxy().context)?" SIM ":" NoSIM ") .append(sim.getNetworkType()==SimSignalUtil.IS_2G?"2G":(sim.getNetworkType()==SimSignalUtil.IS_3G)?"3G":(sim.getNetworkType()==SimSignalUtil.IS_4G?"4G":"unknown")) - .append(" [").append(runtime.getSignalStrength()).append(",Mini:").append(SimSignalUtil.getMinSignalStrength(sim.getNetworkType())).append("] ") + .append(" [").append(runtime.getSignalStrength()).append(",").append(runtime.getSignalInfo()).append("] ") .append(runtime.IMEI()) .append("\n SocketConnection ").append(KeepAlive.isConnected).append(" , HBcycle ").append(runtime.getHeartBeatCycle()) .append("\n ServerConnected is ").append(runtime.isServerProtocolConnected()) @@ -243,6 +243,7 @@ public class DeviceInfoUtil { .append(",bpl ").append(runtime.getHRS().getBPL()) .append(" at ").append(runtime.getHRS().getTestTime()) .append("\nrealimei:").append(PhoneUtils.getIMEI(runtime.getContextProxy().context)) + .append("\n").append(runtime.getLBSMultiStationData()) .toString(); } public static String getShortDeviceInfo(Runtime runtime){ @@ -277,4 +278,43 @@ public class DeviceInfoUtil { } public static void setLockSimInfo(Context paramContext) { Settings.System.putInt(paramContext.getContentResolver(), "com.eqc.watch.launcher.SimIsBlocked", 1); } + + private static String[][] packagelist={ + {"com.enqualcomm.support","Protocol"}, + {"com.ic.blood","BLood"}, + {"com.ic.launcher","Launcher"}, + {"com.ic.work","Work"}, + {"com.ic.weather","Weather"}, + {"com.ic.hardware","Hardware"}, + {"mobile.miki","FactoryMode"}, + {"com.ic.dial","Dialer"}, + {"android.rockchip.update.service","Fota"} + }; + + public static String getPackageVersionName(Context context , String packagename) { + String versionName = ""; + try { + PackageManager pm = context.getPackageManager(); + PackageInfo pi = pm.getPackageInfo(packagename, 0); + versionName = "V"+pi.versionCode; + if (versionName == null || versionName.length() <= 0) { + return ""; + } + } catch (Exception e) { + e.printStackTrace(); + } + return versionName; + } + + public static String getPackageVersions(Context context){ + StringBuilder versions=new StringBuilder(); + versions.append(getSWVersionDisplayName()).append(","); + for (String[] packagename: packagelist){ + versions.append(packagename[1]); + versions.append("-"); + versions.append( getPackageVersionName(context,packagename[0])); + versions.append(","); + } + return versions.toString(); + } } diff --git a/app/src/main/java/com/enqualcomm/support/utils/NettyConnection.java b/app/src/main/java/com/enqualcomm/support/utils/NettyConnection.java index 0d248c1c..fcc4cc50 100644 --- a/app/src/main/java/com/enqualcomm/support/utils/NettyConnection.java +++ b/app/src/main/java/com/enqualcomm/support/utils/NettyConnection.java @@ -63,6 +63,10 @@ public class NettyConnection implements Connection { API.handleBP01(cmd); ICLogger.i("服务器收到定位AP01"); break; + case BP02: + API.handleBP02(cmd); + ICLogger.i("服务器收到定位AP02"); + break; case BP03: API.handleBP03(cmd); ICLogger.i("服务器收到心跳包AP03"); diff --git a/app/src/main/java/com/enqualcomm/support/utils/SimSignalUtil.java b/app/src/main/java/com/enqualcomm/support/utils/SimSignalUtil.java index c5d0a9ea..0572ac85 100644 --- a/app/src/main/java/com/enqualcomm/support/utils/SimSignalUtil.java +++ b/app/src/main/java/com/enqualcomm/support/utils/SimSignalUtil.java @@ -64,20 +64,7 @@ public class SimSignalUtil { stringBuilder.append(paramInt2); ICLogger.i(stringBuilder.toString()); } - public static int getMinSignalStrength(int NetworkType) { - byte b2 = -105; - switch (NetworkType) { - case SimSignalUtil.IS_2G: - case SimSignalUtil.IS_3G: - break; - case SimSignalUtil.IS_4G: - b2 = -100; - break; - default: - break; - } - return b2; - } + public static boolean hasSimCard(Context context) { TelephonyManager telMgr = (TelephonyManager) diff --git a/app/version_code.properties b/app/version_code.properties index 69d4d431..51299841 100644 --- a/app/version_code.properties +++ b/app/version_code.properties @@ -1,2 +1,2 @@ -#Fri Apr 10 11:16:37 CST 2020 -VERSION_CODE=397 +#Sat Apr 11 15:09:19 CST 2020 +VERSION_CODE=398