-
-
Notifications
You must be signed in to change notification settings - Fork 416
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Core: Support seekable file sources via
Okio.FileHandle
Replace the previous sepperate read/write functions. Allows `Coil` to efficiently load video thumbnails. Improves SAF performance. See #1434 See coil-kt/coil#2550
- Loading branch information
Showing
19 changed files
with
363 additions
and
167 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
12 changes: 12 additions & 0 deletions
12
app-common-io/src/main/aidl/eu/darken/sdmse/common/ipc/RemoteFileHandle.aidl
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
package eu.darken.sdmse.common.ipc; | ||
|
||
interface RemoteFileHandle { | ||
boolean readWrite(); | ||
// We need inout for the buffer, as FileHandle will pass partially filled buffers that need to stay partially filled when returned | ||
int read(long fileOffset, inout byte[] buffer, int bufferOffset, int byteCount); | ||
void write(long fileOffset, inout byte[] buffer, int bufferOffset, int byteCount); | ||
void resize(long size); | ||
long size(); | ||
void flush(); | ||
void close(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
39 changes: 39 additions & 0 deletions
39
app-common-io/src/main/java/eu/darken/sdmse/common/files/FileHandleWithCallbacks.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
package eu.darken.sdmse.common.files | ||
|
||
import okio.FileHandle | ||
|
||
class FileHandleWithCallbacks( | ||
private val wrapped: FileHandle, | ||
private val onPostClosed: () -> Unit | ||
) : FileHandle(wrapped.readWrite) { | ||
|
||
override fun protectedFlush() = wrapped.flush() | ||
|
||
override fun protectedResize(size: Long) = wrapped.resize(size) | ||
|
||
override fun protectedSize(): Long = wrapped.size() | ||
|
||
override fun protectedRead( | ||
fileOffset: Long, | ||
array: ByteArray, | ||
arrayOffset: Int, | ||
byteCount: Int | ||
): Int = wrapped.read(fileOffset, array, arrayOffset, byteCount) | ||
|
||
override fun protectedWrite( | ||
fileOffset: Long, | ||
array: ByteArray, | ||
arrayOffset: Int, | ||
byteCount: Int | ||
) = wrapped.write(fileOffset, array, arrayOffset, byteCount) | ||
|
||
override fun protectedClose() { | ||
try { | ||
wrapped.close() | ||
} finally { | ||
onPostClosed() | ||
} | ||
} | ||
} | ||
|
||
fun FileHandle.callbacks(onPostClosed: () -> Unit): FileHandle = FileHandleWithCallbacks(this, onPostClosed) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.