diff --git a/mobile/android/base/BrowserApp.java b/mobile/android/base/BrowserApp.java index f7cf67b24770..f2c7a41ce57d 100644 --- a/mobile/android/base/BrowserApp.java +++ b/mobile/android/base/BrowserApp.java @@ -553,6 +553,12 @@ public class BrowserApp extends GeckoApp @Override public void onCreate(Bundle savedInstanceState) { + if (!isSupportedSDK()) { + // This build does not support the Android version of the device; Exit early. + super.onCreate(savedInstanceState); + return; + } + final Intent intent = getIntent(); // Note that we're calling GeckoProfile.get *before GeckoApp.onCreate*. @@ -1217,6 +1223,12 @@ public class BrowserApp extends GeckoApp @Override public void onDestroy() { + if (!isSupportedSDK()) { + // This build does not support the Android version of the device; Exit early. + super.onDestroy(); + return; + } + mDynamicToolbar.destroy(); if (mBrowserToolbar != null) diff --git a/mobile/android/base/GeckoApp.java b/mobile/android/base/GeckoApp.java index a73cdf973b7e..01f4238e9766 100644 --- a/mobile/android/base/GeckoApp.java +++ b/mobile/android/base/GeckoApp.java @@ -64,6 +64,7 @@ import android.hardware.SensorEventListener; import android.location.Location; import android.location.LocationListener; import android.net.Uri; +import android.os.Build; import android.os.Bundle; import android.os.Environment; import android.os.Handler; @@ -1220,6 +1221,14 @@ public abstract class GeckoApp enableStrictMode(); } + if (!isSupportedSDK()) { + // This build does not support the Android version of the device: Show an error and finish the app. + super.onCreate(savedInstanceState); + showSDKVersionError(); + finish(); + return; + } + // The clock starts...now. Better hurry! mJavaUiStartupTimer = new Telemetry.UptimeTimer("FENNEC_STARTUP_TIME_JAVAUI"); mGeckoReadyStartupTimer = new Telemetry.UptimeTimer("FENNEC_STARTUP_TIME_GECKOREADY"); @@ -2133,6 +2142,13 @@ public abstract class GeckoApp @Override public void onDestroy() { + if (!isSupportedSDK()) { + // This build does not support the Android version of the device: + // We did not initialize anything, so skip cleaning up. + super.onDestroy(); + return; + } + EventDispatcher.getInstance().unregisterGeckoThreadListener((GeckoEventListener)this, "Gecko:Ready", "Gecko:DelayedStartup", @@ -2235,6 +2251,16 @@ public abstract class GeckoApp } } + protected boolean isSupportedSDK() { + return Build.VERSION.SDK_INT >= Versions.MIN_SDK_VERSION && + Build.VERSION.SDK_INT <= Versions.MAX_SDK_VERSION; + } + + public void showSDKVersionError() { + final String message = getString(R.string.unsupported_sdk_version, Build.CPU_ABI, Build.VERSION.SDK_INT); + Toast.makeText(this, message, Toast.LENGTH_LONG).show(); + } + // Get a temporary directory, may return null public static File getTempDirectory() { File dir = GeckoApplication.get().getExternalFilesDir("temp"); diff --git a/mobile/android/base/locales/en-US/android_strings.dtd b/mobile/android/base/locales/en-US/android_strings.dtd index 1b8aacef748f..47989134b6a4 100644 --- a/mobile/android/base/locales/en-US/android_strings.dtd +++ b/mobile/android/base/locales/en-US/android_strings.dtd @@ -748,3 +748,8 @@ just addresses the organization to follow, e.g. "This site is run by " --> + + + diff --git a/mobile/android/base/strings.xml.in b/mobile/android/base/strings.xml.in index b2c7f3a3fb45..6f0732979817 100644 --- a/mobile/android/base/strings.xml.in +++ b/mobile/android/base/strings.xml.in @@ -595,4 +595,6 @@ &intent_uri_private_browsing_multiple_match_title; &devtools_auth_scan_header; + + &unsupported_sdk_version;