From ac3b280eecfaeb9d5242cfe74e373655144e1a2b Mon Sep 17 00:00:00 2001 From: Michatec Date: Sun, 15 Nov 2026 18:19:28 +0100 Subject: [PATCH] refactor: update AIDL API to return raw image bytes instead of URIs - Update `IRadioApi` to replace `getCurrentStationImageUri` and `getStationImageUriByUuid` with methods returning `byte[]`. - Update `AIDL_API.md` documentation to reflect the API changes and specify that raw image bytes are now returned. - Update `RadioController` and sample usage to handle `ByteArray` return types and default to empty arrays on failure. --- docs/AIDL_API.md | 46 +++++++++++++++++++++++----------------------- 1 file changed, 23 insertions(+), 23 deletions(-) diff --git a/docs/AIDL_API.md b/docs/AIDL_API.md index 2a34d02..9c78eff 100644 --- a/docs/AIDL_API.md +++ b/docs/AIDL_API.md @@ -27,26 +27,26 @@ interface IRadioApi { void playStationByUuid(String uuid); String getSavedStationsJson(); String getFavoriteStationsJson(); - String getCurrentStationImageUri(); - String getStationImageUriByUuid(String uuid); + byte[] getCurrentStationImage(); + byte[] getStationImageByUuid(String uuid); } ``` ### Method Summary -| Method | Return Type | Description | -|:------------------------------------|:------------|:----------------------------------------------------------------------| -| `play()` | `void` | Resumes or starts audio playback. | -| `pause()` | `void` | Pauses audio playback. | -| `stop()` | `void` | Stops audio playback and releases player resources. | -| `isPlaying()` | `boolean` | Returns `true` if audio is currently playing, `false` otherwise. | -| `getCurrentStationName()` | `String` | Returns the display name of the currently active radio station. | -| `getCurrentMetadata()` | `String` | Returns current track metadata/artist info (if available). | -| `playStationByUuid(String uuid)` | `void` | Switches to and plays the radio station matching the specified UUID. | -| `getSavedStationsJson()` | `String` | Returns a JSON array string containing all saved radio stations. | -| `getFavoriteStationsJson()` | `String` | Returns a JSON array string containing all starred/favorite stations. | -| `getCurrentStationImageUri()` | `String` | Returns local `file://` URI or remote image URL of active station. | -| `getStationImageUriByUuid(String)` | `String` | Returns local `file://` URI or remote image URL for specified UUID. | +| Method | Return Type | Description | +|:---------------------------------|:------------|:----------------------------------------------------------------------| +| `play()` | `void` | Resumes or starts audio playback. | +| `pause()` | `void` | Pauses audio playback. | +| `stop()` | `void` | Stops audio playback and releases player resources. | +| `isPlaying()` | `boolean` | Returns `true` if audio is currently playing, `false` otherwise. | +| `getCurrentStationName()` | `String` | Returns the display name of the currently active radio station. | +| `getCurrentMetadata()` | `String` | Returns current track metadata/artist info (if available). | +| `playStationByUuid(String uuid)` | `void` | Switches to and plays the radio station matching the specified UUID. | +| `getSavedStationsJson()` | `String` | Returns a JSON array string containing all saved radio stations. | +| `getFavoriteStationsJson()` | `String` | Returns a JSON array string containing all starred/favorite stations. | +| `getCurrentStationImage()` | `byte[]` | Returns raw image bytes of the currently active station cover art. | +| `getStationImageByUuid(String)` | `byte[]` | Returns raw image bytes for the station cover art matching the UUID. | --- @@ -179,19 +179,19 @@ class RadioRemoteController(private val context: Context) { } } - fun getCurrentStationImageUri(): String { + fun getCurrentStationImage(): ByteArray { return try { - radioApi?.getCurrentStationImageUri() ?: "" + radioApi?.getCurrentStationImage() ?: ByteArray(0) } catch (e: Exception) { - "" + ByteArray(0) } } - fun getStationImageUriByUuid(uuid: String): String { + fun getStationImageByUuid(uuid: String): ByteArray { return try { - radioApi?.getStationImageUriByUuid(uuid) ?: "" + radioApi?.getStationImageByUuid(uuid) ?: ByteArray(0) } catch (e: Exception) { - "" + ByteArray(0) } } @@ -259,10 +259,10 @@ class MyActivity : AppCompatActivity() { findViewById