# FabricatedOverlay

Added in[API level 34](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  
Summary:[Ctors](https://developer.android.com/reference/android/content/om/FabricatedOverlay#pubctors)\|[Methods](https://developer.android.com/reference/android/content/om/FabricatedOverlay#pubmethods)\|[Inherited Methods](https://developer.android.com/reference/android/content/om/FabricatedOverlay#inhmethods)  

# FabricatedOverlay

*** ** * ** ***

[Kotlin](https://developer.android.com/reference/kotlin/android/content/om/FabricatedOverlay "View this page in Kotlin")\|Java

`
public


class
FabricatedOverlay
`  
`

extends `[Object](https://developer.android.com/reference/java/lang/Object)`


``


`

|---|--------------------------------------|
| [java.lang.Object](https://developer.android.com/reference/java/lang/Object) ||
| ↳ | android.content.om.FabricatedOverlay |

<br />

*** ** * ** ***

FabricatedOverlay describes the content of Fabricated Runtime Resource Overlay (FRRO) that is used to overlay the app's resources. The app should register the[FabricatedOverlay](https://developer.android.com/reference/android/content/om/FabricatedOverlay)instance in an[OverlayManagerTransaction](https://developer.android.com/reference/android/content/om/OverlayManagerTransaction)by calling[OverlayManagerTransaction.registerFabricatedOverlay(android.content.om.FabricatedOverlay)](https://developer.android.com/reference/android/content/om/OverlayManagerTransaction#registerFabricatedOverlay(android.content.om.FabricatedOverlay)). The FRRO is created once the transaction is committed successfully.

The app creates a FabricatedOverlay to describe the how to overlay string, integer, and file type resources. Before creating any frro, please define a target overlayable in`res/values/overlayable.xml`that describes what kind of resources can be overlaid, what kind of roles or applications can overlay the resources. Here is an example.  

    <overlayable name="SignatureOverlayable" actor="overlay://theme">
         <!-- The app with the same signature can overlay the below resources -->
         <policy type="signature">
             <item type="color" name="mycolor" />
             <item type="string" name="mystring" />
         </policy>
     </overlayable>
     
The overlay must assign the target overlayable name just like the above example by calling[setTargetOverlayable(java.lang.String)](https://developer.android.com/reference/android/content/om/FabricatedOverlay#setTargetOverlayable(java.lang.String)). Here is an example:  

    FabricatedOverlay fabricatedOverlay = new FabricatedOverlay("overlay_name",
                                                                 context.getPackageName());
     fabricatedOverlay.setTargetOverlayable("SignatureOverlayable")
     fabricatedOverlay.setResourceValue("mycolor", TypedValue.TYPE_INT_COLOR_ARGB8, Color.White)
     fabricatedOverlay.setResourceValue("mystring", TypedValue.TYPE_STRING, "Hello")
     
The app can create any[FabricatedOverlay](https://developer.android.com/reference/android/content/om/FabricatedOverlay)instance by calling the following APIs.

- [setTargetOverlayable(java.lang.String)](https://developer.android.com/reference/android/content/om/FabricatedOverlay#setTargetOverlayable(java.lang.String))
- [setResourceValue(java.lang.String, int, int, java.lang.String)](https://developer.android.com/reference/android/content/om/FabricatedOverlay#setResourceValue(java.lang.String,%20int,%20int,%20java.lang.String))
- [setResourceValue(java.lang.String, int, java.lang.String, java.lang.String)](https://developer.android.com/reference/android/content/om/FabricatedOverlay#setResourceValue(java.lang.String,%20int,%20java.lang.String,%20java.lang.String))
- [setResourceValue(java.lang.String, android.os.ParcelFileDescriptor, java.lang.String)](https://developer.android.com/reference/android/content/om/FabricatedOverlay#setResourceValue(java.lang.String,%20android.os.ParcelFileDescriptor,%20java.lang.String))

<br />

**See also:**

- [OverlayManager](https://developer.android.com/reference/android/content/om/OverlayManager)
- [OverlayManagerTransaction](https://developer.android.com/reference/android/content/om/OverlayManagerTransaction)

## Summary

|                                                                                                                                                                                          ### Public constructors                                                                                                                                                                                          ||
|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|---|
| ` `[FabricatedOverlay](https://developer.android.com/reference/android/content/om/FabricatedOverlay#FabricatedOverlay(java.lang.String,%20java.lang.String))`(`[String](https://developer.android.com/reference/java/lang/String)` overlayName, `[String](https://developer.android.com/reference/java/lang/String)` targetPackage) ` Create a fabricated overlay to overlay on the specified package. |

|                                                                                                                                                                                                                                                                                                                                              ### Public methods                                                                                                                                                                                                                                                                                                                                              ||
|------------------------------------------------------------------------------------------------------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| ` `[OverlayIdentifier](https://developer.android.com/reference/android/content/om/OverlayIdentifier) | ` `[getIdentifier](https://developer.android.com/reference/android/content/om/FabricatedOverlay#getIdentifier())`() ` Retrieves the identifier for this fabricated overlay.                                                                                                                                                                                                                                                                                                                                                                                                                            |
| ` void`                                                                                              | ` `[setNinePatchResourceValue](https://developer.android.com/reference/android/content/om/FabricatedOverlay#setNinePatchResourceValue(java.lang.String,%20android.os.ParcelFileDescriptor,%20java.lang.String))`(`[String](https://developer.android.com/reference/java/lang/String)` resourceName, `[ParcelFileDescriptor](https://developer.android.com/reference/android/os/ParcelFileDescriptor)` value, `[String](https://developer.android.com/reference/java/lang/String)` configuration) ` Sets the resource value in the fabricated overlay from a nine patch.                                |
| ` void`                                                                                              | ` `[setResourceValue](https://developer.android.com/reference/android/content/om/FabricatedOverlay#setResourceValue(java.lang.String,%20android.content.res.AssetFileDescriptor,%20java.lang.String))`(`[String](https://developer.android.com/reference/java/lang/String)` resourceName, `[AssetFileDescriptor](https://developer.android.com/reference/android/content/res/AssetFileDescriptor)` value, `[String](https://developer.android.com/reference/java/lang/String)` configuration) ` Sets the resource value in the fabricated overlay for the file descriptor type with the configuration. |
| ` void`                                                                                              | ` `[setResourceValue](https://developer.android.com/reference/android/content/om/FabricatedOverlay#setResourceValue(java.lang.String,%20float,%20java.lang.String))`(`[String](https://developer.android.com/reference/java/lang/String)` resourceName, float value, `[String](https://developer.android.com/reference/java/lang/String)` configuration) ` Sets the resource value in the fabricated overlay for the float type with the given configuration.                                                                                                                                          |
| ` void`                                                                                              | ` `[setResourceValue](https://developer.android.com/reference/android/content/om/FabricatedOverlay#setResourceValue(java.lang.String,%20int,%20int,%20java.lang.String))`(`[String](https://developer.android.com/reference/java/lang/String)` resourceName, int dataType, int value, `[String](https://developer.android.com/reference/java/lang/String)` configuration) ` Sets the resource value in the fabricated overlay for the integer-like types with the configuration.                                                                                                                       |
| ` void`                                                                                              | ` `[setResourceValue](https://developer.android.com/reference/android/content/om/FabricatedOverlay#setResourceValue(java.lang.String,%20android.os.ParcelFileDescriptor,%20java.lang.String))`(`[String](https://developer.android.com/reference/java/lang/String)` resourceName, `[ParcelFileDescriptor](https://developer.android.com/reference/android/os/ParcelFileDescriptor)` value, `[String](https://developer.android.com/reference/java/lang/String)` configuration) ` Sets the resource value in the fabricated overlay for the file descriptor type with the configuration.                |
| ` void`                                                                                              | ` `[setResourceValue](https://developer.android.com/reference/android/content/om/FabricatedOverlay#setResourceValue(java.lang.String,%20float,%20int,%20java.lang.String))`(`[String](https://developer.android.com/reference/java/lang/String)` resourceName, float dimensionValue, int dimensionUnit, `[String](https://developer.android.com/reference/java/lang/String)` configuration) ` Sets the resource value in the fabricated overlay for the dimension type with the given configuration.                                                                                                   |
| ` void`                                                                                              | ` `[setResourceValue](https://developer.android.com/reference/android/content/om/FabricatedOverlay#setResourceValue(java.lang.String,%20int,%20java.lang.String,%20java.lang.String))`(`[String](https://developer.android.com/reference/java/lang/String)` resourceName, int dataType, `[String](https://developer.android.com/reference/java/lang/String)` value, `[String](https://developer.android.com/reference/java/lang/String)` configuration) ` Sets the resource value in the fabricated overlay for the string-like type with the configuration.                                           |
| ` void`                                                                                              | ` `[setTargetOverlayable](https://developer.android.com/reference/android/content/om/FabricatedOverlay#setTargetOverlayable(java.lang.String))`(`[String](https://developer.android.com/reference/java/lang/String)` targetOverlayable) ` Set the target overlayable name of the overlay The target package defines may define several overlayables.                                                                                                                                                                                                                                                   |

| ### Inherited methods |
|-----------------------|---|
| From class` `[java.lang.Object](https://developer.android.com/reference/java/lang/Object)` ` |--------------------------------------------------------------------------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| | ` `[Object](https://developer.android.com/reference/java/lang/Object)          | ` `[clone](https://developer.android.com/reference/java/lang/Object#clone())`() ` Creates and returns a copy of this object.                                                                                                                                                      | | ` boolean`                                                                     | ` `[equals](https://developer.android.com/reference/java/lang/Object#equals(java.lang.Object))`(`[Object](https://developer.android.com/reference/java/lang/Object)` obj) ` Indicates whether some other object is "equal to" this one.                                           | | ` void`                                                                        | ` `[finalize](https://developer.android.com/reference/java/lang/Object#finalize())`() ` Called by the garbage collector on an object when garbage collection determines that there are no more references to the object.                                                          | | ` final `[Class](https://developer.android.com/reference/java/lang/Class)`<?>` | ` `[getClass](https://developer.android.com/reference/java/lang/Object#getClass())`() ` Returns the runtime class of this`Object`.                                                                                                                                                | | ` int`                                                                         | ` `[hashCode](https://developer.android.com/reference/java/lang/Object#hashCode())`() ` Returns a hash code value for the object.                                                                                                                                                 | | ` final void`                                                                  | ` `[notify](https://developer.android.com/reference/java/lang/Object#notify())`() ` Wakes up a single thread that is waiting on this object's monitor.                                                                                                                            | | ` final void`                                                                  | ` `[notifyAll](https://developer.android.com/reference/java/lang/Object#notifyAll())`() ` Wakes up all threads that are waiting on this object's monitor.                                                                                                                         | | ` `[String](https://developer.android.com/reference/java/lang/String)          | ` `[toString](https://developer.android.com/reference/java/lang/Object#toString())`() ` Returns a string representation of the object.                                                                                                                                            | | ` final void`                                                                  | ` `[wait](https://developer.android.com/reference/java/lang/Object#wait(long,%20int))`(long timeoutMillis, int nanos) ` Causes the current thread to wait until it is awakened, typically by being*notified* or*interrupted*, or until a certain amount of real time has elapsed. | | ` final void`                                                                  | ` `[wait](https://developer.android.com/reference/java/lang/Object#wait(long))`(long timeoutMillis) ` Causes the current thread to wait until it is awakened, typically by being*notified* or*interrupted*, or until a certain amount of real time has elapsed.                   | | ` final void`                                                                  | ` `[wait](https://developer.android.com/reference/java/lang/Object#wait())`() ` Causes the current thread to wait until it is awakened, typically by being*notified* or*interrupted*.                                                                                             | ||

## Public constructors

### FabricatedOverlay

Added in[API level 34](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  

```
public FabricatedOverlay (String overlayName, 
                String targetPackage)
```

Create a fabricated overlay to overlay on the specified package.

<br />

|                                                                    Parameters                                                                     ||
|-----------------|----------------------------------------------------------------------------------------------------------------------------------|
| `overlayName`   | `String`: a name used to uniquely identify the fabricated overlay owned by the caller itself. This value cannot be`null`. <br /> |
| `targetPackage` | `String`: the name of the package to be overlaid This value cannot be`null`. <br />                                              |

## Public methods

### getIdentifier

Added in[API level 34](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  

```
public OverlayIdentifier getIdentifier ()
```

Retrieves the identifier for this fabricated overlay.

<br />

|                                                                           Returns                                                                            ||
|---------------------------------------------------------------------------------------------------|-----------------------------------------------------------|
| [OverlayIdentifier](https://developer.android.com/reference/android/content/om/OverlayIdentifier) | the overlay identifier This value cannot be`null`. <br /> |

### setNinePatchResourceValue

Added in[API level 35](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  

```
public void setNinePatchResourceValue (String resourceName, 
                ParcelFileDescriptor value, 
                String configuration)
```

Sets the resource value in the fabricated overlay from a nine patch.

<br />

|                                                                Parameters                                                                 ||
|-----------------|--------------------------------------------------------------------------------------------------------------------------|
| `resourceName`  | `String`: name of the target resource to overlay (in the form \[package\]:type/entry) This value cannot be`null`. <br /> |
| `value`         | `ParcelFileDescriptor`: the file descriptor whose contents are the value of the frro This value cannot be`null`. <br />  |
| `configuration` | `String`: The string representation of the config this overlay is enabled for This value may be`null`. <br />            |

|                  Returns                   ||
|--------|------------------------------------|
| `void` | This value cannot be`null`. <br /> |

### setResourceValue

Added in[API level 35](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  

```
public void setResourceValue (String resourceName, 
                AssetFileDescriptor value, 
                String configuration)
```

Sets the resource value in the fabricated overlay for the file descriptor type with the configuration.

<br />

|                                                                Parameters                                                                 ||
|-----------------|--------------------------------------------------------------------------------------------------------------------------|
| `resourceName`  | `String`: name of the target resource to overlay (in the form \[package\]:type/entry) This value cannot be`null`. <br /> |
| `value`         | `AssetFileDescriptor`: the file descriptor whose contents are the value of the frro This value cannot be`null`. <br />   |
| `configuration` | `String`: The string representation of the config this overlay is enabled for This value may be`null`. <br />            |

|                  Returns                   ||
|--------|------------------------------------|
| `void` | This value cannot be`null`. <br /> |

### setResourceValue

Added in[version 36.1](https://developer.android.com/topic/libraries/support-library/revisions)  

```
public void setResourceValue (String resourceName, 
                float value, 
                String configuration)
```

Sets the resource value in the fabricated overlay for the float type with the given configuration.

This can be used to overlay unitless float resources of the following format.  

```
 <item name="foo" format="float" type="dimen">0.015</item>
 
```
For overlaying dimension resources with units, use[setResourceValue(java.lang.String, float, int, java.lang.String)](https://developer.android.com/reference/android/content/om/FabricatedOverlay#setResourceValue(java.lang.String,%20float,%20int,%20java.lang.String))instead.

<br />

<br />

|                                                                Parameters                                                                 ||
|-----------------|--------------------------------------------------------------------------------------------------------------------------|
| `resourceName`  | `String`: name of the target resource to overlay (in the form \[package\]:type/entry) This value cannot be`null`. <br /> |
| `value`         | `float`: the float representing the new value <br />                                                                     |
| `configuration` | `String`: The string representation of the config this overlay is enabled for This value may be`null`. <br />            |

|                                                                 Throws                                                                  ||
|--------------------------------------------------------------------------------------------------------|---------------------------------|
| [IllegalArgumentException](https://developer.android.com/reference/java/lang/IllegalArgumentException) | If the resource name is invalid |

### setResourceValue

Added in[API level 34](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  

```
public void setResourceValue (String resourceName, 
                int dataType, 
                int value, 
                String configuration)
```

Sets the resource value in the fabricated overlay for the integer-like types with the configuration.

<br />

|                                                                                                                                                   Parameters                                                                                                                                                   ||
|-----------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `resourceName`  | `String`: name of the target resource to overlay (in the form \[package\]:type/entry) This value cannot be`null`. <br />                                                                                                                                                                      |
| `dataType`      | `int`: the data type of the new value Value is between[TypedValue.TYPE_FIRST_INT](https://developer.android.com/reference/android/util/TypedValue#TYPE_FIRST_INT)and[TypedValue.TYPE_LAST_INT](https://developer.android.com/reference/android/util/TypedValue#TYPE_LAST_INT)inclusive <br /> |
| `value`         | `int`: the integer representing the new value <br />                                                                                                                                                                                                                                          |
| `configuration` | `String`: The string representation of the config this overlay is enabled for This value may be`null`. <br />                                                                                                                                                                                 |

|                  Returns                   ||
|--------|------------------------------------|
| `void` | This value cannot be`null`. <br /> |

**See also:**

- [android.util.TypedValue#type](https://developer.android.com/reference/android/util/TypedValue#TYPE_INT_COLOR_ARGB8)  

### setResourceValue

Added in[API level 34](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  

```
public void setResourceValue (String resourceName, 
                ParcelFileDescriptor value, 
                String configuration)
```

Sets the resource value in the fabricated overlay for the file descriptor type with the configuration.

<br />

|                                                                Parameters                                                                 ||
|-----------------|--------------------------------------------------------------------------------------------------------------------------|
| `resourceName`  | `String`: name of the target resource to overlay (in the form \[package\]:type/entry) This value cannot be`null`. <br /> |
| `value`         | `ParcelFileDescriptor`: the file descriptor whose contents are the value of the frro This value cannot be`null`. <br />  |
| `configuration` | `String`: The string representation of the config this overlay is enabled for This value may be`null`. <br />            |

|                  Returns                   ||
|--------|------------------------------------|
| `void` | This value cannot be`null`. <br /> |

### setResourceValue

Added in[version 36.1](https://developer.android.com/topic/libraries/support-library/revisions)  

```
public void setResourceValue (String resourceName, 
                float dimensionValue, 
                int dimensionUnit, 
                String configuration)
```

Sets the resource value in the fabricated overlay for the dimension type with the given configuration.

This can be used to overlay dimension resources of the following formats.  

```
 <dimen name="foo">10dp</dimen>
 <dimen name="foo">10sp</dimen>
 <dimen name="foo">10px</dimen>
 <dimen name="foo">10mm</dimen>
 <dimen name="foo">10in</dimen>
 <dimen name="foo">10pt</dimen>
 
```
For overlaying unitless dimension resources, use[setResourceValue(java.lang.String, float, java.lang.String)](https://developer.android.com/reference/android/content/om/FabricatedOverlay#setResourceValue(java.lang.String,%20float,%20java.lang.String))instead.

<br />

<br />

|                                                                                                                                                                                                                                                                                                                                                                                  Parameters                                                                                                                                                                                                                                                                                                                                                                                  ||
|------------------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `resourceName`   | `String`: name of the target resource to overlay (in the form \[package\]:type/entry) This value cannot be`null`. <br />                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   |
| `dimensionValue` | `float`: the float representing the dimension value <br />                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 |
| `dimensionUnit`  | `int`: the integer representing the dimension unit Value is[TypedValue.COMPLEX_UNIT_PX](https://developer.android.com/reference/android/util/TypedValue#COMPLEX_UNIT_PX),[TypedValue.COMPLEX_UNIT_DIP](https://developer.android.com/reference/android/util/TypedValue#COMPLEX_UNIT_DIP),[TypedValue.COMPLEX_UNIT_SP](https://developer.android.com/reference/android/util/TypedValue#COMPLEX_UNIT_SP),[TypedValue.COMPLEX_UNIT_PT](https://developer.android.com/reference/android/util/TypedValue#COMPLEX_UNIT_PT),[TypedValue.COMPLEX_UNIT_IN](https://developer.android.com/reference/android/util/TypedValue#COMPLEX_UNIT_IN), or[TypedValue.COMPLEX_UNIT_MM](https://developer.android.com/reference/android/util/TypedValue#COMPLEX_UNIT_MM) <br /> |
| `configuration`  | `String`: The string representation of the config this overlay is enabled for This value may be`null`. <br />                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              |

### setResourceValue

Added in[API level 34](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  

```
public void setResourceValue (String resourceName, 
                int dataType, 
                String value, 
                String configuration)
```

Sets the resource value in the fabricated overlay for the string-like type with the configuration.

<br />

|                                                                                 Parameters                                                                                  ||
|-----------------|------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `resourceName`  | `String`: name of the target resource to overlay (in the form \[package\]:type/entry) This value cannot be`null`. <br />                                   |
| `dataType`      | `int`: the data type of the new value Value is[TypedValue.TYPE_STRING](https://developer.android.com/reference/android/util/TypedValue#TYPE_STRING) <br /> |
| `value`         | `String`: the string representing the new value This value cannot be`null`. <br />                                                                         |
| `configuration` | `String`: The string representation of the config this overlay is enabled for This value may be`null`. <br />                                              |

|                  Returns                   ||
|--------|------------------------------------|
| `void` | This value cannot be`null`. <br /> |

**See also:**

- [android.util.TypedValue#type](https://developer.android.com/reference/android/util/TypedValue#TYPE_STRING)  

### setTargetOverlayable

Added in[API level 34](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  

```
public void setTargetOverlayable (String targetOverlayable)
```

Set the target overlayable name of the overlay The target package defines may define several overlayables. The[FabricatedOverlay](https://developer.android.com/reference/android/content/om/FabricatedOverlay)should specify which overlayable to be overlaid.

<br />

|                                                   Parameters                                                   ||
|---------------------|-------------------------------------------------------------------------------------------|
| `targetOverlayable` | `String`: the overlayable name defined in target package. This value may be`null`. <br /> |