Commit fc157a75 authored by Administrator's avatar Administrator

udpate

parent 5cd0d967
...@@ -42,9 +42,6 @@ public class MainActivity extends AppCompatActivity implements View.OnClickListe ...@@ -42,9 +42,6 @@ public class MainActivity extends AppCompatActivity implements View.OnClickListe
Button button = findViewById(R.id.btn_report); Button button = findViewById(R.id.btn_report);
button.setOnClickListener(this); button.setOnClickListener(this);
String clientKey = Settings.System.getString(getContentResolver(), Settings.Secure.ANDROID_ID);
textView.setText("device: " + clientKey + "\n\n");
BDLocationUtils bdLocationUtils = new BDLocationUtils(this); BDLocationUtils bdLocationUtils = new BDLocationUtils(this);
//开启定位 //开启定位
...@@ -78,10 +75,7 @@ public class MainActivity extends AppCompatActivity implements View.OnClickListe ...@@ -78,10 +75,7 @@ public class MainActivity extends AppCompatActivity implements View.OnClickListe
//待上传的设备信息:devicesMsg //待上传的设备信息:devicesMsg
JSONObject deviceMsg = DeviceMessageUtil.getDeviceMessage(this); JSONObject deviceMsg = DeviceMessageUtil.getDeviceMessage(this);
String clientKey = Settings.System.getString(getContentResolver(), Settings.Secure.ANDROID_ID); textView.setText(deviceMsg.toString());
String text = "device: " + clientKey + "\n\n";
textView.setText(text + deviceMsg);
Request request = HttpClientUtils.postRequest("http://taskcenter.beta.qunar.com/api/phone/report", deviceMsg); Request request = HttpClientUtils.postRequest("http://taskcenter.beta.qunar.com/api/phone/report", deviceMsg);
......
...@@ -17,6 +17,7 @@ import android.os.Bundle; ...@@ -17,6 +17,7 @@ import android.os.Bundle;
import android.provider.Settings; import android.provider.Settings;
import android.support.v4.app.ActivityCompat; import android.support.v4.app.ActivityCompat;
import android.support.v4.content.ContextCompat; import android.support.v4.content.ContextCompat;
import android.text.TextUtils;
import android.util.Log; import android.util.Log;
import com.google.common.collect.Lists; import com.google.common.collect.Lists;
...@@ -86,7 +87,7 @@ public class DeviceMessageUtil { ...@@ -86,7 +87,7 @@ public class DeviceMessageUtil {
String slaveInfo = getSlaveInfo(context); String slaveInfo = getSlaveInfo(context);
String deviceId; String deviceId;
switch (channel){ switch (channel) {
case 0: case 0:
deviceId = getSerialNumber(); deviceId = getSerialNumber();
Log.e(DeviceMsg, "channel: " + channel); Log.e(DeviceMsg, "channel: " + channel);
...@@ -158,7 +159,7 @@ public class DeviceMessageUtil { ...@@ -158,7 +159,7 @@ public class DeviceMessageUtil {
} }
} }
} }
if(location == null){ if (location == null) {
latAndLon.put(latitude, "" + Const.LATITUDE); latAndLon.put(latitude, "" + Const.LATITUDE);
latAndLon.put(longitude, "" + Const.LONGITUDE); latAndLon.put(longitude, "" + Const.LONGITUDE);
} }
...@@ -167,7 +168,7 @@ public class DeviceMessageUtil { ...@@ -167,7 +168,7 @@ public class DeviceMessageUtil {
Log.e(DeviceMsg, "Longitude: " + String.valueOf(location.getLongitude())); Log.e(DeviceMsg, "Longitude: " + String.valueOf(location.getLongitude()));
latAndLon.put(latitude, String.valueOf(location.getLatitude())); latAndLon.put(latitude, String.valueOf(location.getLatitude()));
latAndLon.put(longitude, String.valueOf(location.getLongitude())); latAndLon.put(longitude, String.valueOf(location.getLongitude()));
}else{ } else {
Log.e(DeviceMsg, "location is null"); Log.e(DeviceMsg, "location is null");
} }
return latAndLon; return latAndLon;
...@@ -358,7 +359,7 @@ public class DeviceMessageUtil { ...@@ -358,7 +359,7 @@ public class DeviceMessageUtil {
if (firstLine != null) { if (firstLine != null) {
slaveInfo = firstLine.split(",")[0]; slaveInfo = firstLine.split(",")[0];
channel = Integer.valueOf(firstLine.split(",")[1]); channel = Integer.valueOf(firstLine.split(",")[1]);
}else{ } else {
Log.e(DeviceMsg, "slave_info.txt can not be parsed!"); Log.e(DeviceMsg, "slave_info.txt can not be parsed!");
} }
return slaveInfo; return slaveInfo;
...@@ -409,8 +410,26 @@ public class DeviceMessageUtil { ...@@ -409,8 +410,26 @@ public class DeviceMessageUtil {
/** /**
* 获取手机android_id * 获取手机android_id
*/ */
private static String getAndroidID(Context context){ private static String getAndroidID(Context context) {
String sandboxIdpath = "/sdcard/qb/android_id.txt";
String firstLine = null;
try {
FileReader fileReader = new FileReader(sandboxIdpath);
BufferedReader br = new BufferedReader(fileReader, 8192);
firstLine = br.readLine();
br.close();
if (!TextUtils.isEmpty(firstLine)) {
return firstLine;
}
} catch (Exception e) {
Log.e(DeviceMsg, "Cannot find slave_info.txt !");
e.printStackTrace();
}
String slaveInfo = null;
// 另一种获取方式 // 另一种获取方式
// DeviceInfoHolder.getCachedAndroidId(context) // DeviceInfoHolder.getCachedAndroidId(context)
return Settings.System.getString(context.getContentResolver(), Settings.Secure.ANDROID_ID); return Settings.System.getString(context.getContentResolver(), Settings.Secure.ANDROID_ID);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment