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

Commit 566b66e2 authored by Salvador Martinez's avatar Salvador Martinez
Browse files

Added guard to logging in AsyncTask

An async task was trying to get the context
in an InstrumentedFragment. This could return
null if the context disappears before the new
thread gets to that line. Logging will now
be aborted if context is null to avoid this.

Bug: 31058928
Change-Id: Iae97d389e58a76b0f213a2749415501894ebf649
parent 141c20c5
Loading
Loading
Loading
Loading
+4 −3
Original line number Diff line number Diff line
@@ -235,17 +235,18 @@ public class DashboardSummary extends InstrumentedFragment

        @Override
        protected List<Tile> doInBackground(Void... params) {
            final Context context = getContext();
            List<Tile> suggestions = mSuggestionParser.getSuggestions();
            for (int i = 0; i < suggestions.size(); i++) {
                Tile suggestion = suggestions.get(i);
                if (mSuggestionsChecks.isSuggestionComplete(suggestion)) {
                    mAdapter.disableSuggestion(suggestion);
                    suggestions.remove(i--);
                } else {
                    String id = DashboardAdapter.getSuggestionIdentifier(getContext(), suggestion);
                } else if (context != null) {
                    String id = DashboardAdapter.getSuggestionIdentifier(context, suggestion);
                    if (!mSuggestionsShownLogged.contains(id)) {
                        mSuggestionsShownLogged.add(id);
                        MetricsLogger.action(getContext(),
                        MetricsLogger.action(context,
                                MetricsEvent.ACTION_SHOW_SETTINGS_SUGGESTION, id);
                    }
                }