mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-24 05:11:16 +00:00
Bug 709585 - Part 5, hal code for the Power API. r=cjones
--HG-- extra : rebase_source : 49c8cb29be617293eb9143b3e3c760229b37943c
This commit is contained in:
parent
235274ffbd
commit
f54487e0fe
@ -729,6 +729,7 @@ sys/pstat.h
|
||||
sys/ptrace.h
|
||||
sys/queue.h
|
||||
sys/quota.h
|
||||
sys/reboot.h
|
||||
sys/reg.h
|
||||
sys/regset.h
|
||||
sys/resource.h
|
||||
|
12
hal/Hal.cpp
12
hal/Hal.cpp
@ -372,5 +372,17 @@ NotifyNetworkChange(const NetworkInformation& aInfo)
|
||||
sNetworkObservers.BroadcastCachedInformation();
|
||||
}
|
||||
|
||||
void Reboot()
|
||||
{
|
||||
AssertMainThread();
|
||||
PROXY_IF_SANDBOXED(Reboot());
|
||||
}
|
||||
|
||||
void PowerOff()
|
||||
{
|
||||
AssertMainThread();
|
||||
PROXY_IF_SANDBOXED(PowerOff());
|
||||
}
|
||||
|
||||
} // namespace hal
|
||||
} // namespace mozilla
|
||||
|
10
hal/Hal.h
10
hal/Hal.h
@ -192,6 +192,16 @@ void GetCurrentNetworkInformation(hal::NetworkInformation* aNetworkInfo);
|
||||
*/
|
||||
void NotifyNetworkChange(const hal::NetworkInformation& aNetworkInfo);
|
||||
|
||||
/**
|
||||
* Reboot the device.
|
||||
*/
|
||||
void Reboot();
|
||||
|
||||
/**
|
||||
* Power off the device.
|
||||
*/
|
||||
void PowerOff();
|
||||
|
||||
} // namespace MOZ_HAL_NAMESPACE
|
||||
} // namespace mozilla
|
||||
|
||||
|
@ -72,9 +72,9 @@ CPPSRCS = \
|
||||
ifeq (android,$(MOZ_WIDGET_TOOLKIT))
|
||||
CPPSRCS += AndroidHal.cpp
|
||||
else ifeq (gonk,$(MOZ_WIDGET_TOOLKIT))
|
||||
CPPSRCS += GonkHal.cpp
|
||||
CPPSRCS += GonkHal.cpp Power.cpp
|
||||
else ifeq (Linux,$(OS_TARGET))
|
||||
CPPSRCS += LinuxHal.cpp
|
||||
CPPSRCS += LinuxHal.cpp Power.cpp
|
||||
ifdef MOZ_ENABLE_DBUS
|
||||
CPPSRCS += UPowerClient.cpp
|
||||
endif
|
||||
|
@ -173,6 +173,14 @@ GetCurrentNetworkInformation(hal::NetworkInformation* aNetworkInfo)
|
||||
bridge->GetCurrentNetworkInformation(aNetworkInfo);
|
||||
}
|
||||
|
||||
void
|
||||
Reboot()
|
||||
{}
|
||||
|
||||
void
|
||||
PowerOff()
|
||||
{}
|
||||
|
||||
} // hal_impl
|
||||
} // mozilla
|
||||
|
||||
|
@ -105,5 +105,13 @@ GetCurrentNetworkInformation(hal::NetworkInformation* aNetworkInfo)
|
||||
aNetworkInfo->canBeMetered() = dom::network::kDefaultCanBeMetered;
|
||||
}
|
||||
|
||||
void
|
||||
Reboot()
|
||||
{}
|
||||
|
||||
void
|
||||
PowerOff()
|
||||
{}
|
||||
|
||||
} // hal_impl
|
||||
} // namespace mozilla
|
||||
|
59
hal/linux/Power.cpp
Normal file
59
hal/linux/Power.cpp
Normal file
@ -0,0 +1,59 @@
|
||||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public License Version
|
||||
* 1.1 (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
* for the specific language governing rights and limitations under the
|
||||
* License.
|
||||
*
|
||||
* The Original Code is mozilla.org code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Mozilla Foundation
|
||||
* Portions created by the Initial Developer are Copyright (C) 2011
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Kan-Ru Chen <kchen@mozilla.com> (Original Author)
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either of the GNU General Public License Version 2 or later (the "GPL"),
|
||||
* or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
* in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
* of those above. If you wish to allow use of your version of this file only
|
||||
* under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
* use your version of this file under the terms of the MPL, indicate your
|
||||
* decision by deleting the provisions above and replace them with the notice
|
||||
* and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
* the provisions above, a recipient may use your version of this file under
|
||||
* the terms of any one of the MPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
#include "Hal.h"
|
||||
|
||||
#include <unistd.h>
|
||||
#include <sys/reboot.h>
|
||||
|
||||
namespace mozilla {
|
||||
namespace hal_impl {
|
||||
|
||||
void
|
||||
Reboot()
|
||||
{
|
||||
reboot(RB_AUTOBOOT);
|
||||
}
|
||||
|
||||
void
|
||||
PowerOff()
|
||||
{
|
||||
reboot(RB_POWER_OFF);
|
||||
}
|
||||
|
||||
} // hal_impl
|
||||
} // mozilla
|
@ -86,6 +86,9 @@ parent:
|
||||
sync GetScreenBrightness() returns (double brightness);
|
||||
SetScreenBrightness(double brightness);
|
||||
|
||||
Reboot();
|
||||
PowerOff();
|
||||
|
||||
__delete__();
|
||||
};
|
||||
|
||||
|
@ -152,6 +152,18 @@ SetScreenBrightness(double brightness)
|
||||
Hal()->SendSetScreenBrightness(brightness);
|
||||
}
|
||||
|
||||
void
|
||||
Reboot()
|
||||
{
|
||||
Hal()->SendReboot();
|
||||
}
|
||||
|
||||
void
|
||||
PowerOff()
|
||||
{
|
||||
Hal()->SendPowerOff();
|
||||
}
|
||||
|
||||
class HalParent : public PHalParent
|
||||
, public BatteryObserver
|
||||
, public NetworkObserver
|
||||
@ -267,6 +279,20 @@ public:
|
||||
hal::SetScreenBrightness(brightness);
|
||||
return true;
|
||||
}
|
||||
|
||||
NS_OVERRIDE virtual bool
|
||||
RecvReboot()
|
||||
{
|
||||
hal::Reboot();
|
||||
return true;
|
||||
}
|
||||
|
||||
NS_OVERRIDE virtual bool
|
||||
RecvPowerOff()
|
||||
{
|
||||
hal::PowerOff();
|
||||
return true;
|
||||
}
|
||||
};
|
||||
|
||||
class HalChild : public PHalChild {
|
||||
|
@ -84,5 +84,13 @@ GetCurrentNetworkInformation(hal::NetworkInformation* aNetworkInfo)
|
||||
aNetworkInfo->canBeMetered() = dom::network::kDefaultCanBeMetered;
|
||||
}
|
||||
|
||||
void
|
||||
Reboot()
|
||||
{}
|
||||
|
||||
void
|
||||
PowerOff()
|
||||
{}
|
||||
|
||||
} // hal_impl
|
||||
} // mozilla
|
||||
|
@ -729,6 +729,7 @@ sys/pstat.h
|
||||
sys/ptrace.h
|
||||
sys/queue.h
|
||||
sys/quota.h
|
||||
sys/reboot.h
|
||||
sys/reg.h
|
||||
sys/regset.h
|
||||
sys/resource.h
|
||||
|
Loading…
Reference in New Issue
Block a user