mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-08 19:04:45 +00:00
Bug 797798: System App can't Receive Sensor Event During Early Suspend State. r=jlebar
This commit is contained in:
parent
84f5850fcd
commit
3c5f85b5ff
@ -232,6 +232,11 @@ const PermissionsTable = { "resource-lock": {
|
||||
privileged: DENY_ACTION,
|
||||
certified: ALLOW_ACTION
|
||||
},
|
||||
"background-sensors": {
|
||||
app: DENY_ACTION,
|
||||
privileged: DENY_ACTION,
|
||||
certified: ALLOW_ACTION
|
||||
},
|
||||
};
|
||||
|
||||
// Sometimes all permissions (fully expanded) need to be iterated through
|
||||
|
@ -18,6 +18,7 @@
|
||||
#include "GeneratedEvents.h"
|
||||
#include "mozilla/Preferences.h"
|
||||
#include "mozilla/Attributes.h"
|
||||
#include "nsIPermissionManager.h"
|
||||
|
||||
using namespace mozilla;
|
||||
using namespace hal;
|
||||
@ -166,6 +167,28 @@ NS_IMETHODIMP nsDeviceSensors::RemoveWindowAsListener(nsIDOMWindow *aWindow)
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
static bool
|
||||
WindowCannotReceiveSensorEvent (nsPIDOMWindow* aWindow)
|
||||
{
|
||||
// Check to see if this window is in the background. If
|
||||
// it is and it does not have the "background-sensors" permission,
|
||||
// don't send any device motion events to it.
|
||||
if (!aWindow || !aWindow->GetOuterWindow()) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (aWindow->GetOuterWindow()->IsBackground()) {
|
||||
nsCOMPtr<nsIPermissionManager> permMgr =
|
||||
do_GetService(NS_PERMISSIONMANAGER_CONTRACTID);
|
||||
NS_ENSURE_TRUE(permMgr, false);
|
||||
uint32_t permission = nsIPermissionManager::DENY_ACTION;
|
||||
permMgr->TestPermissionFromWindow(aWindow, "background-sensors", &permission);
|
||||
return permission != nsIPermissionManager::ALLOW_ACTION;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
void
|
||||
nsDeviceSensors::Notify(const mozilla::hal::SensorData& aSensorData)
|
||||
{
|
||||
@ -185,13 +208,10 @@ nsDeviceSensors::Notify(const mozilla::hal::SensorData& aSensorData)
|
||||
for (uint32_t i = windowListeners.Count(); i > 0 ; ) {
|
||||
--i;
|
||||
|
||||
// check to see if this window is in the background. if
|
||||
// it is, don't send any device motion to it.
|
||||
nsCOMPtr<nsPIDOMWindow> pwindow = do_QueryInterface(windowListeners[i]);
|
||||
if (!pwindow ||
|
||||
!pwindow->GetOuterWindow() ||
|
||||
pwindow->GetOuterWindow()->IsBackground())
|
||||
continue;
|
||||
if (WindowCannotReceiveSensorEvent(pwindow)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIDOMDocument> domdoc;
|
||||
windowListeners[i]->GetDocument(getter_AddRefs(domdoc));
|
||||
|
Loading…
Reference in New Issue
Block a user