# FakeHardwareBufferNativeHelpers

Artifact: [androidx.media3:media3-test-utils](https://developer.android.com/jetpack/androidx/releases/media3) [View Source](https://cs.android.com/search?q=file:androidx/media3/test/utils/FakeHardwareBufferNativeHelpers.java+class:androidx.media3.test.utils.FakeHardwareBufferNativeHelpers)

*** ** * ** ***


```
@ExperimentalApi
public class FakeHardwareBufferNativeHelpers implements HardwareBufferNativeHelpers
```

<br />

*** ** * ** ***

Fake class to simulate `https://developer.android.com/reference/androidx/media3/common/video/HardwareBufferNativeHelpers`.

## Summary

| ### Public fields |
|---|---|
| `boolean` | `https://developer.android.com/reference/androidx/media3/test/utils/FakeHardwareBufferNativeHelpers#shouldSucceed()` Whether the operations should succeed. |

| ### Public constructors |
|---|
| `https://developer.android.com/reference/androidx/media3/test/utils/FakeHardwareBufferNativeHelpers#FakeHardwareBufferNativeHelpers()()` |

| ### Public methods |
|---|---|
| `boolean` | `@https://developer.android.com/reference/androidx/annotation/RequiresApi(value = 26) https://developer.android.com/reference/androidx/media3/test/utils/FakeHardwareBufferNativeHelpers#nativeCopyBitmapToHardwareBuffer(android.graphics.Bitmap,android.hardware.HardwareBuffer)(https://developer.android.com/reference/android/graphics/Bitmap.html bitmap, https://developer.android.com/reference/android/hardware/HardwareBuffer.html hb)` Copies a `https://developer.android.com/reference/android/graphics/Bitmap.html` to a `https://developer.android.com/reference/android/hardware/HardwareBuffer.html`. |
| `boolean` | `@https://developer.android.com/reference/androidx/annotation/RequiresApi(value = 26) https://developer.android.com/reference/androidx/media3/test/utils/FakeHardwareBufferNativeHelpers#nativeCopyHardwareBufferToHardwareBuffer(android.hardware.HardwareBuffer,android.hardware.HardwareBuffer)( https://developer.android.com/reference/android/hardware/HardwareBuffer.html srcHb, https://developer.android.com/reference/android/hardware/HardwareBuffer.html dstHb )` Copies the contents of a source `https://developer.android.com/reference/android/hardware/HardwareBuffer.html` to a destination `https://developer.android.com/reference/android/hardware/HardwareBuffer.html`. |

## Public fields

### shouldSucceed

```
public boolean shouldSucceed
```

Whether the operations should succeed.

## Public constructors

### FakeHardwareBufferNativeHelpers

```
public FakeHardwareBufferNativeHelpers()
```

## Public methods

### nativeCopyBitmapToHardwareBuffer

```
@RequiresApi(value = 26)
public boolean nativeCopyBitmapToHardwareBuffer(Bitmap bitmap, HardwareBuffer hb)
```

Copies a `https://developer.android.com/reference/android/graphics/Bitmap.html` to a `https://developer.android.com/reference/android/hardware/HardwareBuffer.html`.

The destination `https://developer.android.com/reference/android/hardware/HardwareBuffer.html` must have `https://developer.android.com/reference/android/hardware/HardwareBuffer.html#USAGE_CPU_WRITE_OFTEN` usage.

The source `https://developer.android.com/reference/android/graphics/Bitmap.Config.html` must match the destination `https://developer.android.com/reference/android/hardware/HardwareBuffer.html#getFormat()`, and be either `https://developer.android.com/reference/android/graphics/Bitmap.Config.html#ARGB_8888` and `https://developer.android.com/reference/android/hardware/HardwareBuffer.html#RGBA_8888` or `https://developer.android.com/reference/android/graphics/Bitmap.Config.html#RGBA_1010102` and `https://developer.android.com/reference/android/hardware/HardwareBuffer.html#RGBA_1010102`.

| Parameters |
|---|---|
| `https://developer.android.com/reference/android/graphics/Bitmap.html bitmap` | The source bitmap. |
| `https://developer.android.com/reference/android/hardware/HardwareBuffer.html hb` | The destination hardware buffer. |

| Returns |
|---|---|
| `boolean` | Whether the copy is successful. |

### nativeCopyHardwareBufferToHardwareBuffer

```
@RequiresApi(value = 26)
public boolean nativeCopyHardwareBufferToHardwareBuffer(
    HardwareBuffer srcHb,
    HardwareBuffer dstHb
)
```

Copies the contents of a source `https://developer.android.com/reference/android/hardware/HardwareBuffer.html` to a destination `https://developer.android.com/reference/android/hardware/HardwareBuffer.html`.

The source `https://developer.android.com/reference/android/hardware/HardwareBuffer.html` must have `https://developer.android.com/reference/android/hardware/HardwareBuffer.html#USAGE_CPU_READ_OFTEN` usage, and the destination `https://developer.android.com/reference/android/hardware/HardwareBuffer.html` must have `https://developer.android.com/reference/android/hardware/HardwareBuffer.html#USAGE_CPU_WRITE_OFTEN` usage.

The formats of the source and destination buffers must match, and be either `https://developer.android.com/reference/android/hardware/HardwareBuffer.html#RGBA_8888` or `https://developer.android.com/reference/android/hardware/HardwareBuffer.html#RGBA_1010102`.

| Parameters |
|---|---|
| `https://developer.android.com/reference/android/hardware/HardwareBuffer.html srcHb` | The source hardware buffer. |
| `https://developer.android.com/reference/android/hardware/HardwareBuffer.html dstHb` | The destination hardware buffer. |

| Returns |
|---|---|
| `boolean` | Whether the copy is successful. |