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

Commit ec2665d9 authored by Angela Wang's avatar Angela Wang
Browse files

Fix crash when calling sendActivityIfAvailable()

Move the call from onAttach() to onResume() to prevent encountering
BackgroundServiceStartNotAllowedException sometimes.

Flag: EXEMPT bugfix
Test: manually test
Bug: 417247626
Change-Id: Iec1c825917ac0e3a01fdacadf3c6f5da6bdaec4a
parent 271c3ca8
Loading
Loading
Loading
Loading
+9 −5
Original line number Diff line number Diff line
@@ -35,7 +35,6 @@ import com.android.settings.search.BaseSearchIndexProvider;
import com.android.settings.slices.SlicePreferenceController;
import com.android.settingslib.bluetooth.BluetoothUtils;
import com.android.settingslib.bluetooth.HearingAidStatsLogUtils;

import com.android.settingslib.core.instrumentation.MetricsFeatureProvider;
import com.android.settingslib.search.SearchIndexable;

@@ -100,17 +99,22 @@ public class ConnectedDeviceDashboardFragment extends DashboardFragment {
        use(DiscoverableFooterPreferenceController.class)
                .setAlwaysDiscoverable(isAlwaysDiscoverable(callingAppPackageName, action));

        logPageEntrypoint(context, callingAppPackageName, intent);
    }

    @Override
    public void onResume() {
        super.onResume();

        // Show hearing devices survey if user is categorized as one of interested category
        final String category = HearingAidStatsLogUtils.getUserCategory(context);
        final String category = HearingAidStatsLogUtils.getUserCategory(getContext());
        if (category != null && !category.isEmpty()) {
            SurveyFeatureProvider provider =
                    FeatureFactory.getFeatureFactory().getSurveyFeatureProvider(context);
                    FeatureFactory.getFeatureFactory().getSurveyFeatureProvider(getContext());
            if (provider != null) {
                provider.sendActivityIfAvailable(category);
            }
        }

        logPageEntrypoint(context, callingAppPackageName, intent);
    }

    @VisibleForTesting