2
0
mirror of https://github.com/KDE/kdeconnect-android synced 2025-08-29 13:17:43 +00:00

Added some logging to help debugging an issue, now commented for future use

Also we prepend KDE/ to these logs to ease filtering them
This commit is contained in:
Albert Vaca 2015-04-04 11:37:12 -07:00
parent 8550de5e7f
commit a0b82d17b4
6 changed files with 84 additions and 64 deletions

View File

@ -46,13 +46,13 @@ public abstract class BaseLinkProvider {
//These two should be called when the provider links to a new computer //These two should be called when the provider links to a new computer
protected void connectionAccepted(NetworkPackage identityPackage, BaseLink link) { protected void connectionAccepted(NetworkPackage identityPackage, BaseLink link) {
Log.i("LinkProvider", "connectionAccepted"); //Log.i("KDE/LinkProvider", "connectionAccepted");
for(ConnectionReceiver cr : connectionReceivers) { for(ConnectionReceiver cr : connectionReceivers) {
cr.onConnectionReceived(identityPackage, link); cr.onConnectionReceived(identityPackage, link);
} }
} }
protected void connectionLost(BaseLink link) { protected void connectionLost(BaseLink link) {
Log.i("LinkProvider", "connectionLost"); //Log.i("KDE/LinkProvider", "connectionLost");
for(ConnectionReceiver cr : connectionReceivers) { for(ConnectionReceiver cr : connectionReceivers) {
cr.onConnectionLost(link); cr.onConnectionLost(link);
} }

View File

@ -47,8 +47,10 @@ public class LanLink extends BaseLink {
private IoSession session = null; private IoSession session = null;
public void disconnect() { public void disconnect() {
if (session == null) return; if (session == null) {
//Log.i("LanLink", "Disconnect: "+session.getRemoteAddress().toString()); Log.e("KDE/LanLink", "Not yet connected");
return;
}
session.close(true); session.close(true);
} }
@ -60,7 +62,7 @@ public class LanLink extends BaseLink {
//Blocking, do not call from main thread //Blocking, do not call from main thread
private void sendPackageInternal(NetworkPackage np, final Device.SendPackageStatusCallback callback, PublicKey key) { private void sendPackageInternal(NetworkPackage np, final Device.SendPackageStatusCallback callback, PublicKey key) {
if (session == null) { if (session == null) {
Log.e("sendPackage", "Not yet connected"); Log.e("KDE/sendPackage", "Not yet connected");
callback.sendFailure(new NotYetConnectedException()); callback.sendFailure(new NotYetConnectedException());
return; return;
} }
@ -87,7 +89,7 @@ public class LanLink extends BaseLink {
WriteFuture future = session.write(np.serialize()); WriteFuture future = session.write(np.serialize());
future.awaitUninterruptibly(); future.awaitUninterruptibly();
if (!future.isWritten()) { if (!future.isWritten()) {
Log.e("sendPackage", "!future.isWritten()"); Log.e("KDE/sendPackage", "!future.isWritten()");
callback.sendFailure(future.getException()); callback.sendFailure(future.getException());
return; return;
} }
@ -101,7 +103,7 @@ public class LanLink extends BaseLink {
timeout.schedule(new TimerTask() { timeout.schedule(new TimerTask() {
@Override @Override
public void run() { public void run() {
Log.e("sendPackage","Timeout"); Log.e("KDE/sendPackage","Timeout");
try { server.close(); } catch (Exception e) { } try { server.close(); } catch (Exception e) { }
callback.sendFailure(new TimeoutException("Timed out waiting for other end to establish a connection to receive the payload.")); callback.sendFailure(new TimeoutException("Timed out waiting for other end to establish a connection to receive the payload."));
} }
@ -109,7 +111,7 @@ public class LanLink extends BaseLink {
socket = server.accept().getOutputStream(); socket = server.accept().getOutputStream();
timeout.cancel(); timeout.cancel();
Log.i("LanLink", "Beginning to send payload"); Log.i("KDE/LanLink", "Beginning to send payload");
byte[] buffer = new byte[4096]; byte[] buffer = new byte[4096];
int bytesRead; int bytesRead;
@ -123,9 +125,9 @@ public class LanLink extends BaseLink {
callback.sendProgress((int)(progress / np.getPayloadSize())); callback.sendProgress((int)(progress / np.getPayloadSize()));
} }
} }
Log.i("LanLink", "Finished sending payload"); Log.i("KDE/LanLink", "Finished sending payload");
} catch (Exception e) { } catch (Exception e) {
Log.e("sendPackage", "Exception: "+e); Log.e("KDE/sendPackage", "Exception: "+e);
callback.sendFailure(e); callback.sendFailure(e);
return; return;
} finally { } finally {
@ -167,7 +169,7 @@ public class LanLink extends BaseLink {
np = np.decrypt(privateKey); np = np.decrypt(privateKey);
} catch(Exception e) { } catch(Exception e) {
e.printStackTrace(); e.printStackTrace();
Log.e("onPackageReceived","Exception reading the key needed to decrypt the package"); Log.e("KDE/onPackageReceived","Exception reading the key needed to decrypt the package");
} }
} }
@ -182,7 +184,7 @@ public class LanLink extends BaseLink {
np.setPayload(socket.getInputStream(), np.getPayloadSize()); np.setPayload(socket.getInputStream(), np.getPayloadSize());
} catch (Exception e) { } catch (Exception e) {
e.printStackTrace(); e.printStackTrace();
Log.e("LanLink", "Exception connecting to payload remote socket"); Log.e("KDE/LanLink", "Exception connecting to payload remote socket");
} }
} }
@ -200,12 +202,12 @@ public class LanLink extends BaseLink {
candidateServer = new ServerSocket(); candidateServer = new ServerSocket();
candidateServer.bind(new InetSocketAddress(tcpPort)); candidateServer.bind(new InetSocketAddress(tcpPort));
success = true; success = true;
Log.i("LanLink", "Using port "+tcpPort); Log.i("KDE/LanLink", "Using port "+tcpPort);
} catch(IOException e) { } catch(IOException e) {
//Log.e("LanLink", "Exception openning serversocket: "+e); //Log.e("LanLink", "Exception openning serversocket: "+e);
tcpPort++; tcpPort++;
if (tcpPort >= 1764) { if (tcpPort >= 1764) {
Log.e("LanLink", "No more ports available"); Log.e("KDE/LanLink", "No more ports available");
throw e; throw e;
} }
} }

View File

@ -100,7 +100,7 @@ public class LanLinkProvider extends BaseLinkProvider {
String theMessage = (String) message; String theMessage = (String) message;
if (theMessage.isEmpty()) { if (theMessage.isEmpty()) {
Log.e("LanLinkProvider","Empty package received"); Log.e("KDE/LanLinkProvider","Empty package received");
return; return;
} }
@ -113,15 +113,16 @@ public class LanLinkProvider extends BaseLinkProvider {
return; return;
} }
//Log.e("LanLinkProvider", "Identity package received from "+np.getString("deviceName")); //Log.i("KDE/LanLinkProvider", "Identity package received from " + np.getString("deviceName"));
LanLink link = new LanLink(session, np.getString("deviceId"), LanLinkProvider.this); LanLink link = new LanLink(session, np.getString("deviceId"), LanLinkProvider.this);
nioSessions.put(session.getId(),link); nioSessions.put(session.getId(),link);
//Log.e("KDE/LanLinkProvider","nioSessions.size(): " + nioSessions.size());
addLink(np, link); addLink(np, link);
} else { } else {
LanLink prevLink = nioSessions.get(session.getId()); LanLink prevLink = nioSessions.get(session.getId());
if (prevLink == null) { if (prevLink == null) {
Log.e("LanLinkProvider","2 Expecting an identity package"); Log.e("KDE/LanLinkProvider","Expecting an identity package (A)");
} else { } else {
prevLink.injectNetworkPackage(np); prevLink.injectNetworkPackage(np);
} }
@ -143,7 +144,7 @@ public class LanLinkProvider extends BaseLinkProvider {
final NetworkPackage identityPackage = NetworkPackage.unserialize(theMessage); final NetworkPackage identityPackage = NetworkPackage.unserialize(theMessage);
if (!identityPackage.getType().equals(NetworkPackage.PACKAGE_TYPE_IDENTITY)) { if (!identityPackage.getType().equals(NetworkPackage.PACKAGE_TYPE_IDENTITY)) {
Log.e("LanLinkProvider", "1 Expecting an identity package"); Log.e("KDE/LanLinkProvider", "Expecting an identity package (B)");
return; return;
} else { } else {
String myId = NetworkPackage.createIdentityPackage(context).getString("deviceId"); String myId = NetworkPackage.createIdentityPackage(context).getString("deviceId");
@ -152,7 +153,7 @@ public class LanLinkProvider extends BaseLinkProvider {
} }
} }
Log.i("LanLinkProvider", "Identity package received, creating link"); //Log.i("KDE/LanLinkProvider", "Identity package received, creating link");
final InetSocketAddress address = (InetSocketAddress) udpSession.getRemoteAddress(); final InetSocketAddress address = (InetSocketAddress) udpSession.getRemoteAddress();
@ -199,7 +200,7 @@ public class LanLinkProvider extends BaseLinkProvider {
}); });
} catch (Exception e) { } catch (Exception e) {
Log.e("LanLinkProvider","Exception receiving udp package!!"); Log.e("KDE/LanLinkProvider","Exception receiving udp package!!");
e.printStackTrace(); e.printStackTrace();
} }
@ -208,16 +209,16 @@ public class LanLinkProvider extends BaseLinkProvider {
private void addLink(NetworkPackage identityPackage, LanLink link) { private void addLink(NetworkPackage identityPackage, LanLink link) {
String deviceId = identityPackage.getString("deviceId"); String deviceId = identityPackage.getString("deviceId");
Log.i("LanLinkProvider","addLink to "+deviceId); Log.i("KDE/LanLinkProvider","addLink to "+deviceId);
LanLink oldLink = visibleComputers.get(deviceId); LanLink oldLink = visibleComputers.get(deviceId);
if (oldLink == link) { if (oldLink == link) {
Log.e("KDEConnect", "LanLinkProvider: oldLink == link. This should not happen!"); Log.e("KDE/LanLinkProvider", "oldLink == link. This should not happen!");
return; return;
} }
visibleComputers.put(deviceId, link); visibleComputers.put(deviceId, link);
connectionAccepted(identityPackage, link); connectionAccepted(identityPackage, link);
if (oldLink != null) { if (oldLink != null) {
Log.i("LanLinkProvider","Removing old connection to same device"); Log.i("KDE/LanLinkProvider","Removing old connection to same device");
oldLink.disconnect(); oldLink.disconnect();
connectionLost(oldLink); connectionLost(oldLink);
} }
@ -261,7 +262,7 @@ public class LanLinkProvider extends BaseLinkProvider {
try { try {
udpAcceptor.bind(new InetSocketAddress(port)); udpAcceptor.bind(new InetSocketAddress(port));
} catch(Exception e) { } catch(Exception e) {
Log.e("LanLinkProvider", "Error: Could not bind udp socket"); Log.e("KDE/LanLinkProvider", "Error: Could not bind udp socket");
e.printStackTrace(); e.printStackTrace();
} }
@ -276,7 +277,7 @@ public class LanLinkProvider extends BaseLinkProvider {
} }
} }
Log.i("LanLinkProvider","Using tcpPort "+tcpPort); Log.i("KDE/LanLinkProvider","Using tcpPort "+tcpPort);
//I'm on a new network, let's be polite and introduce myself //I'm on a new network, let's be polite and introduce myself
final int finalTcpPort = tcpPort; final int finalTcpPort = tcpPort;
@ -301,10 +302,10 @@ public class LanLinkProvider extends BaseLinkProvider {
socket.setReuseAddress(true); socket.setReuseAddress(true);
socket.setBroadcast(true); socket.setBroadcast(true);
socket.send(packet); socket.send(packet);
//Log.i("LanLinkProvider","Udp identity package sent to address "+packet.getAddress()); //Log.i("KDE/LanLinkProvider","Udp identity package sent to address "+packet.getAddress());
} catch(Exception e) { } catch(Exception e) {
e.printStackTrace(); e.printStackTrace();
Log.e("LanLinkProvider","Sending udp identity package failed. Invalid address? ("+ipstr+")"); Log.e("KDE/LanLinkProvider","Sending udp identity package failed. Invalid address? ("+ipstr+")");
} }
} }
@ -318,8 +319,12 @@ public class LanLinkProvider extends BaseLinkProvider {
@Override @Override
public void onNetworkChange() { public void onNetworkChange() {
//Log.e("KDE/LanLinkProvider","onNetworkChange");
//FilesHelper.LogOpenFileCount();
onStop(); onStop();
//FilesHelper.LogOpenFileCount();
onStart(); onStart();
//FilesHelper.LogOpenFileCount();
} }
@Override @Override

View File

@ -105,17 +105,17 @@ public class BackgroundService extends Service {
@Override @Override
public void onConnectionReceived(final NetworkPackage identityPackage, final BaseLink link) { public void onConnectionReceived(final NetworkPackage identityPackage, final BaseLink link) {
Log.i("BackgroundService", "Connection accepted!"); Log.i("KDE/BackgroundService", "Connection accepted!");
String deviceId = identityPackage.getString("deviceId"); String deviceId = identityPackage.getString("deviceId");
Device device = devices.get(deviceId); Device device = devices.get(deviceId);
if (device != null) { if (device != null) {
Log.i("BackgroundService", "addLink, known device: " + deviceId); Log.i("KDE/BackgroundService", "addLink, known device: " + deviceId);
device.addLink(identityPackage, link); device.addLink(identityPackage, link);
} else { } else {
Log.i("BackgroundService", "addLink,unknown device: " + deviceId); Log.i("KDE/BackgroundService", "addLink,unknown device: " + deviceId);
device = new Device(BackgroundService.this, identityPackage, link); device = new Device(BackgroundService.this, identityPackage, link);
devices.put(deviceId, device); devices.put(deviceId, device);
device.addPairingCallback(devicePairingCallback); device.addPairingCallback(devicePairingCallback);
@ -127,7 +127,7 @@ public class BackgroundService extends Service {
@Override @Override
public void onConnectionLost(BaseLink link) { public void onConnectionLost(BaseLink link) {
Device d = devices.get(link.getDeviceId()); Device d = devices.get(link.getDeviceId());
Log.i("onConnectionLost", "removeLink, deviceId: " + link.getDeviceId()); Log.i("KDE/onConnectionLost", "removeLink, deviceId: " + link.getDeviceId());
if (d != null) { if (d != null) {
d.removeLink(link); d.removeLink(link);
if (!d.isReachable() && !d.isPaired()) { if (!d.isReachable() && !d.isPaired()) {
@ -136,7 +136,7 @@ public class BackgroundService extends Service {
d.removePairingCallback(devicePairingCallback); d.removePairingCallback(devicePairingCallback);
} }
} else { } else {
Log.e("onConnectionLost","Removing connection to unknown device, this should not happen"); Log.e("KDE/onConnectionLost","Removing connection to unknown device, this should not happen");
} }
if (deviceListChangedCallback != null) deviceListChangedCallback.onDeviceListChanged(); if (deviceListChangedCallback != null) deviceListChangedCallback.onDeviceListChanged();
} }
@ -147,34 +147,35 @@ public class BackgroundService extends Service {
} }
public void startDiscovery() { public void startDiscovery() {
Log.i("BackgroundService","StartDiscovery"); Log.i("KDE/BackgroundService","StartDiscovery");
for (BaseLinkProvider a : linkProviders) { for (BaseLinkProvider a : linkProviders) {
a.onStart(); a.onStart();
} }
} }
public void stopDiscovery() { public void stopDiscovery() {
Log.i("BackgroundService","StopDiscovery"); Log.i("KDE/BackgroundService","StopDiscovery");
for (BaseLinkProvider a : linkProviders) { for (BaseLinkProvider a : linkProviders) {
a.onStop(); a.onStop();
} }
} }
public void onNetworkChange() { public void onNetworkChange() {
Log.i("BackgroundService","OnNetworkChange"); Log.i("KDE/BackgroundService","OnNetworkChange");
for (BaseLinkProvider a : linkProviders) { for (BaseLinkProvider a : linkProviders) {
a.onNetworkChange(); a.onNetworkChange();
} }
} }
public void addConnectionListener(BaseLinkProvider.ConnectionReceiver cr) { public void addConnectionListener(BaseLinkProvider.ConnectionReceiver cr) {
Log.i("BackgroundService","Registering connection listener"); Log.i("KDE/BackgroundService","Registering connection listener");
for (BaseLinkProvider a : linkProviders) { for (BaseLinkProvider a : linkProviders) {
a.addConnectionReceiver(cr); a.addConnectionReceiver(cr);
} }
} }
public void removeConnectionListener(BaseLinkProvider.ConnectionReceiver cr) { public void removeConnectionListener(BaseLinkProvider.ConnectionReceiver cr) {
Log.i("KDE/BackgroundService","Removing connection listener");
for (BaseLinkProvider a : linkProviders) { for (BaseLinkProvider a : linkProviders) {
a.removeConnectionReceiver(cr); a.removeConnectionReceiver(cr);
} }
@ -198,7 +199,7 @@ public class BackgroundService extends Service {
IntentFilter filter = new IntentFilter(Intent.ACTION_SCREEN_ON); IntentFilter filter = new IntentFilter(Intent.ACTION_SCREEN_ON);
registerReceiver(new KdeConnectBroadcastReceiver(), filter); registerReceiver(new KdeConnectBroadcastReceiver(), filter);
Log.i("BackgroundService","Service not started yet, initializing..."); Log.i("KDE/BackgroundService","Service not started yet, initializing...");
initializeRsaKeys(); initializeRsaKeys();
MainSettingsActivity.initializeDeviceName(this); MainSettingsActivity.initializeDeviceName(this);
@ -223,7 +224,7 @@ public class BackgroundService extends Service {
keyPair = keyGen.genKeyPair(); keyPair = keyGen.genKeyPair();
} catch(Exception e) { } catch(Exception e) {
e.printStackTrace(); e.printStackTrace();
Log.e("initializeRsaKeys","Exception"); Log.e("KDE/initializeRsaKeys","Exception");
return; return;
} }
@ -268,7 +269,7 @@ public class BackgroundService extends Service {
@Override @Override
public void onDestroy() { public void onDestroy() {
Log.i("BackgroundService", "Destroying"); Log.i("KDE/BackgroundService", "Destroying");
stopDiscovery(); stopDiscovery();
super.onDestroy(); super.onDestroy();
} }

View File

@ -102,7 +102,7 @@ public class Device implements BaseLink.PackageReceiver {
publicKey = KeyFactory.getInstance("RSA").generatePublic(new X509EncodedKeySpec(publicKeyBytes)); publicKey = KeyFactory.getInstance("RSA").generatePublic(new X509EncodedKeySpec(publicKeyBytes));
} catch (Exception e) { } catch (Exception e) {
e.printStackTrace(); e.printStackTrace();
Log.e("Device","Exception"); Log.e("KDE/Device","Exception");
} }
reloadPluginsFromSettings(); reloadPluginsFromSettings();
@ -200,7 +200,7 @@ public class Device implements BaseLink.PackageReceiver {
for (PairingCallback cb : pairingCallback) { for (PairingCallback cb : pairingCallback) {
cb.pairingFailed(context.getString(R.string.error_timed_out)); cb.pairingFailed(context.getString(R.string.error_timed_out));
} }
Log.e("Device","Unpairing (timeout A)"); Log.e("KDE/Device","Unpairing (timeout A)");
pairStatus = PairStatus.NotPaired; pairStatus = PairStatus.NotPaired;
} }
}, 30*1000); //Time to wait for the other to accept }, 30*1000); //Time to wait for the other to accept
@ -212,7 +212,7 @@ public class Device implements BaseLink.PackageReceiver {
for (PairingCallback cb : pairingCallback) { for (PairingCallback cb : pairingCallback) {
cb.pairingFailed(context.getString(R.string.error_could_not_send_package)); cb.pairingFailed(context.getString(R.string.error_could_not_send_package));
} }
Log.e("Device","Unpairing (sendFailed A)"); Log.e("KDE/Device","Unpairing (sendFailed A)");
pairStatus = PairStatus.NotPaired; pairStatus = PairStatus.NotPaired;
} }
@ -271,7 +271,7 @@ public class Device implements BaseLink.PackageReceiver {
public void acceptPairing() { public void acceptPairing() {
Log.i("Device","Accepted pair request started by the other device"); Log.i("KDE/Device","Accepted pair request started by the other device");
//Send our own public key //Send our own public key
NetworkPackage np = NetworkPackage.createPublicKeyPackage(context); NetworkPackage np = NetworkPackage.createPublicKeyPackage(context);
@ -294,7 +294,7 @@ public class Device implements BaseLink.PackageReceiver {
public void rejectPairing() { public void rejectPairing() {
Log.i("Device","Rejected pair request started by the other device"); Log.i("KDE/Device","Rejected pair request started by the other device");
//Log.e("Device","Unpairing (rejectPairing)"); //Log.e("Device","Unpairing (rejectPairing)");
pairStatus = PairStatus.NotPaired; pairStatus = PairStatus.NotPaired;
@ -321,6 +321,7 @@ public class Device implements BaseLink.PackageReceiver {
} }
public void addLink(NetworkPackage identityPackage, BaseLink link) { public void addLink(NetworkPackage identityPackage, BaseLink link) {
//FilesHelper.LogOpenFileCount();
this.protocolVersion = identityPackage.getInt("protocolVersion"); this.protocolVersion = identityPackage.getInt("protocolVersion");
@ -341,10 +342,10 @@ public class Device implements BaseLink.PackageReceiver {
link.setPrivateKey(privateKey); link.setPrivateKey(privateKey);
} catch (Exception e) { } catch (Exception e) {
e.printStackTrace(); e.printStackTrace();
Log.e("Device", "Exception reading our own private key"); //Should not happen Log.e("KDE/Device", "Exception reading our own private key"); //Should not happen
} }
Log.i("Device","addLink "+link.getLinkProvider().getName()+" -> "+getName() + " active links: "+ links.size()); Log.i("KDE/Device","addLink "+link.getLinkProvider().getName()+" -> "+getName() + " active links: "+ links.size());
/* /*
Collections.sort(links, new Comparator<BaseLink>() { Collections.sort(links, new Comparator<BaseLink>() {
@ -363,9 +364,11 @@ public class Device implements BaseLink.PackageReceiver {
} }
public void removeLink(BaseLink link) { public void removeLink(BaseLink link) {
//FilesHelper.LogOpenFileCount();
link.removePackageReceiver(this); link.removePackageReceiver(this);
links.remove(link); links.remove(link);
Log.i("Device","removeLink: "+link.getLinkProvider().getName() + " -> "+getName() + " active links: "+ links.size()); Log.i("KDE/Device","removeLink: "+link.getLinkProvider().getName() + " -> "+getName() + " active links: "+ links.size());
if (links.isEmpty()) { if (links.isEmpty()) {
reloadPluginsFromSettings(); reloadPluginsFromSettings();
} }
@ -376,7 +379,7 @@ public class Device implements BaseLink.PackageReceiver {
if (np.getType().equals(NetworkPackage.PACKAGE_TYPE_PAIR)) { if (np.getType().equals(NetworkPackage.PACKAGE_TYPE_PAIR)) {
Log.i("Device","Pair package"); Log.i("KDE/Device","Pair package");
boolean wantsPair = np.getBoolean("pair"); boolean wantsPair = np.getBoolean("pair");
@ -401,7 +404,7 @@ public class Device implements BaseLink.PackageReceiver {
publicKey = KeyFactory.getInstance("RSA").generatePublic(new X509EncodedKeySpec(publicKeyBytes)); publicKey = KeyFactory.getInstance("RSA").generatePublic(new X509EncodedKeySpec(publicKeyBytes));
} catch(Exception e) { } catch(Exception e) {
e.printStackTrace(); e.printStackTrace();
Log.e("Device","Pairing exception: Received incorrect key"); Log.e("KDE/Device","Pairing exception: Received incorrect key");
for (PairingCallback cb : pairingCallback) { for (PairingCallback cb : pairingCallback) {
cb.pairingFailed(context.getString(R.string.error_invalid_key)); cb.pairingFailed(context.getString(R.string.error_invalid_key));
} }
@ -410,7 +413,7 @@ public class Device implements BaseLink.PackageReceiver {
if (pairStatus == PairStatus.Requested) { //We started pairing if (pairStatus == PairStatus.Requested) { //We started pairing
Log.i("Pairing","Pair answer"); Log.i("KDE/Pairing","Pair answer");
if (pairingTimer != null) pairingTimer.cancel(); if (pairingTimer != null) pairingTimer.cancel();
@ -418,7 +421,7 @@ public class Device implements BaseLink.PackageReceiver {
} else { } else {
Log.i("Pairing","Pair request"); Log.i("KDE/Pairing","Pair request");
Intent intent = new Intent(context, PairActivity.class); Intent intent = new Intent(context, PairActivity.class);
intent.putExtra("deviceId", deviceId); intent.putExtra("deviceId", deviceId);
@ -447,7 +450,7 @@ public class Device implements BaseLink.PackageReceiver {
pairingTimer.schedule(new TimerTask() { pairingTimer.schedule(new TimerTask() {
@Override @Override
public void run() { public void run() {
Log.e("Device","Unpairing (timeout B)"); Log.e("KDE/Device","Unpairing (timeout B)");
pairStatus = PairStatus.NotPaired; pairStatus = PairStatus.NotPaired;
notificationManager.cancel(notificationId); notificationManager.cancel(notificationId);
} }
@ -457,7 +460,7 @@ public class Device implements BaseLink.PackageReceiver {
} }
} else { } else {
Log.i("Pairing","Unpair request"); Log.i("KDE/Pairing","Unpair request");
if (pairStatus == PairStatus.Requested) { if (pairStatus == PairStatus.Requested) {
pairingTimer.cancel(); pairingTimer.cancel();
@ -470,7 +473,6 @@ public class Device implements BaseLink.PackageReceiver {
reloadPluginsFromSettings(); reloadPluginsFromSettings();
} }
//Log.e("Device","Unpairing (unpair request)");
pairStatus = PairStatus.NotPaired; pairStatus = PairStatus.NotPaired;
for (PairingCallback cb : pairingCallback) cb.unpaired(); for (PairingCallback cb : pairingCallback) cb.unpaired();
@ -482,14 +484,14 @@ public class Device implements BaseLink.PackageReceiver {
plugin.onPackageReceived(np); plugin.onPackageReceived(np);
} catch (Exception e) { } catch (Exception e) {
e.printStackTrace(); e.printStackTrace();
Log.e("Device", "Exception in "+plugin.getDisplayName()+"'s onPackageReceived()"); Log.e("KDE/Device", "Exception in "+plugin.getDisplayName()+"'s onPackageReceived()");
} }
} }
} else { } else {
Log.e("onPackageReceived","Device not paired, ignoring package!"); Log.e("KDE/onPackageReceived","Device not paired, ignoring package!");
if (pairStatus != PairStatus.Requested) { if (pairStatus != PairStatus.Requested) {
unpair(); unpair();
@ -512,9 +514,9 @@ public class Device implements BaseLink.PackageReceiver {
public void sendFailure(Throwable e) { public void sendFailure(Throwable e) {
if (e != null) { if (e != null) {
e.printStackTrace(); e.printStackTrace();
Log.e("sendPackage", "Exception: " + e.getMessage()); Log.e("KDE/sendPackage", "Exception: " + e.getMessage());
} else { } else {
Log.e("sendPackage", "Unknown (null) exception"); Log.e("KDE/sendPackage", "Unknown (null) exception");
} }
onFailure(e); onFailure(e);
} }
@ -556,7 +558,7 @@ public class Device implements BaseLink.PackageReceiver {
} }
if (!callback.success) { if (!callback.success) {
Log.e("sendPackage", "No device link (of "+mLinks.size()+" available) could send the package. Package lost!"); Log.e("KDE/sendPackage", "No device link (of "+mLinks.size()+" available) could send the package. Package lost!");
backtrace.printStackTrace(); backtrace.printStackTrace();
} }
@ -584,13 +586,13 @@ public class Device implements BaseLink.PackageReceiver {
private synchronized void addPlugin(final String name) { private synchronized void addPlugin(final String name) {
Plugin existing = plugins.get(name); Plugin existing = plugins.get(name);
if (existing != null) { if (existing != null) {
Log.w("addPlugin","plugin already present:" + name); Log.w("KDE/addPlugin","plugin already present:" + name);
return; return;
} }
final Plugin plugin = PluginFactory.instantiatePluginForDevice(context, name, this); final Plugin plugin = PluginFactory.instantiatePluginForDevice(context, name, this);
if (plugin == null) { if (plugin == null) {
Log.e("addPlugin","could not instantiate plugin: "+name); Log.e("KDE/addPlugin","could not instantiate plugin: "+name);
failedPlugins.put(name, plugin); failedPlugins.put(name, plugin);
return; return;
} }
@ -605,7 +607,7 @@ public class Device implements BaseLink.PackageReceiver {
} catch (Exception e) { } catch (Exception e) {
success = false; success = false;
e.printStackTrace(); e.printStackTrace();
Log.e("addPlugin", "Exception loading plugin " + name); Log.e("KDE/addPlugin", "Exception loading plugin " + name);
} }
if (success) { if (success) {
@ -613,7 +615,7 @@ public class Device implements BaseLink.PackageReceiver {
failedPlugins.remove(name); failedPlugins.remove(name);
plugins.put(name, plugin); plugins.put(name, plugin);
} else { } else {
Log.e("addPlugin", "plugin failed to load " + name); Log.e("KDE/addPlugin", "plugin failed to load " + name);
plugins.remove(name); plugins.remove(name);
failedPlugins.put(name, plugin); failedPlugins.put(name, plugin);
} }
@ -645,7 +647,7 @@ public class Device implements BaseLink.PackageReceiver {
//Log.e("removePlugin","removed " + name); //Log.e("removePlugin","removed " + name);
} catch (Exception e) { } catch (Exception e) {
e.printStackTrace(); e.printStackTrace();
Log.e("removePlugin","Exception calling onDestroy for plugin "+name); Log.e("KDE/removePlugin","Exception calling onDestroy for plugin "+name);
} }
for (PluginsChangedListener listener : pluginsChangedListeners) { for (PluginsChangedListener listener : pluginsChangedListeners) {

View File

@ -20,8 +20,11 @@
package org.kde.kdeconnect.Helpers; package org.kde.kdeconnect.Helpers;
import android.util.Log;
import android.webkit.MimeTypeMap; import android.webkit.MimeTypeMap;
import java.io.File;
public class FilesHelper { public class FilesHelper {
public static String getFileExt(String fileName) { public static String getFileExt(String fileName) {
@ -73,4 +76,11 @@ public class FilesHelper {
return toFileSystemSafeName(name, true, 255); return toFileSystemSafeName(name, true, 255);
} }
public static int GetOpenFileCount() {
return new File("/proc/self/fd").listFiles().length;
}
public static void LogOpenFileCount() {
Log.e("KDE/FileCount",""+GetOpenFileCount());
}
} }