move all mDNS service creation into the Thread
Upon looking at this, ServiceInfo.create() also might take a while to run so might as well run it in the Thread with the other JmDNS stuff.
This commit is contained in:
parent
ba028408a1
commit
f51d192e13
@ -216,14 +216,18 @@ public class LocalRepoService extends Service {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void registerMDNSService() {
|
private void registerMDNSService() {
|
||||||
|
new Thread(new Runnable() {
|
||||||
|
@Override
|
||||||
|
public void run() {
|
||||||
/*
|
/*
|
||||||
* a ServiceInfo can only be registered with a single instance of JmDNS,
|
* a ServiceInfo can only be registered with a single instance
|
||||||
* and there is only ever a single LocalHTTPD port to advertise anyway.
|
* of JmDNS, and there is only ever a single LocalHTTPD port to
|
||||||
|
* advertise anyway.
|
||||||
*/
|
*/
|
||||||
if (pairService != null || jmdns != null)
|
if (pairService != null || jmdns != null)
|
||||||
clearCurrentMDNSService();
|
clearCurrentMDNSService();
|
||||||
String repoName = Preferences.get().getLocalRepoName();
|
String repoName = Preferences.get().getLocalRepoName();
|
||||||
final HashMap<String, String> values = new HashMap<String, String>();
|
HashMap<String, String> values = new HashMap<String, String>();
|
||||||
values.put("path", "/fdroid/repo");
|
values.put("path", "/fdroid/repo");
|
||||||
values.put("name", repoName);
|
values.put("name", repoName);
|
||||||
values.put("fingerprint", FDroidApp.repo.fingerprint);
|
values.put("fingerprint", FDroidApp.repo.fingerprint);
|
||||||
@ -235,12 +239,8 @@ public class LocalRepoService extends Service {
|
|||||||
values.put("type", "fdroidrepo");
|
values.put("type", "fdroidrepo");
|
||||||
type = "_http._tcp.local.";
|
type = "_http._tcp.local.";
|
||||||
}
|
}
|
||||||
pairService = ServiceInfo.create(type, repoName, FDroidApp.port, 0, 0, values);
|
|
||||||
new Thread(new Runnable() {
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void run() {
|
|
||||||
try {
|
try {
|
||||||
|
pairService = ServiceInfo.create(type, repoName, FDroidApp.port, 0, 0, values);
|
||||||
jmdns = JmDNS.create();
|
jmdns = JmDNS.create();
|
||||||
jmdns.registerService(pairService);
|
jmdns.registerService(pairService);
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user