From 63522e8e280a1b76a96be6095e8f9d92882a45e7 Mon Sep 17 00:00:00 2001 From: Gabriele Svelto Date: Mon, 11 Jun 2018 00:22:56 +0200 Subject: Remove unused code for managing physical audio devices. This was only used in B2G/Gonk and can go. --- hal/Hal.cpp | 90 ----------------------------------------- hal/Hal.h | 31 -------------- hal/HalInternal.h | 10 ----- hal/HalTypes.h | 42 ------------------- hal/fallback/FallbackSwitch.cpp | 20 --------- hal/sandbox/PHal.ipdl | 13 ------ hal/sandbox/SandboxHal.cpp | 67 ------------------------------ 7 files changed, 273 deletions(-) (limited to 'hal') diff --git a/hal/Hal.cpp b/hal/Hal.cpp index 8ac9e6847..16201a2d8 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 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 e45bbcde2..224b4c451 100644 --- a/hal/Hal.h +++ b/hal/Hal.h @@ -401,37 +401,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 d93023dd0..ea997c2f4 100644 --- a/hal/HalInternal.h +++ b/hal/HalInternal.h @@ -54,16 +54,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. */ diff --git a/hal/HalTypes.h b/hal/HalTypes.h index 5f0ad3ff7..dc29f0553 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 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::NUM_WAKE_LOCK> {}; -/** - * Serializer for SwitchState - */ -template <> -struct ParamTraits: - public ContiguousEnumSerializer< - mozilla::hal::SwitchState, - mozilla::hal::SWITCH_STATE_UNKNOWN, - mozilla::hal::NUM_SWITCH_STATE> { -}; - -/** - * Serializer for SwitchDevice - */ -template <> -struct ParamTraits: - public ContiguousEnumSerializer< - mozilla::hal::SwitchDevice, - mozilla::hal::SWITCH_DEVICE_UNKNOWN, - mozilla::hal::NUM_SWITCH_DEVICE> { -}; - template <> struct ParamTraits: public ContiguousEnumSerializer< diff --git a/hal/fallback/FallbackSwitch.cpp b/hal/fallback/FallbackSwitch.cpp index e9b7eab0a..38d6a50e9 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 37b69f93f..1af550aff 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 d33a53a2f..9771b3ef6 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); @@ -868,12 +807,6 @@ public: return true; } - 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); -- cgit v1.2.3