Skip to content

Commit c22ee66

Browse files
Jeff BrownAndroid (Google) Code Review
authored andcommitted
Merge "Fix lock ordering bug due to use of reentrant lock."
2 parents d1661dc + 8206525 commit c22ee66

File tree

1 file changed

+21
-27
lines changed

1 file changed

+21
-27
lines changed

services/java/com/android/server/VibratorService.java

Lines changed: 21 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -144,10 +144,10 @@ public void systemReady() {
144144
new ContentObserver(mH) {
145145
@Override
146146
public void onChange(boolean selfChange) {
147-
updateVibrateInputDevicesSetting();
147+
updateInputDeviceVibrators();
148148
}
149149
});
150-
updateVibrateInputDevicesSetting();
150+
updateInputDeviceVibrators();
151151
}
152152

153153
public boolean hasVibrator() {
@@ -334,36 +334,30 @@ private void unlinkVibration(Vibration vib) {
334334
}
335335
}
336336

337-
private void updateVibrateInputDevicesSetting() {
338-
synchronized (mInputDeviceVibrators) {
339-
mVibrateInputDevicesSetting = false;
340-
try {
341-
mVibrateInputDevicesSetting = Settings.System.getInt(mContext.getContentResolver(),
342-
Settings.System.VIBRATE_INPUT_DEVICES) > 0;
343-
} catch (SettingNotFoundException snfe) {
344-
}
345-
346-
if (mVibrateInputDevicesSetting) {
347-
if (!mInputDeviceListenerRegistered) {
348-
mInputDeviceListenerRegistered = true;
349-
mIm.registerInputDeviceListener(this, mH);
350-
}
351-
} else {
352-
if (mInputDeviceListenerRegistered) {
353-
mInputDeviceListenerRegistered = false;
354-
mIm.unregisterInputDeviceListener(this);
355-
}
356-
}
357-
358-
updateInputDeviceVibrators();
359-
}
360-
}
361-
362337
private void updateInputDeviceVibrators() {
363338
synchronized (mVibrations) {
364339
doCancelVibrateLocked();
365340

366341
synchronized (mInputDeviceVibrators) {
342+
mVibrateInputDevicesSetting = false;
343+
try {
344+
mVibrateInputDevicesSetting = Settings.System.getInt(mContext.getContentResolver(),
345+
Settings.System.VIBRATE_INPUT_DEVICES) > 0;
346+
} catch (SettingNotFoundException snfe) {
347+
}
348+
349+
if (mVibrateInputDevicesSetting) {
350+
if (!mInputDeviceListenerRegistered) {
351+
mInputDeviceListenerRegistered = true;
352+
mIm.registerInputDeviceListener(this, mH);
353+
}
354+
} else {
355+
if (mInputDeviceListenerRegistered) {
356+
mInputDeviceListenerRegistered = false;
357+
mIm.unregisterInputDeviceListener(this);
358+
}
359+
}
360+
367361
mInputDeviceVibrators.clear();
368362
if (mVibrateInputDevicesSetting) {
369363
int[] ids = mIm.getInputDeviceIds();

0 commit comments

Comments
 (0)