From: snickersun Date: Tue, 7 Jan 2020 06:18:00 +0000 (+0800) Subject: update gps X-Git-Url: http://git.snicker.com.cn/Users/apple/Desktop/static/gitweb.css?a=commitdiff_plain;h=cf92f4ef0086a6b9b5a8865e52cfe9daaec9311f;p=icsupport.git update gps --- diff --git a/.gradle/5.4.1/executionHistory/executionHistory.bin b/.gradle/5.4.1/executionHistory/executionHistory.bin index 12e3abaf..24892496 100644 Binary files a/.gradle/5.4.1/executionHistory/executionHistory.bin and b/.gradle/5.4.1/executionHistory/executionHistory.bin differ diff --git a/.gradle/5.4.1/executionHistory/executionHistory.lock b/.gradle/5.4.1/executionHistory/executionHistory.lock index 54036f0e..82d4bd2c 100644 Binary files a/.gradle/5.4.1/executionHistory/executionHistory.lock and b/.gradle/5.4.1/executionHistory/executionHistory.lock differ diff --git a/.gradle/5.4.1/fileHashes/fileHashes.bin b/.gradle/5.4.1/fileHashes/fileHashes.bin index 6657a313..36d9f2df 100644 Binary files a/.gradle/5.4.1/fileHashes/fileHashes.bin and b/.gradle/5.4.1/fileHashes/fileHashes.bin differ diff --git a/.gradle/5.4.1/fileHashes/fileHashes.lock b/.gradle/5.4.1/fileHashes/fileHashes.lock index 7991e06d..42ebb4bd 100644 Binary files a/.gradle/5.4.1/fileHashes/fileHashes.lock and b/.gradle/5.4.1/fileHashes/fileHashes.lock differ diff --git a/.gradle/5.4.1/fileHashes/resourceHashesCache.bin b/.gradle/5.4.1/fileHashes/resourceHashesCache.bin index bcac5934..3e8c001f 100644 Binary files a/.gradle/5.4.1/fileHashes/resourceHashesCache.bin and b/.gradle/5.4.1/fileHashes/resourceHashesCache.bin differ diff --git a/.gradle/5.4.1/javaCompile/classAnalysis.bin b/.gradle/5.4.1/javaCompile/classAnalysis.bin index 351b00bd..21649e02 100644 Binary files a/.gradle/5.4.1/javaCompile/classAnalysis.bin and b/.gradle/5.4.1/javaCompile/classAnalysis.bin differ diff --git a/.gradle/5.4.1/javaCompile/javaCompile.lock b/.gradle/5.4.1/javaCompile/javaCompile.lock index 9e5c7f10..2ea28360 100644 Binary files a/.gradle/5.4.1/javaCompile/javaCompile.lock and b/.gradle/5.4.1/javaCompile/javaCompile.lock differ diff --git a/.gradle/5.4.1/javaCompile/taskHistory.bin b/.gradle/5.4.1/javaCompile/taskHistory.bin index ee1587ea..5879777b 100644 Binary files a/.gradle/5.4.1/javaCompile/taskHistory.bin and b/.gradle/5.4.1/javaCompile/taskHistory.bin differ diff --git a/.gradle/buildOutputCleanup/buildOutputCleanup.lock b/.gradle/buildOutputCleanup/buildOutputCleanup.lock index 2ba454f5..41c763b0 100644 Binary files a/.gradle/buildOutputCleanup/buildOutputCleanup.lock and b/.gradle/buildOutputCleanup/buildOutputCleanup.lock differ diff --git a/.gradle/buildOutputCleanup/outputFiles.bin b/.gradle/buildOutputCleanup/outputFiles.bin index 5833ac72..9b692bda 100644 Binary files a/.gradle/buildOutputCleanup/outputFiles.bin and b/.gradle/buildOutputCleanup/outputFiles.bin differ diff --git a/.idea/caches/build_file_checksums.ser b/.idea/caches/build_file_checksums.ser index a1188a26..8f0cd045 100644 Binary files a/.idea/caches/build_file_checksums.ser and b/.idea/caches/build_file_checksums.ser differ diff --git a/.idea/caches/gradle_models.ser b/.idea/caches/gradle_models.ser index ca234e95..0852fa4e 100644 Binary files a/.idea/caches/gradle_models.ser and b/.idea/caches/gradle_models.ser differ diff --git a/.idea/libraries/Gradle__com_android_support_multidex_instrumentation_1_0_2_aar.xml b/.idea/libraries/Gradle__com_android_support_multidex_instrumentation_1_0_2_aar.xml new file mode 100644 index 00000000..82cf4a5b --- /dev/null +++ b/.idea/libraries/Gradle__com_android_support_multidex_instrumentation_1_0_2_aar.xml @@ -0,0 +1,10 @@ + + + + + + + + + + \ No newline at end of file diff --git a/.idea/libraries/Gradle__com_android_support_test_espresso_espresso_core_2_2_2_aar.xml b/.idea/libraries/Gradle__com_android_support_test_espresso_espresso_core_2_2_2_aar.xml new file mode 100644 index 00000000..b49fac82 --- /dev/null +++ b/.idea/libraries/Gradle__com_android_support_test_espresso_espresso_core_2_2_2_aar.xml @@ -0,0 +1,14 @@ + + + + + + + + + + + + + + \ No newline at end of file diff --git a/.idea/libraries/Gradle__com_android_support_test_espresso_espresso_idling_resource_2_2_2_aar.xml b/.idea/libraries/Gradle__com_android_support_test_espresso_espresso_idling_resource_2_2_2_aar.xml new file mode 100644 index 00000000..8b2ad5aa --- /dev/null +++ b/.idea/libraries/Gradle__com_android_support_test_espresso_espresso_idling_resource_2_2_2_aar.xml @@ -0,0 +1,14 @@ + + + + + + + + + + + + + + \ No newline at end of file diff --git a/.idea/libraries/Gradle__com_android_support_test_exposed_instrumentation_api_publish_0_5_aar.xml b/.idea/libraries/Gradle__com_android_support_test_exposed_instrumentation_api_publish_0_5_aar.xml new file mode 100644 index 00000000..ec168069 --- /dev/null +++ b/.idea/libraries/Gradle__com_android_support_test_exposed_instrumentation_api_publish_0_5_aar.xml @@ -0,0 +1,14 @@ + + + + + + + + + + + + + + \ No newline at end of file diff --git a/.idea/libraries/Gradle__com_android_support_test_rules_0_5_aar.xml b/.idea/libraries/Gradle__com_android_support_test_rules_0_5_aar.xml new file mode 100644 index 00000000..5a4687b2 --- /dev/null +++ b/.idea/libraries/Gradle__com_android_support_test_rules_0_5_aar.xml @@ -0,0 +1,17 @@ + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/.idea/libraries/Gradle__com_android_support_test_runner_0_5_aar.xml b/.idea/libraries/Gradle__com_android_support_test_runner_0_5_aar.xml new file mode 100644 index 00000000..a881a73b --- /dev/null +++ b/.idea/libraries/Gradle__com_android_support_test_runner_0_5_aar.xml @@ -0,0 +1,17 @@ + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/.idea/libraries/Gradle__com_google_code_findbugs_jsr305_2_0_1_jar.xml b/.idea/libraries/Gradle__com_google_code_findbugs_jsr305_2_0_1_jar.xml new file mode 100644 index 00000000..8793362d --- /dev/null +++ b/.idea/libraries/Gradle__com_google_code_findbugs_jsr305_2_0_1_jar.xml @@ -0,0 +1,9 @@ + + + + + + + + + \ No newline at end of file diff --git a/.idea/libraries/Gradle__com_squareup_javawriter_2_1_1_jar.xml b/.idea/libraries/Gradle__com_squareup_javawriter_2_1_1_jar.xml new file mode 100644 index 00000000..f9ba1587 --- /dev/null +++ b/.idea/libraries/Gradle__com_squareup_javawriter_2_1_1_jar.xml @@ -0,0 +1,13 @@ + + + + + + + + + + + + + \ No newline at end of file diff --git a/.idea/libraries/Gradle__javax_annotation_javax_annotation_api_1_2_jar.xml b/.idea/libraries/Gradle__javax_annotation_javax_annotation_api_1_2_jar.xml new file mode 100644 index 00000000..90eea213 --- /dev/null +++ b/.idea/libraries/Gradle__javax_annotation_javax_annotation_api_1_2_jar.xml @@ -0,0 +1,13 @@ + + + + + + + + + + + + + \ No newline at end of file diff --git a/.idea/libraries/Gradle__javax_inject_javax_inject_1_jar.xml b/.idea/libraries/Gradle__javax_inject_javax_inject_1_jar.xml new file mode 100644 index 00000000..746319d5 --- /dev/null +++ b/.idea/libraries/Gradle__javax_inject_javax_inject_1_jar.xml @@ -0,0 +1,13 @@ + + + + + + + + + + + + + \ No newline at end of file diff --git a/.idea/libraries/Gradle__org_hamcrest_hamcrest_integration_1_3_jar.xml b/.idea/libraries/Gradle__org_hamcrest_hamcrest_integration_1_3_jar.xml new file mode 100644 index 00000000..a738e54e --- /dev/null +++ b/.idea/libraries/Gradle__org_hamcrest_hamcrest_integration_1_3_jar.xml @@ -0,0 +1,13 @@ + + + + + + + + + + + + + \ No newline at end of file diff --git a/.idea/libraries/Gradle__org_hamcrest_hamcrest_library_1_3_jar.xml b/.idea/libraries/Gradle__org_hamcrest_hamcrest_library_1_3_jar.xml new file mode 100644 index 00000000..40e4b54c --- /dev/null +++ b/.idea/libraries/Gradle__org_hamcrest_hamcrest_library_1_3_jar.xml @@ -0,0 +1,13 @@ + + + + + + + + + + + + + \ No newline at end of file diff --git a/.idea/modules.xml b/.idea/modules.xml index 1db11d52..17b54daa 100644 --- a/.idea/modules.xml +++ b/.idea/modules.xml @@ -4,7 +4,6 @@ - diff --git a/.idea/workspace.xml b/.idea/workspace.xml index 24205b87..b40189b9 100644 --- a/.idea/workspace.xml +++ b/.idea/workspace.xml @@ -1,91 +1,54 @@ + + + + + - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + - + + + + + + + + - - - - - - - - - - - - + + - - + + - - + + + + + + + + + + - + - - + + - - + + - - + + + + + + + + - - - - - - - - - - - - + + + + + + - - + + + + + + - + - - + + + + + + - + - - + + + + + + + + - + - - + + + + + + + + + - setSl - useApi19 - AlarmHelper - SetAl - setRealTimeAlarm - watch.jiai.pro - heart - BP85 - handleBP33 - AP16 - handleBP16 - handleBP15 - lacation_cycle - ACTION_ALARM - AP03 - setheart - ServiceUtil - onHeartAlarm - HEART_ALARM - BP33 - handleBP85 - setRepeating - setAlarm - resolveResult - mCondition queue location getApkBaseName bootClasspath + TYPE_STEP_COUNTER CompileOptions + sensorManager + maxTime + paramWakeLock + handler + msg.what + getCellInfo + setOnWiFiInfoListener + mRuntime + EqcAlgorithmInterfaceMethod3 + EqcAlgorithmInterfaceMethod2 + H10 + Start + gpstest + scanresult + locationManager + flag + GPS_PROVIDER + readGpsThread + ReadGpsThread + locationListener + requestLocationUpdates + LocationManager + locationInfo + getBestLocation @@ -244,10 +240,19 @@ @@ -265,6 +270,49 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -286,7 +334,7 @@ - + @@ -396,24 +444,24 @@ - + - + - + - - - + + + - - - + + + @@ -426,7 +474,7 @@ file://$PROJECT_DIR$/app/src/main/java/com/ic/protocol/LocationClient.java - 747 + 749 @@ -436,62 +484,45 @@ + + + + + + + + + + mCellInfo.split("|") + JAVA + EXPRESSION + + + mCellInfo.split("|")[0] + JAVA + EXPRESSION + + + mCellInfo.split("|")[0].split(","); + JAVA + EXPRESSION + + + arrayOfString.split("|").split(",") + JAVA + EXPRESSION + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -630,19 +661,6 @@ - - - - - - - - - - - - - @@ -657,21 +675,6 @@ - - - - - - - - - - - - - - - @@ -679,20 +682,6 @@ - - - - - - - - - - - - - - @@ -756,8 +745,191 @@ - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/app/app.iml b/app/app.iml index 33198307..95ac0dd5 100644 --- a/app/app.iml +++ b/app/app.iml @@ -10,47 +10,60 @@ - - - + + - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -76,8 +89,20 @@ + + + + + + + + + + + + diff --git a/app/release/ICSer_V110_202001070902_release.apk b/app/release/ICSer_V110_202001070902_release.apk deleted file mode 100644 index 368200bf..00000000 Binary files a/app/release/ICSer_V110_202001070902_release.apk and /dev/null differ diff --git a/app/release/output.json b/app/release/output.json deleted file mode 100644 index 2b238a60..00000000 --- a/app/release/output.json +++ /dev/null @@ -1 +0,0 @@ -[{"outputType":{"type":"APK"},"apkData":{"type":"MAIN","splits":[],"versionCode":110,"versionName":"202001070902","enabled":true,"outputFile":"ICSer_V110_202001070902_release.apk","fullName":"release","baseName":"release"},"path":"ICSer_V110_202001070902_release.apk","properties":{}}] \ No newline at end of file diff --git a/app/src/main/java/com/ic/protocol/GSensorListener.java b/app/src/main/java/com/ic/protocol/GSensorListener.java index 93d75c67..6b619e72 100644 --- a/app/src/main/java/com/ic/protocol/GSensorListener.java +++ b/app/src/main/java/com/ic/protocol/GSensorListener.java @@ -14,6 +14,7 @@ import com.ic.protocol.bean.Runtime; import com.ic.protocol.utils.CellInfoUtil; import com.ic.protocol.utils.FileOutputUtil; import com.ic.protocol.utils.Logger; +import com.ic.protocol.utils.StepCounterInterface; import java.util.Timer; import java.util.TimerTask; @@ -41,14 +42,16 @@ public class GSensorListener implements SensorEventListener { if (msg.what != 100) return; GSensorListener.this.sensorManager.unregisterListener(GSensorListener.this); - int i = 0;//EqcAlgorithmNative.native_EqcAlgorithm_Gsensor_get_step(); + int i = StepCounterInterface.getStepCount();//EqcAlgorithmNative.native_EqcAlgorithm_Gsensor_get_step(); // GSensorListener (GSensorListener.this, i); + GSensorListener.this.CURRENT_STEP = i; StringBuilder stringBuilder1 = new StringBuilder(); stringBuilder1.append("CURRENT_STEP ="); stringBuilder1.append(GSensorListener.this.CURRENT_STEP); Logger.i(stringBuilder1.toString()); GSensorListener.this.sendAntiOff(GSensorListener.this.CURRENT_STEP); // GSensorListener.access$302(GSensorListener.this, 0); +// GSensorListener.getStepCountOver=false; // EqcAlgorithmNative.native_EqcAlgorithmMethod6(0.0F, 0.0F, 0.0F, GSensorListener.this.CURRENT_STEP); Context context = GSensorListener.this.mContext; StringBuilder stringBuilder2 = new StringBuilder(); @@ -75,6 +78,7 @@ public class GSensorListener implements SensorEventListener { public GSensorListener(SensorManager paramSensorManager, Context context, Runtime dev) { this.sensorManager = paramSensorManager; this.mContext = context; + StepCounterInterface.enableStepCounter(); } private void releaseWakeLock(PowerManager.WakeLock paramWakeLock) { @@ -122,7 +126,7 @@ public class GSensorListener implements SensorEventListener { stringBuilder1.append("count ="); stringBuilder1.append(currentStepCount); Logger.i(stringBuilder1.toString()); - int step = 0;//EqcAlgorithmNative.native_EqcAlgorithm_Gsensor_get_step(); + int step = StepCounterInterface.getStepCount();//EqcAlgorithmNative.native_EqcAlgorithm_Gsensor_get_step(); if (step == this.CURRENT_STEP && !this.isReceivedFirstValue) { this.isReceivedFirstValue = true; return; @@ -131,11 +135,13 @@ public class GSensorListener implements SensorEventListener { this.mTimer.cancel(); this.mTimer.purge(); this.mTimer = null; - } + } + // sendAntiOff(i); this.haveAddAntiOffCount = 0; this.CURRENT_STEP = step; // EqcAlgorithmNative.native_EqcAlgorithmMethod6(0.0F, 0.0F, 0.0F, this.CURRENT_STEP); + Context context = this.mContext; StringBuilder stringBuilder2 = new StringBuilder(); stringBuilder2.append("CURRENT_STEP="); @@ -157,7 +163,7 @@ public class GSensorListener implements SensorEventListener { stringBuilder.append("registerListener sensorManager="); stringBuilder.append(GSensorListener.this.sensorManager); Logger.i(stringBuilder.toString()); - GSensorListener.this.sensorManager.registerListener(GSensorListener.this, GSensorListener.this.sensorManager.getDefaultSensor(19), 0); + GSensorListener.this.sensorManager.registerListener(GSensorListener.this, GSensorListener.this.sensorManager.getDefaultSensor(Sensor.TYPE_STEP_COUNTER), 0); } })).start(); if (this.mTimer == null) @@ -165,9 +171,13 @@ public class GSensorListener implements SensorEventListener { if (this.mMyTimerTask != null) this.mMyTimerTask.cancel(); class MyTimerTask extends TimerTask { - public void run() { GSensorListener.this.mHandler.sendEmptyMessage(100); } + public void run() { + //发送读取计步消息 + GSensorListener.this.mHandler.sendEmptyMessage(100); + } }; this.mMyTimerTask = new MyTimerTask(); + //延时2秒执行发送“读取计步”消息 this.mTimer.schedule(this.mMyTimerTask, 2000L); } diff --git a/app/src/main/java/com/ic/protocol/LocationClient.java b/app/src/main/java/com/ic/protocol/LocationClient.java index 2be6009e..06b855e1 100644 --- a/app/src/main/java/com/ic/protocol/LocationClient.java +++ b/app/src/main/java/com/ic/protocol/LocationClient.java @@ -518,13 +518,12 @@ public class LocationClient { this.mLbsHelper.setOnWiFiInfoListener(new LBSHelper.OnWiFiInfoListener() { public void getWifiInfoCallBack(String param1String) { // LocationClient.access$002(true); -// LocationClient.this. + LocationClient.mHasWifiResult=true; runtime.currentWifiInfo = param1String; } }); } - - @TargetApi(Build.VERSION_CODES.FROYO) + // public void EqcAlgorithmInterfaceMethod3() { public void stopGpsLocate() { if (Deliver.is_active_location) { @@ -581,7 +580,7 @@ public void updateCellInfo() { } public PowerManager.WakeLock getLocationWakeLock() { - @SuppressLint("InvalidWakeLockTag") PowerManager.WakeLock wakeLock = ((PowerManager)(runtime.getContextProxy()).context.getSystemService(Context.POWER_SERVICE)).newWakeLock(1, "locationSend"); + PowerManager.WakeLock wakeLock = ((PowerManager)(runtime.getContextProxy()).context.getSystemService(Context.POWER_SERVICE)).newWakeLock(1, "locationSend"); wakeLock.acquire(1000L); return wakeLock; } @@ -602,6 +601,7 @@ public void updateCellInfo() { } public void onReceive(StringMessage paramStringMessage) { + Logger.i("LocationClient onReceive " +paramStringMessage.cmd() ); if ("Sport:OK".equals(paramStringMessage.cmd())) this.mPedometer2 = this.H12StepCount; if (linkOK) @@ -701,6 +701,7 @@ public void updateCellInfo() { intentFilter.addAction("android.intent.action.SCREEN_ON"); (runtime.getContextProxy()).context.registerReceiver(this.screenOnReceiver, intentFilter); (new MyThread2(this.mCondition, this.mLock)).start(); + startGpsLocate(); this.haveChanegTo4GTime = SystemClock.elapsedRealtime(); } @@ -712,6 +713,7 @@ public void updateCellInfo() { public void run() { LocationClient.saveQueue(); } }); this.gSensorListener.stopListen(); + stopGpsLocate(); } static class MyThread2 extends Thread { diff --git a/app/src/main/java/com/ic/protocol/MainActivity.java b/app/src/main/java/com/ic/protocol/MainActivity.java index c7d909c7..47faedd0 100644 --- a/app/src/main/java/com/ic/protocol/MainActivity.java +++ b/app/src/main/java/com/ic/protocol/MainActivity.java @@ -7,9 +7,12 @@ import android.view.View; import android.widget.Button; import android.widget.Toast; +import com.ic.protocol.bean.StepCount; import com.ic.protocol.service.protocolMainServer; +import com.ic.protocol.utils.ExeCommand; import com.ic.protocol.utils.Logger; import com.ic.protocol.utils.RxSocket; +import com.ic.protocol.utils.StepCounterInterface; import java.net.InetAddress; import java.nio.ByteBuffer; @@ -64,7 +67,7 @@ public class MainActivity extends AppCompatActivity { case R.id.btnWrite2: // if(mProtocolMainServer !=null) mProtocolMainServer.testGpsData(); - + StepCounterInterface.getStepCount(); break; } } diff --git a/app/src/main/java/com/ic/protocol/NMEAListener.java b/app/src/main/java/com/ic/protocol/NMEAListener.java index 62b1b7f4..721babed 100644 --- a/app/src/main/java/com/ic/protocol/NMEAListener.java +++ b/app/src/main/java/com/ic/protocol/NMEAListener.java @@ -1,20 +1,43 @@ package com.ic.protocol; import android.annotation.SuppressLint; +import android.location.GpsSatellite; import android.location.GpsStatus; import android.location.GpsStatus.NmeaListener; import android.location.Location; import android.location.LocationListener; import android.location.LocationManager; import android.os.Bundle; +import android.os.Handler; +import android.os.Message; +import android.text.TextUtils; +import android.util.Log; +import android.widget.TextView; + import com.ic.protocol.bean.Runtime; +import com.ic.protocol.utils.Logger; + +import java.text.DecimalFormat; +import java.util.ArrayList; +import java.util.Iterator; +import java.util.List; -@SuppressLint("NewApi") public class NMEAListener implements NmeaListener, LocationListener { private boolean listening; private LocationManager locationManager; - + Location location; + + private String locationInfo; + private List numSatelliteList = new ArrayList(); // 卫星信号 + private List max3Satellite = new ArrayList(); // 卫星信号 + private int satelliteInfo = 0; + private ReadGpsThread readGpsThread; + private double longitude; + private double latitude; + private boolean flag; + int gpsMode; + int numberOfSatellites; Runtime runtime; public NMEAListener(LocationManager paramLocationManager, Runtime paramRuntime) { @@ -26,6 +49,7 @@ public class NMEAListener implements NmeaListener, LocationListener { public void onNmeaReceived(long paramLong, String paramString) { // EqcAlgorithmNative.native_EqcAlgorithmMethod5(paramString); + Logger.i("Nmea :"+paramString+" "+paramLong); } public void onProviderDisabled(String paramString) {} @@ -33,15 +57,282 @@ public class NMEAListener implements NmeaListener, LocationListener { public void onProviderEnabled(String paramString) {} public void onStatusChanged(String paramString, int paramInt, Bundle paramBundle) {} - - @SuppressLint("NewApi") + + private GpsStatus.Listener statusListener = new GpsStatus.Listener() { + public void onGpsStatusChanged(int event) { // GPS状态变化时的回调,如卫星数 + GpsStatus status = locationManager.getGpsStatus(null); //取当前状态 + updateGpsStatus(event, status); //只更新状态 + numberOfSatellites = numSatelliteList.size(); + + switch (event){ + case GpsStatus.GPS_EVENT_SATELLITE_STATUS: + + + //如果是自动测试,则有3颗大于20的就算通过 + if (max3Satellite.size() >= 3 && max3Satellite.get(2).getSnr()>=30) { + + if (readGpsThread != null) { + readGpsThread.endThread(); + } + if (flag) { + flag = false; + pass(); + } + } + + + //如果是pcba测试,则只要有一颗大于30的星就算通过。 + if (max3Satellite.size() > 0 && max3Satellite.get(0).getSnr()>=30) { + + + if (readGpsThread != null) { + readGpsThread.endThread(); + } + if (flag) { + flag = false; + pass(); + } + } + + + break; + case GpsStatus.GPS_EVENT_FIRST_FIX: + //普通测试,必须定位才算通过 +// +" cost "+status.getTimeToFirstFix()+"ms"); + + if (readGpsThread != null) { + readGpsThread.endThread(); + } + if (flag) { + flag = false; + pass(); + } + break; + case GpsStatus.GPS_EVENT_STARTED: + // tvGps.setText("GPS_EVENT_STARTED"); + break; + case GpsStatus.GPS_EVENT_STOPPED: + // tvGps.setText("GPS_EVENT_STOPPED"); + break; + default: + break; + } + + + + + } + }; + + + class ReadGpsThread extends Thread { + private boolean isRunning = false; + private int DELAY_MS = 1000; + private int count = 0; + + public ReadGpsThread() { + isRunning = true; + } + + public void endThread() { + isRunning = false; + readGpsThread = null; + } + + @Override + public void run() { + while (isRunning) { + count++; + if (numberOfSatellites >= 3) { + return; + } + // 15秒没定位成功,则失败 + if (count == 120) { + Message msg = new Message(); + temHandler.sendMessage(msg); + if (readGpsThread != null) { + endThread(); + return; + } + } + try { + Thread.sleep(DELAY_MS); + } catch (Exception e) { + // TODO: handle exception + } + } + super.run(); + } + } + + Handler temHandler = new Handler(new Handler.Callback() { + @Override + public boolean handleMessage(Message message) { + + if (readGpsThread != null) { + readGpsThread.endThread(); + } + return false; + } + }); + private void get3MaxSnrSatellite(GpsSatellite gst){ + + float snr = gst.getSnr(); + for (int k=0;k3){ //超过三个,谁小就删掉 + max3Satellite.remove(3); + } + + } + private int updateGpsStatus(int event, GpsStatus status) { + StringBuilder sb2 = new StringBuilder(""); + float strengh = 0; + if (status == null) { + sb2.append("搜索到卫星个数:" + 0); + } else if (event == GpsStatus.GPS_EVENT_SATELLITE_STATUS) { + int maxSatellites = status.getMaxSatellites(); + Iterator it = status.getSatellites().iterator(); + numSatelliteList.clear(); + int count = 0; + while (it.hasNext() && count <= maxSatellites) { + GpsSatellite s = it.next(); + float snr = s.getSnr(); + if (snr > 0) {//只有信躁比不为0的时候才算搜到了星 + strengh = snr; +// Toast.makeText(this, "信躁比大于20", Toast.LENGTH_LONG).show(); + //排序取得最大3个SNR + get3MaxSnrSatellite(s); + numSatelliteList.add(s); + } + + count++; + } + sb2.append("搜索到卫星个数(SNR>0):" + numSatelliteList.size()+" \n Max 3 SNRs[ " ); + for (int i=0;i 0 && latitude > 0) { + //sucess + if (readGpsThread != null) { + readGpsThread.endThread(); + } + if (isFrist) { + isFrist = false; + pass();// 定位成功,自动跳转2016.9.19 tyy + } + + } else { + + + } + + long gpsTime = location.getTime(); + + double altitude = location.getAltitude();// 海拔 + + // 速度 + float speed = location.getSpeed();// 速度 单位 m/s + speed = (speed * 60) / 1000; // 单位转换 km/h + // 保留一位小数点 + DecimalFormat dfSpeed = new DecimalFormat("#.0"); + String strSpeed = dfSpeed.format(speed); + speed = Float.parseFloat(strSpeed); + int intSpeed = (int) (speed * 10); + // SimpleLogger.d("intSpeed:"+intSpeed); + + // 经纬度 保留6位小数点 + DecimalFormat df = new DecimalFormat("#.000000"); + String strLatitude = df.format(latitude); + String strLongitude = df.format(longitude); + + StringBuffer sb = new StringBuffer(); + sb.append("lon " + strLongitude + "\n" + "lat " + strLatitude); + Logger.i("satelliteInfo:"+satelliteInfo); + return sb.toString(); + } else { + // textView.setText(""); + return ""; + } + } + + public double[] getGpsInfo() { + String tude = locationInfo; + if (!TextUtils.isEmpty(tude)) { + String[] longitudeAndLatitude = tude.split(" "); + String longitude = longitudeAndLatitude[0]; + String latitude = longitudeAndLatitude[1]; + + return new double[]{Double.parseDouble(latitude), + Double.parseDouble(longitude)}; + } + return null; + } + /** + * 获取location对象,优先以GPS_PROVIDER获取location对象,当以GPS_PROVIDER获取到的locaiton为null时 + * ,则以NETWORK_PROVIDER获取location对象,这样可保证在室内开启网络连接的状态下获取到的location对象不为空 + * + * @param locationManager + * @return + */ + private Location getBestLocation(LocationManager locationManager) { + Location result = null; + if (locationManager != null) { + result = locationManager.getLastKnownLocation(LocationManager.GPS_PROVIDER); + if (result != null) { + + return result; + } else { + result = locationManager.getLastKnownLocation(LocationManager.NETWORK_PROVIDER); + return result; + } + } + return result; + } + public boolean startListen() { - this.locationManager.requestLocationUpdates("gps", 0L, 0.0F, this); + this.locationManager.requestLocationUpdates(LocationManager.GPS_PROVIDER, 0L, 0.0F, this); this.listening = true; + locationManager.addGpsStatusListener(statusListener);//搜星 return this.locationManager.addNmeaListener(this); } - @SuppressLint("NewApi") + public void stopListen() { this.locationManager.removeNmeaListener(this); this.locationManager.removeUpdates(this); diff --git a/app/src/main/java/com/ic/protocol/adapter/LBSHelper.java b/app/src/main/java/com/ic/protocol/adapter/LBSHelper.java index 7f398797..3b55470f 100644 --- a/app/src/main/java/com/ic/protocol/adapter/LBSHelper.java +++ b/app/src/main/java/com/ic/protocol/adapter/LBSHelper.java @@ -38,6 +38,7 @@ import static android.net.wifi.WifiManager.WIFI_STATE_ENABLED; import static android.net.wifi.WifiManager.WIFI_STATE_ENABLING; import static android.net.wifi.WifiManager.WIFI_STATE_UNKNOWN; import static android.telephony.PhoneStateListener.LISTEN_SIGNAL_STRENGTHS; +import static android.telephony.TelephonyManager.NETWORK_TYPE_LTE; public class LBSHelper { private boolean IS_HASOPEN = false; @@ -251,16 +252,16 @@ public class LBSHelper { StringBuilder gsmSb = new StringBuilder(var4); StringBuilder mccmnc = new StringBuilder(var4); StringBuilder cdmaSB = new StringBuilder(); - gsmSb.insert(3, ","); - mccmnc.insert(3, ","); + gsmSb.insert(3, "@"); + mccmnc.insert(3, "@"); this.runtime.setMccAndMnc(mccmnc.toString()); if (celllocation instanceof GsmCellLocation) { GsmCellLocation gsmCell = (GsmCellLocation)celllocation; - gsmSb.append(","); + gsmSb.append("@"); gsmSb.append(gsmCell.getLac()); - gsmSb.append(","); + gsmSb.append("@"); gsmSb.append(gsmCell.getCid()); - gsmSb.append(","); + gsmSb.append("@"); gsmSb.append(this.mLastSignal); this.runtime.setCid(String.format("",gsmCell.getCid())); // this.runtime.setLAC(gsmCell.getLac()); @@ -317,11 +318,11 @@ public class LBSHelper { gsmSb.append("+"); gsmSb.append(mccmnc); - gsmSb.append(","); + gsmSb.append("@"); gsmSb.append(mNeighboringCellInfo.getLac()); - gsmSb.append(","); + gsmSb.append("@"); gsmSb.append(mNeighboringCellInfo.getCid()); - gsmSb.append(","); + gsmSb.append("@"); gsmSb.append(mNeighboringCellInfo.getRssi() + 110); var3 = var2 + 1; var2 = var3; @@ -365,15 +366,15 @@ public class LBSHelper { public void onSignalStrengthsChanged(SignalStrength ss) { super.onSignalStrengthsChanged(ss); -// if (((TelephonyManager) LBSHelper.this.context.getSystemService(Context.TELEPHONY_SERVICE)).getNetworkType() == NETWORK_TYPE_LTE) { -// String[] siglist = ss.toString().split(" "); -// LBSHelper.this.mLastSignal = Integer.parseInt(siglist[9]) + 110; -// } else { -// LBSHelper.this.mLastSignal = ss.getGsmSignalStrength() * 2 - 113 + 110; -// } -// LBSHelper.this.runtime.setSignalStrength(LBSHelper.this.mLastSignal - 110); - LBSHelper.this.mLastSignal = ss.getGsmSignalStrength();//ss.getDbm(); - LBSHelper.this.runtime.setSignalStrength(LBSHelper.this.mLastSignal); + if (((TelephonyManager) LBSHelper.this.context.getSystemService(Context.TELEPHONY_SERVICE)).getNetworkType() == NETWORK_TYPE_LTE) { + String[] siglist = ss.toString().split(" "); + LBSHelper.this.mLastSignal = Integer.parseInt(siglist[9]) + 110; + } else { + LBSHelper.this.mLastSignal = ss.getGsmSignalStrength() * 2 - 113 + 110; + } + LBSHelper.this.runtime.setSignalStrength(LBSHelper.this.mLastSignal - 110); +// LBSHelper.this.mLastSignal = ss.getGsmSignalStrength();//ss.getDbm(); +// LBSHelper.this.runtime.setSignalStrength(LBSHelper.this.mLastSignal); } } diff --git a/app/src/main/java/com/ic/protocol/utils/CellInfoUtil.java b/app/src/main/java/com/ic/protocol/utils/CellInfoUtil.java index 77730bf1..cbb54069 100644 --- a/app/src/main/java/com/ic/protocol/utils/CellInfoUtil.java +++ b/app/src/main/java/com/ic/protocol/utils/CellInfoUtil.java @@ -31,11 +31,12 @@ public class CellInfoUtil { return; Logger.i("延时获取基站信息"); // CellInfoUtil.access$010(); -// CellInfoUtil.setCurrentAttachCellInfo(mRuntime, mWakeLock); + + CellInfoUtil.setCurrentAttachCellInfo(mRuntime, mWakeLock); } }; - private static Runtime mDevStatus; + private static Runtime mRuntime; private static PowerManager.WakeLock mWakeLock; @@ -60,13 +61,13 @@ public class CellInfoUtil { public static void setCurrentAttachCellInfo(Runtime dev, PowerManager.WakeLock paramWakeLock) { mWakeLock = paramWakeLock; - mDevStatus = dev; + mRuntime = dev; (new Thread(new Runnable() { public void run() { -// CellInfoUtil.access$302(mDevStatus.getLbsHelper().getAttchCellInfo(mRuntime.getContextProxy().getTelephonyManager())); + CellInfoUtil.mCellInfo=mRuntime.getLbsHelper().getAttchCellInfo(mRuntime.getContextProxy().getTelephonyManager()); if (mCellInfo != null) { - String str1 = mDevStatus.getCdmaInfo(); - String str2 = mDevStatus.getMccAndMnc(); + String str1 = mRuntime.getCdmaInfo(); + String str2 = mRuntime.getMccAndMnc(); if (str1 != null) { String[] arrayOfString2 = str2.split("@"); String[] arrayOfString1 = str1.split(","); @@ -86,10 +87,11 @@ public class CellInfoUtil { CellInfoUtil.CELL_ID = Integer.parseInt(arrayOfString[3]); CellInfoUtil.BSSS = Integer.parseInt(arrayOfString[4]); // CellInfoUtil.access$002(2); + CellInfoUtil.IS2SECOND=2; // EqcAlgorithmNative.native_EqcAlgorithmMethod4(0, 0, CellInfoUtil.BSSS, CellInfoUtil.MCC, CellInfoUtil.MNC, CellInfoUtil.LAC, CellInfoUtil.CELL_ID); -// mRuntime.cellinfo = mCellInfo; + mRuntime.cellinfo = mCellInfo; } -// FileOutputUtil.fileOutput((mRuntime.getContextProxy()).context, "onCellLocationChanged", mCellInfo); + FileOutputUtil.fileOutput((mRuntime.getContextProxy()).context, "onCellLocationChanged", mCellInfo); CellInfoUtil.releaseWakeLock(mWakeLock); return; } @@ -100,7 +102,8 @@ public class CellInfoUtil { CellInfoUtil.CELL_ID = -1; CellInfoUtil.BSSS = 0; // CellInfoUtil.access$002(2); -// Runtime runtime = mRuntime; + CellInfoUtil.IS2SECOND=2; + Runtime runtime = mRuntime; StringBuilder stringBuilder = new StringBuilder(); stringBuilder.append(CellInfoUtil.MCC); stringBuilder.append("@"); @@ -111,9 +114,9 @@ public class CellInfoUtil { stringBuilder.append(CellInfoUtil.CELL_ID); stringBuilder.append("@"); stringBuilder.append(CellInfoUtil.BSSS); -// runtime.cellinfo = stringBuilder.toString(); + runtime.cellinfo = stringBuilder.toString(); // EqcAlgorithmNative.native_EqcAlgorithmMethod4(1, 0, CellInfoUtil.BSSS, CellInfoUtil.MCC, CellInfoUtil.MNC, CellInfoUtil.LAC, CellInfoUtil.CELL_ID); -// FileOutputUtil.fileOutput((mRuntime.getContextProxy()).context, "onCellLocationChanged", mRuntime.cellinfo); + FileOutputUtil.fileOutput((mRuntime.getContextProxy()).context, "onCellLocationChanged", mRuntime.cellinfo); CellInfoUtil.releaseWakeLock(mWakeLock); return; } diff --git a/app/src/main/java/com/ic/protocol/utils/ExeCommand.java b/app/src/main/java/com/ic/protocol/utils/ExeCommand.java new file mode 100644 index 00000000..6276eb75 --- /dev/null +++ b/app/src/main/java/com/ic/protocol/utils/ExeCommand.java @@ -0,0 +1,214 @@ +package com.ic.protocol.utils; + +import android.os.Environment; +import android.util.Log; + +import java.io.BufferedReader; +import java.io.DataOutputStream; +import java.io.InputStreamReader; +import java.util.concurrent.locks.Lock; +import java.util.concurrent.locks.ReadWriteLock; +import java.util.concurrent.locks.ReentrantReadWriteLock; + +import static java.lang.Runtime.getRuntime; + +/** + * 执行命令的类 + * Created by Kappa + */ +public class ExeCommand { + //shell进程 + private Process process; + //对应进程的3个流 + private BufferedReader successResult; + private BufferedReader errorResult; + private DataOutputStream os; + //是否同步,true:run会一直阻塞至完成或超时。false:run会立刻返回 + private boolean bSynchronous; + //表示shell进程是否还在运行 + private boolean bRunning = false; + //同步锁 + ReadWriteLock lock = new ReentrantReadWriteLock(); + + //保存执行结果 + private StringBuffer result = new StringBuffer(); + + /** + * 构造函数 + * + * @param synchronous true:同步,false:异步 + */ + public ExeCommand(boolean synchronous) { + bSynchronous = synchronous; + } + + /** + * 默认构造函数,默认是同步执行 + */ + public ExeCommand() { + bSynchronous = true; + } + + /** + * 还没开始执行,和已经执行完成 这两种情况都返回false + * + * @return 是否正在执行 + */ + public boolean isRunning() { + return bRunning; + } + + /** + * @return 返回执行结果 + */ + public String getResult() { + Lock readLock = lock.readLock(); + readLock.lock(); + try { + Log.i("auto", "getResult"); + return new String(result); + } finally { + readLock.unlock(); + } + } + + /** + * 执行命令 + * + * @param command eg: cat /sdcard/test.txt + * 路径最好不要是自己拼写的路径,最好是通过方法获取的路径 + * example:Environment.getExternalStorageDirectory() + * @param maxTime 最大等待时间 (ms) + * @return this + */ + public ExeCommand run(String command, final int maxTime) { + Log.i("auto", "run command:" + command + ",maxtime:" + maxTime); + if (command == null || command.length() == 0) { + return this; + } + + try { + process = getRuntime().exec("sh");//看情况可能是su + } catch (Exception e) { + return this; + } + bRunning = true; + successResult = new BufferedReader(new InputStreamReader(process.getInputStream())); + errorResult = new BufferedReader(new InputStreamReader(process.getErrorStream())); + os = new DataOutputStream(process.getOutputStream()); + + try { + //向sh写入要执行的命令 + os.write(command.getBytes()); + os.writeBytes("\n"); + os.flush(); + + os.writeBytes("exit\n"); + os.flush(); + + os.close(); + //如果等待时间设置为非正,就不开启超时关闭功能 + if (maxTime > 0) { + //超时就关闭进程 + new Thread(new Runnable() { + @Override + public void run() { + try { + Thread.sleep(maxTime); + } catch (Exception e) { + } + try { + int ret = process.exitValue(); + Log.i("auto", "exitValue Stream over"+ret); + } catch (IllegalThreadStateException e) { + Log.i("auto", "take maxTime,forced to destroy process"); + process.destroy(); + } + } + }).start(); + } + + //开一个线程来处理input流 + final Thread t1 = new Thread(new Runnable() { + @Override + public void run() { + String line; + Lock writeLock = lock.writeLock(); + try { + while ((line = successResult.readLine()) != null) { + line += "\n"; + writeLock.lock(); + result.append(line); + writeLock.unlock(); + } + } catch (Exception e) { + Log.i("auto", "read InputStream exception:" + e.toString()); + } finally { + try { + successResult.close(); + Log.i("auto", "read InputStream over"); + } catch (Exception e) { + Log.i("auto", "close InputStream exception:" + e.toString()); + } + } + } + }); + t1.start(); + + //开一个线程来处理error流 + final Thread t2 = new Thread(new Runnable() { + @Override + public void run() { + String line; + Lock writeLock = lock.writeLock(); + try { + while ((line = errorResult.readLine()) != null) { + line += "\n"; + writeLock.lock(); + result.append(line); + writeLock.unlock(); + } + } catch (Exception e) { + Log.i("auto", "read ErrorStream exception:" + e.toString()); + } finally { + try { + errorResult.close(); + Log.i("auto", "read ErrorStream over"); + } catch (Exception e) { + Log.i("auto", "read ErrorStream exception:" + e.toString()); + } + } + } + }); + t2.start(); + + Thread t3 = new Thread(new Runnable() { + @Override + public void run() { + try { + //等待执行完毕 + t1.join(); + t2.join(); + process.waitFor(); + } catch (Exception e) { + + } finally { + bRunning = false; + Log.i("auto", "run command process end"); + } + } + }); + t3.start(); + + if (bSynchronous) { + Log.i("auto", "run is go to end"); + t3.join(); + Log.i("auto", "run is end"); + } + } catch (Exception e) { + Log.i("auto", "run command process exception:" + e.toString()); + } + return this; + } + +} \ No newline at end of file diff --git a/app/src/main/java/com/ic/protocol/utils/StepCounterInterface.java b/app/src/main/java/com/ic/protocol/utils/StepCounterInterface.java new file mode 100644 index 00000000..8929e297 --- /dev/null +++ b/app/src/main/java/com/ic/protocol/utils/StepCounterInterface.java @@ -0,0 +1,73 @@ +package com.ic.protocol.utils; + +public class StepCounterInterface { + + /** + * shell@sp9820e_1h10:/ $ icsu sctool + * sctool [-sredgcxh] + * -s Save StepCount to disk + * -r Recover StepCount from disk + * -e Enable Step Counter + * -d Disable Step Counter + * -g Get StepCount + * -c Clear StepCount + * -x Get StepCounter enable status + * -h Print help + * shell@sp9820e_1h10:/ $ icsu sctool -e + */ + + public static int stepCount; + public static void enableStepCounter(){ + runcmd("icsu sctool -e"); + } + + public static void disableStepCounter(){ + runcmd("icsu sctool -d"); + } + + public static int getStepCount(){ + + String strCount= runcmd_withreturn("icsu sctool -g"); + if (strCount != null && !strCount.isEmpty()){ + Logger.i("StepCount "+strCount); + strCount=strCount.replace("\r","").replace("\n",""); + try { + int mstepCount =Integer.parseInt(strCount); + stepCount=mstepCount; + }catch (Exception e){ + e.printStackTrace(); + } + } + return stepCount; + } + + public static void cleanStepCount(){ + stepCount=0; + runcmd("icsu sctool -c"); + } + + + private static void runcmd(String cmd){ + + new ExeCommand(false).run(cmd,500); + + } + + private static String runcmd_withreturn(String cmd){ + String ret=""; + ExeCommand runcmd = new ExeCommand(false).run(cmd, 60000); + while(runcmd.isRunning()) + { + try { + Thread.sleep(1000); + } catch (Exception e) { + + } + String buf = runcmd.getResult(); + //do something + return buf; + } + return ""; + } + +} diff --git a/app/version_code.properties b/app/version_code.properties index 42f186d6..07f202d3 100644 --- a/app/version_code.properties +++ b/app/version_code.properties @@ -1,2 +1,2 @@ -#Tue Jan 07 09:02:29 CST 2020 -VERSION_CODE=110 +#Tue Jan 07 10:15:46 CST 2020 +VERSION_CODE=113 diff --git a/library/library.iml b/library/library.iml deleted file mode 100644 index e700d8a6..00000000 --- a/library/library.iml +++ /dev/null @@ -1,81 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/settings.gradle b/settings.gradle index 186294c1..47825c7a 100644 --- a/settings.gradle +++ b/settings.gradle @@ -1 +1 @@ -include ':app', ':okio', ':library' +include ':app', ':okio'