1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/hal/Hal.cpp Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,1219 @@ 1.4 +/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ 1.5 +/* vim: set sw=2 ts=8 et ft=cpp : */ 1.6 +/* This Source Code Form is subject to the terms of the Mozilla Public 1.7 + * License, v. 2.0. If a copy of the MPL was not distributed with this file, 1.8 + * You can obtain one at http://mozilla.org/MPL/2.0/. */ 1.9 + 1.10 +#include "Hal.h" 1.11 +#include "HalImpl.h" 1.12 +#include "HalSandbox.h" 1.13 +#include "nsThreadUtils.h" 1.14 +#include "nsXULAppAPI.h" 1.15 +#include "mozilla/Observer.h" 1.16 +#include "nsIDocument.h" 1.17 +#include "nsIDOMDocument.h" 1.18 +#include "nsPIDOMWindow.h" 1.19 +#include "nsIDOMWindow.h" 1.20 +#include "mozilla/Services.h" 1.21 +#include "nsIWebNavigation.h" 1.22 +#include "nsITabChild.h" 1.23 +#include "nsIDocShell.h" 1.24 +#include "mozilla/StaticPtr.h" 1.25 +#include "mozilla/ClearOnShutdown.h" 1.26 +#include "WindowIdentifier.h" 1.27 +#include "mozilla/dom/ScreenOrientation.h" 1.28 +#include "mozilla/dom/ContentChild.h" 1.29 +#include "mozilla/dom/ContentParent.h" 1.30 + 1.31 +#ifdef XP_WIN 1.32 +#include <process.h> 1.33 +#define getpid _getpid 1.34 +#endif 1.35 + 1.36 +using namespace mozilla::services; 1.37 +using namespace mozilla::dom; 1.38 + 1.39 +#define PROXY_IF_SANDBOXED(_call) \ 1.40 + do { \ 1.41 + if (InSandbox()) { \ 1.42 + if (!hal_sandbox::HalChildDestroyed()) { \ 1.43 + hal_sandbox::_call; \ 1.44 + } \ 1.45 + } else { \ 1.46 + hal_impl::_call; \ 1.47 + } \ 1.48 + } while (0) 1.49 + 1.50 +#define RETURN_PROXY_IF_SANDBOXED(_call, defValue)\ 1.51 + do { \ 1.52 + if (InSandbox()) { \ 1.53 + if (hal_sandbox::HalChildDestroyed()) { \ 1.54 + return defValue; \ 1.55 + } \ 1.56 + return hal_sandbox::_call; \ 1.57 + } else { \ 1.58 + return hal_impl::_call; \ 1.59 + } \ 1.60 + } while (0) 1.61 + 1.62 +namespace mozilla { 1.63 +namespace hal { 1.64 + 1.65 +PRLogModuleInfo * 1.66 +GetHalLog() 1.67 +{ 1.68 + static PRLogModuleInfo *sHalLog; 1.69 + if (!sHalLog) { 1.70 + sHalLog = PR_NewLogModule("hal"); 1.71 + } 1.72 + return sHalLog; 1.73 +} 1.74 + 1.75 +namespace { 1.76 + 1.77 +void 1.78 +AssertMainThread() 1.79 +{ 1.80 + MOZ_ASSERT(NS_IsMainThread()); 1.81 +} 1.82 + 1.83 +bool 1.84 +InSandbox() 1.85 +{ 1.86 + return GeckoProcessType_Content == XRE_GetProcessType(); 1.87 +} 1.88 + 1.89 +void 1.90 +AssertMainProcess() 1.91 +{ 1.92 + MOZ_ASSERT(GeckoProcessType_Default == XRE_GetProcessType()); 1.93 +} 1.94 + 1.95 +bool 1.96 +WindowIsActive(nsIDOMWindow* aWindow) 1.97 +{ 1.98 + nsCOMPtr<nsPIDOMWindow> window = do_QueryInterface(aWindow); 1.99 + NS_ENSURE_TRUE(window, false); 1.100 + 1.101 + nsIDocument* document = window->GetDoc(); 1.102 + NS_ENSURE_TRUE(document, false); 1.103 + 1.104 + return !document->Hidden(); 1.105 +} 1.106 + 1.107 +StaticAutoPtr<WindowIdentifier::IDArrayType> gLastIDToVibrate; 1.108 + 1.109 +void InitLastIDToVibrate() 1.110 +{ 1.111 + gLastIDToVibrate = new WindowIdentifier::IDArrayType(); 1.112 + ClearOnShutdown(&gLastIDToVibrate); 1.113 +} 1.114 + 1.115 +} // anonymous namespace 1.116 + 1.117 +void 1.118 +Vibrate(const nsTArray<uint32_t>& pattern, nsIDOMWindow* window) 1.119 +{ 1.120 + Vibrate(pattern, WindowIdentifier(window)); 1.121 +} 1.122 + 1.123 +void 1.124 +Vibrate(const nsTArray<uint32_t>& pattern, const WindowIdentifier &id) 1.125 +{ 1.126 + AssertMainThread(); 1.127 + 1.128 + // Only active windows may start vibrations. If |id| hasn't gone 1.129 + // through the IPC layer -- that is, if our caller is the outside 1.130 + // world, not hal_proxy -- check whether the window is active. If 1.131 + // |id| has gone through IPC, don't check the window's visibility; 1.132 + // only the window corresponding to the bottommost process has its 1.133 + // visibility state set correctly. 1.134 + if (!id.HasTraveledThroughIPC() && !WindowIsActive(id.GetWindow())) { 1.135 + HAL_LOG(("Vibrate: Window is inactive, dropping vibrate.")); 1.136 + return; 1.137 + } 1.138 + 1.139 + if (!InSandbox()) { 1.140 + if (!gLastIDToVibrate) { 1.141 + InitLastIDToVibrate(); 1.142 + } 1.143 + *gLastIDToVibrate = id.AsArray(); 1.144 + } 1.145 + 1.146 + // Don't forward our ID if we are not in the sandbox, because hal_impl 1.147 + // doesn't need it, and we don't want it to be tempted to read it. The 1.148 + // empty identifier will assert if it's used. 1.149 + PROXY_IF_SANDBOXED(Vibrate(pattern, InSandbox() ? id : WindowIdentifier())); 1.150 +} 1.151 + 1.152 +void 1.153 +CancelVibrate(nsIDOMWindow* window) 1.154 +{ 1.155 + CancelVibrate(WindowIdentifier(window)); 1.156 +} 1.157 + 1.158 +void 1.159 +CancelVibrate(const WindowIdentifier &id) 1.160 +{ 1.161 + AssertMainThread(); 1.162 + 1.163 + // Although only active windows may start vibrations, a window may 1.164 + // cancel its own vibration even if it's no longer active. 1.165 + // 1.166 + // After a window is marked as inactive, it sends a CancelVibrate 1.167 + // request. We want this request to cancel a playing vibration 1.168 + // started by that window, so we certainly don't want to reject the 1.169 + // cancellation request because the window is now inactive. 1.170 + // 1.171 + // But it could be the case that, after this window became inactive, 1.172 + // some other window came along and started a vibration. We don't 1.173 + // want this window's cancellation request to cancel that window's 1.174 + // actively-playing vibration! 1.175 + // 1.176 + // To solve this problem, we keep track of the id of the last window 1.177 + // to start a vibration, and only accepts cancellation requests from 1.178 + // the same window. All other cancellation requests are ignored. 1.179 + 1.180 + if (InSandbox() || (gLastIDToVibrate && *gLastIDToVibrate == id.AsArray())) { 1.181 + // Don't forward our ID if we are not in the sandbox, because hal_impl 1.182 + // doesn't need it, and we don't want it to be tempted to read it. The 1.183 + // empty identifier will assert if it's used. 1.184 + PROXY_IF_SANDBOXED(CancelVibrate(InSandbox() ? id : WindowIdentifier())); 1.185 + } 1.186 +} 1.187 + 1.188 +template <class InfoType> 1.189 +class ObserversManager 1.190 +{ 1.191 +public: 1.192 + void AddObserver(Observer<InfoType>* aObserver) { 1.193 + if (!mObservers) { 1.194 + mObservers = new mozilla::ObserverList<InfoType>(); 1.195 + } 1.196 + 1.197 + mObservers->AddObserver(aObserver); 1.198 + 1.199 + if (mObservers->Length() == 1) { 1.200 + EnableNotifications(); 1.201 + } 1.202 + } 1.203 + 1.204 + void RemoveObserver(Observer<InfoType>* aObserver) { 1.205 + bool removed = mObservers && mObservers->RemoveObserver(aObserver); 1.206 + if (!removed) { 1.207 + NS_WARNING("RemoveObserver() called for unregistered observer"); 1.208 + return; 1.209 + } 1.210 + 1.211 + if (mObservers->Length() == 0) { 1.212 + DisableNotifications(); 1.213 + 1.214 + OnNotificationsDisabled(); 1.215 + 1.216 + delete mObservers; 1.217 + mObservers = nullptr; 1.218 + } 1.219 + } 1.220 + 1.221 + void BroadcastInformation(const InfoType& aInfo) { 1.222 + // It is possible for mObservers to be nullptr here on some platforms, 1.223 + // because a call to BroadcastInformation gets queued up asynchronously 1.224 + // while RemoveObserver is running (and before the notifications are 1.225 + // disabled). The queued call can then get run after mObservers has 1.226 + // been nulled out. See bug 757025. 1.227 + if (!mObservers) { 1.228 + return; 1.229 + } 1.230 + mObservers->Broadcast(aInfo); 1.231 + } 1.232 + 1.233 +protected: 1.234 + virtual void EnableNotifications() = 0; 1.235 + virtual void DisableNotifications() = 0; 1.236 + virtual void OnNotificationsDisabled() {} 1.237 + 1.238 +private: 1.239 + mozilla::ObserverList<InfoType>* mObservers; 1.240 +}; 1.241 + 1.242 +template <class InfoType> 1.243 +class CachingObserversManager : public ObserversManager<InfoType> 1.244 +{ 1.245 +public: 1.246 + InfoType GetCurrentInformation() { 1.247 + if (mHasValidCache) { 1.248 + return mInfo; 1.249 + } 1.250 + 1.251 + GetCurrentInformationInternal(&mInfo); 1.252 + mHasValidCache = true; 1.253 + return mInfo; 1.254 + } 1.255 + 1.256 + void CacheInformation(const InfoType& aInfo) { 1.257 + mHasValidCache = true; 1.258 + mInfo = aInfo; 1.259 + } 1.260 + 1.261 + void BroadcastCachedInformation() { 1.262 + this->BroadcastInformation(mInfo); 1.263 + } 1.264 + 1.265 +protected: 1.266 + virtual void GetCurrentInformationInternal(InfoType*) = 0; 1.267 + 1.268 + virtual void OnNotificationsDisabled() { 1.269 + mHasValidCache = false; 1.270 + } 1.271 + 1.272 +private: 1.273 + InfoType mInfo; 1.274 + bool mHasValidCache; 1.275 +}; 1.276 + 1.277 +class BatteryObserversManager : public CachingObserversManager<BatteryInformation> 1.278 +{ 1.279 +protected: 1.280 + void EnableNotifications() { 1.281 + PROXY_IF_SANDBOXED(EnableBatteryNotifications()); 1.282 + } 1.283 + 1.284 + void DisableNotifications() { 1.285 + PROXY_IF_SANDBOXED(DisableBatteryNotifications()); 1.286 + } 1.287 + 1.288 + void GetCurrentInformationInternal(BatteryInformation* aInfo) { 1.289 + PROXY_IF_SANDBOXED(GetCurrentBatteryInformation(aInfo)); 1.290 + } 1.291 +}; 1.292 + 1.293 +static BatteryObserversManager sBatteryObservers; 1.294 + 1.295 +class NetworkObserversManager : public CachingObserversManager<NetworkInformation> 1.296 +{ 1.297 +protected: 1.298 + void EnableNotifications() { 1.299 + PROXY_IF_SANDBOXED(EnableNetworkNotifications()); 1.300 + } 1.301 + 1.302 + void DisableNotifications() { 1.303 + PROXY_IF_SANDBOXED(DisableNetworkNotifications()); 1.304 + } 1.305 + 1.306 + void GetCurrentInformationInternal(NetworkInformation* aInfo) { 1.307 + PROXY_IF_SANDBOXED(GetCurrentNetworkInformation(aInfo)); 1.308 + } 1.309 +}; 1.310 + 1.311 +static NetworkObserversManager sNetworkObservers; 1.312 + 1.313 +class WakeLockObserversManager : public ObserversManager<WakeLockInformation> 1.314 +{ 1.315 +protected: 1.316 + void EnableNotifications() { 1.317 + PROXY_IF_SANDBOXED(EnableWakeLockNotifications()); 1.318 + } 1.319 + 1.320 + void DisableNotifications() { 1.321 + PROXY_IF_SANDBOXED(DisableWakeLockNotifications()); 1.322 + } 1.323 +}; 1.324 + 1.325 +static WakeLockObserversManager sWakeLockObservers; 1.326 + 1.327 +class ScreenConfigurationObserversManager : public CachingObserversManager<ScreenConfiguration> 1.328 +{ 1.329 +protected: 1.330 + void EnableNotifications() { 1.331 + PROXY_IF_SANDBOXED(EnableScreenConfigurationNotifications()); 1.332 + } 1.333 + 1.334 + void DisableNotifications() { 1.335 + PROXY_IF_SANDBOXED(DisableScreenConfigurationNotifications()); 1.336 + } 1.337 + 1.338 + void GetCurrentInformationInternal(ScreenConfiguration* aInfo) { 1.339 + PROXY_IF_SANDBOXED(GetCurrentScreenConfiguration(aInfo)); 1.340 + } 1.341 +}; 1.342 + 1.343 +static ScreenConfigurationObserversManager sScreenConfigurationObservers; 1.344 + 1.345 +void 1.346 +RegisterBatteryObserver(BatteryObserver* aObserver) 1.347 +{ 1.348 + AssertMainThread(); 1.349 + sBatteryObservers.AddObserver(aObserver); 1.350 +} 1.351 + 1.352 +void 1.353 +UnregisterBatteryObserver(BatteryObserver* aObserver) 1.354 +{ 1.355 + AssertMainThread(); 1.356 + sBatteryObservers.RemoveObserver(aObserver); 1.357 +} 1.358 + 1.359 +void 1.360 +GetCurrentBatteryInformation(BatteryInformation* aInfo) 1.361 +{ 1.362 + AssertMainThread(); 1.363 + *aInfo = sBatteryObservers.GetCurrentInformation(); 1.364 +} 1.365 + 1.366 +void 1.367 +NotifyBatteryChange(const BatteryInformation& aInfo) 1.368 +{ 1.369 + AssertMainThread(); 1.370 + sBatteryObservers.CacheInformation(aInfo); 1.371 + sBatteryObservers.BroadcastCachedInformation(); 1.372 +} 1.373 + 1.374 +bool GetScreenEnabled() 1.375 +{ 1.376 + AssertMainThread(); 1.377 + RETURN_PROXY_IF_SANDBOXED(GetScreenEnabled(), false); 1.378 +} 1.379 + 1.380 +void SetScreenEnabled(bool enabled) 1.381 +{ 1.382 + AssertMainThread(); 1.383 + PROXY_IF_SANDBOXED(SetScreenEnabled(enabled)); 1.384 +} 1.385 + 1.386 +bool GetCpuSleepAllowed() 1.387 +{ 1.388 + // Generally for interfaces that are accessible by normal web content 1.389 + // we should cache the result and be notified on state changes, like 1.390 + // what the battery API does. But since this is only used by 1.391 + // privileged interface, the synchronous getter is OK here. 1.392 + AssertMainThread(); 1.393 + RETURN_PROXY_IF_SANDBOXED(GetCpuSleepAllowed(), true); 1.394 +} 1.395 + 1.396 +void SetCpuSleepAllowed(bool allowed) 1.397 +{ 1.398 + AssertMainThread(); 1.399 + PROXY_IF_SANDBOXED(SetCpuSleepAllowed(allowed)); 1.400 +} 1.401 + 1.402 +double GetScreenBrightness() 1.403 +{ 1.404 + AssertMainThread(); 1.405 + RETURN_PROXY_IF_SANDBOXED(GetScreenBrightness(), 0); 1.406 +} 1.407 + 1.408 +void SetScreenBrightness(double brightness) 1.409 +{ 1.410 + AssertMainThread(); 1.411 + PROXY_IF_SANDBOXED(SetScreenBrightness(clamped(brightness, 0.0, 1.0))); 1.412 +} 1.413 + 1.414 +bool SetLight(LightType light, const LightConfiguration& aConfig) 1.415 +{ 1.416 + AssertMainThread(); 1.417 + RETURN_PROXY_IF_SANDBOXED(SetLight(light, aConfig), false); 1.418 +} 1.419 + 1.420 +bool GetLight(LightType light, LightConfiguration* aConfig) 1.421 +{ 1.422 + AssertMainThread(); 1.423 + RETURN_PROXY_IF_SANDBOXED(GetLight(light, aConfig), false); 1.424 +} 1.425 + 1.426 +class SystemClockChangeObserversManager : public ObserversManager<int64_t> 1.427 +{ 1.428 +protected: 1.429 + void EnableNotifications() { 1.430 + PROXY_IF_SANDBOXED(EnableSystemClockChangeNotifications()); 1.431 + } 1.432 + 1.433 + void DisableNotifications() { 1.434 + PROXY_IF_SANDBOXED(DisableSystemClockChangeNotifications()); 1.435 + } 1.436 +}; 1.437 + 1.438 +static SystemClockChangeObserversManager sSystemClockChangeObservers; 1.439 + 1.440 +void 1.441 +RegisterSystemClockChangeObserver(SystemClockChangeObserver* aObserver) 1.442 +{ 1.443 + AssertMainThread(); 1.444 + sSystemClockChangeObservers.AddObserver(aObserver); 1.445 +} 1.446 + 1.447 +void 1.448 +UnregisterSystemClockChangeObserver(SystemClockChangeObserver* aObserver) 1.449 +{ 1.450 + AssertMainThread(); 1.451 + sSystemClockChangeObservers.RemoveObserver(aObserver); 1.452 +} 1.453 + 1.454 +void 1.455 +NotifySystemClockChange(const int64_t& aClockDeltaMS) 1.456 +{ 1.457 + sSystemClockChangeObservers.BroadcastInformation(aClockDeltaMS); 1.458 +} 1.459 + 1.460 +class SystemTimezoneChangeObserversManager : public ObserversManager<SystemTimezoneChangeInformation> 1.461 +{ 1.462 +protected: 1.463 + void EnableNotifications() { 1.464 + PROXY_IF_SANDBOXED(EnableSystemTimezoneChangeNotifications()); 1.465 + } 1.466 + 1.467 + void DisableNotifications() { 1.468 + PROXY_IF_SANDBOXED(DisableSystemTimezoneChangeNotifications()); 1.469 + } 1.470 +}; 1.471 + 1.472 +static SystemTimezoneChangeObserversManager sSystemTimezoneChangeObservers; 1.473 + 1.474 +void 1.475 +RegisterSystemTimezoneChangeObserver(SystemTimezoneChangeObserver* aObserver) 1.476 +{ 1.477 + AssertMainThread(); 1.478 + sSystemTimezoneChangeObservers.AddObserver(aObserver); 1.479 +} 1.480 + 1.481 +void 1.482 +UnregisterSystemTimezoneChangeObserver(SystemTimezoneChangeObserver* aObserver) 1.483 +{ 1.484 + AssertMainThread(); 1.485 + sSystemTimezoneChangeObservers.RemoveObserver(aObserver); 1.486 +} 1.487 + 1.488 +void 1.489 +NotifySystemTimezoneChange(const SystemTimezoneChangeInformation& aSystemTimezoneChangeInfo) 1.490 +{ 1.491 + sSystemTimezoneChangeObservers.BroadcastInformation(aSystemTimezoneChangeInfo); 1.492 +} 1.493 + 1.494 +void 1.495 +AdjustSystemClock(int64_t aDeltaMilliseconds) 1.496 +{ 1.497 + AssertMainThread(); 1.498 + PROXY_IF_SANDBOXED(AdjustSystemClock(aDeltaMilliseconds)); 1.499 +} 1.500 + 1.501 +void 1.502 +SetTimezone(const nsCString& aTimezoneSpec) 1.503 +{ 1.504 + AssertMainThread(); 1.505 + PROXY_IF_SANDBOXED(SetTimezone(aTimezoneSpec)); 1.506 +} 1.507 + 1.508 +int32_t 1.509 +GetTimezoneOffset() 1.510 +{ 1.511 + AssertMainThread(); 1.512 + RETURN_PROXY_IF_SANDBOXED(GetTimezoneOffset(), 0); 1.513 +} 1.514 + 1.515 +nsCString 1.516 +GetTimezone() 1.517 +{ 1.518 + AssertMainThread(); 1.519 + RETURN_PROXY_IF_SANDBOXED(GetTimezone(), nsCString("")); 1.520 +} 1.521 + 1.522 +void 1.523 +EnableSensorNotifications(SensorType aSensor) { 1.524 + AssertMainThread(); 1.525 + PROXY_IF_SANDBOXED(EnableSensorNotifications(aSensor)); 1.526 +} 1.527 + 1.528 +void 1.529 +DisableSensorNotifications(SensorType aSensor) { 1.530 + AssertMainThread(); 1.531 + PROXY_IF_SANDBOXED(DisableSensorNotifications(aSensor)); 1.532 +} 1.533 + 1.534 +typedef mozilla::ObserverList<SensorData> SensorObserverList; 1.535 +static SensorObserverList* gSensorObservers = nullptr; 1.536 + 1.537 +static SensorObserverList & 1.538 +GetSensorObservers(SensorType sensor_type) { 1.539 + MOZ_ASSERT(sensor_type < NUM_SENSOR_TYPE); 1.540 + 1.541 + if(!gSensorObservers) { 1.542 + gSensorObservers = new SensorObserverList[NUM_SENSOR_TYPE]; 1.543 + } 1.544 + return gSensorObservers[sensor_type]; 1.545 +} 1.546 + 1.547 +void 1.548 +RegisterSensorObserver(SensorType aSensor, ISensorObserver *aObserver) { 1.549 + SensorObserverList &observers = GetSensorObservers(aSensor); 1.550 + 1.551 + AssertMainThread(); 1.552 + 1.553 + observers.AddObserver(aObserver); 1.554 + if(observers.Length() == 1) { 1.555 + EnableSensorNotifications(aSensor); 1.556 + } 1.557 +} 1.558 + 1.559 +void 1.560 +UnregisterSensorObserver(SensorType aSensor, ISensorObserver *aObserver) { 1.561 + AssertMainThread(); 1.562 + 1.563 + if (!gSensorObservers) { 1.564 + return; 1.565 + } 1.566 + 1.567 + SensorObserverList &observers = GetSensorObservers(aSensor); 1.568 + if (!observers.RemoveObserver(aObserver) || observers.Length() > 0) { 1.569 + return; 1.570 + } 1.571 + DisableSensorNotifications(aSensor); 1.572 + 1.573 + // Destroy sSensorObservers only if all observer lists are empty. 1.574 + for (int i = 0; i < NUM_SENSOR_TYPE; i++) { 1.575 + if (gSensorObservers[i].Length() > 0) { 1.576 + return; 1.577 + } 1.578 + } 1.579 + delete [] gSensorObservers; 1.580 + gSensorObservers = nullptr; 1.581 +} 1.582 + 1.583 +void 1.584 +NotifySensorChange(const SensorData &aSensorData) { 1.585 + SensorObserverList &observers = GetSensorObservers(aSensorData.sensor()); 1.586 + 1.587 + AssertMainThread(); 1.588 + 1.589 + observers.Broadcast(aSensorData); 1.590 +} 1.591 + 1.592 +void 1.593 +RegisterNetworkObserver(NetworkObserver* aObserver) 1.594 +{ 1.595 + AssertMainThread(); 1.596 + sNetworkObservers.AddObserver(aObserver); 1.597 +} 1.598 + 1.599 +void 1.600 +UnregisterNetworkObserver(NetworkObserver* aObserver) 1.601 +{ 1.602 + AssertMainThread(); 1.603 + sNetworkObservers.RemoveObserver(aObserver); 1.604 +} 1.605 + 1.606 +void 1.607 +GetCurrentNetworkInformation(NetworkInformation* aInfo) 1.608 +{ 1.609 + AssertMainThread(); 1.610 + *aInfo = sNetworkObservers.GetCurrentInformation(); 1.611 +} 1.612 + 1.613 +void 1.614 +NotifyNetworkChange(const NetworkInformation& aInfo) 1.615 +{ 1.616 + sNetworkObservers.CacheInformation(aInfo); 1.617 + sNetworkObservers.BroadcastCachedInformation(); 1.618 +} 1.619 + 1.620 +void Reboot() 1.621 +{ 1.622 + AssertMainProcess(); 1.623 + AssertMainThread(); 1.624 + PROXY_IF_SANDBOXED(Reboot()); 1.625 +} 1.626 + 1.627 +void PowerOff() 1.628 +{ 1.629 + AssertMainProcess(); 1.630 + AssertMainThread(); 1.631 + PROXY_IF_SANDBOXED(PowerOff()); 1.632 +} 1.633 + 1.634 +void StartForceQuitWatchdog(ShutdownMode aMode, int32_t aTimeoutSecs) 1.635 +{ 1.636 + AssertMainProcess(); 1.637 + AssertMainThread(); 1.638 + PROXY_IF_SANDBOXED(StartForceQuitWatchdog(aMode, aTimeoutSecs)); 1.639 +} 1.640 + 1.641 +void StartMonitoringGamepadStatus() 1.642 +{ 1.643 + PROXY_IF_SANDBOXED(StartMonitoringGamepadStatus()); 1.644 +} 1.645 + 1.646 +void StopMonitoringGamepadStatus() 1.647 +{ 1.648 + PROXY_IF_SANDBOXED(StopMonitoringGamepadStatus()); 1.649 +} 1.650 + 1.651 +void 1.652 +RegisterWakeLockObserver(WakeLockObserver* aObserver) 1.653 +{ 1.654 + AssertMainThread(); 1.655 + sWakeLockObservers.AddObserver(aObserver); 1.656 +} 1.657 + 1.658 +void 1.659 +UnregisterWakeLockObserver(WakeLockObserver* aObserver) 1.660 +{ 1.661 + AssertMainThread(); 1.662 + sWakeLockObservers.RemoveObserver(aObserver); 1.663 +} 1.664 + 1.665 +void 1.666 +ModifyWakeLock(const nsAString& aTopic, 1.667 + WakeLockControl aLockAdjust, 1.668 + WakeLockControl aHiddenAdjust, 1.669 + uint64_t aProcessID /* = CONTENT_PROCESS_ID_UNKNOWN */) 1.670 +{ 1.671 + AssertMainThread(); 1.672 + 1.673 + if (aProcessID == CONTENT_PROCESS_ID_UNKNOWN) { 1.674 + aProcessID = InSandbox() ? ContentChild::GetSingleton()->GetID() : 1.675 + CONTENT_PROCESS_ID_MAIN; 1.676 + } 1.677 + 1.678 + PROXY_IF_SANDBOXED(ModifyWakeLock(aTopic, aLockAdjust, 1.679 + aHiddenAdjust, aProcessID)); 1.680 +} 1.681 + 1.682 +void 1.683 +GetWakeLockInfo(const nsAString& aTopic, WakeLockInformation* aWakeLockInfo) 1.684 +{ 1.685 + AssertMainThread(); 1.686 + PROXY_IF_SANDBOXED(GetWakeLockInfo(aTopic, aWakeLockInfo)); 1.687 +} 1.688 + 1.689 +void 1.690 +NotifyWakeLockChange(const WakeLockInformation& aInfo) 1.691 +{ 1.692 + AssertMainThread(); 1.693 + sWakeLockObservers.BroadcastInformation(aInfo); 1.694 +} 1.695 + 1.696 +void 1.697 +RegisterScreenConfigurationObserver(ScreenConfigurationObserver* aObserver) 1.698 +{ 1.699 + AssertMainThread(); 1.700 + sScreenConfigurationObservers.AddObserver(aObserver); 1.701 +} 1.702 + 1.703 +void 1.704 +UnregisterScreenConfigurationObserver(ScreenConfigurationObserver* aObserver) 1.705 +{ 1.706 + AssertMainThread(); 1.707 + sScreenConfigurationObservers.RemoveObserver(aObserver); 1.708 +} 1.709 + 1.710 +void 1.711 +GetCurrentScreenConfiguration(ScreenConfiguration* aScreenConfiguration) 1.712 +{ 1.713 + AssertMainThread(); 1.714 + *aScreenConfiguration = sScreenConfigurationObservers.GetCurrentInformation(); 1.715 +} 1.716 + 1.717 +void 1.718 +NotifyScreenConfigurationChange(const ScreenConfiguration& aScreenConfiguration) 1.719 +{ 1.720 + sScreenConfigurationObservers.CacheInformation(aScreenConfiguration); 1.721 + sScreenConfigurationObservers.BroadcastCachedInformation(); 1.722 +} 1.723 + 1.724 +bool 1.725 +LockScreenOrientation(const dom::ScreenOrientation& aOrientation) 1.726 +{ 1.727 + AssertMainThread(); 1.728 + RETURN_PROXY_IF_SANDBOXED(LockScreenOrientation(aOrientation), false); 1.729 +} 1.730 + 1.731 +void 1.732 +UnlockScreenOrientation() 1.733 +{ 1.734 + AssertMainThread(); 1.735 + PROXY_IF_SANDBOXED(UnlockScreenOrientation()); 1.736 +} 1.737 + 1.738 +void 1.739 +EnableSwitchNotifications(SwitchDevice aDevice) { 1.740 + AssertMainThread(); 1.741 + PROXY_IF_SANDBOXED(EnableSwitchNotifications(aDevice)); 1.742 +} 1.743 + 1.744 +void 1.745 +DisableSwitchNotifications(SwitchDevice aDevice) { 1.746 + AssertMainThread(); 1.747 + PROXY_IF_SANDBOXED(DisableSwitchNotifications(aDevice)); 1.748 +} 1.749 + 1.750 +SwitchState GetCurrentSwitchState(SwitchDevice aDevice) 1.751 +{ 1.752 + AssertMainThread(); 1.753 + RETURN_PROXY_IF_SANDBOXED(GetCurrentSwitchState(aDevice), SWITCH_STATE_UNKNOWN); 1.754 +} 1.755 + 1.756 +void NotifySwitchStateFromInputDevice(SwitchDevice aDevice, SwitchState aState) 1.757 +{ 1.758 + PROXY_IF_SANDBOXED(NotifySwitchStateFromInputDevice(aDevice, aState)); 1.759 +} 1.760 + 1.761 +typedef mozilla::ObserverList<SwitchEvent> SwitchObserverList; 1.762 + 1.763 +static SwitchObserverList *sSwitchObserverLists = nullptr; 1.764 + 1.765 +static SwitchObserverList& 1.766 +GetSwitchObserverList(SwitchDevice aDevice) { 1.767 + MOZ_ASSERT(0 <= aDevice && aDevice < NUM_SWITCH_DEVICE); 1.768 + if (sSwitchObserverLists == nullptr) { 1.769 + sSwitchObserverLists = new SwitchObserverList[NUM_SWITCH_DEVICE]; 1.770 + } 1.771 + return sSwitchObserverLists[aDevice]; 1.772 +} 1.773 + 1.774 +static void 1.775 +ReleaseObserversIfNeeded() { 1.776 + for (int i = 0; i < NUM_SWITCH_DEVICE; i++) { 1.777 + if (sSwitchObserverLists[i].Length() != 0) 1.778 + return; 1.779 + } 1.780 + 1.781 + //The length of every list is 0, no observer in the list. 1.782 + delete [] sSwitchObserverLists; 1.783 + sSwitchObserverLists = nullptr; 1.784 +} 1.785 + 1.786 +void 1.787 +RegisterSwitchObserver(SwitchDevice aDevice, SwitchObserver *aObserver) 1.788 +{ 1.789 + AssertMainThread(); 1.790 + SwitchObserverList& observer = GetSwitchObserverList(aDevice); 1.791 + observer.AddObserver(aObserver); 1.792 + if (observer.Length() == 1) { 1.793 + EnableSwitchNotifications(aDevice); 1.794 + } 1.795 +} 1.796 + 1.797 +void 1.798 +UnregisterSwitchObserver(SwitchDevice aDevice, SwitchObserver *aObserver) 1.799 +{ 1.800 + AssertMainThread(); 1.801 + 1.802 + if (!sSwitchObserverLists) { 1.803 + return; 1.804 + } 1.805 + 1.806 + SwitchObserverList& observer = GetSwitchObserverList(aDevice); 1.807 + if (!observer.RemoveObserver(aObserver) || observer.Length() > 0) { 1.808 + return; 1.809 + } 1.810 + 1.811 + DisableSwitchNotifications(aDevice); 1.812 + ReleaseObserversIfNeeded(); 1.813 +} 1.814 + 1.815 +void 1.816 +NotifySwitchChange(const SwitchEvent& aEvent) 1.817 +{ 1.818 + // When callback this notification, main thread may call unregister function 1.819 + // first. We should check if this pointer is valid. 1.820 + if (!sSwitchObserverLists) 1.821 + return; 1.822 + 1.823 + SwitchObserverList& observer = GetSwitchObserverList(aEvent.device()); 1.824 + observer.Broadcast(aEvent); 1.825 +} 1.826 + 1.827 +static AlarmObserver* sAlarmObserver; 1.828 + 1.829 +bool 1.830 +RegisterTheOneAlarmObserver(AlarmObserver* aObserver) 1.831 +{ 1.832 + MOZ_ASSERT(!InSandbox()); 1.833 + MOZ_ASSERT(!sAlarmObserver); 1.834 + 1.835 + sAlarmObserver = aObserver; 1.836 + RETURN_PROXY_IF_SANDBOXED(EnableAlarm(), false); 1.837 +} 1.838 + 1.839 +void 1.840 +UnregisterTheOneAlarmObserver() 1.841 +{ 1.842 + if (sAlarmObserver) { 1.843 + sAlarmObserver = nullptr; 1.844 + PROXY_IF_SANDBOXED(DisableAlarm()); 1.845 + } 1.846 +} 1.847 + 1.848 +void 1.849 +NotifyAlarmFired() 1.850 +{ 1.851 + if (sAlarmObserver) { 1.852 + sAlarmObserver->Notify(void_t()); 1.853 + } 1.854 +} 1.855 + 1.856 +bool 1.857 +SetAlarm(int32_t aSeconds, int32_t aNanoseconds) 1.858 +{ 1.859 + // It's pointless to program an alarm nothing is going to observe ... 1.860 + MOZ_ASSERT(sAlarmObserver); 1.861 + RETURN_PROXY_IF_SANDBOXED(SetAlarm(aSeconds, aNanoseconds), false); 1.862 +} 1.863 + 1.864 +void 1.865 +SetProcessPriority(int aPid, 1.866 + ProcessPriority aPriority, 1.867 + ProcessCPUPriority aCPUPriority, 1.868 + uint32_t aBackgroundLRU) 1.869 +{ 1.870 + // n.b. The sandboxed implementation crashes; SetProcessPriority works only 1.871 + // from the main process. 1.872 + MOZ_ASSERT(aBackgroundLRU == 0 || aPriority == PROCESS_PRIORITY_BACKGROUND); 1.873 + PROXY_IF_SANDBOXED(SetProcessPriority(aPid, aPriority, aCPUPriority, 1.874 + aBackgroundLRU)); 1.875 +} 1.876 + 1.877 +// From HalTypes.h. 1.878 +const char* 1.879 +ProcessPriorityToString(ProcessPriority aPriority) 1.880 +{ 1.881 + switch (aPriority) { 1.882 + case PROCESS_PRIORITY_MASTER: 1.883 + return "MASTER"; 1.884 + case PROCESS_PRIORITY_PREALLOC: 1.885 + return "PREALLOC"; 1.886 + case PROCESS_PRIORITY_FOREGROUND_HIGH: 1.887 + return "FOREGROUND_HIGH"; 1.888 + case PROCESS_PRIORITY_FOREGROUND: 1.889 + return "FOREGROUND"; 1.890 + case PROCESS_PRIORITY_FOREGROUND_KEYBOARD: 1.891 + return "FOREGROUND_KEYBOARD"; 1.892 + case PROCESS_PRIORITY_BACKGROUND_PERCEIVABLE: 1.893 + return "BACKGROUND_PERCEIVABLE"; 1.894 + case PROCESS_PRIORITY_BACKGROUND_HOMESCREEN: 1.895 + return "BACKGROUND_HOMESCREEN"; 1.896 + case PROCESS_PRIORITY_BACKGROUND: 1.897 + return "BACKGROUND"; 1.898 + case PROCESS_PRIORITY_UNKNOWN: 1.899 + return "UNKNOWN"; 1.900 + default: 1.901 + MOZ_ASSERT(false); 1.902 + return "???"; 1.903 + } 1.904 +} 1.905 + 1.906 +// From HalTypes.h. 1.907 +const char* 1.908 +ProcessPriorityToString(ProcessPriority aPriority, 1.909 + ProcessCPUPriority aCPUPriority) 1.910 +{ 1.911 + // Sorry this is ugly. At least it's all in one place. 1.912 + // 1.913 + // We intentionally fall through if aCPUPriority is invalid; we won't hit any 1.914 + // of the if statements further down, so it's OK. 1.915 + 1.916 + switch (aPriority) { 1.917 + case PROCESS_PRIORITY_MASTER: 1.918 + if (aCPUPriority == PROCESS_CPU_PRIORITY_NORMAL) { 1.919 + return "MASTER:CPU_NORMAL"; 1.920 + } 1.921 + if (aCPUPriority == PROCESS_CPU_PRIORITY_LOW) { 1.922 + return "MASTER:CPU_LOW"; 1.923 + } 1.924 + case PROCESS_PRIORITY_PREALLOC: 1.925 + if (aCPUPriority == PROCESS_CPU_PRIORITY_NORMAL) { 1.926 + return "PREALLOC:CPU_NORMAL"; 1.927 + } 1.928 + if (aCPUPriority == PROCESS_CPU_PRIORITY_LOW) { 1.929 + return "PREALLOC:CPU_LOW"; 1.930 + } 1.931 + case PROCESS_PRIORITY_FOREGROUND_HIGH: 1.932 + if (aCPUPriority == PROCESS_CPU_PRIORITY_NORMAL) { 1.933 + return "FOREGROUND_HIGH:CPU_NORMAL"; 1.934 + } 1.935 + if (aCPUPriority == PROCESS_CPU_PRIORITY_LOW) { 1.936 + return "FOREGROUND_HIGH:CPU_LOW"; 1.937 + } 1.938 + case PROCESS_PRIORITY_FOREGROUND: 1.939 + if (aCPUPriority == PROCESS_CPU_PRIORITY_NORMAL) { 1.940 + return "FOREGROUND:CPU_NORMAL"; 1.941 + } 1.942 + if (aCPUPriority == PROCESS_CPU_PRIORITY_LOW) { 1.943 + return "FOREGROUND:CPU_LOW"; 1.944 + } 1.945 + case PROCESS_PRIORITY_FOREGROUND_KEYBOARD: 1.946 + if (aCPUPriority == PROCESS_CPU_PRIORITY_NORMAL) { 1.947 + return "FOREGROUND_KEYBOARD:CPU_NORMAL"; 1.948 + } 1.949 + if (aCPUPriority == PROCESS_CPU_PRIORITY_LOW) { 1.950 + return "FOREGROUND_KEYBOARD:CPU_LOW"; 1.951 + } 1.952 + case PROCESS_PRIORITY_BACKGROUND_PERCEIVABLE: 1.953 + if (aCPUPriority == PROCESS_CPU_PRIORITY_NORMAL) { 1.954 + return "BACKGROUND_PERCEIVABLE:CPU_NORMAL"; 1.955 + } 1.956 + if (aCPUPriority == PROCESS_CPU_PRIORITY_LOW) { 1.957 + return "BACKGROUND_PERCEIVABLE:CPU_LOW"; 1.958 + } 1.959 + case PROCESS_PRIORITY_BACKGROUND_HOMESCREEN: 1.960 + if (aCPUPriority == PROCESS_CPU_PRIORITY_NORMAL) { 1.961 + return "BACKGROUND_HOMESCREEN:CPU_NORMAL"; 1.962 + } 1.963 + if (aCPUPriority == PROCESS_CPU_PRIORITY_LOW) { 1.964 + return "BACKGROUND_HOMESCREEN:CPU_LOW"; 1.965 + } 1.966 + case PROCESS_PRIORITY_BACKGROUND: 1.967 + if (aCPUPriority == PROCESS_CPU_PRIORITY_NORMAL) { 1.968 + return "BACKGROUND:CPU_NORMAL"; 1.969 + } 1.970 + if (aCPUPriority == PROCESS_CPU_PRIORITY_LOW) { 1.971 + return "BACKGROUND:CPU_LOW"; 1.972 + } 1.973 + case PROCESS_PRIORITY_UNKNOWN: 1.974 + if (aCPUPriority == PROCESS_CPU_PRIORITY_NORMAL) { 1.975 + return "UNKNOWN:CPU_NORMAL"; 1.976 + } 1.977 + if (aCPUPriority == PROCESS_CPU_PRIORITY_LOW) { 1.978 + return "UNKNOWN:CPU_LOW"; 1.979 + } 1.980 + default: 1.981 + // Fall through. (|default| is here to silence warnings.) 1.982 + break; 1.983 + } 1.984 + 1.985 + MOZ_ASSERT(false); 1.986 + return "???"; 1.987 +} 1.988 + 1.989 +static StaticAutoPtr<ObserverList<FMRadioOperationInformation> > sFMRadioObservers; 1.990 + 1.991 +static void 1.992 +InitializeFMRadioObserver() 1.993 +{ 1.994 + if (!sFMRadioObservers) { 1.995 + sFMRadioObservers = new ObserverList<FMRadioOperationInformation>; 1.996 + ClearOnShutdown(&sFMRadioObservers); 1.997 + } 1.998 +} 1.999 + 1.1000 +void 1.1001 +RegisterFMRadioObserver(FMRadioObserver* aFMRadioObserver) { 1.1002 + AssertMainThread(); 1.1003 + InitializeFMRadioObserver(); 1.1004 + sFMRadioObservers->AddObserver(aFMRadioObserver); 1.1005 +} 1.1006 + 1.1007 +void 1.1008 +UnregisterFMRadioObserver(FMRadioObserver* aFMRadioObserver) { 1.1009 + AssertMainThread(); 1.1010 + InitializeFMRadioObserver(); 1.1011 + sFMRadioObservers->RemoveObserver(aFMRadioObserver); 1.1012 +} 1.1013 + 1.1014 +void 1.1015 +NotifyFMRadioStatus(const FMRadioOperationInformation& aFMRadioState) { 1.1016 + InitializeFMRadioObserver(); 1.1017 + sFMRadioObservers->Broadcast(aFMRadioState); 1.1018 +} 1.1019 + 1.1020 +void 1.1021 +EnableFMRadio(const FMRadioSettings& aInfo) { 1.1022 + AssertMainThread(); 1.1023 + PROXY_IF_SANDBOXED(EnableFMRadio(aInfo)); 1.1024 +} 1.1025 + 1.1026 +void 1.1027 +DisableFMRadio() { 1.1028 + AssertMainThread(); 1.1029 + PROXY_IF_SANDBOXED(DisableFMRadio()); 1.1030 +} 1.1031 + 1.1032 +void 1.1033 +FMRadioSeek(const FMRadioSeekDirection& aDirection) { 1.1034 + AssertMainThread(); 1.1035 + PROXY_IF_SANDBOXED(FMRadioSeek(aDirection)); 1.1036 +} 1.1037 + 1.1038 +void 1.1039 +GetFMRadioSettings(FMRadioSettings* aInfo) { 1.1040 + AssertMainThread(); 1.1041 + PROXY_IF_SANDBOXED(GetFMRadioSettings(aInfo)); 1.1042 +} 1.1043 + 1.1044 +void 1.1045 +SetFMRadioFrequency(const uint32_t aFrequency) { 1.1046 + AssertMainThread(); 1.1047 + PROXY_IF_SANDBOXED(SetFMRadioFrequency(aFrequency)); 1.1048 +} 1.1049 + 1.1050 +uint32_t 1.1051 +GetFMRadioFrequency() { 1.1052 + AssertMainThread(); 1.1053 + RETURN_PROXY_IF_SANDBOXED(GetFMRadioFrequency(), 0); 1.1054 +} 1.1055 + 1.1056 +bool 1.1057 +IsFMRadioOn() { 1.1058 + AssertMainThread(); 1.1059 + RETURN_PROXY_IF_SANDBOXED(IsFMRadioOn(), false); 1.1060 +} 1.1061 + 1.1062 +uint32_t 1.1063 +GetFMRadioSignalStrength() { 1.1064 + AssertMainThread(); 1.1065 + RETURN_PROXY_IF_SANDBOXED(GetFMRadioSignalStrength(), 0); 1.1066 +} 1.1067 + 1.1068 +void 1.1069 +CancelFMRadioSeek() { 1.1070 + AssertMainThread(); 1.1071 + PROXY_IF_SANDBOXED(CancelFMRadioSeek()); 1.1072 +} 1.1073 + 1.1074 +FMRadioSettings 1.1075 +GetFMBandSettings(FMRadioCountry aCountry) { 1.1076 + FMRadioSettings settings; 1.1077 + 1.1078 + switch (aCountry) { 1.1079 + case FM_RADIO_COUNTRY_US: 1.1080 + case FM_RADIO_COUNTRY_EU: 1.1081 + settings.upperLimit() = 108000; 1.1082 + settings.lowerLimit() = 87800; 1.1083 + settings.spaceType() = 200; 1.1084 + settings.preEmphasis() = 75; 1.1085 + break; 1.1086 + case FM_RADIO_COUNTRY_JP_STANDARD: 1.1087 + settings.upperLimit() = 76000; 1.1088 + settings.lowerLimit() = 90000; 1.1089 + settings.spaceType() = 100; 1.1090 + settings.preEmphasis() = 50; 1.1091 + break; 1.1092 + case FM_RADIO_COUNTRY_CY: 1.1093 + case FM_RADIO_COUNTRY_DE: 1.1094 + case FM_RADIO_COUNTRY_DK: 1.1095 + case FM_RADIO_COUNTRY_ES: 1.1096 + case FM_RADIO_COUNTRY_FI: 1.1097 + case FM_RADIO_COUNTRY_FR: 1.1098 + case FM_RADIO_COUNTRY_HU: 1.1099 + case FM_RADIO_COUNTRY_IR: 1.1100 + case FM_RADIO_COUNTRY_IT: 1.1101 + case FM_RADIO_COUNTRY_KW: 1.1102 + case FM_RADIO_COUNTRY_LT: 1.1103 + case FM_RADIO_COUNTRY_ML: 1.1104 + case FM_RADIO_COUNTRY_NO: 1.1105 + case FM_RADIO_COUNTRY_OM: 1.1106 + case FM_RADIO_COUNTRY_PG: 1.1107 + case FM_RADIO_COUNTRY_NL: 1.1108 + case FM_RADIO_COUNTRY_CZ: 1.1109 + case FM_RADIO_COUNTRY_UK: 1.1110 + case FM_RADIO_COUNTRY_RW: 1.1111 + case FM_RADIO_COUNTRY_SN: 1.1112 + case FM_RADIO_COUNTRY_SI: 1.1113 + case FM_RADIO_COUNTRY_ZA: 1.1114 + case FM_RADIO_COUNTRY_SE: 1.1115 + case FM_RADIO_COUNTRY_CH: 1.1116 + case FM_RADIO_COUNTRY_TW: 1.1117 + case FM_RADIO_COUNTRY_UA: 1.1118 + settings.upperLimit() = 108000; 1.1119 + settings.lowerLimit() = 87500; 1.1120 + settings.spaceType() = 100; 1.1121 + settings.preEmphasis() = 50; 1.1122 + break; 1.1123 + case FM_RADIO_COUNTRY_VA: 1.1124 + case FM_RADIO_COUNTRY_MA: 1.1125 + case FM_RADIO_COUNTRY_TR: 1.1126 + settings.upperLimit() = 10800; 1.1127 + settings.lowerLimit() = 87500; 1.1128 + settings.spaceType() = 100; 1.1129 + settings.preEmphasis() = 75; 1.1130 + break; 1.1131 + case FM_RADIO_COUNTRY_AU: 1.1132 + case FM_RADIO_COUNTRY_BD: 1.1133 + settings.upperLimit() = 108000; 1.1134 + settings.lowerLimit() = 87500; 1.1135 + settings.spaceType() = 200; 1.1136 + settings.preEmphasis() = 75; 1.1137 + break; 1.1138 + case FM_RADIO_COUNTRY_AW: 1.1139 + case FM_RADIO_COUNTRY_BS: 1.1140 + case FM_RADIO_COUNTRY_CO: 1.1141 + case FM_RADIO_COUNTRY_KR: 1.1142 + settings.upperLimit() = 108000; 1.1143 + settings.lowerLimit() = 88000; 1.1144 + settings.spaceType() = 200; 1.1145 + settings.preEmphasis() = 75; 1.1146 + break; 1.1147 + case FM_RADIO_COUNTRY_EC: 1.1148 + settings.upperLimit() = 108000; 1.1149 + settings.lowerLimit() = 88000; 1.1150 + settings.spaceType() = 200; 1.1151 + settings.preEmphasis() = 0; 1.1152 + break; 1.1153 + case FM_RADIO_COUNTRY_GM: 1.1154 + settings.upperLimit() = 108000; 1.1155 + settings.lowerLimit() = 88000; 1.1156 + settings.spaceType() = 0; 1.1157 + settings.preEmphasis() = 75; 1.1158 + break; 1.1159 + case FM_RADIO_COUNTRY_QA: 1.1160 + settings.upperLimit() = 108000; 1.1161 + settings.lowerLimit() = 88000; 1.1162 + settings.spaceType() = 200; 1.1163 + settings.preEmphasis() = 50; 1.1164 + break; 1.1165 + case FM_RADIO_COUNTRY_SG: 1.1166 + settings.upperLimit() = 108000; 1.1167 + settings.lowerLimit() = 88000; 1.1168 + settings.spaceType() = 200; 1.1169 + settings.preEmphasis() = 50; 1.1170 + break; 1.1171 + case FM_RADIO_COUNTRY_IN: 1.1172 + settings.upperLimit() = 100000; 1.1173 + settings.lowerLimit() = 108000; 1.1174 + settings.spaceType() = 100; 1.1175 + settings.preEmphasis() = 50; 1.1176 + break; 1.1177 + case FM_RADIO_COUNTRY_NZ: 1.1178 + settings.upperLimit() = 100000; 1.1179 + settings.lowerLimit() = 88000; 1.1180 + settings.spaceType() = 50; 1.1181 + settings.preEmphasis() = 50; 1.1182 + break; 1.1183 + case FM_RADIO_COUNTRY_USER_DEFINED: 1.1184 + break; 1.1185 + default: 1.1186 + MOZ_ASSERT(0); 1.1187 + break; 1.1188 + }; 1.1189 + return settings; 1.1190 +} 1.1191 + 1.1192 +void FactoryReset() 1.1193 +{ 1.1194 + AssertMainThread(); 1.1195 + PROXY_IF_SANDBOXED(FactoryReset()); 1.1196 +} 1.1197 + 1.1198 +void 1.1199 +StartDiskSpaceWatcher() 1.1200 +{ 1.1201 + AssertMainProcess(); 1.1202 + AssertMainThread(); 1.1203 + PROXY_IF_SANDBOXED(StartDiskSpaceWatcher()); 1.1204 +} 1.1205 + 1.1206 +void 1.1207 +StopDiskSpaceWatcher() 1.1208 +{ 1.1209 + AssertMainProcess(); 1.1210 + AssertMainThread(); 1.1211 + PROXY_IF_SANDBOXED(StopDiskSpaceWatcher()); 1.1212 +} 1.1213 + 1.1214 +uint32_t 1.1215 +GetTotalSystemMemory() 1.1216 +{ 1.1217 + return hal_impl::GetTotalSystemMemory(); 1.1218 +} 1.1219 + 1.1220 + 1.1221 +} // namespace hal 1.1222 +} // namespace mozilla