Main effort was to port code to Android 9/12 using Android’s NDK/SDK.
Things I had to have into account to make it happen:
- All language API layers had to be supported for Android, and all APIs supported by NDK’s API
- Current install and test automation at the time written in Python did not support Android
- Android 9 used different and quite often deprecated tools from Android 12, like the android command, the ant tool or an old version of Java/other tools
- Android 9 is incompatible with Android 12 when it comes to the use of NETLINK sockets, and bind() was now privileged since Android 11, which are a special socket that can be used to find out when an network interface has changed on the fly
- Android 12 apps require a set of new permissions to be run
All the above problems were solved:
- Ported the C layer code for both Android 9 and 12, using different code paths and APIs.
- Ported Python automation, which was also specific to each, as there were known Android 9 bugs (the infamous iuautomator bug) and Android 12 granting of permissions (MANAGE_EXTERNAL_STORAGE). Having these new permissions in the Android manifest was not sufficient though, as the user needed to approve it directly from the user interface. As this is not scalable for automating testing, for testing purposes it is allowed to pre-grant certain permissions with adb:
# adb -s <device_id> shell appops set --uid <package_name> MANAGE_EXTERNAL_STORAGE allow
- Created Android JNI code to create an Android app via APK which can reuse C/C++ libraries and use the functionality they provide. Note that the application libraries and the C++ standard library should be part of the APK.
Fun!