The notification's sensitivity (visibility) is set by the developer, but can be overridden (to some extent) by the user.
There are 3 types of notification's lock screen visibility:
- Public: not sensitive, the full content is always shown on the lock screen
- Secret: never shown on the lock screen
- Private: sensitive, only the basic info (title and short content) is shown, but the full content is hidden
By default, all notifications are private (sensitive) unless overridden by the developer.
Changing the "On the lock screen" setting affects all notifications:
- Don't show notifications at all: all notifications are treated as secret
- Show all notification content: all notifications are treated as public
- Hide sensitive notification content: all notifications are treated as private, except for public notifications.
The user can also control per-app notification visibility, either from the app itself or from the Android system (general setting on Android 7.1 and below, or more fine-grained using notification channels on Android 8.0 and above).
Though, based on self-experiment, it's impossible to override per-app notification visibility to higher visibility than the general lock screen's setting. (e.g. when the lock screen is set to "Don't show", setting per-app to "Hide sensitive notification" does not work and instead will not show any notifications).