mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 1245236 - (Part 1) Move isSupportedSystem() from GeckoApp to HardwareUtils. r=rnewman
MozReview-Commit-ID: 6p7UQZBSt0C
This commit is contained in:
parent
e40f02b580
commit
904e3413d0
@ -557,7 +557,7 @@ public class BrowserApp extends GeckoApp
|
||||
|
||||
@Override
|
||||
public void onCreate(Bundle savedInstanceState) {
|
||||
if (!isSupportedSystem()) {
|
||||
if (!HardwareUtils.isSupportedSystem()) {
|
||||
// This build does not support the Android version of the device; Exit early.
|
||||
super.onCreate(savedInstanceState);
|
||||
return;
|
||||
@ -1345,7 +1345,7 @@ public class BrowserApp extends GeckoApp
|
||||
|
||||
@Override
|
||||
public void onDestroy() {
|
||||
if (!isSupportedSystem()) {
|
||||
if (!HardwareUtils.isSupportedSystem()) {
|
||||
// This build does not support the Android version of the device; Exit early.
|
||||
super.onDestroy();
|
||||
return;
|
||||
|
@ -1162,7 +1162,7 @@ public abstract class GeckoApp
|
||||
enableStrictMode();
|
||||
}
|
||||
|
||||
if (!isSupportedSystem()) {
|
||||
if (!HardwareUtils.isSupportedSystem()) {
|
||||
// This build does not support the Android version of the device: Show an error and finish the app.
|
||||
super.onCreate(savedInstanceState);
|
||||
showSDKVersionError();
|
||||
@ -2085,7 +2085,7 @@ public abstract class GeckoApp
|
||||
|
||||
@Override
|
||||
public void onDestroy() {
|
||||
if (!isSupportedSystem()) {
|
||||
if (!HardwareUtils.isSupportedSystem()) {
|
||||
// This build does not support the Android version of the device:
|
||||
// We did not initialize anything, so skip cleaning up.
|
||||
super.onDestroy();
|
||||
@ -2193,32 +2193,6 @@ public abstract class GeckoApp
|
||||
}
|
||||
}
|
||||
|
||||
protected boolean isSupportedSystem() {
|
||||
if (Build.VERSION.SDK_INT < Versions.MIN_SDK_VERSION ||
|
||||
Build.VERSION.SDK_INT > Versions.MAX_SDK_VERSION) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// See http://developer.android.com/ndk/guides/abis.html
|
||||
boolean isSystemARM = Build.CPU_ABI != null && Build.CPU_ABI.startsWith("arm");
|
||||
boolean isSystemX86 = Build.CPU_ABI != null && Build.CPU_ABI.startsWith("x86");
|
||||
|
||||
boolean isAppARM = AppConstants.ANDROID_CPU_ARCH.startsWith("arm");
|
||||
boolean isAppX86 = AppConstants.ANDROID_CPU_ARCH.startsWith("x86");
|
||||
|
||||
// Only reject known incompatible ABIs. Better safe than sorry.
|
||||
if ((isSystemX86 && isAppARM) || (isSystemARM && isAppX86)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if ((isSystemX86 && isAppX86) || (isSystemARM && isAppARM)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
Log.w(LOGTAG, "Unknown app/system ABI combination: " + AppConstants.MOZ_APP_ABI + " / " + Build.CPU_ABI);
|
||||
return true;
|
||||
}
|
||||
|
||||
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();
|
||||
|
@ -5,6 +5,7 @@
|
||||
|
||||
package org.mozilla.gecko.util;
|
||||
|
||||
import org.mozilla.gecko.AppConstants;
|
||||
import org.mozilla.gecko.SysInfo;
|
||||
|
||||
import android.content.Context;
|
||||
@ -97,4 +98,33 @@ public final class HardwareUtils {
|
||||
|
||||
return memSize < LOW_MEMORY_THRESHOLD_MB;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return false if the current system is not supported (e.g. APK/system ABI mismatch).
|
||||
*/
|
||||
public static boolean isSupportedSystem() {
|
||||
if (Build.VERSION.SDK_INT < AppConstants.Versions.MIN_SDK_VERSION ||
|
||||
Build.VERSION.SDK_INT > AppConstants.Versions.MAX_SDK_VERSION) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// See http://developer.android.com/ndk/guides/abis.html
|
||||
boolean isSystemARM = Build.CPU_ABI != null && Build.CPU_ABI.startsWith("arm");
|
||||
boolean isSystemX86 = Build.CPU_ABI != null && Build.CPU_ABI.startsWith("x86");
|
||||
|
||||
boolean isAppARM = AppConstants.ANDROID_CPU_ARCH.startsWith("arm");
|
||||
boolean isAppX86 = AppConstants.ANDROID_CPU_ARCH.startsWith("x86");
|
||||
|
||||
// Only reject known incompatible ABIs. Better safe than sorry.
|
||||
if ((isSystemX86 && isAppARM) || (isSystemARM && isAppX86)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if ((isSystemX86 && isAppX86) || (isSystemARM && isAppARM)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
Log.w(LOGTAG, "Unknown app/system ABI combination: " + AppConstants.MOZ_APP_ABI + " / " + Build.CPU_ABI);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user