Account Options

  1. Sign in
The old Google Groups will be going away soon, but your browser is incompatible with the new version.
Google Groups Home
« Groups Home
calling Android remote services from C++
There are currently too many topics in this group that display first. To make this topic appear first, remove this option from another topic.
There was an error processing your request. Please try again.
flag
  13 messages - Collapse all  -  Translate all to Translated (View all originals)
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
Brad Justice  
View profile  
 More options Nov 18 2011, 3:41 pm
From: Brad Justice <bradleypjust...@gmail.com>
Date: Fri, 18 Nov 2011 12:41:28 -0800 (PST)
Local: Fri, Nov 18 2011 3:41 pm
Subject: calling Android remote services from C++
As part of a porting project I would like to call an Android remote
service from c++. I found some example code here:
http://www.androidenea.com/2010/03/share-memory-using-ashmem-and-bind...
- though I have not been able to build it. I found numerous code
examples by downloading Android source and have focused my attention
on the code in frameworks/base/libs.

Using this code as an example, I have coded an implementation that
makes use of resources not exposed in the standard NDK SYSROOT,
primarily binder (using binder.h). This code compiles, but I am
struggling with linkage.

I have an issue with Lunch, so I cannot currently build the Android
sources. As an alternative, I have pulled /system/lib from a 3.1 AVD
(my target platform) and am linking against those libraries along with
those in SYSROOT. At this point I have two unresolved references, both
from the Android shared libraries:

home/parallels/jack/android_3.1_libs/libutils.so: undefined reference
to `pread64'
/home/parallels/jack/android_3.1_libs/libcutils.so: undefined
reference to `__system_property_set'
collect2: ld returned 1 exit status
make: *** [/media/JACKUBUNTU/eclipse_workspace/SemaphoreClientC/obj/
local/armeabi/SemaphoreClientC++] Error 1

libutils and libcutils are required by libbinder. I have tried various
corrections, including adding -lc to the library list.

First - being new to Android - I am hoping for a sanity check that
there is not some simpler way to achieve my goal of calling remote
services from c++. Failing that, perhaps someone could assist me in
resolving my linkage problem.

Thanking all in advance,

Brad

My Android.mk
-------------------

LOCAL_PATH := $(call my-dir)
include $(CLEAR_VARS)
LOCAL_MODULE := SemaphoreClientC++

LOCAL_SRC_FILES :=      \
        SemaphoreClientC++.cpp \
        SemaphoreClient.cpp \
        ISemServerInterface.cpp

LOCAL_LDLIBS := \
        -L/home/parallels/jack/android_3.1_libs \
        -lbinder \
        -lcutils \
        -lutils \
        -llog

include $(BUILD_EXECUTABLE)

My Application.mk
------------------------

APP_ABI := armeabi
APP_PROJECT_PATH := /home/parallels/jack/eclipse_workspace/
SemaphoreClientC
APP_CFLAGS := --sysroot=/home/parallels/android-ndk-r6b/platforms/
android-9/arch-arm -v -g -I/home/parallels/WORKING_DIRECTORY/system/
core/include -I/home/parallels/WORKING_DIRECTORY/frameworks/base/
include


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
David Turner  
View profile  
 More options Nov 20 2011, 8:31 am
From: David Turner <di...@android.com>
Date: Sun, 20 Nov 2011 14:31:37 +0100
Local: Sun, Nov 20 2011 8:31 am
Subject: Re: calling Android remote services from C++

Neither of libcutils, libutils, libbinder are exposed by the NDK, which
means that applications should never link against them.
Because they are not exposed, their implementation can heavily be modified
between platform releases. This probably explain why you have a linking
problem.

I'm sorry but applications should never use the Binder from native code,
its binary interface is (intentionally) not stable to allow this.

Whatever hacks you may find on the internet, they are just that: fragile
hacks that will break (or are already broken) in the future without notice.

On Fri, Nov 18, 2011 at 9:41 PM, Brad Justice <bradleypjust...@gmail.com>wrote:


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Brad Justice  
View profile  
 More options Nov 21 2011, 10:43 am
