lauchActivity

AMS端向目标进程发送目标Activity的数据:

frameworks/base/core/java/android/app/ApplicationThreadative.java

scheduleLaunchActivity(...) {

    Parcel data = Parcel.obtain();

    ...

    intent.writeToParcel(data, 0);

    data.writeStrongBinder(token);

    data.writeInt(ident);

    info.writeToParcel(data, 0);
    data.writeBundle(state);

    data.writeTypedList(pendingResults);

    data.writeTypedList(pendngNewIntents);

    data.writeInt(notResumed ? 1 : 0);

    data.writeInt(isForward ? 1 :0);

    mRemote.transact(SCHEDULE_LAUNCH_ACTIVITY_TRANSACTION, data, null, IBinder.FLAG_ONEWAY);

    data.recycle();

}

 

目标进程接收目标Activity的数据:

frameworks/base/core/java/android/app/ApplicationThreadative.java

public boolean onTransact(int code, Parcel data, Parcel reply, int flags)
    throws RemoteException {

    Intent intent = Intent.CREATOR.createFromParcel(data);
    IBinder b = data.readStrongBinder();
    int ident = data.readInt();
    ActivityInfo info = ActivityInfo.CREATOR.createFromParcel(data);
    Bundle state = data.readBundle();
    <ResultInfo> ri = data.createTypedArrayList(ResultInfo.CREATOR);
    <Intent> pi = data.createTypedArrayList(Intent.CREATOR);
    boolean notResumed = data.readInt() != 0;
    boolean isForward = data.readInt() != 0;
    scheduleLaunchActivity(intent, b, ident, info, state, ri, pi,notResumed, isForward);

    return true;

}

 

目标进程后续的处理:

1. 将加载目标Activity的请求增加到消息队列

frameworkds/base/core/java/android/app/ActivityThread.java

public final void scheduleLaunchActivity(Intent intent, IBinder token, int ident, ....) {

    ActivityClientRecord r = new ActivityClientRecord();

    r.token = token;

    r.ident = ident;

    r.intent = intent;

    r.activityInfo= info;

    r.state = state;

 

    r.pendingResuts = pendingResults;

    r.pendingIntents = pendingNewIntents;

    r.startsNotResumed = notResumed;

    r.isForward = isForward;

 

    queneOrSendMessage(H.LAUNCH_ACTIVITY, r);

}

 

2.从消息队列中取元素,处理Activity加载请求

frameworkds/base/core/java/android/app/ActivityThread.java

public void handleMessage(Message msg) {

    switch (msg.what) {

        case LAUNCH_ACTIVITY: {

            ActivityClientRecord r = (ActivityClientRecod)msg.obj;

            r.packageInfo= getPackageInfoNoCheck(r.activityInfo.applicationInfo);

            handleLaunchActivity(r, null);

        } break;

        ........

    }

}

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值