Merge "Clarify the process to manage devices with AOSP."
diff --git a/scripts/build.py b/scripts/build.py
index 1325a38..12bcb98 100755
--- a/scripts/build.py
+++ b/scripts/build.py
@@ -1,5 +1,19 @@
 #!/usr/bin/env python
 
+# Copyright (C) 2011 The Android Open Source Project
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+#      http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
 import os
 import glob
 import shutil
@@ -20,7 +34,7 @@
   for line in open(raw_file, 'r'):
     if '#' in line:
       return line.strip(' #\n')
-  return ""
+  return ''
 
 
 # directory to compile the site to (will be clobbered during build!)
@@ -31,36 +45,45 @@
 TEMPLATE_DIR = 'templates'
 
 # filenames of templates to load, in order
-TEMPLATE_LIST = ['includes', 'header', 'sidebar', 'main', 'footer'] 
+TEMPLATE_LIST = ['includes', 'header', 'sidebar', 'main', 'footer']
 
-t = ""
+# Step 1, concatenate the template pieces into a single template string
+t = ''
 for f in TEMPLATE_LIST:
   t += open(os.path.join(TEMPLATE_DIR, f), 'r').read()
 template = string.Template(t)
 
+# Step 2, rm -rf HTML_DIR if it exists, and then re-create it
 if os.path.exists(HTML_DIR):
   shutil.rmtree(HTML_DIR)
 
 os.mkdir(HTML_DIR)
 
+# Step 3, recursively mirror SRC_DIR to HTML_DIR, directory by directory, translating *.md
 category = 'home'
 parents = {}
 for curdir, subdirs, files in os.walk(SRC_DIR):
   print 'Processing %s...'  % (curdir,),
-  outdir = [x for x in curdir.split(os.path.sep) if x]
+  # Step A: split path, and update cached category name if needed
+  curdir = os.path.normpath(curdir)
+  outdir = curdir.split(os.path.sep)
   outdir[0] = HTML_DIR
   if len(outdir) == 2:
     category = outdir[-1]
   outdir = os.path.join(*outdir)
 
+  # Step B: mirror the hierarchy of immediate subdirectories
   for subdir in subdirs:
     os.mkdir(os.path.join(outdir, subdir))
 
+  # Step C: cache the translated sidebars, keyed by parent dir, so we can do sidebar inheritance
+  # FIXME: make this depth-agnostic, perhaps by caching all sidebars and moving the resolution
+  # FIXME: complexity out of the datastructure and into the resolution algorithm.
   parentdir = os.path.dirname(curdir)
   if parentdir in parents:
     parent = parents[parentdir]
   else:
-    parent = ('', '')
+    parent = ('', '', '')
 
   if 'sidebar.md' in files:
     sidebar = markdown(os.path.join(curdir, 'sidebar.md'))
@@ -74,19 +97,30 @@
   else:
     sidebar2 = parent[1]
 
-  parents[curdir] = (sidebar, sidebar2)
+  if 'sidebar3.md' in files:
+    sidebar3 = markdown(os.path.join(curdir, 'sidebar3.md'))
+    del files[files.index('sidebar3.md')]
+  else:
+    sidebar3 = parent[2]
 
+  parents[curdir] = (sidebar, sidebar2, sidebar3)
+
+  # Step D: mirror all non-*.md files, and translate (file).md files into (file).html
   for f in files:
     print ' .',
+    # Note that this "absolute" filename has a root at SRC_DIR, not "/"
+    absfilename = os.path.join(curdir, f)
+
     if f.endswith('.md'):
-      main = markdown(os.path.join(curdir, f))
+      main = markdown(absfilename)
       final = template.safe_substitute(main=main, sidebar=sidebar, sidebar2=sidebar2, \
-          category=category, title=get_title(os.path.join(curdir, f)))
-    
+          sidebar3=sidebar3, category=category, title=get_title(absfilename))
+
       html = file(os.path.join(outdir, f.replace('.md', '.html')), 'w')
       html.write(final)
     else:
-      shutil.copy(os.path.join(curdir, f), os.path.join(outdir, f))
+      shutil.copy(absfilename, os.path.join(outdir, f))
   print
 
 print 'Done.'
+
diff --git a/scripts/micro-httpd.py b/scripts/micro-httpd.py
index 31ad1ea..9292dab 100755
--- a/scripts/micro-httpd.py
+++ b/scripts/micro-httpd.py
@@ -1,4 +1,4 @@
-#!/usr/bin/env python2.4
+#!/usr/bin/env python
 
 # Copyright (C) 2010 The Android Open Source Project
 #
