Skip to content

Android: Convert SyncProgramsJobService to Kotlin#14503

Open
Simonx22 wants to merge 1 commit intodolphin-emu:masterfrom
Simonx22:android/convert-syncprogramsjobservice-to-kotlin
Open

Android: Convert SyncProgramsJobService to Kotlin#14503
Simonx22 wants to merge 1 commit intodolphin-emu:masterfrom
Simonx22:android/convert-syncprogramsjobservice-to-kotlin

Conversation

@Simonx22
Copy link
Copy Markdown
Member

@Simonx22 Simonx22 commented Mar 23, 2026

Changes:

  • Convert SyncProgramsJobService from Java to Kotlin.
  • Replace AsyncTask/executor lifecycle handling with coroutine-based job execution and cancellation.
  • Stop using restricted androidx.tvprovider builder APIs.

Copy link
Copy Markdown
Member

@JosJuice JosJuice left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Quite a lot changed in this PR for being a PR that converts to Kotlin. Was the threading solution changed because the old one didn't work, or just because the new one is preferable? Did you also consider coroutines as an option?

I'm not necessarily opposed to making these changes, but I'd like to know the reasoning.

private const val COLUMN_SHORT_DESCRIPTION = "short_description"
private const val COLUMN_POSTER_ART_URI = "poster_art_uri"
private const val COLUMN_POSTER_ART_ASPECT_RATIO = "poster_art_aspect_ratio"
private const val COLUMN_INTENT_URI = "intent_uri"
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It would be preferable to not hardcode these. Is there a problem with PreviewProgram.Builder?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there a problem with PreviewProgram.Builder?

Yes. PreviewProgram.Builder has a limitation here: the setter methods we need are restricted in androidx.tvprovider, so they cause restricted API errors.
To avoid hardcoding, I used public TV contract column constants (TvContractCompat.PreviewPrograms and framework TvContract.Programs) instead of hardcoded string values.

Changes:
- Convert SyncProgramsJobService from Java to Kotlin.
- Replace AsyncTask/executor lifecycle handling with coroutine-based job execution and cancellation.
- Stop using restricted androidx.tvprovider builder APIs.
@Simonx22 Simonx22 force-pushed the android/convert-syncprogramsjobservice-to-kotlin branch from a7456ec to dbeca0d Compare March 25, 2026 03:05
@Simonx22
Copy link
Copy Markdown
Member Author

Quite a lot changed in this PR for being a PR that converts to Kotlin. Was the threading solution changed because the old one didn't work, or just because the new one is preferable?

Yeah.. I originally intended this to be just a Kotlin conversion, but while working on it I noticed the problematic API calls and decided to clean those up too. I meant to update the PR description but forgot because I was busy dealing with the R8 issues.

Did you also consider coroutines as an option?

Not initially, but I’ve implemented them now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

2 participants