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