Commit graph

397 commits

Author SHA1 Message Date
Robert Müller 9832288983 Adopt changes to AndroidManifest.xml from SDL sample project
Specify `android:installLocation="auto"` so the app can be installed on and move to the external storage.

Specify optional features which the app may use (touchscreen, game controller, external mouse).

Specify `android:preferMinimalPostProcessing="true"` so lower latency HDMI mode is enabled when available. Specify `android:hardwareAccelerated="true"` for consistency (it is already the default setting).

Specify same `android:configChanges` and `android:alwaysRetainTaskState` values as SDL to avoid potential bugs due to inconsistency with what the `SDLActivity` expects.

See f5ed158d1f/android-project/app/src/main/AndroidManifest.xml
2024-09-07 12:09:41 +02:00
furo d40cc86bfa Set correct end line in twlang.py for strings with context 2024-08-30 20:15:26 +02:00
Robert Müller 1dd56f1a90 Remove unnecessary ndkVersion from Gradle build
Gradle can determine the NDK version automatically and this property is only required if multiple NDK versions are installed. The NDK version previously determined from the filename could not be parsed by Gradle anyway.
2024-08-28 18:12:05 +02:00
Robert Müller dc0d4b3b76 Add Android shortcuts for launching with Vulkan/OpenGL
Define shortcuts to launch the client with either Vulkan or OpenGL graphics backend, which can be accessed by long-pressing the app icon on the home screen. This feature is available for Android 7.1 and newer.
2024-08-27 21:04:43 +02:00
furo 728bb9777f Validate language files for and non-matching formatters 2024-08-25 00:40:12 +02:00
Robert Müller 24356bd029 Set debuggable flag in Gradle debug build
So the debug build of the app can be debugged.
2024-08-24 13:44:52 +02:00
Robert Müller e46d2375ba Add note to Android README about using stable rust version 2024-08-24 13:44:47 +02:00
Robert Müller 9b90588ccc Pin curl version to 8.8.0 for Android to fix library building 2024-08-24 13:44:40 +02:00
Robert Müller 0983e813d0 Add required attributes to Android manifest
Fix incorrect default value for Vulkan, which is not required.
2024-07-28 19:38:37 +02:00
Robert Müller 2b3ae2425d Update Vulkan and OpenGL ES versions specified in Android manifest
Specify that Vulkan 1.1.0 is used if supported.

Remove explicit requirement of OpenGL ES 3.0 as OpenGL ES 1.0 is also supported as fallback and the client should pick the highest supported version.
2024-07-27 12:06:39 +02:00
Robert Müller d4f47c2a55 Implement client restarting on Android
Restarting the client previously did not work, as the `shell_execute` function on Android uses `fork` which is not supported.

Now, the client is restarted by using an Android intent to restart the main activity. This is triggered by sending a user-defined message from the native code to the SDL main activity thread.
2024-07-16 12:52:19 +02:00
Robert Müller 60bbbcd424 Remove unnecessary DDNET_TEST_NO_LINK=1 in Android build
Verified with clean build, the variable is not necessary. Closes #8420.
2024-05-31 17:43:12 +02:00
Robert Müller 986508e091 Improve Android storage usage, faster launch, remove permissions
Split the user storage location and the data folder in the app specific external storage in the folders `data` and `user` instead of writing the user setting directly to the external storage.

Remove unnecessary storage permissions. The client only accesses files in its own external storage location, hence these permissions are not necessary for Android API 19 and higher, which is always given as we only target API 19 and higher.

Only unpack changed assets when their hash in the integrity index is different instead of unpacking all assets again, so the app starts faster after updates. Avoid unpacking the entire integrity index file unless it changed, by initially reading only the first hash directly from the asset, so the app starts faster when the data is up-to-date.

Add error handling for external storage not being accessible and other I/O errors during unpacking of assets.

Add `android_main.h` header to export the `InitAndroid` function and potentially other functions in the future. The `extern "C"` and `__attribute__((visibility("default")))` attributes seem to be unnecessary, as this function is only called directly from the native code like many other functions without these attributes.

Initialize the Android storage after the loggers, so the log message are printed properly.

Add documentation for the use of `std::exit` on Android, which is used to forcefully terminate the entire process, to ensure that static variables will be initialized correctly when the app is started again after quitting. Returning from the main function is not enough, as this only results in the native thread terminating, but the Java thread will continue. Java does not support unloading libraries once they have been loaded, so all static variables will not have their expected initial values anymore when the app is started again after quitting.

