Android USAP 历程启动流程

藏宝库编辑 2024-9-13 14:39:42 191 0 来自 中国
从Android Q(10)开始,Google引入了一种新的机制,加快了app的启动时间,具体请看Android Framework | 一种新型的应用启动机制:USAP,本篇将会具体先容USAP 历程启动的流程。
从Activity启动流程 上篇(Android 10),我们得知在Activity启动过程中,我们会调用到\frameworks\base\core\java\android\os\ZygoteProcess.java的start方法,然后调用startViaZygote(),着实在调用startViaZygote()之前尚有一步:
    public final Process.ProcessStartResult start(@NonNull final String processClass,                                                  final String niceName,                                                  int uid, int gid, @Nullable int[] gids,                                                  int runtimeFlags, int mountExternal,                                                  int targetSdkVersion,                                                  @Nullable String seInfo,                                                  @NonNull String abi,                                                  @Nullable String instructionSet,                                                  @Nullable String appDataDir,                                                  @Nullable String invokeWith,                                                  @Nullable String packageName,                                                  boolean useUsapPool,                                                  @Nullable String[] zygoteArgs) {        // TODO (chriswailes): Is there a better place to check this value?        //---------------------------- 就是这里 ----------------------------        if (fetchUsapPoolEnabledPropWithMinInterval()) {            informZygotesOfUsapPoolStatus();        }        try {            return startViaZygote(processClass, niceName, uid, gid, gids,                    runtimeFlags, mountExternal, targetSdkVersion, seInfo,                    abi, instructionSet, appDataDir, invokeWith, /*startChildZygote=*/ false,                    packageName, useUsapPool, zygoteArgs);        } catch (ZygoteStartFailedEx ex) {            Log.e(LOG_TAG,                    "Starting VM process through Zygote failed");            throw new RuntimeException(                    "Starting VM process through Zygote failed", ex);        }    }从函数名称,我们可以得知,这里用fetchUsapPoolEnabledPropWithMinInterval判断体系是否开启了USAP功能,如果开启则调用informZygotesOfUsapPoolStatus():
您需要登录后才可以回帖 登录 | 立即注册

Powered by CangBaoKu v1.0 小黑屋藏宝库It社区( 冀ICP备14008649号 )

GMT+8, 2025-4-10 11:14, Processed in 0.180563 second(s), 32 queries.© 2003-2025 cbk Team.

快速回复 返回顶部 返回列表