为什么通过AIDL方式使用binder机制的时候如果Bn端函数比较耗时Bp端会ANR
2016-10-27 15:28
477 查看
分析:
看源码红色部分,第三个参数是0,而FLAG_ONEWAY = 0x00000001;(可以添加oneway来设置它)
private static class Proxy implements com.example.abc.ITest {
private android.os.IBinder mRemote;
.....................
@Override
public int add(int a, int b) throws android.os.RemoteException {
android.os.Parcel _data = android.os.Parcel.obtain();
android.os.Parcel _reply = android.os.Parcel.obtain();
int _result;
try {
_data.writeInterfaceToken(DESCRIPTOR);
_data.writeInt(a);
_data.writeInt(b);
mRemote.transact(Stub.TRANSACTION_add, _data, _reply, 0);
_reply.readException();
_result = _reply.readInt();
} finally {
_reply.recycle();
_data.recycle();
}
return _result;
}
}
static final int TRANSACTION_add = (android.os.IBinder.FIRST_CALL_TRANSACTION + 0);
}
看源码红色部分,第三个参数是0,而FLAG_ONEWAY = 0x00000001;(可以添加oneway来设置它)
private static class Proxy implements com.example.abc.ITest {
private android.os.IBinder mRemote;
.....................
@Override
public int add(int a, int b) throws android.os.RemoteException {
android.os.Parcel _data = android.os.Parcel.obtain();
android.os.Parcel _reply = android.os.Parcel.obtain();
int _result;
try {
_data.writeInterfaceToken(DESCRIPTOR);
_data.writeInt(a);
_data.writeInt(b);
mRemote.transact(Stub.TRANSACTION_add, _data, _reply, 0);
_reply.readException();
_result = _reply.readInt();
} finally {
_reply.recycle();
_data.recycle();
}
return _result;
}
}
static final int TRANSACTION_add = (android.os.IBinder.FIRST_CALL_TRANSACTION + 0);
}
相关文章推荐
- 通过AIDL及反射机制,使用隐藏API挂断电话
- java同步机制对象锁使用方式比较
- 为什么在定义能够使用函数适配器的函数的时候要继承一下std::unary_function或者std::binary_function
- 通过 AIDL 分析 Binder 的工作机制
- CentOS7安装Hadoop,比较有效的方式,虽然也除了点小问题,但如果仔细按教程走.应该一次通过的
- 通过AIDL及反射机制,使用隐藏API挂断电话
- 使用AIDL分析Binder的工作机制
- 为什么在训练神经网络时候比较适合使用交叉熵错误率,而不是分类错误率或是均方差
- c++ 提高4 map容器 共性机制 使用时机 比较| STL算法 算法基础仿函数 谓词 函数适配器 遍历算法
- Tensorflow使用技巧:通过graph.as_graph_def探索函数内部机制
- 使用ODBC方式读取sybase数据库的时候,如果字符串大于4k(4096),结果只能读取到4096个字符(关键字 SYBASE TEXT 4096 截断 TRUNCATE)
- Android中Binder机制理解及AIDL使用基本步骤
- 启动网页时候自动加载servlet如果不使用strus最常用的两种方式
- 基础篇-Binder机制和AIDL使用介绍
- 通过AIDL及反射机制,使用隐藏API挂断电话
- 通过调用C语言的库函数与在C代码中使用内联汇编两种方式来使用同一个系统调用来分析系统调用的工作机制
- 为什么在C++使用pthread_create()的时候,类成员函数做线程的处理函数必须要定义成static类型的?
- 创建存储过程,以部门编号为参数返回该部门的人数及平均工资(返回一个值可以通过函数来实现,但如果要返回多个值,需要使用out或in out模式参数实现)
- 为什么在C++使用pthread_create()的时候,类成员函数做线程的处理函数必须要定义成static类型的?
- AIDL使用和Binder机制详解