Use `fs_chdir` and `fs_makedir` instead of `chdir` and `mkdir`.
2024-05-25 21:09:42 +02:00
Robert Müller 1dfed5434e Lower minimum SDK to 19, remove unnecessary Gradle dependencies
SDK 19 is the lowest API level support by SDL2 because it is the lowest API level supported by the latest NDK toolchain. According to https://www.composables.com/tools/distribution-chart this should cover virtually all Android devices.

The dependencies on Kotlin and various `androidx`-Packages were entirely unnecessary and can be removed.
2024-05-23 22:09:23 +02:00
Robert Müller 63710a18a4 Preserve filenames and line numbers in ProGuard for debugging 2024-05-23 22:08:42 +02:00
Robert Müller 7de52fd46f Improve Android build script output, improve colors
Abort the Android CMake build immediately if any of the command line arguments is not specified, instead of assuming default values.

Add more log messages for different build steps to improve progress reporting and improve the existing log messages.

Improve and fix colors of log messages. Previously, some log message colors were not terminated properly, causing the output color of subsequent commands to change.

Avoid some error messages when the build script is executed for the first time, i.e. when cleanup of the previous build is not necessary because the files do not exist yet.

Make some related variable names more readable by removing the unnecessary underscore and `DEFAULT` prefixes.
2024-05-23 22:08:34 +02:00
Robert Müller 1a3b2eac10 Abort build script if CMake build failed for any architecture
Abort the build script when the CMake build fails for any of the selected architectures. Previously, the build may have continued and caused an APK without the respective library files to be built.
2024-05-23 20:48:56 +02:00
Robert Müller c8f0391c62 Remove unnecessary copy_dummy_files_rec function
Create the folder and copy the file manually instead of using a separate function for this, as the function is only used once.
2024-05-23 20:48:20 +02:00
Robert Müller d9f810691b Remove duplicate dynamic loading of game library
SDL automatically loads the libraries specified in the array returned by the `getLibraries` method, so loading it manually is unnecessary. SDL also has additional error handling to quit the app with an appropriate error message popup if the library could not be loaded, which was not handled previously.
2024-05-23 20:47:18 +02:00
Robert Müller 41738f1880 Ensure libary is copied successfully, remove unnecessary copies
Ensure that the main game library is copied successfully. Remove unnecessary copies of library files that do not exist and are unused, which were causing error messages during the build.
2024-05-23 20:46:35 +02:00
Robert Müller d9686591f0 Ensure APK build type parameter is valid
Abort build script if the build type parameter value is not valid, instead of assuming the debug build.
2024-05-23 20:45:52 +02:00
Robert Müller e981d48b24 Extract build_gradle function, fix Gradle use without arguments
Extract `build_gradle` function to reduce duplicate code for running the Gradle build. Remove the initial invocation of Gradle without a build target, which has no effect and was causing an error message during the build.
2024-05-23 20:45:42 +02:00
Robert Müller 6a453d10b4 Remove unused _RELEASE_TYPE_APK_NAME variable
This variable is always empty.
2024-05-23 20:43:53 +02:00
Robert Müller 69102880c9 Remove unused GE_NO_APK_BUILD variable
This variable is always empty and we don't need to support not building the APK file.
2024-05-23 20:43:53 +02:00
Robert Müller 930836f349 Split compile_source function for readability
Split the `compile_source` function into `compile_source_android` and `compile_source_webasm` instead of using a parameter to switch between the functionality.
2024-05-23 20:43:53 +02:00
Robert Müller 45f619722b Avoid duplicate creation of ddnet-libs directory
Avoid error messages due to `ddnet-libs` directory already existing and being created multiple times.
2024-05-23 20:43:53 +02:00
Robert Müller 60733bc033 Remove redundant check for existing directory with mkdir -p
The `mkdir -p` command is already idempotent so separately checking whether the directory exists is not necessary.
2024-05-23 20:43:30 +02:00
Robert Müller e9581b87ba Ensure specified target system for buiding libraries is valid
Abort building libraries if the specified target system is not one of the supported values.
2024-05-23 20:42:25 +02:00
Robert Müller 2844ad7239 Remove redundant OS_NAME_PATH variable
This variable was simply assigned the same value as the `OS_NAME` variable.
2024-05-23 18:06:59 +02:00
Robert Müller 0da30b7857 Remove obsolete autogen.sh usage for OpenSSL build
The OpenSSL project does not contain an `autogen.sh` file anymore, which was causing an error message when building the libraries.
2024-05-23 18:06:59 +02:00
ChillerDragon c75584406a Use shfmt as formatter for shell scripts 2024-05-23 08:05:00 +08:00
Robert Müller 1316ac3c70 Improve the Android building README.md 2024-05-21 17:38:48 +02:00
Robert Müller e4a7fd59f7 Determine default version name and code from version.h
Parse `GAME_RELEASE_VERSION` and `DDNET_VERSION_NUMBER` definitions from `src/game/version.h` by default, so specifying a version manually is usually not necessary.
2024-05-21 17:38:48 +02:00
Robert Müller 51e4e41805 Change tw.DDNet package name to org.ddnet.client 2024-05-21 17:38:48 +02:00
Robert Müller 664b0e98bb Upgrade Gradle and fix Android deprecation errors
Upgrade to Gradle 8.5 and Gradle Plugin 8.3.0 for compatibility with Java 21. Explicity set Java version 21 in `build.gradle`. Increment compile and target SDK version to 34 accordingly.

