Avoid exceptions when calendar and contacts sync packages do not exist.

PackageManagerService will NPE when adjusting permissions if no calendar
or contacts sync packages exist. This commit adds simple null checks to
avoid this.

(cherry pick from Ia6db335d86c514a5b4f3b438f72c8d5375066178)
Bug: 138449617
Test: m -j && emulator&

Change-Id: Iaca027b92b64c40ca2fae2942c67632b5ad3cccc
1 file changed