Overlays are a way to customize resource files and do not work for source files.
Replacement works on string granularity. That means, that for strings that do not exist in the overlay file, the corresponding string from the original is used.
From the documentation:
The Android build system uses resource overlays to customize a product
at build time. Resource overlays specify resource files that are
applied on top of the defaults. To use resource overlays, modify the
project buildfile to set PRODUCT_PACKAGE_OVERLAYS
to a path relative
to your top-level directory. That path becomes a shadow root searched
along with the current root when the build system searches for
resources.
The most commonly customized settings are contained in the file
frameworks/base/core/res/res/values/config.xml.
To set up a resource overlay on this file, add the overlay directory
to the project buildfile using one of the following:
PRODUCT_PACKAGE_OVERLAYS := device/device-implementer/device-name/overlay
or
PRODUCT_PACKAGE_OVERLAYS := vendor/vendor-name/overlay
Then, add an overlay file to the directory, for example:
vendor/foobar/overlay/frameworks/base/core/res/res/values/config.xml
Any strings or string arrays found in the overlay config.xml
file
replace those found in the original file.