public class ResourcesManager extends Object
Constructor and Description |
---|
ResourcesManager() |
Modifier and Type | Method and Description |
---|---|
void |
appendLibAssetForMainAssetPath(String assetPath,
String libAsset)
Appends the library asset path to any ResourcesImpl object that contains the main
assetPath.
|
boolean |
applyCompatConfigurationLocked(int displayDensity,
Configuration compatConfiguration) |
boolean |
applyConfigurationToResourcesLocked(Configuration config,
CompatibilityInfo compat) |
protected AssetManager |
createAssetManager(ResourcesKey key)
Creates an AssetManager from the paths within the ResourcesKey.
|
Resources |
createBaseActivityResources(IBinder activityToken,
String resDir,
String[] splitResDirs,
String[] overlayDirs,
String[] libDirs,
int displayId,
Configuration overrideConfig,
CompatibilityInfo compatInfo,
ClassLoader classLoader)
Creates base resources for an Activity.
|
Display |
getAdjustedDisplay(int displayId,
DisplayAdjustments displayAdjustments)
Returns an adjusted
Display object based on the inputs or null if display isn't
available. |
Configuration |
getConfiguration() |
protected DisplayMetrics |
getDisplayMetrics(int displayId,
DisplayAdjustments da)
Protected so that tests can override and returns something a fixed value.
|
static ResourcesManager |
getInstance() |
Resources |
getResources(IBinder activityToken,
String resDir,
String[] splitResDirs,
String[] overlayDirs,
String[] libDirs,
int displayId,
Configuration overrideConfig,
CompatibilityInfo compatInfo,
ClassLoader classLoader)
Gets or creates a new Resources object associated with the IBinder token.
|
void |
invalidatePath(String path)
Invalidate and destroy any resources that reference content under the
given filesystem path.
|
void |
updateResourcesForActivity(IBinder activityToken,
Configuration overrideConfig)
Updates an Activity's Resources object with overrideConfig.
|
public static ResourcesManager getInstance()
public void invalidatePath(String path)
public Configuration getConfiguration()
protected DisplayMetrics getDisplayMetrics(int displayId, DisplayAdjustments da)
public boolean applyCompatConfigurationLocked(int displayDensity, Configuration compatConfiguration)
public Display getAdjustedDisplay(int displayId, DisplayAdjustments displayAdjustments)
Display
object based on the inputs or null if display isn't
available.displayId
- display Id.displayAdjustments
- display adjustments.protected AssetManager createAssetManager(ResourcesKey key)
key
- The key containing the resource paths to add to the AssetManager.public Resources createBaseActivityResources(IBinder activityToken, String resDir, String[] splitResDirs, String[] overlayDirs, String[] libDirs, int displayId, Configuration overrideConfig, CompatibilityInfo compatInfo, ClassLoader classLoader)
getResources(IBinder, String, String[], String[], String[], int, Configuration,
CompatibilityInfo, ClassLoader)
with the same activityToken will have their override
configurations merged with the one specified here.activityToken
- Represents an Activity.resDir
- The base resource path. Can be null (only framework resources will be loaded).splitResDirs
- An array of split resource paths. Can be null.overlayDirs
- An array of overlay paths. Can be null.libDirs
- An array of resource library paths. Can be null.displayId
- The ID of the display for which to create the resources.overrideConfig
- The configuration to apply on top of the base configuration. Can be
null. This provides the base override for this Activity.compatInfo
- The compatibility settings to use. Cannot be null. A default to use is
CompatibilityInfo.DEFAULT_COMPATIBILITY_INFO
.classLoader
- The class loader to use when inflating Resources. If null, the
ClassLoader.getSystemClassLoader()
is used.public Resources getResources(IBinder activityToken, String resDir, String[] splitResDirs, String[] overlayDirs, String[] libDirs, int displayId, Configuration overrideConfig, CompatibilityInfo compatInfo, ClassLoader classLoader)
activityToken
- Represents an Activity. If null, global resources are assumed.resDir
- The base resource path. Can be null (only framework resources will be loaded).splitResDirs
- An array of split resource paths. Can be null.overlayDirs
- An array of overlay paths. Can be null.libDirs
- An array of resource library paths. Can be null.displayId
- The ID of the display for which to create the resources.overrideConfig
- The configuration to apply on top of the base configuration. Can be
null. Mostly used with Activities that are in multi-window which may override width and
height properties from the base config.compatInfo
- The compatibility settings to use. Cannot be null. A default to use is
CompatibilityInfo.DEFAULT_COMPATIBILITY_INFO
.classLoader
- The class loader to use when inflating Resources. If null, the
ClassLoader.getSystemClassLoader()
is used.public void updateResourcesForActivity(IBinder activityToken, Configuration overrideConfig)
getResources(IBinder, String, String[], String[], String[], int, Configuration,
CompatibilityInfo, ClassLoader)
is
still valid and will have the updated configuration.activityToken
- The Activity token.overrideConfig
- The configuration override to update.public final boolean applyConfigurationToResourcesLocked(Configuration config, CompatibilityInfo compat)
public void appendLibAssetForMainAssetPath(String assetPath, String libAsset)
assetPath
- The main asset path for which to add the library asset path.libAsset
- The library asset path to add.