@@ -58,39 +58,44 @@ public Set<SupportedCluster> getSupportedClusters(final Resources resources, fin
58
58
SupportedCluster cluster = new SupportedCluster ();
59
59
while (reader .hasNext ()) {
60
60
String name = reader .nextName ();
61
- if (name .equals (KEY_CLUSTER_ID )) {
62
- cluster .clusterIdentifier = reader .nextInt ();
63
- } else if (name .equals (KEY_FEATURE_FLAGS )) {
64
- cluster .features = reader .nextInt ();
65
- } else if (name .equals (KEY_OPTIONAL_COMMANDS )) {
66
- List <Integer > commands = new ArrayList <>();
67
- reader .beginArray ();
68
- while (reader .hasNext ()) {
69
- commands .add (reader .nextInt ());
70
- }
71
- reader .endArray ();
72
- int [] commandIds = new int [commands .size ()];
73
- int i = 0 ;
74
- for (Integer command : commands ) {
75
- commandIds [i ++] = command ;
76
- }
77
- cluster .optionalCommandIdentifiers = commandIds ;
78
- } else if (name .equals (KEY_OPTIONAL_ATTRIBUTES )) {
79
- List <Integer > attributes = new ArrayList <>();
80
- reader .beginArray ();
81
- while (reader .hasNext ()) {
82
- attributes .add (reader .nextInt ());
83
- }
84
- reader .endArray ();
85
- int [] attributeIds = new int [attributes .size ()];
86
- int i = 0 ;
87
- for (Integer command : attributes ) {
88
- attributeIds [i ++] = command ;
89
- }
90
- cluster .optionalAttributesIdentifiers = attributeIds ;
91
- } else {
61
+ try {
62
+ if (name .equals (KEY_CLUSTER_ID )) {
63
+ cluster .clusterIdentifier = reader .nextInt ();
64
+ } else if (name .equals (KEY_FEATURE_FLAGS )) {
65
+ cluster .features = reader .nextInt ();
66
+ } else if (name .equals (KEY_OPTIONAL_COMMANDS )) {
67
+ List <Integer > commands = new ArrayList <>();
68
+ reader .beginArray ();
69
+ while (reader .hasNext ()) {
70
+ commands .add (reader .nextInt ());
71
+ }
72
+ reader .endArray ();
73
+ int [] commandIds = new int [commands .size ()];
74
+ int i = 0 ;
75
+ for (Integer command : commands ) {
76
+ commandIds [i ++] = command ;
77
+ }
78
+ cluster .optionalCommandIdentifiers = commandIds ;
79
+ } else if (name .equals (KEY_OPTIONAL_ATTRIBUTES )) {
80
+ List <Integer > attributes = new ArrayList <>();
81
+ reader .beginArray ();
82
+ while (reader .hasNext ()) {
83
+ attributes .add (reader .nextInt ());
84
+ }
85
+ reader .endArray ();
86
+ int [] attributeIds = new int [attributes .size ()];
87
+ int i = 0 ;
88
+ for (Integer command : attributes ) {
89
+ attributeIds [i ++] = command ;
90
+ }
91
+ cluster .optionalAttributesIdentifiers = attributeIds ;
92
+ } else {
92
93
reader .skipValue ();
93
94
}
95
+ } catch (NumberFormatException | IllegalStateException e ) {
96
+ Log .e (TAG , "Invalid number format in JSON for key: " + name , e );
97
+ reader .skipValue (); // Skip the invalid entry
98
+ }
94
99
}
95
100
supportedClusters .add (cluster );
96
101
reader .endObject ();
0 commit comments