only update static WiFi settings var from WifiInfoThread
Since Intents can come in any time, whether WifiInfoThread is running or not, the global static vars for storing the WiFi settings info should only be updated from the WifiInfoThread. Otherwise, the WiFi settings could be nulled out between the time of the null guard and the execution in code like this: if (!TextUtils.isEmpty(FDroidApp.ipAddressString) && netmask != null) { FDroidApp.subnetInfo = new SubnetUtils(FDroidApp.ipAddressString, netmask).getInfo(); fixes #589 https://gitlab.com/fdroid/fdroidclient/issues/589 java.lang.RuntimeException: An error occured while executing doInBackground() at android.os.AsyncTask$3.done(AsyncTask.java:304) at java.util.concurrent.FutureTask.finishCompletion(FutureTask.java:355) at java.util.concurrent.FutureTask.setException(FutureTask.java:222) at java.util.concurrent.FutureTask.run(FutureTask.java:242) at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:231) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1112) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:587) at java.lang.Thread.run(Thread.java:818) Caused by: java.lang.IllegalArgumentException: Could not parse [null/24] at org.apache.commons.net.util.SubnetUtils.calculate(SubnetUtils.java:275) at org.apache.commons.net.util.SubnetUtils.<init>(SubnetUtils.java:62) at org.fdroid.fdroid.net.WifiStateChangeService$WaitForWifiAsyncTask.doInBackground(WifiStateChangeService.java:89) at org.fdroid.fdroid.net.WifiStateChangeService$WaitForWifiAsyncTask.doInBackground(WifiStateChangeService.java:70) at android.os.AsyncTask$2.call(AsyncTask.java:292) at java.util.concurrent.FutureTask.run(FutureTask.java:237) ... 4 more java.lang.IllegalArgumentException: Could not parse [null/24] at org.apache.commons.net.util.SubnetUtils.calculate(SubnetUtils.java:275) at org.apache.commons.net.util.SubnetUtils.<init>(SubnetUtils.java:62) at org.fdroid.fdroid.net.WifiStateChangeService$WaitForWifiAsyncTask.doInBackground(WifiStateChangeService.java:89) at org.fdroid.fdroid.net.WifiStateChangeService$WaitForWifiAsyncTask.doInBackground(WifiStateChangeService.java:70) at android.os.AsyncTask$2.call(AsyncTask.java:292) at java.util.concurrent.FutureTask.run(FutureTask.java:237) at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:231) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1112) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:587) at java.lang.Thread.run(Thread.java:818)
This commit is contained in:
parent
5f1aee8f0d
commit
db9bdc315d
@ -139,7 +139,9 @@ public class FDroidApp extends Application {
|
||||
}
|
||||
|
||||
/**
|
||||
* Initialize the settings needed to run a local swap repo.
|
||||
* Initialize the settings needed to run a local swap repo. This should
|
||||
* only ever be called in {@link org.fdroid.fdroid.net.WifiStateChangeService.WifiInfoThread},
|
||||
* after the single init call in {@link FDroidApp#onCreate()}.
|
||||
*/
|
||||
public static void initWifiSettings() {
|
||||
port = 8888;
|
||||
|
@ -53,7 +53,6 @@ public class WifiStateChangeService extends IntentService {
|
||||
protected void onHandleIntent(Intent intent) {
|
||||
android.os.Process.setThreadPriority(android.os.Process.THREAD_PRIORITY_LOWEST);
|
||||
Utils.debugLog(TAG, "WiFi change service started, clearing info about wifi state until we have figured it out again.");
|
||||
FDroidApp.initWifiSettings();
|
||||
NetworkInfo ni = intent.getParcelableExtra(WifiManager.EXTRA_NETWORK_INFO);
|
||||
wifiManager = (WifiManager) getSystemService(WIFI_SERVICE);
|
||||
int wifiState = wifiManager.getWifiState();
|
||||
@ -79,6 +78,7 @@ public class WifiStateChangeService extends IntentService {
|
||||
public void run() {
|
||||
android.os.Process.setThreadPriority(android.os.Process.THREAD_PRIORITY_LOWEST);
|
||||
try {
|
||||
FDroidApp.initWifiSettings();
|
||||
Utils.debugLog(TAG, "Checking wifi state (in background thread).");
|
||||
WifiInfo wifiInfo = null;
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user