Android: decouple video/audio subsystems from JNI initialization

Allow Android embedders to use SDL without the full video/audio Java
layer by gating subsystem-specific code behind SDL_VIDEO_DISABLED and
SDL_AUDIO_DISABLED preprocessor flags.

This enables applications that only need joystick/gamepad support
(e.g. Qt-based apps like QGroundControl) to build SDL without shipping
stub Java classes for unused subsystems.

Changes:
- Split SDLActivity JNI method table into core (lifecycle, hints,
  permissions) and video (surface, input, clipboard, orientation)
- Gate SDLAudioManager and SDLInputConnection JNI registration
- Make checkJNIReady() subsystem-aware: no longer requires
  mAudioManagerClass when SDL_AUDIO_DISABLED
- Group method ID resolution by subsystem in nativeSetupJNI()
- Guard all video/audio function implementations and declarations
- Keep display orientation accessors always available (needed by camera)
- Add subsystem-selective SDL.setupJNI(int)/initialize(int) to SDL.java
  with backwards-compatible zero-arg overloads
- Guard SDL_VIDEO_DRIVER_ANDROID and related defines in
  SDL_build_config_android.h
This commit is contained in:
Holden Ramsey 2026-03-12 11:22:14 -04:00 committed by Sam Lantinga
parent 8554d1c23c
commit 7a6eed4ec8
7 changed files with 223 additions and 72 deletions

View file

@ -178,6 +178,7 @@
#define SDL_TIMER_UNIX 1
/* Enable various video drivers */
#ifndef SDL_VIDEO_DISABLED
#define SDL_VIDEO_DRIVER_ANDROID 1
/* Enable OpenGL ES */
@ -196,6 +197,7 @@
#define HAVE_GPU_OPENXR 1
#define SDL_VIDEO_RENDER_GPU 1
#endif
#endif /* SDL_VIDEO_DISABLED */
/* Enable system power support */
#define SDL_POWER_ANDROID 1