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" /> - - -