'How to read Android platform key signature programmatically

I need to read the signature of the platform key, which signed the whole build on the device. Currently, I can read the signature of an arbitrary package like com.android.systemui etc. However, due to some custom ROMs, no package is guaranteed to be installed as a part of the system.

So, my question: is there a way to read the signing signature of the system on Android devices programmatically?


Note: I am not trying to read the key itself. Signature, or its hash is sufficient for me.



Sources

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

Source: Stack Overflow

Solution Source