Change the notifications enabled/disabled status for an app (and channels and priority)
The now defunct Secure Settings plugin used to have a feature that allowed you to enable or disable notifications for an app. I eventually figured out that this can be set with root and the "service call" command, using the following as a reference for Pie https://android.googlesource.com/platform/frameworks/base/+/refs/heads/pie-release/core/java/android/app/INotificationManager.aidl
So for the app "com.my.app", you first need to get the uid:
stat -c "%u" /data/data/com.my.app
Then run the following to disable notifications:
service call notification 10 s16 "com.my.app" i32 app_uid i32 0
To re-enable them, run:
service call notification 10 s16 "com.my.app" i32 app_uid i32 1
You can also fetch the notification status by running:
service call notification 12 s16 "com.my.app" i32 app_uid
It's probably fine to disable the notifications if they're already disabled, and vice versa, but I always check first and run it only if necessary. The Secure Settings plugin did the same.
The number after "notification", in this case 10 and 12, change with each Android version. 10 and 12 are what Pie uses, and the above link can be used to look them up. "bool areNotificationsEnabledForPackage" is the 12th function listed under INotificationManager, and "void setNotificationsEnabledForPackage" is the 10th function listed. I'm not aware of any way to pull this from a running phone, and instead they have to be looked up in Android source. That's presumably why this feature in Secure Settings stopped working.
The other functions there can also be used to change notification priority for the app, along with working with the app's notification channels. I'm not sure how to best represent the app's notification channels in the Tasker UI, but a simple action to just enable or disable an app's notifications would be really convenient.