Hello @gmahendra ,
The slingSettingsService service is deprecated. It's never recommended you use a deprecated code. You can check this: https://github.com/Adobe-Consulting-Services/acs-aem-commons/issues/2476
Since it was very necessary in some situations we can write a custom simple code for this.
In your OSGI config file create something like this.

Maybe you already have some. You can check how you read it from OSGI config: https://medium.com/@toimrank/aem-r6-annotation-57514f7e9838
For this, in your config file just add an extra field
system.runmode=author/publish
system.instance=prod/stage
And finally, in your Java class Inject your service and get the run mode by calling the function.
Hope you understand this custom solution and why I recommended you for this custom one.