mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 964154 - To Detect Whether Headset Event is Came from Input Dev or /sys Node in Runtime Not by Property. r=dhylands
This commit is contained in:
parent
702ff05ae0
commit
928904ed0c
@ -1239,5 +1239,11 @@ GetTotalSystemMemoryLevel()
|
|||||||
return hal_impl::GetTotalSystemMemoryLevel();
|
return hal_impl::GetTotalSystemMemoryLevel();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool IsHeadphoneEventFromInputDev()
|
||||||
|
{
|
||||||
|
AssertMainThread();
|
||||||
|
RETURN_PROXY_IF_SANDBOXED(IsHeadphoneEventFromInputDev(), false);
|
||||||
|
}
|
||||||
|
|
||||||
} // namespace hal
|
} // namespace hal
|
||||||
} // namespace mozilla
|
} // namespace mozilla
|
||||||
|
@ -616,6 +616,11 @@ uint32_t GetTotalSystemMemory();
|
|||||||
*/
|
*/
|
||||||
uint32_t GetTotalSystemMemoryLevel();
|
uint32_t GetTotalSystemMemoryLevel();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Determine whether the headphone switch event is from input device
|
||||||
|
*/
|
||||||
|
bool IsHeadphoneEventFromInputDev();
|
||||||
|
|
||||||
} // namespace MOZ_HAL_NAMESPACE
|
} // namespace MOZ_HAL_NAMESPACE
|
||||||
} // namespace mozilla
|
} // namespace mozilla
|
||||||
|
|
||||||
|
@ -30,5 +30,10 @@ NotifySwitchStateFromInputDevice(SwitchDevice aDevice, SwitchState aState)
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool IsHeadphoneEventFromInputDev()
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
} // namespace hal_impl
|
} // namespace hal_impl
|
||||||
} // namespace mozilla
|
} // namespace mozilla
|
||||||
|
@ -17,7 +17,6 @@
|
|||||||
#include <android/log.h>
|
#include <android/log.h>
|
||||||
#include <fcntl.h>
|
#include <fcntl.h>
|
||||||
#include <sysutils/NetlinkEvent.h>
|
#include <sysutils/NetlinkEvent.h>
|
||||||
#include <cutils/properties.h>
|
|
||||||
|
|
||||||
#include "base/message_loop.h"
|
#include "base/message_loop.h"
|
||||||
|
|
||||||
@ -240,7 +239,9 @@ class SwitchEventObserver MOZ_FINAL : public IUeventObserver
|
|||||||
|
|
||||||
public:
|
public:
|
||||||
NS_INLINE_DECL_REFCOUNTING(SwitchEventObserver)
|
NS_INLINE_DECL_REFCOUNTING(SwitchEventObserver)
|
||||||
SwitchEventObserver() : mEnableCount(0)
|
SwitchEventObserver()
|
||||||
|
: mEnableCount(0),
|
||||||
|
mHeadphonesFromInputDev(false)
|
||||||
{
|
{
|
||||||
Init();
|
Init();
|
||||||
}
|
}
|
||||||
@ -309,6 +310,12 @@ public:
|
|||||||
NS_DispatchToMainThread(new SwitchEventRunnable(info.mEvent));
|
NS_DispatchToMainThread(new SwitchEventRunnable(info.mEvent));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool GetHeadphonesFromInputDev()
|
||||||
|
{
|
||||||
|
return mHeadphonesFromInputDev;
|
||||||
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
class EventInfo
|
class EventInfo
|
||||||
{
|
{
|
||||||
@ -325,15 +332,18 @@ private:
|
|||||||
EventInfo mEventInfo[NUM_SWITCH_DEVICE];
|
EventInfo mEventInfo[NUM_SWITCH_DEVICE];
|
||||||
size_t mEnableCount;
|
size_t mEnableCount;
|
||||||
SwitchHandlerArray mHandler;
|
SwitchHandlerArray mHandler;
|
||||||
|
bool mHeadphonesFromInputDev;
|
||||||
|
|
||||||
void Init()
|
void Init()
|
||||||
{
|
{
|
||||||
char value[PROPERTY_VALUE_MAX];
|
RefPtr<SwitchHandlerHeadphone> switchHeadPhone =
|
||||||
property_get("ro.moz.devinputjack", value, "0");
|
new SwitchHandlerHeadphone(SWITCH_HEADSET_DEVPATH);
|
||||||
bool headphonesFromInputDev = !strcmp(value, "1");
|
|
||||||
|
|
||||||
if (!headphonesFromInputDev) {
|
// If the initial state is unknown, it means the headphone event is from input dev
|
||||||
mHandler.AppendElement(new SwitchHandlerHeadphone(SWITCH_HEADSET_DEVPATH));
|
mHeadphonesFromInputDev = switchHeadPhone->GetState() == SWITCH_STATE_UNKNOWN ? true : false;
|
||||||
|
|
||||||
|
if (!mHeadphonesFromInputDev) {
|
||||||
|
mHandler.AppendElement(switchHeadPhone);
|
||||||
} else {
|
} else {
|
||||||
// If headphone status will be notified from input dev then initialize
|
// If headphone status will be notified from input dev then initialize
|
||||||
// status to "off" and wait for event notification.
|
// status to "off" and wait for event notification.
|
||||||
@ -458,5 +468,12 @@ void NotifySwitchStateFromInputDevice(SwitchDevice aDevice, SwitchState aState)
|
|||||||
FROM_HERE,
|
FROM_HERE,
|
||||||
NewRunnableFunction(NotifySwitchStateIOThread, aDevice, aState));
|
NewRunnableFunction(NotifySwitchStateIOThread, aDevice, aState));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool IsHeadphoneEventFromInputDev()
|
||||||
|
{
|
||||||
|
InitializeResourceIfNeed();
|
||||||
|
return sSwitchObserver->GetHeadphonesFromInputDev();
|
||||||
|
}
|
||||||
|
|
||||||
} // hal_impl
|
} // hal_impl
|
||||||
} //mozilla
|
} //mozilla
|
||||||
|
@ -443,6 +443,12 @@ StopDiskSpaceWatcher()
|
|||||||
NS_RUNTIMEABORT("StopDiskSpaceWatcher() can't be called from sandboxed contexts.");
|
NS_RUNTIMEABORT("StopDiskSpaceWatcher() can't be called from sandboxed contexts.");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool IsHeadphoneEventFromInputDev()
|
||||||
|
{
|
||||||
|
NS_RUNTIMEABORT("IsHeadphoneEventFromInputDev() cannot be called from sandboxed contexts.");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
class HalParent : public PHalParent
|
class HalParent : public PHalParent
|
||||||
, public BatteryObserver
|
, public BatteryObserver
|
||||||
, public NetworkObserver
|
, public NetworkObserver
|
||||||
|
@ -62,7 +62,6 @@
|
|||||||
#include "libui/EventHub.h"
|
#include "libui/EventHub.h"
|
||||||
#include "libui/InputReader.h"
|
#include "libui/InputReader.h"
|
||||||
#include "libui/InputDispatcher.h"
|
#include "libui/InputDispatcher.h"
|
||||||
#include "cutils/properties.h"
|
|
||||||
|
|
||||||
#ifdef MOZ_NUWA_PROCESS
|
#ifdef MOZ_NUWA_PROCESS
|
||||||
#include "ipc/Nuwa.h"
|
#include "ipc/Nuwa.h"
|
||||||
@ -1052,9 +1051,7 @@ nsAppShell::Exit()
|
|||||||
void
|
void
|
||||||
nsAppShell::InitInputDevices()
|
nsAppShell::InitInputDevices()
|
||||||
{
|
{
|
||||||
char value[PROPERTY_VALUE_MAX];
|
sDevInputAudioJack = hal::IsHeadphoneEventFromInputDev();
|
||||||
property_get("ro.moz.devinputjack", value, "0");
|
|
||||||
sDevInputAudioJack = !strcmp(value, "1");
|
|
||||||
sHeadphoneState = AKEY_STATE_UNKNOWN;
|
sHeadphoneState = AKEY_STATE_UNKNOWN;
|
||||||
sMicrophoneState = AKEY_STATE_UNKNOWN;
|
sMicrophoneState = AKEY_STATE_UNKNOWN;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user