diff --git a/F-Droid/src/org/fdroid/fdroid/AppDetails.java b/F-Droid/src/org/fdroid/fdroid/AppDetails.java index 1e8f12b0c..04df20534 100644 --- a/F-Droid/src/org/fdroid/fdroid/AppDetails.java +++ b/F-Droid/src/org/fdroid/fdroid/AppDetails.java @@ -390,10 +390,10 @@ public class AppDetails extends AppCompatActivity implements ProgressListener, A // Get the preferences we're going to use in this Activity... ConfigurationChangeHelper previousData = (ConfigurationChangeHelper)getLastCustomNonConfigurationInstance(); if (previousData != null) { - Log.d(TAG, "Recreating view after configuration change."); + Utils.DebugLog(TAG, "Recreating view after configuration change."); downloadHandler = previousData.downloader; if (downloadHandler != null) { - Log.d(TAG, "Download was in progress before the configuration change, so we will start to listen to its events again."); + Utils.DebugLog(TAG, "Download was in progress before the configuration change, so we will start to listen to its events again."); } app = previousData.app; setApp(app); @@ -499,7 +499,7 @@ public class AppDetails extends AppCompatActivity implements ProgressListener, A super.onPause(); if (app != null && (app.ignoreAllUpdates != startingIgnoreAll || app.ignoreThisUpdate != startingIgnoreThis)) { - Log.d(TAG, "Updating 'ignore updates', as it has changed since we started the activity..."); + Utils.DebugLog(TAG, "Updating 'ignore updates', as it has changed since we started the activity..."); setIgnoreUpdates(app.id, app.ignoreAllUpdates, app.ignoreThisUpdate); } @@ -567,7 +567,7 @@ public class AppDetails extends AppCompatActivity implements ProgressListener, A // Return true if the app was found, false otherwise. private boolean reset(String appId) { - Log.d(TAG, "Getting application details for " + appId); + Utils.DebugLog(TAG, "Getting application details for " + appId); App newApp = null; if (!TextUtils.isEmpty(appId)) { @@ -968,7 +968,7 @@ public class AppDetails extends AppCompatActivity implements ProgressListener, A // the download thread to make sure that we check for cancellations before // sending events, but it is not possible to be perfect, because the interruption // which triggers the download can happen after the check to see if - Log.d(TAG, "Discarding downloader event \"" + event.type + "\" as it is from an old (probably cancelled) downloader."); + Utils.DebugLog(TAG, "Discarding downloader event \"" + event.type + "\" as it is from an old (probably cancelled) downloader."); return; } diff --git a/F-Droid/src/org/fdroid/fdroid/FDroid.java b/F-Droid/src/org/fdroid/fdroid/FDroid.java index 60eae6fc3..9a90e023f 100644 --- a/F-Droid/src/org/fdroid/fdroid/FDroid.java +++ b/F-Droid/src/org/fdroid/fdroid/FDroid.java @@ -184,11 +184,11 @@ public class FDroid extends ActionBarActivity { Intent call = null; if (!TextUtils.isEmpty(appId)) { - Log.d(TAG, "FDroid launched via app link for '" + appId + "'"); + Utils.DebugLog(TAG, "FDroid launched via app link for '" + appId + "'"); call = new Intent(this, AppDetails.class); call.putExtra(AppDetails.EXTRA_APPID, appId); } else if (!TextUtils.isEmpty(query)) { - Log.d(TAG, "FDroid launched via search link for '" + query + "'"); + Utils.DebugLog(TAG, "FDroid launched via search link for '" + query + "'"); call = new Intent(this, SearchResults.class); call.setAction(Intent.ACTION_SEARCH); call.putExtra(SearchManager.QUERY, query); diff --git a/F-Droid/src/org/fdroid/fdroid/RepoUpdater.java b/F-Droid/src/org/fdroid/fdroid/RepoUpdater.java index 936d2e963..a9d7d7370 100644 --- a/F-Droid/src/org/fdroid/fdroid/RepoUpdater.java +++ b/F-Droid/src/org/fdroid/fdroid/RepoUpdater.java @@ -92,7 +92,7 @@ public class RepoUpdater { if (downloader.isCached()) { // The index is unchanged since we last read it. We just mark // everything that came from this repo as being updated. - Log.d(TAG, "Repo index for " + getIndexAddress() + " is up to date (by etag)"); + Utils.DebugLog(TAG, "Repo index for " + getIndexAddress() + " is up to date (by etag)"); } } catch (IOException e) { @@ -190,13 +190,13 @@ public class RepoUpdater { } if (handler.getVersion() != -1 && handler.getVersion() != repo.version) { - Log.d(TAG, "Repo specified a new version: from " + Utils.DebugLog(TAG, "Repo specified a new version: from " + repo.version + " to " + handler.getVersion()); values.put(RepoProvider.DataColumns.VERSION, handler.getVersion()); } if (handler.getMaxAge() != -1 && handler.getMaxAge() != repo.maxage) { - Log.d(TAG, "Repo specified a new maximum age - updated"); + Utils.DebugLog(TAG, "Repo specified a new maximum age - updated"); values.put(RepoProvider.DataColumns.MAX_AGE, handler.getMaxAge()); } @@ -293,7 +293,7 @@ public class RepoUpdater { } if (trustNewSigningCertificate) { - Log.d(TAG, "Saving new signing certificate in the database for " + repo.address); + Utils.DebugLog(TAG, "Saving new signing certificate in the database for " + repo.address); ContentValues values = new ContentValues(2); values.put(RepoProvider.DataColumns.LAST_UPDATED, Utils.formatDate(new Date(), "")); values.put(RepoProvider.DataColumns.PUBLIC_KEY, Hasher.hex(rawCertFromJar)); diff --git a/F-Droid/src/org/fdroid/fdroid/UpdateService.java b/F-Droid/src/org/fdroid/fdroid/UpdateService.java index fad0c94a5..34a7ea982 100644 --- a/F-Droid/src/org/fdroid/fdroid/UpdateService.java +++ b/F-Droid/src/org/fdroid/fdroid/UpdateService.java @@ -136,9 +136,9 @@ public class UpdateService extends IntentService implements ProgressListener { alarm.setInexactRepeating(AlarmManager.ELAPSED_REALTIME, SystemClock.elapsedRealtime() + 5000, AlarmManager.INTERVAL_HOUR, pending); - Log.d(TAG, "Update scheduler alarm set"); + Utils.DebugLog(TAG, "Update scheduler alarm set"); } else { - Log.d(TAG, "Update scheduler alarm not set"); + Utils.DebugLog(TAG, "Update scheduler alarm not set"); } } @@ -323,7 +323,7 @@ public class UpdateService extends IntentService implements ProgressListener { // See if it's time to actually do anything yet... if (manualUpdate) { - Log.d(TAG, "Unscheduled (manually requested) update"); + Utils.DebugLog(TAG, "Unscheduled (manually requested) update"); } else if (!verifyIsTimeForScheduledRun()) { return; } @@ -382,7 +382,7 @@ public class UpdateService extends IntentService implements ProgressListener { } if (!changes) { - Log.d(TAG, "Not checking app details or compatibility, because all repos were up to date."); + Utils.DebugLog(TAG, "Not checking app details or compatibility, because all repos were up to date."); } else { sendStatus(STATUS_INFO, getString(R.string.status_checking_compatibility)); @@ -517,7 +517,7 @@ public class UpdateService extends IntentService implements ProgressListener { } private void showAppUpdatesNotification(Cursor hasUpdates) { - Log.d(TAG, "Notifying " + hasUpdates.getCount() + " updates."); + Utils.DebugLog(TAG, "Notifying " + hasUpdates.getCount() + " updates."); final int icon = Build.VERSION.SDK_INT >= 11 ? R.drawable.ic_stat_notify_updates : R.drawable.ic_launcher; @@ -593,7 +593,7 @@ public class UpdateService extends IntentService implements ProgressListener { } } - Log.d(TAG, "Updating/inserting " + operations.size() + " apps."); + Utils.DebugLog(TAG, "Updating/inserting " + operations.size() + " apps."); try { executeBatchWithStatus(AppProvider.getAuthority(), operations, currentCount, totalUpdateCount); } catch (RemoteException | OperationApplicationException e) { @@ -652,7 +652,7 @@ public class UpdateService extends IntentService implements ProgressListener { } } - Log.d(TAG, "Updating/inserting " + operations.size() + " apks."); + Utils.DebugLog(TAG, "Updating/inserting " + operations.size() + " apks."); try { executeBatchWithStatus(ApkProvider.getAuthority(), operations, currentCount, totalApksAppsCount); } catch (RemoteException | OperationApplicationException e) { @@ -716,7 +716,7 @@ public class UpdateService extends IntentService implements ProgressListener { } long duration = System.currentTimeMillis() - startTime; - Log.d(TAG, "Found " + toRemove.size() + " apks no longer in the updated repos (took " + duration + "ms)"); + Utils.DebugLog(TAG, "Found " + toRemove.size() + " apks no longer in the updated repos (took " + duration + "ms)"); if (toRemove.size() > 0) { ApkProvider.Helper.deleteApks(this, toRemove); @@ -736,13 +736,13 @@ public class UpdateService extends IntentService implements ProgressListener { for (final Repo repo : repos) { Uri uri = ApkProvider.getRepoUri(repo.getId()); int numDeleted = getContentResolver().delete(uri, null, null); - Log.d(TAG, "Removing " + numDeleted + " apks from repo " + repo.address); + Utils.DebugLog(TAG, "Removing " + numDeleted + " apks from repo " + repo.address); } } private void removeAppsWithoutApks() { int numDeleted = getContentResolver().delete(AppProvider.getNoApksUri(), null, null); - Log.d(TAG, "Removing " + numDeleted + " apks that don't have any apks"); + Utils.DebugLog(TAG, "Removing " + numDeleted + " apks that don't have any apks"); } /** diff --git a/F-Droid/src/org/fdroid/fdroid/compat/PackageManagerCompat.java b/F-Droid/src/org/fdroid/fdroid/compat/PackageManagerCompat.java index 394bc9d2a..070e68624 100644 --- a/F-Droid/src/org/fdroid/fdroid/compat/PackageManagerCompat.java +++ b/F-Droid/src/org/fdroid/fdroid/compat/PackageManagerCompat.java @@ -4,6 +4,8 @@ import android.annotation.TargetApi; import android.content.pm.PackageManager; import android.util.Log; +import org.fdroid.fdroid.Utils; + public class PackageManagerCompat extends Compatibility { private static final String TAG = "PackageManagerCompat"; @@ -13,8 +15,7 @@ public class PackageManagerCompat extends Compatibility { if (!hasApi(11)) return; try { mPm.setInstallerPackageName(packageName, "org.fdroid.fdroid"); - Log.d(TAG, "Installer package name for " + - packageName + " set successfully"); + Utils.DebugLog(TAG, "Installer package name for " + packageName + " set successfully"); } catch (Exception e) { // Many problems can occur: // * App wasn't installed due to incompatibility diff --git a/F-Droid/src/org/fdroid/fdroid/data/AppProvider.java b/F-Droid/src/org/fdroid/fdroid/data/AppProvider.java index 239856469..2742da608 100644 --- a/F-Droid/src/org/fdroid/fdroid/data/AppProvider.java +++ b/F-Droid/src/org/fdroid/fdroid/data/AppProvider.java @@ -846,7 +846,7 @@ public class AppProvider extends FDroidProvider { */ private void updateSuggestedFromUpstream() { - Log.d(TAG, "Calculating suggested versions for all apps which specify an upstream version code."); + Utils.DebugLog(TAG, "Calculating suggested versions for all apps which specify an upstream version code."); final String apk = DBHelper.TABLE_APK; final String app = DBHelper.TABLE_APP; @@ -880,7 +880,7 @@ public class AppProvider extends FDroidProvider { */ private void updateCompatibleFlags() { - Log.d(TAG, "Calculating whether apps are compatible, based on whether any of their apks are compatible"); + Utils.DebugLog(TAG, "Calculating whether apps are compatible, based on whether any of their apks are compatible"); final String apk = DBHelper.TABLE_APK; final String app = DBHelper.TABLE_APP; @@ -924,7 +924,7 @@ public class AppProvider extends FDroidProvider { */ private void updateSuggestedFromLatest() { - Log.d(TAG, "Calculating suggested versions for all apps which don't specify an upstream version code."); + Utils.DebugLog(TAG, "Calculating suggested versions for all apps which don't specify an upstream version code."); final String apk = DBHelper.TABLE_APK; final String app = DBHelper.TABLE_APP; @@ -951,10 +951,10 @@ public class AppProvider extends FDroidProvider { final String iconsDir = Utils.getIconsDir(context, 1.0); final String iconsDirLarge = Utils.getIconsDir(context, 1.5); String repoVersion = Integer.toString(Repo.VERSION_DENSITY_SPECIFIC_ICONS); - Log.d(TAG, "Updating icon paths for apps belonging to repos with version >= " + Utils.DebugLog(TAG, "Updating icon paths for apps belonging to repos with version >= " + repoVersion); - Log.d(TAG, "Using icons dir '" + iconsDir + "'"); - Log.d(TAG, "Using large icons dir '" + iconsDirLarge + "'"); + Utils.DebugLog(TAG, "Using icons dir '" + iconsDir + "'"); + Utils.DebugLog(TAG, "Using large icons dir '" + iconsDirLarge + "'"); String query = getIconUpdateQuery(); final String[] params = { repoVersion, iconsDir, Utils.FALLBACK_ICONS_DIR, diff --git a/F-Droid/src/org/fdroid/fdroid/data/DBHelper.java b/F-Droid/src/org/fdroid/fdroid/data/DBHelper.java index ea3a153b0..9b63bcddd 100644 --- a/F-Droid/src/org/fdroid/fdroid/data/DBHelper.java +++ b/F-Droid/src/org/fdroid/fdroid/data/DBHelper.java @@ -139,7 +139,7 @@ public class DBHelper extends SQLiteOpenHelper { private void renameRepoId(SQLiteDatabase db, int oldVersion) { if (oldVersion < 36 && !columnExists(db, TABLE_REPO, "_id")) { - Log.d(TAG, "Renaming " + TABLE_REPO + ".id to _id"); + Utils.DebugLog(TAG, "Renaming " + TABLE_REPO + ".id to _id"); db.beginTransaction(); try { @@ -476,7 +476,7 @@ public class DBHelper extends SQLiteOpenHelper { } private void createInstalledApp(SQLiteDatabase db) { - Log.d(TAG, "Creating 'installed app' database table."); + Utils.DebugLog(TAG, "Creating 'installed app' database table."); db.execSQL(CREATE_TABLE_INSTALLED_APP); } diff --git a/F-Droid/src/org/fdroid/fdroid/data/InstalledAppCacheUpdater.java b/F-Droid/src/org/fdroid/fdroid/data/InstalledAppCacheUpdater.java index ea68d7c6d..d8be61024 100644 --- a/F-Droid/src/org/fdroid/fdroid/data/InstalledAppCacheUpdater.java +++ b/F-Droid/src/org/fdroid/fdroid/data/InstalledAppCacheUpdater.java @@ -13,6 +13,8 @@ import java.util.ArrayList; import java.util.List; import java.util.Map; +import org.fdroid.fdroid.Utils; + /** * Compares what is in the fdroid_installedApp SQLite database table with the package * info that we can gleam from the {@link android.content.pm.PackageManager}. If there @@ -64,7 +66,7 @@ public class InstalledAppCacheUpdater { updateCache(); long duration = System.currentTimeMillis() - startTime; - Log.d(TAG, "Took " + duration + "ms to compare the installed app cache with PackageManager."); + Utils.DebugLog(TAG, "Took " + duration + "ms to compare the installed app cache with PackageManager."); return hasChanged(); } @@ -96,7 +98,7 @@ public class InstalledAppCacheUpdater { if (ops.size() > 0) { try { context.getContentResolver().applyBatch(InstalledAppProvider.getAuthority(), ops); - Log.d(TAG, "Finished executing " + ops.size() + " CRUD operations on installed app cache."); + Utils.DebugLog(TAG, "Finished executing " + ops.size() + " CRUD operations on installed app cache."); } catch (RemoteException | OperationApplicationException e) { Log.e(TAG, "Error updating installed app cache: " + e); } @@ -126,7 +128,7 @@ public class InstalledAppCacheUpdater { private List insertIntoCache(List appsToInsert) { List ops = new ArrayList<>(appsToInsert.size()); if (appsToInsert.size() > 0) { - Log.d(TAG, "Preparing to cache installed info for " + appsToInsert.size() + " new apps."); + Utils.DebugLog(TAG, "Preparing to cache installed info for " + appsToInsert.size() + " new apps."); Uri uri = InstalledAppProvider.getContentUri(); for (PackageInfo info : appsToInsert) { ContentProviderOperation op = ContentProviderOperation.newInsert(uri) @@ -145,7 +147,7 @@ public class InstalledAppCacheUpdater { private List deleteFromCache(List appIds) { List ops = new ArrayList<>(appIds.size()); if (appIds.size() > 0) { - Log.d(TAG, "Preparing to remove " + appIds.size() + " apps from the installed app cache."); + Utils.DebugLog(TAG, "Preparing to remove " + appIds.size() + " apps from the installed app cache."); for (final String appId : appIds) { Uri uri = InstalledAppProvider.getAppUri(appId); ops.add(ContentProviderOperation.newDelete(uri).build()); diff --git a/F-Droid/src/org/fdroid/fdroid/data/InstalledAppProvider.java b/F-Droid/src/org/fdroid/fdroid/data/InstalledAppProvider.java index 5f2342a8c..cad8b18f1 100644 --- a/F-Droid/src/org/fdroid/fdroid/data/InstalledAppProvider.java +++ b/F-Droid/src/org/fdroid/fdroid/data/InstalledAppProvider.java @@ -11,6 +11,7 @@ import android.net.Uri; import android.util.Log; import org.fdroid.fdroid.R; +import org.fdroid.fdroid.Utils; import java.util.HashMap; import java.util.Map; @@ -102,7 +103,7 @@ public class InstalledAppProvider extends FDroidProvider { } catch (PackageManager.NameNotFoundException e) { e.printStackTrace(); } catch (Resources.NotFoundException e) { - Log.d(TAG, "getApplicationLabel: " + e.getMessage()); + Utils.DebugLog(TAG, "getApplicationLabel: " + e.getMessage()); } return packageName; // all else fails, return id } diff --git a/F-Droid/src/org/fdroid/fdroid/data/NewRepoConfig.java b/F-Droid/src/org/fdroid/fdroid/data/NewRepoConfig.java index 5792fbf1e..e2e77bee8 100644 --- a/F-Droid/src/org/fdroid/fdroid/data/NewRepoConfig.java +++ b/F-Droid/src/org/fdroid/fdroid/data/NewRepoConfig.java @@ -7,6 +7,7 @@ import android.text.TextUtils; import android.util.Log; import org.fdroid.fdroid.R; +import org.fdroid.fdroid.Utils; import org.fdroid.fdroid.views.swap.ConnectSwapActivity; import java.util.Arrays; @@ -47,7 +48,7 @@ public class NewRepoConfig { return; } - Log.d(TAG, "Parsing incoming intent looking for repo: " + incomingUri); + Utils.DebugLog(TAG, "Parsing incoming intent looking for repo: " + incomingUri); // scheme and host should only ever be pure ASCII aka Locale.ENGLISH scheme = uri.getScheme(); diff --git a/F-Droid/src/org/fdroid/fdroid/data/RepoProvider.java b/F-Droid/src/org/fdroid/fdroid/data/RepoProvider.java index ebe645ea7..91eae6969 100644 --- a/F-Droid/src/org/fdroid/fdroid/data/RepoProvider.java +++ b/F-Droid/src/org/fdroid/fdroid/data/RepoProvider.java @@ -186,11 +186,11 @@ public class RepoProvider extends FDroidProvider { Uri apkUri = ApkProvider.getRepoUri(repo.getId()); ContentResolver resolver = context.getContentResolver(); int apkCount = resolver.delete(apkUri, null, null); - Log.d(TAG, "Removed " + apkCount + " apks from repo " + repo.name); + Utils.DebugLog(TAG, "Removed " + apkCount + " apks from repo " + repo.name); Uri appUri = AppProvider.getNoApksUri(); int appCount = resolver.delete(appUri, null, null); - Log.d(TAG, "Removed " + appCount + " apps with no apks."); + Utils.DebugLog(TAG, "Removed " + appCount + " apps with no apks."); } public static int countAppsForRepo(Context context, long repoId) { diff --git a/F-Droid/src/org/fdroid/fdroid/installer/Installer.java b/F-Droid/src/org/fdroid/fdroid/installer/Installer.java index f20c07279..f3ff93788 100644 --- a/F-Droid/src/org/fdroid/fdroid/installer/Installer.java +++ b/F-Droid/src/org/fdroid/fdroid/installer/Installer.java @@ -27,6 +27,7 @@ import android.content.pm.PackageManager; import android.util.Log; import org.fdroid.fdroid.Preferences; +import org.fdroid.fdroid.Utils; import java.io.File; import java.util.List; @@ -103,7 +104,7 @@ abstract public class Installer { boolean isSystemInstallerEnabled = Preferences.get().isSystemInstallerEnabled(); if (isSystemInstallerEnabled) { if (hasSystemPermissions(activity, pm)) { - Log.d(TAG, "system permissions -> SystemInstaller"); + Utils.DebugLog(TAG, "system permissions -> SystemInstaller"); try { return new SystemInstaller(activity, pm, callback); @@ -119,7 +120,7 @@ abstract public class Installer { if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.ICE_CREAM_SANDWICH) { // Default installer on Android >= 4.0 try { - Log.d(TAG, "try default installer for Android >= 4"); + Utils.DebugLog(TAG, "try default installer for Android >= 4"); return new DefaultInstallerSdk14(activity, pm, callback); } catch (AndroidNotCompatibleException e) { @@ -128,7 +129,7 @@ abstract public class Installer { } else { // Default installer on Android < 4.0 try { - Log.d(TAG, "try default installer for Android < 4"); + Utils.DebugLog(TAG, "try default installer for Android < 4"); return new DefaultInstaller(activity, pm, callback); } catch (AndroidNotCompatibleException e) { diff --git a/F-Droid/src/org/fdroid/fdroid/installer/SystemInstaller.java b/F-Droid/src/org/fdroid/fdroid/installer/SystemInstaller.java index fed4af1ab..46dcc5814 100644 --- a/F-Droid/src/org/fdroid/fdroid/installer/SystemInstaller.java +++ b/F-Droid/src/org/fdroid/fdroid/installer/SystemInstaller.java @@ -33,6 +33,7 @@ import android.support.v7.app.AlertDialog; import android.util.Log; import org.fdroid.fdroid.R; +import org.fdroid.fdroid.Utils; import java.io.File; import java.lang.reflect.Method; @@ -107,7 +108,7 @@ public class SystemInstaller extends Installer { public void packageInstalled(String packageName, int returnCode) throws RemoteException { // TODO: propagate other return codes? if (returnCode == INSTALL_SUCCEEDED) { - Log.d(TAG, "Install succeeded"); + Utils.DebugLog(TAG, "Install succeeded"); mCallback.onSuccess(InstallerCallback.OPERATION_INSTALL); } else { @@ -125,7 +126,7 @@ public class SystemInstaller extends Installer { public void packageDeleted(String packageName, int returnCode) throws RemoteException { // TODO: propagate other return codes? if (returnCode == DELETE_SUCCEEDED) { - Log.d(TAG, "Delete succeeded"); + Utils.DebugLog(TAG, "Delete succeeded"); mCallback.onSuccess(InstallerCallback.OPERATION_DELETE); } else { diff --git a/F-Droid/src/org/fdroid/fdroid/localrepo/LocalRepoKeyStore.java b/F-Droid/src/org/fdroid/fdroid/localrepo/LocalRepoKeyStore.java index 0ab42f434..b4c065138 100644 --- a/F-Droid/src/org/fdroid/fdroid/localrepo/LocalRepoKeyStore.java +++ b/F-Droid/src/org/fdroid/fdroid/localrepo/LocalRepoKeyStore.java @@ -4,6 +4,7 @@ import android.content.Context; import android.util.Log; import org.fdroid.fdroid.FDroidApp; +import org.fdroid.fdroid.Utils; import org.spongycastle.asn1.ASN1Sequence; import org.spongycastle.asn1.x500.X500Name; import org.spongycastle.asn1.x509.GeneralName; @@ -84,15 +85,15 @@ public class LocalRepoKeyStore { try { File appKeyStoreDir = context.getDir("keystore", Context.MODE_PRIVATE); - Log.d(TAG, "Generating LocalRepoKeyStore instance: " + appKeyStoreDir.getAbsolutePath()); + Utils.DebugLog(TAG, "Generating LocalRepoKeyStore instance: " + appKeyStoreDir.getAbsolutePath()); this.keyStoreFile = new File(appKeyStoreDir, "kerplapp.bks"); - Log.d(TAG, "Using default KeyStore type: " + KeyStore.getDefaultType()); + Utils.DebugLog(TAG, "Using default KeyStore type: " + KeyStore.getDefaultType()); this.keyStore = KeyStore.getInstance(KeyStore.getDefaultType()); if (keyStoreFile.exists()) { try { - Log.d(TAG, "Keystore already exists, loading..."); + Utils.DebugLog(TAG, "Keystore already exists, loading..."); keyStore.load(new FileInputStream(keyStoreFile), "".toCharArray()); } catch (IOException e) { Log.e(TAG, "Error while loading existing keystore. Will delete and create a new one."); @@ -109,7 +110,7 @@ public class LocalRepoKeyStore { // If there isn't a persisted BKS keystore on disk we need to // create a new empty keystore // Init a new keystore with a blank passphrase - Log.d(TAG, "Keystore doesn't exist, creating..."); + Utils.DebugLog(TAG, "Keystore doesn't exist, creating..."); keyStore.load(null, "".toCharArray()); } diff --git a/F-Droid/src/org/fdroid/fdroid/localrepo/LocalRepoService.java b/F-Droid/src/org/fdroid/fdroid/localrepo/LocalRepoService.java index 308cc951e..d1562432a 100644 --- a/F-Droid/src/org/fdroid/fdroid/localrepo/LocalRepoService.java +++ b/F-Droid/src/org/fdroid/fdroid/localrepo/LocalRepoService.java @@ -183,7 +183,7 @@ public class LocalRepoService extends Service { } private void startNetworkServices() { - Log.d(TAG, "Starting local repo network services"); + Utils.DebugLog(TAG, "Starting local repo network services"); startWebServer(); if (Preferences.get().isLocalRepoBonjourEnabled()) registerMDNSService(); @@ -191,13 +191,13 @@ public class LocalRepoService extends Service { } private void stopNetworkServices() { - Log.d(TAG, "Stopping local repo network services"); + Utils.DebugLog(TAG, "Stopping local repo network services"); Preferences.get().unregisterLocalRepoHttpsListeners(localRepoHttpsChangeListener); - Log.d(TAG, "Unregistering MDNS service..."); + Utils.DebugLog(TAG, "Unregistering MDNS service..."); unregisterMDNSService(); - Log.d(TAG, "Stopping web server..."); + Utils.DebugLog(TAG, "Stopping web server..."); stopWebServer(); } diff --git a/F-Droid/src/org/fdroid/fdroid/net/ApkDownloader.java b/F-Droid/src/org/fdroid/fdroid/net/ApkDownloader.java index 98e76f0ba..1c1ed3398 100644 --- a/F-Droid/src/org/fdroid/fdroid/net/ApkDownloader.java +++ b/F-Droid/src/org/fdroid/fdroid/net/ApkDownloader.java @@ -137,10 +137,10 @@ public class ApkDownloader implements AsyncDownloadWrapper.Listener { private boolean verifyOrDelete(@NonNull final File apkFile) { if (apkFile.exists()) { if (hashMatches(apkFile)) { - Log.d(TAG, "Using cached apk at " + apkFile); + Utils.DebugLog(TAG, "Using cached apk at " + apkFile); return true; } - Log.d(TAG, "Not using cached apk at " + apkFile + "(hash doesn't match, will delete file)"); + Utils.DebugLog(TAG, "Not using cached apk at " + apkFile + "(hash doesn't match, will delete file)"); delete(apkFile); } return false; @@ -187,7 +187,7 @@ public class ApkDownloader implements AsyncDownloadWrapper.Listener { } String remoteAddress = getRemoteAddress(); - Log.d(TAG, "Downloading apk from " + remoteAddress + " to " + localFile); + Utils.DebugLog(TAG, "Downloading apk from " + remoteAddress + " to " + localFile); try { Downloader downloader = DownloaderFactory.create(context, remoteAddress, localFile); @@ -245,7 +245,7 @@ public class ApkDownloader implements AsyncDownloadWrapper.Listener { cacheIfRequired(); - Log.d(TAG, "Download finished: " + localFile); + Utils.DebugLog(TAG, "Download finished: " + localFile); prepareApkFileAndSendCompleteMessage(); } diff --git a/F-Droid/src/org/fdroid/fdroid/net/Downloader.java b/F-Droid/src/org/fdroid/fdroid/net/Downloader.java index 4802f39f2..42f8977cd 100644 --- a/F-Droid/src/org/fdroid/fdroid/net/Downloader.java +++ b/F-Droid/src/org/fdroid/fdroid/net/Downloader.java @@ -99,7 +99,7 @@ public abstract class Downloader { public abstract boolean isCached(); protected void downloadFromStream() throws IOException, InterruptedException { - Log.d(TAG, "Downloading from stream"); + Utils.DebugLog(TAG, "Downloading from stream"); InputStream input = null; try { input = getInputStream(); @@ -133,7 +133,7 @@ public abstract class Downloader { */ private void throwExceptionIfInterrupted() throws InterruptedException { if (Thread.interrupted()) { - Log.d(TAG, "Received interrupt, cancelling download"); + Utils.DebugLog(TAG, "Received interrupt, cancelling download"); throw new InterruptedException(); } } @@ -160,7 +160,7 @@ public abstract class Downloader { throwExceptionIfInterrupted(); if (count == -1) { - Log.d(TAG, "Finished downloading from stream"); + Utils.DebugLog(TAG, "Finished downloading from stream"); break; } bytesRead += count; diff --git a/F-Droid/src/org/fdroid/fdroid/net/LocalHTTPD.java b/F-Droid/src/org/fdroid/fdroid/net/LocalHTTPD.java index bbc731278..4beb5aecb 100644 --- a/F-Droid/src/org/fdroid/fdroid/net/LocalHTTPD.java +++ b/F-Droid/src/org/fdroid/fdroid/net/LocalHTTPD.java @@ -7,6 +7,7 @@ import android.util.Log; import android.webkit.MimeTypeMap; import org.fdroid.fdroid.FDroidApp; +import org.fdroid.fdroid.Utils; import org.fdroid.fdroid.localrepo.LocalRepoKeyStore; import org.fdroid.fdroid.views.swap.ConnectSwapActivity; @@ -73,8 +74,8 @@ public class LocalHTTPD extends NanoHTTPD { } private void requestSwap(String repo) { - Log.d(TAG, "Received request to swap with " + repo); - Log.d(TAG, "Showing confirm screen to check whether that is okay with the user."); + Utils.DebugLog(TAG, "Received request to swap with " + repo); + Utils.DebugLog(TAG, "Showing confirm screen to check whether that is okay with the user."); Uri repoUri = Uri.parse(repo); Intent intent = new Intent(context, ConnectSwapActivity.class); diff --git a/F-Droid/src/org/fdroid/fdroid/receiver/PackageAddedReceiver.java b/F-Droid/src/org/fdroid/fdroid/receiver/PackageAddedReceiver.java index 0b29fb746..ac980c973 100644 --- a/F-Droid/src/org/fdroid/fdroid/receiver/PackageAddedReceiver.java +++ b/F-Droid/src/org/fdroid/fdroid/receiver/PackageAddedReceiver.java @@ -25,6 +25,7 @@ import android.content.pm.PackageInfo; import android.net.Uri; import android.util.Log; +import org.fdroid.fdroid.Utils; import org.fdroid.fdroid.data.InstalledAppProvider; public class PackageAddedReceiver extends PackageReceiver { @@ -34,7 +35,7 @@ public class PackageAddedReceiver extends PackageReceiver { @Override protected boolean toDiscard(Intent intent) { if (intent.hasExtra(Intent.EXTRA_REPLACING)) { - Log.d(TAG, "Discarding since this PACKAGE_ADDED is just a PACKAGE_REPLACED"); + Utils.DebugLog(TAG, "Discarding since this PACKAGE_ADDED is just a PACKAGE_REPLACED"); return true; } return false; @@ -44,11 +45,11 @@ public class PackageAddedReceiver extends PackageReceiver { protected void handle(Context context, String appId) { PackageInfo info = getPackageInfo(context, appId); if (info == null) { - Log.d(TAG, "Could not get package info on '" + appId + "' - skipping."); + Utils.DebugLog(TAG, "Could not get package info on '" + appId + "' - skipping."); return; } - Log.d(TAG, "Inserting installed app info for '" + appId + "' (v" + info.versionCode + ")"); + Utils.DebugLog(TAG, "Inserting installed app info for '" + appId + "' (v" + info.versionCode + ")"); Uri uri = InstalledAppProvider.getContentUri(); ContentValues values = new ContentValues(4); diff --git a/F-Droid/src/org/fdroid/fdroid/receiver/PackageReceiver.java b/F-Droid/src/org/fdroid/fdroid/receiver/PackageReceiver.java index f0b5663c5..1a7277abf 100644 --- a/F-Droid/src/org/fdroid/fdroid/receiver/PackageReceiver.java +++ b/F-Droid/src/org/fdroid/fdroid/receiver/PackageReceiver.java @@ -25,6 +25,7 @@ import android.content.Intent; import android.content.pm.PackageInfo; import android.util.Log; +import org.fdroid.fdroid.Utils; import org.fdroid.fdroid.data.ApkProvider; import org.fdroid.fdroid.data.AppProvider; @@ -46,7 +47,7 @@ abstract class PackageReceiver extends BroadcastReceiver { @Override public void onReceive(Context context, Intent intent) { - Log.d(TAG, "PackageReceiver received [action = '" + intent.getAction() + "', data = '" + intent.getData() + "']"); + Utils.DebugLog(TAG, "PackageReceiver received [action = '" + intent.getAction() + "', data = '" + intent.getData() + "']"); if (toDiscard(intent)) { return; } diff --git a/F-Droid/src/org/fdroid/fdroid/receiver/PackageRemovedReceiver.java b/F-Droid/src/org/fdroid/fdroid/receiver/PackageRemovedReceiver.java index bd63beedd..56f972d9d 100644 --- a/F-Droid/src/org/fdroid/fdroid/receiver/PackageRemovedReceiver.java +++ b/F-Droid/src/org/fdroid/fdroid/receiver/PackageRemovedReceiver.java @@ -23,6 +23,7 @@ import android.content.Intent; import android.net.Uri; import android.util.Log; +import org.fdroid.fdroid.Utils; import org.fdroid.fdroid.data.InstalledAppProvider; public class PackageRemovedReceiver extends PackageReceiver { @@ -32,7 +33,7 @@ public class PackageRemovedReceiver extends PackageReceiver { @Override protected boolean toDiscard(Intent intent) { if (intent.hasExtra(Intent.EXTRA_REPLACING)) { - Log.d(TAG, "Discarding since this PACKAGE_REMOVED is just a PACKAGE_REPLACED"); + Utils.DebugLog(TAG, "Discarding since this PACKAGE_REMOVED is just a PACKAGE_REPLACED"); return true; } return false; @@ -41,7 +42,7 @@ public class PackageRemovedReceiver extends PackageReceiver { @Override protected void handle(Context context, String appId) { - Log.d(TAG, "Removing installed app info for '" + appId + "'"); + Utils.DebugLog(TAG, "Removing installed app info for '" + appId + "'"); Uri uri = InstalledAppProvider.getAppUri(appId); context.getContentResolver().delete(uri, null, null); diff --git a/F-Droid/src/org/fdroid/fdroid/receiver/PackageUpgradedReceiver.java b/F-Droid/src/org/fdroid/fdroid/receiver/PackageUpgradedReceiver.java index 2d32ad506..53cf1b292 100644 --- a/F-Droid/src/org/fdroid/fdroid/receiver/PackageUpgradedReceiver.java +++ b/F-Droid/src/org/fdroid/fdroid/receiver/PackageUpgradedReceiver.java @@ -25,6 +25,7 @@ import android.content.pm.PackageInfo; import android.net.Uri; import android.util.Log; +import org.fdroid.fdroid.Utils; import org.fdroid.fdroid.data.InstalledAppProvider; /** @@ -46,11 +47,11 @@ public class PackageUpgradedReceiver extends PackageReceiver { protected void handle(Context context, String appId) { PackageInfo info = getPackageInfo(context, appId); if (info == null) { - Log.d(TAG, "Could not get package info on '" + appId + "' - skipping."); + Utils.DebugLog(TAG, "Could not get package info on '" + appId + "' - skipping."); return; } - Log.d(TAG, "Updating installed app info for '" + appId + "' to v" + info.versionCode + " (" + info.versionName + ")"); + Utils.DebugLog(TAG, "Updating installed app info for '" + appId + "' to v" + info.versionCode + " (" + info.versionName + ")"); Uri uri = InstalledAppProvider.getContentUri(); ContentValues values = new ContentValues(4); diff --git a/F-Droid/src/org/fdroid/fdroid/views/ManageReposActivity.java b/F-Droid/src/org/fdroid/fdroid/views/ManageReposActivity.java index 9937d968b..333a6c3d9 100644 --- a/F-Droid/src/org/fdroid/fdroid/views/ManageReposActivity.java +++ b/F-Droid/src/org/fdroid/fdroid/views/ManageReposActivity.java @@ -66,6 +66,7 @@ import org.fdroid.fdroid.FDroidApp; import org.fdroid.fdroid.Preferences; import org.fdroid.fdroid.R; import org.fdroid.fdroid.UpdateService; +import org.fdroid.fdroid.Utils; import org.fdroid.fdroid.compat.ClipboardCompat; import org.fdroid.fdroid.data.NewRepoConfig; import org.fdroid.fdroid.data.Repo; @@ -519,7 +520,7 @@ public class ManageReposActivity extends ActionBarActivity { final String[] pathsToCheck = {"", "fdroid/repo", "repo"}; for (final String path : pathsToCheck) { - Log.d(TAG, "Checking for repo at " + originalAddress + " with suffix \"" + path + "\"."); + Utils.DebugLog(TAG, "Checking for repo at " + originalAddress + " with suffix \"" + path + "\"."); Uri.Builder builder = Uri.parse(originalAddress).buildUpon().appendEncodedPath(path); final String addressWithoutIndex = builder.build().toString(); publishProgress(addressWithoutIndex); @@ -537,7 +538,7 @@ public class ManageReposActivity extends ActionBarActivity { } if (isCancelled()) { - Log.d(TAG, "Not checking any more repo addresses, because process was skipped."); + Utils.DebugLog(TAG, "Not checking any more repo addresses, because process was skipped."); break; } } @@ -638,7 +639,7 @@ public class ManageReposActivity extends ActionBarActivity { } } - Log.d(TAG, "Enabling existing repo: " + url); + Utils.DebugLog(TAG, "Enabling existing repo: " + url); Repo repo = RepoProvider.Helper.findByAddress(context, url); ContentValues values = new ContentValues(2); values.put(RepoProvider.DataColumns.IN_USE, 1); diff --git a/F-Droid/src/org/fdroid/fdroid/views/fragments/AppListFragment.java b/F-Droid/src/org/fdroid/fdroid/views/fragments/AppListFragment.java index a1080d713..1c2445fa1 100644 --- a/F-Droid/src/org/fdroid/fdroid/views/fragments/AppListFragment.java +++ b/F-Droid/src/org/fdroid/fdroid/views/fragments/AppListFragment.java @@ -20,6 +20,7 @@ import org.fdroid.fdroid.AppDetails; import org.fdroid.fdroid.Preferences; import org.fdroid.fdroid.R; import org.fdroid.fdroid.UpdateService; +import org.fdroid.fdroid.Utils; import org.fdroid.fdroid.data.App; import org.fdroid.fdroid.data.AppProvider; import org.fdroid.fdroid.views.AppListAdapter; @@ -125,12 +126,12 @@ abstract public class AppListFragment extends ThemeableListFragment implements SharedPreferences prefs = getActivity().getPreferences(Context.MODE_PRIVATE); boolean hasTriedEmptyUpdate = prefs.getBoolean(TRIED_EMPTY_UPDATE, false); if (!hasTriedEmptyUpdate) { - Log.d(TAG, "Empty app list, and we haven't done an update yet. Forcing repo update."); + Utils.DebugLog(TAG, "Empty app list, and we haven't done an update yet. Forcing repo update."); prefs.edit().putBoolean(TRIED_EMPTY_UPDATE, true).commit(); UpdateService.updateNow(getActivity()); return true; } - Log.d(TAG, "Empty app list, but it looks like we've had an update previously. Will not force repo update."); + Utils.DebugLog(TAG, "Empty app list, but it looks like we've had an update previously. Will not force repo update."); return false; } diff --git a/F-Droid/src/org/fdroid/fdroid/views/fragments/AvailableAppsFragment.java b/F-Droid/src/org/fdroid/fdroid/views/fragments/AvailableAppsFragment.java index 281c7babf..0c05ea4d3 100644 --- a/F-Droid/src/org/fdroid/fdroid/views/fragments/AvailableAppsFragment.java +++ b/F-Droid/src/org/fdroid/fdroid/views/fragments/AvailableAppsFragment.java @@ -23,6 +23,7 @@ import android.widget.Spinner; import org.fdroid.fdroid.FDroidApp; import org.fdroid.fdroid.Preferences; import org.fdroid.fdroid.R; +import org.fdroid.fdroid.Utils; import org.fdroid.fdroid.compat.ArrayAdapterCompat; import org.fdroid.fdroid.data.AppProvider; import org.fdroid.fdroid.views.AppListAdapter; @@ -156,7 +157,7 @@ public class AvailableAppsFragment extends AppListFragment implements @Override public void onItemSelected(AdapterView parent, View view, int pos, long id) { getListView().setSelection(0); - Log.d(TAG, "Selected category: " + categories.get(pos)); + Utils.DebugLog(TAG, "Selected category: " + categories.get(pos)); setCurrentCategory(categories.get(pos)); } @Override @@ -194,7 +195,7 @@ public class AvailableAppsFragment extends AppListFragment implements private void setCurrentCategory(String category) { currentCategory = category; - Log.d(TAG, "Category '" + currentCategory + "' selected."); + Utils.DebugLog(TAG, "Category '" + currentCategory + "' selected."); getLoaderManager().restartLoader(0, null, AvailableAppsFragment.this); } diff --git a/F-Droid/src/org/fdroid/fdroid/views/fragments/SearchResultsFragment.java b/F-Droid/src/org/fdroid/fdroid/views/fragments/SearchResultsFragment.java index 1d450d5a0..095b53d13 100644 --- a/F-Droid/src/org/fdroid/fdroid/views/fragments/SearchResultsFragment.java +++ b/F-Droid/src/org/fdroid/fdroid/views/fragments/SearchResultsFragment.java @@ -19,6 +19,7 @@ import android.widget.TextView; import org.fdroid.fdroid.AppDetails; import org.fdroid.fdroid.R; +import org.fdroid.fdroid.Utils; import org.fdroid.fdroid.data.App; import org.fdroid.fdroid.data.AppProvider; import org.fdroid.fdroid.views.AppListAdapter; @@ -102,7 +103,7 @@ public class SearchResultsFragment extends ListFragment implements LoaderManager headerText = getString(R.string.searchres_napps, count, query); } tv.setText(headerText); - Log.d(TAG, "Search for '" + query + "' returned " + count + " results"); + Utils.DebugLog(TAG, "Search for '" + query + "' returned " + count + " results"); } @Override diff --git a/F-Droid/src/org/fdroid/fdroid/views/swap/ConnectSwapActivity.java b/F-Droid/src/org/fdroid/fdroid/views/swap/ConnectSwapActivity.java index d54433275..4ef228c89 100644 --- a/F-Droid/src/org/fdroid/fdroid/views/swap/ConnectSwapActivity.java +++ b/F-Droid/src/org/fdroid/fdroid/views/swap/ConnectSwapActivity.java @@ -192,7 +192,8 @@ public class ConnectSwapActivity extends ActionBarActivity { HttpHost host = new HttpHost(repoUri.getHost(), repoUri.getPort(), repoUri.getScheme()); try { - Log.d(TAG, "Asking server at " + newRepoConfig.getRepoUriString() + " to swap with us in return (by POSTing to \"/request-swap\" with repo \"" + swapBackUri + "\")..."); + Utils.DebugLog(TAG, "Asking server at " + newRepoConfig.getRepoUriString() + + " to swap with us in return (by POSTing to \"/request-swap\" with repo \"" + swapBackUri + "\")..."); populatePostParams(swapBackUri, request); client.execute(host, request); } catch (IOException e) {