java.lang.Object | ||
↳ | android.content.res.Resources | |
↳ | android.content.res.XResources |
Resources
subclass that allows replacing individual resources.
Xposed replaces the standard resources with this class, which overrides the methods used for retrieving individual resources and adds possibilities to replace them. These replacements can be set using the methods made available via the API methods in this class.
Nested Classes | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
XResources.DimensionReplacement | Callback for dimension replacements. | ||||||||||
XResources.DrawableLoader | Callback for drawable replacements. | ||||||||||
XResources.ResourceNames | Wrapper for information about an indiviual resource. |
Public Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
Makes any individual resource available from another
Resources
instance available in this XResources instance.
| |||||||||||
Generates a fake resource ID.
| |||||||||||
Generates a fake resource ID.
| |||||||||||
Returns the name of the package that these resources belong to, or "android" for system resources.
| |||||||||||
Special case of
getPackageName() during object creation.
| |||||||||||
Hook the inflation of a layout.
| |||||||||||
Hook the inflation of a layout.
| |||||||||||
This method was deprecated
in API level 81.
Use
hookLayout(String, String, String, XC_LayoutInflated) instead.
| |||||||||||
This method was deprecated
in API level 81.
Use
hookSystemWideLayout(String, String, String, XC_LayoutInflated) instead.
| |||||||||||
Hook the inflation of an Android framework layout (in the
android package).
| |||||||||||
Hook the inflation of an Android framework layout (in the
android package).
| |||||||||||
This method was deprecated
in API level 81.
Use
setReplacement(String, String, String, Object) instead.
| |||||||||||
Sets a replacement for an individual resource.
| |||||||||||
Sets a replacement for an individual resource.
| |||||||||||
This method was deprecated
in API level 81.
Use
setSystemWideReplacement(String, String, String, Object) instead.
| |||||||||||
Sets a replacement for an individual Android framework resource (in the
android package).
| |||||||||||
Sets a replacement for an individual Android framework resource (in the
android package).
|
[Expand]
Inherited Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
From class
android.content.res.Resources
| |||||||||||
From class
java.lang.Object
|
Makes any individual resource available from another Resources
instance available in this XResources
instance.
This method combines calls to getFakeResId(Resources, int)
and
setReplacement(int, Object)
to generate a fake resource ID and set up a replacement
for it which forwards to the given resource.
The returned ID can only be used to retrieve the resource, it won't work for methods like
Resources.getResourceName(int)
etc.
res | The target Resources instance. |
---|---|
id | The target resource ID. |
Generates a fake resource ID.
The parameter is just hashed, it doesn't have a deeper meaning. However, it's recommended to use values with a low risk for conflicts, such as a full resource name. Calling this method multiple times will return the same ID.
resName | A used for hashing, see above. |
---|
Generates a fake resource ID.
This variant uses the result of Resources.getResourceName(int)
to create the hash that the ID is
based on. The given resource doesn't need to match the XResources
instance for which
the fake resource ID is going to be used.
res | The Resources object to be used for hashing. |
---|---|
id | The resource ID to be used for hashing. |
Returns the name of the package that these resources belong to, or "android" for system resources.
Special case of getPackageName()
during object creation.
For a short moment during/after the creation of a new Resources
object, it isn't an instance of XResources
yet. For any hooks that need information
about the just created object during this particular stage, this method will return the
package name.
If you call this method outside of getTopLevelResources()
, it
throws an IllegalStateException
.
Hook the inflation of a layout.
pkg | The package name, e.g. com.android.systemui .
See Resources.getResourcePackageName(int) . |
---|---|
type | The type name, e.g. layout .
See Resources.getResourceTypeName(int) . |
name | The entry name, e.g. statusbar .
See Resources.getResourceEntryName(int) . |
callback | The callback to be executed when the layout has been inflated. |
Hook the inflation of a layout.
id | The ID of the resource which should be replaced. |
---|---|
callback | The callback to be executed when the layout has been inflated. |
This method was deprecated
in API level 81.
Use hookLayout(String, String, String, XC_LayoutInflated)
instead.
Hook the inflation of a layout.
fullName | The full resource name, e.g. com.android.systemui:layout/statusbar .
See Resources.getResourceName(int) . |
---|---|
callback | The callback to be executed when the layout has been inflated. |
This method was deprecated
in API level 81.
Use hookSystemWideLayout(String, String, String, XC_LayoutInflated)
instead.
Hook the inflation of an Android framework layout (in the android
package).
See hookSystemWideLayout(String, String, String, XC_LayoutInflated)
.
fullName | The full resource name, e.g. android:layout/simple_list_item_1 .
See Resources.getResourceName(int) . |
---|---|
callback | The callback to be executed when the layout has been inflated. |
Hook the inflation of an Android framework layout (in the android
package).
See hookSystemWideLayout(String, String, String, XC_LayoutInflated)
.
id | The ID of the resource which should be replaced. |
---|---|
callback | The callback to be executed when the layout has been inflated. |
Hook the inflation of an Android framework layout (in the android
package).
Some layouts are part of the Android framework and can be used in any app. They're
accessible via android.R.layout
and are not bound to a specific
Resources
instance. Such resources can be replaced in
initZygote()
for all apps. As there is no
XResources
object easily available in that scope, this static method can be used
to hook layouts.
pkg | The package name, e.g. android .
See Resources.getResourcePackageName(int) . |
---|---|
type | The type name, e.g. layout .
See Resources.getResourceTypeName(int) . |
name | The entry name, e.g. simple_list_item_1 .
See Resources.getResourceEntryName(int) . |
callback | The callback to be executed when the layout has been inflated. |
This method was deprecated
in API level 81.
Use setReplacement(String, String, String, Object)
instead.
Sets a replacement for an individual resource. See setReplacement(String, String, String, Object)
.
fullName | The full resource name, e.g. com.example.myapplication:string/app_name .
See Resources.getResourceName(int) . |
---|---|
replacement | The replacement. |
Sets a replacement for an individual resource. If called more than once for the same ID, the
replacement from the last call is used. Setting the replacement to null
removes it.
The allowed replacements depend on the type of the source. All types accept an
XResForwarder
object, which is usually created with XModuleResources.fwd(int)
.
The resource request will then be forwarded to another Resources
object. In addition to that, the following replacement types are accepted:
Other resource types, such as styles/themes, raw resources and typed arrays can't be replaced.
* Auto-boxing allows you to use literals like 123
where an Integer
is
accepted, so you don't neeed to call methods like Integer.valueOf(int)
manually.
** Some of these methods have multiple variants, only one of them is mentioned here.
pkg | The package name, e.g. com.example.myapplication .
See Resources.getResourcePackageName(int) . |
---|---|
type | The type name, e.g. string .
See Resources.getResourceTypeName(int) . |
name | The entry name, e.g. app_name .
See Resources.getResourceEntryName(int) . |
replacement | The replacement. |
Sets a replacement for an individual resource. See setReplacement(String, String, String, Object)
.
id | The ID of the resource which should be replaced. |
---|---|
replacement | The replacement, see above. |
This method was deprecated
in API level 81.
Use setSystemWideReplacement(String, String, String, Object)
instead.
Sets a replacement for an individual Android framework resource (in the android
package).
See setSystemWideReplacement(String, String, String, Object)
.
fullName | The full resource name, e.g. android:string/yes .
See Resources.getResourceName(int) . |
---|---|
replacement | The replacement. |
Sets a replacement for an individual Android framework resource (in the android
package).
See setSystemWideReplacement(String, String, String, Object)
.
id | The ID of the resource which should be replaced. |
---|---|
replacement | The replacement. |
Sets a replacement for an individual Android framework resource (in the android
package).
Some resources are part of the Android framework and can be used in any app. They're
accessible via android.R
and are not bound to a specific
Resources
instance. Such resources can be replaced in
initZygote()
for all apps. As there is no
XResources
object easily available in that scope, this static method can be used
to set resource replacements. All other details (e.g. how certain types can be replaced) are
mentioned in setReplacement(String, String, String, Object)
.
pkg | The package name, should always be android here.
See Resources.getResourcePackageName(int) . |
---|---|
type | The type name, e.g. string .
See Resources.getResourceTypeName(int) . |
name | The entry name, e.g. yes .
See Resources.getResourceEntryName(int) . |
replacement | The replacement. |