2
0
mirror of https://github.com/KDE/kdeconnect-android synced 2025-08-31 06:05:12 +00:00

Use Log.e instead of printStackTrace

This commit is contained in:
Nicolas Fella
2019-03-31 20:09:44 +02:00
parent 386a9f3f40
commit f1194e88c2
31 changed files with 90 additions and 157 deletions

View File

@@ -149,7 +149,7 @@ public class BluetoothLinkProvider extends BaseLinkProvider {
try {
serverSocket.close();
} catch (IOException e) {
e.printStackTrace();
Log.e("KDEConnect", "Exception", e);
}
}
}
@@ -160,7 +160,7 @@ public class BluetoothLinkProvider extends BaseLinkProvider {
serverSocket = bluetoothAdapter
.listenUsingRfcommWithServiceRecord("KDE Connect", SERVICE_UUID);
} catch (IOException e) {
e.printStackTrace();
Log.e("KDEConnect", "Exception", e);
return;
}

View File

@@ -71,7 +71,7 @@ public class LanLink extends BaseLink {
try {
socket.close();
} catch (IOException e) {
e.printStackTrace();
Log.e("LanLink", "Error", e);
}
}
@@ -257,8 +257,7 @@ public class LanLink extends BaseLink {
try {
np = RsaHelper.decrypt(np, privateKey);
} catch(Exception e) {
e.printStackTrace();
Log.e("KDE/onPacketReceived","Exception decrypting the package");
Log.e("KDE/onPacketReceived","Exception decrypting the package", e);
}
}
@@ -275,8 +274,7 @@ public class LanLink extends BaseLink {
np.setPayload(new NetworkPacket.Payload(payloadSocket, np.getPayloadSize()));
} catch (Exception e) {
try { payloadSocket.close(); } catch(Exception ignored) { }
e.printStackTrace();
Log.e("KDE/LanLink", "Exception connecting to payload remote socket");
Log.e("KDE/LanLink", "Exception connecting to payload remote socket", e);
}
}

View File

