Bug 1419581 - Part 2: Guard media Fennec JNI primitives with MOZ_NATIVE_DEVICES. r=jchen
MozReview-Commit-ID: 3NWZ6BL5Tlr
--- a/mobile/android/base/Makefile.in
+++ b/mobile/android/base/Makefile.in
@@ -551,17 +551,22 @@ endif
# GeneratedJNIWrappers.cpp target also generates
# GeneratedJNIWrappers.h and GeneratedJNINatives.h
# FennecJNIWrappers.cpp target also generates
# FennecJNIWrappers.h and FennecJNINatives.h
# List of build flags used by auto-generated JNI bindings (through the
# @BuildFlag annotation in Java). For example, add a "MOZ_FOO \" line to this
# list to support @BuildFlag(MOZ_FOO).
+#
+# Be sure that the given BUILD_FLAG is exposed to the generated JNI
+# wrapper compilation environment! This might mean adding a local
+# DEFINE in /widget/android and/or /widget/android/fennec.
BINDING_BUILD_FLAGS = \
+ MOZ_NATIVE_DEVICES \
$(NULL)
# Preprocess a JNI binding file using the build flags defined above.
# $(1): JNI binding file to preprocess.
preprocess-binding = ($(call py_action,preprocessor, \
$(foreach flag,$(BINDING_BUILD_FLAGS),$(if $($(flag)),-D$(flag))) \
-DMOZ_PREPROCESSOR $(1)) || echo $(1))
--- a/mobile/android/base/java/org/mozilla/gecko/PresentationMediaPlayerManager.java
+++ b/mobile/android/base/java/org/mozilla/gecko/PresentationMediaPlayerManager.java
@@ -15,21 +15,23 @@ import android.view.Display;
import android.view.Surface;
import android.view.SurfaceHolder;
import android.view.SurfaceView;
import android.view.ViewGroup;
import android.view.WindowManager;
import org.mozilla.gecko.AppConstants.Versions;
+import org.mozilla.gecko.annotation.BuildFlag;
import org.mozilla.gecko.annotation.WrapForJNI;
/**
* A MediaPlayerManager with API 17+ Presentation support.
*/
+@BuildFlag("MOZ_NATIVE_DEVICES")
@TargetApi(17)
public class PresentationMediaPlayerManager extends MediaPlayerManager {
private static final String LOGTAG = "Gecko" + PresentationMediaPlayerManager.class.getSimpleName();
private GeckoPresentation presentation;
public PresentationMediaPlayerManager() {
--- a/widget/android/fennec/FennecJNINatives.h
+++ b/widget/android/fennec/FennecJNINatives.h
@@ -78,16 +78,17 @@ public:
template<class Impl>
const JNINativeMethod MemoryMonitor::Natives<Impl>::methods[] = {
mozilla::jni::MakeNativeMethod<MemoryMonitor::DispatchMemoryPressure_t>(
mozilla::jni::NativeStub<MemoryMonitor::DispatchMemoryPressure_t, Impl>
::template Wrap<&Impl::DispatchMemoryPressure>)
};
+#ifdef MOZ_NATIVE_DEVICES
template<class Impl>
class PresentationMediaPlayerManager::Natives : public mozilla::jni::NativeImpl<PresentationMediaPlayerManager, Impl>
{
public:
static const JNINativeMethod methods[3];
};
template<class Impl>
@@ -101,16 +102,17 @@ const JNINativeMethod PresentationMediaP
mozilla::jni::NativeStub<PresentationMediaPlayerManager::InvalidateAndScheduleComposite_t, Impl>
::template Wrap<&Impl::InvalidateAndScheduleComposite>),
mozilla::jni::MakeNativeMethod<PresentationMediaPlayerManager::RemovePresentationSurface_t>(
mozilla::jni::NativeStub<PresentationMediaPlayerManager::RemovePresentationSurface_t, Impl>
::template Wrap<&Impl::RemovePresentationSurface>)
};
+#endif // MOZ_NATIVE_DEVICES
template<class Impl>
class Telemetry::Natives : public mozilla::jni::NativeImpl<Telemetry, Impl>
{
public:
static const JNINativeMethod methods[5];
};
template<class Impl>
--- a/widget/android/fennec/FennecJNIWrappers.cpp
+++ b/widget/android/fennec/FennecJNIWrappers.cpp
@@ -169,28 +169,30 @@ auto GlobalHistory::SetURITitle(mozilla:
}
const char MemoryMonitor::name[] =
"org/mozilla/gecko/MemoryMonitor";
constexpr char MemoryMonitor::DispatchMemoryPressure_t::name[];
constexpr char MemoryMonitor::DispatchMemoryPressure_t::signature[];
+#ifdef MOZ_NATIVE_DEVICES
const char PresentationMediaPlayerManager::name[] =
"org/mozilla/gecko/PresentationMediaPlayerManager";
constexpr char PresentationMediaPlayerManager::AddPresentationSurface_t::name[];
constexpr char PresentationMediaPlayerManager::AddPresentationSurface_t::signature[];
constexpr char PresentationMediaPlayerManager::InvalidateAndScheduleComposite_t::name[];
constexpr char PresentationMediaPlayerManager::InvalidateAndScheduleComposite_t::signature[];
constexpr char PresentationMediaPlayerManager::RemovePresentationSurface_t::name[];
constexpr char PresentationMediaPlayerManager::RemovePresentationSurface_t::signature[];
+#endif // MOZ_NATIVE_DEVICES
const char Telemetry::name[] =
"org/mozilla/gecko/Telemetry";
constexpr char Telemetry::AddHistogram_t::name[];
constexpr char Telemetry::AddHistogram_t::signature[];
constexpr char Telemetry::AddKeyedHistogram_t::name[];
constexpr char Telemetry::AddKeyedHistogram_t::signature[];
--- a/widget/android/fennec/FennecJNIWrappers.h
+++ b/widget/android/fennec/FennecJNIWrappers.h
@@ -513,16 +513,17 @@ public:
};
static const mozilla::jni::CallingThread callingThread =
mozilla::jni::CallingThread::UI;
template<class Impl> class Natives;
};
+#ifdef MOZ_NATIVE_DEVICES
class PresentationMediaPlayerManager : public mozilla::jni::ObjectBase<PresentationMediaPlayerManager>
{
public:
static const char name[];
explicit PresentationMediaPlayerManager(const Context& ctx) : ObjectBase<PresentationMediaPlayerManager>(ctx) {}
struct AddPresentationSurface_t {
@@ -580,16 +581,17 @@ public:
};
static const mozilla::jni::CallingThread callingThread =
mozilla::jni::CallingThread::UI;
template<class Impl> class Natives;
};
+#endif // MOZ_NATIVE_DEVICES
class Telemetry : public mozilla::jni::ObjectBase<Telemetry>
{
public:
static const char name[];
explicit Telemetry(const Context& ctx) : ObjectBase<Telemetry>(ctx) {}
struct AddHistogram_t {
--- a/widget/android/fennec/moz.build
+++ b/widget/android/fennec/moz.build
@@ -17,8 +17,11 @@ UNIFIED_SOURCES += [
]
FINAL_LIBRARY = 'xul'
LOCAL_INCLUDES += [
'/widget',
'/widget/android',
]
+
+if CONFIG['MOZ_NATIVE_DEVICES']:
+ DEFINES['MOZ_NATIVE_DEVICES'] = True
--- a/widget/android/moz.build
+++ b/widget/android/moz.build
@@ -73,10 +73,12 @@ LOCAL_INCLUDES += [
'/widget',
'/xpcom/threads',
]
CXXFLAGS += ['-Wno-error=shadow']
OS_LIBS += ['android']
+if CONFIG['MOZ_NATIVE_DEVICES']:
+ DEFINES['MOZ_NATIVE_DEVICES'] = True
+
#DEFINES['DEBUG_WIDGETS'] = True
-