Skip to content

Commit

Permalink
[Android] Implement OTA Provider exception case (project-chip#30777)
Browse files Browse the repository at this point in the history
* 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]>
  • Loading branch information
joonhaengHeo and restyled-commits authored Dec 5, 2023
1 parent d809f32 commit ec5ff8d
Show file tree
Hide file tree
Showing 8 changed files with 726 additions and 42 deletions.

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,19 @@
android:layout_marginBottom="8dp"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/titleText"
app:layout_constraintBottom_toTopOf="@+id/nodeIdEd"/>

<EditText
android:id="@+id/nodeIdEd"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:hint="@string/ota_provider_node_id_text"
android:inputType="number"
android:textSize="16sp"
android:layout_marginBottom="8dp"
android:visibility="gone"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/groupIdEd"
app:layout_constraintBottom_toTopOf="@+id/accessControlEntryTv"/>

<TextView
Expand All @@ -34,7 +47,7 @@
android:textSize="16sp"
android:layout_marginTop="8dp"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/groupIdEd"
app:layout_constraintTop_toBottomOf="@id/nodeIdEd"
app:layout_constraintBottom_toTopOf="@id/accessControlEntrySp"
/>

Expand All @@ -47,7 +60,7 @@
android:layout_marginBottom="8dp"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/accessControlEntryTv"
app:layout_constraintBottom_toTopOf="@+id/addGroupDialogBtn"/>
app:layout_constraintBottom_toTopOf="@+id/addAccessControlBtn"/>

<Button
android:id="@+id/addAccessControlBtn"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,30 +11,148 @@
android:layout_alignParentStart="true"
android:layout_alignParentTop="true" />

<TextView
android:id="@+id/titleStatus"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/ota_provider_query_image_response_status_text"
android:textSize="16sp"
android:layout_below="@id/addressUpdateFragment" />

<Spinner
android:id="@+id/titleStatusSp"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:hint="@string/subscribe_dialog_keep_subscriptions_hint"
android:inputType="text"
android:spinnerMode="dropdown"
android:textSize="16sp"
android:layout_below="@id/titleStatus" />

<EditText
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/vendorIdTv"
android:id="@+id/delayActionTimeTv"
android:textSize="16sp"
android:padding="16dp"
android:layout_margin="8dp"
android:layout_alignParentStart="true"
android:enabled="false"
android:text="@string/ota_provider_vendorId_text"
android:layout_below="@id/addressUpdateFragment" />
android:text="@string/ota_provider_delayed_action_time_text"
android:visibility="gone"
android:layout_below="@id/titleStatusSp" />

<EditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/vendorIdEd"
android:id="@+id/delayActionTimeEd"
android:textSize="16sp"
android:padding="16dp"
android:layout_margin="8dp"
android:visibility="gone"
android:layout_toEndOf="@id/vendorIdTv"
android:layout_below="@id/addressUpdateFragment"
android:autofillHints="@string/ota_provider_vendorId_text"
android:layout_below="@id/titleStatusSp"
android:autofillHints="@string/ota_provider_delayed_action_time_text"
android:inputType="numberDecimal" />

<TextView
android:id="@+id/titleUserConsentNeeded"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/ota_provider_user_consent_needed_text"
android:textSize="16sp"
android:layout_below="@id/delayActionTimeTv" />

<Spinner
android:id="@+id/titleUserConsentNeededSp"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:entries="@array/chip_select_menu"
android:inputType="text"
android:spinnerMode="dropdown"
android:textSize="16sp"
android:layout_below="@id/titleUserConsentNeeded" />

<TextView
android:id="@+id/titleRWAttribute"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/ota_provider_read_write_attribute_text"
android:textSize="16sp"
android:layout_below="@id/titleUserConsentNeededSp" />

<TextView
android:id="@+id/writeAclBtn"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@id/titleUserConsentNeededSp"
android:layout_marginStart="5dp"
android:layout_marginTop="5dp"
android:layout_marginEnd="5dp"
android:layout_marginBottom="5dp"
android:layout_toStartOf="@id/readAttributeBtn"
android:background="@android:color/darker_gray"
android:padding="5dp"
android:text="@string/ota_provider_write_acl_btn_text"
android:textSize="16sp" />

<TextView
android:id="@+id/readAttributeBtn"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/ota_provider_read_attribute_btn_text"
android:padding="5dp"
android:layout_margin="5dp"
android:background="@android:color/darker_gray"
android:textSize="16sp"
android:layout_toStartOf="@id/writeAttributeBtn"
android:layout_below="@id/titleUserConsentNeededSp" />

<TextView
android:id="@+id/writeAttributeBtn"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/ota_provider_write_attribute_btn_text"
android:padding="5dp"
android:layout_margin="5dp"
android:background="@android:color/darker_gray"
android:textSize="16sp"
android:layout_alignParentEnd="true"
android:layout_below="@id/titleUserConsentNeededSp" />

<Spinner
android:id="@+id/attributeSp"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:inputType="text"
android:spinnerMode="dropdown"
android:textSize="16sp"
android:layout_below="@id/titleRWAttribute" />

<EditText
android:id="@+id/vendorIdTv"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@id/attributeSp"
android:layout_alignParentStart="true"
android:layout_marginStart="8dp"
android:layout_marginEnd="8dp"
android:enabled="false"
android:padding="8dp"
android:text="@string/ota_provider_vendorId_text"
android:textSize="16sp" />

