Merge "Refactor restorePermissionState() locking."