From: Brad Justice <bradleypjust...@gmail.com>
Date: Mon, 21 Nov 2011 07:43:49 -0800 (PST)
Local: Mon, Nov 21 2011 10:43 am
Subject: Re: calling Android remote services from C++
So what is the recommended way to call a remote service from a C or C+
+ executable? I still need to accomplish this goal.

On Nov 20, 5:31 am, David Turner <di...@android.com> wrote:


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
David Turner  
View profile  
 More options Nov 21 2011, 10:46 am
From: David Turner <di...@android.com>
Date: Mon, 21 Nov 2011 16:46:47 +0100
Local: Mon, Nov 21 2011 10:46 am
Subject: Re: calling Android remote services from C++

On Mon, Nov 21, 2011 at 4:43 PM, Brad Justice <bradleypjust...@gmail.com>wrote:


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Luiz Valdetaro  
View profile  
 More options Nov 21 2011, 12:07 pm
From: Luiz Valdetaro <lcvaldet...@gmail.com>
Date: Mon, 21 Nov 2011 11:07:28 -0600
Local: Mon, Nov 21 2011 12:07 pm
Subject: Re: calling Android remote services from C++

My guess is to call java from your c++ code; however that java method is
static... so then the question becomes, how to call an android rpc from a
static method?

On Nov 21, 2011 9:46 AM, "David Turner" <di...@android.com> wrote:

bradleypjust...@gmail.com>wrote:

Groups "android-ndk" group.
>> To post to this group, send email to android-ndk@googlegroups.com.
>> To unsubscribe from this group, send email to

android-ndk+unsubscribe@googlegroups.com.
>> For more options, visit this group at

http://groups.google.com/group/android-ndk?hl=en.

> --
> You received this message because you are subscribed to the Google Groups

"android-ndk" group.
> To post to this group, send email to android-ndk@googlegroups.com.
> To unsubscribe from this group, send email to

android-ndk+unsubscribe@googlegroups.com.
> For more options, visit this group at

http://groups.google.com/group/android-ndk?hl=en.

 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Brad Justice  
View profile  
 More options Nov 21 2011, 2:54 pm
From: Brad Justice <bradleypjust...@gmail.com>
Date: Mon, 21 Nov 2011 11:54:58 -0800 (PST)
Local: Mon, Nov 21 2011 2:54 pm
Subject: Re: calling Android remote services from C++
In addition, I need access to ashmem to share data between processes.
The Android MemoryFile class is not suitable as I need to access the
data in situ - copying the data will result in an unacceptable
performance penalty. Up till this point I have been assuming that I
could follow the recommendations in this post in android-platform:

>Dave Sparks
>     More options Feb 24 2009, 7:14 pm
>For security reasons, you cannot access shared memory by name. You
>pass a file descriptor through the binder interface. See the IMemory
>implementations for examples of how ashmem is used.

Is it possible to follow this recommendation without breaking the rule
regarding use of the Binder interface from NDK code? Has anyone out
there successfully implemented shared memory?

Thanks in advance,

Brad


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Adrian Taylor  
View profile  
 More options Nov 21 2011, 3:14 pm
From: Adrian Taylor <adrian.tay...@realvnc.com>
Date: Mon, 21 Nov 2011 20:14:42 +0000
Local: Mon, Nov 21 2011 3:14 pm
Subject: Re: calling Android remote services from C++

On 21 Nov 2011, at 19:54, Brad Justice wrote:

>> Dave Sparks
>>         More options Feb 24 2009, 7:14 pm
>> For security reasons, you cannot access shared memory by name. You
>> pass a file descriptor through the binder interface. See the IMemory
>> implementations for examples of how ashmem is used.

> Is it possible to follow this recommendation without breaking the rule
> regarding use of the Binder interface from NDK code? Has anyone out
> there successfully implemented shared memory?

I *think* you can do it without breaking the rules, but you'll have to do the IPC in Java:

-- Use 'ashmem' to create a shared memory area
-- Create an .aidl interface which passes a ParcelFileDescriptor
-- Implement the .aidl interface in Java rather than C++.
-- Pass in the ashmem FD
-- Retrieve the numeric FD from the ParcelFileDescriptor, and use mmap to access it from the other process.

