diff --git a/app/src/main/java/org/fdroid/fdroid/installer/InstallManagerService.java b/app/src/main/java/org/fdroid/fdroid/installer/InstallManagerService.java index 144eeef95..237a2584b 100644 --- a/app/src/main/java/org/fdroid/fdroid/installer/InstallManagerService.java +++ b/app/src/main/java/org/fdroid/fdroid/installer/InstallManagerService.java @@ -357,9 +357,18 @@ public class InstallManagerService extends Service { TEMP_HACK_APP_NAMES.put(urlString, app.name); // TODO delete me once InstallerService exists } + /** + * Remove the {@link App} and {@Apk} instances that are associated with + * {@code urlString} from the {@link Map} of active apps. This can be + * called after this service has been destroyed and recreated based on the + * {@link BroadcastReceiver}s, in which case {@code urlString} would not + * find anything in the active maps. + */ private static Apk removeFromActive(String urlString) { Apk apk = ACTIVE_APKS.remove(urlString); - ACTIVE_APPS.remove(apk.packageName); + if (apk != null) { + ACTIVE_APPS.remove(apk.packageName); + } return apk; } diff --git a/app/src/main/java/org/fdroid/fdroid/net/WifiStateChangeService.java b/app/src/main/java/org/fdroid/fdroid/net/WifiStateChangeService.java index bd624427d..d0560a052 100644 --- a/app/src/main/java/org/fdroid/fdroid/net/WifiStateChangeService.java +++ b/app/src/main/java/org/fdroid/fdroid/net/WifiStateChangeService.java @@ -36,6 +36,12 @@ import java.util.Locale; * which is how it can be triggered by code, or it came in from the system * via {@link org.fdroid.fdroid.receiver.WifiStateChangeReceiver}, in * which case an instance of {@link NetworkInfo} is included. + * + * The work is done in a {@link Thread} so that new incoming {@code Intents} + * are not blocked by processing. A new {@code Intent} immediately nullifies + * the current state because it means that something about the wifi has + * changed. Having the {@code Thread} also makes it easy to kill work + * that is in progress. */ public class WifiStateChangeService extends IntentService { private static final String TAG = "WifiStateChangeService"; @@ -202,9 +208,15 @@ public class WifiStateChangeService extends IntentService { } // the following methods were not added until android-9/Gingerbread for (InterfaceAddress address : netIf.getInterfaceAddresses()) { + short networkPrefixLength = address.getNetworkPrefixLength(); + if (networkPrefixLength > 32) { + // something is giving a "/64" netmask, IPv6? + // java.lang.IllegalArgumentException: Value [64] not in range [0,32] + continue; + } if (inetAddress.equals(address.getAddress()) && !TextUtils.isEmpty(FDroidApp.ipAddressString)) { String cidr = String.format(Locale.ENGLISH, "%s/%d", - FDroidApp.ipAddressString, address.getNetworkPrefixLength()); + FDroidApp.ipAddressString, networkPrefixLength); FDroidApp.subnetInfo = new SubnetUtils(cidr).getInfo(); break; } diff --git a/app/src/main/java/org/fdroid/fdroid/net/bluetooth/BluetoothConnection.java b/app/src/main/java/org/fdroid/fdroid/net/bluetooth/BluetoothConnection.java index 55ebd042b..0eb4fbe89 100644 --- a/app/src/main/java/org/fdroid/fdroid/net/bluetooth/BluetoothConnection.java +++ b/app/src/main/java/org/fdroid/fdroid/net/bluetooth/BluetoothConnection.java @@ -34,7 +34,7 @@ public class BluetoothConnection { @TargetApi(Build.VERSION_CODES.ICE_CREAM_SANDWICH) public void open() throws IOException { - if (!socket.isConnected()) { + if (Build.VERSION.SDK_INT >= 14 && !socket.isConnected()) { // Server sockets will already be connected when they are passed to us, // client sockets require us to call connect(). socket.connect();