Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 10b88599 authored by Treehugger Robot's avatar Treehugger Robot Committed by Android (Google) Code Review
Browse files

Merge "Fix VibrationSettings to handle missing AudioManager" into main

parents 95b8b7e6 e61fd381
Loading
Loading
Loading
Loading
+5 −5
Original line number Diff line number Diff line
@@ -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();
        }
    }

+12 −0
Original line number Diff line number Diff line
@@ -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() {