如何获取Android上指定文件的SELinux上下文?

How to get the SELinux context of a specified file on Android?

我正在为 Android 开发 SU-aware 应用程序,发现某些设备上的 SELinux 上下文配置和策略与其他设备略有不同。

是否有AndroidSDK的public或隐藏的API查询指定文件的SELinux上下文,如"ls -Z"在shell中提供的?

看看这个。

https://android.googlesource.com/platform/frameworks/base/+/master/core/java/android/os/SELinux.java

也许您知道如何为商店中的 Android 应用程序设置 SELinux scontext。 我想为我的自定义域更改 utrusted_app。