зеркало из https://github.com/mozilla/gecko-dev.git
Bug 911242 - [LED] De-couple the control of screen backlight and keyboard backlight. r=dhylands, sr=sicking
This commit is contained in:
Родитель
c9d1aee8c2
Коммит
08364d3403
|
@ -154,6 +154,18 @@ PowerManager::SetScreenEnabled(bool aEnabled)
|
||||||
hal::SetScreenEnabled(aEnabled);
|
hal::SetScreenEnabled(aEnabled);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool
|
||||||
|
PowerManager::KeyLightEnabled()
|
||||||
|
{
|
||||||
|
return hal::GetKeyLightEnabled();
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
PowerManager::SetKeyLightEnabled(bool aEnabled)
|
||||||
|
{
|
||||||
|
hal::SetKeyLightEnabled(aEnabled);
|
||||||
|
}
|
||||||
|
|
||||||
double
|
double
|
||||||
PowerManager::ScreenBrightness()
|
PowerManager::ScreenBrightness()
|
||||||
{
|
{
|
||||||
|
|
|
@ -53,6 +53,8 @@ public:
|
||||||
ErrorResult& aRv);
|
ErrorResult& aRv);
|
||||||
bool ScreenEnabled();
|
bool ScreenEnabled();
|
||||||
void SetScreenEnabled(bool aEnabled);
|
void SetScreenEnabled(bool aEnabled);
|
||||||
|
bool KeyLightEnabled();
|
||||||
|
void SetKeyLightEnabled(bool aEnabled);
|
||||||
double ScreenBrightness();
|
double ScreenBrightness();
|
||||||
void SetScreenBrightness(double aBrightness, ErrorResult& aRv);
|
void SetScreenBrightness(double aBrightness, ErrorResult& aRv);
|
||||||
bool CpuSleepAllowed();
|
bool CpuSleepAllowed();
|
||||||
|
|
|
@ -12,3 +12,5 @@ skip-if = toolkit != "gonk"
|
||||||
skip-if = toolkit != "gonk"
|
skip-if = toolkit != "gonk"
|
||||||
[test_power_set_screen_enabled.html]
|
[test_power_set_screen_enabled.html]
|
||||||
skip-if = toolkit != "gonk"
|
skip-if = toolkit != "gonk"
|
||||||
|
[test_power_set_key_light_enabled.html]
|
||||||
|
skip-if = toolkit != "gonk"
|
||||||
|
|
|
@ -0,0 +1,64 @@
|
||||||
|
<!DOCTYPE HTML>
|
||||||
|
<html>
|
||||||
|
<head>
|
||||||
|
<meta charset="utf-8">
|
||||||
|
<title>Test Enabling/Disabling Screen with Power Management API</title>
|
||||||
|
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
|
||||||
|
<script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<p id="display"></p>
|
||||||
|
<div id="content" style="display: none"></div>
|
||||||
|
<pre id="test">
|
||||||
|
<script type="application/javascript">
|
||||||
|
|
||||||
|
"use strict";
|
||||||
|
|
||||||
|
function testEnableKeyLight() {
|
||||||
|
try {
|
||||||
|
navigator.mozPower.keyLightEnabled = true;
|
||||||
|
ok(navigator.mozPower.keyLightEnabled === true, "Enabled key backlight.");
|
||||||
|
} catch (e) {
|
||||||
|
ok(false, "Unexpected exception trying to enable key backlight.");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function testDisableKeyLight() {
|
||||||
|
try {
|
||||||
|
navigator.mozPower.keyLightEnabled = false;
|
||||||
|
ok(navigator.mozPower.keyLightEnabled === false, "Disabled key backlight.");
|
||||||
|
} catch (e) {
|
||||||
|
ok(false, "Unexpected exception trying to disable key backlight.");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function startTests() {
|
||||||
|
|
||||||
|
// Make sure we don't suspend
|
||||||
|
navigator.mozPower.cpuSleepAllowed = false;
|
||||||
|
|
||||||
|
testDisableKeyLight();
|
||||||
|
testEnableKeyLight();
|
||||||
|
|
||||||
|
SimpleTest.finish();
|
||||||
|
}
|
||||||
|
|
||||||
|
SimpleTest.waitForExplicitFinish();
|
||||||
|
if (SpecialPowers.hasPermission("power", document)) {
|
||||||
|
// Currently only applicable on FxOS
|
||||||
|
if (navigator.userAgent.indexOf("Mobile") != -1 &&
|
||||||
|
navigator.appVersion.indexOf("Android") == -1) {
|
||||||
|
startTests();
|
||||||
|
} else {
|
||||||
|
ok(true, "mozPower on Firefox OS only.");
|
||||||
|
SimpleTest.finish();
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
// Add the permission and reload so it's propogated
|
||||||
|
SpecialPowers.addPermission("power", true, document);
|
||||||
|
window.location.reload();
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
</pre>
|
||||||
|
</body>
|
||||||
|
</html>
|
|
@ -49,6 +49,13 @@ interface MozPowerManager
|
||||||
*/
|
*/
|
||||||
attribute boolean screenEnabled;
|
attribute boolean screenEnabled;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Is the device's keypad/button backlight enabled? Setting it to false will
|
||||||
|
* turn off the device's keypad/button backlight. And the brightness level
|
||||||
|
* is the same as |screenBrightness|.
|
||||||
|
*/
|
||||||
|
attribute boolean keyLightEnabled;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* How bright is the screen's backlight, on a scale from 0 (very dim) to 1
|
* How bright is the screen's backlight, on a scale from 0 (very dim) to 1
|
||||||
* (full brightness)? Setting this attribute modifies the screen's
|
* (full brightness)? Setting this attribute modifies the screen's
|
||||||
|
|
24
hal/Hal.cpp
24
hal/Hal.cpp
|
@ -374,10 +374,22 @@ bool GetScreenEnabled()
|
||||||
RETURN_PROXY_IF_SANDBOXED(GetScreenEnabled(), false);
|
RETURN_PROXY_IF_SANDBOXED(GetScreenEnabled(), false);
|
||||||
}
|
}
|
||||||
|
|
||||||
void SetScreenEnabled(bool enabled)
|
void SetScreenEnabled(bool aEnabled)
|
||||||
{
|
{
|
||||||
AssertMainThread();
|
AssertMainThread();
|
||||||
PROXY_IF_SANDBOXED(SetScreenEnabled(enabled));
|
PROXY_IF_SANDBOXED(SetScreenEnabled(aEnabled));
|
||||||
|
}
|
||||||
|
|
||||||
|
bool GetKeyLightEnabled()
|
||||||
|
{
|
||||||
|
AssertMainThread();
|
||||||
|
RETURN_PROXY_IF_SANDBOXED(GetKeyLightEnabled(), false);
|
||||||
|
}
|
||||||
|
|
||||||
|
void SetKeyLightEnabled(bool aEnabled)
|
||||||
|
{
|
||||||
|
AssertMainThread();
|
||||||
|
PROXY_IF_SANDBOXED(SetKeyLightEnabled(aEnabled));
|
||||||
}
|
}
|
||||||
|
|
||||||
bool GetCpuSleepAllowed()
|
bool GetCpuSleepAllowed()
|
||||||
|
@ -390,10 +402,10 @@ bool GetCpuSleepAllowed()
|
||||||
RETURN_PROXY_IF_SANDBOXED(GetCpuSleepAllowed(), true);
|
RETURN_PROXY_IF_SANDBOXED(GetCpuSleepAllowed(), true);
|
||||||
}
|
}
|
||||||
|
|
||||||
void SetCpuSleepAllowed(bool allowed)
|
void SetCpuSleepAllowed(bool aAllowed)
|
||||||
{
|
{
|
||||||
AssertMainThread();
|
AssertMainThread();
|
||||||
PROXY_IF_SANDBOXED(SetCpuSleepAllowed(allowed));
|
PROXY_IF_SANDBOXED(SetCpuSleepAllowed(aAllowed));
|
||||||
}
|
}
|
||||||
|
|
||||||
double GetScreenBrightness()
|
double GetScreenBrightness()
|
||||||
|
@ -402,10 +414,10 @@ double GetScreenBrightness()
|
||||||
RETURN_PROXY_IF_SANDBOXED(GetScreenBrightness(), 0);
|
RETURN_PROXY_IF_SANDBOXED(GetScreenBrightness(), 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
void SetScreenBrightness(double brightness)
|
void SetScreenBrightness(double aBrightness)
|
||||||
{
|
{
|
||||||
AssertMainThread();
|
AssertMainThread();
|
||||||
PROXY_IF_SANDBOXED(SetScreenBrightness(clamped(brightness, 0.0, 1.0)));
|
PROXY_IF_SANDBOXED(SetScreenBrightness(clamped(aBrightness, 0.0, 1.0)));
|
||||||
}
|
}
|
||||||
|
|
||||||
bool SetLight(LightType light, const LightConfiguration& aConfig)
|
bool SetLight(LightType light, const LightConfiguration& aConfig)
|
||||||
|
|
16
hal/Hal.h
16
hal/Hal.h
|
@ -124,7 +124,17 @@ bool GetScreenEnabled();
|
||||||
*
|
*
|
||||||
* Note that it may take a few seconds for the screen to turn on or off.
|
* Note that it may take a few seconds for the screen to turn on or off.
|
||||||
*/
|
*/
|
||||||
void SetScreenEnabled(bool enabled);
|
void SetScreenEnabled(bool aEnabled);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Determine whether the device's keypad/button backlight is currently enabled.
|
||||||
|
*/
|
||||||
|
bool GetKeyLightEnabled();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Enable or disable the device's keypad/button backlight.
|
||||||
|
*/
|
||||||
|
void SetKeyLightEnabled(bool aEnabled);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the brightness of the device's screen's backlight, on a scale from 0
|
* Get the brightness of the device's screen's backlight, on a scale from 0
|
||||||
|
@ -145,7 +155,7 @@ double GetScreenBrightness();
|
||||||
* followed by GetScreenBrightness(), the value returned by
|
* followed by GetScreenBrightness(), the value returned by
|
||||||
* GetScreenBrightness() may not be exactly x.
|
* GetScreenBrightness() may not be exactly x.
|
||||||
*/
|
*/
|
||||||
void SetScreenBrightness(double brightness);
|
void SetScreenBrightness(double aBrightness);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Determine whether the device is allowed to sleep.
|
* Determine whether the device is allowed to sleep.
|
||||||
|
@ -156,7 +166,7 @@ bool GetCpuSleepAllowed();
|
||||||
* Set whether the device is allowed to suspend automatically after
|
* Set whether the device is allowed to suspend automatically after
|
||||||
* the screen is disabled.
|
* the screen is disabled.
|
||||||
*/
|
*/
|
||||||
void SetCpuSleepAllowed(bool allowed);
|
void SetCpuSleepAllowed(bool aAllowed);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set the value of a light to a particular color, with a specific flash pattern.
|
* Set the value of a light to a particular color, with a specific flash pattern.
|
||||||
|
|
|
@ -14,7 +14,17 @@ GetScreenEnabled()
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
SetScreenEnabled(bool enabled)
|
SetScreenEnabled(bool aEnabled)
|
||||||
|
{}
|
||||||
|
|
||||||
|
bool
|
||||||
|
GetKeyLightEnabled()
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
SetKeyLightEnabled(bool aEnabled)
|
||||||
{}
|
{}
|
||||||
|
|
||||||
double
|
double
|
||||||
|
@ -24,7 +34,7 @@ GetScreenBrightness()
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
SetScreenBrightness(double brightness)
|
SetScreenBrightness(double aBrightness)
|
||||||
{}
|
{}
|
||||||
|
|
||||||
} // hal_impl
|
} // hal_impl
|
||||||
|
|
|
@ -540,21 +540,53 @@ GetScreenEnabled()
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
SetScreenEnabled(bool enabled)
|
SetScreenEnabled(bool aEnabled)
|
||||||
{
|
{
|
||||||
GetGonkDisplay()->SetEnabled(enabled);
|
GetGonkDisplay()->SetEnabled(aEnabled);
|
||||||
sScreenEnabled = enabled;
|
sScreenEnabled = aEnabled;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool
|
||||||
|
GetKeyLightEnabled()
|
||||||
|
{
|
||||||
|
hal::LightConfiguration config;
|
||||||
|
hal_impl::GetLight(hal::eHalLightID_Buttons, &config);
|
||||||
|
return (config.color() != 0x00000000);
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
SetKeyLightEnabled(bool aEnabled)
|
||||||
|
{
|
||||||
|
hal::LightConfiguration config;
|
||||||
|
config.mode() = hal::eHalLightMode_User;
|
||||||
|
config.flash() = hal::eHalLightFlash_None;
|
||||||
|
config.flashOnMS() = config.flashOffMS() = 0;
|
||||||
|
config.color() = 0x00000000;
|
||||||
|
|
||||||
|
if (aEnabled) {
|
||||||
|
// Convert the value in [0, 1] to an int between 0 and 255 and then convert
|
||||||
|
// it to a color. Note that the high byte is FF, corresponding to the alpha
|
||||||
|
// channel.
|
||||||
|
double brightness = GetScreenBrightness();
|
||||||
|
uint32_t val = static_cast<int>(round(brightness * 255.0));
|
||||||
|
uint32_t color = (0xff<<24) + (val<<16) + (val<<8) + val;
|
||||||
|
|
||||||
|
config.color() = color;
|
||||||
|
}
|
||||||
|
|
||||||
|
hal_impl::SetLight(hal::eHalLightID_Buttons, config);
|
||||||
|
hal_impl::SetLight(hal::eHalLightID_Keyboard, config);
|
||||||
}
|
}
|
||||||
|
|
||||||
double
|
double
|
||||||
GetScreenBrightness()
|
GetScreenBrightness()
|
||||||
{
|
{
|
||||||
hal::LightConfiguration aConfig;
|
hal::LightConfiguration config;
|
||||||
hal::LightType light = hal::eHalLightID_Backlight;
|
hal::LightType light = hal::eHalLightID_Backlight;
|
||||||
|
|
||||||
hal::GetLight(light, &aConfig);
|
hal_impl::GetLight(light, &config);
|
||||||
// backlight is brightness only, so using one of the RGB elements as value.
|
// backlight is brightness only, so using one of the RGB elements as value.
|
||||||
int brightness = aConfig.color() & 0xFF;
|
int brightness = config.color() & 0xFF;
|
||||||
return brightness / 255.0;
|
return brightness / 255.0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -571,16 +603,19 @@ SetScreenBrightness(double brightness)
|
||||||
|
|
||||||
// Convert the value in [0, 1] to an int between 0 and 255 and convert to a color
|
// Convert the value in [0, 1] to an int between 0 and 255 and convert to a color
|
||||||
// note that the high byte is FF, corresponding to the alpha channel.
|
// note that the high byte is FF, corresponding to the alpha channel.
|
||||||
int val = static_cast<int>(round(brightness * 255));
|
uint32_t val = static_cast<int>(round(brightness * 255.0));
|
||||||
uint32_t color = (0xff<<24) + (val<<16) + (val<<8) + val;
|
uint32_t color = (0xff<<24) + (val<<16) + (val<<8) + val;
|
||||||
|
|
||||||
hal::LightConfiguration aConfig;
|
hal::LightConfiguration config;
|
||||||
aConfig.mode() = hal::eHalLightMode_User;
|
config.mode() = hal::eHalLightMode_User;
|
||||||
aConfig.flash() = hal::eHalLightFlash_None;
|
config.flash() = hal::eHalLightFlash_None;
|
||||||
aConfig.flashOnMS() = aConfig.flashOffMS() = 0;
|
config.flashOnMS() = config.flashOffMS() = 0;
|
||||||
aConfig.color() = color;
|
config.color() = color;
|
||||||
hal::SetLight(hal::eHalLightID_Backlight, aConfig);
|
hal_impl::SetLight(hal::eHalLightID_Backlight, config);
|
||||||
hal::SetLight(hal::eHalLightID_Buttons, aConfig);
|
if (GetKeyLightEnabled()) {
|
||||||
|
hal_impl::SetLight(hal::eHalLightID_Buttons, config);
|
||||||
|
hal_impl::SetLight(hal::eHalLightID_Keyboard, config);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static Monitor* sInternalLockCpuMonitor = nullptr;
|
static Monitor* sInternalLockCpuMonitor = nullptr;
|
||||||
|
|
|
@ -127,13 +127,16 @@ parent:
|
||||||
returns (NetworkInformation aNetworkInfo);
|
returns (NetworkInformation aNetworkInfo);
|
||||||
|
|
||||||
sync GetScreenEnabled() returns (bool enabled);
|
sync GetScreenEnabled() returns (bool enabled);
|
||||||
SetScreenEnabled(bool enabled);
|
SetScreenEnabled(bool aEnabled);
|
||||||
|
|
||||||
|
sync GetKeyLightEnabled() returns (bool enabled);
|
||||||
|
SetKeyLightEnabled(bool aEnabled);
|
||||||
|
|
||||||
sync GetCpuSleepAllowed() returns (bool allowed);
|
sync GetCpuSleepAllowed() returns (bool allowed);
|
||||||
SetCpuSleepAllowed(bool allowed);
|
SetCpuSleepAllowed(bool aAllowed);
|
||||||
|
|
||||||
sync GetScreenBrightness() returns (double brightness);
|
sync GetScreenBrightness() returns (double brightness);
|
||||||
SetScreenBrightness(double brightness);
|
SetScreenBrightness(double aBrightness);
|
||||||
|
|
||||||
AdjustSystemClock(int64_t aDeltaMilliseconds);
|
AdjustSystemClock(int64_t aDeltaMilliseconds);
|
||||||
SetTimezone(nsCString aTimezoneSpec);
|
SetTimezone(nsCString aTimezoneSpec);
|
||||||
|
|
|
@ -143,9 +143,23 @@ GetScreenEnabled()
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
SetScreenEnabled(bool enabled)
|
SetScreenEnabled(bool aEnabled)
|
||||||
{
|
{
|
||||||
Hal()->SendSetScreenEnabled(enabled);
|
Hal()->SendSetScreenEnabled(aEnabled);
|
||||||
|
}
|
||||||
|
|
||||||
|
bool
|
||||||
|
GetKeyLightEnabled()
|
||||||
|
{
|
||||||
|
bool enabled = false;
|
||||||
|
Hal()->SendGetKeyLightEnabled(&enabled);
|
||||||
|
return enabled;
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
SetKeyLightEnabled(bool aEnabled)
|
||||||
|
{
|
||||||
|
Hal()->SendSetKeyLightEnabled(aEnabled);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool
|
bool
|
||||||
|
@ -157,9 +171,9 @@ GetCpuSleepAllowed()
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
SetCpuSleepAllowed(bool allowed)
|
SetCpuSleepAllowed(bool aAllowed)
|
||||||
{
|
{
|
||||||
Hal()->SendSetCpuSleepAllowed(allowed);
|
Hal()->SendSetCpuSleepAllowed(aAllowed);
|
||||||
}
|
}
|
||||||
|
|
||||||
double
|
double
|
||||||
|
@ -171,9 +185,9 @@ GetScreenBrightness()
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
SetScreenBrightness(double brightness)
|
SetScreenBrightness(double aBrightness)
|
||||||
{
|
{
|
||||||
Hal()->SendSetScreenBrightness(brightness);
|
Hal()->SendSetScreenBrightness(aBrightness);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool
|
bool
|
||||||
|
@ -591,62 +605,82 @@ public:
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual bool
|
virtual bool
|
||||||
RecvGetScreenEnabled(bool *enabled) MOZ_OVERRIDE
|
RecvGetScreenEnabled(bool* aEnabled) MOZ_OVERRIDE
|
||||||
{
|
{
|
||||||
if (!AssertAppProcessPermission(this, "power")) {
|
if (!AssertAppProcessPermission(this, "power")) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
*enabled = hal::GetScreenEnabled();
|
*aEnabled = hal::GetScreenEnabled();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual bool
|
virtual bool
|
||||||
RecvSetScreenEnabled(const bool &enabled) MOZ_OVERRIDE
|
RecvSetScreenEnabled(const bool& aEnabled) MOZ_OVERRIDE
|
||||||
{
|
{
|
||||||
if (!AssertAppProcessPermission(this, "power")) {
|
if (!AssertAppProcessPermission(this, "power")) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
hal::SetScreenEnabled(enabled);
|
hal::SetScreenEnabled(aEnabled);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual bool
|
virtual bool
|
||||||
RecvGetCpuSleepAllowed(bool *allowed) MOZ_OVERRIDE
|
RecvGetKeyLightEnabled(bool* aEnabled) MOZ_OVERRIDE
|
||||||
{
|
{
|
||||||
if (!AssertAppProcessPermission(this, "power")) {
|
if (!AssertAppProcessPermission(this, "power")) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
*allowed = hal::GetCpuSleepAllowed();
|
*aEnabled = hal::GetKeyLightEnabled();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual bool
|
virtual bool
|
||||||
RecvSetCpuSleepAllowed(const bool &allowed) MOZ_OVERRIDE
|
RecvSetKeyLightEnabled(const bool& aEnabled) MOZ_OVERRIDE
|
||||||
{
|
{
|
||||||
if (!AssertAppProcessPermission(this, "power")) {
|
if (!AssertAppProcessPermission(this, "power")) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
hal::SetCpuSleepAllowed(allowed);
|
hal::SetKeyLightEnabled(aEnabled);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual bool
|
virtual bool
|
||||||
RecvGetScreenBrightness(double *brightness) MOZ_OVERRIDE
|
RecvGetCpuSleepAllowed(bool* aAllowed) MOZ_OVERRIDE
|
||||||
{
|
{
|
||||||
if (!AssertAppProcessPermission(this, "power")) {
|
if (!AssertAppProcessPermission(this, "power")) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
*brightness = hal::GetScreenBrightness();
|
*aAllowed = hal::GetCpuSleepAllowed();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual bool
|
virtual bool
|
||||||
RecvSetScreenBrightness(const double &brightness) MOZ_OVERRIDE
|
RecvSetCpuSleepAllowed(const bool& aAllowed) MOZ_OVERRIDE
|
||||||
{
|
{
|
||||||
if (!AssertAppProcessPermission(this, "power")) {
|
if (!AssertAppProcessPermission(this, "power")) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
hal::SetScreenBrightness(brightness);
|
hal::SetCpuSleepAllowed(aAllowed);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
virtual bool
|
||||||
|
RecvGetScreenBrightness(double* aBrightness) MOZ_OVERRIDE
|
||||||
|
{
|
||||||
|
if (!AssertAppProcessPermission(this, "power")) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
*aBrightness = hal::GetScreenBrightness();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
virtual bool
|
||||||
|
RecvSetScreenBrightness(const double& aBrightness) MOZ_OVERRIDE
|
||||||
|
{
|
||||||
|
if (!AssertAppProcessPermission(this, "power")) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
hal::SetScreenBrightness(aBrightness);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Загрузка…
Ссылка в новой задаче