Moves lock screen shortcuts summary loading to the background.

To load the summary for the Settings > Display > Lock screen >
Shortcuts, we need to issue a binder/IPC call to query the content
provider that resides in the System UI process.

Previously, this was being done on the main thread. The thinking was
that it's critical to load this as soon as the Settings page is shown.
This results in ANRs, as per the attached bug.

The fix is to move the loading off the main thread and onto a background
thread.

Fix: 274788437
Test: unit tests updated
Test: manually verified that the summary is correct and that it updates
correctly after clicking on it, changing the lock screen shortcuts, and
going back

Change-Id: I41a5e883236de4f16c105f3930b8849538807f00
This commit is contained in:
Alejandro Nijamkin
2023-03-24 15:38:30 -07:00
parent e0c151f401
commit d2fb185677
2 changed files with 24 additions and 11 deletions

View File

@@ -26,6 +26,7 @@ import androidx.preference.PreferenceScreen;
import com.android.settings.R;
import com.android.settings.core.BasePreferenceController;
import com.android.settings.core.PreferenceControllerMixin;
import com.android.settingslib.utils.ThreadUtils;
/**
* Preference for accessing an experience to customize lock screen quick affordances.
@@ -65,7 +66,11 @@ public class CustomizableLockScreenQuickAffordancesPreferenceController extends
}
@Override
public CharSequence getSummary() {
return CustomizableLockScreenUtils.getQuickAffordanceSummary(mContext);
protected void refreshSummary(Preference preference) {
ThreadUtils.postOnBackgroundThread(() -> {
final CharSequence summary =
CustomizableLockScreenUtils.getQuickAffordanceSummary(mContext);
ThreadUtils.postOnMainThread(() -> preference.setSummary(summary));
});
}
}