From b35ba2365034a80f8a7096d5d0c17602ec1cfda4 Mon Sep 17 00:00:00 2001 From: Justin Wood Date: Tue, 2 Nov 2021 10:11:10 -0700 Subject: [PATCH] Revert "Android add discover (#10682)" This reverts commit 8ae5b652f5aeb076ff035d37f9758b0e9982efb8. --- .../com/tcl/chip/chiptest/MainActivity.kt | 2 +- .../com/google/chip/chiptool/ChipClient.kt | 2 +- .../AddressCommissioningFragment.kt | 46 ----- .../layout/address_commissioning_fragment.xml | 23 --- .../app/src/main/res/values/strings.xml | 1 - src/controller/java/BUILD.gn | 1 - .../java/CHIPDeviceController-JNI.cpp | 49 ----- .../ChipDeviceController.java | 16 -- .../devicecontroller/DiscoveredDevice.java | 23 --- .../android/AndroidChipPlatform-JNI.cpp | 19 +- src/platform/android/BUILD.gn | 2 - src/platform/android/DnssdImpl.cpp | 175 +----------------- src/platform/android/DnssdImpl.h | 9 +- .../chip/platform/AndroidChipPlatform.java | 37 +--- .../java/chip/platform/ChipMdnsCallback.java | 7 - .../chip/platform/ChipMdnsCallbackImpl.java | 15 -- .../platform/NsdManagerServiceBrowser.java | 154 --------------- .../platform/NsdManagerServiceResolver.java | 11 +- .../java/chip/platform/ServiceBrowser.java | 27 --- 19 files changed, 30 insertions(+), 589 deletions(-) delete mode 100644 src/controller/java/src/chip/devicecontroller/DiscoveredDevice.java delete mode 100644 src/platform/android/java/chip/platform/NsdManagerServiceBrowser.java delete mode 100644 src/platform/android/java/chip/platform/ServiceBrowser.java diff --git a/src/android/CHIPTest/app/src/main/java/com/tcl/chip/chiptest/MainActivity.kt b/src/android/CHIPTest/app/src/main/java/com/tcl/chip/chiptest/MainActivity.kt index 67e78748dc1cfd..d1f4fa14ec8ff7 100644 --- a/src/android/CHIPTest/app/src/main/java/com/tcl/chip/chiptest/MainActivity.kt +++ b/src/android/CHIPTest/app/src/main/java/com/tcl/chip/chiptest/MainActivity.kt @@ -53,6 +53,6 @@ class MainActivity : AppCompatActivity() { }.start() } - AndroidChipPlatform.defaultInstance(this) + AndroidChipPlatform(AndroidBleManager(), PreferencesKeyValueStoreManager(this), PreferencesConfigurationManager(this), NsdManagerServiceResolver(this), ChipMdnsCallbackImpl()) } } diff --git a/src/android/CHIPTool/app/src/main/java/com/google/chip/chiptool/ChipClient.kt b/src/android/CHIPTool/app/src/main/java/com/google/chip/chiptool/ChipClient.kt index 322495a3b29041..7fcdfeb46f706f 100644 --- a/src/android/CHIPTool/app/src/main/java/com/google/chip/chiptool/ChipClient.kt +++ b/src/android/CHIPTool/app/src/main/java/com/google/chip/chiptool/ChipClient.kt @@ -50,7 +50,7 @@ object ChipClient { if (!this::androidPlatform.isInitialized && context != null) { //force ChipDeviceController load jni ChipDeviceController.loadJni() - androidPlatform = AndroidChipPlatform.defaultInstance(context) + androidPlatform = AndroidChipPlatform(AndroidBleManager(), PreferencesKeyValueStoreManager(context), PreferencesConfigurationManager(context), NsdManagerServiceResolver(context), ChipMdnsCallbackImpl()) } return androidPlatform } diff --git a/src/android/CHIPTool/app/src/main/java/com/google/chip/chiptool/provisioning/AddressCommissioningFragment.kt b/src/android/CHIPTool/app/src/main/java/com/google/chip/chiptool/provisioning/AddressCommissioningFragment.kt index 27aa3be27a912c..dd7015fac13dd6 100644 --- a/src/android/CHIPTool/app/src/main/java/com/google/chip/chiptool/provisioning/AddressCommissioningFragment.kt +++ b/src/android/CHIPTool/app/src/main/java/com/google/chip/chiptool/provisioning/AddressCommissioningFragment.kt @@ -5,8 +5,6 @@ import android.util.Log import android.view.LayoutInflater import android.view.View import android.view.ViewGroup -import android.widget.AdapterView -import android.widget.ArrayAdapter import androidx.fragment.app.Fragment import com.google.chip.chiptool.ChipClient import com.google.chip.chiptool.R @@ -15,21 +13,10 @@ import com.google.chip.chiptool.setuppayloadscanner.CHIPDeviceInfo import com.google.chip.chiptool.util.FragmentUtil import kotlinx.android.synthetic.main.address_commissioning_fragment.addressEditText import kotlinx.android.synthetic.main.address_commissioning_fragment.commissionBtn -import kotlinx.android.synthetic.main.address_commissioning_fragment.discoverBtn -import kotlinx.android.synthetic.main.address_commissioning_fragment.discoverListSpinner import kotlinx.android.synthetic.main.address_commissioning_fragment.discriminatorEditText import kotlinx.android.synthetic.main.address_commissioning_fragment.pincodeEditText -import kotlinx.coroutines.CoroutineScope -import kotlinx.coroutines.Dispatchers -import kotlinx.coroutines.Job -import kotlinx.coroutines.delay -import kotlinx.coroutines.launch - class AddressCommissioningFragment : Fragment() { - private val ipAddressList = ArrayList() - private val scope = CoroutineScope(Dispatchers.Main + Job()) - override fun onCreateView( inflater: LayoutInflater, container: ViewGroup?, @@ -59,39 +46,6 @@ class AddressCommissioningFragment : Fragment() { ) ) } - - discoverBtn.setOnClickListener { _ -> - discoverBtn.isEnabled = false - val deviceController = ChipClient.getDeviceController(requireContext()) - deviceController.discoverCommissionableNodes() - scope.launch { - delay(7000) - updateSpinner() - discoverBtn.isEnabled = true - } - } - } - - private fun updateSpinner() { - val deviceController = ChipClient.getDeviceController(requireContext()) - for(i in 0..10) { - val device = deviceController.getDiscoveredDevice(i) ?: break - ipAddressList.add("${device.ipAddress}, ${device.discriminator}") - } - requireActivity().runOnUiThread { - discoverListSpinner.adapter = - ArrayAdapter(requireContext(), android.R.layout.simple_spinner_dropdown_item, ipAddressList) - discoverListSpinner.onItemSelectedListener = object : AdapterView.OnItemSelectedListener { - override fun onItemSelected(parent: AdapterView<*>, view: View, position: Int, id: Long) { - val address = ipAddressList[position].split(",")[0].trim() - val discriminator = ipAddressList[position].split(",")[1].trim() - addressEditText.setText(address) - discriminatorEditText.setText(discriminator) - } - - override fun onNothingSelected(parent: AdapterView<*>) {} - } - } } companion object { diff --git a/src/android/CHIPTool/app/src/main/res/layout/address_commissioning_fragment.xml b/src/android/CHIPTool/app/src/main/res/layout/address_commissioning_fragment.xml index 4ff57d1767d7ed..21fafbd3ff9edf 100644 --- a/src/android/CHIPTool/app/src/main/res/layout/address_commissioning_fragment.xml +++ b/src/android/CHIPTool/app/src/main/res/layout/address_commissioning_fragment.xml @@ -16,7 +16,6 @@ app:layout_constraintTop_toTopOf="parent" /> - - -