mirror of
				https://github.com/TeamNewPipe/NewPipe
				synced 2025-10-31 15:23:00 +00:00 
			
		
		
		
	Don't enable SAF on Fire TV (#6516)
This commit is contained in:
		| @@ -9,6 +9,7 @@ import androidx.annotation.NonNull; | |||||||
| import androidx.preference.PreferenceManager; | import androidx.preference.PreferenceManager; | ||||||
|  |  | ||||||
| import org.schabi.newpipe.R; | import org.schabi.newpipe.R; | ||||||
|  | import org.schabi.newpipe.util.DeviceUtils; | ||||||
|  |  | ||||||
| import java.io.File; | import java.io.File; | ||||||
| import java.util.Set; | import java.util.Set; | ||||||
| @@ -110,10 +111,12 @@ public final class NewPipeSettings { | |||||||
|     } |     } | ||||||
|  |  | ||||||
|     public static boolean useStorageAccessFramework(final Context context) { |     public static boolean useStorageAccessFramework(final Context context) { | ||||||
|         if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q) { |         // There's a FireOS bug which prevents SAF open/close dialogs from being confirmed with a | ||||||
|             return true; |         // remote (see #6455). | ||||||
|         } else if (Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP) { |         if (Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP || DeviceUtils.isFireTv()) { | ||||||
|             return false; |             return false; | ||||||
|  |         } else if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q) { | ||||||
|  |             return true; | ||||||
|         } |         } | ||||||
|  |  | ||||||
|         final String key = context.getString(R.string.storage_use_saf); |         final String key = context.getString(R.string.storage_use_saf); | ||||||
|   | |||||||
| @@ -11,6 +11,7 @@ import org.schabi.newpipe.R; | |||||||
| import org.schabi.newpipe.error.ErrorActivity; | import org.schabi.newpipe.error.ErrorActivity; | ||||||
| import org.schabi.newpipe.error.ErrorInfo; | import org.schabi.newpipe.error.ErrorInfo; | ||||||
| import org.schabi.newpipe.error.UserAction; | import org.schabi.newpipe.error.UserAction; | ||||||
|  | import org.schabi.newpipe.util.DeviceUtils; | ||||||
|  |  | ||||||
| import static org.schabi.newpipe.MainActivity.DEBUG; | import static org.schabi.newpipe.MainActivity.DEBUG; | ||||||
|  |  | ||||||
| @@ -63,9 +64,11 @@ public final class SettingMigrations { | |||||||
|             // We reset the setting to its default value, i.e. "use SAF", since now there are no |             // We reset the setting to its default value, i.e. "use SAF", since now there are no | ||||||
|             // more issues with SAF and users should use that one instead of the old |             // more issues with SAF and users should use that one instead of the old | ||||||
|             // NoNonsenseFilePicker. SAF does not work on KitKat and below, though, so the setting |             // NoNonsenseFilePicker. SAF does not work on KitKat and below, though, so the setting | ||||||
|             // is set to false in that case. |             // is set to false in that case. Also, there's a bug on FireOS in which SAF open/close | ||||||
|  |             // dialogs cannot be confirmed with a remote (see #6455). | ||||||
|             sp.edit().putBoolean(context.getString(R.string.storage_use_saf), |             sp.edit().putBoolean(context.getString(R.string.storage_use_saf), | ||||||
|                     Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP).apply(); |                     Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP | ||||||
|  |                             && !DeviceUtils.isFireTv()).apply(); | ||||||
|         } |         } | ||||||
|     }; |     }; | ||||||
|  |  | ||||||
|   | |||||||
| @@ -21,6 +21,7 @@ public final class DeviceUtils { | |||||||
|  |  | ||||||
|     private static final String AMAZON_FEATURE_FIRE_TV = "amazon.hardware.fire_tv"; |     private static final String AMAZON_FEATURE_FIRE_TV = "amazon.hardware.fire_tv"; | ||||||
|     private static Boolean isTV = null; |     private static Boolean isTV = null; | ||||||
|  |     private static Boolean isFireTV = null; | ||||||
|  |  | ||||||
|     /* |     /* | ||||||
|      * Devices that do not support media tunneling |      * Devices that do not support media tunneling | ||||||
| @@ -35,6 +36,16 @@ public final class DeviceUtils { | |||||||
|     private DeviceUtils() { |     private DeviceUtils() { | ||||||
|     } |     } | ||||||
|  |  | ||||||
|  |     public static boolean isFireTv() { | ||||||
|  |         if (isFireTV != null) { | ||||||
|  |             return isFireTV; | ||||||
|  |         } | ||||||
|  |  | ||||||
|  |         isFireTV = | ||||||
|  |                 App.getApp().getPackageManager().hasSystemFeature(AMAZON_FEATURE_FIRE_TV); | ||||||
|  |         return isFireTV; | ||||||
|  |     } | ||||||
|  |  | ||||||
|     public static boolean isTv(final Context context) { |     public static boolean isTv(final Context context) { | ||||||
|         if (isTV != null) { |         if (isTV != null) { | ||||||
|             return isTV; |             return isTV; | ||||||
| @@ -45,7 +56,7 @@ public final class DeviceUtils { | |||||||
|         // from doc: https://developer.android.com/training/tv/start/hardware.html#runtime-check |         // from doc: https://developer.android.com/training/tv/start/hardware.html#runtime-check | ||||||
|         boolean isTv = ContextCompat.getSystemService(context, UiModeManager.class) |         boolean isTv = ContextCompat.getSystemService(context, UiModeManager.class) | ||||||
|                 .getCurrentModeType() == Configuration.UI_MODE_TYPE_TELEVISION |                 .getCurrentModeType() == Configuration.UI_MODE_TYPE_TELEVISION | ||||||
|                 || pm.hasSystemFeature(AMAZON_FEATURE_FIRE_TV) |                 || isFireTv() | ||||||
|                 || pm.hasSystemFeature(PackageManager.FEATURE_TELEVISION); |                 || pm.hasSystemFeature(PackageManager.FEATURE_TELEVISION); | ||||||
|  |  | ||||||
|         // from https://stackoverflow.com/a/58932366 |         // from https://stackoverflow.com/a/58932366 | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user
	 Mohammed Anas
					Mohammed Anas