Skip to content

Commit

Permalink
Restyled by google-java-format
Browse files Browse the repository at this point in the history
  • Loading branch information
restyled-commits authored and Damian-Nordic committed Jul 21, 2021
1 parent 8b6dcb4 commit 1111800
Show file tree
Hide file tree
Showing 3 changed files with 43 additions and 30 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -242,9 +242,14 @@ private native void enableThreadNetwork(
public static native void setKeyValueStoreManager(KeyValueStoreManager manager);

public static native void setServiceResolver(ServiceResolver resolver);

public static native void handleServiceResolve(
String instanceName, String serviceType, String address, int port,
long callback, long context);
String instanceName,
String serviceType,
String address,
int port,
long callback,
long context);

static {
System.loadLibrary("CHIPController");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,7 @@
import android.net.nsd.NsdServiceInfo;
import android.util.Log;

public class NsdManagerServiceResolver implements ServiceResolver
{
public class NsdManagerServiceResolver implements ServiceResolver {
private final String TAG = NsdManagerServiceResolver.class.getSimpleName();
private final NsdManager nsdManager;

Expand All @@ -32,35 +31,43 @@ public NsdManagerServiceResolver(Context context) {
}

@Override
public void resolve(final String instanceName, final String serviceType, final long callbackHandle, final long contextHandle) {
public void resolve(
final String instanceName,
final String serviceType,
final long callbackHandle,
final long contextHandle) {
NsdServiceInfo serviceInfo = new NsdServiceInfo();
serviceInfo.setServiceName(instanceName);
serviceInfo.setServiceType(serviceType);

this.nsdManager.resolveService(serviceInfo, new NsdManager.ResolveListener() {
@Override
public void onResolveFailed(NsdServiceInfo serviceInfo, int errorCode) {
Log.w(TAG, "Failed to resolve service '" + serviceInfo.getServiceName() + "': " + errorCode);
ChipDeviceController.handleServiceResolve(
instanceName,
serviceType,
null,
0,
callbackHandle,
contextHandle);
}
this.nsdManager.resolveService(
serviceInfo,
new NsdManager.ResolveListener() {
@Override
public void onResolveFailed(NsdServiceInfo serviceInfo, int errorCode) {
Log.w(
TAG,
"Failed to resolve service '" + serviceInfo.getServiceName() + "': " + errorCode);
ChipDeviceController.handleServiceResolve(
instanceName, serviceType, null, 0, callbackHandle, contextHandle);
}

@Override
public void onServiceResolved(NsdServiceInfo serviceInfo) {
Log.i(TAG, "Resolved service '" + serviceInfo.getServiceName() + "' to " + serviceInfo.getHost());
ChipDeviceController.handleServiceResolve(
instanceName,
serviceType,
serviceInfo.getHost().getHostAddress(),
serviceInfo.getPort(),
callbackHandle,
contextHandle);
}
});
@Override
public void onServiceResolved(NsdServiceInfo serviceInfo) {
Log.i(
TAG,
"Resolved service '"
+ serviceInfo.getServiceName()
+ "' to "
+ serviceInfo.getHost());
ChipDeviceController.handleServiceResolve(
instanceName,
serviceType,
serviceInfo.getHost().getHostAddress(),
serviceInfo.getPort(),
callbackHandle,
contextHandle);
}
});
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,5 +18,6 @@
package chip.devicecontroller;

public interface ServiceResolver {
public void resolve(String instanceName, String serviceType, long callbackHandle, long contextHandle);
public void resolve(
String instanceName, String serviceType, long callbackHandle, long contextHandle);
}

0 comments on commit 1111800

Please sign in to comment.