/packages/apps/DeskClock/src/com/android/deskclock/data/DataModel.kt
最初代码:
private class UnmuteAlarmVolumeListener : View.OnClickListener {
override fun onClick(v: View) {
// Set the alarm volume to 11/16th of max and show the slider UI.
// 11/16th of max is the initial volume of the alarm stream on a fresh install.
val context: Context = v.context
val am: AudioManager = context.getSystemService(AUDIO_SERVICE) as AudioManager
val index = (am.getStreamMaxVolume(STREAM_ALARM) * 11f / 16f).roundToInt()
am.setStreamVolume(STREAM_ALARM, index, FLAG_SHOW_UI)
}
}
新增修改后的代码:
private class UnmuteAlarmVolumeListener : View.OnClickListener {
override fun onClick(v: View) {
// Set the alarm volume to 11/16th of max and show the slider UI.
// 11/16th of max is the initial volume of the alarm stream on a fresh install.
val context: Context = v.context
val am: AudioManager = context.getSystemService(AUDIO_SERVICE) as AudioManager
val index = (am.getStreamMaxVolume(STREAM_ALARM) * 11f / 16f).roundToInt()
am.setStreamVolume(STREAM_ALARM, index, FLAG_SHOW_UI)
//MengLingbiao add it to "Turn off the mute in Do Not Disturb mode."(Time:2024_10_11)
if (Utils.isLOrLater) {
try {
// Attempt to open the dnd settings for this app.
context.startActivity(
Intent("android.settings.ZEN_MODE_SETTINGS")
.putExtra(Settings.EXTRA_APP_PACKAGE, context.packageName))
return
} catch (ignored: Exception) {
// best attempt only; recovery code below
}
}
//MengLingbiao add it to "Turn off the mute in Do Not Disturb mode."(Time:2024_10_11)
}
}
上述是通过Intent页面跳转实现的,在勿扰模式下进入闹钟后退弹出一个取消静音的提示,此时点击取消静音就会跳转到设置下勿扰模式设置的页面,在该页面进行一些取消的操作即可。