installd进程流程分析

本文探讨了Android系统中的installd服务,该服务在systemserver的startBootstrapServices阶段启动。installd主要负责创建和删除应用目录、odex与oat文件,计算应用大小以及数据迁移等操作。在frameworks ativecmdsinstalldAndroid.bp文件中编译,并在installd.cpp的主函数中启动。服务通过Binder机制在native层的servicemanager中发布,install.java中的功能调用最终由InstalldNativeService处理。
installd服务启动

在systemserver中installer服务作为一个重要服务在:startBootstrapServices中启动:

// Wait for installd to finish starting up so that it has a chance to
        // create critical directories such as /data/user with the appropriate
        // permissions.  We need this to complete before we initialize other services.
        traceBeginAndSlog("StartInstaller");
        Installer installer = mSystemServiceManager.startService(Installer.class);
        traceEnd();

installer代码较为简洁,主要为一些创建、删除应用目录、创建、删除odex文件,创建、删除oat文件、计算app大小、迁移app等功能:

    private void connect() {
        获取installd守护进程的binder
        IBinder binder = ServiceManager.getService("installd");
        if (binder != null) {
            try {
                binder.linkToDeath(new DeathRecipient() {
                    @Override
                    public void binderDied() {
                        Slog.w(TAG, "installd died; reconnecting");
                        connect();
                    }
                }, 0);
            } catch (RemoteException e) {
                binder = null;
            }
        }

        if (binder != null) {
            获取installd服务的代理
            mInstalld = IInstalld.Stub.asInterface(binder);
            try {
                invalidateMounts();
            } catch (InstallerException ignored) {
            }
        } else {
            Slog.w(TAG, "installd not found; trying again");
            Backgrou
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值