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

Commit e47e8520 authored by Dianne Hackborn's avatar Dianne Hackborn
Browse files

Keyguard sound needs to hold wake lock.

We need to hold a wakelock while playing the keyguard lock sound,
so that it actually completes before the CPU goes to sleep.

Change-Id: I144c345383afeb911ea461b2eb17b31183b6d092
parent a80599f5
Loading
Loading
Loading
Loading
+16 −1
Original line number Diff line number Diff line
@@ -204,6 +204,21 @@ public class Ringtone {
        openMediaPlayer();
    }

    /** @hide */
    public void setWakeMode(Context context, int mode) {
        if (mAudio == null) {
            try {
                openMediaPlayer();
            } catch (Exception ex) {
                Log.e(TAG, "setWakeMode() caught ", ex);
                mAudio = null;
            }
        }
        if (mAudio != null) {
            mAudio.setWakeMode(context, mode);
        }
    }

    /**
     * Plays the ringtone.
     */
+1 −0
Original line number Diff line number Diff line
@@ -1054,6 +1054,7 @@ public class KeyguardViewMediator implements KeyguardViewCallback,
                    final Ringtone sfx = RingtoneManager.getRingtone(mContext, soundUri);
                    if (sfx != null) {
                        sfx.setStreamType(AudioManager.STREAM_SYSTEM);
                        sfx.setWakeMode(mContext, PowerManager.PARTIAL_WAKE_LOCK);
                        sfx.play();
                    } else {
                        if (DEBUG) Log.d(TAG, "playSounds: failed to load ringtone from uri: "