Bug 1119915 - Show toast if APK API range does not match device. r=rnewman

--HG--
extra : commitid : 3iwwga4cugN
extra : rebase_source : 4d0cc5bc73a0be966cf6d9a2da5768fba319ac58
This commit is contained in:
Sebastian Kaspari 2015-11-03 14:09:41 +00:00
Родитель 332295eb06
Коммит 4597e1161a
4 изменённых файлов: 45 добавлений и 0 удалений

Просмотреть файл

@ -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)

Просмотреть файл

@ -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");

Просмотреть файл

@ -748,3 +748,8 @@ just addresses the organization to follow, e.g. "This site is run by " -->
<!ENTITY bookmarks_restricted_support2 "Firefox Help and Support for restricted profiles on Android tablets">
<!-- LOCALIZATION NOTE (bookmarks_restricted_webmaker):link title for https://webmaker.org -->
<!ENTITY bookmarks_restricted_webmaker "Learn the Web: Mozilla Webmaker">
<!-- LOCALIZATION NOTE (unsupported_sdk_version): The user installed a build of this app that does not support
the Android version of this device. the formatS1 is replaced by the CPU ABI (e.g., ARMv7); the formatS2 is
replaced by the Android OS version (e.g., 14)-->
<!ENTITY unsupported_sdk_version "Sorry! This &brandShortName; won\'t work on this device (&formatS1;, &formatS2;). Please download the correct version.">

Просмотреть файл

@ -595,4 +595,6 @@
<string name="intent_uri_private_browsing_multiple_match_title">&intent_uri_private_browsing_multiple_match_title;</string>
<string name="devtools_auth_scan_header">&devtools_auth_scan_header;</string>
<string name="unsupported_sdk_version">&unsupported_sdk_version;</string>
</resources>