About binders

手写ASP.NET Core MVC框架:路由、绑定与渲染五步实现 MVC框架是Web开发的核心范式,其本质是HTTP请求在服务端的标准化处理流水线。理解其原理需从请求生命周期切入:路由解析定位资源、模型绑定转换数据、控制器激活协调逻辑、动作执行注入业务、结果渲染生成响应。这一过程高度依赖接口抽象(如IModelBinder、IActionResult)、依赖注入与中间件管道机制,技术价值在于解耦、可扩展与调试可控。典型应用场景包括高级后端面试准备、微服务网关定制、低代码平台内核构建及性能敏感型内部框架研发。本文聚焦.NET 6+环境,以零分配Span优化、RazorLig 阅读详情

From: http://mylifewithandroid.blogspot.com/2008/01/about-binders.html

 

I wanted to go back to my Bluetooth exercise once again but then I stumbled into this beautiful sample program from John Guilfoyle. I decided immediately that before playing again with that wicked Bluetooth service, I have to test-drive again the service framework and the low-level mechanisms behind it.

My Android experiences with services were so far restricted to repeating the sample program in the documentation. This time I wanted to try something more ambitious: connecting two applications through services. In order to do that, it is worth getting behind the facade of the Android service framework. This thread contains a lot of information that I try to recap here .

The workhorse of the Android IPC is the "IBinder class". As its name implies, android.os.IBinder is really an interface, implemented by the real worker objects, namely android.os.BinderNative and android.os.BinderProxy. The binder provides a simple functionality of synchronous method invocation. Calling the transact() method on the binder is able to transmit a function code, a java.os.Parcel instance and some flags. The result is returned in another Parcel instance. Look for this method signature:

public final boolean transact(int code, Parcel data, Parcel reply, int flags ) throws DeadObjectException;

The client calls the transact method and the other side of the binder, in the other side of the process separation will receive a callback.

protected boolean onTransact(int code, Parcel data, Parcel reply, int flags);
The IPC has a thread pool for each process and the onTransact method is invoked in the context of a thread in the IPC thread pool. Parcel is the abstraction of the data the IPC framework is able to serialize and deserialize, you can look at the documentation of the android.os.Parcel object to see, what data types are supported. The most interesting data type is the IBinder itself (readStrongBinder, writeStrongBinder) so it is possible to pass binder endpoints to another processes. The interface mechanism that the aidl tool provides is really simple after that. Aidl takes the interface description and turns it into Java code that serializes and deserializes invocation parameters and return values to and from Parcels. Take for example our trusty IAdderService which has a method with this signature:

int add( in int i1, in int i2 );

Aidl has to generate a code that serializes two integers into the request Parcel and deserializes the return integer from the response Parcel in transact() because this is the client side of the stub. In onTransact method, as it is the receiver side of the call, it has to deserialize the input parameters, invoke the service-side implementation of the method then serialize the result. And it does exactly that (excerpts from the IAdderService.java generated by the aidl tool):

