The phenomenon of

When downloading files using DownloadProvider on some Android PHONES, the notification bar does not display the download progress bar. This problem occurs on different versions of the same phone

solution

Since using DownloadProvider to send notifications involves the application, DownloadProvider, NotificationManager, and SystemUI. They need to be eliminated one by one

  1. The app, and the code that the app is using, and the progress bar is not displayed in the notification bar when you download the app on Google Play should not be related to the app
  2. The DownloadProvider, which can normally display the notification progress bar, is used to replace the DownloadProvider
  3. NotificationManager and SystemUI, both of which need to be debugged, but the problem is that the code is too new, the version is too old, and direct compilation will cause errors and failure to boot

Difficult to solve

The difficulty is that the version in question is too old, and the latest version doesn’t have the problem. Therefore, you need to go back to the code before the old version was compiled. There are two ways to do this. One is to judge by the time, that is, the compilation time of the version in the phone, and the other is the tag after the release of the version

# Roll back by compile time
repo forall -c 'commitID=`git log --before "2019-04-01 07:00" -1 --pretty=format:"%H"`; git reset --hard $commitID'
# Roll back using tag
Git tag = git tag = git tag = git tagRepo forall -c git checkout -b new_branch_xxx xxx_halo_2.1.2 _L1_20181220Copy the code

Problem orientation

This application will cancel the Notification of the DownloadProvider and do not know how it obtains the key of the Notification. The specific cancellation process is as follows:

GoogleRestore->snoozeNotificationUntilContextFromListener()->snoozeNotificationInt()->mHandler.post(new SnoozeNotificationRunnable(key, duration, snoozeCriterionId))->snoozeLocked()->snoozeNotificationLocked()->cancelNotificationLocked()
Copy the code

There are two things that need a little attention:

  1. GoogleRestore cancelates with REASON_SNOOZED, which is supposed to be displayed as a notification delay
  2. SnoozeNotificationUntilContextFromListener () this is to define in INotificationManager, does not show in the SDK, If you can call getService() in NotificationManger through reflection, you actually have the opportunity to call this method.

conclusion

I hate GMS and Google