更新 HeartbeatWorker.java

dev
wangsiyuan 2023-12-08 21:04:10 +08:00
parent 4009796ac2
commit 935bd0edc3
1 changed files with 4 additions and 1 deletions

View File

@ -23,6 +23,7 @@ import timber.log.Timber;
public class HeartbeatWorker extends Worker { public class HeartbeatWorker extends Worker {
private final Context context; private final Context context;
private String accessToken; private String accessToken;
private String SN;
public HeartbeatWorker(@NonNull Context context, @NonNull WorkerParameters workerParams) { public HeartbeatWorker(@NonNull Context context, @NonNull WorkerParameters workerParams) {
@ -66,11 +67,13 @@ public class HeartbeatWorker extends Worker {
} }
private <T>Request buildRequest(String apiUrl){ private <T>Request buildRequest(String apiUrl){
SN = context.getResources().getString(R.string.SN);
accessToken = context.getResources().getString(R.string.access_token); accessToken = context.getResources().getString(R.string.access_token);
DeviceInfo deviceInfo = new DeviceInfo(); DeviceInfo deviceInfo = new DeviceInfo();
deviceInfo.setDeviceBrand(DeviceInfoUtils.getDeviceBrand()); deviceInfo.setDeviceBrand(DeviceInfoUtils.getDeviceBrand());
deviceInfo.setDeviceModel(DeviceInfoUtils.getDeviceModel()); deviceInfo.setDeviceModel(DeviceInfoUtils.getDeviceModel());
deviceInfo.setAndroidVersion(DeviceInfoUtils.getDeviceAndroidVersion()); deviceInfo.setAndroidVersion("Android " + DeviceInfoUtils.getDeviceAndroidVersion());
deviceInfo.setSN(SN);
Gson gson = new Gson(); Gson gson = new Gson();
// 将对象转换为JSON字符串 // 将对象转换为JSON字符串
String json = gson.toJson(deviceInfo); String json = gson.toJson(deviceInfo);