@@ -102,7 +102,7 @@ public class LanLinkProvider extends BaseLinkProvider implements LanLink.LinkDis
networkPacket = NetworkPacket.unserialize(message);
//Log.e("TcpListener","Received TCP package: "+networkPacket.serialize());
} catch (Exception e) {
e.printStackTrace();
Log.e("KDE/LanLinkProvider", "Exception while receiving TCP packet", e);
return;
}
@@ -157,8 +157,7 @@ public class LanLinkProvider extends BaseLinkProvider implements LanLink.LinkDis
identityPacketReceived(identityPacket, socket, LanLink.ConnectionStarted.Remotely);
} catch (Exception e) {
Log.e("KDE/LanLinkProvider", "Cannot connect to " + address);
e.printStackTrace();
Log.e("KDE/LanLinkProvider", "Cannot connect to " + address, e);
if (!reverseConnectionBlackList.contains(address)) {
Log.w("KDE/LanLinkProvider", "Blacklisting " + address);
reverseConnectionBlackList.add(address);
@@ -179,7 +178,7 @@ public class LanLinkProvider extends BaseLinkProvider implements LanLink.LinkDis
try {
socket.setKeepAlive(true);
} catch (SocketException e) {
e.printStackTrace();
Log.e("LanLink", "Exception", e);
}
}
@@ -236,8 +235,7 @@ public class LanLinkProvider extends BaseLinkProvider implements LanLink.LinkDis
Log.i("KDE/LanLinkProvider", "Handshake as " + mode + " successful with " + identityPacket.getString("deviceName") + " secured with " + event.getCipherSuite());
addLink(identityPacket, sslsocket, connectionStarted);
} catch (Exception e) {
Log.e("KDE/LanLinkProvider", "Handshake as " + mode + " failed with " + identityPacket.getString("deviceName"));
e.printStackTrace();
Log.e("KDE/LanLinkProvider", "Handshake as " + mode + " failed with " + identityPacket.getString("deviceName"), e);
BackgroundService.RunCommand(context, service -> {
Device device = service.getDevice(deviceId);
if (device == null) return;
@@ -252,8 +250,7 @@ public class LanLinkProvider extends BaseLinkProvider implements LanLink.LinkDis
sslsocket.startHandshake();
}
} catch (Exception e) {
Log.e("KDE/LanLinkProvider", "Handshake failed with " + identityPacket.getString("deviceName"));
e.printStackTrace();
Log.e("KDE/LanLinkProvider", "Handshake failed with " + identityPacket.getString("deviceName"), e);
//String[] ciphers = sslsocket.getSupportedCipherSuites();
//for (String cipher : ciphers) {
@@ -265,7 +262,7 @@ public class LanLinkProvider extends BaseLinkProvider implements LanLink.LinkDis
addLink(identityPacket, socket, connectionStarted);
}
} catch (Exception e) {
e.printStackTrace();
Log.e("LanLink", "Exception", e);
}
}
@@ -311,8 +308,7 @@ public class LanLinkProvider extends BaseLinkProvider implements LanLink.LinkDis
udpServer.setReuseAddress(true);
udpServer.setBroadcast(true);
} catch (SocketException e) {
Log.e("LanLinkProvider", "Error creating udp server");
e.printStackTrace();
Log.e("LanLinkProvider", "Error creating udp server", e);
return;
}
new Thread(() -> {
@@ -324,8 +320,7 @@ public class LanLinkProvider extends BaseLinkProvider implements LanLink.LinkDis
udpServer.receive(packet);
udpPacketReceived(packet);
} catch (Exception e) {
e.printStackTrace();
Log.e("LanLinkProvider", "UdpReceive exception");
Log.e("LanLinkProvider", "UdpReceive exception", e);
}
}
Log.w("UdpListener", "Stopping UDP listener");
@@ -336,8 +331,7 @@ public class LanLinkProvider extends BaseLinkProvider implements LanLink.LinkDis
try {
tcpServer = openServerSocketOnFreePort(MIN_PORT);
} catch (Exception e) {
Log.e("LanLinkProvider", "Error creating tcp server");
e.printStackTrace();
Log.e("LanLinkProvider", "Error creating tcp server", e);
return;
}
new Thread(() -> {
@@ -347,8 +341,7 @@ public class LanLinkProvider extends BaseLinkProvider implements LanLink.LinkDis
configureSocket(socket);
tcpPacketReceived(socket);
} catch (Exception e) {
e.printStackTrace();
Log.e("LanLinkProvider", "TcpReceive exception");
Log.e("LanLinkProvider", "TcpReceive exception", e);
}
}
Log.w("TcpListener", "Stopping TCP listener");
@@ -398,8 +391,7 @@ public class LanLinkProvider extends BaseLinkProvider implements LanLink.LinkDis
socket.setBroadcast(true);
bytes = identity.serialize().getBytes(StringsHelper.UTF8);
} catch (Exception e) {
e.printStackTrace();
Log.e("KDE/LanLinkProvider", "Failed to create DatagramSocket");
Log.e("KDE/LanLinkProvider", "Failed to create DatagramSocket", e);
}
if (bytes != null) {
@@ -410,8 +402,7 @@ public class LanLinkProvider extends BaseLinkProvider implements LanLink.LinkDis
socket.send(new DatagramPacket(bytes, bytes.length, client, MIN_PORT));
//Log.i("KDE/LanLinkProvider","Udp identity package sent to address "+client);
} catch (Exception e) {
e.printStackTrace();
Log.e("KDE/LanLinkProvider", "Sending udp identity package failed. Invalid address? (" + ipstr + ")");
Log.e("KDE/LanLinkProvider", "Sending udp identity package failed. Invalid address? (" + ipstr + ")", e);
}
}
}
@@ -449,12 +440,12 @@ public class LanLinkProvider extends BaseLinkProvider implements LanLink.LinkDis
try {
tcpServer.close();
} catch (Exception e) {
e.printStackTrace();
Log.e("LanLink", "Exception", e);
}
try {
udpServer.close();
} catch (Exception e) {
e.printStackTrace();
Log.e("LanLink", "Exception", e);
}
}

View File

