问题标签 [android-binder]

For questions regarding programming in ECMAScript (JavaScript/JS) and its various dialects/implementations (excluding ActionScript). Note JavaScript is NOT the same as Java! Please include all relevant tags on your question; e.g., [node.js], [jquery], [json], [reactjs], [angular], [ember.js], [vue.js], [typescript], [svelte], etc.

0 投票
0 回答
1160 浏览

android - SecurityException:对错误接口的 Binder 调用

我在此代码上收到错误消息:“Binder 调用不正确的接口” :

错误出现在ibta.getConnectionState(device)

这就是我之前所做的:

这是我如何使用 .aidl 设置我的包的层次结构:

在此处输入图像描述

我做错了什么。我读了这个问题:SO-Question。但我不知道我做错了什么。

0 投票
1 回答
1424 浏览

android - 自 JellyBean 以来,libbinder 在哪里?

我在框架基础代码库中看到了 libbinder 代码/libs/binder。但是自从 jellybean 之后,libbinder 被移到了其他地方,我再也找不到它了。尽管如此,我仍然发现许多库引用它。我想知道它现在在哪里。

PS 4.04r2.1 中的 libbinder 代码可以在这里找到

0 投票
0 回答
692 浏览

android - 在 BroadcastReceiver 中确定 Intent 的来源

我正在寻找一种方法来确定哪个应用程序发送了Intent. 目前,我已经注册了 aBroadcastReceiver并一直在尝试使用Binder.getCallingPid,但它通常会返回我的应用程序的 PID。我觉得奇怪的是通常的部分,我的应用程序偶尔会获得发送Intent.

有没有办法准确确定哪个应用程序发起了呼叫BroadcastReceiver.onReceive

0 投票
1 回答
483 浏览

android - android系统如何管理连接到有界远程服务的客户端列表

我正在做一个项目,对android手机上的系统进行实时分析。我想知道在给定的时间点有多少客户端绑定到任何远程服务。

例如:绑定到 LocationManager 服务的客户端数量。

这将帮助我识别对系统服务施加压力的应用程序。此外,它还将帮助我识别它的系统服务是否写得不好,或者系统服务的客户端是否表现不佳。

例如:我发现当您不断查询/更新/删除联系人内容提供者时,系统显示 com.android.acore 正在消耗更多的 cpu,但实际上它是表现不佳的第三方应用程序。

我正在开发自定义 ROM,并且可以访问代码以进行任何修改。

我知道活页夹是引用计数的,并且每个引用活页夹的 BinderProxy 构成对该活页夹的引用。但我不确定它是如何在代码中完成的。

如果有人已经对此进行了一些研究,请分享您的知识。

0 投票
1 回答
397 浏览

android - Binder thread interrupt unexpected behavior

Android ContentProviders use a pool of "binder threads" to process RPCs such as query, insert and call. In my implementation of a ContentProvider I am performing a long running task that is interruptible using Thread#interrupt(). I wrote a watchdog thread that interrupts the currently executing binder thread under certain circumstances. The interrupt is correctly taking effect but now I noticed that binder thread still has its interrupt flag set when it is used again by android to handle a new RPC. This causes the new RPC to behave as if it was interrupted. I did not expect this. I catch InterruptedException but this can happen if the watchdog thread sets the interrupted flag towards the end of the RPC when there is nothing looking at or clearing the flag.

Some ad-hoc testing of ExecutorService indicates that when it is reusing threads to handle tasks it resets the interrupt flag sometime before running each task. I found this comment in the ThreadPoolExecutor class:

To correct android's behavior I am thinking that at the beginning of each ContentProvider RPC I clear the interrupt flag with Thread.interrupted() but that doesn't seem like the most elegant solution.

Can anyone confirm if android binder threads are in fact handling thread interrupts differently from an ExecutorService, and what might be the best work-around so the interrupt flag isn't propagated between different RPCs?

Here is some code that can be placed in a ContentProvider to reproduce the issue:

Then in an Activity (make sure it is running in a different process from the ContentProvider!) hook up two buttons, one that does a regular call and one that does a call which will trigger an interrupt:

0 投票
0 回答
39 浏览

android - contentprovidernative 的 bn 客户端是什么?

我在 contentproviderNative.java 中看到了源代码。有一个名为 openAssetFile() 的方法,并有一个名为 remote.transact() 的字段;我知道我应该找到该方法的 c++ 文件,但我应该阅读哪个 c++ 文件?

0 投票
1 回答
1471 浏览

android - android - 广播接收器 - 调用者验证

我正在编写一个 Android 应用程序,其中我需要接收系统发送的一些广播。我想确保广播确实是由系统发送的。我找到了这个 OWASP视频

在视频中的 18:00 时间,演讲者建议验证广播来源的方法之一是使用(查看他的幻灯片):

我试图在我的应用程序中对此进行测试,但是这个 API 为我提供了我自己的应用程序的 uid。

我从 Dianne Hackborn找到了这个解释:

此外,来自文档

鉴于这两种解释,Binder.getCallingUid在Android组件的生命周期事件中是否有任何使用的API(我在BroadcastReceiver的onReceive,Service的onStartCommand中测试过)?

如果没有,为什么 OWASP 要求我们使用它?

0 投票
0 回答
652 浏览

java - Android 失败的 Binder 事务解决方法

我需要一个可行的解决方法来解决这个问题。我使用安卓相机拍照。调用的方法称为 onPictureTaken。该程序应该从图片中获取字节数组,并将其传递回在另一个类中等待它的意图。

我的问题是我得到了Failed Binder Transaction错误。我知道这是因为数据太大。有没有可行的方法在发送之前对其进行压缩?

**注意,我知道我可以只制作和压缩位图,但用我的程序编写来发送实际字节数组的方式更可取。

下面的代码:

另外,我只在一些安卓设备上得到这个错误,例如我的 GS5 不会抛出这个错误,但我的 Moto X 会。有没有办法确保将要完成的压缩足以不会在设备上引发错误?

谢谢!

0 投票
0 回答
1173 浏览

java - Android - “服务列表”与“dumpsys 活动服务”

这些命令显示的服务之间有什么区别?如何从普通 Java 类启动服务并在“服务列表”中查看它,以便能够从另一个本机进程访问它以共享数据?

我在设备上运行了一个本机(C/C++ 代码)二进制文件,并希望它连接到以 java 启动的服务。我已经使用 binder 接口在两个不同的本机应用程序之间共享内容。但是有没有办法直接上java?(JNI可能不工作,因为二进制有其他权限,并且在Java-App启动时已经运行很久了。当应用程序启动服务时,本机代码将自动连接并开始发送数据。)

我有本机代码启动服务和 Java 部分连接到的代码。但在这种情况下,我无权在本机部分创建服务。但我可以连接到一个已经在运行的。

0 投票
2 回答
1542 浏览

android - Android Binder IPC addService:有没有办法再次删除服务?

我在代码中的某个地方,我只有非常有限的权限,但必须将数据发送到 android 应用程序之外。(Android系统C代码)显然我不能在那里启动一个binder服务,但我可以连接到一个已经运行的服务。因此,我的实现每秒检查服务是否可用,如果可用,它会连接并开始发送数据。这工作正常。

我的问题如下。如果我终止服务二进制/进程,客户端不知何故看不到该服务不再可用。有没有办法删除我添加的服务addService(...)?客户做getService()