mirror of
https://github.com/KDE/kdeconnect-android
synced 2025-08-31 14:15:14 +00:00
Less and more useful logging in LanBackend
This commit is contained in:
@@ -225,7 +225,7 @@ public class LanLink extends BaseLink {
|
|||||||
np = RsaHelper.decrypt(np, privateKey);
|
np = RsaHelper.decrypt(np, privateKey);
|
||||||
} catch(Exception e) {
|
} catch(Exception e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
Log.e("KDE/onPackageReceived","Exception reading the key needed to decrypt the package");
|
Log.e("KDE/onPackageReceived","Exception decrypting the package");
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@@ -147,9 +147,7 @@ public class LanLinkProvider extends BaseLinkProvider {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void channelRead0(ChannelHandlerContext ctx, String message) throws Exception {
|
public void channelRead0(ChannelHandlerContext ctx, String message) throws Exception {
|
||||||
// Log.e("LanLinkProvider","Incoming package, address: " + ctx.channel().remoteAddress());
|
//Log.e("KDE/LanLinkProvider", "Received a TCP packet from " + ctx.channel().remoteAddress() + ":" + message);
|
||||||
// Log.e("LanLinkProvider","Received:"+message);
|
|
||||||
|
|
||||||
|
|
||||||
if (message.isEmpty()) {
|
if (message.isEmpty()) {
|
||||||
Log.e("KDE/LanLinkProvider", "Empty package received");
|
Log.e("KDE/LanLinkProvider", "Empty package received");
|
||||||
@@ -162,10 +160,11 @@ public class LanLinkProvider extends BaseLinkProvider {
|
|||||||
|
|
||||||
String myId = DeviceHelper.getDeviceId(context);
|
String myId = DeviceHelper.getDeviceId(context);
|
||||||
if (np.getString("deviceId").equals(myId)) {
|
if (np.getString("deviceId").equals(myId)) {
|
||||||
|
Log.e("KDE/LanLinkProvider", "Somehow I'm connected to myself, ignoring. This should not happen.");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
Log.i("KDE/LanLinkProvider", "Identity package received from " + np.getString("deviceName"));
|
Log.i("KDE/LanLinkProvider", "Identity package received from a stablished TCP connection from " + np.getString("deviceName"));
|
||||||
|
|
||||||
final Channel channel = ctx.channel();
|
final Channel channel = ctx.channel();
|
||||||
final LanLink.ConnectionStarted connectionStarted = LanLink.ConnectionStarted.Locally;
|
final LanLink.ConnectionStarted connectionStarted = LanLink.ConnectionStarted.Locally;
|
||||||
@@ -244,7 +243,7 @@ public class LanLinkProvider extends BaseLinkProvider {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Log.i("KDE/LanLinkProvider", "Identity package received, creating link");
|
//Log.i("KDE/LanLinkProvider", "Identity package received, creating link");
|
||||||
|
|
||||||
try{
|
try{
|
||||||
Bootstrap b = new Bootstrap();
|
Bootstrap b = new Bootstrap();
|
||||||
@@ -278,8 +277,7 @@ public class LanLinkProvider extends BaseLinkProvider {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//Log.e("KDE/LanLinkProvider", "Connection successful: " + channel.isActive());
|
||||||
Log.i("KDE/LanLinkProvider", "Connection successful: " + channel.isActive());
|
|
||||||
|
|
||||||
// Add ssl handler if device supports new protocol
|
// Add ssl handler if device supports new protocol
|
||||||
if (identityPackage.getInt("protocolVersion") >= MIN_VERSION_WITH_SSL_SUPPORT) {
|
if (identityPackage.getInt("protocolVersion") >= MIN_VERSION_WITH_SSL_SUPPORT) {
|
||||||
@@ -301,7 +299,9 @@ public class LanLinkProvider extends BaseLinkProvider {
|
|||||||
// If ssl handler is in channel, add link after handshake is completed
|
// If ssl handler is in channel, add link after handshake is completed
|
||||||
final SslHandler sslHandler = channel.pipeline().get(SslHandler.class);
|
final SslHandler sslHandler = channel.pipeline().get(SslHandler.class);
|
||||||
if (sslHandler != null) {
|
if (sslHandler != null) {
|
||||||
|
//Log.e("KDE/LanLinkProvider", "Initiating SSL handshake");
|
||||||
sslHandler.handshakeFuture().addListener(new GenericFutureListener<Future<? super Channel>>() {
|
sslHandler.handshakeFuture().addListener(new GenericFutureListener<Future<? super Channel>>() {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void operationComplete(Future<? super Channel> future) throws Exception {
|
public void operationComplete(Future<? super Channel> future) throws Exception {
|
||||||
if (future.isSuccess()) {
|
if (future.isSuccess()) {
|
||||||
@@ -370,7 +370,7 @@ public class LanLinkProvider extends BaseLinkProvider {
|
|||||||
Log.i("KDE/LanLinkProvider","addLink to "+deviceId);
|
Log.i("KDE/LanLinkProvider","addLink to "+deviceId);
|
||||||
LanLink currentLink = visibleComputers.get(deviceId);
|
LanLink currentLink = visibleComputers.get(deviceId);
|
||||||
if (currentLink != null) {
|
if (currentLink != null) {
|
||||||
Log.e("KDE/LanLinkProvider", "Reusing same link for device " + deviceId);
|
Log.i("KDE/LanLinkProvider", "Reusing same link for device " + deviceId);
|
||||||
Channel oldChannel = currentLink.reset(channel, connectionOrigin, useSsl);
|
Channel oldChannel = currentLink.reset(channel, connectionOrigin, useSsl);
|
||||||
nioLinks.remove(oldChannel.hashCode());
|
nioLinks.remove(oldChannel.hashCode());
|
||||||
nioLinks.put(channel.hashCode(), currentLink);
|
nioLinks.put(channel.hashCode(), currentLink);
|
||||||
@@ -446,7 +446,7 @@ public class LanLinkProvider extends BaseLinkProvider {
|
|||||||
@Override
|
@Override
|
||||||
public void onStart() {
|
public void onStart() {
|
||||||
|
|
||||||
Log.e("KDE/LanLinkProvider", "onStart");
|
Log.i("KDE/LanLinkProvider", "onStart");
|
||||||
|
|
||||||
|
|
||||||
new Thread(new Runnable() {
|
new Thread(new Runnable() {
|
||||||
@@ -500,18 +500,14 @@ public class LanLinkProvider extends BaseLinkProvider {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onNetworkChange() {
|
public void onNetworkChange() {
|
||||||
Log.e("KDE/LanLinkProvider", "onNetworkChange");
|
|
||||||
|
|
||||||
//FilesHelper.LogOpenFileCount();
|
//FilesHelper.LogOpenFileCount();
|
||||||
|
|
||||||
onStart();
|
onStart();
|
||||||
|
|
||||||
//FilesHelper.LogOpenFileCount();
|
//FilesHelper.LogOpenFileCount();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onStop() {
|
public void onStop() {
|
||||||
Log.e("KDE/LanLinkProvider", "onStop");
|
//Log.i("KDE/LanLinkProvider", "onStop");
|
||||||
try {
|
try {
|
||||||
workerGroup.shutdownGracefully();
|
workerGroup.shutdownGracefully();
|
||||||
bossGroup.shutdownGracefully();
|
bossGroup.shutdownGracefully();
|
||||||
|
Reference in New Issue
Block a user