Details
-
Bug
-
Resolution: Unresolved
-
P2: Important
-
None
-
5.11.2, 5.15.2
-
Android API level 4 and newer
Description
Some devices (like the Pixel 3) require you to acquire a "Multi cast lock". This lock enables apps on the device to receive broadcasts while acquired.
Not acquiring this lock is often not harm full since the locking takes effect system wide. Therefore, a single app acquiring the lock is enough for all apps to receive broadcasts. But you are screwed if no other app does this for you.
See https://developer.android.com/reference/android/Manifest.permission
android.permission.CHANGE_WIFI_MULTICAST_STATE
See also https://developer.android.com/reference/android/net/wifi/WifiManager.MulticastLock
Allows an application to receive Wifi Multicast packets. Normally the Wifi stack filters out packets not explicitly addressed to this device. Acquring a MulticastLock will cause the stack to receive packets addressed to multicast addresses. Processing these extra packets can cause a noticeable battery drain and should be disabled when not needed.
Probably a related issue: https://bugreports.qt.io/browse/QTBUG-64233 "UDP broadcast packets not received on Android 8.0"
We deployed the following workaround:
/* * \copyright Copyright (c) 2019 Governikus GmbH & Co. KG, Germany */ package com.governikus.ausweisapp2; import android.content.Context; import android.net.wifi.WifiManager; import android.util.Log; public final class MulticastLockJniBridgeUtil { private static final String LOG_TAG = AusweisApp2Service.LOG_TAG; private static WifiManager.MulticastLock cLock; private MulticastLockJniBridgeUtil() { } public static synchronized void acquire(Context pContext) { if (cLock == null) { WifiManager wifi = (WifiManager) pContext.getSystemService(Context.WIFI_SERVICE); cLock = wifi.createMulticastLock("AusweisApp2"); cLock.setReferenceCounted(true); } cLock.acquire(); Log.d(LOG_TAG, "Multicast lock: " + cLock.toString()); } public static synchronized void release(Context pContext) { cLock.release(); Log.d(LOG_TAG, "Multicast lock released."); } }
Attachments
Issue Links
- relates to
-
QTBUG-64233 UDP broadcast packets not received on Android 8.0
- Closed