@@ -158,11 +158,7 @@ public class LanPairingHandler extends BasePairingHandler {
@Override
public void onFailure(Throwable e) {
if (e != null) {
e.printStackTrace();
} else {
Log.e("LanPairing/onFailure", "Unknown (null) exception");
}
Log.e("LanPairing/onFailure", "Exception", e);
mCallback.pairingFailed(mDevice.getContext().getString(R.string.error_could_not_send_package));
}
};
@@ -187,11 +183,7 @@ public class LanPairingHandler extends BasePairingHandler {
@Override
public void onFailure(Throwable e) {
if (e != null) {
e.printStackTrace();
} else {
Log.e("LanPairing/onFailure", "Unknown (null) exception");
}
Log.e("LanPairing/onFailure", "Exception", e);
mCallback.pairingFailed(mDevice.getContext().getString(R.string.error_not_reachable));
}
};
@@ -217,7 +209,7 @@ public class LanPairingHandler extends BasePairingHandler {
String encodedPublicKey = Base64.encodeToString(mDevice.publicKey.getEncoded(), 0);
editor.putString("publicKey", encodedPublicKey);
} catch (Exception e) {
Log.e("KDE/PairingDone", "Error encoding public key");
Log.e("KDE/PairingDone", "Error encoding public key", e);
}
}
@@ -225,12 +217,11 @@ public class LanPairingHandler extends BasePairingHandler {
String encodedCertificate = Base64.encodeToString(mDevice.certificate.getEncoded(), 0);
editor.putString("certificate", encodedCertificate);
} catch (NullPointerException n) {
Log.w("KDE/PairingDone", "Certificate is null, remote device does not support ssl");
Log.w("KDE/PairingDone", "Certificate is null, remote device does not support ssl", n);
} catch (CertificateEncodingException c) {
Log.e("KDE/PairingDOne", "Error encoding certificate");
Log.e("KDE/PairingDOne", "Error encoding certificate", c);
} catch (Exception e) {
e.printStackTrace();
Log.e("KDE/Pairng", "Exception");
Log.e("KDE/Pairng", "Exception", e);
}
editor.apply();

View File

