Added in [API level 30](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels) Summary: [Inherited Constants](https://developer.android.com/reference/android/view/SurfaceControlViewHost.SurfacePackage#inhconstants) \| [Fields](https://developer.android.com/reference/android/view/SurfaceControlViewHost.SurfacePackage#lfields) \| [Ctors](https://developer.android.com/reference/android/view/SurfaceControlViewHost.SurfacePackage#pubctors) \| [Methods](https://developer.android.com/reference/android/view/SurfaceControlViewHost.SurfacePackage#pubmethods) \| [Inherited Methods](https://developer.android.com/reference/android/view/SurfaceControlViewHost.SurfacePackage#inhmethods)

# SurfaceControlViewHost.SurfacePackage

*** ** * ** ***


`
public
static
final

class
SurfaceControlViewHost.SurfacePackage
`


`

extends https://developer.android.com/reference/java/lang/Object


`

`


implements

https://developer.android.com/reference/android/os/Parcelable


`

|---|---|
| [java.lang.Object](https://developer.android.com/reference/java/lang/Object) ||
| ↳ | android.view.SurfaceControlViewHost.SurfacePackage |

<br />

*** ** * ** ***

Package encapsulating a Surface hierarchy which contains interactive view
elements. It's expected to get this object from
`https://developer.android.com/reference/android/view/SurfaceControlViewHost#getSurfacePackage()` afterwards it can be embedded within
a SurfaceView by calling `https://developer.android.com/reference/android/view/SurfaceView#setChildSurfacePackage(android.view.SurfaceControlViewHost.SurfacePackage)`.

Note that each `https://developer.android.com/reference/android/view/SurfaceControlViewHost.SurfacePackage` must be released by calling
`https://developer.android.com/reference/android/view/SurfaceControlViewHost.SurfacePackage#release()`. However, if you use the recommended flow,
the framework will automatically handle the lifetime for you.

1. When sending the package to the remote process, return it from an AIDL method
or manually use FLAG_WRITE_RETURN_VALUE in writeToParcel. This will automatically
release the package in the local process.
2. In the remote process, consume the package using SurfaceView. This way the
SurfaceView will take over the lifetime and call `https://developer.android.com/reference/android/view/SurfaceControlViewHost.SurfacePackage#release()`
for the user.

One final note: The `https://developer.android.com/reference/android/view/SurfaceControlViewHost.SurfacePackage` lifetime is totally de-coupled
from the lifetime of the underlying `https://developer.android.com/reference/android/view/SurfaceControlViewHost`. Regardless
of the lifetime of the package the user should still call
`https://developer.android.com/reference/android/view/SurfaceControlViewHost#release()` when finished.

## Summary

| ### Inherited constants |
|---|
| From interface `https://developer.android.com/reference/android/os/Parcelable` |---|---| | `int` | `https://developer.android.com/reference/android/os/Parcelable#CONTENTS_FILE_DESCRIPTOR` Descriptor bit used with `https://developer.android.com/reference/android/os/Parcelable#describeContents()`: indicates that the Parcelable object's flattened representation includes a file descriptor. | | `int` | `https://developer.android.com/reference/android/os/Parcelable#PARCELABLE_WRITE_RETURN_VALUE` Flag for use with `https://developer.android.com/reference/android/os/Parcelable#writeToParcel(android.os.Parcel,%20int)`: the object being written is a return value, that is the result of a function such as "`Parcelable someFunction()`", "`void someFunction(out Parcelable)`", or "`void someFunction(inout Parcelable)`". | |

| ### Fields ||
|---|---|
| ` public static final https://developer.android.com/reference/android/os/Parcelable.Creator<https://developer.android.com/reference/android/view/SurfaceControlViewHost.SurfacePackage>` | `https://developer.android.com/reference/android/view/SurfaceControlViewHost.SurfacePackage#CREATOR` |

| ### Public constructors ||
|---|---|
| ` https://developer.android.com/reference/android/view/SurfaceControlViewHost.SurfacePackage#SurfacePackage(android.view.SurfaceControlViewHost.SurfacePackage)(https://developer.android.com/reference/android/view/SurfaceControlViewHost.SurfacePackage other) ` Constructs a copy of `SurfacePackage` with an independent lifetime. |

| ### Public methods ||
|---|---|
| ` int` | ` https://developer.android.com/reference/android/view/SurfaceControlViewHost.SurfacePackage#describeContents()() ` Describe the kinds of special objects contained in this Parcelable instance's marshaled representation. |
| ` https://developer.android.com/reference/android/window/InputTransferToken` | ` https://developer.android.com/reference/android/view/SurfaceControlViewHost.SurfacePackage#getInputTransferToken()() ` Gets an `https://developer.android.com/reference/android/window/InputTransferToken` which can be used to request focus on the embedded surface or to transfer touch gesture to the embedded surface. |
| ` https://developer.android.com/reference/android/view/SurfaceControl` | ` https://developer.android.com/reference/android/view/SurfaceControlViewHost.SurfacePackage#getSurfaceControl()() ` Returns the `https://developer.android.com/reference/android/view/SurfaceControl` associated with this SurfacePackage for cases where more control is required. |
| ` void` | ` https://developer.android.com/reference/android/view/SurfaceControlViewHost.SurfacePackage#notifyConfigurationChanged(android.content.res.Configuration)(https://developer.android.com/reference/android/content/res/Configuration c) ` Forward a configuration to the remote SurfaceControlViewHost. |
| ` void` | ` https://developer.android.com/reference/android/view/SurfaceControlViewHost.SurfacePackage#notifyDetachedFromWindow()() ` Tear down the remote SurfaceControlViewHost and cause View#onDetachedFromWindow to be invoked on the other side. |
| ` void` | ` https://developer.android.com/reference/android/view/SurfaceControlViewHost.SurfacePackage#release()() ` Release the `https://developer.android.com/reference/android/view/SurfaceControl` associated with this package. |
| ` https://developer.android.com/reference/java/lang/String` | ` https://developer.android.com/reference/android/view/SurfaceControlViewHost.SurfacePackage#toString()() ` Returns a string representation of the object. |
| ` void` | ` https://developer.android.com/reference/android/view/SurfaceControlViewHost.SurfacePackage#writeToParcel(android.os.Parcel,%20int)(https://developer.android.com/reference/android/os/Parcel out, int flags) ` Flatten this object in to a Parcel. |

| ### Inherited methods |
|---|---|
| From class ` https://developer.android.com/reference/java/lang/Object ` |---|---| | ` https://developer.android.com/reference/java/lang/Object` | ` https://developer.android.com/reference/java/lang/Object#clone()() ` Creates and returns a copy of this object. | | ` boolean` | ` https://developer.android.com/reference/java/lang/Object#equals(java.lang.Object)(https://developer.android.com/reference/java/lang/Object obj) ` Indicates whether some other object is "equal to" this one. | | ` void` | ` 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 https://developer.android.com/reference/java/lang/Class<?>` | ` https://developer.android.com/reference/java/lang/Object#getClass()() ` Returns the runtime class of this `Object`. | | ` int` | ` https://developer.android.com/reference/java/lang/Object#hashCode()() ` Returns a hash code value for the object. | | ` final void` | ` https://developer.android.com/reference/java/lang/Object#notify()() ` Wakes up a single thread that is waiting on this object's monitor. | | ` final void` | ` https://developer.android.com/reference/java/lang/Object#notifyAll()() ` Wakes up all threads that are waiting on this object's monitor. | | ` https://developer.android.com/reference/java/lang/String` | ` https://developer.android.com/reference/java/lang/Object#toString()() ` Returns a string representation of the object. | | ` final void` | ` 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` | ` 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` | ` 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*. | ||
| From interface ` https://developer.android.com/reference/android/os/Parcelable ` |---|---| | ` abstract int` | ` https://developer.android.com/reference/android/os/Parcelable#describeContents()() ` Describe the kinds of special objects contained in this Parcelable instance's marshaled representation. | | ` abstract void` | ` https://developer.android.com/reference/android/os/Parcelable#writeToParcel(android.os.Parcel,%20int)(https://developer.android.com/reference/android/os/Parcel dest, int flags) ` Flatten this object in to a Parcel. | ||

## Fields

### CREATOR

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

```
public static final Creator<SurfaceControlViewHost.SurfacePackage> CREATOR
```

<br />

<br />

## Public constructors

### SurfacePackage

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

```
public SurfacePackage (SurfaceControlViewHost.SurfacePackage other)
```

Constructs a copy of `SurfacePackage` with an independent lifetime.

The caller can use this to create an independent copy in situations where ownership of
the `SurfacePackage` would be transferred elsewhere, such as attaching to a
`SurfaceView`, returning as `Binder` result value, etc. The caller is
responsible for releasing this copy when its done.

<br />

| Parameters ||
|---|---|
| `other` | `SurfaceControlViewHost.SurfacePackage`: `SurfacePackage` to create a copy of. This value cannot be `null`. <br /> |

## Public methods

### describeContents

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

```
public int describeContents ()
```

Describe the kinds of special objects contained in this Parcelable
instance's marshaled representation. For example, if the object will
include a file descriptor in the output of `https://developer.android.com/reference/android/os/Parcelable#writeToParcel(android.os.Parcel,%20int)`,
the return value of this method must include the
`https://developer.android.com/reference/android/os/Parcelable#CONTENTS_FILE_DESCRIPTOR` bit.

<br />

| Returns ||
|---|---|
| `int` | a bitmask indicating the set of special object types marshaled by this Parcelable object instance. Value is either `0` or - `https://developer.android.com/reference/android/os/Parcelable#CONTENTS_FILE_DESCRIPTOR` |

### getInputTransferToken

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

```
public InputTransferToken getInputTransferToken ()
```

Gets an `https://developer.android.com/reference/android/window/InputTransferToken` which can be used to request focus on the embedded
surface or to transfer touch gesture to the embedded surface.

<br />

| Returns ||
|---|---|
| `https://developer.android.com/reference/android/window/InputTransferToken` | the InputTransferToken associated with `https://developer.android.com/reference/android/view/SurfaceControlViewHost.SurfacePackage` or `null` if the embedded hasn't set up its view or doesn't have input. <br /> |

**See also:**

- `https://developer.android.com/reference/android/view/WindowManager#transferTouchGesture(android.window.InputTransferToken,%20android.window.InputTransferToken)`

### getSurfaceControl

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

```
public SurfaceControl getSurfaceControl ()
```

Returns the `https://developer.android.com/reference/android/view/SurfaceControl` associated with this SurfacePackage for
cases where more control is required.

<br />

| Returns ||
|---|---|
| `https://developer.android.com/reference/android/view/SurfaceControl` | the SurfaceControl associated with this SurfacePackage and its containing SurfaceControlViewHost. This value cannot be `null`. <br /> |

### notifyConfigurationChanged

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

```
public void notifyConfigurationChanged (Configuration c)
```

Forward a configuration to the remote SurfaceControlViewHost.
This will cause View#onConfigurationChanged to be invoked on the remote
end. This does not automatically cause the SurfaceControlViewHost
to be resized. The root View of a SurfaceControlViewHost
is more akin to a PopupWindow in that the size is user specified
independent of configuration width and height.

In order to receive the configuration change via
`https://developer.android.com/reference/android/view/View#onConfigurationChanged(android.content.res.Configuration)`, the context used with the
SurfaceControlViewHost and it's embedded view hierarchy must
be a WindowContext obtained from `https://developer.android.com/reference/android/content/Context#createWindowContext(android.view.Display,%20int,%20android.os.Bundle)`.

If a regular service context is used, then your embedded view hierarchy
will always perceive the global configuration.

<br />

| Parameters ||
|---|---|
| `c` | `Configuration`: The configuration to forward. This value cannot be `null`. <br /> |

### notifyDetachedFromWindow

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

```
public void notifyDetachedFromWindow ()
```

Tear down the remote SurfaceControlViewHost and cause
View#onDetachedFromWindow to be invoked on the other side.

<br />

### release

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

```
public void release ()
```

Release the `https://developer.android.com/reference/android/view/SurfaceControl` associated with this package.
It's not necessary to call this if you pass the package to
`https://developer.android.com/reference/android/view/SurfaceView#setChildSurfacePackage(android.view.SurfaceControlViewHost.SurfacePackage)` as `https://developer.android.com/reference/android/view/SurfaceView` will
take ownership in that case.

<br />

### toString

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

```
public String toString ()
```

Returns a string representation of the object.

<br />

| Returns ||
|---|---|
| `https://developer.android.com/reference/java/lang/String` | a string representation of the object. <br /> |

### writeToParcel

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

```
public void writeToParcel (Parcel out, 
                int flags)
```

Flatten this object in to a Parcel.

<br />

| Parameters ||
|---|---|
| `out` | `Parcel`: This value cannot be `null`. <br /> |
| `flags` | `int`: Additional flags about how the object should be written. May be 0 or `https://developer.android.com/reference/android/os/Parcelable#PARCELABLE_WRITE_RETURN_VALUE`. Value is either `0` or a combination of the following: - `https://developer.android.com/reference/android/os/Parcelable#PARCELABLE_WRITE_RETURN_VALUE` |