Switch OnePlus Alert Slider Notification Profiles 2.0

Switch notification profiles between Ring, Vibration and Silent

  1. autormali

    Update. Version 2.0 created and tested on Android 11 (OxygenOS 11).

    Since the last update of the project, OnePlus abandoned using of DND in Alert Slider settings thus I decided release the update as the profiles can be emulated in more reliable way compare to the first release of the project.

    The project provides three tasks Silent, Vibration and Ring which you can use creating your own profiles referring to these tasks. Alert Slider should be physically kept in its bottom position (Ring position) when applying the settings with the tasks.

    While Ring and Vibration profiles is quite easy to emulate, Silent profile requires additional constants to be changed. You can observe proper status bar icon but the icon in the settings will remain as vibration - picture . The vibration is disabled by applying appropiate setting of notification_vibration_intensity (see Silent task description for details), which is normally toggleable in Settings>System>Accessibility>Vibration& haptic strenght - picture .

    There is Notification Profiles Setup Task, it needs to be run before you start using of the project. Profile Alert Slider Notification Profiles Logger is logging physical or applied by this project slider position as well as restoring some settings. Debug/Test Settings task (not seen in the descriptions below) is for testing purposes and you can erase it if you want. It is recomended to remove previous version of the poject from Tasker before you import version 2.0.

    Descriptions:

    Code (Text):
        Notification Profiles Setup Task (549)
        A1: Ask Permissions [ Required Permissions:android.permission.WRITE_SECURE_SETTINGS ]
        <Read three_key_mode setting>
        A2: Custom Setting [ Type:Global Name:three_Key_mode Value: Use Root:Off Read Setting To:%three_key_mode ]
        A3: Text Dialog [  Title:Notification Profiles Setup Text:Please switch Alert Slider to Ring position to set \%AlertSlider variable and run this task again.<br> Button 1:OK Button 2: Button 3: Close After (Seconds):30 Use HTML:On ] If [ %three_key_mode !~ 3 ]
        A4: Stop [ With Error:Off Task: ] If [ %three_key_mode !~ 3 ]
        <Set variable to current Alert Slider setting name>
        A5: Variable Set [ Name:%AlertSlider To:Ring Recurse Variables:Off Do Maths:Off Append:Off Max Rounding Digits:3 ]
        A6: Flash [ Text:Setup completed if permissions granted. Long:Off ]


        Profile: Alert Slider Notification Profiles Logger (662)
        Priority: 45 Notification: no
        Event: Custom Setting [ Type:Global Name:three_Key_mode Value:* ]
        Enter: Alert Slider Notification Profiles Logger (1030)
        <ℹ️ This task is run when three_Key_mode constant is changed in both following cases: 1. Alert Slider is physically switched and 2. One of the tasks (Ring, Vibration and Silent) has been run>
        A1: Stop [ With Error:Off Task: ] If [ %evtprm(3) !Set ]
        A2: Array Set [ Variable Array:%alertslider Values:Silent,Vibration,Ring Splitter:, ]
        <Set variable to current Alert Slider setting name>
        A3: Variable Set [ Name:%AlertSlider To:%alertslider(%evtprm3) Recurse Variables:Off Do Maths:Off Append:Off Max Rounding Digits:3 ]
        A4: [X] Flash [ Text:Alert Slider set to: %AlertSlider Long:Off ]
        <ℹ️ Below settings will be restored in one particular situation. When Silent task has been run and after that Alert Slider is switched physically to any position.>
        A5: If [ %evtprm(3) ~ 2 | %evtprm(3) ~ 3 ]
        <Set notification_vibration_intensity. Restore notifications vibration setting.>
        A6: Custom Setting [ Type:System Name:notification_vibration_intensity Value:%Notification_vibration_intensity Use Root:Off Read Setting To: ] If [ %Notification_vibration_intensity Set ]
        <Rrstore media volume level.>
        A7: Media Volume [ Level:%Volume_music_speaker Display:Off Sound:Off ] If [ %Volume_music_speaker Set ]
        A8: Variable Clear [ Name:%Notification_vibration_intensity Pattern Matching:On Local Variables Only:Off Clear All Variables:Off ] If [ %Notification_vibration_intensity Set ]
        A9: Variable Clear [ Name:%Volume_music_speaker Pattern Matching:On Local Variables Only:Off Clear All Variables:Off ] If [ %Volume_music_speaker Set ]
        A10: End If


        Ring (1038)
        A1: Stop [ With Error:Off Task: ] If [ %AlertSlider ~ Ring ]
        A2: [X] Vibrate Pattern [ Pattern:0,200 ]
        <Run Vibration task when running this task direct from Silent notification profile>
        A3: Perform Task [ Name:Vibration Priority:%priority Parameter 1 (%par1): Parameter 2 (%par2): Return Value Variable: Stop:Off Local Variable Passthrough:Off Limit Passthrough To: Reset Return Variable:Off Allow Overwrite Variables:Off ] If [ %AlertSlider ~ Silent ]
        <Set mode_ringer to 2>
        A4: Custom Setting [ Type:Global Name:mode_ringer Value:2 Use Root:Off Read Setting To: ]
        <Set three_Key_mode to 3. This will trigger accompanying profile and set %AlertSlider variable.>
        A5: Custom Setting [ Type:Global Name:three_Key_mode Value:3 Use Root:Off Read Setting To: ]
        A6: Sound Mode [ Mode:Sound ]


        Vibration (989)
        A1: Stop [ With Error:Off Task: ] If [ %AlertSlider ~ Vibration ]
        A2: [X] Vibrate Pattern [ Pattern:0,51,30,51 ]
        <Set notification_vibration_intensity. Restore notifications vibration setting when switching from Silent task.>
        A3: Custom Setting [ Type:System Name:notification_vibration_intensity Value:%Notification_vibration_intensity Use Root:Off Read Setting To: ] If [ %AlertSlider ~ Silent & %Notification_vibration_intensity Set ]
        <Restore media volume level when switching from Silent task.>
        A4: Media Volume [ Level:%Volume_music_speaker Display:Off Sound:Off ] If [ %AlertSlider ~ Silent & %Volume_music_speaker Set ]
        <Set mode_ringer to 1>
        A5: Custom Setting [ Type:Global Name:mode_ringer Value:1 Use Root:Off Read Setting To: ]
        <Set three_Key_mode to 2. This will trigger accompanying profile and set %AlertSlider variable.>
        A6: Custom Setting [ Type:Global Name:three_Key_mode Value:2 Use Root:Off Read Setting To: ]
        A7: Sound Mode [ Mode:Vibrate ]
        A8: Variable Clear [ Name:%Notification_vibration_intensity/%Volume_music_speaker Pattern Matching:On Local Variables Only:Off Clear All Variables:Off ]
        <Do not remove or disable this action. This is for proper and reliable execution of settings applied by this task and Alert Slider Notification Profiles Logger task when switching direct between Ring to Silent and Silent to Ring.>
        A9: Wait [ MS:500 Seconds:0 Minutes:0 Hours:0 Days:0 ]



        Silent (1039)
        A1: Stop [ With Error:Off Task: ] If [ %AlertSlider ~ Silent ]
        <Run Vibration task when running this task direct from Ring notification profile>
        A2: Perform Task [ Name:Vibration Priority:%priority Parameter 1 (%par1): Parameter 2 (%par2): Return Value Variable: Stop:Off Local Variable Passthrough:Off Limit Passthrough To: Reset Return Variable:Off Allow Overwrite Variables:Off ] If [ %AlertSlider ~ Ring ]
        <Read notification_vibration_intensity setting and store it in global var>
        A3: Custom Setting [ Type:System Name:notification_vibration_intensity Value: Use Root:Off Read Setting To:%Notification_vibration_intensity ]
        A4: Sound Mode [ Mode:Mute ]
        <Set mode_ringer to 0>
        A5: Custom Setting [ Type:Global Name:mode_ringer Value:0 Use Root:Off Read Setting To: ]
        <Set three_Key_mode to 1. This will trigger accompanying profile and set %AlertSlider variable.>
        A6: Custom Setting [ Type:Global Name:three_Key_mode Value:1 Use Root:Off Read Setting To: ]
        <Set notification_vibration_intensity to 0. Disable notifications vibration.>
        A7: Custom Setting [ Type:System Name:notification_vibration_intensity Value:0 Use Root:Off Read Setting To: ]
        <Read oem_zen_media_switch setting>
        A8: Custom Setting [ Type:System Name:oem_zen_media_switch Value: Use Root:Off Read Setting To:%oem_zen_media_switch ]
        <Read volume_music_speaker setting and store it in global var>
        A9: Custom Setting [ Type:System Name:volume_music_speaker Value: Use Root:Off Read Setting To:%Volume_music_speaker ]
        <Mute Media Volume, if alert slider option "Mute Media Volume" is enabled>
        A10: Media Volume [ Level:0 Display:Off Sound:Off ] If [ %oem_zen_media_switch ~ 1 ]

    ___
    Project version 1.1 works only with Oxygen 8. Description below for this version.


    This Tasker project allows you to switch notification profiles between Ring, Do Not Disturb and Silent on OnePlus devices.

    This is how it works:




    OnePlus blocked the customization the alert slider behavior (Oxygen 3.5.X and above) by locking the volume to the minimum level of 1 in all of the positions of physical slider, except for the top position. OP owners are missing the possibility of automate switching to Silent or Do Not Disturb profiles without acting on physical slider. This Tasker project makes it possible.

    By default, the three positions from top to bottom represent the Silent, Do Not Disturb, and Ring profiles respectively. All the settings applied by the project are made while the alert slider is physically kept at it's bottom position where Do Not Disturb and Silent settings are normally not available. That was not possible before due to necessity of switching the notification profiles physically.

    The project consists of profile Notification Profile=:=, three main tasks: Ring, Do Not Disturb, Silent and one accompanying subroutine task Adjust Stream Volume. Thanks to u/pleplenus for the idea of volume slider task which has been tweaked a little bit to fit the project needs. All tasks desriptions are avialable here.

    To apply the notification profile, simply run one of the main tasks or use AutoApps command accordingly: Notification Profile=:=Silent, Notification Profile=:=Do Not Disturb and Notification Profile=:=Ring. If you want to disable the volume panel toasts - disable the last action in each of the main tasks.

    There is one additional helper task Test Audio Streams added to the project. It's toasting current volume levels of audio streams and playing these streams for testing purpose. Run it to compare what settings are currently applied at all alert slider positions as well as after the tasks are run.

    Provided project supposed to be used while the alert slider is physically switched to its bottom (Ring) position . When alert slider is switched the middle or top position the settings of the alert slider are applied.


    Any enhancements and comments are welcome.
    Adam R likes this.