@@ -157,8 +157,7 @@ public class Device implements BaseLink.PacketReceiver {
publicKey = KeyFactory.getInstance("RSA").generatePublic(new X509EncodedKeySpec(publicKeyBytes));
}
} catch (Exception e) {
e.printStackTrace();
Log.e("KDE/Device", "Exception deserializing stored public key for device");
Log.e("KDE/Device", "Exception deserializing stored public key for device", e);
}
//Assume every plugin is supported until addLink is called and we can get the actual list
@@ -459,8 +458,7 @@ public class Device implements BaseLink.PacketReceiver {
certificate = SslHelper.parseCertificate(certificateBytes);
Log.i("KDE/Device", "Got certificate ");
} catch (Exception e) {
e.printStackTrace();
Log.e("KDE/Device", "Error getting certificate");
Log.e("KDE/Device", "Error getting certificate", e);
}
}
@@ -474,8 +472,7 @@ public class Device implements BaseLink.PacketReceiver {
PrivateKey privateKey = KeyFactory.getInstance("RSA").generatePrivate(new PKCS8EncodedKeySpec(privateKeyBytes));
link.setPrivateKey(privateKey);
} catch (Exception e) {
e.printStackTrace();
Log.e("KDE/Device", "Exception reading our own private key"); //Should not happen
Log.e("KDE/Device", "Exception reading our own private key", e); //Should not happen
}
Log.i("KDE/Device", "addLink " + link.getLinkProvider().getName() + " -> " + getName() + " active links: " + links.size());
@@ -559,8 +556,7 @@ public class Device implements BaseLink.PacketReceiver {
try {
ph.packageReceived(np);
} catch (Exception e) {
e.printStackTrace();
Log.e("PairingPacketReceived", "Exception");
Log.e("PairingPacketReceived", "Exception", e);
}
}
} else if (isPaired()) {
@@ -578,8 +574,7 @@ public class Device implements BaseLink.PacketReceiver {
try {
plugin.onPacketReceived(np);
} catch (Exception e) {
e.printStackTrace();
Log.e("KDE/Device", "Exception in " + plugin.getPluginKey() + "'s onPacketReceived()");
Log.e("KDE/Device", "Exception in " + plugin.getPluginKey() + "'s onPacketReceived()", e);
//try { Log.e("KDE/Device", "NetworkPacket:" + np.serialize()); } catch (Exception _) { }
}
}
@@ -604,8 +599,7 @@ public class Device implements BaseLink.PacketReceiver {
try {
plugin.onUnpairedDevicePacketReceived(np);
} catch (Exception e) {
e.printStackTrace();
Log.e("KDE/Device", "Exception in " + plugin.getDisplayName() + "'s onPacketReceived() in unPairedPacketListeners");
Log.e("KDE/Device", "Exception in " + plugin.getDisplayName() + "'s onPacketReceived() in unPairedPacketListeners", e);
}
}
} else {
@@ -631,11 +625,7 @@ public class Device implements BaseLink.PacketReceiver {
@Override
public void onFailure(Throwable e) {
if (e != null) {
e.printStackTrace();
} else {
Log.e("KDE/sendPacket", "Unknown (null) exception");
}
Log.e("KDE/sendPacket", "Exception", e);
}
};
@@ -734,10 +724,7 @@ public class Device implements BaseLink.PacketReceiver {
success = plugin.onCreate();
} catch (Exception e) {
success = false;
e.printStackTrace();
}
if (!success) {
Log.e("KDE/addPlugin", "plugin failed to load " + pluginKey);
Log.e("KDE/addPlugin", "plugin failed to load " + pluginKey, e);
}
plugins.put(pluginKey, plugin);
@@ -775,8 +762,7 @@ public class Device implements BaseLink.PacketReceiver {
plugin.onDestroy();
//Log.e("removePlugin","removed " + pluginKey);
} catch (Exception e) {
e.printStackTrace();
Log.e("KDE/removePlugin", "Exception calling onDestroy for plugin " + pluginKey);
Log.e("KDE/removePlugin", "Exception calling onDestroy for plugin " + pluginKey, e);
}
return true;

View File

@@ -39,8 +39,7 @@ public class AppsHelper {
} catch (final PackageManager.NameNotFoundException e) {
e.printStackTrace();
Log.e("AppsHelper", "Could not resolve name " + packageName);
Log.e("AppsHelper", "Could not resolve name " + packageName, e);
return null;
@@ -57,15 +56,8 @@ public class AppsHelper {
return pm.getApplicationIcon(ai);
} catch (final PackageManager.NameNotFoundException e) {
e.printStackTrace();
Log.e("AppsHelper", "Could not find icon for " + packageName);
Log.e("AppsHelper", "Could not find icon for " + packageName, e);
return null;
}
}
}

View File

@@ -191,7 +191,7 @@ public class ContactsHelper {
}
} catch (IOException e) {
// If you are experiencing this, please open a bug report indicating how you got here
e.printStackTrace();
Log.e("Contacts", "Exception while fetching vcards", e);
}
// At this point we are screwed:
@@ -239,10 +239,10 @@ public class ContactsHelper {
toReturn.put(ID, new VCardBuilder(vcard.toString()));
} catch (IOException e) {
// If you are experiencing this, please open a bug report indicating how you got here
e.printStackTrace();
Log.e("Contacts", "Exception while fetching vcards", e);
} catch (NullPointerException e) {
// If you are experiencing this, please open a bug report indicating how you got here
e.printStackTrace();
Log.e("Contacts", "Exception while fetching vcards", e);
}
}

View File

