Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit ad6fb766 authored by Haijie Hong's avatar Haijie Hong
Browse files

Call onAttach before finish

Test: local tested
Flag: EXEMPT minor fix
Bug: 417625626
Change-Id: Ib85826ab1c343696725e84ebe51fb204ba6ed1af
parent cce6ef49
Loading
Loading
Loading
Loading
+4 −0
Original line number Diff line number Diff line
@@ -117,6 +117,7 @@ abstract class BluetoothDetailsConfigurableFragment :
            arguments?.getString(KEY_DEVICE_ADDRESS)
                ?: run {
                    Log.w(TAG, "onAttach() address is null!")
                    super.onAttach(context)
                    finish()
                    return
                }
@@ -124,6 +125,7 @@ abstract class BluetoothDetailsConfigurableFragment :
            getCachedDevice(deviceAddress)
                ?: run {
                    Log.w(TAG, "onAttach() CachedDevice is null!")
                    super.onAttach(context)
                    finish()
                    return
                }
@@ -671,6 +673,8 @@ abstract class BluetoothDetailsConfigurableFragment :
        return localBluetoothManager.cachedDeviceManager.addDevice(remoteDevice)
    }

    protected fun isCachedDeviceInitialized() = ::cachedDevice.isInitialized

    private class SpotlightPreference(context: Context) : Preference(context) {
        init {
            layoutResource = R.layout.bluetooth_device_spotlight_preference
+1 −1
Original line number Diff line number Diff line
@@ -395,7 +395,7 @@ public class BluetoothDeviceDetailsFragment extends BluetoothDetailsConfigurable
    @Override
    protected List<AbstractPreferenceController> createPreferenceControllers(Context context) {
        ArrayList<AbstractPreferenceController> controllers = new ArrayList<>();
        if (cachedDevice != null) {
        if (isCachedDeviceInitialized()) {
            Lifecycle lifecycle = getSettingsLifecycle();
            controllers.add(
                    new BluetoothDetailsBannerController(
+20 −16
Original line number Diff line number Diff line
@@ -42,7 +42,8 @@ class DeviceDetailsMoreSettingsFragment : BluetoothDetailsConfigurableFragment()
    }

    override fun createPreferenceControllers(context: Context): List<AbstractPreferenceController> {
        return listOf(
        return if (isCachedDeviceInitialized()) {
            listOf(
                BluetoothDetailsProfilesController(
                    context,
                    this,
@@ -58,6 +59,9 @@ class DeviceDetailsMoreSettingsFragment : BluetoothDetailsConfigurableFragment()
                    settingsLifecycle,
                ),
            )
        } else {
            emptyList()
        }
    }

    override fun getLogTag(): String = TAG