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,15 +31,18 @@ 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) {
Bundle bundle = new Bundle(); List<JSONArray> splitted = BroadcastTreatment.splitArray(statuses);
bundle.putString("devicestatuses", statuses.toString()); for (JSONArray part: splitted) {
bundle.putBoolean("delta", isDelta); Bundle bundle = new Bundle();
Intent intent = new Intent(Intents.ACTION_NEW_DEVICESTATUS); bundle.putString("devicestatuses", part.toString());
intent.putExtras(bundle); bundle.putBoolean("delta", isDelta);
intent.addFlags(Intent.FLAG_INCLUDE_STOPPED_PACKAGES); Intent intent = new Intent(Intents.ACTION_NEW_DEVICESTATUS);
context.sendBroadcast(intent); intent.putExtras(bundle);
List<ResolveInfo> x = context.getPackageManager().queryBroadcastReceivers(intent, 0); intent.addFlags(Intent.FLAG_INCLUDE_STOPPED_PACKAGES);
context.sendBroadcast(intent);
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();