Replace printStackTrace with proper Log.e calls

This commit is contained in:
Daniel Martí 2015-08-20 19:28:30 -07:00
parent 8669fddd70
commit 1f41bbdc0d
7 changed files with 18 additions and 12 deletions

View File

@ -39,6 +39,7 @@ import android.os.Message;
import android.os.Messenger; import android.os.Messenger;
import android.os.RemoteException; import android.os.RemoteException;
import android.preference.PreferenceManager; import android.preference.PreferenceManager;
import android.util.Log;
import android.widget.Toast; import android.widget.Toast;
import com.nostra13.universalimageloader.cache.disc.impl.LimitedAgeDiskCache; import com.nostra13.universalimageloader.cache.disc.impl.LimitedAgeDiskCache;
@ -63,6 +64,8 @@ import java.util.Set;
public class FDroidApp extends Application { public class FDroidApp extends Application {
private static final String TAG = "FDroidApp";
// for the local repo on this device, all static since there is only one // for the local repo on this device, all static since there is only one
public static int port; public static int port;
public static String ipAddressString; public static String ipAddressString;
@ -295,8 +298,8 @@ public class FDroidApp extends Application {
break; break;
} }
} }
} catch (PackageManager.NameNotFoundException e1) { } catch (PackageManager.NameNotFoundException e) {
e1.printStackTrace(); Log.e(TAG, "Could not get application info to send via bluetooth", e);
found = false; found = false;
} }
if (sendBt != null) { if (sendBt != null) {
@ -351,7 +354,7 @@ public class FDroidApp extends Application {
Message msg = Message.obtain(null, LocalRepoService.RESTART, LocalRepoService.RESTART, 0); Message msg = Message.obtain(null, LocalRepoService.RESTART, LocalRepoService.RESTART, 0);
localRepoServiceMessenger.send(msg); localRepoServiceMessenger.send(msg);
} catch (RemoteException e) { } catch (RemoteException e) {
e.printStackTrace(); Log.e(TAG, "Could not reset local repo service", e);
} }
} }
} }

View File

@ -10,9 +10,12 @@ import android.nfc.NdefMessage;
import android.nfc.NdefRecord; import android.nfc.NdefRecord;
import android.nfc.NfcAdapter; import android.nfc.NfcAdapter;
import android.os.Build; import android.os.Build;
import android.util.Log;
public class NfcHelper { public class NfcHelper {
private static final String TAG = "NfcHelper";
@TargetApi(14) @TargetApi(14)
private static NfcAdapter getAdapter(Context context) { private static NfcAdapter getAdapter(Context context) {
if (Build.VERSION.SDK_INT < 14) if (Build.VERSION.SDK_INT < 14)
@ -48,7 +51,7 @@ public class NfcHelper {
}; };
nfcAdapter.setBeamPushUris(uris, activity); nfcAdapter.setBeamPushUris(uris, activity);
} catch (PackageManager.NameNotFoundException e) { } catch (PackageManager.NameNotFoundException e) {
e.printStackTrace(); Log.e(TAG, "Could not get application info", e);
} }
} }
} }

View File

@ -76,7 +76,7 @@ public class RepoUpdater {
String versionName = context.getPackageManager().getPackageInfo(context.getPackageName(), 0).versionName; String versionName = context.getPackageManager().getPackageInfo(context.getPackageName(), 0).versionName;
urlString += "?client_version=" + versionName; urlString += "?client_version=" + versionName;
} catch (PackageManager.NameNotFoundException e) { } catch (PackageManager.NameNotFoundException e) {
e.printStackTrace(); Log.e(TAG, "Could not get client version name", e);
} }
return new URL(urlString); return new URL(urlString);
} }

View File

@ -100,9 +100,7 @@ public class InstalledAppProvider extends FDroidProvider {
try { try {
appInfo = pm.getApplicationInfo(packageName, PackageManager.GET_META_DATA); appInfo = pm.getApplicationInfo(packageName, PackageManager.GET_META_DATA);
return appInfo.loadLabel(pm).toString(); return appInfo.loadLabel(pm).toString();
} catch (PackageManager.NameNotFoundException e) { } catch (PackageManager.NameNotFoundException | Resources.NotFoundException e) {
e.printStackTrace();
} catch (Resources.NotFoundException e) {
Utils.DebugLog(TAG, "Could not get application label", e); Utils.DebugLog(TAG, "Could not get application label", e);
} }
return packageName; // all else fails, return id return packageName; // all else fails, return id

View File

@ -7,6 +7,7 @@ import android.net.wifi.WifiManager.MulticastLock;
import android.os.AsyncTask; import android.os.AsyncTask;
import android.os.Handler; import android.os.Handler;
import android.os.Looper; import android.os.Looper;
import android.util.Log;
import android.view.LayoutInflater; import android.view.LayoutInflater;
import android.view.View; import android.view.View;
import android.view.ViewGroup; import android.view.ViewGroup;
@ -105,7 +106,7 @@ public class MDnsHelper implements ServiceListener {
}; };
mJmdns = JmDNS.create(InetAddress.getByAddress(byteIp)); mJmdns = JmDNS.create(InetAddress.getByAddress(byteIp));
} catch (IOException e) { } catch (IOException e) {
e.printStackTrace(); Log.e(TAG, "An error occured while discovering services", e);
} }
return null; return null;
} }

View File

@ -171,8 +171,8 @@ public class WifiStateChangeService extends Service {
} }
} }
} }
} catch (SocketException ex) { } catch (SocketException e) {
ex.printStackTrace(); Log.e(TAG, "Could not get ip address", e);
} }
return null; return null;

View File

@ -10,6 +10,7 @@ import android.support.annotation.NonNull;
import android.support.v4.app.Fragment; import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager; import android.support.v4.app.FragmentManager;
import android.support.v7.app.ActionBarActivity; import android.support.v7.app.ActionBarActivity;
import android.util.Log;
import android.view.MenuItem; import android.view.MenuItem;
import android.widget.Toast; import android.widget.Toast;
@ -268,7 +269,7 @@ public class SwapActivity extends ActionBarActivity implements SwapProcessManage
} }
}.execute(); }.execute();
} catch (Exception e) { } catch (Exception e) {
e.printStackTrace(); Log.e(TAG, "An error occured while setting up the local repo", e);
} }
return null; return null;
} }