Disable media tunneling if the device is known for not supporting it

Revert removing the Utils related to media tunneling.
This commit is contained in:
TobiGr 2023-07-18 09:53:00 +02:00
parent 78e577d260
commit 8b63b437d8
3 changed files with 72 additions and 1 deletions

View file

@ -76,6 +76,10 @@ public final class NewPipeSettings {
saveDefaultVideoDownloadDirectory(context);
saveDefaultAudioDownloadDirectory(context);
if (isFirstRun) { // NOSONAR: isFirstRun is never null
setMediaTunneling(context);
}
}
static void saveDefaultVideoDownloadDirectory(final Context context) {
@ -152,4 +156,18 @@ public final class NewPipeSettings {
return showSearchSuggestions(context, sharedPreferences,
R.string.show_remote_search_suggestions_key);
}
/**
* Check if device does not support media tunneling
* and disable that exoplayer feature if necessary.
* @see DeviceUtils#shouldSupportMediaTunneling()
* @param context
*/
public static void setMediaTunneling(@NonNull final Context context) {
if (!DeviceUtils.shouldSupportMediaTunneling()) {
PreferenceManager.getDefaultSharedPreferences(context).edit()
.putBoolean(context.getString(R.string.disable_media_tunneling_key), true)
.apply();
}
}
}

View file

@ -128,6 +128,17 @@ public final class SettingMigrations {
}
};
private static final Migration MIGRATION_5_6 = new Migration(5, 6) {
@Override
protected void migrate(@NonNull final Context context) {
// PR #8875 added a new settings page for exoplayer introducing a specific setting
// to disable media tunneling. However, media tunneling should be disabled by default
// for some devices, because they are known for not supporting media tunneling
// which can result in a black screen while playing videos.
NewPipeSettings.setMediaTunneling(context);
}
};
/**
* List of all implemented migrations.
* <p>
@ -140,12 +151,13 @@ public final class SettingMigrations {
MIGRATION_2_3,
MIGRATION_3_4,
MIGRATION_4_5,
MIGRATION_5_6,
};
/**
* Version number for preferences. Must be incremented every time a migration is necessary.
*/
private static final int VERSION = 5;
private static final int VERSION = 6;
public static void initMigrations(@NonNull final Context context, final boolean isFirstRun) {