mirror of
https://github.com/moonlight-stream/moonlight-android.git
synced 2026-06-17 22:31:35 +00:00
Remove init hack in DiscoveryService
This commit is contained in:
Binary file not shown.
@@ -1,6 +1,5 @@
|
|||||||
package com.limelight.discovery;
|
package com.limelight.discovery;
|
||||||
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import com.limelight.nvstream.mdns.MdnsComputer;
|
import com.limelight.nvstream.mdns.MdnsComputer;
|
||||||
@@ -47,14 +46,7 @@ public class DiscoveryService extends Service {
|
|||||||
multicastLock = wifiMgr.createMulticastLock("Limelight mDNS");
|
multicastLock = wifiMgr.createMulticastLock("Limelight mDNS");
|
||||||
multicastLock.setReferenceCounted(false);
|
multicastLock.setReferenceCounted(false);
|
||||||
|
|
||||||
// This pattern is nasty. We have to do it
|
discoveryAgent = new MdnsDiscoveryAgent(new MdnsDiscoveryListener() {
|
||||||
// because we can't do network on the main thread
|
|
||||||
// even if it's non-blocking
|
|
||||||
Thread initThread = new Thread() {
|
|
||||||
@Override
|
|
||||||
public void run() {
|
|
||||||
try {
|
|
||||||
discoveryAgent = MdnsDiscoveryAgent.createDiscoveryAgent(new MdnsDiscoveryListener() {
|
|
||||||
@Override
|
@Override
|
||||||
public void notifyComputerAdded(MdnsComputer computer) {
|
public void notifyComputerAdded(MdnsComputer computer) {
|
||||||
if (boundListener != null) {
|
if (boundListener != null) {
|
||||||
@@ -76,32 +68,15 @@ public class DiscoveryService extends Service {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
} catch (IOException e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
discoveryAgent = null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
};
|
|
||||||
initThread.start();
|
|
||||||
try {
|
|
||||||
initThread.join();
|
|
||||||
} catch (InterruptedException e) {
|
|
||||||
discoveryAgent = null;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private DiscoveryBinder binder = new DiscoveryBinder();
|
private DiscoveryBinder binder = new DiscoveryBinder();
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public IBinder onBind(Intent intent) {
|
public IBinder onBind(Intent intent) {
|
||||||
// We should only be bindable if discovery can happen
|
|
||||||
if (discoveryAgent != null) {
|
|
||||||
return binder;
|
return binder;
|
||||||
}
|
}
|
||||||
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean onUnbind(Intent intent) {
|
public boolean onUnbind(Intent intent) {
|
||||||
// Stop any discovery session
|
// Stop any discovery session
|
||||||
|
|||||||
Reference in New Issue
Block a user