Disable suggestion on low memory devices

Change-Id: I9d22170845661fc8b48b116c9b09f758926c096f
Fix: 63157777
Test: make RunSettingsRoboTests
This commit is contained in:
Fan Zhang
2017-07-06 15:59:31 -07:00
parent 08da5d84c0
commit 1e0b51218b
4 changed files with 47 additions and 10 deletions

View File

@@ -94,9 +94,11 @@ public class DashboardSummary extends InstrumentedFragment
mConditionManager = ConditionManager.get(activity, false);
getLifecycle().addObserver(mConditionManager);
mSuggestionParser = new SuggestionParser(activity,
mSuggestionFeatureProvider.getSharedPrefs(activity), R.xml.suggestion_ordering);
mSuggestionsChecks = new SuggestionsChecks(getContext());
if (mSuggestionFeatureProvider.isSuggestionEnabled(activity)) {
mSuggestionParser = new SuggestionParser(activity,
mSuggestionFeatureProvider.getSharedPrefs(activity), R.xml.suggestion_ordering);
mSuggestionsChecks = new SuggestionsChecks(getContext());
}
if (DEBUG_TIMING) {
Log.d(TAG, "onCreate took " + (System.currentTimeMillis() - startTime)
+ " ms");
@@ -206,11 +208,16 @@ public class DashboardSummary extends InstrumentedFragment
@VisibleForTesting
void rebuildUI() {
new SuggestionLoader().execute();
// Set categories on their own if loading suggestions takes too long.
mHandler.postDelayed(() -> {
if (!mSuggestionFeatureProvider.isSuggestionEnabled(getContext())) {
Log.d(TAG, "Suggestion feature is disabled, skipping suggestion entirely");
updateCategoryAndSuggestion(null /* tiles */);
}, MAX_WAIT_MILLIS);
} else {
new SuggestionLoader().execute();
// Set categories on their own if loading suggestions takes too long.
mHandler.postDelayed(() -> {
updateCategoryAndSuggestion(null /* tiles */);
}, MAX_WAIT_MILLIS);
}
}
@Override