mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 975667 - gecko: hal: gonk: Emit battery level/charging notification. r=dhylands
The battery level and charging flag is now emitted from nsIObserverService via the "gonkhal-battery-notifier" topic. This can be useful to XPCOM components that are not statically linked to Gecko. The notification data is a IPropertyBag2 object. Change-Id: Ia7b1faf3b66c19d6551d71ad554fd361c2614a22
This commit is contained in:
parent
1774026f94
commit
392a5b1ca9
@ -66,6 +66,7 @@
|
|||||||
#include "nsXULAppAPI.h"
|
#include "nsXULAppAPI.h"
|
||||||
#include "OrientationObserver.h"
|
#include "OrientationObserver.h"
|
||||||
#include "UeventPoller.h"
|
#include "UeventPoller.h"
|
||||||
|
#include "nsIWritablePropertyBag2.h"
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
|
|
||||||
#define LOG(args...) __android_log_print(ANDROID_LOG_INFO, "Gonk", args)
|
#define LOG(args...) __android_log_print(ANDROID_LOG_INFO, "Gonk", args)
|
||||||
@ -290,6 +291,25 @@ public:
|
|||||||
hal_impl::SetLight(hal::eHalLightID_Battery, aConfig);
|
hal_impl::SetLight(hal::eHalLightID_Battery, aConfig);
|
||||||
|
|
||||||
hal::NotifyBatteryChange(info);
|
hal::NotifyBatteryChange(info);
|
||||||
|
|
||||||
|
{
|
||||||
|
// bug 975667
|
||||||
|
// Gecko gonk hal is required to emit battery charging/level notification via nsIObserverService.
|
||||||
|
// This is useful for XPCOM components that are not statically linked to Gecko and cannot call
|
||||||
|
// hal::EnableBatteryNotifications
|
||||||
|
nsCOMPtr<nsIObserverService> obsService = mozilla::services::GetObserverService();
|
||||||
|
nsCOMPtr<nsIWritablePropertyBag2> propbag =
|
||||||
|
do_CreateInstance("@mozilla.org/hash-property-bag;1");
|
||||||
|
if (obsService && propbag) {
|
||||||
|
propbag->SetPropertyAsBool(NS_LITERAL_STRING("charging"),
|
||||||
|
info.charging());
|
||||||
|
propbag->SetPropertyAsDouble(NS_LITERAL_STRING("level"),
|
||||||
|
info.level());
|
||||||
|
|
||||||
|
obsService->NotifyObservers(propbag, "gonkhal-battery-notifier", nullptr);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return NS_OK;
|
return NS_OK;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
Loading…
Reference in New Issue
Block a user