summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/com/android/providers/downloads/DownloadNotifier.java44
-rw-r--r--src/com/android/providers/downloads/DownloadProvider.java5
-rw-r--r--src/com/android/providers/downloads/DownloadReceiver.java21
-rw-r--r--src/com/android/providers/downloads/Helpers.java2
4 files changed, 52 insertions, 20 deletions
diff --git a/src/com/android/providers/downloads/DownloadNotifier.java b/src/com/android/providers/downloads/DownloadNotifier.java
index d13bb5e2..c36dbd8c 100644
--- a/src/com/android/providers/downloads/DownloadNotifier.java
+++ b/src/com/android/providers/downloads/DownloadNotifier.java
@@ -26,6 +26,7 @@ import static com.android.providers.downloads.Constants.TAG;
import android.app.DownloadManager;
import android.app.Notification;
+import android.app.NotificationChannel;
import android.app.NotificationManager;
import android.app.PendingIntent;
import android.content.ContentUris;
@@ -61,6 +62,10 @@ public class DownloadNotifier {
private static final int TYPE_WAITING = 2;
private static final int TYPE_COMPLETE = 3;
+ private static final String CHANNEL_ACTIVE = "active";
+ private static final String CHANNEL_WAITING = "waiting";
+ private static final String CHANNEL_COMPLETE = "complete";
+
private final Context mContext;
private final NotificationManager mNotifManager;
@@ -89,8 +94,18 @@ public class DownloadNotifier {
public DownloadNotifier(Context context) {
mContext = context;
- mNotifManager = (NotificationManager) context.getSystemService(
- Context.NOTIFICATION_SERVICE);
+ mNotifManager = context.getSystemService(NotificationManager.class);
+
+ // Ensure that all our channels are ready to use
+ mNotifManager.createNotificationChannel(new NotificationChannel(CHANNEL_ACTIVE,
+ context.getText(R.string.download_running),
+ NotificationManager.IMPORTANCE_LOW));
+ mNotifManager.createNotificationChannel(new NotificationChannel(CHANNEL_WAITING,
+ context.getText(R.string.download_queued),
+ NotificationManager.IMPORTANCE_DEFAULT));
+ mNotifManager.createNotificationChannel(new NotificationChannel(CHANNEL_COMPLETE,
+ context.getText(com.android.internal.R.string.done_label),
+ NotificationManager.IMPORTANCE_DEFAULT));
}
public void init() {
@@ -178,7 +193,20 @@ public class DownloadNotifier {
final IntArray cluster = clustered.valueAt(i);
final int type = getNotificationTagType(tag);
- final Notification.Builder builder = new Notification.Builder(mContext);
+ final Notification.Builder builder;
+ if (type == TYPE_ACTIVE) {
+ builder = new Notification.Builder(mContext, CHANNEL_ACTIVE);
+ builder.setSmallIcon(android.R.drawable.stat_sys_download);
+ } else if (type == TYPE_WAITING) {
+ builder = new Notification.Builder(mContext, CHANNEL_WAITING);
+ builder.setSmallIcon(android.R.drawable.stat_sys_warning);
+ } else if (type == TYPE_COMPLETE) {
+ builder = new Notification.Builder(mContext, CHANNEL_COMPLETE);
+ builder.setSmallIcon(android.R.drawable.stat_sys_download_done);
+ } else {
+ continue;
+ }
+
builder.setColor(res.getColor(
com.android.internal.R.color.system_notification_accent_color));
@@ -191,15 +219,7 @@ public class DownloadNotifier {
mActiveNotifs.put(tag, firstShown);
}
builder.setWhen(firstShown);
-
- // Show relevant icon
- if (type == TYPE_ACTIVE) {
- builder.setSmallIcon(android.R.drawable.stat_sys_download);
- } else if (type == TYPE_WAITING) {
- builder.setSmallIcon(android.R.drawable.stat_sys_warning);
- } else if (type == TYPE_COMPLETE) {
- builder.setSmallIcon(android.R.drawable.stat_sys_download_done);
- }
+ builder.setOnlyAlertOnce(true);
// Build action intents
if (type == TYPE_ACTIVE || type == TYPE_WAITING) {
diff --git a/src/com/android/providers/downloads/DownloadProvider.java b/src/com/android/providers/downloads/DownloadProvider.java
index f3b7b6f3..d50b394c 100644
--- a/src/com/android/providers/downloads/DownloadProvider.java
+++ b/src/com/android/providers/downloads/DownloadProvider.java
@@ -1116,8 +1116,9 @@ public final class DownloadProvider extends ContentProvider {
@Override
public int update(final Uri uri, final ContentValues values,
final String where, final String[] whereArgs) {
-
- Helpers.validateSelection(where, sAppReadableColumnsSet);
+ if (shouldRestrictVisibility()) {
+ Helpers.validateSelection(where, sAppReadableColumnsSet);
+ }
final Context context = getContext();
final ContentResolver resolver = context.getContentResolver();
diff --git a/src/com/android/providers/downloads/DownloadReceiver.java b/src/com/android/providers/downloads/DownloadReceiver.java
index a0dc6947..92d0bad4 100644
--- a/src/com/android/providers/downloads/DownloadReceiver.java
+++ b/src/com/android/providers/downloads/DownloadReceiver.java
@@ -139,13 +139,24 @@ public class DownloadReceiver extends BroadcastReceiver {
private void handleUidRemoved(Context context, Intent intent) {
final ContentResolver resolver = context.getContentResolver();
-
final int uid = intent.getIntExtra(Intent.EXTRA_UID, -1);
- final int count = resolver.delete(
- Downloads.Impl.ALL_DOWNLOADS_CONTENT_URI, Constants.UID + "=" + uid, null);
- if (count > 0) {
- Slog.d(TAG, "Deleted " + count + " downloads owned by UID " + uid);
+ // First, disown any downloads that live in shared storage
+ final ContentValues values = new ContentValues();
+ values.putNull(Constants.UID);
+ final int disowned = resolver.update(Downloads.Impl.ALL_DOWNLOADS_CONTENT_URI, values,
+ Constants.UID + "=" + uid + " AND " + Downloads.Impl.COLUMN_DESTINATION + " IN ("
+ + Downloads.Impl.DESTINATION_EXTERNAL + ","
+ + Downloads.Impl.DESTINATION_FILE_URI + ")",
+ null);
+
+ // Finally, delete any remaining downloads owned by UID
+ final int deleted = resolver.delete(Downloads.Impl.ALL_DOWNLOADS_CONTENT_URI,
+ Constants.UID + "=" + uid, null);
+
+ if ((disowned + deleted) > 0) {
+ Slog.d(TAG, "Disowned " + disowned + " and deleted " + deleted
+ + " downloads owned by UID " + uid);
}
}
diff --git a/src/com/android/providers/downloads/Helpers.java b/src/com/android/providers/downloads/Helpers.java
index e9549052..7354076b 100644
--- a/src/com/android/providers/downloads/Helpers.java
+++ b/src/com/android/providers/downloads/Helpers.java
@@ -796,7 +796,7 @@ public class Helpers {
mCurrentToken = TOKEN_COLUMN;
return;
}
- throw new IllegalArgumentException("unrecognized column or keyword");
+ throw new IllegalArgumentException("unrecognized column or keyword: " + word);
}
// quoted strings