Skip to content

Commit

Permalink
Remove Android updateDevice API (#22093)
Browse files Browse the repository at this point in the history
  • Loading branch information
joonhaengHeo authored and pull[bot] committed Sep 27, 2023
1 parent d6154e1 commit 1961076
Show file tree
Hide file tree
Showing 4 changed files with 1 addition and 49 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ import com.google.chip.chiptool.R
import com.google.chip.chiptool.util.DeviceIdUtil
import kotlinx.android.synthetic.main.address_update_fragment.deviceIdEd
import kotlinx.android.synthetic.main.address_update_fragment.fabricIdEd
import kotlinx.android.synthetic.main.address_update_fragment.view.updateAddressBtn

/** Fragment for updating the address of a device given its fabric and node ID. */
class AddressUpdateFragment: Fragment() {
Expand All @@ -28,9 +27,7 @@ class AddressUpdateFragment: Fragment() {
container: ViewGroup?,
savedInstanceState: Bundle?
): View {
return inflater.inflate(R.layout.address_update_fragment, container, false).apply {
updateAddressBtn.setOnClickListener { updateAddressClick() }
}
return inflater.inflate(R.layout.address_update_fragment, container, false).apply { }
}

override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
Expand All @@ -40,16 +37,4 @@ class AddressUpdateFragment: Fragment() {
fabricIdEd.setText(compressedFabricId.toULong().toString(16).padStart(16, '0'))
deviceIdEd.setText(DeviceIdUtil.getLastDeviceId(requireContext()).toString())
}

private fun updateAddressClick() {
try {
deviceController.updateDevice(
fabricIdEd.text.toString().toULong(16).toLong(),
deviceIdEd.text.toString().toULong().toLong()
)
Toast.makeText(requireContext(), "Address update started", Toast.LENGTH_SHORT).show()
} catch (ex: Exception) {
Toast.makeText(requireContext(), "Address update failed: $ex", Toast.LENGTH_SHORT).show()
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,6 @@ class SensorClientFragment : Fragment() {
ChipClient.getDeviceController(requireContext()).setCompletionListener(null)
deviceIdEd.setOnEditorActionListener { textView, actionId, _ ->
if (actionId == EditorInfo.IME_ACTION_DONE) {
updateAddress(textView.text.toString())
resetSensorGraph() // reset the graph on device change
}
actionId == EditorInfo.IME_ACTION_DONE
Expand Down Expand Up @@ -116,25 +115,13 @@ class SensorClientFragment : Fragment() {
override fun onStart() {
super.onStart()
deviceIdEd.setText(DeviceIdUtil.getLastDeviceId(requireContext()).toString())
updateAddress(deviceIdEd.text.toString())
}

override fun onStop() {
resetSensorGraph() // reset the graph on fragment exit
super.onStop()
}

private fun updateAddress(deviceId: String) {
try {
ChipClient.getDeviceController(requireContext()).updateDevice(
/* fabric ID */ 5544332211,
deviceId.toULong().toLong()
)
} catch (ex: Exception) {
showMessage(R.string.update_device_address_failure, ex.toString())
}
}

private fun resetSensorGraph() {
watchSensorBtn.isChecked = false
sensorGraph.visibility = View.INVISIBLE
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,18 +32,4 @@
android:layout_height="wrap_content"
app:barrierDirection="bottom"
app:constraint_referenced_ids="fabricIdEd,deviceIdEd" />

<Button
android:id="@+id/updateAddressBtn"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="16dp"
android:layout_below="@id/deviceIdEd"
android:padding="16dp"
android:text="@string/update_device_address_btn_text"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/barrier"
app:layout_constraintVertical_bias="0.0" />
</androidx.constraintlayout.widget.ConstraintLayout>
Original file line number Diff line number Diff line change
Expand Up @@ -397,10 +397,6 @@ public long getCompressedFabricId() {
*/
public native long generateCompressedFabricId(byte[] rcac, byte[] noc);

public void updateDevice(long fabricId, long deviceId) {
updateDevice(deviceControllerPtr, fabricId, deviceId);
}

/**
* Get commmissionible Node. Commmissionible Node results are able to get using {@link
* ChipDeviceController.getDiscoveredDevice}.
Expand Down Expand Up @@ -639,8 +635,6 @@ private native void getConnectedDevicePointer(

private native long getCompressedFabricId(long deviceControllerPtr);

private native void updateDevice(long deviceControllerPtr, long fabricId, long deviceId);

private native void discoverCommissionableNodes(long deviceControllerPtr);

private native DiscoveredDevice getDiscoveredDevice(long deviceControllerPtr, int idx);
Expand Down

0 comments on commit 1961076

Please sign in to comment.