When a user updates their BlackBerry® Device Software or transfers phones, there is a period of time where the device applications are installed and the device boots up, but the application databases are not yet restored. Applications which start automatically will be started before the Backup/Restore process has completed restoring their Persistent data. This includes RMS databases and the Application Permissions database.
Applications which start automatically and test for their permissions will frequently request permissions from the user again. The result is a poor user experience as the user is prompted to save permissions for each app they had installed, and the prompts are unnecessary. APIs exist to determine if a database restoration is happening, and to allow the application to wait until it is complete before proceeding.
The sample application attached does a permission check at the time the device starts. If the permissions are not as desired, the thread waits for a BlackBerry® Desktop Manager database restoration. If one starts in a short timeframe, the thread will wait until the restoration is complete before checking the permission again. After waiting for a sync to start, and complete if so, it will check and request permissions again if necessary.
The SyncManager API is what provides the functionality used in this example.
An implementation of the SyncEventListener interface is connected as follows: