|
|
@@ -141,7 +141,7 @@ public class ConfigManager { |
|
|
|
getReception(); |
|
|
|
} |
|
|
|
if((data & 0x10000) > 0){ |
|
|
|
|
|
|
|
getConfig(); |
|
|
|
} |
|
|
|
} else { |
|
|
|
onFail(obj.getString("msg")); |
|
|
@@ -343,14 +343,14 @@ public class ConfigManager { |
|
|
|
model.workdayHour = new WorkDayHour().create(jsonObject.optJSONObject("workdayHour")); |
|
|
|
} |
|
|
|
if(jsonObject.has("broadcast")){ |
|
|
|
JSONArray array = jsonObject.getJSONArray("broadcast"); |
|
|
|
JSONObject object = jsonObject.getJSONObject("broadcast"); |
|
|
|
// List<Broadcast> broadcasts = new ArrayList<>(); |
|
|
|
// for (int i = 0; i < array.length(); i++) { |
|
|
|
// JSONObject broadcastObj = array.getJSONObject(i); |
|
|
|
// Broadcast broadcast = new Broadcast().create(broadcastObj); |
|
|
|
// broadcasts.add(broadcast); |
|
|
|
// } |
|
|
|
MessageUtils.sendBroadcast(array.toString()); |
|
|
|
MessageUtils.sendBroadcast(object.toString()); |
|
|
|
} |
|
|
|
ModelDbHelper.getInstance().add(model); |
|
|
|
if (obj.has("timestamp")) { |
|
|
@@ -424,6 +424,52 @@ public class ConfigManager { |
|
|
|
}); |
|
|
|
} |
|
|
|
|
|
|
|
private void getConfig() { |
|
|
|
HashMap<String, String> map = new HashMap<>(); |
|
|
|
map.put("id", "123456"); |
|
|
|
map.put("devId", StatusUtils.getSerialNumber()); |
|
|
|
map.put("type", "4"); |
|
|
|
map.put("sign", "123456"); |
|
|
|
map.put("enterpriseName", "administrator"); |
|
|
|
map.put("timestamp", "1"); |
|
|
|
RequestBody requestBody = RequestBody.create(MediaType.parse("application/json"), new JSONObject(map).toString()); |
|
|
|
HttpUtil.post(Config.CURRENT_URL + "message/api/update", requestBody, null, new HttpUtil.HttpCallback<String>() { |
|
|
|
|
|
|
|
@Override |
|
|
|
public void onSuccess(String success) { |
|
|
|
Log.e(TAG, "getReception = " + success); |
|
|
|
try { |
|
|
|
JSONTokener t = new JSONTokener(success); |
|
|
|
JSONObject obj = (JSONObject) t.nextValue(); |
|
|
|
int code = 0; |
|
|
|
if (obj.has("code")) { |
|
|
|
code = obj.getInt("code"); |
|
|
|
} |
|
|
|
if (code == 200) { |
|
|
|
// MessageUtils.sendMessage("接待任务:" + success); |
|
|
|
if (obj.has("data")) { |
|
|
|
JSONObject object = obj.getJSONObject("data"); |
|
|
|
if (object.has("msg")) { |
|
|
|
JSONObject config = object.getJSONObject("msg"); |
|
|
|
MessageUtils.sendConfig(config.toString()); |
|
|
|
} |
|
|
|
} |
|
|
|
} else { |
|
|
|
onFail(obj.getString("msg")); |
|
|
|
} |
|
|
|
} catch (Exception e) { |
|
|
|
e.printStackTrace(); |
|
|
|
onFail(e.getMessage()); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
@Override |
|
|
|
public void onFail(String error) { |
|
|
|
Log.e(TAG, "getReception = " + error); |
|
|
|
} |
|
|
|
}); |
|
|
|
} |
|
|
|
|
|
|
|
private void checkServiceStatus(){ |
|
|
|
boolean survive = Utils.isProcessAlive("com.lecooai.lewatchdog");//packageName |
|
|
|
Log.e(TAG, "进程是存活: " + survive + ", PID: " + survive); |
|
|
|