Merge branch 'master' into discovery

Change-Id: Ic9c22b988ef0b87d19fa9842ee57826a4ee5457b
diff --git a/runtime/factories/android/android.go b/runtime/factories/android/android.go
index 61cda08..759c752 100644
--- a/runtime/factories/android/android.go
+++ b/runtime/factories/android/android.go
@@ -2,7 +2,7 @@
 // Use of this source code is governed by a BSD-style
 // license that can be found in the LICENSE file.
 
-// +build linux darwin
+// +build android
 
 // Package android implements a RuntimeFactory suitable for android.  It is
 // based on the roaming package.
@@ -14,13 +14,17 @@
 
 import (
 	"flag"
+	"os"
 
 	"v.io/v23"
 	"v.io/v23/context"
+	"v.io/v23/discovery"
 	"v.io/v23/flow"
 	"v.io/v23/rpc"
 
 	"v.io/x/ref/internal/logger"
+	idiscovery "v.io/x/ref/lib/discovery"
+
 	dfactory "v.io/x/ref/lib/discovery/factory"
 	"v.io/x/ref/lib/flags"
 	"v.io/x/ref/lib/pubsub"
@@ -40,10 +44,13 @@
 	_ "v.io/x/ref/runtime/internal/rpc/protocols/tcp"
 	_ "v.io/x/ref/runtime/internal/rpc/protocols/ws"
 	_ "v.io/x/ref/runtime/internal/rpc/protocols/wsh"
+	"v.io/x/ref/lib/discovery/plugins/mdns"
 )
 
 var commonFlags *flags.Flags
 
+var bleCreator func(string) (idiscovery.Plugin, error)
+
 func init() {
 	v23.RegisterRuntimeFactory(Init)
 	rpc.RegisterUnknownProtocol("wsh", websocket.HybridDial, websocket.HybridResolve, websocket.HybridListener)
@@ -57,7 +64,7 @@
 	}
 
 	ac := appcycle.New()
-	discovery, err := dfactory.New()
+	discovery, err := createDiscovery()
 	if err != nil {
 		ac.Shutdown()
 		return nil, nil, nil, err
@@ -97,3 +104,28 @@
 	}
 	return runtime, ctx, runtimeFactoryShutdown, nil
 }
+
+func createDiscovery() (discovery.T, error) {
+	plugins := make([]idiscovery.Plugin, 2)
+	host, _ := os.Hostname()
+	if host == "" {
+		host = "v23"
+	}
+	var err error
+	plugins[0], err = mdns.New(host)
+	if err != nil {
+		return nil, err
+	}
+
+	plugins[1], err = bleCreator(host)
+	if err != nil {
+		return nil, err
+	}
+
+	return idiscovery.NewWithPlugins(plugins...), nil
+}
+
+// SetBleCreator sets the function that will used to create the ble plugin.
+func SetBleCreator(creator func(string) (idiscovery.Plugin, error)) {
+	bleCreator = creator
+}
diff --git a/runtime/factories/android/proxy.go b/runtime/factories/android/proxy.go
index 3b4f880..d8668fb 100644
--- a/runtime/factories/android/proxy.go
+++ b/runtime/factories/android/proxy.go
@@ -2,6 +2,7 @@
 // Use of this source code is governed by a BSD-style
 // license that can be found in the LICENSE file.
 
+// +build android
 package android
 
 import (