@@ -496,8 +496,7 @@ public class DeviceHelper {
}
} catch (Exception e) {
//Some phones might not define BRAND or MODEL, ignore exceptions
Log.e("Exception", e.getMessage());
e.printStackTrace();
Log.e("Exception", e.getMessage(), e);
}
if (deviceName == null || deviceName.isEmpty()) {
return "Android"; //Could not find a name

View File

@@ -129,8 +129,7 @@ public class FilesHelper {
try {
size = new File(uri.getPath()).length();
} catch (Exception e) {
Log.e("SendFileActivity", "Could not obtain file size");
e.printStackTrace();
Log.e("SendFileActivity", "Could not obtain file size", e);
}
} else {
@@ -155,8 +154,7 @@ public class FilesHelper {
String name = cursor.getString(column_index);
np.set("filename", name);
} catch (Exception e) {
e.printStackTrace();
Log.e("SendFileActivity", "Could not obtain file name");
Log.e("SendFileActivity", "Could not obtain file name", e);
}
try {
@@ -165,8 +163,7 @@ public class FilesHelper {
//For some reason this size can differ from the actual file size!
size = cursor.getInt(column_index);
} catch (Exception e) {
Log.e("SendFileActivity", "Could not obtain file size");
e.printStackTrace();
Log.e("SendFileActivity", "Could not obtain file size", e);
}
} finally {
try {
@@ -182,7 +179,6 @@ public class FilesHelper {
return np;
} catch (Exception e) {
Log.e("SendFileActivity", "Exception creating network packet", e);
e.printStackTrace();
return null;
}
}

View File

@@ -45,14 +45,12 @@ public class NetworkHelper {
return false; //I have neighbours, so this doesn't look like a mobile network
}
} catch (Exception e) {
Log.e("NetworkHelper", "Exception reading procnetarp");
e.printStackTrace();
Log.e("NetworkHelper", "Exception reading procnetarp", e);
}
}
return mobile;
} catch (Exception e) {
e.printStackTrace();
Log.d("isOnMobileNetwork", "Something went wrong, but this is non-critical.");
Log.e("isOnMobileNetwork", "Something went wrong, but this is non-critical.", e);
}
return false;
}

View File

@@ -55,8 +55,7 @@ public class RsaHelper {
keyGen.initialize(2048);
keyPair = keyGen.genKeyPair();
} catch (Exception e) {
e.printStackTrace();
Log.e("KDE/initializeRsaKeys", "Exception");
Log.e("KDE/initializeRsaKeys", "Exception", e);
return;
}

View File

@@ -114,8 +114,7 @@ public class SslHelper {
edit.apply();
} catch (Exception e) {
e.printStackTrace();
Log.e("KDE/initialiseCert", "Exception");
Log.e("KDE/initialiseCert", "Exception", e);
}
} else {
@@ -125,8 +124,7 @@ public class SslHelper {
X509CertificateHolder certificateHolder = new X509CertificateHolder(certificateBytes);
certificate = new JcaX509CertificateConverter().setProvider(BC).getCertificate(certificateHolder);
} catch (Exception e) {
Log.e("KDE/SslHelper", "Exception reading own certificate");
e.printStackTrace();
Log.e("KDE/SslHelper", "Exception reading own certificate", e);
}
}
}
@@ -195,8 +193,7 @@ public class SslHelper {
}
return tlsContext;
} catch (Exception e) {
Log.e("KDE/SslHelper", "Error creating tls context");
e.printStackTrace();
Log.e("KDE/SslHelper", "Error creating tls context", e);
}
return null;

View File

