Backport of core PR17474.
This has been adapted to match our codebase changes from core.
It introduces one change to the way the unknown service bits are displayed,
to make them consistenly display as a bit number. This matches what core does
when the backports are up-to-date and makes the code simpler.