OverlayManagerService

com.android.server.om.OverlayManagerService#updateActivityManager:

    /**
     * Tell the activity manager to tell a set of packages to reload their
     * resources.
     */
    private void updateActivityManager(@NonNull List<String> targetPackageNames, final int userId) {
        final IActivityManager am = ActivityManager.getService();
        try {
            am.scheduleApplicationInfoChanged(targetPackageNames, userId);
        } catch (RemoteException e) {
            Slog.e(TAG, "updateActivityManager remote exception", e);
        }
    }

android.app.ActivityThread#handleApplicationInfoChanged

to :

在这里插入图片描述

OverlayManagerSettings:

all the data about overlay packages:

com.android.server.om.OverlayManagerSettings#insert()

How to add a item?


com.android.server.om.OverlayManagerSettings#init()

How to tell the target apk that a overlay is added?

  public static final String ACTION_OVERLAY_CHANGED = "android.intent.action.OVERLAY_CHANGED";
  com.android.server.om.OverlayManagerService#updateTargetPackagesLocked()
	com.android.server.om.OverlayManagerService#broadcastActionOverlayChanged()

on packaage installed:

com.android.server.om.OverlayManagerService.PackageReceiver
com.android.server.om.OverlayManagerService.PackageReceiver#onPackageAdded()


com.android.server.om.OverlayManagerService#updateTargetPackagesLocked()




/data/system/overlays.xml

publishBinderService(Context.OVERLAY_SERVICE, mService);

query overlay:

com.android.server.om.OverlayManagerSettings#getOverlaysForUser

all overlays:

com.android.server.om.OverlayManagerSettings#mItems

    /**
     * Returns true if the settings were modified, false if they remain the same.
     */
    boolean setLowestPriority(@NonNull final OverlayIdentifier overlay, final int userId) {
        final int idx = select(overlay, userId);
        if (idx <= 0) {
            // If the item doesn't exist or is already the lowest, don't change anything.
            return false;
        }

        final SettingsItem item = mItems.get(idx);
        mItems.remove(item);
        mItems.add(0, item);
        return true;
    }

    /**
     * Returns true if the settings were modified, false if they remain the same.
     */
    boolean setHighestPriority(@NonNull final OverlayIdentifier overlay, final int userId) {
        final int idx = select(overlay, userId);

        // If the item doesn't exist or is already the highest, don't change anything.
        if (idx < 0 || idx == mItems.size() - 1) {
            return false;
        }

        final SettingsItem item = mItems.get(idx);
        mItems.remove(idx);
        mItems.add(item);
        return true;
    }

com.android.server.om.IdmapManager#createIdmap

private static final String IDMAP_DAEMON = "idmap2d";
   @Nullable
    private IBinder getIdmapService() throws TimeoutException, RemoteException {
        try {
            SystemService.start(IDMAP_DAEMON);
        } catch (RuntimeException e) {
            if (e.getMessage().contains("failed to set system property")) {
                Slog.w(TAG, "Failed to enable idmap2 daemon", e);
                return null;
            }
        }

        final long endMillis = SystemClock.elapsedRealtime() + SERVICE_CONNECT_TIMEOUT_MS;
        while (SystemClock.elapsedRealtime() <= endMillis) {
            final IBinder binder = ServiceManager.getService(IDMAP_SERVICE);
            if (binder != null) {
                binder.linkToDeath(
                        () -> Slog.w(TAG, String.format("service '%s' died", IDMAP_SERVICE)), 0);
                return binder;
            }

            try {
                Thread.sleep(SERVICE_CONNECT_INTERVAL_SLEEP_MS);
            } catch (InterruptedException ignored) {
            }
        }

        throw new TimeoutException(
            String.format("Failed to connect to '%s' in %d milliseconds", IDMAP_SERVICE,
                    SERVICE_CONNECT_TIMEOUT_MS));
    }

/home/andy/aosp13/frameworks/base/cmds/idmap2

  • 8
    点赞
  • 5
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值