summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorDoug Zongker <dougz@android.com>2014-01-27 09:43:42 -0800
committerDoug Zongker <dougz@android.com>2014-01-27 09:46:30 -0800
commit4f9d2d04003fafb358d7c127054055b3a9732c9b (patch)
tree72d9e3f0c49592856955dedde187f32e835f7aa8 /src
parent808e8736fc4ce38c6d868541e8389d838a890fef (diff)
downloadandroid_packages_providers_DownloadProvider-4f9d2d04003fafb358d7c127054055b3a9732c9b.zip
android_packages_providers_DownloadProvider-4f9d2d04003fafb358d7c127054055b3a9732c9b.tar.gz
android_packages_providers_DownloadProvider-4f9d2d04003fafb358d7c127054055b3a9732c9b.tar.bz2
change download provider to use system log
Try to catch the download provider in the act of deleting pending system updates. Bug: 12680933 Change-Id: If58aba5c30fd624217e5d073730645af05e98ac7
Diffstat (limited to 'src')
-rw-r--r--src/com/android/providers/downloads/Constants.java6
-rw-r--r--src/com/android/providers/downloads/DownloadProvider.java52
-rw-r--r--src/com/android/providers/downloads/DownloadReceiver.java14
-rw-r--r--src/com/android/providers/downloads/DownloadScanner.java6
-rw-r--r--src/com/android/providers/downloads/DownloadService.java30
-rw-r--r--src/com/android/providers/downloads/DownloadThread.java36
-rw-r--r--src/com/android/providers/downloads/StorageManager.java32
7 files changed, 88 insertions, 88 deletions
diff --git a/src/com/android/providers/downloads/Constants.java b/src/com/android/providers/downloads/Constants.java
index 89210a2..1579507 100644
--- a/src/com/android/providers/downloads/Constants.java
+++ b/src/com/android/providers/downloads/Constants.java
@@ -168,11 +168,11 @@ public class Constants {
static final boolean LOGX = false;
/** Enable verbose logging - use with "setprop log.tag.DownloadManager VERBOSE" */
- private static final boolean LOCAL_LOGV = false;
- public static final boolean LOGV = LOCAL_LOGV && Log.isLoggable(TAG, Log.VERBOSE);
+ private static final boolean LOCAL_LOGV = true;
+ public static final boolean LOGV = true; //LOCAL_LOGV && Log.isLoggable(TAG, Log.VERBOSE);
/** Enable super-verbose logging */
- private static final boolean LOCAL_LOGVV = false;
+ private static final boolean LOCAL_LOGVV = true;
public static final boolean LOGVV = LOCAL_LOGVV && LOGV;
public static final String STORAGE_AUTHORITY = "com.android.providers.downloads.documents";
diff --git a/src/com/android/providers/downloads/DownloadProvider.java b/src/com/android/providers/downloads/DownloadProvider.java
index ad3cf7a..7e4e080 100644
--- a/src/com/android/providers/downloads/DownloadProvider.java
+++ b/src/com/android/providers/downloads/DownloadProvider.java
@@ -45,7 +45,7 @@ import android.provider.Downloads;
import android.provider.OpenableColumns;
import android.text.TextUtils;
import android.text.format.DateUtils;
-import android.util.Log;
+import android.util.Slog;
import com.android.internal.util.IndentingPrintWriter;
import com.google.android.collect.Maps;
@@ -237,7 +237,7 @@ public final class DownloadProvider extends ContentProvider {
@Override
public void onCreate(final SQLiteDatabase db) {
if (Constants.LOGVV) {
- Log.v(Constants.TAG, "populating new database");
+ Slog.v(Constants.TAG, "populating new database");
}
onUpgrade(db, 0, DB_VERSION);
}
@@ -257,13 +257,13 @@ public final class DownloadProvider extends ContentProvider {
oldV = 100;
} else if (oldV < 100) {
// no logic to upgrade from these older version, just recreate the DB
- Log.i(Constants.TAG, "Upgrading downloads database from version " + oldV
+ Slog.i(Constants.TAG, "Upgrading downloads database from version " + oldV
+ " to version " + newV + ", which will destroy all old data");
oldV = 99;
} else if (oldV > newV) {
// user must have downgraded software; we have no way to know how to downgrade the
// DB, so just recreate it
- Log.i(Constants.TAG, "Downgrading downloads database from version " + oldV
+ Slog.i(Constants.TAG, "Downgrading downloads database from version " + oldV
+ " (current version is " + newV + "), destroying all old data");
oldV = 99;
}
@@ -418,7 +418,7 @@ public final class DownloadProvider extends ContentProvider {
Downloads.Impl.COLUMN_DESCRIPTION + " TEXT, " +
Constants.MEDIA_SCANNED + " BOOLEAN);");
} catch (SQLException ex) {
- Log.e(Constants.TAG, "couldn't create table in downloads database");
+ Slog.e(Constants.TAG, "couldn't create table in downloads database");
throw ex;
}
}
@@ -455,7 +455,7 @@ public final class DownloadProvider extends ContentProvider {
appInfo = getContext().getPackageManager().
getApplicationInfo("com.android.defcontainer", 0);
} catch (NameNotFoundException e) {
- Log.wtf(Constants.TAG, "Could not get ApplicationInfo for com.android.defconatiner", e);
+ Slog.wtf(Constants.TAG, "Could not get ApplicationInfo for com.android.defconatiner", e);
}
if (appInfo != null) {
mDefContainerUid = appInfo.uid;
@@ -468,7 +468,7 @@ public final class DownloadProvider extends ContentProvider {
try {
SELinux.restorecon(mDownloadsDataDir.getCanonicalPath());
} catch (IOException e) {
- Log.wtf(Constants.TAG, "Could not get canonical path for download directory", e);
+ Slog.wtf(Constants.TAG, "Could not get canonical path for download directory", e);
}
return true;
}
@@ -503,7 +503,7 @@ public final class DownloadProvider extends ContentProvider {
}
default: {
if (Constants.LOGV) {
- Log.v(Constants.TAG, "calling getType on an unknown URI: " + uri);
+ Slog.v(Constants.TAG, "calling getType on an unknown URI: " + uri);
}
throw new IllegalArgumentException("Unknown URI: " + uri);
}
@@ -521,7 +521,7 @@ public final class DownloadProvider extends ContentProvider {
// note we disallow inserting into ALL_DOWNLOADS
int match = sURIMatcher.match(uri);
if (match != MY_DOWNLOADS) {
- Log.d(Constants.TAG, "calling insert on an unknown/invalid URI: " + uri);
+ Slog.d(Constants.TAG, "calling insert on an unknown/invalid URI: " + uri);
throw new IllegalArgumentException("Unknown/Invalid URI " + uri);
}
@@ -668,17 +668,17 @@ public final class DownloadProvider extends ContentProvider {
}
if (Constants.LOGVV) {
- Log.v(Constants.TAG, "initiating download with UID "
+ Slog.v(Constants.TAG, "initiating download with UID "
+ filteredValues.getAsInteger(Constants.UID));
if (filteredValues.containsKey(Downloads.Impl.COLUMN_OTHER_UID)) {
- Log.v(Constants.TAG, "other UID " +
+ Slog.v(Constants.TAG, "other UID " +
filteredValues.getAsInteger(Downloads.Impl.COLUMN_OTHER_UID));
}
}
long rowID = db.insert(DB_TABLE, null, filteredValues);
if (rowID == -1) {
- Log.d(Constants.TAG, "couldn't insert into downloads database");
+ Slog.d(Constants.TAG, "couldn't insert into downloads database");
return null;
}
@@ -844,7 +844,7 @@ public final class DownloadProvider extends ContentProvider {
int match = sURIMatcher.match(uri);
if (match == -1) {
if (Constants.LOGV) {
- Log.v(Constants.TAG, "querying unknown URI: " + uri);
+ Slog.v(Constants.TAG, "querying unknown URI: " + uri);
}
throw new IllegalArgumentException("Unknown URI: " + uri);
}
@@ -891,12 +891,12 @@ public final class DownloadProvider extends ContentProvider {
if (ret != null) {
ret.setNotificationUri(getContext().getContentResolver(), uri);
if (Constants.LOGVV) {
- Log.v(Constants.TAG,
+ Slog.v(Constants.TAG,
"created cursor " + ret + " on behalf of " + Binder.getCallingPid());
}
} else {
if (Constants.LOGV) {
- Log.v(Constants.TAG, "query failed in downloads database");
+ Slog.v(Constants.TAG, "query failed in downloads database");
}
}
@@ -943,7 +943,7 @@ public final class DownloadProvider extends ContentProvider {
sb.append("sort is ");
sb.append(sort);
sb.append(".");
- Log.v(Constants.TAG, sb.toString());
+ Slog.v(Constants.TAG, sb.toString());
}
private String getDownloadIdFromUri(final Uri uri) {
@@ -1084,7 +1084,7 @@ public final class DownloadProvider extends ContentProvider {
break;
default:
- Log.d(Constants.TAG, "updating unknown/invalid URI: " + uri);
+ Slog.d(Constants.TAG, "updating unknown/invalid URI: " + uri);
throw new UnsupportedOperationException("Cannot update URI: " + uri);
}
@@ -1168,7 +1168,7 @@ public final class DownloadProvider extends ContentProvider {
break;
default:
- Log.d(Constants.TAG, "deleting unknown/invalid URI: " + uri);
+ Slog.d(Constants.TAG, "deleting unknown/invalid URI: " + uri);
throw new UnsupportedOperationException("Cannot delete URI: " + uri);
}
notifyContentChanged(uri, match);
@@ -1268,33 +1268,33 @@ public final class DownloadProvider extends ContentProvider {
}
private void logVerboseOpenFileInfo(Uri uri, String mode) {
- Log.v(Constants.TAG, "openFile uri: " + uri + ", mode: " + mode
+ Slog.v(Constants.TAG, "openFile uri: " + uri + ", mode: " + mode
+ ", uid: " + Binder.getCallingUid());
Cursor cursor = query(Downloads.Impl.CONTENT_URI,
new String[] { "_id" }, null, null, "_id");
if (cursor == null) {
- Log.v(Constants.TAG, "null cursor in openFile");
+ Slog.v(Constants.TAG, "null cursor in openFile");
} else {
if (!cursor.moveToFirst()) {
- Log.v(Constants.TAG, "empty cursor in openFile");
+ Slog.v(Constants.TAG, "empty cursor in openFile");
} else {
do {
- Log.v(Constants.TAG, "row " + cursor.getInt(0) + " available");
+ Slog.v(Constants.TAG, "row " + cursor.getInt(0) + " available");
} while(cursor.moveToNext());
}
cursor.close();
}
cursor = query(uri, new String[] { "_data" }, null, null, null);
if (cursor == null) {
- Log.v(Constants.TAG, "null cursor in openFile");
+ Slog.v(Constants.TAG, "null cursor in openFile");
} else {
if (!cursor.moveToFirst()) {
- Log.v(Constants.TAG, "empty cursor in openFile");
+ Slog.v(Constants.TAG, "empty cursor in openFile");
} else {
String filename = cursor.getString(0);
- Log.v(Constants.TAG, "filename in openFile: " + filename);
+ Slog.v(Constants.TAG, "filename in openFile: " + filename);
if (new java.io.File(filename).isFile()) {
- Log.v(Constants.TAG, "file exists in openFile");
+ Slog.v(Constants.TAG, "file exists in openFile");
}
}
cursor.close();
diff --git a/src/com/android/providers/downloads/DownloadReceiver.java b/src/com/android/providers/downloads/DownloadReceiver.java
index f3d2376..85ada1e 100644
--- a/src/com/android/providers/downloads/DownloadReceiver.java
+++ b/src/com/android/providers/downloads/DownloadReceiver.java
@@ -33,7 +33,7 @@ import android.os.Handler;
import android.os.HandlerThread;
import android.provider.Downloads;
import android.text.TextUtils;
-import android.util.Log;
+import android.util.Slog;
import android.widget.Toast;
import com.google.common.annotations.VisibleForTesting;
@@ -64,13 +64,13 @@ public class DownloadReceiver extends BroadcastReceiver {
String action = intent.getAction();
if (action.equals(Intent.ACTION_BOOT_COMPLETED)) {
if (Constants.LOGVV) {
- Log.v(Constants.TAG, "Received broadcast intent for " +
+ Slog.v(Constants.TAG, "Received broadcast intent for " +
Intent.ACTION_BOOT_COMPLETED);
}
startService(context);
} else if (action.equals(Intent.ACTION_MEDIA_MOUNTED)) {
if (Constants.LOGVV) {
- Log.v(Constants.TAG, "Received broadcast intent for " +
+ Slog.v(Constants.TAG, "Received broadcast intent for " +
Intent.ACTION_MEDIA_MOUNTED);
}
startService(context);
@@ -139,7 +139,7 @@ public class DownloadReceiver extends BroadcastReceiver {
status = getInt(cursor, Downloads.Impl.COLUMN_STATUS);
visibility = getInt(cursor, Downloads.Impl.COLUMN_VISIBILITY);
} else {
- Log.w(TAG, "Missing details for download " + id);
+ Slog.w(TAG, "Missing details for download " + id);
return;
}
} finally {
@@ -184,7 +184,7 @@ public class DownloadReceiver extends BroadcastReceiver {
clazz = getString(cursor, Downloads.Impl.COLUMN_NOTIFICATION_CLASS);
isPublicApi = getInt(cursor, Downloads.Impl.COLUMN_IS_PUBLIC_API) != 0;
} else {
- Log.w(TAG, "Missing details for download " + ids[0]);
+ Slog.w(TAG, "Missing details for download " + ids[0]);
return;
}
} finally {
@@ -192,7 +192,7 @@ public class DownloadReceiver extends BroadcastReceiver {
}
if (TextUtils.isEmpty(packageName)) {
- Log.w(TAG, "Missing package; skipping broadcast");
+ Slog.w(TAG, "Missing package; skipping broadcast");
return;
}
@@ -204,7 +204,7 @@ public class DownloadReceiver extends BroadcastReceiver {
} else { // legacy behavior
if (TextUtils.isEmpty(clazz)) {
- Log.w(TAG, "Missing class; skipping broadcast");
+ Slog.w(TAG, "Missing class; skipping broadcast");
return;
}
diff --git a/src/com/android/providers/downloads/DownloadScanner.java b/src/com/android/providers/downloads/DownloadScanner.java
index ca79506..463eafa 100644
--- a/src/com/android/providers/downloads/DownloadScanner.java
+++ b/src/com/android/providers/downloads/DownloadScanner.java
@@ -29,7 +29,7 @@ import android.media.MediaScannerConnection.MediaScannerConnectionClient;
import android.net.Uri;
import android.os.SystemClock;
import android.provider.Downloads;
-import android.util.Log;
+import android.util.Slog;
import com.android.internal.annotations.GuardedBy;
import com.google.common.collect.Maps;
@@ -99,7 +99,7 @@ public class DownloadScanner implements MediaScannerConnectionClient {
* @see #hasPendingScans()
*/
public void requestScan(DownloadInfo info) {
- if (LOGV) Log.v(TAG, "requestScan() for " + info.mFileName);
+ if (LOGV) Slog.v(TAG, "requestScan() for " + info.mFileName);
synchronized (mConnection) {
final ScanRequest req = new ScanRequest(info.mId, info.mFileName, info.mMimeType);
mPending.put(req.path, req);
@@ -132,7 +132,7 @@ public class DownloadScanner implements MediaScannerConnectionClient {
req = mPending.remove(path);
}
if (req == null) {
- Log.w(TAG, "Missing request for path " + path);
+ Slog.w(TAG, "Missing request for path " + path);
return;
}
diff --git a/src/com/android/providers/downloads/DownloadService.java b/src/com/android/providers/downloads/DownloadService.java
index 7d746cc..5d9647d 100644
--- a/src/com/android/providers/downloads/DownloadService.java
+++ b/src/com/android/providers/downloads/DownloadService.java
@@ -37,7 +37,7 @@ import android.os.Message;
import android.os.Process;
import android.provider.Downloads;
import android.text.TextUtils;
-import android.util.Log;
+import android.util.Slog;
import com.android.internal.annotations.GuardedBy;
import com.android.internal.util.IndentingPrintWriter;
@@ -149,7 +149,7 @@ public class DownloadService extends Service {
public void onCreate() {
super.onCreate();
if (Constants.LOGVV) {
- Log.v(Constants.TAG, "Service onCreate");
+ Slog.v(Constants.TAG, "Service onCreate");
}
if (mSystemFacade == null) {
@@ -177,7 +177,7 @@ public class DownloadService extends Service {
public int onStartCommand(Intent intent, int flags, int startId) {
int returnValue = super.onStartCommand(intent, flags, startId);
if (Constants.LOGVV) {
- Log.v(Constants.TAG, "Service onStart");
+ Slog.v(Constants.TAG, "Service onStart");
}
mLastStartId = startId;
enqueueUpdate();
@@ -190,7 +190,7 @@ public class DownloadService extends Service {
mScanner.shutdown();
mUpdateThread.quit();
if (Constants.LOGVV) {
- Log.v(Constants.TAG, "Service onDestroy");
+ Slog.v(Constants.TAG, "Service onDestroy");
}
super.onDestroy();
}
@@ -223,7 +223,7 @@ public class DownloadService extends Service {
Process.setThreadPriority(Process.THREAD_PRIORITY_BACKGROUND);
final int startId = msg.arg1;
- if (DEBUG_LIFECYCLE) Log.v(TAG, "Updating for startId " + startId);
+ if (DEBUG_LIFECYCLE) Slog.v(TAG, "Updating for startId " + startId);
// Since database is current source of truth, our "active" status
// depends on database state. We always get one final update pass
@@ -242,14 +242,14 @@ public class DownloadService extends Service {
for (Map.Entry<Thread, StackTraceElement[]> entry :
Thread.getAllStackTraces().entrySet()) {
if (entry.getKey().getName().startsWith("pool")) {
- Log.d(TAG, entry.getKey() + ": " + Arrays.toString(entry.getValue()));
+ Slog.d(TAG, entry.getKey() + ": " + Arrays.toString(entry.getValue()));
}
}
// Dump speed and update details
mNotifier.dumpSpeeds();
- Log.wtf(TAG, "Final update pass triggered, isActive=" + isActive
+ Slog.wtf(TAG, "Final update pass triggered, isActive=" + isActive
+ "; someone didn't update correctly.");
}
@@ -267,7 +267,7 @@ public class DownloadService extends Service {
// will always be delivered with a new startId.
if (stopSelfResult(startId)) {
- if (DEBUG_LIFECYCLE) Log.v(TAG, "Nothing left; stopped");
+ if (DEBUG_LIFECYCLE) Slog.v(TAG, "Nothing left; stopped");
getContentResolver().unregisterContentObserver(mObserver);
mScanner.shutdown();
mUpdateThread.quit();
@@ -332,7 +332,7 @@ public class DownloadService extends Service {
final boolean activeScan = info.startScanIfReady(mScanner);
if (DEBUG_LIFECYCLE && (activeDownload || activeScan)) {
- Log.v(TAG, "Download " + info.mId + ": activeDownload=" + activeDownload
+ Slog.v(TAG, "Download " + info.mId + ": activeDownload=" + activeDownload
+ ", activeScan=" + activeScan);
}
@@ -359,7 +359,7 @@ public class DownloadService extends Service {
// continues to run in meantime, since it will kick off an update pass.
if (nextActionMillis > 0 && nextActionMillis < Long.MAX_VALUE) {
if (Constants.LOGV) {
- Log.v(TAG, "scheduling start in " + nextActionMillis + "ms");
+ Slog.v(TAG, "scheduling start in " + nextActionMillis + "ms");
}
final Intent intent = new Intent(Constants.ACTION_RETRY);
@@ -381,7 +381,7 @@ public class DownloadService extends Service {
mDownloads.put(info.mId, info);
if (Constants.LOGVV) {
- Log.v(Constants.TAG, "processing inserted download " + info.mId);
+ Slog.v(Constants.TAG, "processing inserted download " + info.mId);
}
return info;
@@ -393,7 +393,7 @@ public class DownloadService extends Service {
private void updateDownload(DownloadInfo.Reader reader, DownloadInfo info, long now) {
reader.updateFromDatabase(info);
if (Constants.LOGVV) {
- Log.v(Constants.TAG, "processing updated download " + info.mId +
+ Slog.v(Constants.TAG, "processing updated download " + info.mId +
", status: " + info.mStatus);
}
}
@@ -408,7 +408,7 @@ public class DownloadService extends Service {
}
if (info.mDestination != Downloads.Impl.DESTINATION_EXTERNAL && info.mFileName != null) {
if (Constants.LOGVV) {
- Log.d(TAG, "deleteDownloadLocked() deleting " + info.mFileName);
+ Slog.d(TAG, "deleteDownloadLocked() deleting " + info.mFileName);
}
deleteFileIfExists(info.mFileName);
}
@@ -418,11 +418,11 @@ public class DownloadService extends Service {
private void deleteFileIfExists(String path) {
if (!TextUtils.isEmpty(path)) {
if (Constants.LOGVV) {
- Log.d(TAG, "deleteFileIfExists() deleting " + path);
+ Slog.d(TAG, "deleteFileIfExists() deleting " + path);
}
final File file = new File(path);
if (file.exists() && !file.delete()) {
- Log.w(TAG, "file: '" + path + "' couldn't be deleted");
+ Slog.w(TAG, "file: '" + path + "' couldn't be deleted");
}
}
}
diff --git a/src/com/android/providers/downloads/DownloadThread.java b/src/com/android/providers/downloads/DownloadThread.java
index 93f8d65..3e1cce6 100644
--- a/src/com/android/providers/downloads/DownloadThread.java
+++ b/src/com/android/providers/downloads/DownloadThread.java
@@ -51,7 +51,7 @@ import android.os.SystemClock;
import android.os.WorkSource;
import android.provider.Downloads;
import android.text.TextUtils;
-import android.util.Log;
+import android.util.Slog;
import android.util.Pair;
import com.android.providers.downloads.DownloadInfo.NetworkState;
@@ -175,7 +175,7 @@ public class DownloadThread implements Runnable {
// probably started again while racing with UpdateThread.
if (DownloadInfo.queryDownloadStatus(mContext.getContentResolver(), mInfo.mId)
== Downloads.Impl.STATUS_SUCCESS) {
- Log.d(TAG, "Download " + mInfo.mId + " already finished; skipping");
+ Slog.d(TAG, "Download " + mInfo.mId + " already finished; skipping");
return;
}
@@ -196,7 +196,7 @@ public class DownloadThread implements Runnable {
// while performing download, register for rules updates
netPolicy.registerListener(mPolicyListener);
- Log.i(Constants.TAG, "Download " + mInfo.mId + " starting");
+ Slog.i(Constants.TAG, "Download " + mInfo.mId + " starting (" + mInfo.mUri + ")");
// Remember which network this download started on; used to
// determine if errors were due to network changes.
@@ -225,9 +225,9 @@ public class DownloadThread implements Runnable {
// remove the cause before printing, in case it contains PII
errorMsg = error.getMessage();
String msg = "Aborting request for download " + mInfo.mId + ": " + errorMsg;
- Log.w(Constants.TAG, msg);
+ Slog.w(Constants.TAG, msg);
if (Constants.LOGV) {
- Log.w(Constants.TAG, msg, error);
+ Slog.w(Constants.TAG, msg, error);
}
finalStatus = error.getFinalStatus();
@@ -262,7 +262,7 @@ public class DownloadThread implements Runnable {
} catch (Throwable ex) {
errorMsg = ex.getMessage();
String msg = "Exception for id " + mInfo.mId + ": " + errorMsg;
- Log.w(Constants.TAG, msg, ex);
+ Slog.w(Constants.TAG, msg, ex);
finalStatus = Downloads.Impl.STATUS_UNKNOWN_ERROR;
// falls through to the code that reports an error
} finally {
@@ -276,7 +276,7 @@ public class DownloadThread implements Runnable {
cleanupDestination(state, finalStatus);
notifyDownloadCompleted(state, finalStatus, errorMsg, numFailed);
- Log.i(Constants.TAG, "Download " + mInfo.mId + " finished with status "
+ Slog.i(Constants.TAG, "Download " + mInfo.mId + " finished with status "
+ Downloads.Impl.statusToString(finalStatus));
netPolicy.unregisterListener(mPolicyListener);
@@ -299,7 +299,7 @@ public class DownloadThread implements Runnable {
// skip when already finished; remove after fixing race in 5217390
if (state.mCurrentBytes == state.mTotalBytes) {
- Log.i(Constants.TAG, "Skipping initiating request for download " +
+ Slog.i(Constants.TAG, "Skipping initiating request for download " +
mInfo.mId + "; already completed");
return;
}
@@ -477,7 +477,7 @@ public class DownloadThread implements Runnable {
reportProgress(state);
if (Constants.LOGVV) {
- Log.v(Constants.TAG, "downloaded " + state.mCurrentBytes + " for "
+ Slog.v(Constants.TAG, "downloaded " + state.mCurrentBytes + " for "
+ mInfo.mUri);
}
@@ -502,7 +502,7 @@ public class DownloadThread implements Runnable {
private void cleanupDestination(State state, int finalStatus) {
if (state.mFilename != null && Downloads.Impl.isStatusError(finalStatus)) {
if (Constants.LOGVV) {
- Log.d(TAG, "cleanupDestination() deleting " + state.mFilename);
+ Slog.d(TAG, "cleanupDestination() deleting " + state.mFilename);
}
new File(state.mFilename).delete();
state.mFilename = null;
@@ -715,7 +715,7 @@ public class DownloadThread implements Runnable {
if (transferEncoding == null) {
state.mContentLength = getHeaderFieldLong(conn, "Content-Length", -1);
} else {
- Log.i(TAG, "Ignoring Content-Length since Transfer-Encoding is also defined");
+ Slog.i(TAG, "Ignoring Content-Length since Transfer-Encoding is also defined");
state.mContentLength = -1;
}
@@ -752,7 +752,7 @@ public class DownloadThread implements Runnable {
private void setupDestinationFile(State state) throws StopRequestException {
if (!TextUtils.isEmpty(state.mFilename)) { // only true if we've already run a thread for this download
if (Constants.LOGV) {
- Log.i(Constants.TAG, "have run thread before for id: " + mInfo.mId +
+ Slog.i(Constants.TAG, "have run thread before for id: " + mInfo.mId +
", and state.mFilename: " + state.mFilename);
}
if (!Helpers.isFilenameValid(state.mFilename,
@@ -765,26 +765,26 @@ public class DownloadThread implements Runnable {
File f = new File(state.mFilename);
if (f.exists()) {
if (Constants.LOGV) {
- Log.i(Constants.TAG, "resuming download for id: " + mInfo.mId +
+ Slog.i(Constants.TAG, "resuming download for id: " + mInfo.mId +
", and state.mFilename: " + state.mFilename);
}
long fileLength = f.length();
if (fileLength == 0) {
// The download hadn't actually started, we can restart from scratch
if (Constants.LOGVV) {
- Log.d(TAG, "setupDestinationFile() found fileLength=0, deleting "
+ Slog.d(TAG, "setupDestinationFile() found fileLength=0, deleting "
+ state.mFilename);
}
f.delete();
state.mFilename = null;
if (Constants.LOGV) {
- Log.i(Constants.TAG, "resuming download for id: " + mInfo.mId +
+ Slog.i(Constants.TAG, "resuming download for id: " + mInfo.mId +
", BUT starting from scratch again: ");
}
} else if (mInfo.mETag == null && !mInfo.mNoIntegrity) {
// This should've been caught upon failure
if (Constants.LOGVV) {
- Log.d(TAG, "setupDestinationFile() unable to resume download, deleting "
+ Slog.d(TAG, "setupDestinationFile() unable to resume download, deleting "
+ state.mFilename);
}
f.delete();
@@ -793,7 +793,7 @@ public class DownloadThread implements Runnable {
} else {
// All right, we'll be able to resume this download
if (Constants.LOGV) {
- Log.i(Constants.TAG, "resuming download for id: " + mInfo.mId +
+ Slog.i(Constants.TAG, "resuming download for id: " + mInfo.mId +
", and starting with file of length: " + fileLength);
}
state.mCurrentBytes = (int) fileLength;
@@ -803,7 +803,7 @@ public class DownloadThread implements Runnable {
state.mHeaderETag = mInfo.mETag;
state.mContinuingDownload = true;
if (Constants.LOGV) {
- Log.i(Constants.TAG, "resuming download for id: " + mInfo.mId +
+ Slog.i(Constants.TAG, "resuming download for id: " + mInfo.mId +
", state.mCurrentBytes: " + state.mCurrentBytes +
", and setting mContinuingDownload to true: ");
}
diff --git a/src/com/android/providers/downloads/StorageManager.java b/src/com/android/providers/downloads/StorageManager.java
index deb412e..df5312a 100644
--- a/src/com/android/providers/downloads/StorageManager.java
+++ b/src/com/android/providers/downloads/StorageManager.java
@@ -29,7 +29,7 @@ import android.os.Environment;
import android.os.StatFs;
import android.provider.Downloads;
import android.text.TextUtils;
-import android.util.Log;
+import android.util.Slog;
import com.android.internal.R;
@@ -130,7 +130,7 @@ class StorageManager {
resetBytesDownloadedSinceLastCheckOnSpace();
File dir = null;
if (Constants.LOGV) {
- Log.i(Constants.TAG, "in verifySpace, destination: " + destination +
+ Slog.i(Constants.TAG, "in verifySpace, destination: " + destination +
", path: " + path + ", length: " + length);
}
if (path == null) {
@@ -202,7 +202,7 @@ class StorageManager {
* few MB of space left on the filesystem.
*/
if (root.equals(mSystemCacheDir)) {
- Log.w(Constants.TAG, "System cache dir ('/cache') is running low on space." +
+ Slog.w(Constants.TAG, "System cache dir ('/cache') is running low on space." +
"space available (in bytes): " + bytesAvailable);
} else {
throw new StopRequestException(Downloads.Impl.STATUS_INSUFFICIENT_SPACE_ERROR,
@@ -216,7 +216,7 @@ class StorageManager {
bytesAvailable = getAvailableBytesInDownloadsDataDir(mDownloadDataDir);
if (bytesAvailable < sDownloadDataDirLowSpaceThreshold) {
// print a warning
- Log.w(Constants.TAG, "Downloads data dir: " + root +
+ Slog.w(Constants.TAG, "Downloads data dir: " + root +
" is running low on space. space available (in bytes): " + bytesAvailable);
}
if (bytesAvailable < targetBytes) {
@@ -248,7 +248,7 @@ class StorageManager {
space -= files[i].length();
}
if (Constants.LOGV) {
- Log.i(Constants.TAG, "available space (in bytes) in downloads data dir: " + space);
+ Slog.i(Constants.TAG, "available space (in bytes) in downloads data dir: " + space);
}
return space;
}
@@ -259,7 +259,7 @@ class StorageManager {
long availableBlocks = (long) stat.getAvailableBlocks() - 4;
long size = stat.getBlockSize() * availableBlocks;
if (Constants.LOGV) {
- Log.i(Constants.TAG, "available space (in bytes) in filesystem rooted at: " +
+ Slog.i(Constants.TAG, "available space (in bytes) in filesystem rooted at: " +
root.getPath() + " is: " + size);
}
return size;
@@ -303,7 +303,7 @@ class StorageManager {
*/
private long discardPurgeableFiles(int destination, long targetBytes) {
if (true || Constants.LOGV) {
- Log.i(Constants.TAG, "discardPurgeableFiles: destination = " + destination +
+ Slog.i(Constants.TAG, "discardPurgeableFiles: destination = " + destination +
", targetBytes = " + targetBytes);
}
String destStr = (destination == Downloads.Impl.DESTINATION_SYSTEMCACHE_PARTITION) ?
@@ -330,7 +330,7 @@ class StorageManager {
File file = new File(data);
if (Constants.LOGV) {
- Log.d(Constants.TAG, "purging " + file.getAbsolutePath() + " for "
+ Slog.d(Constants.TAG, "purging " + file.getAbsolutePath() + " for "
+ file.length() + " bytes");
}
totalFreed += file.length();
@@ -344,7 +344,7 @@ class StorageManager {
cursor.close();
}
if (true || Constants.LOGV) {
- Log.i(Constants.TAG, "Purged files, freed " + totalFreed + " for " +
+ Slog.i(Constants.TAG, "Purged files, freed " + totalFreed + " for " +
targetBytes + " requested");
}
return totalFreed;
@@ -359,7 +359,7 @@ class StorageManager {
*/
private void removeSpuriousFiles() {
if (Constants.LOGV) {
- Log.i(Constants.TAG, "in removeSpuriousFiles");
+ Slog.i(Constants.TAG, "in removeSpuriousFiles");
}
// get a list of all files in system cache dir and downloads data dir
List<File> files = new ArrayList<File>();
@@ -383,7 +383,7 @@ class StorageManager {
String filename = cursor.getString(0);
if (!TextUtils.isEmpty(filename)) {
if (LOGV) {
- Log.i(Constants.TAG, "in removeSpuriousFiles, preserving file " +
+ Slog.i(Constants.TAG, "in removeSpuriousFiles, preserving file " +
filename);
}
files.remove(new File(filename));
@@ -404,12 +404,12 @@ class StorageManager {
final StructStat stat = Libcore.os.stat(path);
if (stat.st_uid == myUid) {
if (Constants.LOGVV) {
- Log.d(TAG, "deleting spurious file " + path);
+ Slog.d(TAG, "deleting spurious file " + path);
}
file.delete();
}
} catch (ErrnoException e) {
- Log.w(TAG, "stat(" + path + ") result: " + e);
+ Slog.w(TAG, "stat(" + path + ") result: " + e);
}
}
}
@@ -421,7 +421,7 @@ class StorageManager {
*/
private void trimDatabase() {
if (Constants.LOGV) {
- Log.i(Constants.TAG, "in trimDatabase");
+ Slog.i(Constants.TAG, "in trimDatabase");
}
Cursor cursor = null;
try {
@@ -432,7 +432,7 @@ class StorageManager {
if (cursor == null) {
// This isn't good - if we can't do basic queries in our database,
// nothing's gonna work
- Log.e(Constants.TAG, "null cursor in trimDatabase");
+ Slog.e(Constants.TAG, "null cursor in trimDatabase");
return;
}
if (cursor.moveToFirst()) {
@@ -452,7 +452,7 @@ class StorageManager {
// trimming the database raised an exception. alright, ignore the exception
// and return silently. trimming database is not exactly a critical operation
// and there is no need to propagate the exception.
- Log.w(Constants.TAG, "trimDatabase failed with exception: " + e.getMessage());
+ Slog.w(Constants.TAG, "trimDatabase failed with exception: " + e.getMessage());
return;
} finally {
if (cursor != null) {