diff options
Diffstat (limited to 'src/com/android/providers/downloads/DownloadReceiver.java')
-rw-r--r-- | src/com/android/providers/downloads/DownloadReceiver.java | 43 |
1 files changed, 29 insertions, 14 deletions
diff --git a/src/com/android/providers/downloads/DownloadReceiver.java b/src/com/android/providers/downloads/DownloadReceiver.java index 03a37186..2065c649 100644 --- a/src/com/android/providers/downloads/DownloadReceiver.java +++ b/src/com/android/providers/downloads/DownloadReceiver.java @@ -23,18 +23,15 @@ import android.content.ContentUris; import android.content.ContentValues; import android.content.Context; import android.content.Intent; -import android.content.pm.PackageManager; -import android.content.pm.ResolveInfo; import android.database.Cursor; -import android.provider.Downloads; import android.net.ConnectivityManager; import android.net.NetworkInfo; import android.net.Uri; +import android.provider.Downloads; import android.util.Config; import android.util.Log; import java.io.File; -import java.util.List; /** * Receives system broadcasts (boot, network connectivity) @@ -54,7 +51,22 @@ public class DownloadReceiver extends BroadcastReceiver { NetworkInfo info = (NetworkInfo) intent.getParcelableExtra(ConnectivityManager.EXTRA_NETWORK_INFO); if (info != null && info.isConnected()) { + if (Constants.LOGX) { + if (Helpers.isNetworkAvailable(context)) { + Log.i(Constants.TAG, "Broadcast: Network Up"); + } else { + Log.i(Constants.TAG, "Broadcast: Network Up, Actually Down"); + } + } context.startService(new Intent(context, DownloadService.class)); + } else { + if (Constants.LOGX) { + if (Helpers.isNetworkAvailable(context)) { + Log.i(Constants.TAG, "Broadcast: Network Down, Actually Up"); + } else { + Log.i(Constants.TAG, "Broadcast: Network Down"); + } + } } } else if (intent.getAction().equals(Constants.ACTION_RETRY)) { if (Constants.LOGVV) { @@ -74,20 +86,22 @@ public class DownloadReceiver extends BroadcastReceiver { intent.getData(), null, null, null, null); if (cursor != null) { if (cursor.moveToFirst()) { - int statusColumn = cursor.getColumnIndexOrThrow(Downloads.STATUS); + int statusColumn = cursor.getColumnIndexOrThrow(Downloads.COLUMN_STATUS); int status = cursor.getInt(statusColumn); - int visibilityColumn = cursor.getColumnIndexOrThrow(Downloads.VISIBILITY); + int visibilityColumn = + cursor.getColumnIndexOrThrow(Downloads.COLUMN_VISIBILITY); int visibility = cursor.getInt(visibilityColumn); if (Downloads.isStatusCompleted(status) && visibility == Downloads.VISIBILITY_VISIBLE_NOTIFY_COMPLETED) { ContentValues values = new ContentValues(); - values.put(Downloads.VISIBILITY, Downloads.VISIBILITY_VISIBLE); + values.put(Downloads.COLUMN_VISIBILITY, Downloads.VISIBILITY_VISIBLE); context.getContentResolver().update(intent.getData(), values, null, null); } if (intent.getAction().equals(Constants.ACTION_OPEN)) { int filenameColumn = cursor.getColumnIndexOrThrow(Downloads._DATA); - int mimetypeColumn = cursor.getColumnIndexOrThrow(Downloads.MIMETYPE); + int mimetypeColumn = + cursor.getColumnIndexOrThrow(Downloads.COLUMN_MIME_TYPE); String filename = cursor.getString(filenameColumn); String mimetype = cursor.getString(mimetypeColumn); Uri path = Uri.parse(filename); @@ -109,13 +123,13 @@ public class DownloadReceiver extends BroadcastReceiver { } } else { int packageColumn = - cursor.getColumnIndexOrThrow(Downloads.NOTIFICATION_PACKAGE); + cursor.getColumnIndexOrThrow(Downloads.COLUMN_NOTIFICATION_PACKAGE); int classColumn = - cursor.getColumnIndexOrThrow(Downloads.NOTIFICATION_CLASS); + cursor.getColumnIndexOrThrow(Downloads.COLUMN_NOTIFICATION_CLASS); String pckg = cursor.getString(packageColumn); String clazz = cursor.getString(classColumn); if (pckg != null && clazz != null) { - Intent appIntent = new Intent(Downloads.NOTIFICATION_CLICKED_ACTION); + Intent appIntent = new Intent(Downloads.ACTION_NOTIFICATION_CLICKED); appIntent.setClassName(pckg, clazz); if (intent.getBooleanExtra("multiple", true)) { appIntent.setData(Downloads.CONTENT_URI); @@ -141,14 +155,15 @@ public class DownloadReceiver extends BroadcastReceiver { intent.getData(), null, null, null, null); if (cursor != null) { if (cursor.moveToFirst()) { - int statusColumn = cursor.getColumnIndexOrThrow(Downloads.STATUS); + int statusColumn = cursor.getColumnIndexOrThrow(Downloads.COLUMN_STATUS); int status = cursor.getInt(statusColumn); - int visibilityColumn = cursor.getColumnIndexOrThrow(Downloads.VISIBILITY); + int visibilityColumn = + cursor.getColumnIndexOrThrow(Downloads.COLUMN_VISIBILITY); int visibility = cursor.getInt(visibilityColumn); if (Downloads.isStatusCompleted(status) && visibility == Downloads.VISIBILITY_VISIBLE_NOTIFY_COMPLETED) { ContentValues values = new ContentValues(); - values.put(Downloads.VISIBILITY, Downloads.VISIBILITY_VISIBLE); + values.put(Downloads.COLUMN_VISIBILITY, Downloads.VISIBILITY_VISIBLE); context.getContentResolver().update(intent.getData(), values, null, null); } } |