From 92001f4d37f8484a6c32ab509c3a6b254b1407e8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sa=C3=BAl=20Ibarra=20Corretg=C3=A9?= Date: Thu, 26 Jul 2018 15:30:36 +0200 Subject: [PATCH] android: run WiFi stats operations on a dedicated thread --- .../java/org/jitsi/meet/sdk/WiFiStatsModule.java | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/android/sdk/src/main/java/org/jitsi/meet/sdk/WiFiStatsModule.java b/android/sdk/src/main/java/org/jitsi/meet/sdk/WiFiStatsModule.java index aa7716233..cd2e50deb 100644 --- a/android/sdk/src/main/java/org/jitsi/meet/sdk/WiFiStatsModule.java +++ b/android/sdk/src/main/java/org/jitsi/meet/sdk/WiFiStatsModule.java @@ -19,8 +19,6 @@ package org.jitsi.meet.sdk; import android.content.Context; import android.net.wifi.WifiInfo; import android.net.wifi.WifiManager; -import android.os.Handler; -import android.os.Looper; import android.util.Log; import com.facebook.react.bridge.Promise; @@ -36,6 +34,8 @@ import java.net.NetworkInterface; import java.net.SocketException; import java.net.UnknownHostException; import java.util.Enumeration; +import java.util.concurrent.ExecutorService; +import java.util.concurrent.Executors; /** * Module exposing WiFi statistics. @@ -64,10 +64,10 @@ class WiFiStatsModule public final static int SIGNAL_LEVEL_SCALE = 101; /** - * {@link Handler} for running all operations on the main thread. + * {@link ExecutorService} for running all operations on a dedicated thread. */ - private final Handler mainThreadHandler - = new Handler(Looper.getMainLooper()); + private static final ExecutorService executor + = Executors.newSingleThreadExecutor(); /** * Initializes a new module instance. There shall be a single instance of @@ -203,6 +203,6 @@ class WiFiStatsModule } } }; - mainThreadHandler.post(r); + executor.execute(r); } }