From c7a965933b8d77f36b5adfdfd14b3a3ea01387a1 Mon Sep 17 00:00:00 2001 From: Ralf Habacker Date: Fri, 1 Dec 2017 21:14:52 +0100 Subject: [PATCH] Add build information for Android platforms With this commit dbus-run-session is build and installed on non Windows platforms. Signed-off-by: Ralf Habacker Bug: https://bugs.freedesktop.org/show_bug.cgi?id=104022 --- README.android | 127 +++++++++++++++++++++++++++++++++++++++++++++ cmake/tools/CMakeLists.txt | 10 ++++ 2 files changed, 137 insertions(+) create mode 100644 README.android diff --git a/README.android b/README.android new file mode 100644 index 00000000..f0ea0a6f --- /dev/null +++ b/README.android @@ -0,0 +1,127 @@ +Build DBus for android on Linux +=============================== + + +1. download and install android-studio.sh +----------------------------------------- + +see https://developer.android.com/studio/index.html + + +2. install required Android SDK and Tools +----------------------------------------- +This is performed with the android-studio SDK manager +(see https://developer.android.com/studio/intro/update.html#sdk-manager) + +Install + from SDK Platforms + - Android 5.0 ABI level 21 (for example) + + from SDK tools + - CMake + - Android NDK + +into say ~/Android/Sdk + + +3. Setup environment in bash shell +---------------------------------- + + export ANDROID_NDK=~/Android/Sdk/ndk-bundle + # this path may change with newer cmake installations + export ANDROID_CMAKE=~/Android/Sdk/cmake/3.6.4111459/bin/cmake + export ANDROID_NATIVE_API_LEVEL=21 + export ANDROID_ABI=armeabi-v7a + export ANDROID_INSTALL_DIR=~/dbus-android-binaries + + +4. fetch and build expat +------------------------ + + mkdir src + cd src + git clone https://github.com/libexpat/libexpat.git + mkdir libexpat-android-build + cd libexpat-android-build + $ANDROID_CMAKE \ + -DANDROID_TOOLCHAIN=clang \ + -DANDROID_STANDALONE_TOOLCHAIN=$ANDROID_NDK \ + -DCMAKE_TOOLCHAIN_FILE=$ANDROID_NDK/build/cmake/android.toolchain.cmake \ + -DANDROID_NATIVE_API_LEVEL=$ANDROID_NATIVE_API_LEVEL \ + -DANDROID_ABI=$ANDROID_ABI \ + -DCMAKE_INSTALL_PREFIX=/data/local/tmp/dbus \ + ../libexpat/expat + make + make install DESTDIR=$ANDROID_INSTALL_DIR + cd .. + + +5. fetch and build dbus +------------------------ + + git clone git://anongit.freedesktop.org/git/dbus/dbus + mkdir dbus-android-buil + cd dbus-android-build + + $ANDROID_CMAKE \ + -DANDROID_TOOLCHAIN=clang \ + -DANDROID_STANDALONE_TOOLCHAIN=$ANDROID_NDK \ + -DCMAKE_TOOLCHAIN_FILE=$ANDROID_NDK/build/cmake/android.toolchain.cmake \ + -DANDROID_NATIVE_API_LEVEL=$ANDROID_NATIVE_API_LEVEL \ + -DANDROID_ABI=$ANDROID_ABI \ + -DDBUS_ENABLE_XML_DOCS=OFF \ + -DEXPAT_INCLUDE_DIR=$ANDROID_INSTALL_DIR/data/local/tmp/dbus/include \ + -DEXPAT_LIBRARY=$ANDROID_INSTALL_DIR/data/local/tmp/dbus/lib/libexpat.so \ + -DCMAKE_INSTALL_PREFIX=/data/local/tmp/dbus \ + ../dbus/cmake + make + make install DESTDIR=$ANDROID_INSTALL_DIR + + +6. install dbus on android device +--------------------------------- + + adb push $ANDROID_INSTALL_DIR/data /data + + +7. start dbus daemon +-------------------- + + adb shell + cd /data/local/tmp/dbus/ + export LD_LIBRARY_PATH=$PWD/lib + bin/dbus-daemon --config-file=share/dbus-1/session.conf --print-address + + +8. start client +---------------- + +You need to set the environment variable DBUS_SESSION_BUS_ADDRESS which +is displayed at topic 7 before been able to run any client app + + DBUS_SESSION_BUS_ADDRESS=xxx bin/dbus-monitor + + +9. Run complete session +----------------------- + +To run a complete dbus session you can use the following commands: + + adb shell + cd /data/local/tmp/dbus/ + export LD_LIBRARY_PATH=$PWD/lib + bin/dbus-run-session -- + +In case should be an application installed by an apk file you may run + + adb shell + cd /data/local/tmp/dbus/ + export LD_LIBRARY_PATH=$PWD/lib + bin/dbus-run-session -- monkey -p -c android.intent.category.LAUNCHER 1 + +where identifies the related application and is something like 'com.example.myapp'. +For an installed package it could be fetched from the install database with + + aapt dump badging |awk -F" " '/package/ {print $2}'|awk -F"'" '/name=/ {print $2}') + +with = 'myapp' diff --git a/cmake/tools/CMakeLists.txt b/cmake/tools/CMakeLists.txt index c05ced43..b687afea 100644 --- a/cmake/tools/CMakeLists.txt +++ b/cmake/tools/CMakeLists.txt @@ -54,6 +54,10 @@ set (dbus_cleanup_sockets_SOURCES ../../tools/dbus-cleanup-sockets.c ) +set (dbus_run_session_SOURCES + ../../tools/dbus-run-session.c +) + add_executable(dbus-send ${dbus_send_SOURCES}) target_link_libraries(dbus-send ${DBUS_LIBRARIES}) install(TARGETS dbus-send ${INSTALL_TARGETS_DEFAULT_ARGS}) @@ -86,5 +90,11 @@ add_executable(dbus-monitor ${dbus_monitor_SOURCES}) target_link_libraries(dbus-monitor ${DBUS_LIBRARIES}) install(TARGETS dbus-monitor ${INSTALL_TARGETS_DEFAULT_ARGS}) +if(NOT WIN32) + add_executable(dbus-run-session ${dbus_run_session_SOURCES}) + target_link_libraries(dbus-run-session ${DBUS_LIBRARIES}) + install(TARGETS dbus-run-session ${INSTALL_TARGETS_DEFAULT_ARGS}) +endif() + # create the /var/lib/dbus directory for dbus-uuidgen install(DIRECTORY DESTINATION var/lib/dbus) -- 2.12.3