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

# SurfaceSyncGroup

*** ** * ** ***


`
public

final

class
SurfaceSyncGroup
`


`

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


`

`


`

|---|---|
| [java.lang.Object](https://developer.android.com/reference/java/lang/Object) ||
| ↳ | android.window.SurfaceSyncGroup |

<br />

*** ** * ** ***

A way for data to be gathered so multiple surfaces can be synced. This is intended to be
used with AttachedSurfaceControl, SurfaceView, and SurfaceControlViewHost. This allows different
parts of the system to synchronize different surfaces themselves without having to manage timing
of different rendering threads.
This will also allow synchronization of surfaces across multiple processes. The caller can add
SurfaceControlViewHosts from another process to the SurfaceSyncGroup in a different process
and this clas will ensure all the surfaces are ready before applying everything together.
see the [SurfaceSyncGroup documentation](https://android.googlesource.com/platform/frameworks/base/+/master/core/java/android/window/SurfaceSyncGroup.md)

<br />

## Summary

| ### Public constructors ||
|---|---|
| ` https://developer.android.com/reference/android/window/SurfaceSyncGroup#SurfaceSyncGroup(java.lang.String)(https://developer.android.com/reference/java/lang/String name) ` Starts a sync and will automatically apply the final, merged transaction. |

| ### Public methods ||
|---|---|
| ` boolean` | ` https://developer.android.com/reference/android/window/SurfaceSyncGroup#add(android.view.SurfaceControlViewHost.SurfacePackage,%20java.lang.Runnable)(https://developer.android.com/reference/android/view/SurfaceControlViewHost.SurfacePackage surfacePackage, https://developer.android.com/reference/java/lang/Runnable runnable) ` Add a SurfaceControlViewHost.SurfacePackage to the SurfaceSyncGroup. |
| ` boolean` | ` https://developer.android.com/reference/android/window/SurfaceSyncGroup#add(android.view.AttachedSurfaceControl,%20java.lang.Runnable)(https://developer.android.com/reference/android/view/AttachedSurfaceControl attachedSurfaceControl, https://developer.android.com/reference/java/lang/Runnable runnable) ` Add an AttachedSurfaceControl to the SurfaceSyncGroup. |
| ` void` | ` https://developer.android.com/reference/android/window/SurfaceSyncGroup#addTransaction(android.view.SurfaceControl.Transaction)(https://developer.android.com/reference/android/view/SurfaceControl.Transaction transaction) ` Add a Transaction to this SurfaceSyncGroup. |
| ` void` | ` https://developer.android.com/reference/android/window/SurfaceSyncGroup#markSyncReady()() ` Mark the SurfaceSyncGroup as ready to complete. |

| ### 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*. | ||

## Public constructors

### SurfaceSyncGroup

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

```
public SurfaceSyncGroup (String name)
```

Starts a sync and will automatically apply the final, merged transaction.

<br />

| Parameters ||
|---|---|
| `name` | `String`: Used for identifying and debugging. This value cannot be `null`. <br /> |

## Public methods

### add

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

```
public boolean add (SurfaceControlViewHost.SurfacePackage surfacePackage, 
                Runnable runnable)
```

Add a SurfaceControlViewHost.SurfacePackage to the SurfaceSyncGroup. This will
get the SurfaceSyncGroup from the SurfacePackage, which will pause rendering for the
SurfaceControlViewHost. The runnable will be invoked to allow the host to update the SCVH
in a synchronized way. Finally, it will add the SCVH to the SurfaceSyncGroup and unpause
rendering in the SCVH, allowing the changes to get picked up and included in the sync.

<br />

| Parameters ||
|---|---|
| `surfacePackage` | `SurfaceControlViewHost.SurfacePackage`: The SurfacePackage that will be added to this SurfaceSyncGroup. This value cannot be `null`. <br /> |
| `runnable` | `Runnable`: This is run on the same thread that the call was made on, but after the rendering is paused and before continuing to render the next frame. This method will not return until the execution of the runnable completes. This can be used to make changes to the SurfaceControlViewHost, ensuring that the changes are included in the sync. This value may be `null`. <br /> |

| Returns ||
|---|---|
| `boolean` | true if the SurfaceControlViewHost was successfully added to the current SurfaceSyncGroup, false otherwise. <br /> |

### add

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

```
public boolean add (AttachedSurfaceControl attachedSurfaceControl, 
                Runnable runnable)
```

Add an AttachedSurfaceControl to the SurfaceSyncGroup. The AttachedSurfaceControl will pause
rendering to ensure the runnable can be invoked and that the sync picks up the frame that
contains the changes.


This method must be called on the thread that originally created
this UI element. This is typically the
[main thread](https://developer.android.com/reference/android/os/Looper#getMainLooper()) of your app.

<br />

| Parameters ||
|---|---|
| `attachedSurfaceControl` | `AttachedSurfaceControl`: The AttachedSurfaceControl that will be add to this SurfaceSyncGroup. This value may be `null`. <br /> |
| `runnable` | `Runnable`: This is run on the same thread that the call was made on, but after the rendering is paused and before continuing to render the next frame. This method will not return until the execution of the runnable completes. This can be used to make changes to the AttachedSurfaceControl, ensuring that the changes are included in the sync. This value may be `null`. <br /> |

| Returns ||
|---|---|
| `boolean` | true if the AttachedSurfaceControl was successfully added to the SurfaceSyncGroup, false otherwise. <br /> |

### addTransaction

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

```
public void addTransaction (SurfaceControl.Transaction transaction)
```

Add a Transaction to this SurfaceSyncGroup. This allows the caller to provide other info that
should be synced with the other transactions in this SurfaceSyncGroup.

<br />

| Parameters ||
|---|---|
| `transaction` | `SurfaceControl.Transaction`: The transaction to add to the SurfaceSyncGroup. This value cannot be `null`. <br /> |

### markSyncReady

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

```
public void markSyncReady ()
```

Mark the SurfaceSyncGroup as ready to complete. No more data can be added to this
SurfaceSyncGroup.


Once the SurfaceSyncGroup is marked as ready, it will be able to complete once all child
SurfaceSyncGroup have completed their sync.

<br />