Intent的实质是binder
Intent 的实质是binder,如下为代码流程。
常见场景:
Intent intent = newIntent(AudioManager.ACTION_AUDIO_BECOMING_NOISY);
mContext.
sendBroadcast
(intent);
ActivityManagerNative.java
public int
broadcastIntent
(IApplicationThread caller,
Intent intent, String resolvedType, IIntentReceiver resultTo,
intresultCode, String resultData, Bundle map,
String requiredPermission, int appOp, boolean serialized,
boolean sticky, int userId) throws RemoteException
{
mRemote.transact(
BROADCAST_INTENT_TRANSACTION
,data, reply, 0);
//
此处即为
binder
通信机制实现
ActivityManagerNative.java
public booleanonTransact(int code, Parcel data, Parcel reply, int flags)
case
BROADCAST_INTENT_TRANSACTION
:
{
data.enforceInterface(IActivityManager.descriptor);
IBinder b =data.readStrongBinder();
int res =
broadcastIntent
(app,intent, resolvedType, resultTo,
resultCode, resultData,resultExtras, perm, appOp,
serialized, sticky,userId);