'How to programmatically enable/disable haptic feedback in System Settings in a device running SDK API level 30+?

Since as of API level 30, System.HAPTIC_FEEDBACK_ENABLED has been marked as deprecated, how would one programmatically enable/disable haptic feedback in System Settings(i.e. globally) on a device running SDK API level 30+ using the VibrationAttributes-related APIs?



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source