Bug 736073 - Implement power state support for Flash on Android r=blassey

This commit is contained in:
James Willcox 2012-06-06 22:39:18 -04:00
parent f4fb203aac
commit 9d981715b0
3 changed files with 24 additions and 2 deletions

View File

@ -63,7 +63,9 @@ jclass anp_system_loadJavaClass(NPP instance, const char* className)
void anp_system_setPowerState(NPP instance, ANPPowerState powerState)
{
NOT_IMPLEMENTED();
nsNPAPIPluginInstance* pinst = static_cast<nsNPAPIPluginInstance*>(instance->ndata);
pinst->SetWakeLock(powerState == kScreenOn_ANPPowerState);
}
void InitSystemInterface(ANPSystemInterfaceV0 *i) {

View File

@ -4,7 +4,7 @@
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#ifdef MOZ_WIDGET_ANDROID
// For ScreenOrientation.h
// For ScreenOrientation.h and Hal.h
#include "base/basictypes.h"
#endif
@ -41,6 +41,7 @@
#include "mozilla/CondVar.h"
#include "AndroidBridge.h"
#include "mozilla/dom/ScreenOrientation.h"
#include "mozilla/Hal.h"
class PluginEventRunnable : public nsRunnable
{
@ -81,6 +82,7 @@ nsNPAPIPluginInstance::nsNPAPIPluginInstance()
mANPDrawingModel(0),
mOnScreen(true),
mFullScreenOrientation(dom::eScreenOrientation_LandscapePrimary),
mWakeLocked(false),
#endif
mRunning(NOT_STARTED),
mWindowless(false),
@ -115,6 +117,10 @@ nsNPAPIPluginInstance::~nsNPAPIPluginInstance()
PR_Free((void *)mMIMEType);
mMIMEType = nsnull;
}
#if MOZ_WIDGET_ANDROID
SetWakeLock(false);
#endif
}
void
@ -788,6 +794,17 @@ void nsNPAPIPluginInstance::PopPostedEvent(PluginEventRunnable* r)
mPostedEvents.RemoveElement(r);
}
void nsNPAPIPluginInstance::SetWakeLock(bool aLocked)
{
if (aLocked == mWakeLocked)
return;
mWakeLocked = aLocked;
hal::ModifyWakeLock(NS_LITERAL_STRING("nsNPAPIPluginInstance"),
mWakeLocked ? hal::WAKE_LOCK_ADD_ONE : hal::WAKE_LOCK_REMOVE_ONE,
hal::WAKE_LOCK_NO_CHANGE);
}
#endif
nsresult nsNPAPIPluginInstance::GetDrawingModel(PRInt32* aModel)

View File

@ -140,6 +140,8 @@ public:
// difficult to include that here
PRUint32 FullScreenOrientation() { return mFullScreenOrientation; }
void SetFullScreenOrientation(PRUint32 orientation) { mFullScreenOrientation = orientation; }
void SetWakeLock(bool aLock);
#endif
nsresult NewStreamListener(const char* aURL, void* notifyData,
@ -226,6 +228,7 @@ protected:
void PopPostedEvent(PluginEventRunnable* r);
PRUint32 mFullScreenOrientation;
bool mWakeLocked;
#endif
enum {