From a52731f45b13c79001a2b68ef0d0782b057c3e16 Mon Sep 17 00:00:00 2001 From: Austin Hsieh <77706079+austinh0@users.noreply.github.com> Date: Fri, 17 Sep 2021 07:44:08 -0700 Subject: [PATCH] Stop using destroyed fragment in pairing complete callback (#9729) --- .../chiptool/provisioning/DeviceProvisioningFragment.kt | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/android/CHIPTool/app/src/main/java/com/google/chip/chiptool/provisioning/DeviceProvisioningFragment.kt b/src/android/CHIPTool/app/src/main/java/com/google/chip/chiptool/provisioning/DeviceProvisioningFragment.kt index 4867cbb88dd6f6..fd33ca940c8a37 100644 --- a/src/android/CHIPTool/app/src/main/java/com/google/chip/chiptool/provisioning/DeviceProvisioningFragment.kt +++ b/src/android/CHIPTool/app/src/main/java/com/google/chip/chiptool/provisioning/DeviceProvisioningFragment.kt @@ -158,6 +158,13 @@ class DeviceProvisioningFragment : Fragment() { override fun onPairingComplete(code: Int) { Log.d(TAG, "onPairingComplete: $code") + // In IP commissioning, commissioning complete will already be called at this point, and the + // next fragment will be shown. As a result, this fragment will be in a destroyed state and + // should not be operated on. + if (deviceInfo.ipAddress != null) { + return + } + if (code == STATUS_PAIRING_SUCCESS) { childFragmentManager.beginTransaction() .add(R.id.fragment_container, EnterNetworkFragment.newInstance(networkType))