The error you're encountering is due to Android's security restrictions: ADD_TRUSTED_DISPLAY is a system-level permission that is not directly grantable to third-party apps (like Termux) via standard Android permission mechanisms. This permission is typically reserved for system apps or services with elevated privileges.
ADD_TRUSTED_DISPLAY is a system-only permission, meaning only apps signed with the platform key (i.e., built into the Android system) can use it.su to run Termux as root and bypass the permission check.DisplayManagerService to allow your app to use the permission.bashadb shell su -c "app_process -Djava.class.path=/path/to/your/app / com.termux.api.TermuxApiReceiver createVirtualDisplay ..."
AndroidManifest.xml, Android will still enforce the system-only restriction:
xml<uses-permission android:name="android.permission.ADD_TRUSTED_DISPLAY" />
There is no standard way to grant the ADD_TRUSTED_DISPLAY permission to a third-party app like Termux without rooting or modifying the Android framework. The restriction is intentional for security reasons.
If you are developing this for a specific use case (e.g., screen mirroring, accessibility), consider alternative approaches, such as using non-trusted virtual displays or leveraging other APIs (e.g., MediaProjection for screen capture).
Would you like help exploring alternative solutions for your specific use case?