public int add(int i1, int i2) throws android.os.DeadObjectException { android.os.Parcel _data = android.os.Parcel.obtain();
android.os.Parcel _reply = android.os.Parcel.obtain();

int _result;

try {

_data.writeInt(i1);

_data.writeInt(i2);

mRemote.transact(Stub.TRANSACTION_add, _data, _reply, 0);

_result = _reply.readInt();

}

...

public boolean onTransact(int code, android.os.Parcel data, android.os.Parcel reply, int flags) {
try {
switch (code)

{

case TRANSACTION_add:

{
int _arg0;
_arg0 = data.readInt();

int _arg1;

_arg1 = data.readInt();

int _result = this.add(_arg0, _arg1);

reply.writeInt(_result);
return true;
}

}

The service framework does not provide any means to find out, what is the serialization and deserialization stub on the client and the service side which I consider a drawback. This is a reason why it is impossible to discover the service interfaces (one can retrieve the client-side binder but not the interface stub, therefore it is impossible to know, how to talk to the service without knowing the interface stub from some other, independent source). The framework simply assumes that the client- and the server-side stubs match, if not, then it is the programmer's fault.

I was now ready to realize my dream to connect two applications by means of service invocations. The best way is, of course, Intent-based invocation but I wanted to work that around just for the sake of hacking. As Dianne Hackbod pointed out, however, Android application lifecycle makes the direct connection impossible. Depending on resource situation, Android apps just come and go and therefore the binders connecting them may stop functioning without any warning. One has to go through services because service dependencies are respected by the application manager. So I created the following simple application (actually, two applications and one service).

You can download the example program from here.

The task is to receive a callback from Application 2 (called SClientApp) by Application 1 (called HostappClient). The connection between the two applications goes through a service (HostappServiceImpl, co-located with HostappClient). Both applications bind this service in a usual way. In addition to that, HostappClient provides the HostappServiceImpl with a callback binder. Why binder, why not interface? It could be interface and it would be more elegant to do so. The Windows version of the aidl tool in the current version (m3-rc37a) has an annoying bug that makes the import statement almost unusable so there is no way to import our own interface classes. This is not a problem, however, if we know the relationship of binders and interfaces. We just pass the binder reference and apply the interface stubs onto it when the binder arrives. The call flow is the following:
  • HostappClient binds HostappServiceImpl. When the service binding callback arrives, we pass the binder of HostAppClient's ISetTextService to HostappServiceImpl.
  • Now HostappClient launches SClientApp as subActivity. The first thing SClientApp does is to bind HostAppServiceImpl. When the service is bound succesfully, SClientApp passes the hugely valuable text result to HostAppServiceImpl which in turn calls HostappClient's ISetTextService whose binder we have received previously.
  • One interesting bit remained: the use of android.os.Handler in HostappClient. When HostappClient receives the service callback, it cannot directly manipulate the UI, only the UI thread is allowed to do that. The service callback runs in an IPC thread, not the UI thread, therefore it uses a Handler instance to pass a Runnable to the UI thread which is then executed there (the Handler executes the Runnable in the context of the thread it was created in and our Handler instance was created in the context of the UI thread).

Huh, pretty complicated instead of returning that hugely important string in the intent invocation bundle? And that is not the end, because our example program is not perfect. It is not prepared for low-memory situations when each of our three players may be destroyed and resurrected by the application manager. The worst-case scenario is this:
  • HostappClient is launched and when it binds HostappServiceImpl, these two entities are in the memory.
  • When HostappClient makes an intent invocation to SClientApp, both HostappClient and HostappService may be destroyed by the application manager.
  • SClientApp now binds HostappServiceImpl and these two are in the memory now. The IBinder instance passed by HostappClient is now lost.
  • When SClientApp finishes, SClientApp and HostappServiceImpl may both be destroyed again. Our hugely valuable text data passed by SClientApp to HostappServiceImpl is lost then.
  • HostappClient is resurrected but it has nothing to receive from HostappServiceImpl.

serviceconnecthostapp

A robust implementation of HostappServiceImpl would store setMyText() invocations in a persistent storage, e.g. SQLite database if the callback to HostappClient fails (DeadObjectException or appService==null in HostappServiceImpl.setMyText). When the binder is set by HostappClient's invocation to setCallback(), HostappServiceImpl would check its storage and would immediately send back setMyText() callbacks to HostappClient from the persistent storage. This exercise is left, however, to the interested reader. :-)
ASP.NET MVC 1.0 Controller底层原理与实战避坑指南 Controller是ASP.NET MVC中处理HTTP请求的核心组件,其本质是一个遵循约定的、由框架反射调用的公共类实例。理解其工作原理需从路由匹配、Action方法发现、模型绑定(Model Binding)、ActionResult执行到视图定位的完整链路出发。其中,ValueProvider体系决定参数数据来源优先级,DefaultModelBinder负责将字符串值转换为强类型对象,而ActionResult抽象则保障了响应方式的可扩展性。这些机制共同支撑RESTful路由、表单提交、AJAX交 阅读详情

相关推荐

ASP.NET MVC生命周期详解:11个阶段执行顺序与实战调试

ASP.NET MVC生命周期是理解请求处理流程的核心技术概念,它定义了从URL路由匹配到视图渲染完成的完整执行链条。其本质是一套基于事件钩子(如OnActionExecuting、OnResultExecuted)和可插拔组件(Filter、ModelBinder、ViewEngine)的分阶段控制机制,核心原理在于各阶段严格有序、上下文隔离、对象生命周期明确。这一机制赋予开发者对请求流的精准干预能力,支撑统一日志、权限校验、模型绑定定制等关键工程实践。典型应用场景包括异常全局捕获、响应头动态注入、AJA

diaozhiwa5526的博客 506

Unity Android log view(Android Debug Bridge)

Android Debug Bridge

蛰伏--当你不够强大时,就不要放弃努力 4178

西周BC809年世界历史地图矢量文件SHP格式.zip

本资源为《西周BC809年世界历史地图矢量文件SHP格式》压缩包,文件大小约 24.49 MB,便于集中下载、整理和使用。具体内容请结合压缩包内的实际文件与说明查看。 在当前可读取的目录中,可见属性表(.dbf)、投影说明文件(.prj)、Shapefile 主文件(.shp)、Shapefile 索引(.shx)。建议解压后保持原有目录结构,先浏览文件清单与说明,再选择需要的资料进行加载或整理。 应用方面,可根据实际资料用于学习练习、资料检索、研究整理或项目参考。使用时可先确定所需内容,建立清晰的文件分类,再按项目要求进行筛选、转换与汇总。 使用 Shapefile 数据时,请把实际配套的 .shp、.shx、.dbf 等文件保存在同一目录,并保持同名关联;加载后再检查坐标系与中文字段显示。如需叠加其它数据,请先统一坐标与字段口径。 数据来源、时间范围、坐标系、字段定义、精度和使用条件,请以实际文件及原始说明为准。本介绍不对文件名之外尚未核实的信息作额外承诺。

【风力涡轮发电机】用于电磁暂态(EMT)研究的第四类(即全变流器)风力发电机系统的通用模型研究(Simulink仿真实现)

内容概要:本文研究了一种用于电磁暂态(EMT)仿真的第四类全变流器型风力发电机系统的通用化建模方法,并基于Simulink平台实现了该模型的仿真。该模型全面涵盖了风力机气动特性、传动系统动力学、发电机电气特性、全功率电力电子变流器及其核心控制策略,包括最大功率点跟踪(MPPT)、有功与无功功率解耦控制、电网同步控制等,旨在为高比例风电接入的现代电力系统提供一个高精度、高效率的动态仿真工具。研究重点在于构建能够准确反映全变流器风机在各类电网扰动下动态响应行为的综合性模型,以支撑复杂电网的暂态稳定性分析、并网适应性评估、保护与控制策略的验证。文中详细阐述了各子系统模块的数学建模原理、参数设计依据及模块间的耦合关系,并通过不同运行工况下的仿真结果,验证了所建模型的动态准确性和工程实用性。; 适合人群:具备电力系统分析、电力电子技术、自动控制理论及Matlab/Simulink仿真基础的研究生、高校科研人员以及从事新能源发电并网仿真、电力系统规划与运行的工程技术人员。; 使用场景及目标:①研究高渗透率风电对电网电磁暂态过程(如短路故障、电压跌落)的影响机制;②开发与验证适用于风电场的新型继电保护、低电压穿越(LVRT)及高电压穿越(HVRT)控制策略;③进行含大规模风电的电力系统小干扰与大干扰稳定性评估;④作为高等院校相关专业进行风力发电系统动态特性教学与科研的先进仿真案例。; 阅读建议:读者应结合Matlab/Simulink环境,亲手搭建并调试文中所述模型,尤其关注变流器双闭环(电流环、电压环)控制器的设计、参数整定及其与电网强度的交互影响,建议深入研读文中引用的经典文献以巩固对风电机组控制理论与实践的理解。

最新全国景区A-5A级景区数据集(更新至2025年)

最新全国景区A-5A级景区数据集(更新至2025年) A级景区分为A至5A不同级别,是国家对旅游景区质量等级的评级体系。旅游景区质量等级的标牌和证书由全国旅游景区质量等级评定机构统一规定,其中A级至3A级景区的评定工作由国家评定机构委托各省级旅游景区质量等级评定委员会负责。 4A级旅游景区由全国景区质量评定委员会直接评定。取得4A级资质满一年且符合申报条件的景区,可申请5A级评定。5A级旅游景区需经省级旅游景区质量等级评定委员会推荐,最终由全国旅游景区质量等级评定委员会组织评定。 数据整理全国A及至5A及各个景区的基本信息景区名称、等级、所属省份城市区县、坐标、地址以及评定时间等。截止2025年5月份全国31个省份最新A级景区数据。

西周BC980年世界历史地图矢量文件SHP格式.zip

本资源为《西周BC980年世界历史地图矢量文件SHP格式》压缩包,文件大小约 28.61 MB,便于集中下载、整理和使用。具体内容请结合压缩包内的实际文件与说明查看。 在当前可读取的目录中,可见属性表(.dbf)、投影说明文件(.prj)、Shapefile 主文件(.shp)、Shapefile 索引(.shx)。建议解压后保持原有目录结构,先浏览文件清单与说明,再选择需要的资料进行加载或整理。 应用方面,可根据实际资料用于学习练习、资料检索、研究整理或项目参考。使用时可先确定所需内容,建立清晰的文件分类,再按项目要求进行筛选、转换与汇总。 使用 Shapefile 数据时,请把实际配套的 .shp、.shx、.dbf 等文件保存在同一目录,并保持同名关联;加载后再检查坐标系与中文字段显示。如需叠加其它数据,请先统一坐标与字段口径。 数据来源、时间范围、坐标系、字段定义、精度和使用条件,请以实际文件及原始说明为准。本介绍不对文件名之外尚未核实的信息作额外承诺。

硬件原理图与PCB设计自查清单:48项检查+12个真实缺陷案例(Altium/立创EDA通用)

【使用方法】用 Excel 或 WPS 打开,先看「使用说明」页了解判定口径与模块划分,再在「自查清单」页逐项核对;结论列是下拉选项(通过 / 待核对 / 缺陷 / 不适用),选完「完成度统计」页会自动算出通过率,评审会上可以对着表逐条过。建议按设计阶段分开用:原理图评审只核对 S 模块 12 项,布局前核对 L 模块,发板前核对 R、K 模块,出 Gerber 前核对 M 模块,不必一次全填。【内容概要】48 项检查覆盖原理图设计、封装库、器件布局、布线、叠层与 EMC、输出与制造六个环节,每一项都写了合格判据和「怎么查」的动手方法,比如去耦要逐电源引脚核对、阻抗要按实际叠层算线宽、差分对要控间距与等长,不是只给一句空话。另附 12 条真实缺陷案例,覆盖电源冒烟、I2C 偶发 NACK、QFN 批量虚焊、差分阻抗失配、晶振不起振等典型问题,每条从现象写到根因、改法和验证方式,可以直接当新人培训素材。【适用人群】硬件工程师、PCB 设计初学者、做毕设和电赛的学生,以及负责设计评审把关的项目负责人;Altium Designer 与立创 EDA 都适用,个人打样和中小批量投产前的自查都能用。

西周BC940年世界历史地图矢量文件SHP格式.zip

本资源为《西周BC940年世界历史地图矢量文件SHP格式》压缩包,文件大小约 28.57 MB,便于集中下载、整理和使用。具体内容请结合压缩包内的实际文件与说明查看。 在当前可读取的目录中,可见属性表(.dbf)、投影说明文件(.prj)、Shapefile 主文件(.shp)、Shapefile 索引(.shx)。建议解压后保持原有目录结构,先浏览文件清单与说明,再选择需要的资料进行加载或整理。 应用方面,可根据实际资料用于学习练习、资料检索、研究整理或项目参考。使用时可先确定所需内容,建立清晰的文件分类,再按项目要求进行筛选、转换与汇总。 使用 Shapefile 数据时,请把实际配套的 .shp、.shx、.dbf 等文件保存在同一目录,并保持同名关联;加载后再检查坐标系与中文字段显示。如需叠加其它数据,请先统一坐标与字段口径。 数据来源、时间范围、坐标系、字段定义、精度和使用条件,请以实际文件及原始说明为准。本介绍不对文件名之外尚未核实的信息作额外承诺。

ORACLE驱动agent.exe

ORACLE驱动agent.exe

西周BC840年世界历史地图矢量文件SHP格式.zip

本资源为《西周BC840年世界历史地图矢量文件SHP格式》压缩包,文件大小约 24.46 MB,便于集中下载、整理和使用。具体内容请结合压缩包内的实际文件与说明查看。 在当前可读取的目录中,可见属性表(.dbf)、投影说明文件(.prj)、Shapefile 主文件(.shp)、Shapefile 索引(.shx)。建议解压后保持原有目录结构,先浏览文件清单与说明,再选择需要的资料进行加载或整理。 应用方面,可根据实际资料用于学习练习、资料检索、研究整理或项目参考。使用时可先确定所需内容,建立清晰的文件分类,再按项目要求进行筛选、转换与汇总。 使用 Shapefile 数据时,请把实际配套的 .shp、.shx、.dbf 等文件保存在同一目录,并保持同名关联;加载后再检查坐标系与中文字段显示。如需叠加其它数据,请先统一坐标与字段口径。 数据来源、时间范围、坐标系、字段定义、精度和使用条件,请以实际文件及原始说明为准。本介绍不对文件名之外尚未核实的信息作额外承诺。

智慧城市工程施工管理智能体理场景的设计与实施方案.docx

智慧城市工程施工管理智能体理场景的设计与实施方案.docx

智慧城市运行监测智能体理场景的设计与实施方案.docx

智慧城市运行监测智能体理场景的设计与实施方案.docx

数字医院医疗质量智能体理场景的设计与实施方案.docx

数字医院医疗质量智能体理场景的设计与实施方案.docx

智能体长期记忆与个性化偏好管理系统详细设计方案.docx

智能体长期记忆与个性化偏好管理系统详细设计方案.docx

市十五五银发经济产业园与智慧养老服务平台项目建设方案.docx

市十五五银发经济产业园与智慧养老服务平台项目建设方案.docx

智慧规划展览馆智能化及系统集成系统规划建设方案.docx

智慧规划展览馆智能化及系统集成系统规划建设方案.docx

智慧工业园区智能化及系统集成系统规划建设方案.docx

智慧工业园区智能化及系统集成系统规划建设方案.docx

URDF模型转换实战:解决SolidWorks到Gazebo的五大常见问题

本文详细解析了从SolidWorks导出URDF模型到Gazebo仿真过程中常见的五大问题及解决方案,包括插件安装、坐标系建立、Link与Joint配置等关键步骤。通过实战经验分享,帮助机器人仿真工程师高效完成模型转换,确保Gazebo仿真准确性。

weixin_29052717的博客 450
上一篇: Controlling application separation
下一篇: Android Network Resources
CodeJoker
博客等级 码龄18年 50粉丝 37原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

当前余额3.43元 前往充值 >
需支付:10.00元
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付元
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值
⌂ 换网址