fix NullPointerException in BonjourPeer and BluetoothPeer
java.lang.IllegalStateException: Fatal Exception thrown on Scheduler.Worker thread. at rx.internal.schedulers.ScheduledAction.run(ScheduledAction.java:62) at android.os.Handler.handleCallback(Handler.java:751) at android.os.Handler.dispatchMessage(Handler.java:95) at android.os.Looper.loop(Looper.java:154) at android.app.ActivityThread.main(ActivityThread.java:6128) at java.lang.reflect.Method.invoke(Native Method) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:889) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:779) Caused by: java.lang.NullPointerException: Attempt to invoke virtual method 'boolean java.lang.String.equals(java.lang.Object)' on a null object reference at org.fdroid.fdroid.localrepo.peers.BonjourPeer.equals(BonjourPeer.java:34) at java.util.HashMap.put(HashMap.java:427) at java.util.HashSet.add(HashSet.java:217) at rx.internal.operators.OperatorDistinct$1.onNext(OperatorDistinct.java:62) at rx.internal.operators.OperatorObserveOn$ObserveOnSubscriber.pollQueue(OperatorObserveOn.java:202) at rx.internal.operators.OperatorObserveOn$ObserveOnSubscriber$2.call(OperatorObserveOn.java:162) at rx.internal.schedulers.ScheduledAction.run(ScheduledAction.java:55)
This commit is contained in:
parent
779a0122fd
commit
289976667d
@ -2,7 +2,7 @@ package org.fdroid.fdroid.localrepo.peers;
|
|||||||
|
|
||||||
import android.bluetooth.BluetoothDevice;
|
import android.bluetooth.BluetoothDevice;
|
||||||
import android.os.Parcel;
|
import android.os.Parcel;
|
||||||
|
import android.text.TextUtils;
|
||||||
import org.fdroid.fdroid.R;
|
import org.fdroid.fdroid.R;
|
||||||
import org.fdroid.fdroid.localrepo.type.BluetoothSwap;
|
import org.fdroid.fdroid.localrepo.type.BluetoothSwap;
|
||||||
|
|
||||||
@ -31,9 +31,8 @@ public class BluetoothPeer implements Peer {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean equals(Object peer) {
|
public boolean equals(Object peer) {
|
||||||
return peer != null
|
return peer instanceof BluetoothPeer
|
||||||
&& peer instanceof BluetoothPeer
|
&& TextUtils.equals(((BluetoothPeer) peer).device.getAddress(), device.getAddress());
|
||||||
&& ((BluetoothPeer) peer).device.getAddress().equals(device.getAddress());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -48,7 +47,7 @@ public class BluetoothPeer implements Peer {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Return the fingerprint of the signing key, or {@code null} if it is not set.
|
* Return the fingerprint of the signing key, or {@code null} if it is not set.
|
||||||
*
|
* <p>
|
||||||
* This is not yet stored for Bluetooth connections. Once a device is connected to a bluetooth
|
* This is not yet stored for Bluetooth connections. Once a device is connected to a bluetooth
|
||||||
* socket, if we trust it enough to accept a fingerprint from it somehow, then we may as well
|
* socket, if we trust it enough to accept a fingerprint from it somehow, then we may as well
|
||||||
* trust it enough to receive an index from it that contains a fingerprint we can use.
|
* trust it enough to receive an index from it that contains a fingerprint we can use.
|
||||||
|
@ -2,6 +2,7 @@ package org.fdroid.fdroid.localrepo.peers;
|
|||||||
|
|
||||||
import android.net.Uri;
|
import android.net.Uri;
|
||||||
import android.os.Parcel;
|
import android.os.Parcel;
|
||||||
|
import android.text.TextUtils;
|
||||||
|
|
||||||
import javax.jmdns.ServiceInfo;
|
import javax.jmdns.ServiceInfo;
|
||||||
import javax.jmdns.impl.FDroidServiceInfo;
|
import javax.jmdns.impl.FDroidServiceInfo;
|
||||||
@ -29,9 +30,9 @@ public class BonjourPeer extends WifiPeer {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean equals(Object peer) {
|
public boolean equals(Object peer) {
|
||||||
if (peer != null && peer instanceof BonjourPeer) {
|
if (peer instanceof BonjourPeer) {
|
||||||
BonjourPeer that = (BonjourPeer) peer;
|
BonjourPeer that = (BonjourPeer) peer;
|
||||||
return this.getFingerprint().equals(that.getFingerprint());
|
return TextUtils.equals(this.getFingerprint(), that.getFingerprint());
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user