Pass null looper if the looper is not prepared in the calling thread
**Root cause** The PreferenceController can be constructed by the SettingsSearchIndexablesProvider where the looper of the thread is not prepared. This result in not able to construct the PreferenceController that will be used as part of the SettingsSearch. Currently, if the SettingsSearchIndexablesProvider is not able to construct the PreferenceController defined in xml, it would just silently failed. Test: atest SettingsUnitTests Test: atest SettingsRoboTests Flag: EXEMPT low risk bugfix Bug: 352622249 Change-Id: I72a4ce24ec6842b9efe067e3cb7d1c73cd98a566
This commit is contained in:
@@ -23,6 +23,7 @@ import android.content.Context;
|
||||
import android.database.ContentObserver;
|
||||
import android.net.Uri;
|
||||
import android.os.Handler;
|
||||
import android.os.Looper;
|
||||
import android.os.VibrationAttributes;
|
||||
import android.os.Vibrator;
|
||||
import android.provider.Settings;
|
||||
@@ -49,7 +50,8 @@ public class VibrationMainSwitchPreferenceController extends SettingsMainSwitchP
|
||||
public VibrationMainSwitchPreferenceController(Context context, String preferenceKey) {
|
||||
super(context, preferenceKey);
|
||||
mVibrator = context.getSystemService(Vibrator.class);
|
||||
mSettingObserver = new ContentObserver(new Handler(/* async= */ true)) {
|
||||
Handler handler = Looper.myLooper() != null ? new Handler(/* async= */ true) : null;
|
||||
mSettingObserver = new ContentObserver(handler) {
|
||||
@Override
|
||||
public void onChange(boolean selfChange, Uri uri) {
|
||||
updateState(mSwitchPreference);
|
||||
|
Reference in New Issue
Block a user