Non-existent Notification of Queued Process (NNQP)

ECn Categories > Non-Existent Result Notification (NRN) > Non-existent Notification of Queued Process (NNQP)

There was an unexpected background process which produced a result, and it was not informed to the user.

Amount of Issues App List
6 (A4) Galaxy Zoo, (A14) Wikimedia Commons, (A19) K-9 Mail, (A44) Materialistic - Hacker News

Examples

Galaxy Zoo

Category: Education
v 1.69
Scenario: To turn on the internet after downloading an image without internet connection
This video shows an example of a Unexpected result from background process. At the 8th second the user while is seeing an image click on a menu item that allows him to download the current image. As it can be seen in the image, when this menu item is clicked a new download notification is shown in the status bar for the download process and result. Nevertheless, at 22nd second the user makes the same process but whitout connection, in this moment the notification is created in the status bar but disapear after 2 second. After trying to reproduce the process without sucess the user at 44th second enables the connection and after been stablished try again to download the image, however when the process is finished there are 4 download notifications in the status bar. Therefore the downloads that were requested without connection were resolved and the user never knew that this download request remains until they are solved.

The following code snippets show the classes and files that are involved in the generation of the previuos issue.

In order to see how this error is generated, we need to review all the flow event. First, as it can be seen in the video the user select to download an image and that menu item triggers the “doDownloadImage” method.

app/src/main/java/com/murrayc/galaxyzoo/app/SubjectFragment.java

        private void doDownloadImage() {

Inside that method happens 3 important events, the first one is at line 196 where the download notification is created. The second one is at line 204 where the first approach to create a new “DownloadManager” is made, following the documentation that states “Instances of this class must be obtained using Context.getSystemService(Class) with the argument DownloadManager.class or Context.getSystemService(String) with the argument Context.DOWNLOAD_SERVICE” as it can be seen at line 204

app/src/main/java/com/murrayc/galaxyzoo/app/SubjectFragment.java

        final DownloadManager.Request request = new DownloadManager.Request(uri);
196.    request.setNotificationVisibility(DownloadManager.Request.VISIBILITY_VISIBLE_NOTIFY_COMPLETED);

        final Activity activity = getActivity();
        if (activity == null) {
            Log.error("doDownloadImage(): activity was null.");
            return;
        }

204.    final Object systemService = activity.getSystemService(Context.DOWNLOAD_SERVICE);
        if (systemService == null || !(systemService instanceof DownloadManager)) {
            Log.error("doDownloadImage(): Could not get DOWNLOAD_SERVICE.");
            return;
        }

Finally at line 210 the “DownloadManager” object is parsed and at line 211 the new request is queued in order to be resolve. Nevertheless, from the documentation we can now that the “DownloadManager” will perform several attemps to resolve the request. So at this point we know that there is a missing notification to the user to let him know that the request that he made without connectivity are still in queue in order to let it know that only need to ask for the content once

app/src/main/java/com/murrayc/galaxyzoo/app/SubjectFragment.java

        final DownloadManager downloadManager = (DownloadManager)systemService;
211.    downloadManager.enqueue(request);