Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit f9e8523e authored by Vasu Nori's avatar Vasu Nori
Browse files

bug:3425749 send notification for completed download

Change-Id: Ib46df5eaa9316fe0fc843fee1e4597e22768f4a8
parent f37c2e2d
Loading
Loading
Loading
Loading
+13 −0
Original line number Diff line number Diff line
@@ -28829,6 +28829,8 @@
</parameter>
<parameter name="length" type="long">
</parameter>
<parameter name="showNotification" type="boolean">
</parameter>
</method>
<method name="enqueue"
 return="long"
@@ -29635,6 +29637,17 @@
 visibility="public"
>
</field>
<field name="VISIBILITY_VISIBLE_NOTIFY_ONLY_COMPLETION"
 type="int"
 transient="false"
 volatile="false"
 value="3"
 static="true"
 final="true"
 deprecated="not deprecated"
 visibility="public"
>
</field>
</class>
<class name="ExpandableListActivity"
 extends="android.app.Activity"
+15 −2
Original line number Diff line number Diff line
@@ -373,8 +373,17 @@ public class DownloadManager {
         */
        public static final int VISIBILITY_HIDDEN = 2;

        /**
         * This download shows in the notifications after completion ONLY.
         * It is usuable only with
         * {@link DownloadManager#completedDownload(String, String, boolean, String,
         * String, long, boolean)}.
         */
        public static final int VISIBILITY_VISIBLE_NOTIFY_ONLY_COMPLETION = 3;

        /** can take any of the following values: {@link #VISIBILITY_HIDDEN}
         * {@link #VISIBILITY_VISIBLE_NOTIFY_COMPLETED}, {@link #VISIBILITY_VISIBLE}
         * {@link #VISIBILITY_VISIBLE_NOTIFY_COMPLETED}, {@link #VISIBILITY_VISIBLE},
         * {@link #VISIBILITY_VISIBLE_NOTIFY_ONLY_COMPLETION}
         */
        private int mNotificationVisibility = VISIBILITY_VISIBLE;

@@ -1098,11 +1107,13 @@ public class DownloadManager {
     * be managed by the Downloads App and any other app that is used to read it (for example,
     * Gallery app to display the file, if the file contents represent a video/image).
     * @param length length of the downloaded file
     * @param showNotification true if a notification is to be sent, false otherwise
     * @return  an ID for the download entry added to the downloads app, unique across the system
     * This ID is used to make future calls related to this download.
     */
    public long completedDownload(String title, String description,
            boolean isMediaScannerScannable, String mimeType, String path, long length) {
            boolean isMediaScannerScannable, String mimeType, String path, long length,
            boolean showNotification) {
        // make sure the input args are non-null/non-zero
        validateArgumentIsNonEmpty("title", title);
        validateArgumentIsNonEmpty("description", description);
@@ -1126,6 +1137,8 @@ public class DownloadManager {
        values.put(Downloads.Impl.COLUMN_MEDIA_SCANNED,
                (isMediaScannerScannable) ? Request.SCANNABLE_VALUE_YES :
                        Request.SCANNABLE_VALUE_NO);
        values.put(Downloads.Impl.COLUMN_VISIBILITY, (showNotification) ?
                Request.VISIBILITY_VISIBLE_NOTIFY_ONLY_COMPLETION : Request.VISIBILITY_HIDDEN);
        Uri downloadUri = mResolver.insert(Downloads.Impl.CONTENT_URI, values);
        if (downloadUri == null) {
            return -1;
+11 −0
Original line number Diff line number Diff line
@@ -527,6 +527,17 @@ public final class Downloads {
            return (status >= 500 && status < 600);
        }

        /**
         * this method determines if a notification should be displayed for a
         * given {@link #COLUMN_VISIBILITY} value
         * @param visibility the value of {@link #COLUMN_VISIBILITY}.
         * @return true if the notification should be displayed. false otherwise.
         */
        public static boolean isNotificationToBeDisplayed(int visibility) {
            return visibility == DownloadManager.Request.VISIBILITY_VISIBLE_NOTIFY_COMPLETED ||
                    visibility == DownloadManager.Request.VISIBILITY_VISIBLE_NOTIFY_ONLY_COMPLETION;
        }

        /**
         * Returns whether the download has completed (either with success or
         * error).