Loading services/core/java/com/android/server/vibrator/VibrationSettings.java +5 −5 Original line number Diff line number Diff line Loading @@ -617,11 +617,11 @@ final class VibrationSettings { private void updateRingerMode() { synchronized (mLock) { // If audio manager was not loaded yet then assume most restrictive mode. // This will be loaded again as soon as the audio manager is loaded in onSystemReady. mRingerMode = (mAudioManager == null) ? AudioManager.RINGER_MODE_SILENT : mAudioManager.getRingerModeInternal(); if (mAudioManager == null) { // Service not ready yet or audio service not available, skip this update request. return; } mRingerMode = mAudioManager.getRingerModeInternal(); } } Loading services/tests/vibrator/src/com/android/server/vibrator/VibrationSettingsTest.java +12 −0 Original line number Diff line number Diff line Loading @@ -449,6 +449,18 @@ public class VibrationSettingsTest { } } @Test public void shouldIgnoreVibration_withoutAudioManager_allowsAllVibrations() { mVibrationSettings = new VibrationSettings(mContextSpy, new Handler(mTestLooper.getLooper()), mVibrationConfigMock); mVibrationSettings.onSystemReady(mPackageManagerInternalMock, mPowerManagerInternalMock, mActivityManagerMock, mVirtualDeviceManagerInternalMock, /* audioManager= */ null); for (int usage : ALL_USAGES) { assertVibrationNotIgnoredForUsage(usage); } } @Test public void shouldIgnoreVibration_vibrateOnDisabled_ignoresUsagesNotAccessibility() { Loading Loading
services/core/java/com/android/server/vibrator/VibrationSettings.java +5 −5 Original line number Diff line number Diff line Loading @@ -617,11 +617,11 @@ final class VibrationSettings { private void updateRingerMode() { synchronized (mLock) { // If audio manager was not loaded yet then assume most restrictive mode. // This will be loaded again as soon as the audio manager is loaded in onSystemReady. mRingerMode = (mAudioManager == null) ? AudioManager.RINGER_MODE_SILENT : mAudioManager.getRingerModeInternal(); if (mAudioManager == null) { // Service not ready yet or audio service not available, skip this update request. return; } mRingerMode = mAudioManager.getRingerModeInternal(); } } Loading
services/tests/vibrator/src/com/android/server/vibrator/VibrationSettingsTest.java +12 −0 Original line number Diff line number Diff line Loading @@ -449,6 +449,18 @@ public class VibrationSettingsTest { } } @Test public void shouldIgnoreVibration_withoutAudioManager_allowsAllVibrations() { mVibrationSettings = new VibrationSettings(mContextSpy, new Handler(mTestLooper.getLooper()), mVibrationConfigMock); mVibrationSettings.onSystemReady(mPackageManagerInternalMock, mPowerManagerInternalMock, mActivityManagerMock, mVirtualDeviceManagerInternalMock, /* audioManager= */ null); for (int usage : ALL_USAGES) { assertVibrationNotIgnoredForUsage(usage); } } @Test public void shouldIgnoreVibration_vibrateOnDisabled_ignoresUsagesNotAccessibility() { Loading