aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChris "Koying" Browet <cbro@semperpax.com>2017-04-17 16:01:37 +0200
committerChris Koying Browet <cbro@semperpax.com>2018-02-06 11:51:43 +0100
commitcc557101df8b7381bcd9fabb5e2dde1bdf61307c (patch)
tree14464ccd6fc52ab8f7906fa81b7898177161fcb7
parentc45a8bf7919173d3bc54d298dcc0cb31833e498b (diff)
FIX: [droid] proper handling of HDMI on/off broadcasts
-rw-r--r--xbmc/platform/android/activity/XBMCApp.cpp25
-rw-r--r--xbmc/platform/android/activity/XBMCApp.h2
2 files changed, 23 insertions, 4 deletions
diff --git a/xbmc/platform/android/activity/XBMCApp.cpp b/xbmc/platform/android/activity/XBMCApp.cpp
index 3228280aae..b6caf1a773 100644
--- a/xbmc/platform/android/activity/XBMCApp.cpp
+++ b/xbmc/platform/android/activity/XBMCApp.cpp
@@ -126,6 +126,7 @@ ANativeWindow* CXBMCApp::m_window = NULL;
int CXBMCApp::m_batteryLevel = 0;
bool CXBMCApp::m_hasFocus = false;
bool CXBMCApp::m_headsetPlugged = false;
+bool CXBMCApp::m_hdmiPlugged = true;
IInputDeviceCallbacks* CXBMCApp::m_inputDeviceCallbacks = nullptr;
IInputDeviceEventHandler* CXBMCApp::m_inputDeviceEventHandler = nullptr;
bool CXBMCApp::m_hasReqVisible = false;
@@ -214,7 +215,7 @@ void CXBMCApp::onStart()
intentFilter.addAction("android.intent.action.BATTERY_CHANGED");
intentFilter.addAction("android.intent.action.SCREEN_ON");
intentFilter.addAction("android.intent.action.HEADSET_PLUG");
- intentFilter.addAction("android.intent.action.HDMI_AUDIO_PLUG");
+ intentFilter.addAction("android.media.action.HDMI_AUDIO_PLUG");
intentFilter.addAction("android.intent.action.SCREEN_OFF");
intentFilter.addAction("android.net.conn.CONNECTIVITY_CHANGE");
registerReceiver(*this, intentFilter);
@@ -433,6 +434,11 @@ bool CXBMCApp::IsHeadsetPlugged()
return m_headsetPlugged;
}
+bool CXBMCApp::IsHDMIPlugged()
+{
+ return m_hdmiPlugged;
+}
+
void CXBMCApp::run()
{
int status = 0;
@@ -942,11 +948,10 @@ void CXBMCApp::onReceive(CJNIIntent intent)
g_application.WakeUpScreenSaverAndDPMS();
}
else if (action == "android.intent.action.HEADSET_PLUG" ||
- action == "android.bluetooth.a2dp.profile.action.CONNECTION_STATE_CHANGED" ||
- action == "android.intent.action.HDMI_AUDIO_PLUG")
+ action == "android.bluetooth.a2dp.profile.action.CONNECTION_STATE_CHANGED")
{
bool newstate = m_headsetPlugged;
- if (action == "android.intent.action.HEADSET_PLUG" || action == "android.intent.action.HDMI_AUDIO_PLUG")
+ if (action == "android.intent.action.HEADSET_PLUG")
newstate = (intent.getIntExtra("state", 0) != 0);
else if (action == "android.bluetooth.a2dp.profile.action.CONNECTION_STATE_CHANGED")
newstate = (intent.getIntExtra("android.bluetooth.profile.extra.STATE", 0) == 2 /* STATE_CONNECTED */);
@@ -957,6 +962,18 @@ void CXBMCApp::onReceive(CJNIIntent intent)
CServiceBroker::GetActiveAE().DeviceChange();
}
}
+ else if (action == "android.media.action.HDMI_AUDIO_PLUG")
+ {
+ bool newstate;
+ newstate = (intent.getIntExtra("android.media.extra.AUDIO_PLUG_STATE", 0) != 0);
+
+ if (newstate != m_hdmiPlugged)
+ {
+ CLog::Log(LOGDEBUG, "-- HDMI state: %s", newstate ? "on" : "off");
+ m_hdmiPlugged = newstate;
+ CServiceBroker::GetActiveAE().DeviceChange();
+ }
+ }
else if (action == "android.intent.action.SCREEN_OFF")
{
if (m_playback_state & PLAYBACK_STATE_VIDEO)
diff --git a/xbmc/platform/android/activity/XBMCApp.h b/xbmc/platform/android/activity/XBMCApp.h
index 3dd9d87e45..8ee81776b1 100644
--- a/xbmc/platform/android/activity/XBMCApp.h
+++ b/xbmc/platform/android/activity/XBMCApp.h
@@ -146,6 +146,7 @@ public:
static bool EnableWakeLock(bool on);
static bool HasFocus() { return m_hasFocus; }
static bool IsHeadsetPlugged();
+ static bool IsHDMIPlugged();
static bool StartActivity(const std::string &package, const std::string &intent = std::string(), const std::string &dataType = std::string(), const std::string &dataURI = std::string());
static std::vector <androidPackage> GetApplications();
@@ -226,6 +227,7 @@ private:
static int m_batteryLevel;
static bool m_hasFocus;
static bool m_headsetPlugged;
+ static bool m_hdmiPlugged;
static IInputDeviceCallbacks* m_inputDeviceCallbacks;
static IInputDeviceEventHandler* m_inputDeviceEventHandler;
static bool m_hasReqVisible;