android-binder

Android Binder clearing caller identity

折月煮酒 提交于 2019-12-06 04:27:59
问题 Recently I read Android source codes and find that a pair of methods are always called when doing some Binder IPC call. I read the comment, but I can't clearly know the root reason. The pair of method is as follow: final long origId = Binder.clearCallingIdentity(); //other local method. Binder.restoreCallingIdentity(origId); Does anyone know what's the function of that pair of method? It seems to relate to permission. 回答1: I don't think I can answer better than the description in the official

Bundle inside Intent from Native cpp application using Binder

瘦欲@ 提交于 2019-12-05 01:39:44
I'm trying to call an intent from native cpp code. Basically, from what i've understand, i have to compose a Parcel to match the exact deserialization sequence from frameworks/base/core/java/android/app/ActivityManagerNative.java ; case BROADCAST_INTENT_TRANSACTION. The progress so far is that i've received the intent in a Java app, but i have some problem with the bundle payload. I've debugged the Java app and it seems that it reads garbage as an int instead of reading the int which holds the type for the keys of the bundle. W/System.err( 1386): java.lang.RuntimeException: Parcel android.os

Android Binder clearing caller identity

不问归期 提交于 2019-12-04 07:48:05
Recently I read Android source codes and find that a pair of methods are always called when doing some Binder IPC call. I read the comment, but I can't clearly know the root reason. The pair of method is as follow: final long origId = Binder.clearCallingIdentity(); //other local method. Binder.restoreCallingIdentity(origId); Does anyone know what's the function of that pair of method? It seems to relate to permission. I don't think I can answer better than the description in the official APIs: http://developer.android.com/reference/android/os/Binder.html public static final long

How to listen to dev/binder?

為{幸葍}努か 提交于 2019-12-03 12:31:41
In Android is dev/binder also for layers communication responsible. Is it possible to listen to messages? I know that they must be decoded than, but how can I get this messages. For example if an app send a message to became an Geolocation. I have also root on my android device. Short: Nope, it shouldn't be possible, even with root. There isn't that much informations about Binder in detail on the net but there are some, especially about the security. Refer to this or to point 3.8 here . You may also read the source of the kernel driver and the source of openbinder . You can decode most of the

Android Local Service Sample, bindservice(), and ServiceConnection()

痴心易碎 提交于 2019-11-30 23:18:02
I have a question which is related to this question that was asked by @mnish about a year ago. Please have a look at his question and code. He implements a ServiceConnection() and passes it to bindService(). This follows the Local Service Sample in the Service documentation near the top. I want to implement the Local Service Sample, so I am trying to add some details from @mnish question/answer. In ServiceConnection() @mnish has this line that confuses me: mService = ILocService.Stub.asInterface(iservice); I understand @mnish wrote this code, but does anybody have any idea what ILocService is

Sharing file descriptor using Android binder

99封情书 提交于 2019-11-30 17:40:43
问题 How can I share file descriptor across process using Android binder IPC in C++? Can you post example also? 回答1: In client process we do the following to perform a binder transaction remote()->transact(MYTRANSACTION, data, &reply, IBinder::FLAG_ONEWAY); data and reply are of type Parcel. marshall and unmarshalling is done in native android using Parcel objects. It has the functionality to marshall a file descriptor. data.writeFileDescriptor(fd); In server process (i.e, Service in android), we

Binder preventing garbage collection

一笑奈何 提交于 2019-11-30 15:05:46
I think I tracked down a memory leak and want to confirm what I think may true about how Android's Binder is implemented. In this case I have a Service and an Activity, each in their own process. I created an AIDL that allows me to pass a Callback object from the Activity to the Service through an ipc method and then have the callback called when the Service is done with the requested task. For a long time I was wondering: if I pass a new Callback object to the Service and I don't keep a pointer to the Callback object in my Activity why doesn't the garbage collector just go ahead and collect

Transfer InputStream to another Service (across process boundaries) with ParcelFileDescriptor.createPipe() failes with “EBADF (Bad file number)”

痞子三分冷 提交于 2019-11-30 10:41:30
问题 I want to "send" an InputStream from one Android Service to another service running within a different process by using ParcelFileDescriptor.createPipe(), a stream-to-stream copy thread and a ParcelFileDescriptor, representing the read side of the pipe, which is given to the other service with means of Binder IPC. Sending Code (Process A) I want to send a given InputStream to the receiving service: public sendInputStream() { InputStream is = ...; // that's the stream for process/service B

How to Create a android native service and use binder to communicate with it?

心已入冬 提交于 2019-11-29 23:19:05
My basic task is to create a native service in android and then write a simple native program to test it. lets say i want to write a simple service which return me sum of 2 integers. I have to use binders to talk to it from the program, I have tried to google around but i cant find a precise example. I need to know how to create a native service and find it in the program and if needed in Java also. If you're creating a normal Android application using the NDK, you can't use Binder because it's not part of the NDK APIs. Look in the NDK docs/STABLE-APIS.html for the full list of stable APIs,

Transfer InputStream to another Service (across process boundaries) with ParcelFileDescriptor.createPipe() failes with “EBADF (Bad file number)”

吃可爱长大的小学妹 提交于 2019-11-29 21:57:14
I want to "send" an InputStream from one Android Service to another service running within a different process by using ParcelFileDescriptor.createPipe() , a stream-to-stream copy thread and a ParcelFileDescriptor, representing the read side of the pipe, which is given to the other service with means of Binder IPC. Sending Code (Process A) I want to send a given InputStream to the receiving service: public sendInputStream() { InputStream is = ...; // that's the stream for process/service B ParcelFileDescriptor pdf = ParcelFileDescriptorUtil.pipeFrom(is); inputStreamService.inputStream(pdf); }