<EditText
android:id="@+id/vendorIdEd"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@id/attributeSp"
android:layout_marginStart="8dp"
android:layout_marginEnd="8dp"
android:layout_toEndOf="@id/vendorIdTv"
android:autofillHints="@string/ota_provider_vendorId_text"
android:inputType="numberDecimal"
android:padding="8dp"
android:textSize="16sp" />

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="match_parent"
Expand All @@ -45,17 +163,26 @@
android:id="@+id/selectFirmwareFileBtn"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:padding="16dp"
android:padding="8dp"
android:layout_margin="8dp"
android:layout_columnWeight="1"
android:background="@android:color/darker_gray"
android:text="@string/ota_provider_select_firmware_file_text"
android:textSize="16sp"/>
<TextView
android:id="@+id/updateOTAStatusBtn"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:padding="8dp"
android:layout_margin="8dp"
android:background="@android:color/darker_gray"
android:text="@string/ota_provider_update_ota_status_text"
android:textSize="16sp"/>
<TextView
android:id="@+id/announceOTAProviderBtn"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:padding="16dp"
android:padding="8dp"
android:layout_margin="8dp"
android:background="@android:color/darker_gray"
android:text="@string/ota_provider_start_firmware_update_text"
Expand All @@ -65,12 +192,13 @@
android:id="@+id/firmwareFileTv"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_columnWeight="1"
android:layout_below="@id/buttonLayout"
android:padding="16dp"
android:layout_margin="8dp"
android:layout_gravity="center"
android:layout_columnWeight="4"
android:textSize="16sp"/>
android:layout_marginStart="8dp"
android:layout_marginEnd="8dp"
android:textSize="12sp" />

<TextView
android:id="@+id/commandStatusTv"
android:layout_width="match_parent"
Expand All @@ -79,5 +207,5 @@
android:padding="16dp"
android:minLines="4"
android:singleLine="false"
android:textSize="20sp" />
android:textSize="16sp" />
</RelativeLayout>
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:padding="16dp">
<TextView
android:id="@+id/titleText"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/ota_provider_write_default_ota_providers_text"
android:textSize="22sp"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />

<EditText
android:id="@+id/fabricIndexEd"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:hint="@string/ota_provider_fabric_index_text"
android:inputType="number"
android:textSize="16sp"
android:layout_marginBottom="8dp"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/titleText"
app:layout_constraintBottom_toTopOf="@id/providerNodeIdEd"/>

<EditText
android:id="@+id/providerNodeIdEd"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:hint="@string/ota_provider_provider_node_id_text"
android:inputType="number"
android:textSize="16sp"
android:layout_marginBottom="8dp"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/fabricIndexEd"
app:layout_constraintBottom_toTopOf="@id/endpointIdEd"/>

<EditText
android:id="@+id/endpointIdEd"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:hint="@string/ota_provider_endpoint_id_text"
android:inputType="number"
android:textSize="16sp"
android:layout_marginBottom="8dp"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/providerNodeIdEd"
app:layout_constraintBottom_toTopOf="@id/writeDefaultOtaProvidersBtn"/>

<Button
android:id="@+id/writeDefaultOtaProvidersBtn"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/group_setting_write_btn_text"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent" />
</androidx.constraintlayout.widget.ConstraintLayout>
15 changes: 15 additions & 0 deletions examples/android/CHIPTool/app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -256,7 +256,22 @@
<string name="group_setting_write_btn_text">Write</string>

<string name="ota_provider_btn_text">OTA Provider</string>
<string name="ota_provider_query_image_response_status_text">Query Image Response Status</string>
<string name="ota_provider_delayed_action_time_text">DelayTime</string>
<string name="ota_provider_user_consent_needed_text">User Consent Needed (bool)</string>
<string name="ota_provider_read_write_attribute_text">R/W Attribute</string>
<string name="ota_provider_write_acl_btn_text">Write Acl</string>
<string name="ota_provider_read_attribute_btn_text">Read</string>
<string name="ota_provider_write_attribute_btn_text">Write</string>
<string name="ota_provider_vendorId_text">Vendor ID</string>
<string name="ota_provider_select_firmware_file_text">Select Firmware</string>
<string name="ota_provider_update_ota_status_text">Update OTA Status</string>
<string name="ota_provider_start_firmware_update_text">Start Firmware Update</string>
<string name="ota_provider_invalid_attribute">Invalid Attribute</string>
<string name="ota_provider_write_default_ota_providers_text">Write Default OTA Providers</string>
<string name="ota_provider_fabric_index_text">Fabric Index</string>
<string name="ota_provider_provider_node_id_text">Provider Node ID</string>
<string name="ota_provider_endpoint_id_text">Endpoint ID</string>
<string name="ota_provider_write_text">Write</string>
<string name="ota_provider_node_id_text">Node ID</string>
</resources>
1 change: 1 addition & 0 deletions kotlin-detect-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -280,6 +280,7 @@ complexity:
- "**/examples/android/CHIPTool/app/src/main/java/com/google/chip/chiptool/clusterclient/clusterinteraction/ClusterDetailFragment.kt"
- "**/examples/android/CHIPTool/app/src/main/java/com/google/chip/chiptool/clusterclient/GroupSettingFragment.kt"
- "**/examples/android/CHIPTool/app/src/main/java/com/google/chip/chiptool/clusterclient/OnOffClientFragment.kt"
- "**/examples/android/CHIPTool/app/src/main/java/com/google/chip/chiptool/clusterclient/OtaProviderClientFragment.kt"
- "**/examples/android/CHIPTool/app/src/main/java/com/google/chip/chiptool/clusterclient/SensorClientFragment.kt"
- "**/examples/android/CHIPTool/app/src/main/java/com/google/chip/chiptool/clusterclient/WildcardFragment.kt"
- "**/examples/android/CHIPTool/app/src/main/java/com/google/chip/chiptool/GenericChipDeviceListener.kt"
Expand Down
Loading

0 comments on commit ec5ff8d

Please sign in to comment.