From: snickersun Date: Tue, 10 Mar 2020 16:38:10 +0000 (+0800) Subject: 1、修改GPS 定位解析方式,采用NMEA进行解析,以便解决定位状态一直获取不到的问题。 X-Git-Url: http://git.snicker.com.cn/sitemap.xml?a=commitdiff_plain;h=2b849113101a184b8f074d0fecf4edea21c4643d;p=icsupport.git 1、修改GPS 定位解析方式,采用NMEA进行解析,以便解决定位状态一直获取不到的问题。 2、修改界面,增加调试button,可以上传日志,设置工作模式1,3,5 3、短信修改:修复wifi关闭时不能短信设置链接方式的问题。添加wifi息屏不关机选项。 4、添加活动Activity判断,如果在进行工厂测试,则停止操作GPS,以防测试冲突。 --- diff --git a/app/build.gradle b/app/build.gradle index bbc4d72d..539d7c72 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -84,12 +84,13 @@ android { // } } 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', { exclude group: 'com.android.support', module: 'support-annotations' }) - compile 'com.android.support:appcompat-v7:25.1.0' - compile 'com.github.ChestnutPlus:TestModules:v1.0.16' + implementation 'com.android.support:appcompat-v7:25.1.0' + implementation 'com.github.ChestnutPlus:TestModules:v1.0.16' testCompile 'junit:junit:4.12' implementation project(path: ':dNSCache') } @@ -117,4 +118,4 @@ def releaseTime() { return new Date().format("yyMMddHHmm", TimeZone.getTimeZone("GMT+08:00")) -} \ No newline at end of file +} diff --git a/app/release/ICSer_V372_2003091732_release.apk b/app/release/ICSer_V372_2003091732_release.apk deleted file mode 100644 index 88f36ea8..00000000 Binary files a/app/release/ICSer_V372_2003091732_release.apk and /dev/null differ diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index 6166794b..b1e1d142 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -1,122 +1,97 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + android:sharedUserId="android.uid.system" + android:supportsRtl="true"> + + + + + + + + + + + + + + + + + + + + + - + - - - + + - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - - - - - + + + + + + + + - + + @@ -132,41 +108,43 @@ - + - + + android:exported="true" /> - + - + - + - - - - - - - - - - + + + + + + + + + + - - \ No newline at end of file diff --git a/app/src/main/java/com/enqualcomm/support/CoreService.java b/app/src/main/java/com/enqualcomm/support/CoreService.java index 0abe58b4..95cfe5e7 100644 --- a/app/src/main/java/com/enqualcomm/support/CoreService.java +++ b/app/src/main/java/com/enqualcomm/support/CoreService.java @@ -319,7 +319,10 @@ public class CoreService extends Service { } } else if ("android.intent.action.SCREEN_OFF".equals(param1Intent.getAction()) && Util.isWifiIsOpen(runtime.getContextProxy().context,runtime)) { CoreService.is_wifi_network_ok = true; - Util.turnOffWifiForSleep(runtime.getContextProxy().context, runtime); + if (!runtime.isNoTurnOffWifiOnScreenOff()) { + //不关闭wifi when ScreenOff + Util.turnOffWifiForSleep(runtime.getContextProxy().context, runtime); + } } } }; diff --git a/app/src/main/java/com/enqualcomm/support/ICSmsManager.java b/app/src/main/java/com/enqualcomm/support/ICSmsManager.java index 6d05ce58..307bcc4b 100644 --- a/app/src/main/java/com/enqualcomm/support/ICSmsManager.java +++ b/app/src/main/java/com/enqualcomm/support/ICSmsManager.java @@ -352,8 +352,25 @@ public class ICSmsManager { }); }else { + sendSMS(phonenumber, "WiFi Control format error!"); + } + } else if (tmp[1].startsWith("noTurnOffWhenScreenOff,")) { + + String tmplist[]=tmp[1].split(","); + if (tmplist.length==2){ + String enabled=tmplist[1]; + boolean isenabled=enabled.toLowerCase().equals("true")?true:false; + runtime.setNoTurnOffOnScreenOff(isenabled); + StringBuilder sb=new StringBuilder(); + if (isenabled && !Util.isWifiIsOpen(runtime.getContextProxy().context,runtime)){ + Util.turnOnWifiForConnect(runtime.getContextProxy().context,runtime); + sb.append(" Turn On Wifi first and "); + } + sb.append("set noTurnOffWhenScreenOff " + enabled); + sendSMS(phonenumber,sb.toString() ); - sendSMS(phonenumber, "set SkipMoveCheck " + LocationClient.getSkipMoveCheck() + " success!"); + }else { + sendSMS(phonenumber, "WiFi Control format error!"); } } else { sendSMS(phonenumber, "WiFi Control format error!"); @@ -426,7 +443,7 @@ public class ICSmsManager { } } }); - }else if (!logfile.isEmpty()&& logfile.startsWith("SDLog:")){ + }else if (!logfile.isEmpty()&& ( logfile.startsWith("SDLog:")||logfile.startsWith("SDLogInfo:"))){ String sdfilelist[] = logfile.split(":"); if (sdfilelist.length==2) { @@ -442,30 +459,51 @@ public class ICSmsManager { } if ( new File(filepath).exists()) { - sendSMS(phonenumber, "start Upload " + filepath + " to " + Config.getFtpServer(mContext) + " ..."); + sendSMS(phonenumber,"start Upload " + filepath + " to " + Config.getFtpServer(mContext) + " ..."); + + if (logfile.startsWith("SDLogInfo:")){ + Util.ShowToast(runtime,"start Upload " + filepath + " to " + Config.getFtpServer(mContext) + " ..."); + } String logtime = TimeUtil.getSystemTime3(); if (upload_logs_via_ftp) { if (ftpUtils.upload(serverurl, Config.getFtpUser(mContext), Config.getFtpPWD(mContext), new File(filepath))) { sendSMS(phonenumber, "Upload " + filepath + " to " + Config.getFtpServer(mContext) + " success!"); + + if (logfile.startsWith("SDLogInfo:")){ + Util.ShowToast(runtime,"Upload " + filepath + " to " + Config.getFtpServer(mContext) + " success!"); + } } else { sendSMS(phonenumber, "Upload " + filepath + " to " + Config.getFtpServer(mContext) + " failed!"); + if (logfile.startsWith("SDLogInfo:")){ + Util.ShowToast(runtime,"Upload " + filepath + " to " + Config.getFtpServer(mContext) + " failed!"); + } } } else { if (ICHttpUtil.uploadFile(filepath, runtime, logtime)) { sendSMS(phonenumber, "Upload " + filepath + " to " + Config.getFtpServer(mContext) + " success!"); + if (logfile.startsWith("SDLogInfo:")){ + Util.ShowToast(runtime,"Upload " + filepath + " to " + Config.getFtpServer(mContext) + " success!"); + } } else { sendSMS(phonenumber, "Upload " + filepath + " to " + Config.getFtpServer(mContext) + " failed!"); + if (logfile.startsWith("SDLogInfo:")){ + Util.ShowToast(runtime,"Upload " + filepath + " to " + Config.getFtpServer(mContext) + " failed!"); + } } } } else { sendSMS(phonenumber, filepath + " not exist !"); + if (logfile.startsWith("SDLogInfo:")){ + Util.ShowToast(runtime,filepath + " not exist !"); + } } } }); }else{ sendSMS(phonenumber, " SDLog format error !"); } + }else{ Observable.timer(500L, TimeUnit.MILLISECONDS).subscribe(new Action1() { public void call(Long param1Long) { diff --git a/app/src/main/java/com/enqualcomm/support/LocationClient.java b/app/src/main/java/com/enqualcomm/support/LocationClient.java index 059ce5f6..d9c48f05 100644 --- a/app/src/main/java/com/enqualcomm/support/LocationClient.java +++ b/app/src/main/java/com/enqualcomm/support/LocationClient.java @@ -216,11 +216,17 @@ public class LocationClient { public void startGpsLocate() { ICLogger.i("开启GPS扫描"); runtime.getLocationInstance().setLocationStat( ICLocation.LOCATION_STAT.LOCATION_OPEN); //此处为了检测是否定位时可以正确识别状态,以防一直处于GPS定位成功状态 - Settings.Secure.setLocationProviderEnabled(runtime.getContextProxy().getResolver(), GPS_PROVIDER, true); - Single.just(null).observeOn(AndroidSchedulers.mainThread()).subscribe(new Action1() { - public void call(Object param1Object) { LocationClient.this.nmeaListener.startListen(); } - }); + //防止与工厂测试冲突 + if (!DeviceInfoUtil.isFactoryTestTopActivity(runtime.getContextProxy().context)) { + + Settings.Secure.setLocationProviderEnabled(runtime.getContextProxy().getResolver(), GPS_PROVIDER, true); + Single.just(null).observeOn(AndroidSchedulers.mainThread()).subscribe(new Action1() { + public void call(Object param1Object) { + LocationClient.this.nmeaListener.startListen(); + } + }); + } } public void clearGPSlocateStat(){ @@ -383,10 +389,17 @@ public class LocationClient { // Deliver.is_active_location = false; // getLocationWakeLock(); // } - Settings.Secure.setLocationProviderEnabled(runtime.getContextProxy().getResolver(), GPS_PROVIDER, false); - Single.just(null).observeOn(AndroidSchedulers.mainThread()).subscribe(new Action1() { - public void call(Object param1Object) { LocationClient.this.nmeaListener.stopListen(); } - }); + + //防止与工厂测试冲突 + if (!DeviceInfoUtil.isFactoryTestTopActivity(runtime.getContextProxy().context)) { + + Settings.Secure.setLocationProviderEnabled(runtime.getContextProxy().getResolver(), GPS_PROVIDER, false); + Single.just(null).observeOn(AndroidSchedulers.mainThread()).subscribe(new Action1() { + public void call(Object param1Object) { + LocationClient.this.nmeaListener.stopListen(); + } + }); + } } @@ -469,6 +482,7 @@ public void updateCellInfo() { case ICLocation.NORMAL_MOD: default: clearGPSlocateStat(); //如果wifi优先,则确保gps关闭,防止切换回来gps状态错误,尤其是不NoStop模式下的gps切换回来有此风险。 + break; } diff --git a/app/src/main/java/com/enqualcomm/support/MainActivity.java b/app/src/main/java/com/enqualcomm/support/MainActivity.java index eefe2252..f05c0330 100644 --- a/app/src/main/java/com/enqualcomm/support/MainActivity.java +++ b/app/src/main/java/com/enqualcomm/support/MainActivity.java @@ -1,5 +1,6 @@ package com.enqualcomm.support; +import android.content.ComponentName; import android.content.Context; import android.content.Intent; import android.content.pm.PackageInfo; @@ -18,6 +19,7 @@ import com.enqualcomm.support.R; import com.enqualcomm.support.adapter.protocolAPIHelper; import com.enqualcomm.support.utils.DeviceInfoUtil; import com.enqualcomm.support.utils.SimSignalUtil; +import com.enqualcomm.support.utils.Util; import com.ic.jni.ICJniUtils; import com.enqualcomm.support.CoreService; import com.enqualcomm.support.utils.ICLogger; @@ -29,6 +31,8 @@ import java.util.concurrent.TimeUnit; import rx.Observable; import rx.functions.Action1; +import static android.content.Intent.FLAG_ACTIVITY_NEW_TASK; + public class MainActivity extends AppCompatActivity { TextView tv; @@ -65,16 +69,21 @@ public class MainActivity extends AppCompatActivity { btnConnect.setOnClickListener(clickListener); - ToggleButton tbtn = (ToggleButton)findViewById(R.id.toggleButton); - tbtn.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener(){ - + Button tbtn = (Button)findViewById(R.id.btn_tools); + tbtn.setOnClickListener(new View.OnClickListener() { @Override - public void onCheckedChanged(CompoundButton compoundButton, boolean b) { - SimSignalUtil.send_at_to_onoff_simcard(CoreService.getInstance().runtime); + public void onClick(View view) { + Intent intent=new Intent(); + ComponentName var3 = new ComponentName("com.enqualcomm.support", "com.enqualcomm.support.toolActivity"); + intent.addFlags(FLAG_ACTIVITY_NEW_TASK); + intent.setComponent(var3); + startActivity(intent); } }); - ToggleButton tbtnblood = (ToggleButton)findViewById(R.id.toggleButton2); - tbtnblood.setVisibility(View.GONE); + + +// SimSignalUtil.send_at_to_onoff_simcard(CoreService.getInstance().runtime)); + // tbtnblood.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() { // @Override // public void onCheckedChanged(CompoundButton compoundButton, boolean b) { @@ -137,11 +146,13 @@ public class MainActivity extends AppCompatActivity { switch (view.getId()) { case R.id.btnConnect: //进行连接Socket:这里使用的是,在本地上开启了一个服务器。 + Util.ShowToast(CoreService.getInstance().runtime,"Stop ProtocolService!"); stopService(new Intent(MainActivity.this,CoreService.class));// protocol service //delay 5秒再重启 Observable.timer(5000L, TimeUnit.MILLISECONDS).subscribe(new Action1() { public void call(Long param1Long) { + Util.ShowToast(CoreService.getInstance().runtime,"Start ProtocolService!"); startService(new Intent(MainActivity.this,CoreService.class));// protocol service } }); diff --git a/app/src/main/java/com/enqualcomm/support/NMEAListener.java b/app/src/main/java/com/enqualcomm/support/NMEAListener.java index e8e98c17..47735638 100644 --- a/app/src/main/java/com/enqualcomm/support/NMEAListener.java +++ b/app/src/main/java/com/enqualcomm/support/NMEAListener.java @@ -24,11 +24,26 @@ import java.util.List; public class NMEAListener implements NmeaListener, LocationListener { private boolean listening; - + + + public class GpsSatellitePriv { + int prn; + float snr; + GpsSatellitePriv(int _prn, float _snr) { + prn=_prn; + snr=_snr; + } + public int getPrn() { + return prn; + } + public float getSnr() { + return snr; + } + } private LocationManager locationManager; private String locationInfo; - private List numSatelliteList = new ArrayList(); // 卫星信号 - private List max3Satellite = new ArrayList(); // 卫星信号 + private List numSatelliteList = new ArrayList(); // 卫星信号 + private List max3Satellite = new ArrayList(); // 卫星信号 private double longitude; private double latitude; @@ -60,10 +75,243 @@ public class NMEAListener implements NmeaListener, LocationListener { } public void onLocationChanged(Location paramLocation) {} - - public void onNmeaReceived(long paramLong, String paramString) { + static int satindex=0; + public void onNmeaReceived(long paramLong, String nmeastr) { // EqcAlgorithmNative.native_EqcAlgorithmMethod5(paramString); - ICLogger.i("Nmea :"+paramString+" "+paramLong); +// ICLogger.i("Nmea :"+nmeastr+" "+paramLong); + + if (Config.LOG_TOFILE) FileOutputUtil.fileOutput(this.runtime.getCacheDir(),"Nmea","Nmea :"+nmeastr+" "+paramLong); + + searchCout++; + + + if (nmeastr.startsWith("$GPGLL,")){ + String tmplist[]=nmeastr.split(","); +// GPGLL编辑 +//(地理定位信息) +// 例:$GPGLL,4250.5589,S,14718.5084,E,092204.999,A*2D +// 字段0:$GPGLL,语句ID,表明该语句为Geographic Position(GLL)地理定位信息 +// 字段1:纬度ddmm.mmmm,度分格式(前导位数不足则补0) +// 字段2:纬度N(北纬)或S(南纬) +// 字段3:经度dddmm.mmmm,度分格式(前导位数不足则补0) +// 字段4:经度E(东经)或W(西经) +// 字段5:UTC时间,hhmmss.sss格式 +// 字段6:状态,A=定位,V=未定位 +// 字段7:校验值($与*之间的数异或后的值) + String Lat=tmplist[1]; + String lon=tmplist[3]; + String fixed=tmplist[6]; + ICLogger.i("GPGLL Lat="+Lat+",Lon="+lon+",fixed="+fixed); + + }else if (nmeastr.startsWith("$GPRMC,")) { +// GPRMC编辑 +//(推荐定位信息数据格式) +// 例:$GPRMC,024813.640,A,3158.4608,N,11848.3737,E,10.05,324.27,150706,,,A*50 +// 字段0:$GPRMC,语句ID,表明该语句为Recommended Minimum Specific GPS/TRANSIT Data(RMC)推荐最小定位信息 +// 字段1:UTC时间,hhmmss.sss格式 +// 字段2:状态,A=定位,V=未定位 +// 字段3:纬度ddmm.mmmm,度分格式(前导位数不足则补0) +// 字段4:纬度N(北纬)或S(南纬) +// 字段5:经度dddmm.mmmm,度分格式(前导位数不足则补0) +// 字段6:经度E(东经)或W(西经) +// 字段7:速度,节,Knots +// 字段8:方位角,度 +// 字段9:UTC日期,DDMMYY格式 +// 字段10:磁偏角,(000 - 180)度(前导位数不足则补0) +// 字段11:磁偏角方向,E=东W=西 +// 字段12:模式,A=自动,D=差分,E=估测,N=数据无效(3.0协议内容) +// 字段13:校验值($与*之间的数异或后的值) + String tmplist[]=nmeastr.split(","); + String utctime=tmplist[1]; + String Lat=tmplist[3]; + String lon=tmplist[5]; + String fixed=tmplist[2]; + String speed=tmplist[7]; + ICLogger.i("GPRMC GPSTime="+utctime+",Lat="+Lat+",Lon="+lon+",fixed="+fixed+",speed="+speed); + if (Config.LOG_TOFILE) + FileOutputUtil.fileOutput(this.runtime.getCacheDir(), "GPS", "GPRMC GPSTime="+utctime+",Lat="+Lat+",Lon="+lon+",fixed="+fixed+",speed="+speed); + + StringBuilder sb=new StringBuilder(); + + //定位了, + if (fixed.equals("A")) { + locationFixedCount++; + + sb.append(", location time= " + TimeUtil.getLocalTime() + " ,lon= " + lon + ", lat= " + Lat + " FixedCount=" + locationFixedCount + ", speed=" + speed); + ICLogger.i(sb.toString()); + if (Config.LOG_TOFILE) + FileOutputUtil.fileOutput(this.runtime.getCacheDir(), "GPS", sb.toString()); + + if (speed.trim().isEmpty())speed="0.0"; + runtime.getLocationInstance().setLocation(latitude, longitude,Double.valueOf(speed), 0, numSatelliteList.size()); + if (locationFixedCount > MaxFixedTimes) { + /* + 只有当前GPS已经定位,且location不为空才给 runtime赋值GPS坐标。 + 延迟MaxFixedTimes秒后才设置runtime的定位标志,以便稳定坐标值。 + */ + runtime.getLocationInstance().setLocationStat(ICLocation.LOCATION_STAT.LOCATION_FIXED); + ICLogger.i("定位"+locationFixedCount+"次 > "+MaxFixedTimes+", set LOCATION_FIXED "); + if (!noStop) { + stopListen(); + } + } + } + + }else if (nmeastr.startsWith("$GPGSV,")) { + +// GPGSV编辑 +// (可见卫星信息) +// 例:$GPGSV,3,1,10,20,78,331,45,01,59,235,47,22,41,069,,13,32,252,45*70 +// 字段0:$GPGSV,语句ID,表明该语句为GPS Satellites in View(GSV)可见卫星信息 +// 字段1:本次GSV语句的总数目(1 - 3) +// 字段2:本条GSV语句是本次GSV语句的第几条(1 - 3) +// 字段3:当前可见卫星总数(00 - 12)(前导位数不足则补0) +// 字段4:PRN 码(伪随机噪声码)(01 - 32)(前导位数不足则补0) +// 字段5:卫星仰角(00 - 90)度(前导位数不足则补0) +// 字段6:卫星方位角(00 - 359)度(前导位数不足则补0) +// 字段7:信噪比(00-99)dbHz +// 字段8:PRN 码(伪随机噪声码)(01 - 32)(前导位数不足则补0) +// 字段9:卫星仰角(00 - 90)度(前导位数不足则补0) +// 字段10:卫星方位角(00 - 359)度(前导位数不足则补0) +// 字段11:信噪比(00-99)dbHz +// 字段12:PRN 码(伪随机噪声码)(01 - 32)(前导位数不足则补0) +// 字段13:卫星仰角(00 - 90)度(前导位数不足则补0) +//// 字段14:卫星方位角(00 - 359)度(前导位数不足则补0) +//// 字段15:信噪比(00-99)dbHz +// 字段16:校验值($与*之间的数异或后的值) + + String tmplist[]=nmeastr.split(","); + int maxPageCount=Integer.valueOf(tmplist[1]); + int currentPage=Integer.valueOf(tmplist[2]); + int SatlitesCount=Integer.valueOf(tmplist[3]); + if (maxPageCount>0 && currentPage==1){ + //第一页把数组初始化一遍。 + satindex=0; + numSatelliteList.clear(); //清除 SNR >0的卫星 + max3Satellite.clear(); //清除 最大3个星值 + } + int satcount=(tmplist.length-4)/4; + ICLogger.i("Nmea :"+nmeastr+" "+satcount); + for (int i=0;i0] ="+numSatelliteList.size()); + sb.append(", Max 3 SNR ["); + for (int i=0;i0?(max3Satellite.get(0).getSnr()<20?true:false) : true)){ + noSignalCount++; + } + + + StringBuilder sb2=new StringBuilder(); + if(!noStop) { + if (searchCout > SearchTimeout) { + sb2.append(" 搜索" + searchCout + "次未定位,超过" + SearchTimeout + "限制退出GPS定位"); + + runtime.getLocationInstance().setLocationStat(ICLocation.LOCATION_STAT.LOCATION_GPS_TIEMOUT); + + stop(MSG_WHAT_GPS_TIMEOUT); + } + if (noSignalCount > 10) { + sb2.append(" 搜索" + searchCout + "次,超过" + noSignalCount + "次没有收到星,退出GPS定位"); + runtime.getLocationInstance().setLocationStat(ICLocation.LOCATION_STAT.LOCATION_GPS_TIEMOUT); + stop(MSG_WHAT_GPS_NOSTAR); + } + } + if (Config.LOG_TOFILE) + FileOutputUtil.fileOutput(this.runtime.getCacheDir(),"GPS",sb2.toString()); + + + } + }else if (nmeastr.startsWith("$GPGGA,")) { + +// GPGGA编辑 +//(定位信息) +// 例:$GPGGA,092204.999,4250.5589,S,14718.5084,E,1,04,24.4,12.2,M,19.7,M,,0000*1F +// 字段0:$GPGGA,语句ID,表明该语句为Global Positioning System Fix Data(GGA)GPS定位信息 +// 字段1:UTC 时间,hhmmss.sss,时分秒格式 +// 字段2:纬度ddmm.mmmm,度分格式(前导位数不足则补0) +// 字段3:纬度N(北纬)或S(南纬) +// 字段4:经度dddmm.mmmm,度分格式(前导位数不足则补0) +// 字段5:经度E(东经)或W(西经) +// 字段6:GPS状态,0=不可用(FIX NOT valid),1=单点定位(GPS FIX),2=差分定位(DGPS),3=无效PPS,4=实时差分定位(RTK FIX),5=RTK FLOAT,6=正在估算 +// 字段7:正在使用的卫星数量(00 - 12)(前导位数不足则补0) +// 字段8:HDOP水平精度因子(0.5 - 99.9) +// 字段9:海拔高度(-9999.9 - 99999.9) +// 字段10:单位:M(米) +// 字段11:地球椭球面相对大地水准面的高度 WGS84水准面划分 +// 字段12:WGS84水准面划分单位:M(米) +// 字段13:差分时间(从接收到差分信号开始的秒数,如果不是差分定位将为空) +// 字段14:差分站ID号0000 - 1023(前导位数不足则补0,如果不是差分定位将为空) +// 字段15:校验值($与*之间的数异或后的值) + + String tmplist[]=nmeastr.split(","); + String utctime=tmplist[1]; + String Lat=tmplist[2]; + String lon=tmplist[4]; + String fixed=tmplist[6]; +// ICLogger.i("GPGGA GPSTime="+utctime+",Lat="+Lat+",Lon="+lon+",fixed="+fixed); + + + }else if (nmeastr.startsWith("$GPGSA,")) { + +// GPGSA编辑 +//( 当前卫星信息) +// 例:$GPGSA,A,3,01,20,19,13,,,,,,,,,40.4,24.4,32.2*0A +// 字段0:$GPGSA,语句ID,表明该语句为GPS DOP and Active Satellites(GSA)当前卫星信息 +// 字段1:定位模式(选择2D/3D),A=自动选择,M=手动选择 +// 字段2:定位类型,1=未定位,2=2D定位,3=3D定位 +// 字段3:PRN码(伪随机噪声码),第1信道正在使用的卫星PRN码编号(00)(前导位数不足则补0) +// 字段4:PRN码(伪随机噪声码),第2信道正在使用的卫星PRN码编号(00)(前导位数不足则补0) +// 字段5:PRN码(伪随机噪声码),第3信道正在使用的卫星PRN码编号(00)(前导位数不足则补0) +// 字段6:PRN码(伪随机噪声码),第4信道正在使用的卫星PRN码编号(00)(前导位数不足则补0) +// 字段7:PRN码(伪随机噪声码),第5信道正在使用的卫星PRN码编号(00)(前导位数不足则补0) +// 字段8:PRN码(伪随机噪声码),第6信道正在使用的卫星PRN码编号(00)(前导位数不足则补0) +// 字段9:PRN码(伪随机噪声码),第7信道正在使用的卫星PRN码编号(00)(前导位数不足则补0) +// 字段10:PRN码(伪随机噪声码),第8信道正在使用的卫星PRN码编号(00)(前导位数不足则补0) +// 字段11:PRN码(伪随机噪声码),第9信道正在使用的卫星PRN码编号(00)(前导位数不足则补0) +// 字段12:PRN码(伪随机噪声码),第10信道正在使用的卫星PRN码编号(00)(前导位数不足则补0) +// 字段13:PRN码(伪随机噪声码),第11信道正在使用的卫星PRN码编号(00)(前导位数不足则补0) +// 字段14:PRN码(伪随机噪声码),第12信道正在使用的卫星PRN码编号(00)(前导位数不足则补0) +// 字段15:PDOP综合位置精度因子(0.5 - 99.9) +// 字段16:HDOP水平精度因子(0.5 - 99.9) +// 字段17:VDOP垂直精度因子(0.5 - 99.9) +// 字段18:校验值($与*之间的数异或后的值) + + String tmplist[]=nmeastr.split(","); + String locationmod=tmplist[1]; + String fixed=tmplist[2]; +// ICLogger.i("GPGSA locationMode="+locationmod+",fixed="+fixed); + + } } public void onProviderDisabled(String paramString) {} @@ -90,7 +338,6 @@ public class NMEAListener implements NmeaListener, LocationListener { locationManager.sendExtraCommand("gps", "force_xtra_injection", bundleWarm); //command locationManager.sendExtraCommand("gps", "force_time_injection", bundleWarm); boolean b2 = locationManager.sendExtraCommand("gps", "delete_aiding_data", bundleWarm); - return b2; } @@ -121,7 +368,7 @@ public class NMEAListener implements NmeaListener, LocationListener { // 定位算通过 gpsMode = GPS_CURRENT_STATUS.GPS_FIXED; - + ICLogger.i("GPS_EVENT_FIRST_FIX !"); // delaystop(); break; @@ -180,7 +427,7 @@ public class NMEAListener implements NmeaListener, LocationListener { return true; } }); - private void get3MaxSnrSatellite(GpsSatellite gst){ + private void get3MaxSnrSatellite(GpsSatellitePriv gst){ float snr = gst.getSnr(); for (int k=0;k arrayList = new ArrayList(); + arrayList.add("mobile.miki"); + return arrayList.contains(((ActivityManager.RunningTaskInfo)((ActivityManager)paramContext.getSystemService(Context.ACTIVITY_SERVICE)).getRunningTasks(1).get(0)).topActivity.getPackageName()); + } public static String getDeviceInfo(Runtime runtime){ 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 847b0f76..4157b411 100644 --- a/app/src/main/java/com/enqualcomm/support/utils/SimSignalUtil.java +++ b/app/src/main/java/com/enqualcomm/support/utils/SimSignalUtil.java @@ -208,6 +208,15 @@ public class SimSignalUtil { ( runtime.getContextProxy()).context.sendBroadcast(intent); ICLogger.i("send_at_to_update_lbs "); } + + public static void send_at_to_reload_simcard(Runtime runtime){ + + Intent intent = new Intent("com.eqc.intent.action.getTelephony.lbs"); + intent.putExtra("command", "AT+SFUN=3"); //重新初始化sim卡 + intent.putExtra("arg2", ""); + ( runtime.getContextProxy()).context.sendBroadcast(intent); + ICLogger.i("send_at_to_update_lbs "); + } public static void send_at_to_update_lbs(Runtime runtime) { Intent intent = new Intent("com.eqc.intent.action.getTelephony.lbs"); intent.putExtra("command", "AT+CREG=2"); diff --git a/app/src/main/java/com/enqualcomm/support/utils/Util.java b/app/src/main/java/com/enqualcomm/support/utils/Util.java index 0e165ea2..392c9755 100644 --- a/app/src/main/java/com/enqualcomm/support/utils/Util.java +++ b/app/src/main/java/com/enqualcomm/support/utils/Util.java @@ -10,6 +10,9 @@ import android.net.NetworkInfo; import android.net.wifi.WifiConfiguration; import android.net.wifi.WifiManager; import android.os.Build; +import android.os.Handler; +import android.os.Looper; +import android.widget.Toast; import java.io.BufferedInputStream; @@ -606,7 +609,23 @@ public class Util { public static boolean isWifiIsOpen(Context paramContext, Runtime paramRuntime) { return paramRuntime.getContextProxy().getWifiManager().isWifiEnabled(); } - + public static void ShowToast(Runtime runtime,String msg) { + new Thread(new Runnable() { + + @Override + public void run() { + Handler handler = new Handler(Looper.getMainLooper()); + handler.post(new Runnable() { + + @Override + public void run() { + Toast.makeText(runtime.getContextProxy().context, msg, Toast.LENGTH_LONG).show(); + } + }); + } + }).start(); + } + public static byte[] loadFile(File paramFile) { // if (paramFile != null && paramFile.exists()) // try { diff --git a/app/src/main/res/layout/activity_main.xml b/app/src/main/res/layout/activity_main.xml index 59c8af67..2a1c4c15 100644 --- a/app/src/main/res/layout/activity_main.xml +++ b/app/src/main/res/layout/activity_main.xml @@ -34,25 +34,15 @@ android:id="@+id/btnConnect" android:layout_width="80dp" android:layout_height="wrap_content" - android:text="ReCon" /> - - + android:text="ReCon" /> - + android:text="Tools" /> + + + + +