Remove the explicitly defined, obsolete `buildToolsVersion` property in `build.gradle`, as it is now automatically derived by Gradle.

Replace the deprecated property `android:extractNativeLibs` in `AndroidMainfest.xml` with `useLegacyPackaging` in `build.gradle`.

Replace the deprecated package definition `package="tw.DDNet"` in `AndroidMainfest.xml` with `namespace("tw.DDNet")` in `build.gradle`.

Add the required property `android:exported="true"` to the main activity in `AndroidMainfest.xml`.
2024-05-21 17:38:42 +02:00
Robert Müller cdbe1f775a Various fixes/improvements to Android building scripts
Use [cargo-ndk](https://github.com/bbqsrc/cargo-ndk) to configure cargo for building with the Android NDK. The output of `cargo ndk` is written to a subfolder for the target triplet, which cannot be changed by parameter. Therefore, the `CARGO_BUILD_DIR` is changed to this subfolder for the Android build, so the build process can find the output.

Use `$HOME` instead of `~` because cargo-ndk cannot correctly access the folder otherwise (will fail with error message indicating it could not determine the NDK version).

Add `DDNET_TEST_NO_LINK=ON` CMake argument, to fix Rust linking errors with tests.

Add additional CMake arguments to specify system name, API version and NDK location. Upgrade to Android API 34.

Use `nproc` instead of `32` threads for building.
2024-05-21 17:36:47 +02:00
Robert Müller b2c2a74db7 Remove unused shell script function arguments
Only the first two arguments of the `build_for_type` and `copy_libs` functions are used.
2024-05-21 17:36:47 +02:00
Robert Müller ceb1640320 Fix incorrect CMake target name in cmake_android.sh
The name of the main target was changed from `DDNet` to `game-client`.
2024-05-21 17:36:46 +02:00
Robert Müller 468cd85839 Add build folder parameter to cmake_android.sh
Add a parameter instead of using the fixed build folder `build_android`.
2024-05-21 17:36:46 +02:00
Robert Müller 9afe7444c1 Fix SDL3 being used in gen_libs.sh
The SDL default branch is now SDL3, so we need to check out specifically the SDL2 branch.
2024-05-21 17:36:46 +02:00
Robert Müller ad9b44bfed Remove local.properties and add it to .gitignore
This file is not supposed to be added to version control and will be regenerated whenever the Gradle build is run.
2024-05-21 17:36:46 +02:00
Robert Müller fd4f61e601 Fix performance regression in copy_fix.py 2024-05-19 19:47:12 +02:00
Robert Müller 05c825947a Force landscape orientation and hide title bar on Android
Always force landscape orientation to be used for the game on Android.

Hide the title bar so it is not shown when starting the game. There is also a bug with SDL currently that leads to the title bar and status bar being shown permanently after minimizing and reopening the app, which is alleviated by hiding the title bar.
2024-05-19 12:58:33 +02:00
Robert Müller c8f6811aba Also print external module/symbol names in parse_drmingw.sh
Example output before this change:

```
Module offset: 0x00007FF7C8DE0000
Image base: 0x0000000140000000
0x0000000772cb5efc: ?? ??:0
0x000000077cd5c3e8: ?? ??:0
0x000000075d063cc3: ?? ??:0
0x000000075d2a3d61: ?? ??:0
0x000000075d0b7fde: ?? ??:0
0x000000075d2a5f18: ?? ??:0
0x000000075d2a6809: ?? ??:0
0x000000075d0b8140: ?? ??:0
0x000000075cf9d41b: ?? ??:0
0x000000014034b4c7: CCommandProcessorFragment_Vulkan::WaitFrame() at src/engine/client/backend/vulkan/backend_vulkan.cpp:2341
0x000000014034a1a5: CCommandProcessorFragment_Vulkan::NextFrame() at src/engine/client/backend/vulkan/backend_vulkan.cpp:2501
0x000000014032d5b6: CCommandProcessorFragment_Vulkan::RunCommand(CCommandBuffer::SCommand const*) at src/engine/client/backend/vulkan/backend_vulkan.cpp:6473
0x000000014001a7e6: CCommandProcessor_SDL_GL::RunBuffer(CCommandBuffer*) at src/engine/client/backend_sdl.cpp:335
0x00000001400168eb: CGraphicsBackend_Threaded::ThreadFunc(void*) at src/engine/client/backend_sdl.cpp:65
0x0000000140237f9a: CWindowsComLifecycle::~CWindowsComLifecycle() at src/base/system.cpp:4660
 (inlined by) thread_run at src/base/system.cpp:796
0x00000007ea7e257d: ?? ??:0
0x00000007eb62aa48: ?? ??:0
```

Output for the same crash dump with this change:

```
Module offset: 0x00007FF7C8DE0000
Image base: 0x0000000140000000

amdvlk64.dll!vk_icdGetInstanceProcAddrSG+0x1f40c
atig6pxx.dll!AmdGetCallbackProcs+0x124
amdvlk64.dll!vk_icdGetInstanceProcAddrSG+0x57773
amdvlk64.dll!vk_icdGetInstanceProcAddrSG+0x297811
amdvlk64.dll!vk_icdGetInstanceProcAddrSG+0xaba8e
amdvlk64.dll!vk_icdGetInstanceProcAddrSG+0x2999c8
amdvlk64.dll!vk_icdGetInstanceProcAddrSG+0x29a2b9
amdvlk64.dll!vk_icdGetInstanceProcAddrSG+0xabbf0
amdvlk64.dll!IcdPresentBuffers+0xb8eb
0x000000014034b4c7: CCommandProcessorFragment_Vulkan::WaitFrame() at src/engine/client/backend/vulkan/backend_vulkan.cpp:2341
0x000000014034a1a5: CCommandProcessorFragment_Vulkan::NextFrame() at src/engine/client/backend/vulkan/backend_vulkan.cpp:2501
0x000000014032d5b6: CCommandProcessorFragment_Vulkan::RunCommand(CCommandBuffer::SCommand const*) at src/engine/client/backend/vulkan/backend_vulkan.cpp:6473
0x000000014001a7e6: CCommandProcessor_SDL_GL::RunBuffer(CCommandBuffer*) at src/engine/client/backend_sdl.cpp:335
0x00000001400168eb: CGraphicsBackend_Threaded::ThreadFunc(void*) at src/engine/client/backend_sdl.cpp:65
0x0000000140237f9a: CWindowsComLifecycle::~CWindowsComLifecycle() at src/base/system.cpp:4660
 (inlined by) thread_run at src/base/system.cpp:796
KERNEL32.DLL!BaseThreadInitThunk+0x1d
ntdll.dll!RtlUserThreadStart+0x28
```

Also improve variable names in the script and add some comments.
2024-05-17 19:35:37 +02:00
Robert Müller e341c56c35 Fix possibly-used-before-assignment in copy_fix.py
Always initialize the variables `local` and `supported` instead of initializing them conditionally, to fix the false-positive `possibly-used-before-assignment` pylint detection.

Closes #8369.
2024-05-16 20:46:14 +02:00
furo b24f14d4f3 Set sqlite3 .timeout in integration_test.sh 2024-05-10 17:48:44 +02:00
ChillerDragon 244875e339 Increase rcon command delay in integration test
Closed #8261
2024-05-05 15:24:38 +08:00
Zwelf 2eb4a50d4d Add check for correct finish time in integration_test.sh
ALso exclude coverage.map from twmap-checker due to using tele
checkpoints without matching tele checkpoints to test physics.

Disable exact checks on valgrind. Only require at least one finish.
2024-04-21 23:24:16 +02:00
Robert Müller 00bf9b5248 Make parse_drmingw.sh script also useable on Windows with MSYS2
Use `objdump` instead of `winedump` to determine the image base address of the executable file, as `winedump` is not easily available on Windows.

It should be enough to install the `binutils` package (containing `addr2line` and `objdump`) from a package manager to use the script now.
2024-03-29 11:13:48 +01:00
dobrykafe e46f16ed91 check for newline at the end of source files 2024-03-23 16:01:00 +01:00