Skip to content
Snippets Groups Projects
Unverified Commit 64406ebb authored by Sébastien Blin's avatar Sébastien Blin
Browse files

firebase: re-add wakelock to avoid to block incoming calls

Even if wakeLock is deprecated, without this part, some devices are blocking
during the call negotiation. So, re-add this code to avoid to block here.

Change-Id: Icd7ec3e0c441eab31efad5080dc79357edde2747
parent e86cb669
No related branches found
No related tags found
No related merge requests found
...@@ -18,6 +18,10 @@ ...@@ -18,6 +18,10 @@
*/ */
package cx.ring.services; package cx.ring.services;
import android.content.Context;
import android.os.PowerManager;
import android.util.Log;
import androidx.annotation.NonNull; import androidx.annotation.NonNull;
import com.google.firebase.messaging.FirebaseMessagingService; import com.google.firebase.messaging.FirebaseMessagingService;
...@@ -29,6 +33,17 @@ import cx.ring.application.JamiApplicationFirebase; ...@@ -29,6 +33,17 @@ import cx.ring.application.JamiApplicationFirebase;
public class JamiFirebaseMessagingService extends FirebaseMessagingService { public class JamiFirebaseMessagingService extends FirebaseMessagingService {
@Override @Override
public void onMessageReceived(@NonNull RemoteMessage remoteMessage) { public void onMessageReceived(@NonNull RemoteMessage remoteMessage) {
try {
// Even if wakeLock is deprecated, without this part, some devices are blocking
// during the call negotiation. So, re-add this code to avoid to block here.
PowerManager pm = (PowerManager)getSystemService(Context.POWER_SERVICE);
PowerManager.WakeLock wl = pm.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK, "wake:push");
wl.setReferenceCounted(false);
wl.acquire(20 * 1000);
} catch (Exception e) {
Log.w("JamiFirebaseMessaging", "Can't acquire wake lock", e);
}
JamiApplicationFirebase app = (JamiApplicationFirebase)JamiApplication.getInstance(); JamiApplicationFirebase app = (JamiApplicationFirebase)JamiApplication.getInstance();
if (app != null) if (app != null)
app.onMessageReceived(remoteMessage); app.onMessageReceived(remoteMessage);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment