Skip to content

Commit

Permalink
hopefully fixed broken dnd-bypass
Browse files Browse the repository at this point in the history
  • Loading branch information
newhinton committed Dec 29, 2023
1 parent 1ebbea1 commit 419f9f3
Showing 1 changed file with 12 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -32,16 +32,18 @@ import android.app.NotificationManager
import android.content.Context
import android.media.AudioManager
import android.util.Log
import androidx.core.content.ContextCompat.getSystemService
import de.felixnuesse.timedsilence.Constants.Companion.REASON_MANUALLY_SET
import de.felixnuesse.timedsilence.handler.LogHandler
import de.felixnuesse.timedsilence.handler.PreferencesManager
import de.felixnuesse.timedsilence.handler.calculator.HeadsetHandler
import de.felixnuesse.timedsilence.handler.volume.VolumeState.Companion.TIME_SETTING_LOUD
import de.felixnuesse.timedsilence.handler.volume.VolumeState.Companion.TIME_SETTING_SILENT
import de.felixnuesse.timedsilence.handler.volume.VolumeState.Companion.TIME_SETTING_UNSET
import de.felixnuesse.timedsilence.handler.volume.VolumeState.Companion.TIME_SETTING_VIBRATE
import de.felixnuesse.timedsilence.handler.LogHandler
import de.felixnuesse.timedsilence.handler.PreferencesManager
import de.felixnuesse.timedsilence.handler.calculator.HeadsetHandler
import de.felixnuesse.timedsilence.util.PermissionManager


class VolumeHandler(private var mContext: Context) {
companion object {
private const val TAG = "VolumeHandler"
Expand Down Expand Up @@ -82,35 +84,32 @@ class VolumeHandler(private var mContext: Context) {
Log.e(TAG, "VolumeHandler: Apply: Silent!")
val manager = mContext.getSystemService(Context.AUDIO_SERVICE) as AudioManager


if(!manager.isMusicActive || mIgnoreMusicPlaying){
setMediaVolume(0, manager)
}

//supress annoying vibration on Q
//maybe this is nessessary on P, but idk
if (android.os.Build.VERSION.SDK_INT < 29) {


}

setStreamToPercent(
manager,
AudioManager.STREAM_ALARM,
PreferencesManager(mContext).getAlarmVolume()
)

if(manager.ringerMode!= AudioManager.RINGER_MODE_SILENT){
manager.ringerMode=AudioManager.RINGER_MODE_SILENT
}


if(mPreferencesManager.changeRingerVolume()){
Log.d(TAG, "VolumeHandler: Setting Ringer! This might be not what you want!")
setStreamToPercent(
manager,
AudioManager.STREAM_RING,
0
)
if(manager.ringerMode!= AudioManager.RINGER_MODE_SILENT){
manager.ringerMode=AudioManager.RINGER_MODE_SILENT
}
}


val mNotificationManager = mContext.getSystemService(Context.NOTIFICATION_SERVICE) as NotificationManager?
mNotificationManager?.setInterruptionFilter(NotificationManager.INTERRUPTION_FILTER_ALARMS)
mNotificationManager?.setInterruptionFilter(NotificationManager.INTERRUPTION_FILTER_PRIORITY)
Expand Down

0 comments on commit 419f9f3

Please sign in to comment.