API-level-21-prevent-crash-on-download.patch 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738
  1. From: csagan5 <32685696+csagan5@users.noreply.github.com>
  2. Date: Sun, 27 Jun 2021 16:53:48 +0200
  3. Subject: API level 21: prevent crash on download
  4. On Lollipop 5.0.x it is not possible to use the system persistent bundle.
  5. This patch ignores boolean settings for them and prevents the crash.
  6. See also: https://github.com/bromite/bromite/issues/1184
  7. ---
  8. .../internal/BundleToPersistableBundleConverter.java | 12 ++++++++++--
  9. 1 file changed, 10 insertions(+), 2 deletions(-)
  10. diff --git a/components/background_task_scheduler/internal/android/java/src/org/chromium/components/background_task_scheduler/internal/BundleToPersistableBundleConverter.java b/components/background_task_scheduler/internal/android/java/src/org/chromium/components/background_task_scheduler/internal/BundleToPersistableBundleConverter.java
  11. --- a/components/background_task_scheduler/internal/android/java/src/org/chromium/components/background_task_scheduler/internal/BundleToPersistableBundleConverter.java
  12. +++ b/components/background_task_scheduler/internal/android/java/src/org/chromium/components/background_task_scheduler/internal/BundleToPersistableBundleConverter.java
  13. @@ -85,9 +85,17 @@ class BundleToPersistableBundleConverter {
  14. if (obj == null) {
  15. persistableBundle.putString(key, null);
  16. } else if (obj instanceof Boolean) {
  17. - persistableBundle.putBoolean(key, (Boolean) obj);
  18. + if Build.VERSION.SDK_INT == Build.VERSION_CODES.LOLLIPOP {
  19. + failedKeys.add(key);
  20. + } else {
  21. + persistableBundle.putBoolean(key, (Boolean) obj);
  22. + }
  23. } else if (obj instanceof boolean[]) {
  24. - persistableBundle.putBooleanArray(key, (boolean[]) obj);
  25. + if Build.VERSION.SDK_INT == Build.VERSION_CODES.LOLLIPOP {
  26. + failedKeys.add(key);
  27. + } else {
  28. + persistableBundle.putBooleanArray(key, (boolean[]) obj);
  29. + }
  30. } else if (obj instanceof Double) {
  31. persistableBundle.putDouble(key, (Double) obj);
  32. } else if (obj instanceof double[]) {
  33. --
  34. 2.17.1