Bug 1342288 - Remove PresentationMediaPlayerManager. r?snorp
MozReview-Commit-ID: 4H46ahWTntR
--- a/mobile/android/app/build.gradle
+++ b/mobile/android/app/build.gradle
@@ -126,17 +126,16 @@ android {
}
if (!mozconfig.substs.MOZ_NATIVE_DEVICES) {
exclude 'org/mozilla/gecko/ChromeCastDisplay.java'
exclude 'org/mozilla/gecko/ChromeCastPlayer.java'
exclude 'org/mozilla/gecko/GeckoMediaPlayer.java'
exclude 'org/mozilla/gecko/GeckoPresentationDisplay.java'
exclude 'org/mozilla/gecko/MediaPlayerManager.java'
- exclude 'org/mozilla/gecko/PresentationMediaPlayerManager.java'
exclude 'org/mozilla/gecko/RemotePresentationService.java'
}
if (mozconfig.substs.MOZ_INSTALL_TRACKING) {
exclude 'org/mozilla/gecko/adjust/StubAdjustHelper.java'
} else {
exclude 'org/mozilla/gecko/adjust/AdjustHelper.java'
}
--- a/mobile/android/base/java/org/mozilla/gecko/MediaPlayerManager.java
+++ b/mobile/android/base/java/org/mozilla/gecko/MediaPlayerManager.java
@@ -38,22 +38,17 @@ public class MediaPlayerManager extends
private static MediaPlayerManager instance = null;
@ReflectionTarget
public static MediaPlayerManager getInstance() {
if (instance != null) {
return instance;
}
- if (Versions.feature17Plus) {
- instance = (MediaPlayerManager) new PresentationMediaPlayerManager();
- } else {
- instance = new MediaPlayerManager();
- }
- return instance;
+ return new MediaPlayerManager();
}
private static final String LOGTAG = "GeckoMediaPlayerManager";
protected boolean isPresentationMode = false; // Used to prevent mirroring when Presentation API is used.
@ReflectionTarget
public static final String MEDIA_PLAYER_TAG = "MPManagerFragment";
deleted file mode 100644
--- a/mobile/android/base/java/org/mozilla/gecko/PresentationMediaPlayerManager.java
+++ /dev/null
@@ -1,153 +0,0 @@
-/* -*- Mode: Java; c-basic-offset: 4; tab-width: 4; 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.annotation.TargetApi;
-import android.app.Presentation;
-import android.content.Context;
-import android.os.Bundle;
-import android.support.v7.media.MediaRouter;
-import android.util.Log;
-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;
-import org.mozilla.geckoview.GeckoSession;
-import org.mozilla.geckoview.GeckoView;
-
-/**
- * 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() {
- if (!Versions.feature17Plus) {
- throw new IllegalStateException(PresentationMediaPlayerManager.class.getSimpleName() +
- " does not support < API 17");
- }
- }
-
- @Override
- public void onStop() {
- super.onStop();
- if (presentation != null) {
- presentation.dismiss();
- presentation = null;
- }
- }
-
- @Override
- protected void updatePresentation() {
- if (mediaRouter == null) {
- return;
- }
-
- if (isPresentationMode) {
- return;
- }
-
- MediaRouter.RouteInfo route = mediaRouter.getSelectedRoute();
- Display display = route != null ? route.getPresentationDisplay() : null;
-
- if (display != null) {
- if ((presentation != null) && (presentation.getDisplay() != display)) {
- presentation.dismiss();
- presentation = null;
- }
-
- if (presentation == null) {
- final GeckoView geckoView = (GeckoView) getActivity().findViewById(R.id.layer_view);
- presentation = new GeckoPresentation(getActivity(), display, geckoView);
-
- try {
- presentation.show();
- } catch (WindowManager.InvalidDisplayException ex) {
- Log.w(LOGTAG, "Couldn't show presentation! Display was removed in "
- + "the meantime.", ex);
- presentation = null;
- }
- }
- } else if (presentation != null) {
- presentation.dismiss();
- presentation = null;
- }
- }
-
- @WrapForJNI(calledFrom = "ui")
- /* protected */ static native void invalidateAndScheduleComposite(GeckoSession session);
-
- @WrapForJNI(calledFrom = "ui")
- /* protected */ static native void addPresentationSurface(GeckoSession session, Surface surface);
-
- @WrapForJNI(calledFrom = "ui")
- /* protected */ static native void removePresentationSurface();
-
- private static final class GeckoPresentation extends Presentation {
- private SurfaceView mView;
- private GeckoView mGeckoView;
-
- public GeckoPresentation(Context context, Display display, GeckoView geckoView) {
- super(context, display);
-
- mGeckoView = geckoView;
- }
-
- @Override
- protected void onCreate(Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
-
- mView = new SurfaceView(getContext());
- setContentView(mView, new ViewGroup.LayoutParams(
- ViewGroup.LayoutParams.MATCH_PARENT,
- ViewGroup.LayoutParams.MATCH_PARENT));
- mView.getHolder().addCallback(new SurfaceListener(mGeckoView));
- }
- }
-
- private static final class SurfaceListener implements SurfaceHolder.Callback {
- private GeckoView mGeckoView;
-
- public SurfaceListener(GeckoView geckoView) {
- mGeckoView = geckoView;
- }
-
- @Override
- public void surfaceChanged(SurfaceHolder holder, int format, int width,
- int height) {
- // Surface changed so force a composite
- if (GeckoThread.isStateAtLeast(GeckoThread.State.PROFILE_READY)) {
- invalidateAndScheduleComposite(mGeckoView.getSession());
- }
- }
-
- @Override
- public void surfaceCreated(SurfaceHolder holder) {
- if (GeckoThread.isStateAtLeast(GeckoThread.State.PROFILE_READY)) {
- addPresentationSurface(mGeckoView.getSession(), holder.getSurface());
- }
- }
-
- @Override
- public void surfaceDestroyed(SurfaceHolder holder) {
- if (GeckoThread.isStateAtLeast(GeckoThread.State.PROFILE_READY)) {
- removePresentationSurface();
- }
- }
- }
-}
--- a/widget/android/fennec/FennecJNINatives.h
+++ b/widget/android/fennec/FennecJNINatives.h
@@ -78,41 +78,16 @@ 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>
-const JNINativeMethod PresentationMediaPlayerManager::Natives<Impl>::methods[] = {
-
- mozilla::jni::MakeNativeMethod<PresentationMediaPlayerManager::AddPresentationSurface_t>(
- mozilla::jni::NativeStub<PresentationMediaPlayerManager::AddPresentationSurface_t, Impl>
- ::template Wrap<&Impl::AddPresentationSurface>),
-
- mozilla::jni::MakeNativeMethod<PresentationMediaPlayerManager::InvalidateAndScheduleComposite_t>(
- 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,30 +169,16 @@ 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,85 +513,16 @@ 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 {
- typedef PresentationMediaPlayerManager Owner;
- typedef void ReturnType;
- typedef void SetterType;
- typedef mozilla::jni::Args<
- mozilla::jni::Object::Param,
- mozilla::jni::Object::Param> Args;
- static constexpr char name[] = "addPresentationSurface";
- static constexpr char signature[] =
- "(Lorg/mozilla/geckoview/GeckoSession;Landroid/view/Surface;)V";
- static const bool isStatic = true;
- static const mozilla::jni::ExceptionMode exceptionMode =
- mozilla::jni::ExceptionMode::ABORT;
- static const mozilla::jni::CallingThread callingThread =
- mozilla::jni::CallingThread::UI;
- static const mozilla::jni::DispatchTarget dispatchTarget =
- mozilla::jni::DispatchTarget::CURRENT;
- };
-
- struct InvalidateAndScheduleComposite_t {
- typedef PresentationMediaPlayerManager Owner;
- typedef void ReturnType;
- typedef void SetterType;
- typedef mozilla::jni::Args<
- mozilla::jni::Object::Param> Args;
- static constexpr char name[] = "invalidateAndScheduleComposite";
- static constexpr char signature[] =
- "(Lorg/mozilla/geckoview/GeckoSession;)V";
- static const bool isStatic = true;
- static const mozilla::jni::ExceptionMode exceptionMode =
- mozilla::jni::ExceptionMode::ABORT;
- static const mozilla::jni::CallingThread callingThread =
- mozilla::jni::CallingThread::UI;
- static const mozilla::jni::DispatchTarget dispatchTarget =
- mozilla::jni::DispatchTarget::CURRENT;
- };
-
- struct RemovePresentationSurface_t {
- typedef PresentationMediaPlayerManager Owner;
- typedef void ReturnType;
- typedef void SetterType;
- typedef mozilla::jni::Args<> Args;
- static constexpr char name[] = "removePresentationSurface";
- static constexpr char signature[] =
- "()V";
- static const bool isStatic = true;
- static const mozilla::jni::ExceptionMode exceptionMode =
- mozilla::jni::ExceptionMode::ABORT;
- static const mozilla::jni::CallingThread callingThread =
- mozilla::jni::CallingThread::UI;
- static const mozilla::jni::DispatchTarget dispatchTarget =
- mozilla::jni::DispatchTarget::CURRENT;
- };
-
- 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/nsWindow.cpp
+++ b/widget/android/nsWindow.cpp
@@ -1131,104 +1131,16 @@ public:
}
}
}
};
template<> const char
nsWindow::NativePtr<nsWindow::LayerViewSupport>::sName[] = "LayerViewSupport";
-#ifdef MOZ_NATIVE_DEVICES
-/* PresentationMediaPlayerManager native calls access inner nsWindow functionality so PMPMSupport is a child class of nsWindow */
-class nsWindow::PMPMSupport final
- : public PresentationMediaPlayerManager::Natives<PMPMSupport>
-{
- PMPMSupport() = delete;
-
- static LayerViewSupport* GetLayerViewSupport(jni::Object::Param aSession)
- {
- const auto& session = LayerSession::Ref::From(aSession);
-
- LayerSession::Compositor::LocalRef compositor = session->GetCompositor();
- if (!compositor) {
- return nullptr;
- }
-
- LayerViewSupport* const lvs = LayerViewSupport::FromNative(compositor);
- if (!lvs) {
- // There is a pending exception whenever FromNative returns nullptr.
- compositor.Env()->ExceptionClear();
- }
- return lvs;
- }
-
-public:
- static ANativeWindow* sWindow;
- static EGLSurface sSurface;
-
- static void InvalidateAndScheduleComposite(jni::Object::Param aSession)
- {
- LayerViewSupport* const lvs = GetLayerViewSupport(aSession);
- if (lvs) {
- lvs->SyncInvalidateAndScheduleComposite();
- }
- }
-
- static void AddPresentationSurface(const jni::Class::LocalRef& aCls,
- jni::Object::Param aSession,
- jni::Object::Param aSurface)
- {
- RemovePresentationSurface();
-
- LayerViewSupport* const lvs = GetLayerViewSupport(aSession);
- if (!lvs) {
- return;
- }
-
- ANativeWindow* const window = ANativeWindow_fromSurface(
- aCls.Env(), aSurface.Get());
- if (!window) {
- return;
- }
-
- sWindow = window;
-
- const bool wasAlreadyPaused = lvs->CompositorPaused();
- if (!wasAlreadyPaused) {
- lvs->SyncPauseCompositor();
- }
-
- if (sSurface) {
- // Destroy the EGL surface! The compositor is paused so it should
- // be okay to destroy the surface here.
- mozilla::gl::GLContextProvider::DestroyEGLSurface(sSurface);
- sSurface = nullptr;
- }
-
- if (!wasAlreadyPaused) {
- lvs->SyncResumeCompositor();
- }
-
- lvs->SyncInvalidateAndScheduleComposite();
- }
-
- static void RemovePresentationSurface()
- {
- if (sWindow) {
- ANativeWindow_release(sWindow);
- sWindow = nullptr;
- }
- }
-};
-
-ANativeWindow* nsWindow::PMPMSupport::sWindow;
-EGLSurface nsWindow::PMPMSupport::sSurface;
-#endif
-
-
nsWindow::GeckoViewSupport::~GeckoViewSupport()
{
// Disassociate our GeckoEditable instance with our native object.
if (window.mEditableSupport) {
window.mEditableSupport.Detach();
window.mEditableParent = nullptr;
}
@@ -1385,21 +1297,16 @@ nsWindow::GeckoViewSupport::AttachEditab
}
void
nsWindow::InitNatives()
{
nsWindow::GeckoViewSupport::Base::Init();
nsWindow::LayerViewSupport::Init();
nsWindow::NPZCSupport::Init();
-#ifdef MOZ_NATIVE_DEVICES
- if (jni::IsFennec()) {
- nsWindow::PMPMSupport::Init();
- }
-#endif
GeckoEditableSupport::Init();
}
nsWindow*
nsWindow::TopWindow()
{
if (!gTopLevelWindows.IsEmpty())
@@ -2070,38 +1977,25 @@ nsWindow::GetNativeData(uint32_t aDataTy
return NS_ONLY_ONE_NATIVE_IME_CONTEXT;
}
case NS_JAVA_SURFACE:
if (NativePtr<LayerViewSupport>::Locked lvs{mLayerViewSupport}) {
return lvs->GetSurface().Get();
}
return nullptr;
-
-#ifdef MOZ_NATIVE_DEVICES
- case NS_PRESENTATION_WINDOW:
- return PMPMSupport::sWindow;
-
- case NS_PRESENTATION_SURFACE:
- return PMPMSupport::sSurface;
-#endif
}
return nullptr;
}
void
nsWindow::SetNativeData(uint32_t aDataType, uintptr_t aVal)
{
switch (aDataType) {
-#ifdef MOZ_NATIVE_DEVICES
- case NS_PRESENTATION_SURFACE:
- PMPMSupport::sSurface = reinterpret_cast<EGLSurface>(aVal);
- break;
-#endif
}
}
void
nsWindow::DispatchHitTest(const WidgetTouchEvent& aEvent)
{
if (aEvent.mMessage == eTouchStart && aEvent.mTouches.Length() == 1) {
// Since touch events don't get retargeted by PositionedEventTargeting.cpp
--- a/widget/android/nsWindow.h
+++ b/widget/android/nsWindow.h
@@ -188,21 +188,16 @@ private:
class GeckoViewSupport;
// Object that implements native GeckoView calls and associated states.
// nullptr for nsWindows that were not opened from GeckoView.
// Because other objects get destroyed in the mGeckOViewSupport destructor,
// keep it last in the list, so its destructor is called first.
mozilla::UniquePtr<GeckoViewSupport> mGeckoViewSupport;
-#ifdef MOZ_NATIVE_DEVICES
- // Class that implements native PresentationMediaPlayerManager calls.
- class PMPMSupport;
-#endif
-
mozilla::Atomic<bool, mozilla::ReleaseAcquire> mContentDocumentDisplayed;
public:
static nsWindow* TopWindow();
static mozilla::Modifiers GetModifiers(int32_t aMetaState);
static mozilla::TimeStamp GetEventTimeStamp(int64_t aEventTime);