@@ -14,10 +14,14 @@
 # See the License for the specific language governing permissions and
 # limitations under the License.
 
-import SimpleHTTPServer, SocketServer, os
+import SimpleHTTPServer
+import SocketServer
+import os
+
 PORT = int(os.environ.get('HTTP_PORT', 8080))
 Handler = SimpleHTTPServer.SimpleHTTPRequestHandler
-httpd = SocketServer.TCPServer(("0.0.0.0", PORT), Handler)
+httpd = SocketServer.TCPServer(('0.0.0.0', PORT), Handler)
 httpd.allow_reuse_address = True
-print "Serving on port %d" % PORT
+print 'Serving on port %d' % PORT
 httpd.serve_forever()
+
diff --git a/src/compatibility/4.0/versions.md b/src/compatibility/4.0/versions.md
index 45ddd0e..1b70297 100644
--- a/src/compatibility/4.0/versions.md
+++ b/src/compatibility/4.0/versions.md
@@ -32,3 +32,5 @@
 - 4.0
 
 - 4.0.1
+
+- 4.0.3
diff --git a/src/compatibility/cts-development.md b/src/compatibility/cts-development.md
index a7ba7af..04adb00 100644
--- a/src/compatibility/cts-development.md
+++ b/src/compatibility/cts-development.md
@@ -19,7 +19,7 @@
 ## Initializing Your Repo Client ##
 
 Follow the [instructions](/source/downloading.html)
-to get and build the Android source code but specify `-b android-4.0.1_r1`
+to get and build the Android source code but specify `-b android-4.0.3_r1`
 when issuing the `repo init` command. This assures that your CTS
 changes will be included in the next CTS release and beyond.
 
diff --git a/src/compatibility/downloads.md b/src/compatibility/downloads.md
index c491962..5894e5c 100644
--- a/src/compatibility/downloads.md
+++ b/src/compatibility/downloads.md
@@ -19,15 +19,15 @@
 Thanks for your interest in Android Compatibility! The links below allow
 you to access the key documents and information.
 
-## Android 4.0 ##
+## Android 4.0.3 ##
 
-Android 4.0 is the release of the development milestone code-named
-Ice Cream Sandwich. Android 4.0 is the current version of Android. Source code for
-Android 4.0 is found in the 'android-4.0.1_r1' branch in the open-source tree.
+Android 4.0.3 is the release of the development milestone code-named
+Ice Cream Sandwich. Android 4.0.3 is the current version of Android. Source code for
+Android 4.0.3 is found in the 'android-4.0.3_r1' branch in the open-source tree.
 
 - [Android 4.0 Compatibility Definition Document (CDD)](4.0/android-4.0-cdd.pdf)
