Handle Looper in PreferenceController
When indexing content in search, the preference controllers are init'd on the background thread, thus you can't create a handler without calling Looper.prepare(). We have PreferenceConttrollerContractTest to catch these errors, but it was not running in presubmit. Bug tracking: b/73242024 This caused the indexing thread to crash, thus not adding any non-indexable keys for settings results. Test: atest PreferenceControllerContractTest Fixes: 73168342 Change-Id: I89fe596435d317bb3e3baebdaace97a67700d77e
This commit is contained in:
@@ -20,6 +20,7 @@ import android.content.Context;
|
|||||||
import android.database.ContentObserver;
|
import android.database.ContentObserver;
|
||||||
import android.net.Uri;
|
import android.net.Uri;
|
||||||
import android.os.Handler;
|
import android.os.Handler;
|
||||||
|
import android.os.Looper;
|
||||||
import android.provider.Settings;
|
import android.provider.Settings;
|
||||||
import android.support.annotation.VisibleForTesting;
|
import android.support.annotation.VisibleForTesting;
|
||||||
import android.support.v7.preference.Preference;
|
import android.support.v7.preference.Preference;
|
||||||
@@ -46,7 +47,7 @@ public class AutoBatterySeekBarPreferenceController extends BasePreferenceContro
|
|||||||
|
|
||||||
public AutoBatterySeekBarPreferenceController(Context context, Lifecycle lifecycle) {
|
public AutoBatterySeekBarPreferenceController(Context context, Lifecycle lifecycle) {
|
||||||
super(context, KEY_AUTO_BATTERY_SEEK_BAR);
|
super(context, KEY_AUTO_BATTERY_SEEK_BAR);
|
||||||
mContentObserver = new AutoBatterySaverSettingObserver(new Handler());
|
mContentObserver = new AutoBatterySaverSettingObserver(new Handler(Looper.getMainLooper()));
|
||||||
if (lifecycle != null) {
|
if (lifecycle != null) {
|
||||||
lifecycle.addObserver(this);
|
lifecycle.addObserver(this);
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user