Android14——DeskClock勿扰模式下取消闹钟的静音(通过页面跳转实现)

/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页面跳转实现的,在勿扰模式下进入闹钟后退弹出一个取消静音的提示,此时点击取消静音就会跳转到设置下勿扰模式设置的页面,在该页面进行一些取消的操作即可。

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

爱睡觉的小Meng

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值