ResourceLoaders allow inserting another .apk/.arsc into AssetManager's resource resolution search. The effect is similar to overlays, where a entry of >= config later in the path list will return that ApkAsset's resource value instead. Because loading from an .arsc is supported, which doesn't contain any actual files, ResourceLoader exposes loadDrawable and loadXmlResourceParser to allow an application load those files from anywhere or create them in code. The data being loaded is either pushed into an .apk or .arsc that mocks itself as the package being "overlaid" and is passed in through ResourcesProvider, an interface with static methods that supports loading from a readable path on disk or a FileDescriptor. The APIs are accessed through a Context's getResources(), which has been changed to be unique per "Context-scope", which is usually the lifetime of the Java object. The exception is that Activities who get their Resources object persisted across recreations maintain that logic for persisting ResourceLoaders. Bug: 135270223 Test: atest FrameworksResourceLoaderTests Change-Id: I6929f0828629ad39a21fa155e7fec73bd75eec7d
43 lines
1.4 KiB
XML
43 lines
1.4 KiB
XML
<?xml version="1.0" encoding="utf-8"?>
|
|
<!--
|
|
~ Copyright (C) 2019 The Android Open Source Project
|
|
~
|
|
~ Licensed under the Apache License, Version 2.0 (the "License");
|
|
~ you may not use this file except in compliance with the License.
|
|
~ You may obtain a copy of the License at
|
|
~
|
|
~ http://www.apache.org/licenses/LICENSE-2.0
|
|
~
|
|
~ Unless required by applicable law or agreed to in writing, software
|
|
~ distributed under the License is distributed on an "AS IS" BASIS,
|
|
~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
~ See the License for the specific language governing permissions and
|
|
~ limitations under the License
|
|
-->
|
|
|
|
<!-- Split loading is tested separately, so this must be marked isolated -->
|
|
<manifest
|
|
xmlns:android="http://schemas.android.com/apk/res/android"
|
|
package="android.content.res.loader.test"
|
|
android:isolatedSplits="true"
|
|
>
|
|
|
|
<uses-sdk android:minSdkVersion="29"/>
|
|
|
|
<application>
|
|
<uses-library android:name="android.test.runner"/>
|
|
|
|
<activity
|
|
android:name=".TestActivity"
|
|
android:configChanges="orientation"
|
|
/>
|
|
</application>
|
|
|
|
<instrumentation
|
|
android:name="androidx.test.runner.AndroidJUnitRunner"
|
|
android:label="ResourceLoaderTests"
|
|
android:targetPackage="android.content.res.loader.test"
|
|
/>
|
|
|
|
</manifest>
|