Merge "Keyguard sound needs to hold wake lock."

This commit is contained in:
Dianne Hackborn
2011-09-21 15:15:18 -07:00
committed by Android (Google) Code Review
2 changed files with 17 additions and 1 deletions

View File

@ -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.
*/

View File

@ -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: "