Before API level 13, you'll need to write your own Java marshalling and unmarshalling code and use Binder.writeFileDescriptor, instead of using aidl and ParcelFileDescriptor.

Cheers

Adrian


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Luiz Valdetaro  
View profile  
 More options Nov 21 2011, 4:08 pm
From: Luiz Valdetaro <lcvaldet...@gmail.com>
Date: Mon, 21 Nov 2011 15:08:10 -0600
Local: Mon, Nov 21 2011 4:08 pm
Subject: Re: calling Android remote services from C++

I don't think it is possible to use shared memory in java
On Nov 21, 2011 1:55 PM, "Brad Justice" <bradleypjust...@gmail.com> wrote:


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Luiz Valdetaro  
View profile  
 More options Nov 21 2011, 4:09 pm
From: Luiz Valdetaro <lcvaldet...@gmail.com>
Date: Mon, 21 Nov 2011 15:09:44 -0600
Local: Mon, Nov 21 2011 4:09 pm
Subject: Re: calling Android remote services from C++

How to call an rpc service from a static method?
On Nov 21, 2011 2:14 PM, "Adrian Taylor" <adrian.tay...@realvnc.com> wrote:


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Brad Justice  
View profile  
 More options Dec 7 2011, 7:50 pm
From: Brad Justice <bradleypjust...@gmail.com>
Date: Wed, 7 Dec 2011 16:50:43 -0800 (PST)
Local: Wed, Dec 7 2011 7:50 pm
Subject: Re: calling Android remote services from C++
I have coded a solution for calling a remote service from native code.
In a nutshell, you create an intermediate Java object that binds to
the remote service via AIDL. It publishes an interface that maps into
the remote service methods you wish to call. The native code
instantiates the object and then calls through this object to invoke
the remote methods.

I have a test app that seems to be working well using this method.

I have published some detail here: http://interprocess-android.blogspot.com/
and plan to follow up with more detail shortly.

As I have mentioned previously, I am new to Android so comments and
advice are appreciated.


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Emeric Vigier  
View profile  
 More options Aug 28 2012, 10:33 am
From: Emeric Vigier <emeric.vig...@gmail.com>
Date: Tue, 28 Aug 2012 07:33:35 -0700 (PDT)
Local: Tues, Aug 28 2012 10:33 am
Subject: Re: calling Android remote services from C++

Bradley, your work is very inspiring.
I spent a week on making JNI remote calls work both ways: java calling
native, and native calling java.
I am most grateful to Jurij Smakov for his fully explained JNI example<http://android.wooyd.org/JNIExample/>.
But JNI's GetObject, GetField, NewObject, CallMethod, and method signatures
are really painful to deal with. I have hundreds of functions to export
this way... I need to define an abstraction layer based on JNI to make
message and signal sending (Java/Native) easier. Do you have any idea how
to abstract that easily?


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Brad Justice  
View profile  
 More options Sep 5 2012, 11:05 am
From: Brad Justice <bradleypjust...@gmail.com>
Date: Wed, 5 Sep 2012 08:05:17 -0700 (PDT)
Local: Wed, Sep 5 2012 11:05 am
Subject: Re: calling Android remote services from C++

I am afraid that I have no recommendations for you - I have yet to work on
a project where the number of calls made the standard "brute force"
approach impractical. There may be others on this forum who are familiar
with tools to automate the process.

You could build a generic call gate that passed a data blob from which you
extract details of the call and parameters yourself, though I am
unconvinced it would make the job easier.


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
John Rusnak  
View profile  
 More options Oct 23 2012, 9:50 pm
From: John Rusnak <jrusna...@gmail.com>
Date: Tue, 23 Oct 2012 18:50:10 -0700 (PDT)
Local: Tues, Oct 23 2012 9:50 pm
Subject: Re: calling Android remote services from C++

Domain sockets are a great way to share data between processes and are
supported in native and Java (android.network).  

John R


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
End of messages
« Back to Discussions « Newer topic     Older topic »