@@ -26,6 +26,7 @@ import android.net.Uri;
import android.os.Build;
import android.os.Environment;
import android.provider.DocumentsContract;
import android.util.Log;
import java.io.BufferedReader;
import java.io.File;
@@ -89,7 +90,7 @@ public class StorageHelper {
try (Scanner scanner = new Scanner(new File("/proc/mounts"))) {
mounts = scanner.useDelimiter("\\A").next();
} catch (Exception e) {
e.printStackTrace();
Log.e("StorageHelper", "Exception while getting storageList", e);
}
File dirs[] = storage.listFiles();
@@ -129,7 +130,7 @@ public class StorageHelper {
}
}
} catch (Exception e) {
e.printStackTrace();
Log.e("StorageHelper", "Exception", e);
}
for (String line : entries) {

View File

@@ -279,8 +279,7 @@ public class NetworkPacket {
np.mBody.put("incomingCapabilities", new JSONArray(PluginFactory.getIncomingCapabilities()));
np.mBody.put("outgoingCapabilities", new JSONArray(PluginFactory.getOutgoingCapabilities()));
} catch (Exception e) {
e.printStackTrace();
Log.e("NetworkPacakge", "Exception on createIdentityPacket");
Log.e("NetworkPackage", "Exception on createIdentityPacket", e);
}
return np;

View File

@@ -307,8 +307,7 @@ public class MprisPlugin extends Plugin {
try {
playerStatusUpdated.get(key).dispatchMessage(new Message());
} catch (Exception e) {
e.printStackTrace();
Log.e("MprisControl", "Exception");
Log.e("MprisControl", "Exception", e);
playerStatusUpdated.remove(key);
}
}
@@ -355,8 +354,7 @@ public class MprisPlugin extends Plugin {
try {
playerListUpdated.get(key).dispatchMessage(new Message());
} catch (Exception e) {
e.printStackTrace();
Log.e("MprisControl", "Exception");
Log.e("MprisControl", "Exception", e);
playerListUpdated.remove(key);
}
}
@@ -468,8 +466,7 @@ public class MprisPlugin extends Plugin {
try {
playerStatusUpdated.get(key).dispatchMessage(new Message());
} catch (Exception e) {
e.printStackTrace();
Log.e("MprisControl", "Exception");
Log.e("MprisControl", "Exception", e);
playerStatusUpdated.remove(key);
}
}

View File

@@ -256,8 +256,7 @@ public class NotificationsPlugin extends Plugin implements NotificationReceiver.
np.set("payloadHash", getChecksum(bitmapData));
}
} catch (Exception e) {
e.printStackTrace();
Log.e("NotificationsPlugin", "Error retrieving icon");
Log.e("NotificationsPlugin", "Error retrieving icon", e);
}
} else {
currentNotifications.add(key);
@@ -379,8 +378,7 @@ public class NotificationsPlugin extends Plugin implements NotificationReceiver.
Bundle extras = notification.extras;
title = extractStringFromExtra(extras, TITLE_KEY);
} catch (Exception e) {
Log.w("NotificationPlugin", "problem parsing notification extras for " + notification.tickerText);
e.printStackTrace();
Log.e("NotificationPlugin", "problem parsing notification extras for " + notification.tickerText, e);
}
}
}
@@ -407,8 +405,7 @@ public class NotificationsPlugin extends Plugin implements NotificationReceiver.
repliableNotification.tag = statusBarNotification.getTag();//TODO find how to pass Tag with sending PendingIntent, might fix Hangout problem
}
} catch (Exception e) {
Log.w("NotificationPlugin", "problem extracting notification wear for " + statusBarNotification.getNotification().tickerText);
e.printStackTrace();
Log.e("NotificationPlugin", "problem extracting notification wear for " + statusBarNotification.getNotification().tickerText, e);
}
}
}
@@ -427,8 +424,7 @@ public class NotificationsPlugin extends Plugin implements NotificationReceiver.
Object extraTextExtra = extras.get(TEXT_KEY);
if (extraTextExtra != null) text = extraTextExtra.toString();
} catch (Exception e) {
Log.w("NotificationPlugin", "problem parsing notification extras for " + notification.tickerText);
e.printStackTrace();
Log.e("NotificationPlugin", "problem parsing notification extras for " + notification.tickerText, e);
}
}
}
@@ -476,8 +472,7 @@ public class NotificationsPlugin extends Plugin implements NotificationReceiver.
ticker = extraText;
}
} catch (Exception e) {
Log.w("NotificationPlugin", "problem parsing notification extras for " + notification.tickerText);
e.printStackTrace();
Log.e("NotificationPlugin", "problem parsing notification extras for " + notification.tickerText, e);
}
}

View File

@@ -141,8 +141,7 @@ public class PluginFactory {
plugin.setContext(context, device);
return plugin;
} catch (Exception e) {
Log.e("PluginFactory", "Could not instantiate plugin: " + pluginKey);
e.printStackTrace();
Log.e("PluginFactory", "Could not instantiate plugin: " + pluginKey, e);
return null;
}
}

View File

@@ -25,6 +25,7 @@ import android.content.ClipboardManager;
import android.content.Context;
import android.os.Build;
import android.os.Bundle;
import android.util.Log;
import android.view.ContextMenu;
import android.view.MenuInflater;
import android.view.MenuItem;
@@ -69,7 +70,7 @@ public class RunCommandActivity extends AppCompatActivity {
commandItems.add(new CommandEntry(obj.getString("name"),
obj.getString("command"), obj.getString("key")));
} catch (JSONException e) {
e.printStackTrace();
Log.e("RunCommand", "Error parsing JSON", e);
}
}

View File

