Logging fixes

* Make expensive Log.d calls (inside loops) only in DEBUG
* Always make TAG private to make sure it doesn't use a parent's TAG
This commit is contained in:
Daniel Martí 2015-04-10 13:58:26 +02:00
parent 8f0488aa6a
commit 3e9aca4137
9 changed files with 33 additions and 20 deletions

View File

@ -37,16 +37,21 @@ public class CompatibilityChecker extends Compatibility {
ignoreTouchscreen = prefs.getBoolean(Preferences.PREF_IGN_TOUCH, false); ignoreTouchscreen = prefs.getBoolean(Preferences.PREF_IGN_TOUCH, false);
PackageManager pm = ctx.getPackageManager(); PackageManager pm = ctx.getPackageManager();
StringBuilder logMsg = new StringBuilder();
logMsg.append("Available device features:");
features = new HashSet<>(); features = new HashSet<>();
if (pm != null) { if (pm != null) {
final FeatureInfo[] featureArray = pm.getSystemAvailableFeatures(); final FeatureInfo[] featureArray = pm.getSystemAvailableFeatures();
if (featureArray != null) if (featureArray != null) {
if (BuildConfig.DEBUG) {
StringBuilder logMsg = new StringBuilder("Available device features:");
for (FeatureInfo fi : pm.getSystemAvailableFeatures()) {
logMsg.append('\n').append(fi.name);
}
Log.d(TAG, logMsg.toString());
}
for (FeatureInfo fi : pm.getSystemAvailableFeatures()) { for (FeatureInfo fi : pm.getSystemAvailableFeatures()) {
features.add(fi.name); features.add(fi.name);
logMsg.append('\n'); }
logMsg.append(fi.name);
} }
} }
@ -62,8 +67,6 @@ public class CompatibilityChecker extends Compatibility {
builder.append(abi); builder.append(abi);
} }
cpuAbisDesc = builder.toString(); cpuAbisDesc = builder.toString();
Log.d(TAG, logMsg.toString());
} }
private boolean compatibleApi(Utils.CommaSeparatedList nativecode) { private boolean compatibleApi(Utils.CommaSeparatedList nativecode) {
@ -96,9 +99,10 @@ public class CompatibilityChecker extends Compatibility {
// Don't check it! // Don't check it!
} else if (!features.contains(feat)) { } else if (!features.contains(feat)) {
Collections.addAll(incompatibleReasons, feat.split(",")); Collections.addAll(incompatibleReasons, feat.split(","));
if (BuildConfig.DEBUG) {
Log.d(TAG, apk.id + " vercode " + apk.vercode Log.d(TAG, apk.id + " vercode " + apk.vercode
+ " is incompatible based on lack of " + " is incompatible based on lack of " + feat);
+ feat); }
} }
} }
} }
@ -106,10 +110,12 @@ public class CompatibilityChecker extends Compatibility {
for (final String code : apk.nativecode) { for (final String code : apk.nativecode) {
incompatibleReasons.add(code); incompatibleReasons.add(code);
} }
if (BuildConfig.DEBUG) {
Log.d(TAG, apk.id + " vercode " + apk.vercode Log.d(TAG, apk.id + " vercode " + apk.vercode
+ " only supports " + Utils.CommaSeparatedList.str(apk.nativecode) + " only supports " + Utils.CommaSeparatedList.str(apk.nativecode)
+ " while your architectures are " + cpuAbisDesc); + " while your architectures are " + cpuAbisDesc);
} }
}
return incompatibleReasons; return incompatibleReasons;
} }

View File

