split device statuses too before broadcast

This commit is contained in:
Milos Kozak 2017-06-30 10:57:29 +02:00
parent f0c9ce5a00
commit 51b01a0993
2 changed files with 13 additions and 10 deletions

View file

@ -31,8 +31,10 @@ public class BroadcastDeviceStatus {
log.debug("DEVICESTATUS " + x.size() + " receivers"); log.debug("DEVICESTATUS " + x.size() + " receivers");
} }
public static void handleNewDeviceStatus(JSONArray statuses, Context context, boolean isDelta) { public static void handleNewDeviceStatus(JSONArray statuses, Context context, boolean isDelta) {
List<JSONArray> splitted = BroadcastTreatment.splitArray(statuses);
for (JSONArray part: splitted) {
Bundle bundle = new Bundle(); Bundle bundle = new Bundle();
bundle.putString("devicestatuses", statuses.toString()); bundle.putString("devicestatuses", part.toString());
bundle.putBoolean("delta", isDelta); bundle.putBoolean("delta", isDelta);
Intent intent = new Intent(Intents.ACTION_NEW_DEVICESTATUS); Intent intent = new Intent(Intents.ACTION_NEW_DEVICESTATUS);
intent.putExtras(bundle); intent.putExtras(bundle);
@ -40,6 +42,7 @@ public class BroadcastDeviceStatus {
context.sendBroadcast(intent); context.sendBroadcast(intent);
List<ResolveInfo> x = context.getPackageManager().queryBroadcastReceivers(intent, 0); List<ResolveInfo> x = context.getPackageManager().queryBroadcastReceivers(intent, 0);
log.debug("DEVICESTATUS " + x.size() + " receivers"); log.debug("DEVICESTATUS " + part.length() + " records " + x.size() + " receivers");
}
} }
} }

View file

@ -114,7 +114,7 @@ public class BroadcastTreatment {
} }
private static List<JSONArray> splitArray(JSONArray array) { public static List<JSONArray> splitArray(JSONArray array) {
List<JSONArray> ret = new ArrayList<>(); List<JSONArray> ret = new ArrayList<>();
try { try {
int size = array.length(); int size = array.length();