Skip to content

Commit

Permalink
Revert "[Android] Generate cluster info mapping (#10629)" (#10886)
Browse files Browse the repository at this point in the history
This reverts commit b7109f5.
  • Loading branch information
woody-apple authored and pull[bot] committed Jan 18, 2022
1 parent cf980e7 commit 2b060cc
Show file tree
Hide file tree
Showing 12 changed files with 4 additions and 7,310 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,6 @@ import android.view.View
import android.view.ViewGroup
import android.widget.Toast
import androidx.fragment.app.Fragment
import chip.clusterinfo.ClusterCommandCallback
import chip.clusterinfo.ClusterInfo
import chip.clusterinfo.CommandInfo
import chip.devicecontroller.ChipDeviceController
import com.google.chip.chiptool.ChipClient
import com.google.chip.chiptool.GenericChipDeviceListener
Expand All @@ -18,18 +15,12 @@ import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.Job
import kotlinx.coroutines.cancel
import chip.devicecontroller.ClusterInfoMapping
import java.lang.Exception
import kotlinx.android.synthetic.main.cluster_interaction_fragment.view.getClusterMappingBtn
import kotlinx.coroutines.launch

class ClusterInteractionFragment : Fragment() {
private val deviceController: ChipDeviceController
get() = ChipClient.getDeviceController(requireContext())

private val scope = CoroutineScope(Dispatchers.Main + Job())
private lateinit var addressUpdateFragment: AddressUpdateFragment
private lateinit var clusterMap: Map<String, ClusterInfo>

override fun onCreateView(
inflater: LayoutInflater,
Expand All @@ -38,43 +29,9 @@ class ClusterInteractionFragment : Fragment() {
): View {
return inflater.inflate(R.layout.cluster_interaction_fragment, container, false).apply {
deviceController.setCompletionListener(ChipControllerCallback())
addressUpdateFragment =
childFragmentManager.findFragmentById(R.id.addressUpdateFragment) as AddressUpdateFragment
clusterMap = ClusterInfoMapping().clusterMap;
getClusterMappingBtn.setOnClickListener { scope.launch { getClusterMapping() } }
}
}

private suspend fun getClusterMapping() {
// In real code: "OnOff" would be selected by the user.
val methodSelected = "onOff"
showMessage(methodSelected + " is initialized")
val selectedClusterInfo = clusterMap[methodSelected]!!
val devicePtr =
ChipClient.getConnectedDevicePointer(requireContext(), addressUpdateFragment.deviceId)
val endpointId = 1
val selectedCluster = selectedClusterInfo.createClusterFunction.create(devicePtr, endpointId)
// Imagine user wants to execute the command "OffWithEffect", pass the string here
val selectedCommandInfo: CommandInfo = selectedClusterInfo.commands["on"]!!

var selectedCommandCallback = selectedCommandInfo.commandCallbackSupplier.get()
selectedCommandCallback?.setCallbackDelegate(object : ClusterCommandCallback {
override fun onSuccess(responseValues: List<Any>) {
showMessage("Command success")
// Populate UI based on response values. We know the types from CommandInfo.getCommandResponses().
responseValues.forEach { Log.d(TAG, it.toString()) }
}

override fun onFailure(exception: Exception) {
showMessage("Command failed")
Log.e(TAG, exception.toString())
}
})

var commandArguments: HashMap<String, Any> = HashMap<String, Any>()
selectedCommandInfo.getCommandFunction().invokeCommand(selectedCluster, selectedCommandCallback, commandArguments)
}

private fun showMessage(msg: String) {
requireActivity().runOnUiThread {
Toast.makeText(requireContext(), msg, Toast.LENGTH_SHORT).show()
Expand Down
Original file line number Diff line number Diff line change
@@ -1,34 +1,24 @@
<?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:id="@+id/clusterInteraction"
android:layout_width="match_parent"
android:layout_height="match_parent">

<Button
android:id="@+id/getClusterMappingBtn"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="132dp"
android:layout_marginStart="16dp"
android:text="Button"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<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_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
app:layout_constraintEnd_toEndOf="parent"/>

<androidx.recyclerview.widget.RecyclerView
android:id="@+id/endpointList"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginTop="180dp"
android:clipToPadding="false"
android:layout_marginTop="48dp"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/addressUpdateFragment" />

Expand Down
6 changes: 0 additions & 6 deletions src/controller/java/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -58,19 +58,13 @@ android_library("java") {
]

sources = [
"src/chip/clusterinfo/ClusterCommandCallback.java",
"src/chip/clusterinfo/ClusterInfo.java",
"src/chip/clusterinfo/CommandInfo.java",
"src/chip/clusterinfo/CommandParameterInfo.java",
"src/chip/clusterinfo/DelegatedClusterCallback.java",
"src/chip/devicecontroller/ChipClusterException.java",
"src/chip/devicecontroller/ChipCommandType.java",
"src/chip/devicecontroller/ChipDeviceController.java",
"src/chip/devicecontroller/ChipDeviceControllerException.java",
"src/chip/devicecontroller/GetConnectedDeviceCallbackJni.java",
"src/chip/devicecontroller/PaseVerifierParams.java",
"zap-generated/chip/devicecontroller/ChipClusters.java",
"zap-generated/chip/devicecontroller/ClusterInfoMapping.java",
]

javac_flags = [ "-Xlint:deprecation" ]
Expand Down

This file was deleted.

33 changes: 0 additions & 33 deletions src/controller/java/src/chip/clusterinfo/ClusterInfo.java

This file was deleted.

49 changes: 0 additions & 49 deletions src/controller/java/src/chip/clusterinfo/CommandInfo.java

This file was deleted.

14 changes: 0 additions & 14 deletions src/controller/java/src/chip/clusterinfo/CommandParameterInfo.java

This file was deleted.

This file was deleted.

Loading

0 comments on commit 2b060cc

Please sign in to comment.