From 1c9c5317eb33d92dde3293dfe6a857c279a7ab12 Mon Sep 17 00:00:00 2001 From: Jeff Boek Date: Tue, 24 Sep 2019 17:37:26 -0700 Subject: [PATCH] For #5552 - Temporary fix for startup crash on es locales --- .../fenix/components/BackgroundServices.kt | 23 ++++++++++++++----- 1 file changed, 17 insertions(+), 6 deletions(-) diff --git a/app/src/main/java/org/mozilla/fenix/components/BackgroundServices.kt b/app/src/main/java/org/mozilla/fenix/components/BackgroundServices.kt index df7b215ea..106f4e008 100644 --- a/app/src/main/java/org/mozilla/fenix/components/BackgroundServices.kt +++ b/app/src/main/java/org/mozilla/fenix/components/BackgroundServices.kt @@ -40,6 +40,7 @@ import org.mozilla.fenix.ext.components import org.mozilla.fenix.ext.settings import org.mozilla.fenix.isInExperiment import org.mozilla.fenix.test.Mockable +import java.util.FormatFlagsConversionMismatchException /** * Component group for background services. These are the components that need to be accessed from within a @@ -61,12 +62,22 @@ class BackgroundServices( } } - fun defaultDeviceName(context: Context): String = context.getString( - R.string.default_device_name, - context.getString(R.string.app_name), - Build.MANUFACTURER, - Build.MODEL - ) + // // A malformed string is causing crashes. + // This will be removed when the string is fixed. See #5552 + fun defaultDeviceName(context: Context): String = try { + context.getString( + R.string.default_device_name, + context.getString(R.string.app_name), + Build.MANUFACTURER, + Build.MODEL + ) + } catch (ex: FormatFlagsConversionMismatchException) { + "%s on %s %s".format( + context.getString(R.string.app_name), + Build.MANUFACTURER, + Build.MODEL + ) + } private val serverConfig = ServerConfig.release(CLIENT_ID, redirectUrl(context)) private val deviceConfig = DeviceConfig(