summaryrefslogtreecommitdiff
path: root/hal
diff options
context:
space:
mode:
authorGabriele Svelto <gsvelto@mozilla.com>2018-06-11 00:22:56 +0200
committerwolfbeast <mcwerewolf@gmail.com>2018-06-29 08:23:41 +0200
commit6db714a56d701a964c19dd03880d5fdc45bd690f (patch)
tree89a64bca6417641f5a56c16e83b9d5eb2f77eb6f /hal
parentd6a7d1cff8be12e9ac7ddad2a69fc1e6bb54d6c8 (diff)
downloaduxp-6db714a56d701a964c19dd03880d5fdc45bd690f.tar.gz
Remove unused code for managing physical audio devices.
This was only used in B2G/Gonk and can go.
Diffstat (limited to 'hal')
-rw-r--r--hal/Hal.cpp90
-rw-r--r--hal/Hal.h31
-rw-r--r--hal/HalInternal.h10
-rw-r--r--hal/HalTypes.h42
-rw-r--r--hal/fallback/FallbackSwitch.cpp20
-rw-r--r--hal/sandbox/PHal.ipdl13
-rw-r--r--hal/sandbox/SandboxHal.cpp67
7 files changed, 0 insertions, 273 deletions
diff --git a/hal/Hal.cpp b/hal/Hal.cpp
index 8ac9e68470..16201a2d8d 100644
--- a/hal/Hal.cpp
+++ b/hal/Hal.cpp
@@ -754,96 +754,6 @@ UnlockScreenOrientation()
PROXY_IF_SANDBOXED(UnlockScreenOrientation());
}
-void
-EnableSwitchNotifications(SwitchDevice aDevice) {
- AssertMainThread();
- PROXY_IF_SANDBOXED(EnableSwitchNotifications(aDevice));
-}
-
-void
-DisableSwitchNotifications(SwitchDevice aDevice) {
- AssertMainThread();
- PROXY_IF_SANDBOXED(DisableSwitchNotifications(aDevice));
-}
-
-SwitchState GetCurrentSwitchState(SwitchDevice aDevice)
-{
- AssertMainThread();
- RETURN_PROXY_IF_SANDBOXED(GetCurrentSwitchState(aDevice), SWITCH_STATE_UNKNOWN);
-}
-
-void NotifySwitchStateFromInputDevice(SwitchDevice aDevice, SwitchState aState)
-{
- AssertMainThread();
- PROXY_IF_SANDBOXED(NotifySwitchStateFromInputDevice(aDevice, aState));
-}
-
-typedef mozilla::ObserverList<SwitchEvent> SwitchObserverList;
-
-static SwitchObserverList *sSwitchObserverLists = nullptr;
-
-static SwitchObserverList&
-GetSwitchObserverList(SwitchDevice aDevice) {
- MOZ_ASSERT(0 <= aDevice && aDevice < NUM_SWITCH_DEVICE);
- if (sSwitchObserverLists == nullptr) {
- sSwitchObserverLists = new SwitchObserverList[NUM_SWITCH_DEVICE];
- }
- return sSwitchObserverLists[aDevice];
-}
-
-static void
-ReleaseObserversIfNeeded() {
- for (int i = 0; i < NUM_SWITCH_DEVICE; i++) {
- if (sSwitchObserverLists[i].Length() != 0)
- return;
- }
-
- //The length of every list is 0, no observer in the list.
- delete [] sSwitchObserverLists;
- sSwitchObserverLists = nullptr;
-}
-
-void
-RegisterSwitchObserver(SwitchDevice aDevice, SwitchObserver *aObserver)
-{
- AssertMainThread();
- SwitchObserverList& observer = GetSwitchObserverList(aDevice);
- observer.AddObserver(aObserver);
- if (observer.Length() == 1) {
- EnableSwitchNotifications(aDevice);
- }
-}
-
-void
-UnregisterSwitchObserver(SwitchDevice aDevice, SwitchObserver *aObserver)
-{
- AssertMainThread();
-
- if (!sSwitchObserverLists) {
- return;
- }
-
- SwitchObserverList& observer = GetSwitchObserverList(aDevice);
- if (!observer.RemoveObserver(aObserver) || observer.Length() > 0) {
- return;
- }
-
- DisableSwitchNotifications(aDevice);
- ReleaseObserversIfNeeded();
-}
-
-void
-NotifySwitchChange(const SwitchEvent& aEvent)
-{
- // When callback this notification, main thread may call unregister function
- // first. We should check if this pointer is valid.
- if (!sSwitchObserverLists)
- return;
-
- SwitchObserverList& observer = GetSwitchObserverList(aEvent.device());
- observer.Broadcast(aEvent);
-}
-
static AlarmObserver* sAlarmObserver;
bool
diff --git a/hal/Hal.h b/hal/Hal.h
index e45bbcde24..224b4c451e 100644
--- a/hal/Hal.h
+++ b/hal/Hal.h
@@ -402,37 +402,6 @@ MOZ_MUST_USE bool LockScreenOrientation(const dom::ScreenOrientationInternal& aO
void UnlockScreenOrientation();
/**
- * Register an observer for the switch of given SwitchDevice.
- *
- * The observer will receive data whenever the data generated by the
- * given switch.
- */
-void RegisterSwitchObserver(hal::SwitchDevice aDevice, hal::SwitchObserver *aSwitchObserver);
-
-/**
- * Unregister an observer for the switch of given SwitchDevice.
- */
-void UnregisterSwitchObserver(hal::SwitchDevice aDevice, hal::SwitchObserver *aSwitchObserver);
-
-/**
- * Notify the state of the switch.
- *
- * This API is internal to hal; clients shouldn't call it directly.
- */
-void NotifySwitchChange(const hal::SwitchEvent& aEvent);
-
-/**
- * Get current switch information.
- */
-hal::SwitchState GetCurrentSwitchState(hal::SwitchDevice aDevice);
-
-/**
- * Notify switch status change from input device.
- */
-void NotifySwitchStateFromInputDevice(hal::SwitchDevice aDevice,
- hal::SwitchState aState);
-
-/**
* Register an observer that is notified when a programmed alarm
* expires.
*
diff --git a/hal/HalInternal.h b/hal/HalInternal.h
index d93023dd0d..ea997c2f48 100644
--- a/hal/HalInternal.h
+++ b/hal/HalInternal.h
@@ -55,16 +55,6 @@ void EnableScreenConfigurationNotifications();
void DisableScreenConfigurationNotifications();
/**
- * Enable switch notifications from the backend
- */
-void EnableSwitchNotifications(hal::SwitchDevice aDevice);
-
-/**
- * Disable switch notifications from the backend
- */
-void DisableSwitchNotifications(hal::SwitchDevice aDevice);
-
-/**
* Enable alarm notifications from the backend.
*/
MOZ_MUST_USE bool EnableAlarm();
diff --git a/hal/HalTypes.h b/hal/HalTypes.h
index 5f0ad3ff7b..dc29f0553b 100644
--- a/hal/HalTypes.h
+++ b/hal/HalTypes.h
@@ -33,26 +33,6 @@ enum ShutdownMode {
eHalShutdownMode_Count = 3
};
-class SwitchEvent;
-
-enum SwitchDevice {
- SWITCH_DEVICE_UNKNOWN = -1,
- SWITCH_HEADPHONES,
- SWITCH_USB,
- NUM_SWITCH_DEVICE
-};
-
-enum SwitchState {
- SWITCH_STATE_UNKNOWN = -1,
- SWITCH_STATE_ON,
- SWITCH_STATE_OFF,
- SWITCH_STATE_HEADSET, // Headphone with microphone
- SWITCH_STATE_HEADPHONE, // without microphone
- NUM_SWITCH_STATE
-};
-
-typedef Observer<SwitchEvent> SwitchObserver;
-
// Note that we rely on the order of this enum's entries. Higher priorities
// should have larger int values.
enum ProcessPriority {
@@ -141,28 +121,6 @@ struct ParamTraits<mozilla::hal::WakeLockControl>
mozilla::hal::NUM_WAKE_LOCK>
{};
-/**
- * Serializer for SwitchState
- */
-template <>
-struct ParamTraits<mozilla::hal::SwitchState>:
- public ContiguousEnumSerializer<
- mozilla::hal::SwitchState,
- mozilla::hal::SWITCH_STATE_UNKNOWN,
- mozilla::hal::NUM_SWITCH_STATE> {
-};
-
-/**
- * Serializer for SwitchDevice
- */
-template <>
-struct ParamTraits<mozilla::hal::SwitchDevice>:
- public ContiguousEnumSerializer<
- mozilla::hal::SwitchDevice,
- mozilla::hal::SWITCH_DEVICE_UNKNOWN,
- mozilla::hal::NUM_SWITCH_DEVICE> {
-};
-
template <>
struct ParamTraits<mozilla::hal::ProcessPriority>:
public ContiguousEnumSerializer<
diff --git a/hal/fallback/FallbackSwitch.cpp b/hal/fallback/FallbackSwitch.cpp
index e9b7eab0ae..38d6a50e92 100644
--- a/hal/fallback/FallbackSwitch.cpp
+++ b/hal/fallback/FallbackSwitch.cpp
@@ -10,26 +10,6 @@ using namespace mozilla::hal;
namespace mozilla {
namespace hal_impl {
-void
-EnableSwitchNotifications(SwitchDevice aDevice)
-{
-}
-
-void
-DisableSwitchNotifications(SwitchDevice aDevice)
-{
-}
-
-SwitchState
-GetCurrentSwitchState(SwitchDevice aDevice) {
- return SWITCH_STATE_UNKNOWN;
-}
-
-void
-NotifySwitchStateFromInputDevice(SwitchDevice aDevice, SwitchState aState)
-{
-}
-
bool IsHeadphoneEventFromInputDev()
{
return false;
diff --git a/hal/sandbox/PHal.ipdl b/hal/sandbox/PHal.ipdl
index 37b69f93fe..1af550aff4 100644
--- a/hal/sandbox/PHal.ipdl
+++ b/hal/sandbox/PHal.ipdl
@@ -13,8 +13,6 @@ using mozilla::dom::ScreenOrientationInternal from "mozilla/dom/ScreenOrientatio
using mozilla::hal::SensorType from "mozilla/HalSensor.h";
using mozilla::hal::SensorAccuracyType from "mozilla/HalSensor.h";
using mozilla::hal::WakeLockControl from "mozilla/HalTypes.h";
-using mozilla::hal::SwitchState from "mozilla/HalTypes.h";
-using mozilla::hal::SwitchDevice from "mozilla/HalTypes.h";
using mozilla::hal::ProcessPriority from "mozilla/HalTypes.h";
using nsIntRect from "nsRect.h";
using PRTime from "prtime.h";
@@ -41,11 +39,6 @@ struct NetworkInformation {
uint32_t dhcpGateway;
};
-struct SwitchEvent {
- SwitchDevice device;
- SwitchState status;
-};
-
struct WakeLockInformation {
nsString topic;
uint32_t numLocks;
@@ -80,7 +73,6 @@ child:
async NotifyNetworkChange(NetworkInformation aNetworkInfo);
async NotifyWakeLockChange(WakeLockInformation aWakeLockInfo);
async NotifyScreenConfigurationChange(ScreenConfiguration aScreenOrientation);
- async NotifySwitchChange(SwitchEvent aEvent);
async NotifySystemClockChange(int64_t aClockDeltaMS);
async NotifySystemTimezoneChange(SystemTimezoneChangeInformation aSystemTimezoneChangeInfo);
@@ -138,11 +130,6 @@ parent:
returns (bool allowed);
async UnlockScreenOrientation();
- async EnableSwitchNotifications(SwitchDevice aDevice);
- async DisableSwitchNotifications(SwitchDevice aDevice);
- sync GetCurrentSwitchState(SwitchDevice aDevice)
- returns (SwitchState aState);
-
async FactoryReset(nsString aReason);
child:
diff --git a/hal/sandbox/SandboxHal.cpp b/hal/sandbox/SandboxHal.cpp
index d33a53a2fb..9771b3ef64 100644
--- a/hal/sandbox/SandboxHal.cpp
+++ b/hal/sandbox/SandboxHal.cpp
@@ -300,34 +300,6 @@ GetWakeLockInfo(const nsAString &aTopic, WakeLockInformation *aWakeLockInfo)
Hal()->SendGetWakeLockInfo(nsString(aTopic), aWakeLockInfo);
}
-void
-EnableSwitchNotifications(SwitchDevice aDevice)
-{
- Hal()->SendEnableSwitchNotifications(aDevice);
-}
-
-void
-DisableSwitchNotifications(SwitchDevice aDevice)
-{
- Hal()->SendDisableSwitchNotifications(aDevice);
-}
-
-SwitchState
-GetCurrentSwitchState(SwitchDevice aDevice)
-{
- SwitchState state;
- Hal()->SendGetCurrentSwitchState(aDevice, &state);
- return state;
-}
-
-void
-NotifySwitchStateFromInputDevice(SwitchDevice aDevice, SwitchState aState)
-{
- Unused << aDevice;
- Unused << aState;
- NS_RUNTIMEABORT("Only the main process may notify switch state change.");
-}
-
bool
EnableAlarm()
{
@@ -420,7 +392,6 @@ class HalParent : public PHalParent
, public ISensorObserver
, public WakeLockObserver
, public ScreenConfigurationObserver
- , public SwitchObserver
, public SystemClockChangeObserver
, public SystemTimezoneChangeObserver
{
@@ -440,10 +411,6 @@ public:
hal::UnregisterWakeLockObserver(this);
hal::UnregisterSystemClockChangeObserver(this);
hal::UnregisterSystemTimezoneChangeObserver(this);
- for (int32_t switchDevice = SWITCH_DEVICE_UNKNOWN + 1;
- switchDevice < NUM_SWITCH_DEVICE; ++switchDevice) {
- hal::UnregisterSwitchObserver(SwitchDevice(switchDevice), this);
- }
}
virtual bool
@@ -771,34 +738,6 @@ public:
Unused << SendNotifyWakeLockChange(aWakeLockInfo);
}
- virtual bool
- RecvEnableSwitchNotifications(const SwitchDevice& aDevice) override
- {
- // Content has no reason to listen to switch events currently.
- hal::RegisterSwitchObserver(aDevice, this);
- return true;
- }
-
- virtual bool
- RecvDisableSwitchNotifications(const SwitchDevice& aDevice) override
- {
- hal::UnregisterSwitchObserver(aDevice, this);
- return true;
- }
-
- void Notify(const SwitchEvent& aSwitchEvent) override
- {
- Unused << SendNotifySwitchChange(aSwitchEvent);
- }
-
- virtual bool
- RecvGetCurrentSwitchState(const SwitchDevice& aDevice, hal::SwitchState *aState) override
- {
- // Content has no reason to listen to switch events currently.
- *aState = hal::GetCurrentSwitchState(aDevice);
- return true;
- }
-
void Notify(const int64_t& aClockDeltaMS) override
{
Unused << SendNotifySystemClockChange(aClockDeltaMS);
@@ -869,12 +808,6 @@ public:
}
virtual bool
- RecvNotifySwitchChange(const mozilla::hal::SwitchEvent& aEvent) override {
- hal::NotifySwitchChange(aEvent);
- return true;
- }
-
- virtual bool
RecvNotifySystemClockChange(const int64_t& aClockDeltaMS) override {
hal::NotifySystemClockChange(aClockDeltaMS);
return true;