Skip to content

Commit 3947206

Browse files
joonhaengHeorestyled-commits
authored andcommitted
[Android] Implement OTA Provider exception case (#30777)
* Implement Android OTA Provider exception case * Restyled by google-java-format * Restyled by clang-format * Add TooManyFunctions exception --------- Co-authored-by: Restyled.io <[email protected]>
1 parent 44ace9f commit 3947206

File tree

8 files changed

+726
-42
lines changed

8 files changed

+726
-42
lines changed

examples/android/CHIPTool/app/src/main/java/com/google/chip/chiptool/clusterclient/OtaProviderClientFragment.kt

+383-12
Large diffs are not rendered by default.

examples/android/CHIPTool/app/src/main/res/layout/add_access_control_dialog.xml

+15-2
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,19 @@
2424
android:layout_marginBottom="8dp"
2525
app:layout_constraintStart_toStartOf="parent"
2626
app:layout_constraintTop_toBottomOf="@id/titleText"
27+
app:layout_constraintBottom_toTopOf="@+id/nodeIdEd"/>
28+
29+
<EditText
30+
android:id="@+id/nodeIdEd"
31+
android:layout_width="wrap_content"
32+
android:layout_height="wrap_content"
33+
android:hint="@string/ota_provider_node_id_text"
34+
android:inputType="number"
35+
android:textSize="16sp"
36+
android:layout_marginBottom="8dp"
37+
android:visibility="gone"
38+
app:layout_constraintStart_toStartOf="parent"
39+
app:layout_constraintTop_toBottomOf="@id/groupIdEd"
2740
app:layout_constraintBottom_toTopOf="@+id/accessControlEntryTv"/>
2841

2942
<TextView
@@ -34,7 +47,7 @@
3447
android:textSize="16sp"
3548
android:layout_marginTop="8dp"
3649
app:layout_constraintStart_toStartOf="parent"
37-
app:layout_constraintTop_toBottomOf="@id/groupIdEd"
50+
app:layout_constraintTop_toBottomOf="@id/nodeIdEd"
3851
app:layout_constraintBottom_toTopOf="@id/accessControlEntrySp"
3952
/>
4053

@@ -47,7 +60,7 @@
4760
android:layout_marginBottom="8dp"
4861
app:layout_constraintStart_toStartOf="parent"
4962
app:layout_constraintTop_toBottomOf="@id/accessControlEntryTv"
50-
app:layout_constraintBottom_toTopOf="@+id/addGroupDialogBtn"/>
63+
app:layout_constraintBottom_toTopOf="@+id/addAccessControlBtn"/>
5164

5265
<Button
5366
android:id="@+id/addAccessControlBtn"

examples/android/CHIPTool/app/src/main/res/layout/ota_provider_client_fragment.xml

+143-15
Original file line numberDiff line numberDiff line change
@@ -11,30 +11,148 @@
1111
android:layout_alignParentStart="true"
1212
android:layout_alignParentTop="true" />
1313

14+
<TextView
15+
android:id="@+id/titleStatus"
16+
android:layout_width="match_parent"
17+
android:layout_height="wrap_content"
18+
android:text="@string/ota_provider_query_image_response_status_text"
19+
android:textSize="16sp"
20+
android:layout_below="@id/addressUpdateFragment" />
21+
22+
<Spinner
23+
android:id="@+id/titleStatusSp"
24+
android:layout_width="wrap_content"
25+
android:layout_height="wrap_content"
26+
android:hint="@string/subscribe_dialog_keep_subscriptions_hint"
27+
android:inputType="text"
28+
android:spinnerMode="dropdown"
29+
android:textSize="16sp"
30+
android:layout_below="@id/titleStatus" />
31+
1432
<EditText
1533
android:layout_width="wrap_content"
1634
android:layout_height="wrap_content"
17-
android:id="@+id/vendorIdTv"
35+
android:id="@+id/delayActionTimeTv"
1836
android:textSize="16sp"
1937
android:padding="16dp"
20-
android:layout_margin="8dp"
2138
android:layout_alignParentStart="true"
2239
android:enabled="false"
23-
android:text="@string/ota_provider_vendorId_text"
24-
android:layout_below="@id/addressUpdateFragment" />
40+
android:text="@string/ota_provider_delayed_action_time_text"
41+
android:visibility="gone"
42+
android:layout_below="@id/titleStatusSp" />
2543

2644
<EditText
2745
android:layout_width="match_parent"
2846
android:layout_height="wrap_content"
29-
android:id="@+id/vendorIdEd"
47+
android:id="@+id/delayActionTimeEd"
3048
android:textSize="16sp"
3149
android:padding="16dp"
32-
android:layout_margin="8dp"
50+
android:visibility="gone"
3351
android:layout_toEndOf="@id/vendorIdTv"
34-
android:layout_below="@id/addressUpdateFragment"
35-
android:autofillHints="@string/ota_provider_vendorId_text"
52+
android:layout_below="@id/titleStatusSp"
53+
android:autofillHints="@string/ota_provider_delayed_action_time_text"
3654
android:inputType="numberDecimal" />
3755

56+
<TextView
57+
android:id="@+id/titleUserConsentNeeded"
58+
android:layout_width="match_parent"
59+
android:layout_height="wrap_content"
60+
android:text="@string/ota_provider_user_consent_needed_text"
61+
android:textSize="16sp"
62+
android:layout_below="@id/delayActionTimeTv" />
63+
64+
<Spinner
65+
android:id="@+id/titleUserConsentNeededSp"
66+
android:layout_width="wrap_content"
67+
android:layout_height="wrap_content"
68+
android:entries="@array/chip_select_menu"
69+
android:inputType="text"
70+
android:spinnerMode="dropdown"
71+
android:textSize="16sp"
72+
android:layout_below="@id/titleUserConsentNeeded" />
73+
74+
<TextView
75+
android:id="@+id/titleRWAttribute"
76+
android:layout_width="wrap_content"
77+
android:layout_height="wrap_content"
78+
android:text="@string/ota_provider_read_write_attribute_text"
79+
android:textSize="16sp"
80+
android:layout_below="@id/titleUserConsentNeededSp" />
81+
82+
<TextView
83+
android:id="@+id/writeAclBtn"
84+
android:layout_width="wrap_content"
85+
android:layout_height="wrap_content"
86+
android:layout_below="@id/titleUserConsentNeededSp"
87+
android:layout_marginStart="5dp"
88+
android:layout_marginTop="5dp"
89+
android:layout_marginEnd="5dp"
90+
android:layout_marginBottom="5dp"
91+
android:layout_toStartOf="@id/readAttributeBtn"
92+
android:background="@android:color/darker_gray"
93+
android:padding="5dp"
94+
android:text="@string/ota_provider_write_acl_btn_text"
95+
android:textSize="16sp" />
96+
97+
<TextView
98+
android:id="@+id/readAttributeBtn"
99+
android:layout_width="wrap_content"
100+
android:layout_height="wrap_content"
101+
android:text="@string/ota_provider_read_attribute_btn_text"
102+
android:padding="5dp"
103+
android:layout_margin="5dp"
104+
android:background="@android:color/darker_gray"
105+
android:textSize="16sp"
106+
android:layout_toStartOf="@id/writeAttributeBtn"
107+
android:layout_below="@id/titleUserConsentNeededSp" />
108+
109+
<TextView
110+
android:id="@+id/writeAttributeBtn"
111+
android:layout_width="wrap_content"
112+
android:layout_height="wrap_content"
113+
android:text="@string/ota_provider_write_attribute_btn_text"
114+
android:padding="5dp"
115+
android:layout_margin="5dp"
116+
android:background="@android:color/darker_gray"
117+
android:textSize="16sp"
118+
android:layout_alignParentEnd="true"
119+
android:layout_below="@id/titleUserConsentNeededSp" />
120+
121+
<Spinner
122+
android:id="@+id/attributeSp"
123+
android:layout_width="wrap_content"
124+
android:layout_height="wrap_content"
125+
android:inputType="text"
126+
android:spinnerMode="dropdown"
127+
android:textSize="16sp"
128+
android:layout_below="@id/titleRWAttribute" />
129+
130+
<EditText
131+
android:id="@+id/vendorIdTv"
132+
android:layout_width="wrap_content"
133+
android:layout_height="wrap_content"
134+
android:layout_below="@id/attributeSp"
135+
android:layout_alignParentStart="true"
136+
android:layout_marginStart="8dp"
137+
android:layout_marginEnd="8dp"
138+
android:enabled="false"
139+
android:padding="8dp"
140+
android:text="@string/ota_provider_vendorId_text"
141+
android:textSize="16sp" />
142+
143+
<EditText
144+
android:id="@+id/vendorIdEd"
145+
android:layout_width="match_parent"
146+
android:layout_height="wrap_content"
147+
android:layout_below="@id/attributeSp"
148+
android:layout_marginStart="8dp"
149+
android:layout_marginEnd="8dp"
150+
android:layout_toEndOf="@id/vendorIdTv"
151+
android:autofillHints="@string/ota_provider_vendorId_text"
152+
android:inputType="numberDecimal"
153+
android:padding="8dp"
154+
android:textSize="16sp" />
155+
38156
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
39157
android:orientation="vertical"
40158
android:layout_width="match_parent"
@@ -45,17 +163,26 @@
45163
android:id="@+id/selectFirmwareFileBtn"
46164
android:layout_width="wrap_content"
47165
android:layout_height="wrap_content"
48-
android:padding="16dp"
166+
android:padding="8dp"
49167
android:layout_margin="8dp"
50168
android:layout_columnWeight="1"
51169
android:background="@android:color/darker_gray"
52170
android:text="@string/ota_provider_select_firmware_file_text"
53171
android:textSize="16sp"/>
172+
<TextView
173+
android:id="@+id/updateOTAStatusBtn"
174+
android:layout_width="wrap_content"
175+
android:layout_height="wrap_content"
176+
android:padding="8dp"
177+
android:layout_margin="8dp"
178+
android:background="@android:color/darker_gray"
179+
android:text="@string/ota_provider_update_ota_status_text"
180+
android:textSize="16sp"/>
54181
<TextView
55182
android:id="@+id/announceOTAProviderBtn"
56183
android:layout_width="wrap_content"
57184
android:layout_height="wrap_content"
58-
android:padding="16dp"
185+
android:padding="8dp"
59186
android:layout_margin="8dp"
60187
android:background="@android:color/darker_gray"
61188
android:text="@string/ota_provider_start_firmware_update_text"
@@ -65,12 +192,13 @@
65192
android:id="@+id/firmwareFileTv"
66193
android:layout_width="match_parent"
67194
android:layout_height="wrap_content"
195+
android:layout_columnWeight="1"
68196
android:layout_below="@id/buttonLayout"
69-
android:padding="16dp"
70-
android:layout_margin="8dp"
71197
android:layout_gravity="center"
72-
android:layout_columnWeight="4"
73-
android:textSize="16sp"/>
198+
android:layout_marginStart="8dp"
199+
android:layout_marginEnd="8dp"
200+
android:textSize="12sp" />
201+
74202
<TextView
75203
android:id="@+id/commandStatusTv"
76204
android:layout_width="match_parent"
@@ -79,5 +207,5 @@
79207
android:padding="16dp"
80208
android:minLines="4"
81209
android:singleLine="false"
82-
android:textSize="20sp" />
210+
android:textSize="16sp" />
83211
</RelativeLayout>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
3+
xmlns:app="http://schemas.android.com/apk/res-auto"
4+
xmlns:tools="http://schemas.android.com/tools"
5+
android:layout_width="wrap_content"
6+
android:layout_height="wrap_content"
7+
android:padding="16dp">
8+
<TextView
9+
android:id="@+id/titleText"
10+
android:layout_width="wrap_content"
11+
android:layout_height="wrap_content"
12+
android:text="@string/ota_provider_write_default_ota_providers_text"
13+
android:textSize="22sp"
14+
app:layout_constraintStart_toStartOf="parent"
15+
app:layout_constraintTop_toTopOf="parent" />
16+
17+
<EditText
18+
android:id="@+id/fabricIndexEd"
19+
android:layout_width="wrap_content"
20+
android:layout_height="wrap_content"
21+
android:hint="@string/ota_provider_fabric_index_text"
22+
android:inputType="number"
23+
android:textSize="16sp"
24+
android:layout_marginBottom="8dp"
25+
app:layout_constraintStart_toStartOf="parent"
26+
app:layout_constraintTop_toBottomOf="@id/titleText"
27+
app:layout_constraintBottom_toTopOf="@id/providerNodeIdEd"/>
28+
29+
<EditText
30+
android:id="@+id/providerNodeIdEd"
31+
android:layout_width="wrap_content"
32+
android:layout_height="wrap_content"
33+
android:hint="@string/ota_provider_provider_node_id_text"
34+
android:inputType="number"
35+
android:textSize="16sp"
36+
android:layout_marginBottom="8dp"
37+
app:layout_constraintStart_toStartOf="parent"
38+
app:layout_constraintTop_toBottomOf="@id/fabricIndexEd"
39+
app:layout_constraintBottom_toTopOf="@id/endpointIdEd"/>
40+
41+
<EditText
42+
android:id="@+id/endpointIdEd"
43+
android:layout_width="wrap_content"
44+
android:layout_height="wrap_content"
45+
android:hint="@string/ota_provider_endpoint_id_text"
46+
android:inputType="number"
47+
android:textSize="16sp"
48+
android:layout_marginBottom="8dp"
49+
app:layout_constraintStart_toStartOf="parent"
50+
app:layout_constraintTop_toBottomOf="@id/providerNodeIdEd"
51+
app:layout_constraintBottom_toTopOf="@id/writeDefaultOtaProvidersBtn"/>
52+
53+
<Button
54+
android:id="@+id/writeDefaultOtaProvidersBtn"
55+
android:layout_width="wrap_content"
56+
android:layout_height="wrap_content"
57+
android:text="@string/group_setting_write_btn_text"
58+
app:layout_constraintBottom_toBottomOf="parent"
59+
app:layout_constraintEnd_toEndOf="parent" />
60+
</androidx.constraintlayout.widget.ConstraintLayout>

examples/android/CHIPTool/app/src/main/res/values/strings.xml

+15
Original file line numberDiff line numberDiff line change
@@ -256,7 +256,22 @@
256256
<string name="group_setting_write_btn_text">Write</string>
257257

258258
<string name="ota_provider_btn_text">OTA Provider</string>
259+
<string name="ota_provider_query_image_response_status_text">Query Image Response Status</string>
260+
<string name="ota_provider_delayed_action_time_text">DelayTime</string>
261+
<string name="ota_provider_user_consent_needed_text">User Consent Needed (bool)</string>
262+
<string name="ota_provider_read_write_attribute_text">R/W Attribute</string>
263+
<string name="ota_provider_write_acl_btn_text">Write Acl</string>
264+
<string name="ota_provider_read_attribute_btn_text">Read</string>
265+
<string name="ota_provider_write_attribute_btn_text">Write</string>
259266
<string name="ota_provider_vendorId_text">Vendor ID</string>
260267
<string name="ota_provider_select_firmware_file_text">Select Firmware</string>
268+
<string name="ota_provider_update_ota_status_text">Update OTA Status</string>
261269
<string name="ota_provider_start_firmware_update_text">Start Firmware Update</string>
270+
<string name="ota_provider_invalid_attribute">Invalid Attribute</string>
271+
<string name="ota_provider_write_default_ota_providers_text">Write Default OTA Providers</string>
272+
<string name="ota_provider_fabric_index_text">Fabric Index</string>
273+
<string name="ota_provider_provider_node_id_text">Provider Node ID</string>
274+
<string name="ota_provider_endpoint_id_text">Endpoint ID</string>
275+
<string name="ota_provider_write_text">Write</string>
276+
<string name="ota_provider_node_id_text">Node ID</string>
262277
</resources>

kotlin-detect-config.yaml

+1
Original file line numberDiff line numberDiff line change
@@ -280,6 +280,7 @@ complexity:
280280
- "**/examples/android/CHIPTool/app/src/main/java/com/google/chip/chiptool/clusterclient/clusterinteraction/ClusterDetailFragment.kt"
281281
- "**/examples/android/CHIPTool/app/src/main/java/com/google/chip/chiptool/clusterclient/GroupSettingFragment.kt"
282282
- "**/examples/android/CHIPTool/app/src/main/java/com/google/chip/chiptool/clusterclient/OnOffClientFragment.kt"
283+
- "**/examples/android/CHIPTool/app/src/main/java/com/google/chip/chiptool/clusterclient/OtaProviderClientFragment.kt"
283284
- "**/examples/android/CHIPTool/app/src/main/java/com/google/chip/chiptool/clusterclient/SensorClientFragment.kt"
284285
- "**/examples/android/CHIPTool/app/src/main/java/com/google/chip/chiptool/clusterclient/WildcardFragment.kt"
285286
- "**/examples/android/CHIPTool/app/src/main/java/com/google/chip/chiptool/GenericChipDeviceListener.kt"

0 commit comments

Comments
 (0)