@@ -24,6 +24,7 @@ package org.kde.kdeconnect.Plugins.RunCommandPlugin;
import android.app.Activity;
import android.content.Intent;
import android.graphics.drawable.Drawable;
import android.util.Log;
import org.json.JSONException;
import org.json.JSONObject;
@@ -115,7 +116,7 @@ public class RunCommandPlugin extends Plugin {
)
);
} catch (JSONException e) {
e.printStackTrace();
Log.e("RunCommand", "Error parsing JSON", e);
}
}
@@ -125,7 +126,7 @@ public class RunCommandPlugin extends Plugin {
context.sendBroadcast(updateWidget);
} catch (JSONException e) {
e.printStackTrace();
Log.e("RunCommand", "Error parsing JSON", e);
}
for (CommandsChangedCallback aCallback : callbacks) {

View File

@@ -324,8 +324,7 @@ public class SMSPlugin extends Plugin {
//TODO: Notify other end
} catch (Exception e) {
//TODO: Notify other end
Log.e("SMSPlugin", e.getMessage());
e.printStackTrace();
Log.e("SMSPlugin", "Exception", e);
}
}
break;

View File

@@ -25,6 +25,7 @@ import android.content.ContentResolver;
import android.content.SharedPreferences;
import android.net.Uri;
import android.os.Build;
import android.util.Log;
import org.json.JSONException;
import org.json.JSONObject;
@@ -80,7 +81,7 @@ public class SftpPlugin extends Plugin implements SharedPreferences.OnSharedPref
return true;
} catch (Exception e) {
e.printStackTrace();
Log.e("SFTP", "Exception in server.init()", e);
return false;
}
}

View File

