mirror of
https://github.com/moonlight-stream/moonlight-android.git
synced 2026-02-16 10:31:07 +00:00
Catch IllegalArgumentException when trying to insert an entry to TvContract.Channels.CONTENT_URI
HarmonyOS has FEATURE_LEANBACK but doesn't support this URI
This commit is contained in:
@@ -77,8 +77,18 @@ public class TvChannelHelper {
|
||||
return;
|
||||
}
|
||||
|
||||
Uri channelUri = context.getContentResolver().insert(
|
||||
TvContract.Channels.CONTENT_URI, builder.toContentValues());
|
||||
Uri channelUri;
|
||||
|
||||
try {
|
||||
channelUri = context.getContentResolver().insert(
|
||||
TvContract.Channels.CONTENT_URI, builder.toContentValues());
|
||||
} catch (IllegalArgumentException e) {
|
||||
// This can happen on HarmonyOS devices which report to
|
||||
// support Leanback APIs, yet don't implement this URI
|
||||
e.printStackTrace();
|
||||
return;
|
||||
}
|
||||
|
||||
if (channelUri != null) {
|
||||
long id = ContentUris.parseId(channelUri);
|
||||
updateChannelIcon(id);
|
||||
@@ -144,8 +154,15 @@ public class TvChannelHelper {
|
||||
return;
|
||||
}
|
||||
|
||||
context.getContentResolver().insert(TvContract.PreviewPrograms.CONTENT_URI,
|
||||
builder.toContentValues());
|
||||
try {
|
||||
context.getContentResolver().insert(TvContract.PreviewPrograms.CONTENT_URI,
|
||||
builder.toContentValues());
|
||||
} catch (IllegalArgumentException e) {
|
||||
// This can happen on HarmonyOS devices which report to
|
||||
// support Leanback APIs, yet don't implement this URI
|
||||
e.printStackTrace();
|
||||
return;
|
||||
}
|
||||
|
||||
TvContract.requestChannelBrowsable(context, channelId);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user