-- [Android 4.0 R1 Compatibility Test Suite (CTS)](http://dl.google.com/dl/android/cts/android-cts-4.0_r1-linux_x86-arm.zip)
-- [Android 4.0 R1 CTS Verifier](http://dl.google.com/dl/android/cts/android-cts-verifier-4.0_r1-linux_x86-arm.zip)
+- [Android 4.0.3 R1 Compatibility Test Suite (CTS)](http://dl.google.com/dl/android/cts/android-cts-4.0.3_r1-linux_x86-arm.zip)
+- [Android 4.0.3 R1 CTS Verifier](http://dl.google.com/dl/android/cts/android-cts-verifier-4.0.3_r1-linux_x86-arm.zip)
 
 ## Android 2.3 ##
 
@@ -36,7 +36,7 @@
 the open-source tree.
 
 - [Android 2.3 Compatibility Definition Document (CDD)](2.3/android-2.3.3-cdd.pdf)
-- [Android 2.3 R10 Compatibility Test Suite (CTS)](http://dl.google.com/dl/android/cts/android-cts-2.3_r10-linux_x86-arm.zip)
+- [Android 2.3 R11 Compatibility Test Suite (CTS)](http://dl.google.com/dl/android/cts/android-cts-2.3_r11-linux_x86-arm.zip)
 - [Android 2.3 R2 CTS Verifier](http://dl.google.com/dl/android/cts/android-cts-verifier-2.3_r2-linux_x86-armv5.zip)
 
 ## Android 2.2 ##
diff --git a/src/compatibility/index.md b/src/compatibility/index.md
index 7044f23..da38918 100644
--- a/src/compatibility/index.md
+++ b/src/compatibility/index.md
@@ -28,9 +28,7 @@
 them.
 
 These pages describe the Android Compatibility Program and how to get
-access to compatibility information and tools. The latest version of the
-Android source code and compatibility program is 4.0, which 
-corresponded to the Ice Cream Sandwich branch.
+access to compatibility information and tools.
 
 ## Why build compatible Android devices? ##
 
diff --git a/src/source/build-numbers.md b/src/source/build-numbers.md
index 42117de..4862e42 100644
--- a/src/source/build-numbers.md
+++ b/src/source/build-numbers.md
@@ -105,8 +105,9 @@
 GRK39F | android-2.3.6_r1   | Nexus One, Nexus S
 GWK74  | android-2.3.7_r1   | latest Gingerbread version, Nexus S 4G
 ITL41D | android-4.0.1_r1   | earliest IceCreamSandwich version, Galaxy Nexus
+ITL41D | android-4.0.1_r1.1 | Galaxy Nexus
 ITL41F | android-4.0.1_r1.2 | Galaxy Nexus
-ICL53F |                    | Galaxy Nexus
+ICL53F | android-4.0.2_r1   | Galaxy Nexus
 IML74K | android-4.0.3_r1   | latest IceCreamSandwich version, Nexus S
 
 The branches froyo, gingerbread, ics-mr0, ics-mr1, represent development
diff --git a/src/source/initializing.md b/src/source/initializing.md
index 138e86f..3660c16 100644
--- a/src/source/initializing.md
+++ b/src/source/initializing.md
@@ -20,7 +20,7 @@
 
 *Note: The source download is approximately 6GB in size.
 You will need 25GB free to complete a single build, and
-up to 80GB (or more) for a full set of builds.*
+up to 90GB (or more) for a full set of builds.*
 
 For an overview of the entire code-review and code-update process, see [Life of a Patch](life-of-a-patch.html).
 
@@ -42,6 +42,8 @@
 
  - Python 2.5 -- 2.7, which you can download from [python.org](http://www.python.org/download/).
 
+ - GNU Make 3.81 -- 3.82, which you can download from [gnu.org](http://ftp.gnu.org/gnu/make/),
+
  - JDK 6 if you wish to build Gingerbread or newer; JDK 5 for Froyo or older.  You can download both from [java.sun.com](http://java.sun.com/javase/downloads/).
 
  - Git 1.7 or newer. You can find it at [git-scm.com](http://git-scm.com/download).
diff --git a/src/source/known-issues.md b/src/source/known-issues.md
new file mode 100644
index 0000000..9f5e872
--- /dev/null
+++ b/src/source/known-issues.md
@@ -0,0 +1,36 @@
+<!--
+   Copyright 2010 The Android Open Source Project
+
+   Licensed under the Apache License, Version 2.0 (the "License");
+   you may not use this file except in compliance with the License.
+   You may obtain a copy of the License at
+
+       http://www.apache.org/licenses/LICENSE-2.0
+
+   Unless required by applicable law or agreed to in writing, software
+   distributed under the License is distributed on an "AS IS" BASIS,
+   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+   See the License for the specific language governing permissions and
+   limitations under the License.
+-->
+
+# Known Issues #
+
+Even with our best care, small problems sometimes slip in. This page keeps
+track of the known issues around using the Android source code.
+
+## Black Gingerbread Emulator ##
+
+**Symptom**: The emulator built directly from the gingerbread branch
+doesn't start and stays stuck on a black screen.
+
+**Cause**: The gingerbread branch uses version R7 of the emulator,
+which doesn't have all the features necessary to run recent versions
+of gingerbread.
+
+**Fix**: Use version R12 of the emulator, and a newer kernel that matches
+those tools. No need to do a clean build.
+
+    $ repo forall external/qemu -c git checkout aosp/tools_r12
+    $ make
+    $ emulator -kernel prebuilt/android-arm/kernel/kernel-qemu-armv7
diff --git a/src/source/sidebar.md b/src/source/sidebar.md
index 31d782b..362eb04 100644
--- a/src/source/sidebar.md
+++ b/src/source/sidebar.md
@@ -4,6 +4,7 @@
 - [Downloading the Source](downloading.html)
 - [Building and Running](building.html)
 - [Building for Devices](building-devices.html)
+- [Known Issues](known-issues.html)
 
 # Navigating the Source #
 
diff --git a/templates/sidebar b/templates/sidebar
index 16e8000..748a2fc 100644
--- a/templates/sidebar
+++ b/templates/sidebar
@@ -1,4 +1,4 @@
 <div id=sidebar>
-  $sidebar$sidebar2
+  $sidebar$sidebar2$sidebar3
 </div>