OSDN Git Service

am a581a4af: Add logging to track connectivity as seen from the Download Manager.
authorJean-Baptiste Queru <jbq@google.com>
Mon, 21 Sep 2009 17:14:45 +0000 (10:14 -0700)
committerAndroid Git Automerger <android-git-automerger@android.com>
Mon, 21 Sep 2009 17:14:45 +0000 (10:14 -0700)
Merge commit 'a581a4af046fd82b5854d213519e3f418047c0ba' into eclair-plus-aosp

* commit 'a581a4af046fd82b5854d213519e3f418047c0ba':
  Add logging to track connectivity as seen from the Download Manager.

src/com/android/providers/downloads/Constants.java
src/com/android/providers/downloads/DownloadReceiver.java
src/com/android/providers/downloads/DownloadThread.java

index 993ed78..cae5370 100644 (file)
@@ -140,6 +140,9 @@ public class Constants {
      */
     public static final int RETRY_FIRST_DELAY = 30;
 
+    /** Enable separate connectivity logging */
+    static final boolean LOGX = true;
+
     /** Enable verbose logging - use with "setprop log.tag.DownloadManager VERBOSE" */
     private static final boolean LOCAL_LOGV = true;
     public static final boolean LOGV = Config.LOGV
index c0ccad3..74f2931 100644 (file)
@@ -51,12 +51,22 @@ public class DownloadReceiver extends BroadcastReceiver {
             NetworkInfo info = (NetworkInfo)
                     intent.getParcelableExtra(ConnectivityManager.EXTRA_NETWORK_INFO);
             if (info != null && info.isConnected()) {
+                if (Constants.LOGX) {
+                    Log.i(Constants.TAG, "Broadcast: Network Up");
+                }
                 context.startService(new Intent(context, DownloadService.class));
+            } else {
+                if (Constants.LOGX) {
+                    Log.i(Constants.TAG, "Broadcast: Network Down");
+                }
             }
         } else if (intent.getAction().equals(Constants.ACTION_RETRY)) {
             if (Constants.LOGVV) {
                 Log.v(Constants.TAG, "Receiver retry");
             }
+            if (Constants.LOGX) {
+                Log.i(Constants.TAG, "Broadcast: Timed Retry");
+            }
             context.startService(new Intent(context, DownloadService.class));
         } else if (intent.getAction().equals(Constants.ACTION_OPEN)
                 || intent.getAction().equals(Constants.ACTION_LIST)) {
index 7703d14..cee34cf 100644 (file)
@@ -201,6 +201,13 @@ http_request_loop:
 
                 HttpResponse response;
                 try {
+                    if (Constants.LOGX) {
+                        if (Helpers.isNetworkAvailable(mContext)) {
+                            Log.i(Constants.TAG, "Starting, Net Up");
+                        } else {
+                            Log.i(Constants.TAG, "Starting, Net Down");
+                        }
+                    }
                     response = client.execute(request);
                 } catch (IllegalArgumentException ex) {
                     if (Constants.LOGV) {
@@ -214,6 +221,13 @@ http_request_loop:
                     request.abort();
                     break http_request_loop;
                 } catch (IOException ex) {
+                    if (Constants.LOGX) {
+                        if (Helpers.isNetworkAvailable(mContext)) {
+                            Log.i(Constants.TAG, "Execute Failed, Net Up");
+                        } else {
+                            Log.i(Constants.TAG, "Execute Failed, Net Down");
+                        }
+                    }
                     if (!Helpers.isNetworkAvailable(mContext)) {
                         finalStatus = Downloads.STATUS_RUNNING_PAUSED;
                     } else if (mInfo.mNumFailed < Constants.MAX_RETRIES) {
@@ -442,6 +456,13 @@ http_request_loop:
                     try {
                         entityStream = response.getEntity().getContent();
                     } catch (IOException ex) {
+                        if (Constants.LOGX) {
+                            if (Helpers.isNetworkAvailable(mContext)) {
+                                Log.i(Constants.TAG, "GetContent Failed, Net Up");
+                            } else {
+                                Log.i(Constants.TAG, "GetContent Failed, Net Down");
+                            }
+                        }
                         if (!Helpers.isNetworkAvailable(mContext)) {
                             finalStatus = Downloads.STATUS_RUNNING_PAUSED;
                         } else if (mInfo.mNumFailed < Constants.MAX_RETRIES) {
@@ -468,6 +489,13 @@ http_request_loop:
                         try {
                             bytesRead = entityStream.read(data);
                         } catch (IOException ex) {
+                            if (Constants.LOGX) {
+                                if (Helpers.isNetworkAvailable(mContext)) {
+                                    Log.i(Constants.TAG, "Read Failed, Net Up");
+                                } else {
+                                    Log.i(Constants.TAG, "Read Failed, Net Down");
+                                }
+                            }
                             ContentValues values = new ContentValues();
                             values.put(Downloads.COLUMN_CURRENT_BYTES, bytesSoFar);
                             mContext.getContentResolver().update(contentUri, values, null, null);