diff --git a/F-Droid/src/org/fdroid/fdroid/QrGenAsyncTask.java b/F-Droid/src/org/fdroid/fdroid/QrGenAsyncTask.java index 4c5a9f544..9c527c7ec 100644 --- a/F-Droid/src/org/fdroid/fdroid/QrGenAsyncTask.java +++ b/F-Droid/src/org/fdroid/fdroid/QrGenAsyncTask.java @@ -52,7 +52,7 @@ public class QrGenAsyncTask extends AsyncTask { qrCodeDimension = x; else qrCodeDimension = y; - Log.i(TAG, "generating QRCode Bitmap of " + qrCodeDimension + "x" + qrCodeDimension); + Utils.DebugLog(TAG, "generating QRCode Bitmap of " + qrCodeDimension + "x" + qrCodeDimension); QRCodeEncoder qrCodeEncoder = new QRCodeEncoder(qrData, null, Contents.Type.TEXT, BarcodeFormat.QR_CODE.toString(), qrCodeDimension); diff --git a/F-Droid/src/org/fdroid/fdroid/Utils.java b/F-Droid/src/org/fdroid/fdroid/Utils.java index 1444a602f..3f82d866e 100644 --- a/F-Droid/src/org/fdroid/fdroid/Utils.java +++ b/F-Droid/src/org/fdroid/fdroid/Utils.java @@ -616,18 +616,18 @@ public final class Utils { } if (startsWith != null) { - Log.i(TAG, "Cleaning up files in " + directory + " that start with \"" + startsWith + "\""); + DebugLog(TAG, "Cleaning up files in " + directory + " that start with \"" + startsWith + "\""); } if (endsWith != null) { - Log.i(TAG, "Cleaning up files in " + directory + " that end with \"" + endsWith + "\""); + DebugLog(TAG, "Cleaning up files in " + directory + " that end with \"" + endsWith + "\""); } for (File f : files) { if ((startsWith != null && f.getName().startsWith(startsWith)) || (endsWith != null && f.getName().endsWith(endsWith))) { if (!f.delete()) { - Log.i(TAG, "Couldn't delete cache file " + f); + Log.w(TAG, "Couldn't delete cache file " + f); } } } diff --git a/F-Droid/src/org/fdroid/fdroid/data/ApkProvider.java b/F-Droid/src/org/fdroid/fdroid/data/ApkProvider.java index 92b002bf0..1aea8f58d 100644 --- a/F-Droid/src/org/fdroid/fdroid/data/ApkProvider.java +++ b/F-Droid/src/org/fdroid/fdroid/data/ApkProvider.java @@ -14,6 +14,8 @@ import java.util.HashMap; import java.util.List; import java.util.Map; +import org.fdroid.fdroid.Utils; + public class ApkProvider extends FDroidProvider { private static final String TAG = "ApkProvider"; @@ -427,7 +429,7 @@ public class ApkProvider extends FDroidProvider { for (Map.Entry repoField : REPO_FIELDS.entrySet()) { final String field = repoField.getKey(); if (values.containsKey(field)) { - Log.i(TAG, "Cannot insert/update '" + field + "' field " + + Utils.DebugLog(TAG, "Cannot insert/update '" + field + "' field " + "on apk table, as it belongs to the repo table. " + "This field will be ignored."); values.remove(field); diff --git a/F-Droid/src/org/fdroid/fdroid/data/DBHelper.java b/F-Droid/src/org/fdroid/fdroid/data/DBHelper.java index 9b63bcddd..efcb28352 100644 --- a/F-Droid/src/org/fdroid/fdroid/data/DBHelper.java +++ b/F-Droid/src/org/fdroid/fdroid/data/DBHelper.java @@ -112,7 +112,7 @@ public class DBHelper extends SQLiteOpenHelper { private void populateRepoNames(SQLiteDatabase db, int oldVersion) { if (oldVersion < 37) { - Log.i(TAG, "Populating repo names from the url"); + Utils.DebugLog(TAG, "Populating repo names from the url"); final String[] columns = { "address", "_id" }; Cursor cursor = db.query(TABLE_REPO, columns, "name IS NULL OR name = ''", null, null, null, null); @@ -126,7 +126,7 @@ public class DBHelper extends SQLiteOpenHelper { String name = Repo.addressToName(address); values.put("name", name); final String[] args = { Long.toString(id) }; - Log.i(TAG, "Setting repo name to '" + name + "' for repo " + address); + Utils.DebugLog(TAG, "Setting repo name to '" + name + "' for repo " + address); db.update(TABLE_REPO, values, "_id = ?", args); cursor.moveToNext(); } @@ -255,15 +255,14 @@ public class DBHelper extends SQLiteOpenHelper { values.put(RepoProvider.DataColumns.PRIORITY, priority); values.put(RepoProvider.DataColumns.LAST_ETAG, (String) null); - Log.i(TAG, "Adding repository " + name); + Utils.DebugLog(TAG, "Adding repository " + name); db.insert(TABLE_REPO, null, values); } @Override public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) { - Log.i(TAG, "Upgrading database from v" + oldVersion + " v" - + newVersion); + Utils.DebugLog(TAG, "Upgrading database from v" + oldVersion + " v" + newVersion); migrateRepoTable(db, oldVersion); @@ -407,35 +406,35 @@ public class DBHelper extends SQLiteOpenHelper { private void addLastUpdatedToRepo(SQLiteDatabase db, int oldVersion) { if (oldVersion < 35 && !columnExists(db, TABLE_REPO, "lastUpdated")) { - Log.i(TAG, "Adding lastUpdated column to " + TABLE_REPO); + Utils.DebugLog(TAG, "Adding lastUpdated column to " + TABLE_REPO); db.execSQL("Alter table " + TABLE_REPO + " add column lastUpdated string"); } } private void addIsSwapToRepo(SQLiteDatabase db, int oldVersion) { if (oldVersion < 47 && !columnExists(db, TABLE_REPO, "isSwap")) { - Log.i(TAG, "Adding isSwap field to " + TABLE_REPO + " table in db."); + Utils.DebugLog(TAG, "Adding isSwap field to " + TABLE_REPO + " table in db."); db.execSQL("alter table " + TABLE_REPO + " add column isSwap boolean default 0;"); } } private void addChangelogToApp(SQLiteDatabase db, int oldVersion) { if (oldVersion < 48 && !columnExists(db, TABLE_APP, "changelogURL")) { - Log.i(TAG, "Adding changelogURL column to " + TABLE_APP); + Utils.DebugLog(TAG, "Adding changelogURL column to " + TABLE_APP); db.execSQL("alter table " + TABLE_APP + " add column changelogURL text"); } } private void addIconUrlLargeToApp(SQLiteDatabase db, int oldVersion) { if (oldVersion < 49 && !columnExists(db, TABLE_APP, "iconUrlLarge")) { - Log.i(TAG, "Adding iconUrlLarge columns to " + TABLE_APP); + Utils.DebugLog(TAG, "Adding iconUrlLarge columns to " + TABLE_APP); db.execSQL("alter table " + TABLE_APP + " add column iconUrlLarge text"); } } private void updateIconUrlLarge(SQLiteDatabase db, int oldVersion) { if (oldVersion < 50) { - Log.i(TAG, "Recalculating app icon URLs so that the newly added large icons will get updated."); + Utils.DebugLog(TAG, "Recalculating app icon URLs so that the newly added large icons will get updated."); AppProvider.UpgradeHelper.updateIconUrls(context, db); clearRepoEtags(db); } @@ -447,7 +446,7 @@ public class DBHelper extends SQLiteOpenHelper { * they have changed since last update or not. */ private void clearRepoEtags(SQLiteDatabase db) { - Log.i(TAG, "Clearing repo etags, so next update will not be skipped with \"Repos up to date\"."); + Utils.DebugLog(TAG, "Clearing repo etags, so next update will not be skipped with \"Repos up to date\"."); db.execSQL("update " + TABLE_REPO + " set lastetag = NULL"); } @@ -482,7 +481,7 @@ public class DBHelper extends SQLiteOpenHelper { private void addAppLabelToInstalledCache(SQLiteDatabase db, int oldVersion) { if (oldVersion < 45) { - Log.i(TAG, "Adding applicationLabel to installed app table. " + + Utils.DebugLog(TAG, "Adding applicationLabel to installed app table. " + "Turns out we will need to repopulate the cache after doing this, " + "so just dropping and recreating the table (instead of altering and adding a column). " + "This will force the entire cache to be rebuilt, including app names."); diff --git a/F-Droid/src/org/fdroid/fdroid/data/InstalledAppCacheUpdater.java b/F-Droid/src/org/fdroid/fdroid/data/InstalledAppCacheUpdater.java index d8be61024..f2ca125de 100644 --- a/F-Droid/src/org/fdroid/fdroid/data/InstalledAppCacheUpdater.java +++ b/F-Droid/src/org/fdroid/fdroid/data/InstalledAppCacheUpdater.java @@ -72,7 +72,7 @@ public class InstalledAppCacheUpdater { } protected void notifyProviders() { - Log.i(TAG, "Installed app cache has changed, notifying content providers (so they can update the relevant views)."); + Utils.DebugLog(TAG, "Installed app cache has changed, notifying content providers (so they can update the relevant views)."); context.getContentResolver().notifyChange(AppProvider.getContentUri(), null); context.getContentResolver().notifyChange(ApkProvider.getContentUri(), null); } diff --git a/F-Droid/src/org/fdroid/fdroid/data/RepoProvider.java b/F-Droid/src/org/fdroid/fdroid/data/RepoProvider.java index 91eae6969..cfc5a333b 100644 --- a/F-Droid/src/org/fdroid/fdroid/data/RepoProvider.java +++ b/F-Droid/src/org/fdroid/fdroid/data/RepoProvider.java @@ -337,7 +337,7 @@ public class RepoProvider extends FDroidProvider { } long id = write().insertOrThrow(getTableName(), null, values); - Log.i(TAG, "Inserted repo. Notifying provider change: '" + uri + "'."); + Utils.DebugLog(TAG, "Inserted repo. Notifying provider change: '" + uri + "'."); getContext().getContentResolver().notifyChange(uri, null); return getContentUri(id); } @@ -361,7 +361,7 @@ public class RepoProvider extends FDroidProvider { } int rowsAffected = write().delete(getTableName(), where, whereArgs); - Log.i(TAG, "Deleted repos. Notifying provider change: '" + uri + "'."); + Utils.DebugLog(TAG, "Deleted repos. Notifying provider change: '" + uri + "'."); getContext().getContentResolver().notifyChange(uri, null); return rowsAffected; } @@ -369,7 +369,7 @@ public class RepoProvider extends FDroidProvider { @Override public int update(Uri uri, ContentValues values, String where, String[] whereArgs) { int numRows = write().update(getTableName(), values, where, whereArgs); - Log.i(TAG, "Updated repo. Notifying provider change: '" + uri + "'."); + Utils.DebugLog(TAG, "Updated repo. Notifying provider change: '" + uri + "'."); getContext().getContentResolver().notifyChange(uri, null); return numRows; } diff --git a/F-Droid/src/org/fdroid/fdroid/installer/AppSecurityPermissions.java b/F-Droid/src/org/fdroid/fdroid/installer/AppSecurityPermissions.java index b22eced76..e65ef76cf 100644 --- a/F-Droid/src/org/fdroid/fdroid/installer/AppSecurityPermissions.java +++ b/F-Droid/src/org/fdroid/fdroid/installer/AppSecurityPermissions.java @@ -345,7 +345,7 @@ public class AppSecurityPermissions { myPerm.mNew = newPerm; permSet.add(myPerm); } catch (NameNotFoundException e) { - Log.i(TAG, "Ignoring unknown permission:"+permName); + Log.i(TAG, "Ignoring unknown permission:" + permName); } } } diff --git a/F-Droid/src/org/fdroid/fdroid/localrepo/LocalRepoManager.java b/F-Droid/src/org/fdroid/fdroid/localrepo/LocalRepoManager.java index 3624aef9e..220fa6cf6 100644 --- a/F-Droid/src/org/fdroid/fdroid/localrepo/LocalRepoManager.java +++ b/F-Droid/src/org/fdroid/fdroid/localrepo/LocalRepoManager.java @@ -260,7 +260,7 @@ public class LocalRepoManager { Log.e(TAG, Log.getStackTraceString(e)); return; } - Log.i(TAG, "apps.put: " + packageName); + Utils.DebugLog(TAG, "apps.put: " + packageName); apps.put(packageName, app); } diff --git a/F-Droid/src/org/fdroid/fdroid/localrepo/LocalRepoService.java b/F-Droid/src/org/fdroid/fdroid/localrepo/LocalRepoService.java index d1562432a..880eb2582 100644 --- a/F-Droid/src/org/fdroid/fdroid/localrepo/LocalRepoService.java +++ b/F-Droid/src/org/fdroid/fdroid/localrepo/LocalRepoService.java @@ -118,7 +118,7 @@ public class LocalRepoService extends Service { private final ChangeListener localRepoHttpsChangeListener = new ChangeListener() { @Override public void onPreferenceChange() { - Log.i(TAG, "onPreferenceChange"); + Utils.DebugLog(TAG, "onPreferenceChange"); if (localHttpd.isAlive()) { new AsyncTask() { @Override @@ -216,7 +216,7 @@ public class LocalRepoService extends Service { webServerThreadHandler = new Handler() { @Override public void handleMessage(Message msg) { - Log.i(TAG, "we've been asked to stop the webserver: " + msg.obj); + Utils.DebugLog(TAG, "we've been asked to stop the webserver: " + msg.obj); localHttpd.stop(); } }; @@ -242,7 +242,7 @@ public class LocalRepoService extends Service { private void stopWebServer() { if (webServerThreadHandler == null) { - Log.i(TAG, "null handler in stopWebServer"); + Utils.DebugLog(TAG, "null handler in stopWebServer"); return; } Message msg = webServerThreadHandler.obtainMessage(); diff --git a/F-Droid/src/org/fdroid/fdroid/net/ApkDownloader.java b/F-Droid/src/org/fdroid/fdroid/net/ApkDownloader.java index 1c1ed3398..6c8b5a9ba 100644 --- a/F-Droid/src/org/fdroid/fdroid/net/ApkDownloader.java +++ b/F-Droid/src/org/fdroid/fdroid/net/ApkDownloader.java @@ -230,7 +230,7 @@ public class ApkDownloader implements AsyncDownloadWrapper.Listener { private void cacheIfRequired() { if (Preferences.get().shouldCacheApks()) { - Log.i(TAG, "Copying .apk file to cache at " + potentiallyCachedFile.getAbsolutePath()); + Utils.DebugLog(TAG, "Copying .apk file to cache at " + potentiallyCachedFile.getAbsolutePath()); Utils.copy(localFile, potentiallyCachedFile); } } diff --git a/F-Droid/src/org/fdroid/fdroid/net/HttpDownloader.java b/F-Droid/src/org/fdroid/fdroid/net/HttpDownloader.java index 2e88779af..c70fdfe8c 100644 --- a/F-Droid/src/org/fdroid/fdroid/net/HttpDownloader.java +++ b/F-Droid/src/org/fdroid/fdroid/net/HttpDownloader.java @@ -4,6 +4,7 @@ import android.content.Context; import android.util.Log; import org.fdroid.fdroid.Preferences; +import org.fdroid.fdroid.Utils; import java.io.File; import java.io.FileNotFoundException; @@ -78,14 +79,14 @@ public class HttpDownloader extends Downloader { protected void doDownload() throws IOException, InterruptedException { if (wantToCheckCache()) { setupCacheCheck(); - Log.i(TAG, "Checking cached status of " + sourceUrl); + Utils.DebugLog(TAG, "Checking cached status of " + sourceUrl); statusCode = connection.getResponseCode(); } if (isCached()) { - Log.i(TAG, sourceUrl + " is cached, so not downloading (HTTP " + statusCode + ")"); + Utils.DebugLog(TAG, sourceUrl + " is cached, so not downloading (HTTP " + statusCode + ")"); } else { - Log.i(TAG, "Downloading from " + sourceUrl); + Utils.DebugLog(TAG, "Downloading from " + sourceUrl); downloadFromStream(); updateCacheCheck(); } diff --git a/F-Droid/src/org/fdroid/fdroid/net/LocalHTTPD.java b/F-Droid/src/org/fdroid/fdroid/net/LocalHTTPD.java index 4beb5aecb..643bf93a1 100644 --- a/F-Droid/src/org/fdroid/fdroid/net/LocalHTTPD.java +++ b/F-Droid/src/org/fdroid/fdroid/net/LocalHTTPD.java @@ -6,6 +6,7 @@ import android.net.Uri; import android.util.Log; import android.webkit.MimeTypeMap; +import org.fdroid.fdroid.BuildConfig; import org.fdroid.fdroid.FDroidApp; import org.fdroid.fdroid.Utils; import org.fdroid.fdroid.localrepo.LocalRepoKeyStore; @@ -35,11 +36,9 @@ public class LocalHTTPD extends NanoHTTPD { private final Context context; private final File webRoot; - private final boolean logRequests; public LocalHTTPD(Context context, File webRoot, boolean useHttps) { super(FDroidApp.ipAddressString, FDroidApp.port); - this.logRequests = false; this.webRoot = webRoot; this.context = context.getApplicationContext(); if (useHttps) @@ -123,18 +122,18 @@ public class LocalHTTPD extends NanoHTTPD { Map parms = session.getParms(); String uri = session.getUri(); - if (logRequests) { - Log.i(TAG, session.getMethod() + " '" + uri + "' "); + if (BuildConfig.DEBUG) { + Utils.DebugLog(TAG, session.getMethod() + " '" + uri + "' "); Iterator e = header.keySet().iterator(); while (e.hasNext()) { String value = e.next(); - Log.i(TAG, " HDR: '" + value + "' = '" + header.get(value) + "'"); + Utils.DebugLog(TAG, " HDR: '" + value + "' = '" + header.get(value) + "'"); } e = parms.keySet().iterator(); while (e.hasNext()) { String value = e.next(); - Log.i(TAG, " PRM: '" + value + "' = '" + parms.get(value) + "'"); + Utils.DebugLog(TAG, " PRM: '" + value + "' = '" + parms.get(value) + "'"); } } diff --git a/F-Droid/src/org/fdroid/fdroid/net/WifiStateChangeService.java b/F-Droid/src/org/fdroid/fdroid/net/WifiStateChangeService.java index b7d18845d..401719d93 100644 --- a/F-Droid/src/org/fdroid/fdroid/net/WifiStateChangeService.java +++ b/F-Droid/src/org/fdroid/fdroid/net/WifiStateChangeService.java @@ -44,7 +44,7 @@ public class WifiStateChangeService extends Service { if (ni == null || ni.isConnected()) { /* started on app start or from WifiStateChangeReceiver, NetworkInfo is only passed via WifiStateChangeReceiver */ - Log.i(TAG, "ni == " + ni + " wifiState == " + printWifiState(wifiState)); + Utils.DebugLog(TAG, "ni == " + ni + " wifiState == " + printWifiState(wifiState)); if (wifiState == WifiManager.WIFI_STATE_ENABLED || wifiState == WifiManager.WIFI_STATE_DISABLING // might be switching to hotspot || wifiState == WifiManager.WIFI_STATE_DISABLED // might be hotspot diff --git a/F-Droid/src/org/fdroid/fdroid/views/ManageReposActivity.java b/F-Droid/src/org/fdroid/fdroid/views/ManageReposActivity.java index 333a6c3d9..3f287321a 100644 --- a/F-Droid/src/org/fdroid/fdroid/views/ManageReposActivity.java +++ b/F-Droid/src/org/fdroid/fdroid/views/ManageReposActivity.java @@ -343,13 +343,13 @@ public class ManageReposActivity extends ActionBarActivity { return; } - switch(addRepoState) { + switch (addRepoState) { case DOESNT_EXIST: prepareToCreateNewRepo(url, fp); break; case IS_SWAP: - Log.i(TAG, "Removing existing swap repo " + url + " before adding new repo."); + Utils.DebugLog(TAG, "Removing existing swap repo " + url + " before adding new repo."); Repo repo = RepoProvider.Helper.findByAddress(context, url); RepoProvider.Helper.remove(context, repo.getId()); prepareToCreateNewRepo(url, fp); @@ -529,7 +529,7 @@ public class ManageReposActivity extends ActionBarActivity { try { if (checkForRepository(uri)) { - Log.i(TAG, "Found F-Droid repo at " + addressWithoutIndex); + Utils.DebugLog(TAG, "Found F-Droid repo at " + addressWithoutIndex); return addressWithoutIndex; } } catch (IOException e) { @@ -704,7 +704,7 @@ public class ManageReposActivity extends ActionBarActivity { @Override public Loader onCreateLoader(int i, Bundle bundle) { Uri uri = RepoProvider.allExceptSwapUri(); - Log.i(TAG, "Creating repo loader '" + uri + "'."); + Utils.DebugLog(TAG, "Creating repo loader '" + uri + "'."); final String[] projection = { RepoProvider.DataColumns._ID, RepoProvider.DataColumns.NAME, diff --git a/F-Droid/src/org/fdroid/fdroid/views/RepoDetailsActivity.java b/F-Droid/src/org/fdroid/fdroid/views/RepoDetailsActivity.java index 2261b65b7..adecda201 100644 --- a/F-Droid/src/org/fdroid/fdroid/views/RepoDetailsActivity.java +++ b/F-Droid/src/org/fdroid/fdroid/views/RepoDetailsActivity.java @@ -172,7 +172,7 @@ public class RepoDetailsActivity extends ActionBarActivity { i.getParcelableArrayExtra(NfcAdapter.EXTRA_NDEF_MESSAGES); NdefMessage msg = (NdefMessage) rawMsgs[0]; String url = new String(msg.getRecords()[0].getPayload()); - Log.i(TAG, "Got this URL: " + url); + Utils.DebugLog(TAG, "Got this URL: " + url); Toast.makeText(this, "Got this URL: " + url, Toast.LENGTH_LONG).show(); Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(url)); intent.setClass(this, ManageReposActivity.class); 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 4ef228c89..3eb2bad1e 100644 --- a/F-Droid/src/org/fdroid/fdroid/views/swap/ConnectSwapActivity.java +++ b/F-Droid/src/org/fdroid/fdroid/views/swap/ConnectSwapActivity.java @@ -114,9 +114,9 @@ public class ConnectSwapActivity extends ActionBarActivity { switch (statusCode) { case UpdateService.STATUS_COMPLETE_AND_SAME: - Log.i(TAG, "STATUS_COMPLETE_AND_SAME"); + Utils.DebugLog(TAG, "STATUS_COMPLETE_AND_SAME"); case UpdateService.STATUS_COMPLETE_WITH_CHANGES: - Log.i(TAG, "STATUS_COMPLETE_WITH_CHANGES"); + Utils.DebugLog(TAG, "STATUS_COMPLETE_WITH_CHANGES"); Intent salIntent = new Intent(getBaseContext(), SwapAppListActivity.class); salIntent.putExtra(SwapAppListActivity.EXTRA_REPO_ID, repo.getId()); startActivity(salIntent); diff --git a/F-Droid/src/org/fdroid/fdroid/views/swap/WifiQrFragment.java b/F-Droid/src/org/fdroid/fdroid/views/swap/WifiQrFragment.java index ecb7d70ca..6714fe8eb 100644 --- a/F-Droid/src/org/fdroid/fdroid/views/swap/WifiQrFragment.java +++ b/F-Droid/src/org/fdroid/fdroid/views/swap/WifiQrFragment.java @@ -155,7 +155,7 @@ public class WifiQrFragment extends Fragment { } } - Log.i(TAG, "Encoded swap URI in QR Code: " + qrUriString); + Utils.DebugLog(TAG, "Encoded swap URI in QR Code: " + qrUriString); new QrGenAsyncTask(getActivity(), R.id.wifi_qr_code).execute(qrUriString);