Merge "Pass null looper if the looper is not prepared in the calling thread" into main
This commit is contained in:
@@ -27,6 +27,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;
|
||||
@@ -69,7 +70,8 @@ public class KeyboardVibrationTogglePreferenceController extends TogglePreferenc
|
||||
public KeyboardVibrationTogglePreferenceController(Context context, String preferenceKey) {
|
||||
super(context, preferenceKey);
|
||||
mVibrator = context.getSystemService(Vibrator.class);
|
||||
mContentObserver = new ContentObserver(new Handler(/* async= */ true)) {
|
||||
Handler handler = Looper.myLooper() != null ? new Handler(/* async= */ true) : null;
|
||||
mContentObserver = new ContentObserver(handler) {
|
||||
@Override
|
||||
public void onChange(boolean selfChange, Uri uri) {
|
||||
if (uri.equals(MAIN_VIBRATION_SWITCH_URI)) {
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -27,6 +27,7 @@ import android.database.ContentObserver;
|
||||
import android.media.AudioManager;
|
||||
import android.net.Uri;
|
||||
import android.os.Handler;
|
||||
import android.os.Looper;
|
||||
import android.os.VibrationAttributes;
|
||||
import android.os.VibrationEffect;
|
||||
import android.os.Vibrator;
|
||||
@@ -165,7 +166,7 @@ public abstract class VibrationPreferenceConfig {
|
||||
|
||||
/** Creates observer for given preference. */
|
||||
public SettingObserver(VibrationPreferenceConfig preferenceConfig) {
|
||||
super(new Handler(/* async= */ true));
|
||||
super(Looper.myLooper() != null ? new Handler(/* async= */ true) : null);
|
||||
mUri = Settings.System.getUriFor(preferenceConfig.getSettingKey());
|
||||
|
||||
if (preferenceConfig.isRestrictedByRingerModeSilent()) {
|
||||
|
||||
@@ -21,6 +21,7 @@ import android.database.ContentObserver;
|
||||
import android.media.AudioManager;
|
||||
import android.net.Uri;
|
||||
import android.os.Handler;
|
||||
import android.os.Looper;
|
||||
import android.os.Vibrator;
|
||||
import android.provider.DeviceConfig;
|
||||
import android.provider.Settings;
|
||||
@@ -74,7 +75,8 @@ public class VibrationRampingRingerTogglePreferenceController
|
||||
mRingVibrationPreferenceConfig = new RingVibrationPreferenceConfig(context);
|
||||
mRingSettingObserver = new VibrationPreferenceConfig.SettingObserver(
|
||||
mRingVibrationPreferenceConfig);
|
||||
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(mPreference);
|
||||
|
||||
Reference in New Issue
Block a user