Commit 05da71ce by cuiliang.shi

360 属性更新 以及 更新 取优化点算法

1 parent aa4d5f7c
...@@ -33,4 +33,7 @@ dependencies { ...@@ -33,4 +33,7 @@ dependencies {
androidTestImplementation 'com.android.support.test:runner:1.0.2' androidTestImplementation 'com.android.support.test:runner:1.0.2'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2' androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
implementation 'com.amap.api:location:4.5.1' implementation 'com.amap.api:location:4.5.1'
implementation 'com.amap.api:map2d:5.2.0'
} }
...@@ -32,6 +32,8 @@ import com.amap.api.location.AMapLocation; ...@@ -32,6 +32,8 @@ import com.amap.api.location.AMapLocation;
import com.amap.api.location.AMapLocationClient; import com.amap.api.location.AMapLocationClient;
import com.amap.api.location.AMapLocationClientOption; import com.amap.api.location.AMapLocationClientOption;
import com.amap.api.location.AMapLocationListener; import com.amap.api.location.AMapLocationListener;
import com.amap.api.maps2d.AMapUtils;
import com.amap.api.maps2d.model.LatLng;
import org.json.JSONObject; import org.json.JSONObject;
...@@ -69,6 +71,10 @@ public class BirdService extends Service { ...@@ -69,6 +71,10 @@ public class BirdService extends Service {
private String ret_cfgv = "2019031512"; private String ret_cfgv = "2019031512";
private LocationManager mLocationManager; private LocationManager mLocationManager;
private int mNewMsgCount = 0; private int mNewMsgCount = 0;
private double mWifiLatitude = 0;
private double mWifiLongitude = 0;
private double mGpsLatitude = 0;
private double mGpsLongitude = 0;
@Override @Override
public IBinder onBind(Intent intent) { public IBinder onBind(Intent intent) {
...@@ -115,6 +121,9 @@ public class BirdService extends Service { ...@@ -115,6 +121,9 @@ public class BirdService extends Service {
private int mLocationCount = 0; private int mLocationCount = 0;
private float mAccuracy = 10000; private float mAccuracy = 10000;
private float mWifiAccuracy = 1000;
private float mGpsAccuracy = 1000;
public AMapLocationListener mLocationListener = new AMapLocationListener() { public AMapLocationListener mLocationListener = new AMapLocationListener() {
@Override @Override
...@@ -123,6 +132,7 @@ public class BirdService extends Service { ...@@ -123,6 +132,7 @@ public class BirdService extends Service {
if (amapLocation != null) { if (amapLocation != null) {
if (amapLocation.getErrorCode() == 0) { if (amapLocation.getErrorCode() == 0) {
mLocationCount++; mLocationCount++;
Log.d(TAG, "amapLocation.getLatitude(): " + amapLocation.getLatitude() Log.d(TAG, "amapLocation.getLatitude(): " + amapLocation.getLatitude()
+ ", amapLocation.getLongitude(): " + amapLocation.getLongitude() + ", amapLocation.getLongitude(): " + amapLocation.getLongitude()
+ ", amapLocation.getAccuracy():"+amapLocation.getAccuracy() + ", amapLocation.getAccuracy():"+amapLocation.getAccuracy()
...@@ -130,11 +140,49 @@ public class BirdService extends Service { ...@@ -130,11 +140,49 @@ public class BirdService extends Service {
if (amapLocation.getAccuracy() < mAccuracy){ if (amapLocation.getAccuracy() < mAccuracy){
mAccuracy = amapLocation.getAccuracy(); mAccuracy = amapLocation.getAccuracy();
mLatitude = String.valueOf(amapLocation.getLatitude()); mLatitude = String.valueOf(amapLocation.getLatitude());
mLongitude = String.valueOf(amapLocation.getLongitude()); mLongitude = String.valueOf(amapLocation.getLongitude());
} }
if (amapLocation.getLocationType() == 5){
if (amapLocation.getAccuracy() < mWifiAccuracy){
mWifiAccuracy = amapLocation.getAccuracy();
mWifiLatitude = amapLocation.getLatitude();
mWifiLongitude = amapLocation.getLongitude();
}
}
if (amapLocation.getLocationType() == 1){
if (amapLocation.getAccuracy() < mGpsAccuracy){
mGpsAccuracy = amapLocation.getAccuracy();
mGpsLatitude = amapLocation.getLatitude();
mGpsLongitude = amapLocation.getLongitude();
}
}
if (mLocationCount > 15){ if (mLocationCount > 15){
if (mWifiLatitude != 0 && mWifiLongitude != 0
&& mGpsLatitude != 0 && mGpsLongitude !=0){
LatLng wifiLatLng = new LatLng(mWifiLatitude, mWifiLongitude);
LatLng gpsLatLng = new LatLng(mGpsLatitude, mGpsLongitude);
float distance = AMapUtils.calculateLineDistance(wifiLatLng, gpsLatLng);
Log.d(TAG, "distance: " + distance +
", mWifiAccuracy:" + mWifiAccuracy +
", mGpsAccuracy: " + mGpsAccuracy);
if (distance > mWifiAccuracy + 60){
mLatitude = String.valueOf(mWifiLatitude);
mLongitude = String.valueOf(mWifiLongitude);
mAccuracy = mWifiAccuracy;
}else{
mLatitude = String.valueOf(mGpsLatitude);
mLongitude = String.valueOf(mGpsLongitude);
mAccuracy = mGpsAccuracy;
}
}
Log.d(TAG, "LAST PERFECT INFO amapLocation.getLatitude(): " + mLatitude Log.d(TAG, "LAST PERFECT INFO amapLocation.getLatitude(): " + mLatitude
+ ", amapLocation.getLongitude(): " + mLongitude + ", amapLocation.getLongitude(): " + mLongitude
+ ", amapLocation.getAccuracy():" + mAccuracy); + ", amapLocation.getAccuracy():" + mAccuracy);
...@@ -338,7 +386,8 @@ public class BirdService extends Service { ...@@ -338,7 +386,8 @@ public class BirdService extends Service {
mIMSIStr = temp_imsi.substring(0, temp_imsi.length() - 1); mIMSIStr = temp_imsi.substring(0, temp_imsi.length() - 1);
mICCIDStr = temp_iccid.substring(0, temp_iccid.length() - 1); mICCIDStr = temp_iccid.substring(0, temp_iccid.length() - 1);
String temp_model = Build.MODEL; // String temp_model = Build.MODEL;
String temp_model = PhoneUtils.getProperty("ro.qiku.custom.model", "undefined");
mModel = temp_model.trim().replaceAll(" ", ""); mModel = temp_model.trim().replaceAll(" ", "");
} }
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!