@ -167,6 +167,8 @@ public final class PRNGFixes extends Compatibility {
@SuppressWarnings("serial") @SuppressWarnings("serial")
public static class LinuxPRNGSecureRandom extends SecureRandomSpi { public static class LinuxPRNGSecureRandom extends SecureRandomSpi {
private static final String TAG = "fdroid.PRNGFixes.LinuxPRNGSecureRandom";
/* /*
* IMPLEMENTATION NOTE: Requests to generate bytes and to mix in a seed * IMPLEMENTATION NOTE: Requests to generate bytes and to mix in a seed
* are passed through to the Linux PRNG (/dev/urandom). Instances of * are passed through to the Linux PRNG (/dev/urandom). Instances of
@ -218,8 +220,7 @@ public final class PRNGFixes extends Compatibility {
} catch (IOException e) { } catch (IOException e) {
// On a small fraction of devices /dev/urandom is not writable. // On a small fraction of devices /dev/urandom is not writable.
// Log and ignore. // Log and ignore.
Log.w(PRNGFixes.class.getSimpleName(), Log.w(TAG, "Failed to mix seed into " + URANDOM_FILE);
"Failed to mix seed into " + URANDOM_FILE);
} finally { } finally {
mSeeded = true; mSeeded = true;
} }

View File

@ -30,6 +30,8 @@ import java.util.jar.JarFile;
public class App extends ValueObject implements Comparable<App> { public class App extends ValueObject implements Comparable<App> {
private static final String TAG = "fdroid.App";
// True if compatible with the device (i.e. if at least one apk is) // True if compatible with the device (i.e. if at least one apk is)
public boolean compatible; public boolean compatible;
public boolean includeInRepo = false; public boolean includeInRepo = false;
@ -228,7 +230,7 @@ public class App extends ValueObject implements Comparable<App> {
PackageManager.GET_META_DATA); PackageManager.GET_META_DATA);
installerPackageLabel = installerAppInfo.loadLabel(pm); installerPackageLabel = installerAppInfo.loadLabel(pm);
} catch (PackageManager.NameNotFoundException e) { } catch (PackageManager.NameNotFoundException e) {
Log.d(getClass().getCanonicalName(), e.getMessage()); Log.d(TAG, e.getMessage());
} }
} }
if (TextUtils.isEmpty(installerPackageLabel)) if (TextUtils.isEmpty(installerPackageLabel))

View File

@ -23,7 +23,7 @@ public class RepoProvider extends FDroidProvider {
public static final class Helper { public static final class Helper {
public static final String TAG = "fdroid.RepoProvider.Helper"; private static final String TAG = "fdroid.RepoProvider.Helper";
private Helper() {} private Helper() {}

View File

@ -40,7 +40,7 @@ abstract public class Installer {
protected final PackageManager mPm; protected final PackageManager mPm;
protected final InstallerCallback mCallback; protected final InstallerCallback mCallback;
public static final String TAG = "fdroid.Installer"; private static final String TAG = "fdroid.Installer";
/** /**
* This is thrown when an Installer is not compatible with the Android OS it * This is thrown when an Installer is not compatible with the Android OS it

View File

@ -37,6 +37,8 @@ import eu.chainfire.libsuperuser.Shell;
*/ */
public class RootInstaller extends Installer { public class RootInstaller extends Installer {
private static final String TAG = "fdroid.RootInstaller";
Shell.Interactive rootSession; Shell.Interactive rootSession;
public RootInstaller(Context context, PackageManager pm, InstallerCallback callback) public RootInstaller(Context context, PackageManager pm, InstallerCallback callback)

View File

@ -58,6 +58,8 @@ import java.util.List;
*/ */
public class SystemInstaller extends Installer { public class SystemInstaller extends Installer {
private static final String TAG = "fdroid.SystemInstaller";
private PackageInstallObserver mInstallObserver; private PackageInstallObserver mInstallObserver;
private PackageDeleteObserver mDeleteObserver; private PackageDeleteObserver mDeleteObserver;
private Method mInstallMethod; private Method mInstallMethod;

View File

@ -28,7 +28,7 @@ import javax.jmdns.ServiceListener;
public class MDnsHelper implements ServiceListener { public class MDnsHelper implements ServiceListener {
public static final String TAG = "fdroid.MDnsHelper"; private static final String TAG = "fdroid.MDnsHelper";
public static final String HTTP_SERVICE_TYPE = "_http._tcp.local."; public static final String HTTP_SERVICE_TYPE = "_http._tcp.local.";
public static final String HTTPS_SERVICE_TYPE = "_https._tcp.local."; public static final String HTTPS_SERVICE_TYPE = "_https._tcp.local.";

View File

@ -23,7 +23,7 @@ import org.fdroid.fdroid.data.RepoProvider;
import org.fdroid.fdroid.views.fragments.RepoDetailsFragment; import org.fdroid.fdroid.views.fragments.RepoDetailsFragment;
public class RepoDetailsActivity extends ActionBarActivity { public class RepoDetailsActivity extends ActionBarActivity {
public static final String TAG = "fdroid.RepoDetailsActivity"; private static final String TAG = "fdroid.RepoDetailsActivity";
private Repo repo; private Repo repo;