-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[ICD][Android] Add ICD storage API, UI (#31193)
* Add ICD Client Storage * Add icd list command in java controller * Restyled by google-java-format * Restyled by clang-format * Modify kotlin codestyle * Restyled by google-java-format * Change from comments * Add symmetric Key parameter * Kotlin code style * Restyled by clang-format * Fix kotlin_controller build error * Restyle in kotlin * Update ICDRegistrationComplete callback * Restyled by google-java-format * Restyled by clang-format * Fix Darwin build error * Restyled by clang-format * Modify using GetLocalClassRef * Update error variable * Restyled by clang-format --------- Co-authored-by: Restyled.io <commits@restyled.io>
- Loading branch information
Showing
21 changed files
with
545 additions
and
31 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
61 changes: 61 additions & 0 deletions
61
.../android/CHIPTool/app/src/main/java/com/google/chip/chiptool/clusterclient/ICDFragment.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
package com.google.chip.chiptool.clusterclient | ||
|
||
import android.os.Bundle | ||
import android.view.LayoutInflater | ||
import android.view.View | ||
import android.view.ViewGroup | ||
import androidx.fragment.app.Fragment | ||
import androidx.lifecycle.lifecycleScope | ||
import chip.devicecontroller.ChipDeviceController | ||
import com.google.chip.chiptool.ChipClient | ||
import com.google.chip.chiptool.R | ||
import com.google.chip.chiptool.databinding.ICDFragmentBinding | ||
import kotlinx.coroutines.CoroutineScope | ||
|
||
class ICDFragment : Fragment() { | ||
private val deviceController: ChipDeviceController | ||
get() = ChipClient.getDeviceController(requireContext()) | ||
|
||
private lateinit var scope: CoroutineScope | ||
|
||
private lateinit var addressUpdateFragment: AddressUpdateFragment | ||
|
||
private var _binding: ICDFragmentBinding? = null | ||
private val binding | ||
get() = _binding!! | ||
|
||
override fun onCreateView( | ||
inflater: LayoutInflater, | ||
container: ViewGroup?, | ||
savedInstanceState: Bundle? | ||
): View { | ||
_binding = ICDFragmentBinding.inflate(inflater, container, false) | ||
scope = viewLifecycleOwner.lifecycleScope | ||
|
||
addressUpdateFragment = | ||
childFragmentManager.findFragmentById(R.id.addressUpdateFragment) as AddressUpdateFragment | ||
|
||
val clientInfo = deviceController.icdClientInfo | ||
var msg = "" | ||
|
||
for (info in clientInfo) { | ||
msg += "$info\n" | ||
} | ||
showMessage(msg) | ||
|
||
return binding.root | ||
} | ||
|
||
override fun onDestroyView() { | ||
super.onDestroyView() | ||
_binding = null | ||
} | ||
|
||
private fun showMessage(msg: String) { | ||
requireActivity().runOnUiThread { binding.icdTv.text = msg } | ||
} | ||
|
||
companion object { | ||
fun newInstance(): ICDFragment = ICDFragment() | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
29 changes: 29 additions & 0 deletions
29
examples/android/CHIPTool/app/src/main/res/layout/i_c_d_fragment.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<androidx.constraintlayout.widget.ConstraintLayout | ||
xmlns:android="http://schemas.android.com/apk/res/android" | ||
android:layout_width="match_parent" | ||
android:layout_height="match_parent" | ||
xmlns:app="http://schemas.android.com/apk/res-auto"> | ||
|
||
<androidx.fragment.app.FragmentContainerView | ||
android:id="@+id/addressUpdateFragment" | ||
android:name="com.google.chip.chiptool.clusterclient.AddressUpdateFragment" | ||
android:layout_width="match_parent" | ||
android:layout_height="wrap_content" | ||
app:layout_constraintTop_toTopOf="parent" | ||
app:layout_constraintStart_toStartOf="parent" | ||
app:layout_constraintEnd_toEndOf="parent"/> | ||
|
||
<TextView | ||
android:id="@+id/icdTv" | ||
android:layout_width="match_parent" | ||
android:layout_height="wrap_content" | ||
android:padding="16dp" | ||
app:layout_constraintTop_toBottomOf="@id/addressUpdateFragment" | ||
app:layout_constraintStart_toStartOf="parent" | ||
app:layout_constraintEnd_toEndOf="parent" | ||
android:singleLine="false" | ||
android:minLines="4" | ||
android:textSize="20sp"/> | ||
|
||
</androidx.constraintlayout.widget.ConstraintLayout> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
62 changes: 62 additions & 0 deletions
62
...ples/java-matter-controller/java/src/com/matter/controller/commands/icd/ICDListCommand.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
/* | ||
* Copyright (c) 2023 Project CHIP Authors | ||
* All rights reserved. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
* | ||
*/ | ||
package com.matter.controller.commands.icd | ||
|
||
import chip.devicecontroller.ChipDeviceController | ||
import com.matter.controller.commands.common.CredentialsIssuer | ||
import com.matter.controller.commands.common.MatterCommand | ||
|
||
class ICDListCommand(val controller: ChipDeviceController, credsIssuer: CredentialsIssuer?) : | ||
MatterCommand(controller, credsIssuer, "list") { | ||
|
||
override fun runCommand() { | ||
val info = controller.icdClientInfo | ||
println(" +-----------------------------------------------------------------------------+") | ||
System.out.format( | ||
" | %-52s %10s : %8d |\n", | ||
"Known ICDs", | ||
"FabricIndex", | ||
controller.fabricIndex | ||
) | ||
println(" +-----------------------------------------------------------------------------+") | ||
System.out.format( | ||
" | %20s | %15s | %15s | %16s |\n", | ||
"Node ID", | ||
"Start Counter", | ||
"Counter Offset", | ||
"MonitoredSubject" | ||
) | ||
|
||
for (i in info) { | ||
println(" +-----------------------------------------------------------------------------+") | ||
System.out.format( | ||
" | %20d | %15d | %15d | %16d |\n", | ||
i.peerNodeId, | ||
i.startCounter, | ||
i.offset, | ||
i.monitoredSubject | ||
) | ||
System.out.format(" | %-10s : %62s |\n", "aes key", i.icdAesKey.toHex()) | ||
System.out.format(" | %-10s : %62s |\n", "hamc key", i.icdHmacKey.toHex()) | ||
} | ||
println(" +-----------------------------------------------------------------------------+") | ||
} | ||
|
||
private fun ByteArray.toHex(): String = | ||
joinToString(separator = "") { eachByte -> "%02x".format(eachByte) } | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.