Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Android] Remove updateDevice API #22093

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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