This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

how to run the sample dsp applications in android??

Other Parts Discussed in Thread: OMAPL138

i want to write a jni wrapper for the dsp samples for omapl138 module in BB to use in an android app eg: message_multi which has lot of dependencies to add in the android.mk so i need a library for the applicaton. Can any one guide me on how to go about this??? Been trying for quite sometime........

  • Xavier;

    I going to try to explain in general way what could be the answer, the correct answer could depend in what Android file system you are working on, some features like Platform Library sample code was added until ICS, it was not in GB you could need to check it in your baseline, and I have some time without reading TI Android DevKit and the same some things could change depending on your actual release.

    1. the basic .so file can be created using the Android NDK samples (http://developer.android.com/tools/sdk/ndk/index.html), between this samples

    hello-jni -this sample allows to create a .so (./android-ndk/samples/hello-jni/jni/hello-jni.c) in native code that is used by a .apk (./android-ndk/samples/hello-jni/src/com/example/hellojni/HelloJni.java) that is configured/compiled by creating a new project using Android SDK+ Eclipse (one of the options) and selecting using existing code as example, this will add corresponding Android.mk to create the .apk, it is compiled and uploaded to the device using adb tools, for the .so it uses Android NDK tools, you can find information about this in ./android-ndk/documentation.html this document contains information about configuring $NDK export to point the NDK directory and how to use ndk_build script.

    you can define if it is shared or static library to create between other options,

    include $(BUILD_SHARED_LIBRARY)

    sample code for .apk contains code to load the library and how to access its functions.

    You can create C or C++ using Android NDK, this one contains some predefined permissions like OpenGL or OpenMax AL, you can find more information in ./android-ndk/docs/STABLE-APIS.html, this api's contains permissions to access HW modules if required.

    If you require to use a dlopen you will need to declare -ldl and use #include <dlfcn.h>, some examples can be found in next locations

    ./android-ndk/samples/san-angeles

    ./android-ndk/samples/two-libs

    ./android-ndk/tests/device/whole-static-libs/jni

    ./mydroid/development/samples/SimpleJNI/jni

    you can find some more samples either in Android NDK/SDK or AFS.

    Other options is to use a Platform Library that is used inside Android system until I have checked to access some HW features or to provide a correct permissions or to propagate permissions from .apk to .so or .jar.

    for this .so library sample code is located in

    /mydroid/device/sample/frameworks/PlatformLibrary

    and code for .apk is located in

    ./mydroid/device/sample/apps/client

    both in Android source code downloaded or contained in the compressed package for TI Android DevKit, it must be for ICS package for sure.

    the particularity for this library is that it uses a .xml file to grant the permissions, you can read more about it in the README.txt in referred folders. This code is added to AFS under frameworks/base and compiled as part of the system.

    [Next example is provided for OMAP platform, but it must be applicable to RowBoat-TI Android DevKit too]

    One example that I know of this use is GB in p-gingerbread branch

    http://git.omapzoom.org/?p=platform/frameworks/base.git;a=tree;f=omapmmlib;h=cd974f1b96bfd2e0dbe279dd0702d2569cc59415;hb=refs/heads/p-gingerbread

    and it is used by VideoView object to access HW,

    http://git.omapzoom.org/?p=platform/frameworks/base.git;a=blob;f=core/java/android/widget/VideoView.java;h=49b775500a7589f601ec14aec73b24448e877050;hb=refs/heads/p-gingerbread

    The issue is that it cannot be called from .apk since it doesn't have correct permission, that needs to be correctly set from existing permission in order to HW.

    If the HW you are trying to access has already defined permission then you only need to define them in your AndroidManifest.xml in order to propagate/use them.

    In other case I haven't go into that part, but for what I have read in

    http://source.android.com/tech/security/index.html

    and comments in http://e2e.ti.com/support/embedded/android/f/509/p/88028/697402.aspx#697402

    Those permission needs to exist to access HW from .apk, in other cases Android.com in developers area provides information in how to proceed, this mentions about creating a system service and what features can be used to access this service from standard .apk or native code, what could be missing is the part of creating new permissions to access HW area, matter to check it.

    http://developer.android.com/guide/topics/fundamentals/bound-services.html

    http://developer.android.com/guide/topics/fundamentals/bound-services.html#Binder

    http://developer.android.com/guide/developing/tools/aidl.html

    http://developer.android.com/guide/topics/fundamentals/services.html

    Main idea is to add your service to AFS this to initiate it with root permissions and correct permissions, then a client can connect to this services and use them with only declaring correct permissions.

    It worth to create the library and try to access the HW adding existing HW permission to AndroidManifest.xml, if you are developing a device and plan to add your own services then you have more options to use, either way a .apk can create a service but it could require to check permissions. In order to know if it is a permissions error you can try running with root user using and adb shell am, read about am command for full options, it could depend on Android release.

  • Hi,

    Thanks for your reply :)

    Sorry if i posted the question without much info. The things you have described above, i have tried them, for example say, the "hello-jni", i can build that in ndk and include the library in the java file and run the same and it works as expected. I even can control an LED in the BeagleBoard from the android app using the system calls which is written in C, built in ndk and the added the library in the application, which is ultimately used for LED toggle.

    What i am trying to do now is, as i can execute the dsp samples from linux command prompt, i need to execute the samples from my android app as in case of the  LED toggle. But since the dsp samples have too much dependencies, when i try to run the same in my ndk, i get unreferenced variable and functions and errors, though they are included. As i said i am trying to run the dsp samples through my android app.................. in which i am not successful yet :( ......and thanks for your effort so much :)

  • I can think in next 3 posibilities:

    1. You need to divide the project first in a native application that allows you to isolate if code works at this level and delta is between native and Android layer. then it is just to define proper library interfaces and compile it as a library, then check it in your .apk.

    2. Are you doing a wrapper for the message_multi application? in this case dependencies will be only limited to variable definitions and other values, what if makefile .mk is not correct using correct paths will fail the same.

    3. You are trying to duplicate message_multi behavior in your own code? one thing that could affect is where are you defining include directories or the path they follow, plus how it is being compiled. I can think that probably trying to compile the library in the same folder as message_multi just to check that dependencies are ok? then try to move it to another folder, and the same first a native binary then moving it to  a library. Try to compare .mk files or makefiles just to check if you didn't missed anything, remember that Android handles some global variables. Kernel is separated from Android FS.