mirror of
https://github.com/mozilla/gecko-dev.git
synced 2025-11-12 14:20:14 +02:00
I replaced the compile-time ANDROID_PACKAGE_NAME with the run-time context.getPackageName() for two reasons: 1) I claim this is more correct. It's hard to imagine Fennec working with ANDROID_PACKAGE_NAME != context.getPackageName(), but right here we should use the run-time, not the build-time state. 2) GeckoLoader is part of GeckoView, and as such it shouldn't assume anything about the package it's running as. GeckoView consumers may ship for multiple architectures, so we shouldn't assume anything about the build-time architecture, but the reference to MOZ_CPU_ABI is purely diagnostic. There are substantive changes to make here; we'll cross that bridge some other time. --HG-- extra : source : 48fc328377d41596900fa924b21378ba65a0df1f
275 lines
9.7 KiB
Java
275 lines
9.7 KiB
Java
//#filter substitution
|
|
/* -*- Mode: Java; c-basic-offset: 4; tab-width: 20; indent-tabs-mode: nil; -*-
|
|
* This Source Code Form is subject to the terms of the Mozilla Public
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
|
|
|
package org.mozilla.gecko;
|
|
|
|
import android.os.Build;
|
|
|
|
import java.lang.annotation.Retention;
|
|
import java.lang.annotation.RetentionPolicy;
|
|
|
|
/**
|
|
* A collection of constants that pertain to the build and runtime state of the
|
|
* application. Typically these are sourced from build-time definitions (see
|
|
* Makefile.in). This is a Java-side substitute for nsIXULAppInfo, amongst
|
|
* other things.
|
|
*
|
|
* See also SysInfo.java, which includes some of the values available from
|
|
* nsSystemInfo inside Gecko.
|
|
*/
|
|
// Normally, we'd annotate with @RobocopTarget. Since AppConstants is compiled
|
|
// before RobocopTarget, we instead add o.m.g.AppConstants directly to the
|
|
// Proguard configuration.
|
|
public class AppConstants {
|
|
public static final String ANDROID_PACKAGE_NAME = "@ANDROID_PACKAGE_NAME@";
|
|
public static final String MANGLED_ANDROID_PACKAGE_NAME = "@MANGLED_ANDROID_PACKAGE_NAME@";
|
|
|
|
/**
|
|
* Encapsulates access to compile-time version definitions, allowing
|
|
* for dead code removal for particular APKs.
|
|
*/
|
|
public static final class Versions {
|
|
public static final int MIN_SDK_VERSION = @MOZ_ANDROID_MIN_SDK_VERSION@;
|
|
public static final int MAX_SDK_VERSION =
|
|
//#ifdef MOZ_ANDROID_MAX_SDK_VERSION
|
|
@MOZ_ANDROID_MAX_SDK_VERSION@;
|
|
//#else
|
|
999;
|
|
//#endif
|
|
|
|
/*
|
|
* The SDK_INT >= N check can only pass if our MAX_SDK_VERSION is
|
|
* _greater than or equal_ to that number, because otherwise we
|
|
* won't be installed on the device.
|
|
*
|
|
* If MIN_SDK_VERSION is greater than or equal to the number, there
|
|
* is no need to do the runtime check.
|
|
*/
|
|
public static final boolean feature10Plus = MIN_SDK_VERSION >= 10 || (MAX_SDK_VERSION >= 10 && Build.VERSION.SDK_INT >= 10);
|
|
public static final boolean feature11Plus = MIN_SDK_VERSION >= 11 || (MAX_SDK_VERSION >= 11 && Build.VERSION.SDK_INT >= 11);
|
|
public static final boolean feature12Plus = MIN_SDK_VERSION >= 12 || (MAX_SDK_VERSION >= 12 && Build.VERSION.SDK_INT >= 12);
|
|
public static final boolean feature14Plus = MIN_SDK_VERSION >= 14 || (MAX_SDK_VERSION >= 14 && Build.VERSION.SDK_INT >= 14);
|
|
public static final boolean feature15Plus = MIN_SDK_VERSION >= 15 || (MAX_SDK_VERSION >= 15 && Build.VERSION.SDK_INT >= 15);
|
|
public static final boolean feature16Plus = MIN_SDK_VERSION >= 16 || (MAX_SDK_VERSION >= 16 && Build.VERSION.SDK_INT >= 16);
|
|
public static final boolean feature17Plus = MIN_SDK_VERSION >= 17 || (MAX_SDK_VERSION >= 17 && Build.VERSION.SDK_INT >= 17);
|
|
public static final boolean feature19Plus = MIN_SDK_VERSION >= 19 || (MAX_SDK_VERSION >= 19 && Build.VERSION.SDK_INT >= 19);
|
|
public static final boolean feature21Plus = MIN_SDK_VERSION >= 21 || (MAX_SDK_VERSION >= 21 && Build.VERSION.SDK_INT >= 21);
|
|
|
|
/*
|
|
* If our MIN_SDK_VERSION is 14 or higher, we must be an ICS device.
|
|
* If our MAX_SDK_VERSION is lower than ICS, we must not be an ICS device.
|
|
* Otherwise, we need a range check.
|
|
*/
|
|
public static final boolean preLollipop = MAX_SDK_VERSION < 21 || (MIN_SDK_VERSION < 21 && Build.VERSION.SDK_INT < 21);
|
|
public static final boolean preJBMR2 = MAX_SDK_VERSION < 18 || (MIN_SDK_VERSION < 18 && Build.VERSION.SDK_INT < 18);
|
|
public static final boolean preJB = MAX_SDK_VERSION < 16 || (MIN_SDK_VERSION < 16 && Build.VERSION.SDK_INT < 16);
|
|
public static final boolean preICS = MAX_SDK_VERSION < 14 || (MIN_SDK_VERSION < 14 && Build.VERSION.SDK_INT < 14);
|
|
public static final boolean preHCMR2 = MAX_SDK_VERSION < 13 || (MIN_SDK_VERSION < 13 && Build.VERSION.SDK_INT < 13);
|
|
public static final boolean preHCMR1 = MAX_SDK_VERSION < 12 || (MIN_SDK_VERSION < 12 && Build.VERSION.SDK_INT < 12);
|
|
public static final boolean preHC = MAX_SDK_VERSION < 11 || (MIN_SDK_VERSION < 11 && Build.VERSION.SDK_INT < 11);
|
|
}
|
|
|
|
/**
|
|
* The name of the Java class that launches the browser.
|
|
*/
|
|
public static final String BROWSER_INTENT_CLASS_NAME = "org.mozilla.gecko.BrowserApp";
|
|
public static final String SEARCH_INTENT_CLASS_NAME = "org.mozilla.search.SearchActivity";
|
|
|
|
public static final String GRE_MILESTONE = "@GRE_MILESTONE@";
|
|
|
|
public static final String MOZ_APP_ABI = "@MOZ_APP_ABI@";
|
|
public static final String MOZ_APP_BASENAME = "@MOZ_APP_BASENAME@";
|
|
|
|
// For the benefit of future archaeologists: APP_BUILDID and
|
|
// MOZ_APP_BUILDID are *exactly* the same.
|
|
// GRE_BUILDID is exactly the same unless you're running on XULRunner,
|
|
// which is never the case on Android.
|
|
public static final String MOZ_APP_BUILDID = "@MOZ_APP_BUILDID@";
|
|
public static final String MOZ_APP_ID = "@MOZ_APP_ID@";
|
|
public static final String MOZ_APP_NAME = "@MOZ_APP_NAME@";
|
|
public static final String MOZ_APP_VENDOR = "@MOZ_APP_VENDOR@";
|
|
public static final String MOZ_APP_VERSION = "@MOZ_APP_VERSION@";
|
|
|
|
// MOZILLA_VERSION is already quoted when it gets substituted in. If we
|
|
// add additional quotes we end up with ""x.y"", which is a syntax error.
|
|
public static final String MOZILLA_VERSION = @MOZILLA_VERSION@;
|
|
|
|
public static final String MOZ_STUMBLER_API_KEY =
|
|
//#ifdef MOZ_ANDROID_MLS_STUMBLER
|
|
"@MOZ_STUMBLER_API_KEY@";
|
|
//#else
|
|
null;
|
|
//#endif
|
|
public static final boolean MOZ_STUMBLER_BUILD_TIME_ENABLED = (MOZ_STUMBLER_API_KEY != null);
|
|
|
|
public static final String MOZ_CHILD_PROCESS_NAME = "@MOZ_CHILD_PROCESS_NAME@";
|
|
public static final String MOZ_UPDATE_CHANNEL = "@MOZ_UPDATE_CHANNEL@";
|
|
public static final String OMNIJAR_NAME = "@OMNIJAR_NAME@";
|
|
public static final String OS_TARGET = "@OS_TARGET@";
|
|
public static final String TARGET_XPCOM_ABI = @TARGET_XPCOM_ABI@;
|
|
|
|
public static final String USER_AGENT_BOT_LIKE = "Redirector/" + AppConstants.MOZ_APP_VERSION +
|
|
" (Android; rv:" + AppConstants.MOZ_APP_VERSION + ")";
|
|
|
|
public static final String USER_AGENT_FENNEC_MOBILE = "Mozilla/5.0 (Android; Mobile; rv:" +
|
|
AppConstants.MOZ_APP_VERSION + ") Gecko/" +
|
|
AppConstants.MOZ_APP_VERSION + " Firefox/" +
|
|
AppConstants.MOZ_APP_VERSION;
|
|
|
|
public static final String USER_AGENT_FENNEC_TABLET = "Mozilla/5.0 (Android; Tablet; rv:" +
|
|
AppConstants.MOZ_APP_VERSION + ") Gecko/" +
|
|
AppConstants.MOZ_APP_VERSION + " Firefox/" +
|
|
AppConstants.MOZ_APP_VERSION;
|
|
|
|
public static final int MOZ_MIN_CPU_VERSION = @MOZ_MIN_CPU_VERSION@;
|
|
|
|
public static final boolean MOZ_ANDROID_ANR_REPORTER =
|
|
//#ifdef MOZ_ANDROID_ANR_REPORTER
|
|
true;
|
|
//#else
|
|
false;
|
|
//#endif
|
|
|
|
public static final String MOZ_PKG_SPECIAL =
|
|
//#ifdef MOZ_PKG_SPECIAL
|
|
"@MOZ_PKG_SPECIAL@";
|
|
//#else
|
|
null;
|
|
//#endif
|
|
|
|
/**
|
|
* Whether this APK was built with constrained resources --
|
|
* no xhdpi+ images, for example.
|
|
*/
|
|
public static final boolean MOZ_ANDROID_RESOURCE_CONSTRAINED =
|
|
//#ifdef MOZ_ANDROID_RESOURCE_CONSTRAINED
|
|
true;
|
|
//#else
|
|
false;
|
|
//#endif
|
|
|
|
public static final boolean MOZ_SERVICES_HEALTHREPORT =
|
|
//#ifdef MOZ_SERVICES_HEALTHREPORT
|
|
true;
|
|
//#else
|
|
false;
|
|
//#endif
|
|
|
|
public static final boolean MOZ_TELEMETRY_ON_BY_DEFAULT =
|
|
//#ifdef MOZ_TELEMETRY_ON_BY_DEFAULT
|
|
true;
|
|
//#else
|
|
false;
|
|
//#endif
|
|
|
|
public static final String TELEMETRY_PREF_NAME =
|
|
"toolkit.telemetry.enabled";
|
|
|
|
public static final boolean MOZ_TELEMETRY_REPORTING =
|
|
//#ifdef MOZ_TELEMETRY_REPORTING
|
|
true;
|
|
//#else
|
|
false;
|
|
//#endif
|
|
|
|
public static final boolean MOZ_CRASHREPORTER =
|
|
//#if MOZ_CRASHREPORTER
|
|
true;
|
|
//#else
|
|
false;
|
|
//#endif
|
|
|
|
public static final boolean MOZ_DATA_REPORTING =
|
|
//#ifdef MOZ_DATA_REPORTING
|
|
true;
|
|
//#else
|
|
false;
|
|
//#endif
|
|
|
|
public static final boolean MOZ_LOCALE_SWITCHER =
|
|
//#ifdef MOZ_LOCALE_SWITCHER
|
|
true;
|
|
//#else
|
|
false;
|
|
//#endif
|
|
|
|
public static final boolean MOZ_UPDATER =
|
|
//#ifdef MOZ_UPDATER
|
|
true;
|
|
//#else
|
|
false;
|
|
//#endif
|
|
|
|
public static final boolean MOZ_WEBSMS_BACKEND =
|
|
//#ifdef MOZ_WEBSMS_BACKEND
|
|
true;
|
|
//#else
|
|
false;
|
|
//#endif
|
|
|
|
// Android Beam is only supported on API14+, so we don't even bother building
|
|
// it if this APK doesn't include API14 support.
|
|
public static final boolean MOZ_ANDROID_BEAM =
|
|
//#ifdef MOZ_ANDROID_BEAM
|
|
Versions.feature14Plus;
|
|
//#else
|
|
false;
|
|
//#endif
|
|
|
|
public static final boolean MOZ_ANDROID_APZ =
|
|
//#ifdef MOZ_ANDROID_APZ
|
|
true;
|
|
//#else
|
|
false;
|
|
//#endif
|
|
|
|
// See this wiki page for more details about channel specific build defines:
|
|
// https://wiki.mozilla.org/Platform/Channel-specific_build_defines
|
|
public static final boolean RELEASE_BUILD =
|
|
//#ifdef RELEASE_BUILD
|
|
true;
|
|
//#else
|
|
false;
|
|
//#endif
|
|
|
|
public static final boolean DEBUG_BUILD =
|
|
//#ifdef MOZ_DEBUG
|
|
true;
|
|
//#else
|
|
false;
|
|
//#endif
|
|
|
|
public static final boolean MOZ_MEDIA_PLAYER =
|
|
//#ifdef MOZ_NATIVE_DEVICES
|
|
true;
|
|
//#else
|
|
false;
|
|
//#endif
|
|
|
|
// Official corresponds, roughly, to whether this build is performed on
|
|
// Mozilla's continuous integration infrastructure. You should disable
|
|
// developer-only functionality when this flag is set.
|
|
public static final boolean MOZILLA_OFFICIAL =
|
|
//#ifdef MOZILLA_OFFICIAL
|
|
true;
|
|
//#else
|
|
false;
|
|
//#endif
|
|
|
|
public static final boolean ANDROID_DOWNLOADS_INTEGRATION =
|
|
//#ifdef MOZ_ANDROID_DOWNLOADS_INTEGRATION
|
|
AppConstants.Versions.feature12Plus;
|
|
//#else
|
|
false;
|
|
//#endif
|
|
|
|
public static final boolean MOZ_LINKER_EXTRACT =
|
|
//#ifdef MOZ_LINKER_EXTRACT
|
|
true;
|
|
//#else
|
|
false;
|
|
//#endif
|
|
}
|