If you want to browse the android source code and want to check something specific you can do so from github https://github.com/android . But if you want to download the complete source code then the procedure is not going to be simple.
Complete Android source code could be 18GB or more depending upon the version you want to download. Calculate the download time based on the download speed which you have.In order to download you have to follow the procedure provided at http://source.android.com/source/downloading.html keeping these points in mind for Ubuntu
(a) Use the sudo sysctl -w net.ipv4.tcp_window_scaling=0 before running the repo sync command
(b) While doing repo init you can specify the tag name or release which you want to download. These tag names are present at http://source.android.com/source/build-numbers.html#source-code-tags-and-builds .e.g. For Kitkat version you need to specify android-4.4_r1.1 with -b option as this is the latest version as of today.
(c) Instead of using repo sync use repo sync -j4 command as this will help in downloading multiple blocks in parallel. Both these points are mentioned on the Google page but after the download section.
(d) After you run the “repo sync -j4″ command check whether the new directories are getting created at WORKING_DIRECTORY where you have run the command. If the settings are not proper then you won’t see any directory getting created and need to stop immediately, Otherwise after hours of download you will not see the actual source code. Please note that the actual source code will not be present in the .repo
(e) I used Ubuntu 12.04 LTS to download the source code but it failed twice after showing progress of 99%. Then I used the Ubuntu LTS (10.04) which is being used by Android development team for routine testing and I was able to download the complete source code. You can try it on Ubuntu 12.04 LTS but make sure to check that new directories/files are getting created after you run the repo sync command.
If you want to build the Android source code also then you need to do setup initialization also and you should start from http://source.android.com/source/initializing.html page