@@ -30,6 +30,7 @@ import android.net.Uri;
import android.os.Build;
import android.os.Bundle;
import android.os.Environment;
import android.util.Log;
import android.util.SparseBooleanArray;
import android.view.Menu;
import android.view.MenuInflater;
@@ -276,7 +277,7 @@ public class SftpSettingsFragment
storageInfoList.add(SftpPlugin.StorageInfo.fromJSON(jsonArray.getJSONObject(i)));
}
} catch (JSONException e) {
e.printStackTrace();
Log.e("SFTPSettings", "Couldn't load storage info", e);
}
if (Build.VERSION.SDK_INT <= 19) {

View File

@@ -116,7 +116,6 @@ class SimpleSftpServer {
sshd.start();
started = true;
} catch (Exception e) {
e.printStackTrace();
port++;
if (port >= ENDPORT) {
port = -1;
@@ -135,7 +134,7 @@ class SimpleSftpServer {
started = false;
sshd.stop(true);
} catch (Exception e) {
e.printStackTrace();
Log.e("SFTP", "Exception while stopping the server", e);
}
}

View File

@@ -3,6 +3,7 @@ package org.kde.kdeconnect.Plugins.SharePlugin;
import android.app.NotificationManager;
import android.content.Context;
import android.content.res.Resources;
import android.util.Log;
import org.kde.kdeconnect.Device;
import org.kde.kdeconnect.Helpers.NotificationHelper;
@@ -75,9 +76,7 @@ class NotificationUpdateCallback extends Device.SendPacketStatusCallback {
public void onFailure(Throwable e) {
updateDone(false);
NotificationHelper.notifyCompat(notificationManager, notificationId, builder.build());
if (e != null) {
e.printStackTrace();
}
Log.e("KDEConnect", "Exception", e);
}
private void updateText() {

View File

@@ -147,8 +147,7 @@ public class SharePlugin extends Plugin {
}
} catch (Exception e) {
Log.e("SharePlugin", "Exception");
e.printStackTrace();
Log.e("SharePlugin", "Exception", e);
}
return true;
@@ -231,7 +230,7 @@ public class SharePlugin extends Plugin {
}
}
} catch (Exception e) {
e.printStackTrace();
Log.e("SharePlugin", "Error sending files", e);
}
}).start();
@@ -255,8 +254,7 @@ public class SharePlugin extends Plugin {
queuedSendUriList(uriList);
} catch (Exception e) {
Log.e("ShareActivity", "Exception");
e.printStackTrace();
Log.e("ShareActivity", "Exception", e);
}
} else if (extras.containsKey(Intent.EXTRA_TEXT)) {

View File

@@ -127,7 +127,7 @@ public class ShareSettingsFragment extends PluginSettingsFragment {
try {
getDefaultDestinationDirectory().mkdirs();
} catch (Exception e) {
e.printStackTrace();
Log.e("KDEConnect", "Exception", e);
}
return DocumentFile.fromFile(getDefaultDestinationDirectory());
}

View File

@@ -20,6 +20,8 @@
package org.kde.kdeconnect.Plugins.SystemvolumePlugin;
import android.util.Log;
import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;
@@ -75,7 +77,7 @@ public class SystemVolumePlugin extends Plugin {
sinks.put(sink.getName(), sink);
}
} catch (JSONException e) {
e.printStackTrace();
Log.e("KDEConnect", "Exception", e);
}
for (SinkListener l : listeners) {

View File

@@ -352,7 +352,6 @@ public class DeviceFragment extends Fragment {
mActivity.invalidateOptionsMenu();
} catch (IllegalStateException e) {
e.printStackTrace();
//Ignore: The activity was closed while we were trying to update it
} catch (ConcurrentModificationException e) {
Log.e("DeviceActivity", "ConcurrentModificationException");

View File

@@ -185,7 +185,6 @@ public class PairingFragment extends Fragment implements PairingDeviceItem.Callb
//Restore scroll
list.setSelectionFromTop(index, top);
} catch (IllegalStateException e) {
e.printStackTrace();
//Ignore: The activity was closed while we were trying to update it
} finally {
listRefreshCalledThisFrame = false;

View File

@@ -75,8 +75,7 @@ public class DeviceTest {
keyGen.initialize(2048);
keyPair = keyGen.genKeyPair();
} catch (Exception e) {
e.printStackTrace();
Log.e("KDE/initializeRsaKeys", "Exception");
Log.e("KDE/initializeRsaKeys", "Exception", e);
return;
}
@@ -162,8 +161,8 @@ public class DeviceTest {
keyGen.initialize(2048);
keyPair = keyGen.genKeyPair();
} catch (Exception e) {
e.printStackTrace();
Log.e("KDE/initializeRsaKeys", "Exception");
Log.e("KDE/initializeRsaKeys", "Exception", e);
Log.e("KDE/initializeRsaKeys", "Exception", e);
return;
}
device.publicKey = keyPair.getPublic();
@@ -203,8 +202,7 @@ public class DeviceTest {
keyGen.initialize(2048);
keyPair = keyGen.genKeyPair();
} catch (Exception e) {
e.printStackTrace();
Log.e("KDE/initializeRsaKeys", "Exception");
Log.e("KDE/initializeRsaKeys", "Exception", e);
}
NetworkPacket fakeNetworkPacket = new NetworkPacket(NetworkPacket.PACKET_TYPE_IDENTITY);
@@ -251,7 +249,7 @@ public class DeviceTest {
method.setAccessible(true);
method.invoke(device);
} catch (Exception e) {
e.printStackTrace();
Log.e("KDEConnect", "Exception", e);
}
assertTrue(device.isPaired());

View File

@@ -142,8 +142,7 @@ public class LanLinkTest {
np.setPayload(new NetworkPacket.Payload(socket.getInputStream(), np.getPayloadSize()));
} catch (Exception e) {
socket.close();
e.printStackTrace();
Log.e("KDE/LanLinkTest", "Exception connecting to remote socket");
Log.e("KDE/LanLinkTest", "Exception connecting to remote socket", e);
throw e;
}
@@ -169,8 +168,7 @@ public class LanLinkTest {
input.close();
} catch (Exception e) {
Log.e("Downloader Test", "Exception");
e.printStackTrace();
Log.e("Downloader Test", "Exception", e);
}
}
}
@@ -233,7 +231,7 @@ public class LanLinkTest {
// Wait 1 secs for downloader to finish (if some error, it will continue and assert will fail)
downloader.join(1000);
} catch (Exception e) {
e.printStackTrace();
Log.e("Test", "Exception", e);
throw e;
}
assertEquals(new String(data), new String(downloader.getOutputStream().toByteArray()));