Merge "Match the tutorial documentation more closely"
diff --git a/apps/CustomLocale/Android.mk b/apps/CustomLocale/Android.mk
index 275207f..4b8badc 100644
--- a/apps/CustomLocale/Android.mk
+++ b/apps/CustomLocale/Android.mk
@@ -1,7 +1,7 @@
 LOCAL_PATH:= $(call my-dir)
 include $(CLEAR_VARS)
 
-LOCAL_MODULE_TAGS := user
+LOCAL_MODULE_TAGS := optional
 
 LOCAL_SRC_FILES := $(call all-subdir-java-files)
 
diff --git a/apps/Development/AndroidManifest.xml b/apps/Development/AndroidManifest.xml
index 07a4213..823130b 100644
--- a/apps/Development/AndroidManifest.xml
+++ b/apps/Development/AndroidManifest.xml
@@ -17,28 +17,29 @@
 <manifest xmlns:android="http://schemas.android.com/apk/res/android"
         package="com.android.development"
         android:versionCode="1" android:versionName="1.0">
-    <uses-permission android:name="android.permission.WRITE_SETTINGS" />
+    <uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
+    <uses-permission android:name="android.permission.CHANGE_NETWORK_STATE" />
+    <uses-permission android:name="android.permission.CHANGE_WIFI_STATE" />
+    <uses-permission android:name="android.permission.DEVICE_POWER" />
     <uses-permission android:name="android.permission.DUMP" />
-    <uses-permission android:name="android.permission.SET_PREFERRED_APPLICATIONS" />
-    <uses-permission android:name="android.permission.RESTART_PACKAGES" />
-    <uses-permission android:name="android.permission.SET_ANIMATION_SCALE" />
-    <uses-permission android:name="android.permission.SET_PROCESS_LIMIT" />
-    <uses-permission android:name="android.permission.SET_ALWAYS_FINISH" />
-    <uses-permission android:name="android.permission.SET_DEBUG_APP" />
+    <uses-permission android:name="android.permission.GET_ACCOUNTS" />
     <uses-permission android:name="android.permission.HARDWARE_TEST" />
     <uses-permission android:name="android.permission.INTERNET" />
+    <uses-permission android:name="android.permission.MANAGE_ACCOUNTS" />
+    <uses-permission android:name="android.permission.REBOOT" />
+    <uses-permission android:name="android.permission.KILL_BACKGROUND_PROCESSES" />
+    <uses-permission android:name="android.permission.SET_ALWAYS_FINISH" />
+    <uses-permission android:name="android.permission.SET_ANIMATION_SCALE" />
+    <uses-permission android:name="android.permission.SET_DEBUG_APP" />
+    <uses-permission android:name="android.permission.SET_PREFERRED_APPLICATIONS" />
+    <uses-permission android:name="android.permission.SET_PROCESS_LIMIT" />
+    <uses-permission android:name="android.permission.USE_CREDENTIALS" />
+    <uses-permission android:name="android.permission.WAKE_LOCK" />
+    <uses-permission android:name="android.permission.WRITE_SETTINGS" />
+    <uses-permission android:name="com.google.android.googleapps.permission.ACCESS_GOOGLE_PASSWORD" />
     <uses-permission android:name="com.google.android.googleapps.permission.GOOGLE_AUTH" />
     <uses-permission android:name="com.google.android.googleapps.permission.GOOGLE_AUTH.ALL_SERVICES" />
     <uses-permission android:name="com.google.android.googleapps.permission.GOOGLE_AUTH.YouTubeUser" />
-    <uses-permission android:name="com.google.android.googleapps.permission.ACCESS_GOOGLE_PASSWORD" />
-    <uses-permission android:name="android.permission.GET_ACCOUNTS" />
-    <uses-permission android:name="android.permission.USE_CREDENTIALS" />
-    <uses-permission android:name="android.permission.MANAGE_ACCOUNTS" />
-    <uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
-    <uses-permission android:name="android.permission.CHANGE_WIFI_STATE" />
-    <uses-permission android:name="android.permission.WAKE_LOCK" />
-    <uses-permission android:name="android.permission.DEVICE_POWER" />
-    <uses-permission android:name="android.permission.CHANGE_NETWORK_STATE" />
 
     <application android:label="Dev Tools"
             android:icon="@drawable/ic_launcher_devtools">
diff --git a/apps/Development/res/layout/bad_behavior.xml b/apps/Development/res/layout/bad_behavior.xml
index 62a7245..bbc5b9f 100644
--- a/apps/Development/res/layout/bad_behavior.xml
+++ b/apps/Development/res/layout/bad_behavior.xml
@@ -19,6 +19,11 @@
     android:layout_width="fill_parent"
     android:layout_height="fill_parent">
 
+    <Button android:id="@+id/bad_behavior_crash_system"
+            android:layout_width="wrap_content"
+            android:layout_height="wrap_content"
+            android:text="@string/bad_behavior_crash_system_label" />
+
     <Button android:id="@+id/bad_behavior_crash_main"
             android:layout_width="wrap_content"
             android:layout_height="wrap_content"
@@ -29,6 +34,11 @@
             android:layout_height="wrap_content"
             android:text="@string/bad_behavior_crash_thread_label" />
 
+    <Button android:id="@+id/bad_behavior_wtf"
+            android:layout_width="wrap_content"
+            android:layout_height="wrap_content"
+            android:text="@string/bad_behavior_wtf_label" />
+
     <Button android:id="@+id/bad_behavior_anr"
             android:layout_width="wrap_content"
             android:layout_height="wrap_content"
diff --git a/apps/Development/res/layout/gls_tester.xml b/apps/Development/res/layout/gls_tester.xml
deleted file mode 100644
index fbd4549..0000000
--- a/apps/Development/res/layout/gls_tester.xml
+++ /dev/null
@@ -1,111 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!-- Copyright (C) 2007 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.
--->
-
-<LinearLayout
-    xmlns:android="http://schemas.android.com/apk/res/android"
-    android:orientation="vertical"
-    android:layout_width="fill_parent"
-    android:layout_height="fill_parent">
-
-    <LinearLayout
-       android:orientation="horizontal"
-       android:layout_width="fill_parent"
-       android:layout_height="wrap_content">
-
-      <Button
-         android:id="@+id/prefer_hosted"
-         android:layout_width="wrap_content"
-         android:layout_height="wrap_content"
-         android:text="@string/gls_tester_prefer_hosted"/>
-
-      <Button
-         android:id="@+id/require_google"
-         android:layout_width="wrap_content"
-         android:layout_height="wrap_content"
-         android:text="@string/gls_tester_require_google"/>
-
-      <Button
-         android:id="@+id/get_accounts"
-         android:layout_width="wrap_content"
-         android:layout_height="wrap_content"
-         android:text="@string/gls_tester_get_accounts"/>
-
-      <Button
-         android:id="@+id/clear"
-         android:layout_width="wrap_content"
-         android:layout_height="wrap_content"
-         android:text="@string/gls_tester_clear"/>
-
-      <Button android:id="@+id/go"
-              android:layout_width="wrap_content"
-              android:layout_height="wrap_content"
-              android:text="@string/gls_tester_go"/>
-
-    </LinearLayout>
-
-    <EditText android:id="@+id/username_edit"
-              android:singleLine="true"
-              android:layout_width="fill_parent"
-              android:layout_height="wrap_content"
-              android:minWidth="250dip"
-              android:scrollHorizontally="true"
-              android:capitalize="none"
-              android:autoText="false"/>
-
-    <LinearLayout android:orientation="horizontal"
-                  android:layout_width="fill_parent"
-                  android:layout_height="wrap_content">
-
-      <CheckBox android:id="@+id/do_notification"
-                android:layout_width="wrap_content"
-                android:layout_height="wrap_content"
-                android:text="@string/gls_tester_do_notification"/>
-
-      <CheckBox android:id="@+id/run_intent"
-                android:layout_width="wrap_content"
-                android:layout_height="wrap_content"
-                android:text="@string/gls_tester_run_intent"/>
-
-    </LinearLayout>
-
-    <LinearLayout
-       android:orientation="horizontal"
-       android:layout_width="fill_parent"
-       android:layout_height="wrap_content">
-
-      <Spinner android:id="@+id/service_spinner"
-               android:layout_width="wrap_content"
-               android:layout_height="wrap_content"
-               android:entries="@array/glstester_services"/>
-
-      <Button
-         android:id="@+id/wipe_passwords"
-         android:layout_width="wrap_content"
-         android:layout_height="wrap_content"
-         android:text="@string/gls_tester_wipe_passwords"/>
-    </LinearLayout>
-
-    <com.android.development.LogTextBox
-        android:id="@+id/text"
-        android:background="@drawable/box"
-        android:layout_width="fill_parent"
-        android:layout_height="0dip"
-        android:layout_weight="1"
-        android:scrollbars="vertical"
-        android:textSize="10dip"
-       />
-
-</LinearLayout>
diff --git a/apps/Development/res/values/strings.xml b/apps/Development/res/values/strings.xml
index cb41087..128144e 100644
--- a/apps/Development/res/values/strings.xml
+++ b/apps/Development/res/values/strings.xml
@@ -195,7 +195,9 @@
     <string name="select_account_to_sync">Select account to sync</string>
 
     <!-- BadBehaviorActivity -->
-    <string name="bad_behavior_crash_main_label">Crash the main thread</string>
-    <string name="bad_behavior_crash_thread_label">Crash an auxiliary thread</string>
+    <string name="bad_behavior_crash_system_label">Crash the system server</string>
+    <string name="bad_behavior_crash_main_label">Crash the main app thread</string>
+    <string name="bad_behavior_crash_thread_label">Crash an auxiliary app thread</string>
+    <string name="bad_behavior_wtf_label">Report a WTF condition</string>
     <string name="bad_behavior_anr_label">Stop responding for 20 seconds (ANR)</string>
 </resources>
diff --git a/apps/Development/src/com/android/development/BadBehaviorActivity.java b/apps/Development/src/com/android/development/BadBehaviorActivity.java
index b8f4721..d397456 100644
--- a/apps/Development/src/com/android/development/BadBehaviorActivity.java
+++ b/apps/Development/src/com/android/development/BadBehaviorActivity.java
@@ -18,8 +18,13 @@
 
 import android.app.Activity;
 import android.os.Bundle;
-import android.widget.Button;
+import android.os.IBinder;
+import android.os.IPowerManager;
+import android.os.RemoteException;
+import android.os.ServiceManager;
+import android.util.Log;
 import android.view.View;
+import android.widget.Button;
 
 public class BadBehaviorActivity extends Activity {
     static class BadBehaviorException extends RuntimeException {
@@ -34,6 +39,19 @@
         super.onCreate(icicle);
         setContentView(R.layout.bad_behavior);
 
+        Button crash_system = (Button) findViewById(R.id.bad_behavior_crash_system);
+        crash_system.setOnClickListener(new View.OnClickListener() {
+            public void onClick(View v) {
+                try {
+                    IBinder b = ServiceManager.getService(POWER_SERVICE);
+                    IPowerManager pm = IPowerManager.Stub.asInterface(b);
+                    pm.crash("Crashed by BadBehaviorActivity");
+                } catch (RemoteException e) {
+                    Log.e("BadBehavior", "Can't call IPowerManager.crash()", e);
+                }
+            }
+        });
+
         Button crash_main = (Button) findViewById(R.id.bad_behavior_crash_main);
         crash_main.setOnClickListener(new View.OnClickListener() {
             public void onClick(View v) { throw new BadBehaviorException(); }
@@ -49,6 +67,11 @@
             }
         });
 
+        Button wtf = (Button) findViewById(R.id.bad_behavior_wtf);
+        wtf.setOnClickListener(new View.OnClickListener() {
+            public void onClick(View v) { Log.wtf("BadBehavior", "Apps Behaving Badly"); }
+        });
+
         Button anr = (Button) findViewById(R.id.bad_behavior_anr);
         anr.setOnClickListener(new View.OnClickListener() {
             public void onClick(View v) {
diff --git a/apps/Development/src/com/android/development/GLSTester.java b/apps/Development/src/com/android/development/GLSTester.java
deleted file mode 100644
index 4995b4d..0000000
--- a/apps/Development/src/com/android/development/GLSTester.java
+++ /dev/null
@@ -1,210 +0,0 @@
-/*
- * Copyright (C) 2007 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.
- */
-
-package com.android.development;
-
-import com.google.android.googleapps.GoogleLoginCredentialsResult;
-import com.google.android.googlelogin.GoogleLoginServiceConstants;
-import com.google.android.googleapps.IGoogleLoginService;
-import com.google.android.googleapps.LoginData;
-
-import android.app.Activity;
-import android.content.ComponentName;
-import android.content.Context;
-import android.content.Intent;
-import android.content.ServiceConnection;
-import android.os.Bundle;
-import android.os.IBinder;
-import android.os.RemoteException;
-import android.util.Log;
-import android.view.View;
-import android.widget.Button;
-import android.widget.CheckBox;
-import android.widget.EditText;
-import android.widget.Spinner;
-
-/**
- * Using a LogTextBox to display a scrollable text area
- * to which text is appended.
- *
- */
-public class GLSTester extends Activity {
-
-    private static final String TAG = "GLSTester";
-
-    private LogTextBox mText;
-
-    private IGoogleLoginService mGls = null;
-    private ServiceConnection mConnection = null;
-
-    CheckBox mDoNotify = null;
-    CheckBox mRunIntent = null;
-    Spinner mService = null;
-    EditText mUsernameEdit = null;
-
-    private class Listener implements View.OnClickListener {
-        public Listener() {
-        }
-
-        public void onClick(View v) {
-            if (mGls == null) {
-                mText.append("mGls is null\n");
-                return;
-            }
-            try {
-                String service = (String) mService.getSelectedItem();
-                mText.append("service: " + service + "\n");
-
-                String account = mUsernameEdit.getText().toString();
-                if (account.length() == 0) {
-                    account = null;
-                }
-                mText.append("account: " + account + "\n");
-                GoogleLoginCredentialsResult result =
-                    mGls.blockingGetCredentials(account, service, mDoNotify.isChecked());
-                mText.append("result account: " + result.getAccount() + "\n");
-                mText.append("result string: " + result.getCredentialsString() + "\n");
-                Intent intent = result.getCredentialsIntent();
-                mText.append("result intent: " + intent + "\n");
-
-                if (intent != null && mRunIntent.isChecked()) {
-                    startActivityForResult(intent, 0);
-                }
-            } catch (RemoteException e) {
-                mText.append("caught exception " + e + "\n");
-            }
-        }
-    }
-
-    @Override
-    protected void onActivityResult(int requestCode, int resultCode, Intent data) {
-        mText.append("resultCode: " + resultCode + "\n");
-        if (data != null) {
-            mText.append("account: " +
-                         data.getStringExtra(GoogleLoginServiceConstants.AUTH_ACCOUNT_KEY) + "\n");
-            mText.append("authtoken: " +
-                         data.getStringExtra(GoogleLoginServiceConstants.AUTHTOKEN_KEY) + "\n");
-        } else {
-            mText.append("intent is null");
-        }
-    }
-
-    @Override
-    protected void onCreate(Bundle savedInstanceState) {
-        super.onCreate(savedInstanceState);
-
-        // Open a connection to the Google Login Service.  Return the account.
-        mConnection = new ServiceConnection() {
-                public void onServiceConnected(ComponentName className, IBinder service) {
-                    mGls = IGoogleLoginService.Stub.asInterface(service);
-                }
-                public void onServiceDisconnected(ComponentName className) {
-                    mGls = null;
-                }
-            };
-
-        bindService(GoogleLoginServiceConstants.SERVICE_INTENT,
-                    mConnection, Context.BIND_AUTO_CREATE);
-
-        setContentView(R.layout.gls_tester);
-
-        mText = (LogTextBox) findViewById(R.id.text);
-        mText.append("Hello, world!\n");
-        Log.v(TAG, "hello, world!");
-
-        mDoNotify = (CheckBox) findViewById(R.id.do_notification);
-        mRunIntent = (CheckBox) findViewById(R.id.run_intent);
-        mRunIntent.setChecked(true);
-
-        mService = (Spinner) findViewById(R.id.service_spinner);
-
-        mUsernameEdit = (EditText) findViewById(R.id.username_edit);
-
-        Button b;
-        b = (Button) findViewById(R.id.require_google);
-        b.setOnClickListener(new View.OnClickListener() {
-            public void onClick(View v) {
-                try {
-                    String account = mGls.getAccount(GoogleLoginServiceConstants.REQUIRE_GOOGLE);
-                    mText.append("REQUIRE_GOOGLE gave: " + account + "\n");
-                    mUsernameEdit.setText(account == null ? "" : account);
-                } catch (RemoteException e) {
-                    mText.append("exception: " + e + "\n");
-                }
-            } });
-
-        b = (Button) findViewById(R.id.prefer_hosted);
-        b.setOnClickListener(new View.OnClickListener() {
-            public void onClick(View v) {
-                try {
-                    String account = mGls.getAccount(GoogleLoginServiceConstants.PREFER_HOSTED);
-                    mText.append("PREFER_HOSTED gave: " + account + "\n");
-                    mUsernameEdit.setText(account == null ? "" : account);
-                } catch (RemoteException e) {
-                    mText.append("exception: " + e + "\n");
-                }
-            } });
-
-
-        b = (Button) findViewById(R.id.get_accounts);
-        b.setOnClickListener(new View.OnClickListener() {
-            public void onClick(View v) {
-                try {
-                    String[] accounts = mGls.getAccounts();
-                    mText.append("account list: (" + accounts.length + " entries)\n");
-                    for (String username: accounts) {
-                        mText.append("  " + username + "\n");
-                    }
-                } catch (RemoteException e) {
-                    mText.append("exception: " + e + "\n");
-                }
-            } });
-
-        b = (Button) findViewById(R.id.clear);
-        b.setOnClickListener(new View.OnClickListener() {
-            public void onClick(View v) {
-                mText.setText("");
-            } });
-
-        b = (Button) findViewById(R.id.go);
-        b.setOnClickListener(new Listener());
-
-        b = (Button) findViewById(R.id.wipe_passwords);
-        b.setOnClickListener(new View.OnClickListener() {
-            public void onClick(View v) {
-                mText.setText("wiping passwords:\n");
-                try {
-                    String[] accounts = mGls.getAccounts();
-                    LoginData ld = new LoginData();
-                    for (String username: accounts) {
-                        ld.mUsername = username;
-                        mGls.updatePassword(ld);
-                        mText.append("  " + username + "\n");
-                    }
-                    mText.append("done.\n");
-                } catch (RemoteException e) {
-                    mText.append("caught exception " + e + "\n");
-                }
-            } });
-
-    }
-
-    @Override
-    protected void onDestroy() {
-        super.onDestroy();
-        unbindService(mConnection);
-    }
-}
diff --git a/apps/Development/src/com/android/development/PackageSummary.java b/apps/Development/src/com/android/development/PackageSummary.java
index 5610559..58ab0f7 100644
--- a/apps/Development/src/com/android/development/PackageSummary.java
+++ b/apps/Development/src/com/android/development/PackageSummary.java
@@ -152,7 +152,7 @@
             mRestart.setOnClickListener(new View.OnClickListener() {
                 public void onClick(View v) {
                     try {
-                        ActivityManagerNative.getDefault().restartPackage(mPackageName);
+                        ActivityManagerNative.getDefault().killBackgroundProcesses(mPackageName);
                     } catch (RemoteException e) {
                     }
                 }
diff --git a/apps/Fallback/Android.mk b/apps/Fallback/Android.mk
index 0a7f5cf..cb4ffc4 100644
--- a/apps/Fallback/Android.mk
+++ b/apps/Fallback/Android.mk
@@ -1,7 +1,7 @@
 LOCAL_PATH:= $(call my-dir)
 include $(CLEAR_VARS)
 
-LOCAL_MODULE_TAGS := user
+LOCAL_MODULE_TAGS := optional
 
 LOCAL_SRC_FILES := $(call all-subdir-java-files)
 
diff --git a/apps/SdkSetup/Android.mk b/apps/SdkSetup/Android.mk
index 7647f15..f2face1 100644
--- a/apps/SdkSetup/Android.mk
+++ b/apps/SdkSetup/Android.mk
@@ -1,6 +1,8 @@
 LOCAL_PATH:= $(call my-dir)
 include $(CLEAR_VARS)
 
+LOCAL_MODULE_TAGS := optional
+
 LOCAL_SRC_FILES := $(call all-subdir-java-files)
 
 LOCAL_PACKAGE_NAME := SdkSetup
diff --git a/cmds/monkey/src/com/android/commands/monkey/Monkey.java b/cmds/monkey/src/com/android/commands/monkey/Monkey.java
index 38e4884..42ca6b1 100644
--- a/cmds/monkey/src/com/android/commands/monkey/Monkey.java
+++ b/cmds/monkey/src/com/android/commands/monkey/Monkey.java
@@ -28,6 +28,7 @@
 import android.os.Process;
 import android.os.RemoteException;
 import android.os.ServiceManager;
+import android.os.SystemProperties;
 import android.view.IWindowManager;
 
 import java.io.BufferedReader;
@@ -226,7 +227,7 @@
         }
 
         public boolean appCrashed(String processName, int pid,
-                String tag, String shortMsg, String longMsg,
+                String shortMsg, String longMsg,
                 long timeMillis, String stackTrace) {
             System.err.println("// CRASH: " + processName + " (pid " + pid + ")");
             System.err.println("// Short Msg: " + shortMsg);
@@ -234,8 +235,6 @@
             System.err.println("// Build Label: " + Build.FINGERPRINT);
             System.err.println("// Build Changelist: " + Build.VERSION.INCREMENTAL);
             System.err.println("// Build Time: " + Build.TIME);
-            System.err.println("// ID: ");  // TODO: This was never set -- remove?
-            System.err.println("// Tag: " + tag);
             System.err.println("// " + stackTrace.replace("\n", "\n// "));
 
             if (!mIgnoreCrashes) {
@@ -338,6 +337,9 @@
      * @param args The command-line arguments
      */
     public static void main(String[] args) {
+        // Set ro.monkey if it's not set yet.
+        SystemProperties.set("ro.monkey", "true");
+
         int resultCode = (new Monkey()).run(args);
         System.exit(resultCode);
     }
diff --git a/docs/copyright-templates/xml.txt b/docs/copyright-templates/xml.txt
index 2a9d2b6..3e94185 100644
--- a/docs/copyright-templates/xml.txt
+++ b/docs/copyright-templates/xml.txt
@@ -4,9 +4,9 @@
      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.
diff --git a/pdk/docs/about/philosophy.jd b/pdk/docs/about/philosophy.jd
index 64d0423..1aa1ccf 100644
--- a/pdk/docs/about/philosophy.jd
+++ b/pdk/docs/about/philosophy.jd
@@ -1,13 +1,9 @@
 page.title=Philosophy and Goals
 doc.type=about
+doc.hidenav=true
 @jd:body
 <p>Android is an open-source software stack for mobile phones and similar
-devices. The Android Open Source Project is tasked with maintaining current
-and developing new versions of the Android software. We believe that users
-deserve to have the source code to the software they run on their devices,
-that developers deserve an open, level playing field for their apps, and that
-OEMs and carriers deserve the freedom to differentiate and innovate. That's
-why we created Android, and made the source code open.</p>
+devices.</p>
 <h2>Origin and Goal</h2>
 <p>Android was originated by a group of companies known as the Open Handset
 Alliance, led by Google. Today, many companies -- both original members of the
@@ -25,20 +21,20 @@
 AOSP is to make sure Android is a success as an end user product.</p>
 <h2>Governance Philosophy</h2>
 <p>The companies that have invested in Android have done so on its merits,
-because we collectively believe that an open platform is necessary. In some
-ways, Android is the purest form of an open-source (as opposed to free
-software) effort: a group of organizations with shared needs has pooled
-resources to collaborate on a single implementation of a shared product. That
-is, the Android philosophy is pragmatic, first and foremost. The objective is
+because we collectively believe that an open platform is necessary. Android is
+intentionally and explicitly an open-source -- as opposed to free software --
+effort: a group of organizations with shared needs has pooled
+resources to collaborate on a single implementation of a shared product. 
+The Android philosophy is pragmatic, first and foremost. The objective is
 a shared product that each contributor can tailor and customize.</p>
-<p>Uncontrolled customization can, of course, lead to incompatibile
+<p>Uncontrolled customization can, of course, lead to incompatible
 implementations. To prevent this, the AOSP also maintains the Android
 Compatibility Program, which spells out what it means to be "Android
 compatible", and what is required of device builders to achieve that status.
 Anyone can (and will!) use the Android source code for any purpose, and we
 welcome all such uses. However, in order to take part in the shared
-ecosystem that we are building around Android, device builders can take
-advantage of the Compatibility Program.</p>
+ecosystem of applications that we are building around Android, device builders
+can take advantage of the Compatibility Program.</p>
 <p>Though Android consists of multiple sub-projects, this is strictly a
 project-management technique. We view and manage Android as a single,
 holistic software product, not a "distribution", specification, or collection
@@ -46,20 +42,19 @@
 Android to a device; they don't implement a specification or curate a
 distribution.</p>
 <h2>How We Work</h2>
-<p>We know that quality does not come without hard work. The
-members of the Android Open Source Project have contributed full-time
-engineers, product managers, UI designers, Quality Assurance, and all the
-other roles required to launch modern devices in the modern marketplace.
-We integrate the open source administration and maintenance into the larger
-product development cycle.</p>
+<p>We know that quality does not come without hard work. Along with many
+partners, Google has contributed full-time engineers, product managers, UI
+designers, Quality Assurance, and all the other roles required to bring
+modern devices to market.  We integrate the open source administration and
+maintenance into the larger product development cycle.</p>
 <p>In a nutshell:</p>
 <ul>
 <li>At any given moment, there is a current latest release of the Android
 platform. This typically takes the form of a branch in the tree.</li>
-<li>AOSP members, device builders, and contributors work with the current
+<li>Device builders and Contributors work with the current
 latest release, fixing bugs, launching new devices, experimenting with new
 features, and so on.</li>
-<li>In parallel, the AOSP members work internally on the next version of the
+<li>In parallel, Google works internally on the next version of the
 Android platform and framework, working according to the product's needs and
 goals. Some of the work from the current latest tree will promoted into these
 releases.</li>
diff --git a/pdk/docs/community/community_toc.cs b/pdk/docs/community/community_toc.cs
index 1f4094e..431aae0 100644
--- a/pdk/docs/community/community_toc.cs
+++ b/pdk/docs/community/community_toc.cs
@@ -5,15 +5,15 @@
 </script>
 <ul>
   <li><h2>Discussion Groups</h2><ul>
-    <li><a href="http://groups.google.com/group/android-platform">android-platform</a></li>
-    <li><a href="http://groups.google.com/group/android-porting">android-porting</a></li>
-    <li><a href="http://groups.google.com/group/android-kernel">android-kernel</a></li>
-    <li><a href="http://groups.google.com/group/repo-discuss">repo-discuss</a></li>
-    <li><a href="http://groups.google.com/group/android-framework">android-framework</a></li>
+    <li><a href="http://groups.google.com/group/android-platform">android-platform</a> <span style="font-size: 75%; font-variant: small-caps">[off-site]</span></li>
+    <li><a href="http://groups.google.com/group/android-porting">android-porting</a> <span style="font-size: 75%; font-variant: small-caps">[off-site]</span></li>
+    <li><a href="http://groups.google.com/group/android-kernel">android-kernel</a> <span style="font-size: 75%; font-variant: small-caps">[off-site]</span></li>
+    <li><a href="http://groups.google.com/group/repo-discuss">repo-discuss</a> <span style="font-size: 75%; font-variant: small-caps">[off-site]</span></li>
+    <li><a href="http://groups.google.com/group/android-framework">android-framework</a> <span style="font-size: 75%; font-variant: small-caps">[off-site]</span></li>
   </ul></li>
   <li><h2>Other Links</h2><ul>
     <li><a href="<?cs var:toroot ?>community/groups-charter.html">Groups Charter</a></li>
-    <li><a href="http://developer.android.com/community/index.html">App Developer Groups</a></li>
+    <li><a href="http://developer.android.com/community/index.html">App Developer Groups</a> <span style="font-size: 75%; font-variant: small-caps">[off-site]</span></li>
   </ul></li>
 </ul>
 <script type="text/javascript">
diff --git a/pdk/docs/community/index.jd b/pdk/docs/community/index.jd
index 5d219c8..6e6f59e 100644
--- a/pdk/docs/community/index.jd
+++ b/pdk/docs/community/index.jd
@@ -46,16 +46,6 @@
 Subscribe via email: <a href="mailto:android-building+subscribe@googlegroups.com">android-building+subscribe@googlegroups.com</a>
 </li>
 
-<li><b>android-platform</b><br/>
-This list is for developers who want to contribute code to the Android
-user-space projects, such as the core system libraries, the Android
-services, the public APIs, or the built-in applications. Note: contributors
-to the Android kernel should go to the android-kernel list, below.<br/><br/>
-Subscribe using Google Groups: <a
-href="http://groups.google.com/group/android-platform">android-platform</a><br/>
-Subscribe via email: <a href="mailto:android-platform+subscribe@googlegroups.com">android-platform+subscribe@googlegroups.com</a>
-</li>
-
 <li><b>android-porting</b><br/>
 This list is for developers who want to port Android to a new device. If
 you're wondering how to combine the Android source code with your hardware,
@@ -68,6 +58,16 @@
 Subscribe via email: <a href="mailto:android-porting+subscribe@googlegroups.com">android-porting+subscribe@googlegroups.com</a>
 </li>
 
+<li><b>android-platform</b><br/>
+This list is for developers who want to contribute code to the Android
+user-space projects, such as the core system libraries, the Android
+services, the public APIs, or the built-in applications. Note: contributors
+to the Android kernel should go to the android-kernel list, below.<br/><br/>
+Subscribe using Google Groups: <a
+href="http://groups.google.com/group/android-platform">android-platform</a><br/>
+Subscribe via email: <a href="mailto:android-platform+subscribe@googlegroups.com">android-platform+subscribe@googlegroups.com</a>
+</li>
+
 <li><b>android-kernel</b><br/>
 This list is for deveopers who want to contribute to the Linux kernel that
 Android devices use. If you've downloaded the kernel code, if you know how to
diff --git a/pdk/docs/compatibility/compatibility_toc.cs b/pdk/docs/compatibility/compatibility_toc.cs
index 8e16bc8..5688d14 100644
--- a/pdk/docs/compatibility/compatibility_toc.cs
+++ b/pdk/docs/compatibility/compatibility_toc.cs
@@ -13,7 +13,7 @@
 
   <li><h2>More Information</h2><ul>
     <li><a href="<?cs var:toroot ?>downloads/index.html">Downloads</a></li>
-    <li><a href="<?cs var:toroot ?>compatibility/faq.html">FAQ</a></li>
+    <li><a href="<?cs var:toroot ?>faqs.html#compatibility">FAQs</a></li>
     <li><a href="<?cs var:toroot ?>compatibility/contact-us.html">Contact Us</a></li>
   </ul></li>
 </ul>
diff --git a/pdk/docs/compatibility/contact-us.jd b/pdk/docs/compatibility/contact-us.jd
index 432dc22..ba4e887 100644
--- a/pdk/docs/compatibility/contact-us.jd
+++ b/pdk/docs/compatibility/contact-us.jd
@@ -1,27 +1,31 @@
 page.title=Contact Us
 doc.type=compatibility
 @jd:body
-<h3><b>Mailing list</b></h3>
-<div><div>Welcome to the Android compatibility mailing list!<br>
-To get the most out of the mailing list discussions, please do the following before you post:
-<ol><li><b>Read the <a href="http://sites.google.com/a/android.com/opensource/discuss/android-discussion-groups-charter">mailing list charter</a>
-</b>
-that covers the community guidelines.<br><br></li>
-<li><b>Search the mailing list archives</b>
-to see whether your questions have already been discussed.<br><br></li>
-<li><b>Be very clear</b>
-about your question in the subject -- it helps everyone, both those trying to answer your question as well as those who may be looking for information in the future.<br><br></li>
-<li><b>Give plenty of details</b>
-in your post to help others understand your problem. Code or log snippets, as well as pointers to screenshots, may also be helpful. For a great guide to phrasing your questions, read <a href="http://www.google.com/url?q=http%3A%2F%2Fwww.catb.org%2F%257Eesr%2Ffaqs%2Fsmart-questions.html&amp;sa=D&amp;sntz=1&amp;usg=AFrqEzd169OWM-dgsNW_9rDKrOgOJqgpEA">How To Ask Questions The Smart Way</a>
-.
-</li>
-</ol>
-<br>There are two ways to join the Android compatibility mailing list:<br></div>
-<ul><li>Visit the <a href="http://groups.google.com/group/android-compatibility">android-compatibility sign-up page</a>
-on Google Groups, or
-</li>
-<li>Send email to <a href="mailto:android-compatibility-subscribe@googlegroups.com">android-compatibility-subscribe@googlegroups.com</a>
-.
-</li>
-</ul>
-</div>
+<p>Thanks for your interest in Android compatibility!</p>
+<p>If you have questions about Android compatibility that aren't covered in
+this site, you can reach us in one of a few different ways. To get the most
+out of any of these options, please first read "Getting the Most from Our
+Lists" on the <a href="{@docRoot}community/index.html">Community page.</a></p>
+
+<h3>Discussion Group</h3>
+<p>The preferred way to reach us is via the <a
+href="http://groups.google.com/group/android-compatibility">android-compatibility
+mailing list</a>. Use this list for all your compatibility-related questions.
+Please be aware that this is a public forum.</p>
+
+<h3>CTS Technical Questions</h3>
+<p>If you have specific issues with the Compatibility Test Suite that require
+you to disclose information you'd prefer not to be public, you can contact an
+email address we've set up specifically this purpose: <a
+href="mailto:cts@android.com">cts@android.com</a>. This email address is for
+cases that require disclosure of confidential information only, so general
+questions will be directed back to the public android-compatibility
+list. Note also that this list is for specific technical questions; general
+inquiries will also be directed back to the android-compatibility list.</p>
+
+<h3>Private Inquiries</h3>
+<p>Finally, business inquiries about the compatibility program, including
+requests to use branding elements and so on, can be sent to the address <a
+href="mailto:compatibility@android.com">compatibility@android.com</a>. Like
+the CTS address, this address is for specific, private inquiries; general
+questions will be directed back to the android-compatibility list.</p>
diff --git a/pdk/docs/compatibility/cts-intro.jd b/pdk/docs/compatibility/cts-intro.jd
index eee87d4..f1d2359 100644
--- a/pdk/docs/compatibility/cts-intro.jd
+++ b/pdk/docs/compatibility/cts-intro.jd
@@ -6,13 +6,16 @@
 <div>The CTS is an automated testing harness that includes two major software components:</div>
 <ul>
 <li>The CTS test harness runs on your desktop machine and manages test execution.</li>
-<li>Individual test cases are executed on attached mobile devices or on an emulator. The test cases are written in Java as JUnit tests and packaged as Android .apk files to run on the actual device target.</li>
+<li>Individual test cases are executed on attached mobile devices or on an
+emulator. The test cases are written in Java as JUnit tests and packaged as
+Android .apk files to run on the actual device target.</li>
 </ul>
 
 <h3>Workflow</h3>
 <ol>
-<li>Use the bundled CTS release or download the CTS from the Android Open Source Project onto your desktop machine.</li>
-<li>Install and configure the CTS.</li>
+<li>Obtain the CTS source code. The CTS is included in the Android source code available from the Android
+Open Source Project. (To get a copy of that source code, <a
+href="{@docRoot}source/download.html">read this page.</a></li>
 <li>Attach at least one device (or emulator) to your machine.</li>
 <li>Launch the CTS. The CTS test harness loads the test plan onto the attached devices. For each test in the test harness:
     <ul>
@@ -21,8 +24,6 @@
     </ul>
 </li>
 <li>Once all the tests are executed, you can view the test results in your browser and use the results to adjust your design. You can continue to run the CTS throughout your development process.</li>
-<li>If you see test failures, follow the instructions on the <a href="http://sites.google.com/a/android.com/compatibility/compatibility-faq">Compatibility FAQ</a>
-page.</li>
 </ol>
 <div>When you are ready, you can submit the report generated by the CTS to cts@android.com. The report is a .zip archived file that contains XML results and supplemental information such as screen captures.</div>
 
diff --git a/pdk/docs/compatibility/faq.jd b/pdk/docs/compatibility/faq.jd
deleted file mode 100644
index 1eafeea..0000000
--- a/pdk/docs/compatibility/faq.jd
+++ /dev/null
@@ -1,100 +0,0 @@
-page.title=Frequently Asked Questions
-doc.type=compatibility
-@jd:body
-
-<h3>
-The CTS report shows test failures -- what should I do now?
-</h3>
-<div><div><b>Step 1: Get the latest CTS version.</b>
-Make sure you are running the latest version of CTS -- check if your version is the same as the one posted on the <a href="http://sites.google.com/a/android.com/compatibility/download-cts">Downloads</a>
-page. If not, make sure you update to the latest version and re-run CTS. As we find issues in CTS, we push out new versions with fixes to the tests and/or frame-work. Using the latest version minimizes the chances of you facing any CTS specific issues.
-</div>
-<div><br></div>
-<div><b>Step 2: Investigate the CTS source code.</b>
-Make sure you have grabbed the CTS sources provided on the <a href="http://sites.google.com/a/android.com/compatibility/download-cts">Download</a>
-page. Then unzip the CTS report zip$CTS_ROOT/repository/results/start time.zipand opentestResult.xmlin your favorite browser. Find the exception next to the failing test and check the corresponding source file for possible failure causes.</div>
-<div><br></div>
-<div><b>Step 3: Fix the error in your source and re-run CTS.</b>
-Once you have located the cause of failure in your source code, fix it and re-run CTS.
-</div>
-<div><br></div>
-<div><b>Step 4: The test is broken.</b>
-If you think the CTS test is incorrect or is not testing things the right way, shoot a detailed email to cts@android.com with the following information at the minimum - the failing test, why you think the CTS test is broken, your CTS test report and the log generated by your CTS run (text file in the$CTS_ROOT/repository/results/directory corresponding to timestamp of run).</div>
-<div><br></div>
-<h3>
-Android 1.5 CTS r1 known issues
-</h3>
-<div>android.app.cts.ActivityManagerTest#testGetRunningServices - known issue test, waived automatically</div>
-<div>android.graphics.cts.BitmapTest#testCopyPixelsToBuffer - can be an issue if device uses a pixel format like ARGB (4 bytes per pixel)</div>
-<div>tests.api.java.io.OutputStreamWriterTest.test_write$C(OutputStreamWriterTest.java:470) - test breaks in 1.5 r3</div>
-<div><br></div>
-<div><b>The following tests have known issues with non en_US locales:</b>
-</div>
-<div>tests.api.java.io.PrintStreamTest#test_formatLjava_util_Locale_Ljava_lang_String_$Ljava_lang_Object <br>tests.api.java.io.PrintStreamTest#test_printfLjava_util_Locale_Ljava_lang_String_$Ljava_lang_Object <br>tests.api.java.io.PrintWriterTest#test_formatLjava_util_Locale_Ljava_lang_String_$Ljava_lang_Object <br>tests.api.java.io.PrintWriterTest#test_printfLjava_util_Locale_Ljava_lang_String_$Ljava_lang_Object <br>tests.api.java.util.CalendarTest#test_hashCode <br>tests.api.java.util.CalendarTest#test_getFirstDayOfWeek <br>tests.api.java.util.CalendarTest#test_getInstanceLjava_util_Locale <br>tests.api.java.util.CalendarTest#test_getInstanceLjava_util_TimeZoneLjava_util_Locale <br>tests.api.java.util.CalendarTest#test_getMinimalDaysInFirstWeek <br>tests.api.java.util.FormatterTest#test_formatLjava_lang_String$Ljava_lang_Object_ByteShortIntegerLongConversionD <br>tests.api.java.util.FormatterTest#test_formatLjava_lang_String$Ljava_lang_Object_DateTimeConversion <br>tests.api.java.util.FormatterTest#test_formatLjava_lang_String$LBigInteger <br>tests.api.java.util.FormatterTest#test_formatLjava_lang_String$Ljava_lang_Object_BigIntegerPaddingConversion <br>tests.api.java.util.FormatterTest#test_formatLjava_util_LocaleLjava_lang_StringLjava_lang_Object <br>tests.api.java.util.GregorianCalendarTest#test_ConstructorLjava_util_Locale <br>tests.api.java.util.LocaleTest#test_getDisplayCountryLjava_util_Locale <br>tests.api.java.util.LocaleTest#test_getDisplayLanguageLjava_util_Locale <br>tests.api.java.util.LocaleTest#test_getDisplayNameLjava_util_Locale <br>tests.api.java.util.ScannerTest#test_nextDouble <br>tests.api.java.util.ScannerTest#test_nextFloat <br>tests.api.java.util.ScannerTest#test_nextInt <br>tests.api.java.util.ScannerTest#test_nextIntI <br>tests.api.java.util.ScannerTest#test_nextLong <br>tests.api.java.util.ScannerTest#test_nextShortI <br>tests.api.java.util.ScannerTest#test_nextShort <br>tests.api.java.util.ScannerTest#test_nextLongI <br>tests.api.java.util.ScannerTest#test_hasNextIntI <br>tests.api.java.util.ScannerTest#test_hasNextInt <br>tests.api.java.util.ScannerTest#test_hasNextFloat <br>tests.api.java.util.ScannerTest#test_hasNextShortI <br>tests.api.java.util.ScannerTest#test_hasNextShort <br>tests.api.java.util.ScannerTest#test_hasNextLongI <br>tests.api.java.util.ScannerTest#test_hasNextLong <br>tests.api.java.util.ScannerTest#test_hasNextDouble <br>tests.api.java.util.ScannerTest#test_hasNextBigDecimal <br>tests.api.java.util.ScannerTest#test_nextBigDecimal <br>tests.api.java.util.TimeZoneTest#test_getDisplayNameLjava_util_Locale <br>tests.api.java.util.TimeZoneTest#test_getDisplayNameZILjava_util_Locale <br>org.apache.harmony.text.tests.java.text.DateFormatTest#test_getAvailableLocales <br>org.apache.harmony.text.tests.java.text.DecimalFormatSymbolsTest#test_getCurrency <br>org.apache.harmony.text.tests.java.text.DecimalFormatTest#test_formatToCharacterIteratorLjava_lang_Object <br>org.apache.harmony.text.tests.java.text.NumberFormatTest#test_getInstanceLjava_util_Locale <br>org.apache.harmony.text.tests.java.text.NumberFormatTest#test_parseObjectLjava_lang_StringLjava_text_ParsePosition <br>org.apache.harmony.text.tests.java.text.NumberFormatTest#test_getIntegerInstanceLjava_util_Locale <br>org.apache.harmony.text.tests.java.text.NumberFormatTest#test_formatLdouble <br>org.apache.harmony.text.tests.java.text.NumberFormatTest#test_formatLlong <br>org.apache.harmony.text.tests.java.text.NumberFormatTest#test_getCurrencyInstanceLjava_util_Locale <br>org.apache.harmony.text.tests.java.text.NumberFormatTest#test_getNumberInstanceLjava_util_Locale <br>org.apache.harmony.text.tests.java.text.NumberFormatTest#test_getPercentInstanceLjava_util_Locale <br>org.apache.harmony.text.tests.java.text.NumberFormatTest#test_setGroupingUsed <br><br></div>
-<div><br></div>
-<h3>
-Can I remove the 'final' modifier from classes in the Android public APIs and still be an Android-compatible device?
-</h3>
-<div>Let's take the following example, where you want to extend the base Contacts class to create your own version of the class. Android 1.5 supports SDK add-ons that OEMs can create to expose new functionality and platform APIs specific to the phone. However, the SDK add-on architecture does not allow the add-on provider to include their own android.jar Thus, when you expose your new Contacts class (which expects to extend the base Contacts class) developers using your add-on plugin will be unable to compile and run their applications against the standard android.jar containing the *final* Contacts class.</div>
-<div><div><br></div>
-<div>The recommended approach is to create a new class with the specific fields that you want to add and access these fields from the new class. This will not only ensure compatibility but will also ensure a safer and easier update path when the Android schema/implementation changes with future releases. This is illustrated in the following example:</div>
-<div><div><br></div>
-<div><p>public /* final */ class BaseClass {</p>
-<p>/* private */ protected BaseClass() { }</p>
-<br>
-<p>public static final String SOME_FIELD = "base";</p>
-<p>// If this is declared final, WrongApproach.java won't compile.</p>
-<p>// In Contacts.People, it is not declared final (it didn't need to since the class was final)</p>
-<p>public static /* final */ String frungulate() { return "foo"; }</p>
-<p>}</p>
-<br>
-<p>public final class CorrectApproach {</p>
-<p>public static final String SOME_FIELD = "some";</p>
-
-<p>public static final String frungulate() { return "bar"; }</p>
-<p>}</p>
-<br>
-<p>public class WrongApproach extends BaseClass {</p>
-<p>public static final String SOME_FIELD = "some";</p>
-
-<p>public static final String frungulate() { return "bar"; }</p>
-
-<p>public static void main(String[] args) {</p>
-<p>WrongApproach m = new WrongApproach();</p>
-<p>System.out.println(m.SOME_FIELD);</p>
-<p>System.out.println(m.frungulate());</p>
-
-<p>// What should be done...</p>
-<p>System.out.println(CorrectApproach.SOME_FIELD);</p>
-<p>System.out.println(CorrectApproach.frungulate());</p>
-<p>}</p>
-<p>}</p>
-</div>
-<div></div>
-</div>
-</div>
-<div><br></div>
-<h3>
-I see a failure in my report with the comment "A test that was a known failure actually passed. Please check." -- what does this mean?
-</h3>
-<div>A "known failure" test is one that fails when run against our own implementation on G1 or Magic, hence it gets tagged as such and does not count towards your failure. However, if the test suddenly starts passing on your implementation this is not the expected result causing it to show up as a failure then.
-</div>
-<div><br>You should dig into the test source to see whats happening underneath.<br><br></div>
-<h3>
-Why are compass and accelerometer required for Android compatibility?
-</h3>
-<div>Whenever possible, we try to open up hardware options by making the Android software smarter.For example, in Android 1.5 we added an Input Method Framework and soft keyboard so that devices didn't need physical text input devices.The Android <i>Donut</i>
-release will the ability to scale application windows to different densities and resolutions so that devices aren't restricted to 160-180dpi HVGA displays.<br><br>Unfortunately, software can only do so much, and a compass and accelerometer are things Android cannot replace with software.These two input devices are now commonly used by applications.For example, many of the most popular applications in Android Market:<br><br>-<a href="http://www.android.com/market/featured.html#app=skymap"><i>Google Sky Map</i>
-</a>
-uses compass and accelerometer <br>-<a href="http://www.android.com/market/free.html#app=labyrinth"><i>Labyrinth</i>
-</a>
-uses accelerometer <br>-<a href="http://www.android.com/market/free.html#app=bonsaiblast"><i>Bonzai Blast</i>
-</a>
-uses accelerometer <br>-<a href="http://www.android.com/market/featured.html#app=wikitude"><i>Wikitude</i>
-</a>
-uses compass and accelerometer <br>-<a href="http://www.android.com/market/featured.html#app=zagatnru"><i>Zagat</i>
-</a>
-uses compass <br><br>As Market has no way of knowing whether an application uses these controls, we would not be able to filter these out of Android Market for devices which don't have the required hardware.This would create a bad user experience and could hurt the Android ecosystem if developers can no longer rely on these features in handsets, or receive bad reviews from consumers who have devices which can't support the features.<br></div>
-<div><br></div>
-</div>
-</div>
diff --git a/pdk/docs/faqs.jd b/pdk/docs/faqs.jd
new file mode 100644
index 0000000..a55d380
--- /dev/null
+++ b/pdk/docs/faqs.jd
@@ -0,0 +1,325 @@
+page.title=Frequently Asked Questions
+doc.hidenav=true
+@jd:body
+<a name="aosp"></a><h2>Open Source</h2>
+<h3>What is the Android Open Source Project?</h3>
+<p>We use the phrase "Android Open Source Project" or "AOSP" to refer to the
+  people, the processes, and the source code that make up Android.</p>
+<p>The people oversee the project and develop the actual source code. The
+  processes refer to the tools and procedures we use to manage the development
+  of the software. The net result is the source code that you can use to build
+  cell phone and other devices.</p>
+
+<h3>Why did we open the Android source code?</h3>
+<p>Google started the Android project in response to our own experiences
+launching mobile apps. We wanted to make sure that there would always be an
+open platform available for carriers, OEMs, and developers to use to make
+their innovative ideas a reality. We also wanted to make sure that there was no
+central point of failure, so that no single industry player could restrict or control
+the innovations of any other.  The single most important goal of the Android
+Open-Source Project (AOSP) is to make sure that the open-source Android
+software is implemented as widely and compatibly as possible, to everyone's
+benefit.</p>
+<p>You can find more information on this topic at our Project Philosophy page.</p>
+
+<h3>What kind of open-source project is Android?</h3>
+<p>Google oversees the development of the core Android open-source platform,
+  and works to create robust developer and user communities. For the most part
+  the Android source code is licensed under the permissive Apache Software
+  License 2.0, rather than a "copyleft" license. The main reason for this is
+  because our most important goal is widespread adoption of the software, and
+  we believe that the ASL2.0 license best achieves that goal.</p>
+<p>You can find more information on this topic at our Project Philosophy and
+  Licensing pages. </p>
+
+<h3>Why is Google in charge of Android?</h3>
+<p>Launching a software platform is complex. Openness is vital to the
+  long-term success of a platform, since openness is required to attract
+  investment from developers and ensure a level playing field. However, the
+  platform itself must also be a compelling product to end users.</p>
+<p>That's why Google has committed the professional engineering resources
+  necessary to ensure that Android is a fully competitive software platform.
+  Google treats the Android project as a full-scale product development
+  operation, and strikes the business deals necessary to make sure that great
+  devices running Android actually make it to market.</p>
+<p>By making sure that Android is a success with end users, we help ensure the
+  vitality of Android as a platform, and as an open-source project. After all,
+  who wants the source code to an unsuccessful product?</p>
+<p>Google's goal is to ensure a successful ecosystem around Android, but no
+  one is required to participate, of course. We opened the Android source code
+  so anyone can modify and distribute the software to meet their own needs.</p>
+
+<h3>What is Google's overall strategy for Android product development?</h3>
+<p>We focus on releasing great devices into a competitive marketplace, and
+  then incorporate the innovations and enhancements we made into the core
+  platform, as the next version.</p>
+<p>In practice, this means that the Android engineering team typically focuses
+  on a small number of "flagship" devices, and develops the next version of
+  the Android software to support those product launches. These flagship
+  devices absorb much of the product risk and blaze a trail for the broad OEM
+  community, who follow up with many more devices that take advantage of the
+  new features. In this way, we make sure that the Android platform evolves
+  according to the actual needs of real-world devices.</p>
+
+<h3>How is the Android software developed?</h3>
+<p>Each platform version of Android (such as 1.5, 1.6, and so on) has a
+  corresponding branch in the open-source tree. At any given moment, the most
+  recent such branch will be considered the "current stable" branch version.
+  This current stable branch is the one that manufacturers port to their
+  devices. This branch is kept suitable for release at all times.</p>
+<p>Simultaneously, there is also a "current experimental" branch, which is
+  where speculative contributions, such as large next-generation features, are
+  developed. Bug fixes and other contributions can be included in the current
+  stable branch from the experimental branch as appropriate.</p>
+<p>Finally, Google works on the next version of the Android platform in tandem
+  with developing a flagship device. This branch pulls in changes from the
+  experimental and stable branches as appropriate.</p>
+<p>You can find more information on this topic at our Branches Releases
+  page.</p>
+
+<h3>Why are parts of Android developed in private?</h3>
+<p>It typically takes over a year to bring a device to market, but of course
+  device manufacturers want to ship the latest software they can. Developers,
+  meanwhile, don't want to have to constantly track new versions of the
+  platform when writing apps. Both groups experience a tension between
+  shipping products, and not wanting to fall behind.</p>
+<p>To address this, some parts of the next version of Android including the
+  core platform APIs are developed in a private branch. These APIs constitute
+  the next version of Android. Our aim is to focus attention on the current
+  stable version of the Android source code, while we refine the next version
+  of the platform using the flagship Android devices. This allows developers
+  and OEMs to focus on a single version without having to track unfinished
+  future work just to keep up.Other parts of the Android system that aren't
+  related to application compatibility are developed in the open, however.
+  It's our intention to move more of these parts to open development over
+  time.</p>
+
+<h3>When are source code releases made?</h3>
+<p>When they are ready. Some parts of Android are developed in the open, and
+  so that source code is always available. Other parts are developed first in
+  a private tree, and that source code is released when the next platform
+  version is ready.</p>
+<p>In some releases, core platform APIs will be ready far enough in advance
+  that we can push the source code out for an early look in advance of the
+  device's release; however in others, this isn't possible. In all cases, we
+  release the platform source when we feel the version has stabilized enough,
+  and when the development process permits. Releasing the source code is a
+  fairly complex process.</p>
+
+<h3>What is involved in releasing the source code for a new Android version?</h3>
+<p>Releasing the source code for a new version of the Android platform is a
+  significant process. First, the software gets built into a system image for
+  a device, and put through various forms of certification, including
+  government regulatory certification for the regions the phones will be
+  deployed. It also goes through operator testing. This is an important phase
+  of the process, since it helps shake out a lot of software bugs.</p>
+<p>Once the release is approved by the regulators and operators, the
+  manufacturer begins mass producing devices, and we turn to releasing the
+  source code.</p>
+<p>Simultaneous to mass production the Google team kicks off several efforts
+  to prepare the open source release. These efforts include final API changes
+  and documentation (to reflect any changes that were made during
+  qualification testing, for example), preparing an SDK for the new version,
+  and launching the platform compatibility information.</p>
+<p>Also included is a final legal sign-off to release the code into open
+  source. Just as open source contributors are required to sign a Contributors
+  License Agreement attesting to their IP ownership of their contribution,
+  Google too must verify that it is clear to make contributions.</p>
+<p>Starting at the time mass production begins, the software release process
+  usually takes around a month, which often roughly places source code
+  releases around the same time that the devices reach users.</p>
+
+<h3>How does the AOSP relate to the Android Compatibility Program?</h3>
+<p>The Android Open-Source Project maintains the Android software, and
+  develops new versions. Since it's open-source, this software can be used for
+  any purpose, including to ship devices that are not compatible with other
+  devices based on the same source.</p>
+<p>The function of the Android Compatibility Program is to define a baseline
+  implementation of Android that is compatible with third-party apps written
+  by developers. Devices that are "Android compatible" may participate in the
+  Android ecosystem, including Android Market; devices that don't meet the
+  compatibility requirements exist outside that ecosystem.</p>
+<p>In other words, the Android Compatibility Program is how we separate
+  "Android compatible devices" from devices that merely run derivatives of the
+  source code. We welcome all uses of the Android source code, but only
+  Android compatible devices -- as defined and tested by the Android
+  Compatibility Program -- may call themselves "Android" and participate in
+  the Android ecosystem.</p>
+
+<h3>How can I contribute to Android?</h3>
+<p>There are a number of ways you can contribute to Android. You can report
+  bugs, write apps for Android, or contribute source code to the Android
+  Open-Source Project.</p>
+<p>There are some limits on the kinds of code contributions we are willing or
+  able to accept. For instance, someone might want to contribute an
+  alternative application API, such as a full C++-based environment. We would
+  decline that contribution, since Android is focused on applications that run
+  in the Dalvik VM. Alternatively, we won't accept contributions such as GPL
+  or LGPL libraries that are incompatible with our licensing goals.</p>
+<p>We encourage those interested in contributing source code to contact us via
+  the AOSP Community page prior to beginning any work. You can find more
+  information on this topic at the Getting Involved page.</p>
+
+<h3>How do I become an Android committer?</h3>
+<p>The Android Open Source Project doesn't really have a notion of a
+  "committer". All contributions -- including those authored by Google
+  employees -- go through a web-based system known as "gerrit" that's part of
+  the Android engineering process. This system works in tandem with the git
+  source code management system to cleanly manage source code
+  contributions.</p>
+<p>Once submitted, changes need to be accepted by a designated Approver.
+  Approvers are typically Google employees, but the same approvers are
+  responsible for all submissions, regardless of origin.</p>
+<p>You can find more information on this topic at the Submitting Patches
+  page.</p>
+
+<a name="compatibility"></a><h2>Compatibility</h2>
+<h3>What does "compatibility" mean?</h3>
+<p>We define an "Android compatible" device as one that can run any
+  application written by third-party developers using the Android SDK and NDK.
+  We use this as a filter to separate devices that can participate in the
+  Android app ecosystem, and those that cannot. Devices that are properly
+  compatible can seek approval to use the Android trademark. Devices that are
+  not compatible are merely derived from the Android source code and may not
+  use the Android trademark.</p>
+<p>In other words, compatibility is a prerequisite to participate in the
+  Android apps ecosystem. Anyone is welcome to use the Android source code,
+  but if the device isn't compatible, it's not considered part of the Android
+  ecosystem, and irrelevant to developers.</p>
+
+<h3>What is the role of Android Market in compatibility?</h3>
+<p>Devices that are Android compatible may seek to license the Android Market
+  client software. This allows them to become part of the Android app
+  ecosystem, by allowing users to download developers' apps from a catalog
+  shared by all compatible devices. This option isn't available to devices
+  that aren't compatible.</p>
+
+<h3>What kinds of devices can be Android compatible?</h3>
+<p>The Android software can be ported to a lot of different kinds of devices,
+  including some on which third-party apps won't run properly. The Android
+  Compatibility Definition Document (CDD) spells out the specific device
+  configurations that will be considered compatible.</p>
+<p>For example, though the Android source code could be ported to run on a
+  device that doesn't have a camera, the CDD requires that in order to be
+  compatible, all devices must have a camera. This allows developers to rely
+  on a consistent set of device capabilities when writing their apps.</p>
+<p>The CDD will evolve over time to reflect market realities. For instance,
+  the 1.6 CDD only allows cell phones, but the 2.x CDD allows devices to omit
+  telephony hardware, allowing for non-phone devices such as tablet-style
+  music players to be compatible. As we make these changes, we will also
+  augment Android Market to allow developers to retain control over where
+  their apps are available. To continue the telephony example, an app that
+  manages SMS text messages would not be useful on a media player, so Android
+  Market allows the developer to restrict that app exclusively to phone
+  devices.</p>
+
+<h3>If my device is compatible, does it automatically have access to Android Market and branding?</h3>
+<p>Android Market is a service operated by Google. For legal and business
+  reasons, Google isn't able to make that service available in all parts of
+  the world. Similarly, Google is unable to license the Android trademark for
+  use in all cases.</p>
+<p>As a result, achieving compatibility does not automatically entitle a
+  device to include Android Market or use the Android name. Device
+  manufacturers should contact Google to obtain access to those tools.</p>
+
+<h3>If I am not a manufacturer, how can I get Android Market?</h3>
+<p>Android Market is only licensed to handset manufacturers shipping devices.
+  For questions about specific cases, contact
+  android-partnerships@google.com.</p>
+
+<h3>How can I get access to the Google apps for Android, such as Maps?</h3>
+<p>The Google apps for Android, such as YouTube, Google Maps and Navigation,
+  Gmail, and so on are not part of Android, and are licensed separately.
+  Contact android-partnerships@google.com for inquiries related to those
+  apps.</p>
+
+<h3>Is compatibility mandatory?</h3>
+<p>No. The Android Compatibility Program is optional. Since the Android source
+  code is open, anyone can use it to build any kind of device. However, if a
+  manufacturer wishes to use the Android name with their product, or wants
+  access to Android Market, they must first demonstrate that the device is
+  compatible.</p>
+
+<h3>How much does compatibility certification cost?</h3>
+<p>There is no cost to obtain Android compatibility for a device. The
+  Compatibility Test Suite is open-source and available to anyone to use to
+  test a device.</p>
+
+<h3>How long does compatibility take?</h3>
+<p>The process is automatic. The Compatibility Test Suite generates a report
+  that can be provided to Google to verify compatibility. Eventually we intend
+  to provide self-service tools to upload these reports to a public database.</p>
+
+<h3>Who determines what will be part of the compatibility definition?</h3>
+<p>Since Google is responsible for the overall direction of Android as a
+  platform and product, Google maintains the Compatibility Definition Document
+  for each release. We draft the CDD for a new Android version in consultation
+  with a number of OEMs, who provide input on its contents.</p>
+
+<h3>How long will each Android version be supported for new devices?</h3>
+<p>Since Android's code is open-source, we can't prevent someone from using an
+  old version to launch a device. Instead, Google chooses not to license the
+  Android Market client software for use on versions that are considered
+  obsolete. This allows anyone to continue to ship old versions of Android,
+  but those devices won't use the Android name and will exist outside the
+  Android apps ecosystem, just as if they were non-compatible.</p>
+
+<h3>Can a device have a different user interface and still be compatible?</h3>
+<p>The Android Compatibility Program focuses on whether a device can run
+  third-party applications. The user interface components shipped with a
+  device (such as home screen, dialer, color scheme, and so on) does not
+  generally have much effect on third-party apps. As such, device builders are
+  free to customize the user interface as much as they like. The Compatibility
+  Definition Document does restrict the degree to which OEMs may alter the
+  system user interface for the few areas that do impact third-party apps.</p>
+
+<h3>When are compatibility definitions released for new Android versions?</h3>
+<p>Our goal is to release new versions of Android Compatibility Definition
+  Documents (CDDs) once the corresponding Android platform version has
+  converged enough to permit it. Since the CDDs</p>
+
+<h3>How are device manufacturers' compatibility claims validated?</h3>
+<p>There is no validation process for Android device compatibility. However,
+  if the device is to include Android Market, Google will typically validate
+  the device for compatibility before agreeing to license the Market client
+  software.</p>
+
+<h3>What happens if a device that claims compatibility is later found to have compatibility problems?</h3>
+<p>Typically, Google's relationships with Android Market licensees allow us to
+  ask them to release updated system images that fix the problems.</p>
+
+<a name="cts"></a><h2>Compatibility Test Suite</h2>
+<h3>What is the purpose of the CTS?</h3>
+<p>The Compatibility Test Suite is a tool used by device manufacturers to help
+  ensure their devices are compatible, and to report test results for
+  validations. The CTS is intended to be run frequently by OEMs throughout the
+  engineering process to catch compatibility issues early.</p>
+
+<h3>What kinds of things does the CTS test?</h3>
+<p>The CTS currently tests that all of the supported Android strong-typed APIs
+  are present and behave correctly. It also tests other non-API system
+  behaviors such as application lifecycle and performance. We plan to add
+  support in future CTS versions to test "soft" APIs such as Intents as
+  well.</p>
+
+<h3>Will the CTS reports be made public?</h3>
+<p>Yes. While not currently implemented, Google intends to provide web-based
+  self-service tools for OEMs to publish CTS reports so that they can be
+  viewed by anyone. CTS reports can be shared as widely as manufacturers
+  prefer.</p>
+
+<h3>How is the CTS licensed?</h3>
+<p>The CTS is licensed under the same Apache Software License 2.0 that the
+  bulk of Android uses.</p>
+
+<h3>Does the CTS accept contributions?</h3>
+<p>Yes please! The Android Open-Source Project accepts contributions to
+  improve the CTS in the same way as for any other component. In fact,
+  improving the coverage and quality of the CTS test cases is one of the best
+  ways to help out Android.</p>
+
+<h3>Can anyone use the CTS on existing devices?</h3>
+<p>The Compatibility Definition Document requires that compatible devices
+  implement the 'adb' debugging utility. This means that any compatible device
+  -- including ones available at retail -- must be able to run the CTS
+  tests.</p>
diff --git a/pdk/docs/index.jd b/pdk/docs/index.jd
index 1f7b552..217877d 100644
--- a/pdk/docs/index.jd
+++ b/pdk/docs/index.jd
@@ -2,21 +2,27 @@
 home=true
 @jd:body
 <div style="float: left; width: 45%; font-size: 1.3em;">
-  <p>Here you can find the source code and information you need to build an
+  <p>Here you can find the information and source code you need to build an
   Android-compatible device.</p>
-  <p>Android is an open-source software stack for mobile devices, maintained by
-  the Android Open Source Project (AOSP). We believe that users deserve to have
-  the source code to the devices they use on a daily basis, that developers
-  deserve an open and level playing field, and that OEMs and carriers deserve
-  the freedom to create innovative devices. That's why we created Android, and
-  made its source code open.</p>
+  <p>Android is an open-source software stack for mobile devices, and a
+  corresponding open-source project led by Google. We created Android in
+  response to our own experiences launching mobile apps. We wanted to make
+  sure that there was no central point of failure, so that no industry player
+  can restrict or control the innovations of any other.  That's why we
+  created Android, and made its source code open.</p>
   <p><a href="{@docRoot}about/index.html">Learn more &raquo;</a></p>
 </div>
 <div style="float: right; width: 35%;">
-<h3 style="padding-top: 0px;">News crap here</h3>
-<p>This is a test of the emergency broadcast system. This is only a test. Had
-this been an actual emergency, we would have fled in terror, and you would not
-have been informed.</p>
+<h3 style="padding-top: 0px;">News</h3>
+<p><b>Site redesign</b><br/>
+You're looking at the new and improved source.android.com! We've updated
+the layout and site design, and also added new information. We hope you find
+these improvements helpful.</p>
+<p><b>Introducing the Compatibility Program</b><br/>
+We're pleased to introduce the Android Compatibility Program. We've released
+two tools -- the Compatibility Definition Document and the Compatibility Test
+Suite -- to help device manufacturers build compatible devices. Full details
+of the Compatibility Program will be available in the first quarter of 2010.</p>
 </div>
 <img style="float: right; padding-right: 1.5em;" src="{@docRoot}images/home-bugdroid.png" alt="Android Mascot"/>
 
@@ -26,8 +32,9 @@
 <div class="rebox lil" style="float: left; width: 30%; margin: 1em;"> 
   <h2 style="color: white; background-color: #95C0D0; border: 0px;">Get Involved</h2> 
   <div class="p"> 
-    <p><img src="images/lil-wrench.png" alt="" style="margin: 1em;"
-    />Learn how you, for one, can help welcome our new Android overlords.</p> 
+    <p><img src="images/lil-wrench.png" alt="" style="margin: 1em;"/>
+    If you're interested in contributing to the Android source code or helping
+    out with the project in some other way, click here.</p> 
     <p><a href="{@docRoot}source/index.html">More &raquo;</a></p> 
   </div> 
 </div> 
@@ -35,9 +42,9 @@
 <div class="rebox lil" style="float: left; width: 30%; margin: 1em;"> 
   <h2 style="color: white; background-color: #95C0D0; border: 0px;">Build a Device</h2> 
   <div class="p"> 
-    <p><img src="images/lil-wrench.png" alt="" style="margin: 1em;"/>So,
-    you think you have what it takes to build an Android device? We'll see;
-    we'll see.</p> 
+    <p><img src="images/lil-wrench.png" alt="" style="margin: 1em;"/>
+    If you're an engineer building a device intended to run the Android
+    software stack, click here to find porting information and tips.</p> 
     <p><a href="{@docRoot}porting/index.html">More &raquo;</a></p> 
   </div> 
 </div> 
@@ -45,8 +52,10 @@
 <div class="rebox lil" style="float: left; width: 30%; margin: 1em;"> 
   <h2 style="color: white; background-color: #95C0D0; border: 0px;">Compatibility</h2> 
   <div class="p"> 
-    <p><img src="images/lil-wrench.png" alt="" style="margin: 1em;"/>There's more to this than
-    just booting the Linux kernel. Don't be evil, be compatible.</p> 
+    <p><img src="images/lil-wrench.png" alt="" style="margin: 1em;"/>
+    If you're an OEM or other organization building an Android device, click
+    here to find out how to ensure that your device is fully compatible, and
+    how to take advantage of the benefits of compatibility.</p> 
     <p><a href="{@docRoot}compatibility/index.html">More &raquo;</a></p> 
   </div> 
 </div> 
diff --git a/pdk/docs/source/building-dream.jd b/pdk/docs/source/building-dream.jd
index f5472ce..89392fd 100644
--- a/pdk/docs/source/building-dream.jd
+++ b/pdk/docs/source/building-dream.jd
@@ -1,6 +1,8 @@
-page.title=Building for ADP1
+page.title=Building for an Android Dev Phone
 doc.type=source
 @jd:body
+<p><i>The information on this page is a bit out of date. We'll update this
+page as soon as we can.</i></p>
 <div>The basic manifest for cupcake (and above) defines which projects are
 needed to do a generic build for the emulator or for unlocked Dream devices
 (e.g. the Android Dev Phone 1). You need to have an appropriate device running
diff --git a/pdk/docs/source/code-style.jd b/pdk/docs/source/code-style.jd
index 3122ea8..8b5946e 100644
--- a/pdk/docs/source/code-style.jd
+++ b/pdk/docs/source/code-style.jd
@@ -2,12 +2,11 @@
 doc.type=source
 @jd:body
 <div>
-<h1>Android Code Style Rules</h1>
-<p>The rules below are not guidelines or recommendations, but strict rules.<b>You may not disregard the rules we list below</b>
-except as approved on a need-to-use basis.
+<p>The rules below are not guidelines or recommendations, but strict rules.
+Contributions to Android generally <b>will not be accepted if they do not
+adhere to these rules.</b>
 </p>
-<p>Not all existing code follows these rules, but all new code is expected to.
-</p>
+<p>Not all existing code follows these rules, but all new code is expected to.</p>
 <h1><a>Java Language Rules</a>
 </h1>
 <p>We follow standard Java coding conventions. We add a few rules:
diff --git a/pdk/docs/source/documentation.jd b/pdk/docs/source/documentation.jd
deleted file mode 100644
index 4eae071..0000000
--- a/pdk/docs/source/documentation.jd
+++ /dev/null
@@ -1,54 +0,0 @@
-page.title=Documentation Resources
-doc.type=source
-@jd:body
-<div><p>
-              As this page grows, it will include resources for wireless operators and handset manufacturers as well as for platform developers.<br></p>
-<h3> 
-Resources for platform developers
-            </h3>
-
-            Google I/O videos:<br><ul><li><a href="http://sites.google.com/site/io/an-introduction-to-android">Introduction to Android</a>
-<img src="{@docRoot}images/documentation-0.png">
-<br></li>
-<li><a href="http://sites.google.com/site/io/anatomy--physiology-of-an-android">Anatomy  Physiology of an Android</a>
-<img src="{@docRoot}images/documentation-0.png">
-</li>
-<li><a href="http://sites.google.com/site/io/inside-the-android-application-framework">Inside the Android Application Framework</a>
-<img src="{@docRoot}images/documentation-0.png">
-</li>
-<li><a href="http://sites.google.com/site/io/dalvik-vm-internals">Dalvik VM Internals</a>
-<img src="{@docRoot}images/documentation-0.png">
-</li>
-</ul>
-
-            Getting started with the Android source code:<br><ul><li><a href="http://source.android.com/download">Get source</a>
-</li>
-<li><a href="http://source.android.com/submit-patches/code-style-guide">Code Style Guide</a>
-<br></li>
-</ul>
-
-            Repo and Git resources:<br><ul><li><a href="http://source.android.com/download/using-repo#TOC-Git-and-Repo-cheatsheet">Git and Repo cheat sheet</a>
-</li>
-<li><a href="http://source.android.com/download/using-repo">Using Repo and Git <br></a>
-</li>
-<li>
-                The <a href="http://book.git-scm.com/">Git Community Book</a>
-<img src="{@docRoot}images/documentation-0.png">
-maintained by Scott Chacon <br></li>
-<li><a href="http://git.or.cz/gitwiki/FrontPage">GitWiki</a>
-<img src="{@docRoot}images/documentation-0.png">
-</li>
-<li><a href="http://www.kernel.org/pub/software/scm/git/docs/">Git Manual Page</a>
-<img src="{@docRoot}images/documentation-0.png">
-</li>
-<li><a href="http://www.gitcasts.com/">GitCasts</a>
-<img src="{@docRoot}images/documentation-0.png">
-(Git how-to videos)
-              </li>
-</ul>
-
-            Documentation on specific tasks:<br><ul><li><a href="http://source.android.com/documentation/building-for-dream">Building for Dream</a>
-(Android Developer Phone 1)
-              </li>
-</ul>
-</div>
diff --git a/pdk/docs/source/git-repo.jd b/pdk/docs/source/git-repo.jd
index 97bd2ea..ac7fd37 100644
--- a/pdk/docs/source/git-repo.jd
+++ b/pdk/docs/source/git-repo.jd
@@ -19,11 +19,15 @@
 One of the challenges in setting up the Android project was figuring out how to best support the outside community--from the hobbiest community to large OEMs building mass-market consumer devices. We wanted components to be replaceable, and we wanted interesting components to be able to grow a life of their own outside of Android. We first chose a distributed revision control system, then further narrowed it down to Git.<br><h3>
 Already a Git user?
 </h3>
-In most situations, you can use Git instead of Repo, or mix Repo and Git commands to form complex commands. Using Repo for basic across-network operations will make your work much simpler, however. For more information about Git, see the list of resources on our <a href="http://sites.google.com/a/android.com/opensource/documentation">Documentation</a>
-page.<br></div>
+In most situations, you can use Git instead of Repo, or mix Repo and Git
+commands to form complex commands. Using Repo for basic across-network
+operations will make your work much simpler, however.
+<br></div>
 <div><div><h2>
 Task reference <br></h2>
-The task list below shows a summary of how to do common Repo and Git tasks. For complete quick-start information and examples, see <a href="http://sites.google.com/a/android.com/opensource/download">Get source</a>
+The task list below shows a summary of how to do common Repo and Git tasks.
+For complete quick-start information and examples, see <a
+href="{@docRoot}source/download.html">Get source</a>
 .
 <h3>
 Installing Repo <br></h3>
@@ -33,8 +37,9 @@
 $ repo init-u git://android.git.kernel.org/platform/manifest.git <br><br><h3>
 Synchronizing your client
 </h3>
-To synchronize the files for all available <a href="http://sites.google.com/a/android.com/opensource/projects">projects</a>
-:<br>$ repo sync <br><br>To synchronize the files for selected projects:<br>$ repo sync <i>project1 project2 ...</i>
+To synchronize the files for all available projects:<br>$ repo sync <br><br>To
+synchronize the files for selected projects:<br>$ repo sync <i>project1
+project2 ...</i>
 <i><br></i>
 <br><h3>
 Why use topic branches?
@@ -269,6 +274,40 @@
 
 <div><img src="{@docRoot}images/git-repo-1.png">
 </div>
+
+<!--
+<h2>Additional Resources</h2>
+<h3>Resources for platform developers</h3> 
+Google I/O videos:
+<ul>
+  <li><a href="http://sites.google.com/site/io/an-introduction-to-android">Introduction to Android</a></li> 
+  <li><a href="http://sites.google.com/site/io/anatomy-physiology-of-an-android">Anatomy Physiology of an Android</a></li> 
+  <li><a href="http://sites.google.com/site/io/inside-the-android-application-framework">Inside the Android Application Framework</a></li> 
+  <li><a href="http://sites.google.com/site/io/dalvik-vm-internals">Dalvik VM Internals</a></li> 
+</ul> 
+ 
+Getting started with the Android source code:
+<ul>
+  <li><a href="http://source.android.com/download">Get source</a></li> 
+  <li><a href="http://source.android.com/submit-patches/code-style-guide">Code Style Guide</a></li> 
+</ul> 
+ 
+Repo and Git resources:
+<ul>
+  <li><a href="http://source.android.com/download/using-repo#TOC-Git-and-Repo-cheatsheet">Git and Repo cheat sheet</a></li> 
+  <li><a href="http://source.android.com/download/using-repo">Using Repo and Git</a></li> 
+  <li>The <a href="http://book.git-scm.com/">Git Community Book</a> maintained by Scott Chacon</li> 
+  <li><a href="http://git.or.cz/gitwiki/FrontPage">GitWiki</a></li> 
+  <li><a href="http://www.kernel.org/pub/software/scm/git/docs/">Git Manual Page</a></li> 
+  <li><a href="http://www.gitcasts.com/">GitCasts</a> (Git how-to videos)</li> 
+</ul> 
+ 
+Documentation on specific tasks:
+<ul>
+  <li><a href="http://source.android.com/documentation/building-for-dream">Building for an Android Developer Phone</a></li> 
+</ul> 
+-->
+
 <h2>
 <b>Terminology</b>
 </h2>
diff --git a/pdk/docs/source/index.jd b/pdk/docs/source/index.jd
index 4960e30..230a0b3 100644
--- a/pdk/docs/source/index.jd
+++ b/pdk/docs/source/index.jd
@@ -3,9 +3,9 @@
 @jd:body
 <div>
 <p>Thanks for your interest in Android! Here are some ways you can get involved
-and help us improve Android. For background on the Android project and our
-goals, check out <a href="{@docRoot}about/philosophy.html">Our
-Philosophy</a>.</p>
+and help Google improve Android. For background on the Android project and our
+goals, check out the <a href="{@docRoot}about/philosophy.html">Project
+Philosophy page</a>.</p>
 
 <h2>Report Bugs</h2>
 <p>One of the easiest and most effective ways you can help improve Android is
diff --git a/pdk/docs/source/licenses.jd b/pdk/docs/source/licenses.jd
index 0d2cf2e..846a92a 100644
--- a/pdk/docs/source/licenses.jd
+++ b/pdk/docs/source/licenses.jd
@@ -65,18 +65,16 @@
 (For instance, it's difficult for a user to replace a library on read-only
 flash storage.)</li>
 <li>LGPL requires allowance of customer modification and reverse
-engineering for debugging those modifications.  Most app producers do
-want to have to be bound by these terms, and the more userspace libs
-that are LGPL, the more they would have to be to use Android
-userspace.</li>
+engineering for debugging those modifications.  Most device makers do
+not want to have to be bound by these terms, so to minimize the burden on
+these companies we minimize usage of LGPL software in userspace.</li>
 <li>Historically, LGPL libraries have been the source of a large number
 of compliance problems for downstream device makers and application
-developers (due to ignorance and disbelief, usually).  Education is
-slow going, sadly.  Part of android being successful as a platform is
-that we want to make it easy for our device makers to comply with the
-licenses in Android.  Given the difficulties with complying with LGPL
-in the past, it is easiest to simply not use LGPL libraries if we can
-avoid it.</li>
+developers. Educating engineers on these issues is difficult and slow-going,
+unfortunately. It's critical to Android's success that it be as easy as
+possible for device makers to comply with the licenses.  Given the
+difficulties with complying with LGPL in the past, it is most prudent to
+simply not use LGPL libraries if we can avoid it.</li>
 </ol>
 <p>The issues discussed above are our reasons for preferring ASL2.0 for
 our own code. They aren't criticisms of LGPL or other licenses. We do
diff --git a/pdk/docs/source/life-of-a-bug.jd b/pdk/docs/source/life-of-a-bug.jd
index 1eb1bc4..1d58ae1 100644
--- a/pdk/docs/source/life-of-a-bug.jd
+++ b/pdk/docs/source/life-of-a-bug.jd
@@ -53,8 +53,10 @@
 to a contributor.</p></li>
 <li><b>Reviewed</b><p>Like <code>Unassigned</code>, but the issue
 represented is being tracked in a separate bug database. For example, the bug
-might have been reported via an AOSP member's internal bug-tracking system,
-which is considered the "master" copy.</p></li>
+might have been reported via an internal bug-tracking system,
+which is considered the "master" copy. (For instance, Google maintains one
+such private issue tracker, intended primarily for bugs which contain
+sensitive information which can't be revealed publicly.)</p></li>
 <li><b>Assigned</b><li>Like <code>Unassigned</code>, but the bug has been
 actually assigned to a specific contributor to fix.</p></li>
 </ul>
@@ -120,7 +122,7 @@
 actually multiple issue trackers for Android-related issues. The <a
 href="http://code.google.com/p/android/issues/list">Google Code Project
 Hosting Issue Tracker</a> is the <b>only</b> official public issue tracker; however,
-many of the AOSP Member organizations maintain their own, as do most OEMs. We
-try to keep the public issue tracker in sync with private issue trackers
+Google also maintains a private issue tracker, own, as do most OEMs. We try to
+keep the public issue tracker in sync with private issue trackers
 wherever possible, but in cases where confidential information and security
 issues are involved, this isn't always possible.</p>
diff --git a/pdk/docs/source/overview.jd b/pdk/docs/source/overview.jd
index 9874b4b..2763c52 100644
--- a/pdk/docs/source/overview.jd
+++ b/pdk/docs/source/overview.jd
@@ -9,6 +9,11 @@
 the source code onto your local machine. You can use <code>repo init -u
 git://android.git.kernel.org/platform/manifest.git -b android-1.6</code>
 to download the source code for Android 1.6.</p>
+<p><i>Note: platform overview information for Android 2.x has not yet been
+published, since the <a
+href="{@docRoot}compatibility/index.html">Compatibility Program</a> for
+Android 2.x has not yet launched. When the Compatibilty Definition Document
+for 2.x is released, this page will be updated to match.</i></p>
 <p>Information about older Android releases is also available:<ul>
 <li><a href="{@docRoot}source/overview-1.5.html">Android 1.5 Platform Overview</a></li>
 <li><a href="{@docRoot}source/overview-1.0.html">Android 1.0 Platform Overview</a></li>
diff --git a/pdk/docs/source/report-bugs.jd b/pdk/docs/source/report-bugs.jd
index e89fbbe..138080d 100644
--- a/pdk/docs/source/report-bugs.jd
+++ b/pdk/docs/source/report-bugs.jd
@@ -21,13 +21,16 @@
   templates:<ul>
     <li><a
     href="http://code.google.com/p/android/issues/entry?template=User%20bug%20report">Bugs
-    in your Device (for users)</a></li>
+    in your Device (for users)</a> - use this if you want to report a bug in a
+    device you own</li>
     <li><a
     href="http://code.google.com/p/android/issues/entry?template=Developer%20bug%20report">Bugs
-    in the Software (for developers)</a></li>
+    in the Software (for developers)</a> - use this if you found a bug in the
+    course of developing an app</li>
     <li><a
     href="http://code.google.com/p/android/issues/entry?template=Feature%20request">Request
-    a New Feature</a></li>
+    a New Feature</a> - use this for a feature you'd like to see in a future
+    verison</li>
   </ul></li>
 </ol>
 <p>Please note that we can't guarantee that any particular bug can be fixed in
@@ -54,6 +57,11 @@
 Observed results:
 See above.
 </pre>
+<p>This is a poor bug report because it doesn't provide any context for the
+issue; is it a problem in the Dalvik virtual machine, the core framework, or
+something else? It also doesn't provide any code or hint on how to reproduce
+it. In other words, this bug report doesn't provide enough information for
+anyone to take action on, so it would be ignored.</p>
 <h3>A Good Bug Report</h3>
 <pre>
 Title: Stepping over "Object o = null" causes Eclipse "Internal Error"
diff --git a/pdk/docs/source/roles.jd b/pdk/docs/source/roles.jd
index 2b4a721..451c821 100644
--- a/pdk/docs/source/roles.jd
+++ b/pdk/docs/source/roles.jd
@@ -1,12 +1,12 @@
 page.title=People and Roles
 doc.type=source
 @jd:body
-<div>
 <p>The Android Open Source Project (AOSP) includes individuals working in a variety
 of roles. As noted in <a href="{@docRoot}about/philosophy.html">Our
-Philosophy</a>, the core AOSP members operate the Android product management
-and engineering process. This page describes these roles in a bit more
-detail.</p>
+Philosophy</a>, Google is responsible for Android product management
+and the engineering process for the core framework and platform; however,
+the project considers contributions from any source, not just Google. This
+page describes the kinds of roles that interested parties can take on.</p>
 <p>Anyone who is interested in exploring and contributing to Android can use the
 Android Open Source Project resources. Anyone can join the mailing lists, ask
 questions, contribute patches, report bugs, look at submitted patches, and use
@@ -15,10 +15,10 @@
 
 <h2>Contributor</h2>
 <p>A "Contributor" is anyone making contributions to the AOSP source code,
-including both employees or other affiliates of an AOSP Member, as well as
+including both employees of Google or other companies, as well as
 external developers who are contributing to Android on their own behalf.
-There is no distinction between Contributors who are affiliated with an AOSP
-Member, and those who are not: all engineers use the same git/gerrit tools, 
+There is no distinction between Contributors who are employed by 
+Google, and those who are not: all engineers use the same git/gerrit tools, 
 follow the same code review process, and are subject to the same requirements
 on code style and so on.</p>
 <p/>
@@ -26,9 +26,9 @@
 <h2>Developer</h2>
 <p>A "Developer" is an engineer writing applications that run on Android
 devices. There is, of course, no difference in skillset between a "Developer"
-and a "Contributor"; we simply use "Developer" to help identify our audience.
+and a "Contributor"; AOSP simply uses "Developer" to help identify our audience.
 Since the key purpose of Android is to cultivate an open development platform,
-"Developers" are one of the key customers of the Android project. As such, we
+"Developers" are one of the key customers of the Android platform. As such, we
 talk about them a lot, though this isn't technically a separate role in the
 AOSP <i>per se.</i></p>
 <p/>
@@ -44,18 +44,17 @@
 "Approvers" are experienced members of the project who have demonstrated their
 design skills and have made significant technical contributions to the
 project. In the code-review process, an Approver decides whether to include or
-exclude a change. Project Leads (typically employed by an AOSP Member) choose
+exclude a change. Project Leads (who are typically employed by Google) choose
 the Approvers, sometimes promoting to this position Verifiers who have
 demonstrated their expertise within a specific project.</p>
 <p/>
 
 <h2>Project Leads</h2>
 <p>Android consists of a number of sub-projects; you can see these in the git
-repository, as individual .git files. The AOSP Members generally assign tech
-leads or product leads who oversee the engineering for individual Android
-projects. Typically these tech leads will be employees of an AOSP Member
-company.  A Project Lead for an individual project is responsible for the
-following:</p>
+repository, as individual .git files. Tech Leads are senior Contributors who
+oversee the engineering for individual Android projects. Typically these tech
+leads will be Google employees.  A Project Lead for an individual project is
+responsible for the following:</p>
 <ul>
   <li>Lead all technical aspects of the project; for example, the project
   roadmap, development, release cycles, versioning, and QA.</li>
@@ -72,4 +71,3 @@
   <li>Be the public face for the project and the go-to person for questions
   related to the project.</li>
 </ul>
-</div>
diff --git a/pdk/docs/source/source_toc.cs b/pdk/docs/source/source_toc.cs
index 1531aff..09c20a6 100644
--- a/pdk/docs/source/source_toc.cs
+++ b/pdk/docs/source/source_toc.cs
@@ -8,9 +8,10 @@
   <li><h2>The Project</h2><ul>
     <li><a href="<?cs var:toroot ?>source/roles.html">People and Roles</a></li>
     <li><a href="<?cs var:toroot ?>source/licenses.html">Licensing Information</a></li>
-    <li><a href="http://android.git.kernel.org/">Browse Source</a></li>
+    <li><a href="http://android.git.kernel.org/">Browse Source</a> <span style="font-size: 75%; font-variant: small-caps">[off-site]</span></li>
     <li><a href="<?cs var:toroot ?>source/overview.html">Platform Overview</a></li>
     <li><a href="<?cs var:toroot ?>source/life-of-a-bug.html">Life of a Bug</a></li>
+    <li><a href="<?cs var:toroot ?>faqs.html#aosp">FAQs</a></li>
   </ul>
 
   <li><h2>Getting Started</h2><ul>
@@ -18,7 +19,7 @@
     <li><a href="<?cs var:toroot ?>source/git-repo.html">Using git and repo</a></li>
     <li><a href="<?cs var:toroot ?>source/using-eclipse.html">Using Eclipse</a></li>
     <li><a href="<?cs var:toroot ?>source/code-style.html">Code Style</a></li>
-    <li><a href="<?cs var:toroot ?>source/building-dream.html">Building for ADP1</a></li>
+    <li><a href="<?cs var:toroot ?>source/building-dream.html">Building for an ADP</a></li>
   </ul>
 
   <li><h2>Contributing</h2><ul>
diff --git a/pdk/docs/source/submit-patches.jd b/pdk/docs/source/submit-patches.jd
index 880a682..2b7bae1 100644
--- a/pdk/docs/source/submit-patches.jd
+++ b/pdk/docs/source/submit-patches.jd
@@ -8,13 +8,10 @@
 see <a href="{@docRoot}source/download.html">Get source</a>
 .<br><br>Other recommended reading:<br><ul><li>For an overview of the code
 contribution and review process, see <a
-href="{@docRoot}source/submit-patches.html">Workflow</a>
-.</li>
-<li>For details about Repo, see <a href="{@docRoot}source/git-repo.html">Using Repo and Git</a>
-.<br></li>
+href="{@docRoot}source/life-of-a-patch.html">Life of a Patch</a>.</li>
+<li>For details about Repo, see <a href="{@docRoot}source/git-repo.html">Using Repo and Git</a>.<br></li>
 <li>For information about the different roles you can play within the Android
-Open Source community, see <a href="{@docRoot}source/roles.html">Project roles</a>
-.</li>
+Open Source community, see <a href="{@docRoot}source/roles.html">Project roles</a>.</li>
 <li>If you plan to contribute code to the Android platform, be sure to read
 the <a href="{@docRoot}source/licenses.html">AOSP's licensing information</a>.</li>
 </ul>
@@ -40,16 +37,14 @@
 </ol>
 You can track your uploaded changes using the Gerrit code-review tool. When it's time to work on the code again, run repo sync, then go back to step 1 above and start another topic branch.<br><br>The steps will not always come in the order shown--for example, you might run git diff at several points in the process.<br><br><h3>
 Starting a topic branch</h3>
-Start a topic branch called default in your local work environment:<br><br>$ repo start default <br><br>For more about topic branches, see <a href="{@docRoot}source/git-repo.html">Using Repo and Git</a>
-.<br><h3>
+Start a topic branch called default in your local work environment:<br><br>$ repo start default <br><br>For more about topic branches, see <a href="{@docRoot}source/git-repo.html">Using Repo and Git</a>.<br><h3>
 Editing the files</h3>
 You do not need to check files out before working on them. Edit the files using vim, emacs, or any other editor.<br><br><h3>
 Staging changes</h3>
 To indicate that every new and modified file in your working directory should be "staged" for inclusion in the next commit, run git add without any arguments. You can also specify files or filetypes. For example, the following command would stage all the new and modified files under the bionic directory and its subdirectories:<br><br>$ git add bionic/*<br><br>Run git help add to see more ways to use git add.<br><br><b>When is git add optional?<br></b>
 <br>If you add new files, you must stage them using git add before you run git commit. However, if you are only modifying or deleting files, you can skip git add if you use the -a option with git commit. For more details, see the "Committing changes" section further down.<br><br><h3>
 Using repo status <br></h3>
-To see the status of the current branch, run <br><br>$ repo status .<br><br>For information about how to interpret the results of repo status, see <a href="{@docRoot}source/git-repo.html#TOC-status">Using Repo and Git</a>
-.<br><br><h3>
+To see the status of the current branch, run <br><br>$ repo status .<br><br>For information about how to interpret the results of repo status, see <a href="{@docRoot}source/git-repo.html#TOC-status">Using Repo and Git</a>.<br><br><h3>
 Using git diff</h3>
 To see uncommitted changes, cd into the project directory and run <br><br>$ git
 diff <br><br>Without any arguments, git diff will show you the differences
@@ -113,8 +108,7 @@
 . For more information, see <a href="{@docRoot}source/git-repo.html#TOC-download">Using Repo and Git</a>
 .<br><br><h2>
 Using the Gerrit code-review tool <br></h2>
-You can open Gerrit by visiting whatever URL is returned to you from the repo upload command, or by visiting <a href="https://review.source.android.com/">https://review.source.android.com</a>
-/.<br><br><h3>
+You can open Gerrit by visiting whatever URL is returned to you from the repo upload command, or by visiting <a href="https://review.source.android.com/">https://review.source.android.com</a>.<br><br><h3>
 Viewing the status of uploaded changes <br></h3>
 To check the status of a change that you uploaded, open <a href="https://review.source.android.com/mine">Gerrit</a>
 , sign in, and click MyChanges.<br><b><br></b>
diff --git a/pdk/docs/source/using-eclipse.jd b/pdk/docs/source/using-eclipse.jd
index 1750a20..aa06d16 100644
--- a/pdk/docs/source/using-eclipse.jd
+++ b/pdk/docs/source/using-eclipse.jd
@@ -1,12 +1,13 @@
 page.title=Using Eclipse
 doc.type=source
 @jd:body
-<div><h2><a>About this Document</a>
-</h2>
-<p>This document will help you set up the Eclipse IDE for Android platform development.
-</p>
-
-
+<div>
+<p>This document will help you set up the Eclipse IDE for Android platform development.</p>
+<p><i>Note: if you are looking for information on how to use
+Eclipse to develop applications that run on Android, this is not the right
+page for you. You probably would find <a
+href="http://developer.android.com/sdk/eclipse-adt.html">the Eclipse page on
+developer.android.com</a> more useful.</i></p>
 <h2><a>Enter eclipse</a>
 </h2>
 <h4>
diff --git a/samples/ApiDemos/AndroidManifest.xml b/samples/ApiDemos/AndroidManifest.xml
index 4dbf136..b0cda30 100644
--- a/samples/ApiDemos/AndroidManifest.xml
+++ b/samples/ApiDemos/AndroidManifest.xml
@@ -1405,7 +1405,17 @@
                 <category android:name="android.intent.category.SAMPLE_CODE" />
             </intent-filter>
         </activity>
-
+        
+        <activity android:name=".graphics.CompressedTextureActivity"
+                android:label="Graphics/OpenGL ES/Compressed Texture"
+                android:theme="@android:style/Theme.NoTitleBar"
+                android:configChanges="orientation|keyboardHidden">
+            <intent-filter>
+                <action android:name="android.intent.action.MAIN" />
+                <category android:name="android.intent.category.SAMPLE_CODE" />
+            </intent-filter>
+        </activity>
+        
         <activity android:name=".graphics.GLSurfaceViewActivity"
                 android:label="Graphics/OpenGL ES/GLSurfaceView"
                 android:theme="@android:style/Theme.NoTitleBar"
diff --git a/samples/ApiDemos/res/raw/androids.pkm b/samples/ApiDemos/res/raw/androids.pkm
new file mode 100644
index 0000000..7807e7e
--- /dev/null
+++ b/samples/ApiDemos/res/raw/androids.pkm
Binary files differ
diff --git a/samples/ApiDemos/src/com/example/android/apis/graphics/CompressedTextureActivity.java b/samples/ApiDemos/src/com/example/android/apis/graphics/CompressedTextureActivity.java
new file mode 100644
index 0000000..f3b5478
--- /dev/null
+++ b/samples/ApiDemos/src/com/example/android/apis/graphics/CompressedTextureActivity.java
@@ -0,0 +1,157 @@
+/*
+ * Copyright (C) 2008 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.
+ */
+
+package com.example.android.apis.graphics;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.nio.Buffer;
+import java.nio.ByteBuffer;
+import java.nio.ByteOrder;
+
+import javax.microedition.khronos.opengles.GL10;
+
+import android.app.Activity;
+import android.opengl.ETC1Util;
+import android.opengl.GLES10;
+import android.opengl.GLSurfaceView;
+import android.os.Bundle;
+import android.util.Log;
+
+import com.example.android.apis.R;
+
+/**
+ * Demonstrate how to use ETC1 format compressed textures.
+ * This sample can be recompiled to use either resource-based
+ * textures (compressed offline using the etc1tool), or
+ * textures created on the fly by compressing images.
+ *
+ */
+public class CompressedTextureActivity extends Activity {
+    private final static String TAG = "CompressedTextureActivity";
+    /**
+     * Choose between creating a compressed texture on the fly or
+     * loading a compressed texture from a resource.
+     */
+    private final static boolean TEST_CREATE_TEXTURE = false;
+    /**
+     * When creating a compressed texture on the fly, choose
+     * whether or not to use the i/o stream APIs.
+     */
+    private final static boolean USE_STREAM_IO = false;
+
+    @Override
+    protected void onCreate(Bundle savedInstanceState) {
+        super.onCreate(savedInstanceState);
+        mGLView = new GLSurfaceView(this);
+        mGLView.setEGLConfigChooser(false);
+        StaticTriangleRenderer.TextureLoader loader;
+        if (TEST_CREATE_TEXTURE) {
+            loader = new SyntheticCompressedTextureLoader();
+        } else {
+            loader = new CompressedTextureLoader();
+        }
+        mGLView.setRenderer(new StaticTriangleRenderer(this, loader));
+        setContentView(mGLView);
+    }
+
+    @Override
+    protected void onPause() {
+        super.onPause();
+        mGLView.onPause();
+    }
+
+    @Override
+    protected void onResume() {
+        super.onResume();
+        mGLView.onResume();
+    }
+
+    /**
+     * Demonstrate how to load a compressed texture from an APK resource.
+     *
+     */
+    private class CompressedTextureLoader implements StaticTriangleRenderer.TextureLoader {
+        public void load(GL10 gl) {
+            Log.w(TAG, "ETC1 texture support: " + ETC1Util.isETC1Supported());
+            InputStream input = getResources().openRawResource(R.raw.androids);
+            try {
+                ETC1Util.loadTexture(GLES10.GL_TEXTURE_2D, 0, 0,
+                        GLES10.GL_RGB, GLES10.GL_UNSIGNED_SHORT_5_6_5, input);
+            } catch (IOException e) {
+                Log.w(TAG, "Could not load texture: " + e);
+            } finally {
+                try {
+                    input.close();
+                } catch (IOException e) {
+                    // ignore exception thrown from close.
+                }
+            }
+        }
+    }
+
+    /**
+     * Demonstrate how to create a compressed texture on the fly.
+     */
+    private class SyntheticCompressedTextureLoader implements StaticTriangleRenderer.TextureLoader {
+        public void load(GL10 gl) {
+            int width = 128;
+            int height = 128;
+            Buffer image = createImage(width, height);
+            ETC1Util.ETC1Texture etc1Texture = ETC1Util.compressTexture(image, width, height, 3, 3 * width);
+            if (USE_STREAM_IO) {
+                // Test the ETC1Util APIs for reading and writing compressed textures to I/O streams.
+                try {
+                    ByteArrayOutputStream bos = new ByteArrayOutputStream();
+                    ETC1Util.writeTexture(etc1Texture, bos);
+                    ByteArrayInputStream bis = new ByteArrayInputStream(bos.toByteArray());
+                    ETC1Util.loadTexture(GLES10.GL_TEXTURE_2D, 0, 0,
+                            GLES10.GL_RGB, GLES10.GL_UNSIGNED_SHORT_5_6_5, bis);
+                } catch (IOException e) {
+                    Log.w(TAG, "Could not load texture: " + e);
+                }
+            } else {
+                ETC1Util.loadTexture(GLES10.GL_TEXTURE_2D, 0, 0,
+                        GLES10.GL_RGB, GLES10.GL_UNSIGNED_SHORT_5_6_5, etc1Texture);
+            }
+        }
+
+        private Buffer createImage(int width, int height) {
+            int stride = 3 * width;
+            ByteBuffer image = ByteBuffer.allocateDirect(height * stride)
+                .order(ByteOrder.nativeOrder());
+
+            // Fill with a pretty "munching squares" pattern:
+            for (int t = 0; t < height; t++) {
+                byte red = (byte)(255-2*t);
+                byte green = (byte)(2*t);
+                byte blue = 0;
+                for (int x = 0; x < width; x++) {
+                    int y = x ^ t;
+                    image.position(stride*y+x*3);
+                    image.put(red);
+                    image.put(green);
+                    image.put(blue);
+                }
+            }
+            image.position(0);
+            return image;
+        }
+    }
+    private GLSurfaceView mGLView;
+}
diff --git a/samples/ApiDemos/src/com/example/android/apis/graphics/StaticTriangleRenderer.java b/samples/ApiDemos/src/com/example/android/apis/graphics/StaticTriangleRenderer.java
index c7e7e64..7ef0841 100644
--- a/samples/ApiDemos/src/com/example/android/apis/graphics/StaticTriangleRenderer.java
+++ b/samples/ApiDemos/src/com/example/android/apis/graphics/StaticTriangleRenderer.java
@@ -50,9 +50,25 @@
  */
 public class StaticTriangleRenderer implements GLSurfaceView.Renderer{
 
+    public interface TextureLoader {
+        /**
+         * Load a texture into the currently bound OpenGL texture.
+         */
+        void load(GL10 gl);
+    }
+
     public StaticTriangleRenderer(Context context) {
+        init(context, new RobotTextureLoader());
+    }
+
+    public StaticTriangleRenderer(Context context, TextureLoader loader) {
+        init(context, loader);
+    }
+
+    private void init(Context context, TextureLoader loader) {
         mContext = context;
         mTriangle = new Triangle();
+        mTextureLoader = loader;
     }
 
     public void onSurfaceCreated(GL10 gl, EGLConfig config) {
@@ -99,22 +115,7 @@
 
         glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE,
                 GL_REPLACE);
-
-        InputStream is = mContext.getResources()
-                .openRawResource(R.raw.robot);
-        Bitmap bitmap;
-        try {
-            bitmap = BitmapFactory.decodeStream(is);
-        } finally {
-            try {
-                is.close();
-            } catch(IOException e) {
-                // Ignore.
-            }
-        }
-
-        GLUtils.texImage2D(GL_TEXTURE_2D, 0, bitmap, 0);
-        bitmap.recycle();
+        mTextureLoader.load(gl);
     }
 
     public void onDrawFrame(GL10 gl) {
@@ -181,6 +182,27 @@
     private Context mContext;
     private Triangle mTriangle;
     private int mTextureID;
+    private TextureLoader mTextureLoader;
+
+    private class RobotTextureLoader implements TextureLoader {
+        public void load(GL10 gl) {
+            InputStream is = mContext.getResources().openRawResource(
+                    R.raw.robot);
+            Bitmap bitmap;
+            try {
+                bitmap = BitmapFactory.decodeStream(is);
+            } finally {
+                try {
+                    is.close();
+                } catch (IOException e) {
+                    // Ignore.
+                }
+            }
+
+            GLUtils.texImage2D(GL_TEXTURE_2D, 0, bitmap, 0);
+            bitmap.recycle();
+        }
+    }
 
     static class Triangle {
         public Triangle() {
diff --git a/samples/ApiDemos/src/com/example/android/apis/graphics/spritetext/LabelMaker.java b/samples/ApiDemos/src/com/example/android/apis/graphics/spritetext/LabelMaker.java
index 4bf87f7..6481397 100644
--- a/samples/ApiDemos/src/com/example/android/apis/graphics/spritetext/LabelMaker.java
+++ b/samples/ApiDemos/src/com/example/android/apis/graphics/spritetext/LabelMaker.java
@@ -351,17 +351,12 @@
      */
     public void draw(GL10 gl, float x, float y, int labelID) {
         checkState(STATE_DRAWING, STATE_DRAWING);
-        gl.glPushMatrix();
-        float snappedX = (float) Math.floor(x);
-        float snappedY = (float) Math.floor(y);
-        gl.glTranslatef(snappedX, snappedY, 0.0f);
         Label label = mLabels.get(labelID);
         gl.glEnable(GL10.GL_TEXTURE_2D);
         ((GL11)gl).glTexParameteriv(GL10.GL_TEXTURE_2D,
                 GL11Ext.GL_TEXTURE_CROP_RECT_OES, label.mCrop, 0);
-        ((GL11Ext)gl).glDrawTexiOES((int) snappedX, (int) snappedY, 0,
+        ((GL11Ext)gl).glDrawTexiOES((int) x, (int) y, 0,
                 (int) label.width, (int) label.height);
-        gl.glPopMatrix();
     }
 
     /**
diff --git a/samples/BrowserPlugin/jni/main.cpp b/samples/BrowserPlugin/jni/main.cpp
index 5bbb648..85632e4 100644
--- a/samples/BrowserPlugin/jni/main.cpp
+++ b/samples/BrowserPlugin/jni/main.cpp
@@ -245,7 +245,10 @@
 NPError NPP_Destroy(NPP instance, NPSavedData** save)
 {
     PluginObject *obj = (PluginObject*) instance->pdata;
-    delete obj->activePlugin;
+    if (obj) {
+        delete obj->activePlugin;
+        browser->releaseobject(&obj->header);
+    }
 
     return NPERR_NO_ERROR;
 }
diff --git a/samples/BrowserPlugin/src/com/android/sampleplugin/SamplePlugin.java b/samples/BrowserPlugin/src/com/android/sampleplugin/SamplePlugin.java
index 207c9ec..2cfb525 100644
--- a/samples/BrowserPlugin/src/com/android/sampleplugin/SamplePlugin.java
+++ b/samples/BrowserPlugin/src/com/android/sampleplugin/SamplePlugin.java
@@ -35,7 +35,6 @@
 import android.view.WindowManager;
 import android.view.SurfaceHolder.Callback;
 import android.view.ViewGroup.LayoutParams;
-import android.webkit.plugin.FullScreenDrawingModel;
 import android.webkit.plugin.NativePlugin;
 import android.webkit.plugin.SurfaceDrawingModel;
 import android.widget.FrameLayout;
@@ -53,7 +52,7 @@
     private Context context;
     
     private SurfaceDrawingModel embeddedSurface;
-    private FullScreenDrawingModel fullScreenSurface;
+    private SurfaceDrawingModel fullScreenSurface;
     
     private boolean validNPP = false;
     private Object nppLock = new Object();
@@ -71,7 +70,7 @@
         return embeddedSurface;
     }
 
-    public FullScreenDrawingModel getFullScreenSurface() {
+    public SurfaceDrawingModel getFullScreenSurface() {
         if (fullScreenSurface == null) {
             fullScreenSurface = new FullScreenSurface();
         }
@@ -145,7 +144,7 @@
         }
     }
 
-    private class FullScreenSurface implements FullScreenDrawingModel {
+    private class FullScreenSurface implements SurfaceDrawingModel {
 
         public View getSurface() {
             /* TODO make this aware of the plugin instance and get the video file
@@ -156,37 +155,30 @@
             LayoutParams fp = new LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.FILL_PARENT);
             layout.setLayoutParams(fp);
 
-            VideoView video = new VideoView(context);
-            LayoutParams vp = new LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.FILL_PARENT);
-            layout.setLayoutParams(vp);
+//            VideoView video = new VideoView(context);
+//            LayoutParams vp = new LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.FILL_PARENT);
+//            layout.setLayoutParams(vp);
 
             GLSurfaceView gl = new GLSurfaceView(context);
             LayoutParams gp = new LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.FILL_PARENT);
             layout.setLayoutParams(gp);
 
-            layout.addView(video);
             layout.addView(gl);
+//            layout.addView(video);
 
-            // We want an 8888 pixel format because that's required for a translucent 
-            // window. And we want a depth buffer.
-            gl.setEGLConfigChooser(8, 8, 8, 8, 16, 0);
             // Tell the cube renderer that we want to render a translucent version
             // of the cube:
-            gl.setRenderer(new CubeRenderer(true));
-            // Use a surface format with an Alpha channel:
-            gl.getHolder().setFormat(PixelFormat.TRANSLUCENT);
+            gl.setRenderer(new CubeRenderer(false));
             gl.setWindowType(WindowManager.LayoutParams.TYPE_APPLICATION_MEDIA_OVERLAY);
 
-            video.setVideoPath("/sdcard/test_video.3gp");
-            video.setMediaController(new MediaController(context));
-            video.requestFocus();
+//            video.setVideoPath("/sdcard/test_video.3gp");
+//            video.setMediaController(new MediaController(context));
+//            video.requestFocus();
 
             // ensure that the view system is aware that we will be drawing
             layout.setWillNotDraw(false);
             
             return layout;
         }
-
-        public void onSurfaceRemoved() { }
     }
 }
diff --git a/testrunner/test_defs.xml b/testrunner/test_defs.xml
index 3fa40df..4d95c69 100644
--- a/testrunner/test_defs.xml
+++ b/testrunner/test_defs.xml
@@ -40,7 +40,6 @@
 <test name="android"
     build_path="frameworks/base/tests/AndroidTests"
     package="com.android.unit_tests"
-    class="com.android.unit_tests.AndroidTests"
     coverage_target="framework"
     continuous="true" />
 
diff --git a/tools/etc1tool/Android.mk b/tools/etc1tool/Android.mk
new file mode 100644
index 0000000..5536158
--- /dev/null
+++ b/tools/etc1tool/Android.mk
@@ -0,0 +1,40 @@
+# Copyright 2009 Google Inc. All Rights Reserved.
+#
+# Android.mk for etc1tool 
+#
+
+LOCAL_PATH:= $(call my-dir)
+
+include $(CLEAR_VARS)
+
+LOCAL_SRC_FILES := etc1tool.cpp
+
+LOCAL_C_INCLUDES += external/libpng
+LOCAL_C_INCLUDES += external/zlib
+LOCAL_C_INCLUDES += build/libs/host/include
+LOCAL_C_INCLUDES += frameworks/base/opengl/include
+
+#LOCAL_WHOLE_STATIC_LIBRARIES := 
+LOCAL_STATIC_LIBRARIES := \
+	libhost \
+	libutils \
+	libcutils \
+	libexpat \
+	libpng \
+	libETC1
+
+LOCAL_LDLIBS := -lz
+
+ifeq ($(HOST_OS),linux)
+LOCAL_LDLIBS += -lrt
+endif
+
+ifeq ($(HOST_OS),windows)
+ifeq ($(strip $(USE_CYGWIN),),)
+LOCAL_LDLIBS += -lws2_32
+endif
+endif
+
+LOCAL_MODULE := etc1tool
+
+include $(BUILD_HOST_EXECUTABLE)
diff --git a/tools/etc1tool/etc1tool.cpp b/tools/etc1tool/etc1tool.cpp
new file mode 100644
index 0000000..4cc0202
--- /dev/null
+++ b/tools/etc1tool/etc1tool.cpp
@@ -0,0 +1,583 @@
+// Copyright 2009 Google Inc.
+//
+// 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.
+
+#include <errno.h>
+#include <stdarg.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+
+#include <png.h>
+#include <ETC1/etc1.h>
+
+
+int writePNGFile(const char* pOutput, png_uint_32 width, png_uint_32 height,
+        const png_bytep pImageData, png_uint_32 imageStride);
+
+const char* gpExeName;
+
+static
+void usage(char* message, ...) {
+    if (message) {
+        va_list ap;
+        va_start(ap, message);
+        vfprintf(stderr, message, ap);
+        va_end(ap);
+        fprintf(stderr, "\n\n");
+        fprintf(stderr, "usage:\n");
+    }
+    fprintf(
+            stderr,
+            "%s infile [--help | --encode | --encodeNoHeader | --decode] [--showDifference difffile] [-o outfile]\n",
+            gpExeName);
+    fprintf(stderr, "\tDefault is --encode\n");
+    fprintf(stderr, "\t\t--help           print this usage information.\n");
+    fprintf(stderr,
+            "\t\t--encode         create an ETC1 file from a PNG file.\n");
+    fprintf(
+            stderr,
+            "\t\t--encodeNoHeader create a raw ETC1 data file (without a header) from a PNG file.\n");
+    fprintf(stderr,
+            "\t\t--decode         create a PNG file from an ETC1 file.\n");
+    fprintf(stderr,
+            "\t\t--showDifference difffile    Write difference between original and encoded\n");
+    fprintf(stderr,
+            "\t\t                             image to difffile. (Only valid when encoding).\n");
+    fprintf(stderr,
+            "\tIf outfile is not specified, an outfile path is constructed from infile,\n");
+    fprintf(stderr, "\twith the apropriate suffix (.pkm or .png).\n");
+    exit(1);
+}
+
+// Returns non-zero if an error occured
+
+static
+int changeExtension(char* pPath, size_t pathCapacity, const char* pExtension) {
+    size_t pathLen = strlen(pPath);
+    size_t extensionLen = strlen(pExtension);
+    if (pathLen + extensionLen + 1 > pathCapacity) {
+        return -1;
+    }
+
+    // Check for '.' and '..'
+    if ((pathLen == 1 && pPath[0] == '.') || (pathLen == 2 && pPath[0] == '.'
+            && pPath[1] == '.') || (pathLen >= 2 && pPath[pathLen - 2] == '/'
+            && pPath[pathLen - 1] == '.') || (pathLen >= 3
+            && pPath[pathLen - 3] == '/' && pPath[pathLen - 2] == '.'
+            && pPath[pathLen - 1] == '.')) {
+        return -2;
+    }
+
+    int index;
+    for (index = pathLen - 1; index > 0; index--) {
+        char c = pPath[index];
+        if (c == '/') {
+            // No extension found. Append our extension.
+            strcpy(pPath + pathLen, pExtension);
+            return 0;
+        } else if (c == '.') {
+            strcpy(pPath + index, pExtension);
+            return 0;
+        }
+    }
+
+    // No extension or directory found. Append our extension
+    strcpy(pPath + pathLen, pExtension);
+    return 0;
+}
+
+void PNGAPI user_error_fn(png_structp png_ptr, png_const_charp message) {
+    fprintf(stderr, "PNG error: %s\n", message);
+}
+
+void PNGAPI user_warning_fn(png_structp png_ptr, png_const_charp message) {
+    fprintf(stderr, "PNG warning: %s\n", message);
+}
+
+// Return non-zero on error
+int fwrite_big_endian_uint16(png_uint_32 data, FILE* pOut) {
+    if (fputc(0xff & (data >> 8), pOut) == EOF) {
+        return -1;
+    }
+    if (fputc(0xff & data, pOut) == EOF) {
+        return -1;
+    }
+    return 0;
+}
+
+// Return non-zero on error
+int fread_big_endian_uint16(png_uint_32* data, FILE* pIn) {
+    int a, b;
+    if ((a = fgetc(pIn)) == EOF) {
+        return -1;
+    }
+    if ((b = fgetc(pIn)) == EOF) {
+        return -1;
+    }
+    *data = ((0xff & a) << 8) | (0xff & b);
+    return 0;
+}
+
+// Read a PNG file into a contiguous buffer.
+// Returns non-zero if an error occurred.
+// caller has to delete[] *ppImageData when done with the image.
+
+int read_PNG_File(const char* pInput, etc1_byte** ppImageData,
+        etc1_uint32* pWidth, etc1_uint32* pHeight) {
+    FILE* pIn = NULL;
+    png_structp png_ptr = NULL;
+    png_infop info_ptr = NULL;
+    png_infop end_info = NULL;
+    png_bytep* row_pointers = NULL; // Does not need to be deallocated.
+    png_uint_32 width = 0;
+    png_uint_32 height = 0;
+    png_uint_32 stride = 0;
+    int result = -1;
+    etc1_byte* pSourceImage = 0;
+
+    if ((pIn = fopen(pInput, "rb")) == NULL) {
+        fprintf(stderr, "Could not open input file %s for reading: %d\n",
+                pInput, errno);
+        goto exit;
+    }
+
+    static const size_t PNG_HEADER_SIZE = 8;
+    png_byte pngHeader[PNG_HEADER_SIZE];
+    if (fread(pngHeader, 1, PNG_HEADER_SIZE, pIn) != PNG_HEADER_SIZE) {
+        fprintf(stderr, "Could not read PNG header from %s: %d\n", pInput,
+                errno);
+        goto exit;
+    }
+
+    if (png_sig_cmp(pngHeader, 0, PNG_HEADER_SIZE)) {
+        fprintf(stderr, "%s is not a PNG file.\n", pInput);
+        goto exit;
+    }
+
+    if (!(png_ptr = png_create_read_struct(PNG_LIBPNG_VER_STRING,
+            (png_voidp) NULL, user_error_fn, user_warning_fn))) {
+        fprintf(stderr, "Could not initialize png read struct.\n");
+        goto exit;
+    }
+
+    if (!(info_ptr = png_create_info_struct(png_ptr))) {
+        fprintf(stderr, "Could not create info struct.\n");
+        goto exit;
+    }
+    if (!(end_info = png_create_info_struct(png_ptr))) {
+        fprintf(stderr, "Could not create end_info struct.\n");
+        goto exit;
+    }
+
+    if (setjmp(png_jmpbuf(png_ptr))) {
+        goto exit;
+    }
+
+    png_init_io(png_ptr, pIn);
+    png_set_sig_bytes(png_ptr, PNG_HEADER_SIZE);
+    png_read_png(png_ptr, info_ptr, PNG_TRANSFORM_IDENTITY
+            | PNG_TRANSFORM_STRIP_16 | PNG_TRANSFORM_STRIP_ALPHA
+            | PNG_TRANSFORM_PACKING, NULL);
+
+    row_pointers = png_get_rows(png_ptr, info_ptr);
+    {
+        int bit_depth, color_type;
+        png_get_IHDR(png_ptr, info_ptr, &width, &height, &bit_depth,
+                &color_type, NULL, NULL, NULL);
+    }
+
+    stride = 3 * width;
+
+    pSourceImage = new etc1_byte[stride * height];
+    if (! pSourceImage) {
+        fprintf(stderr, "Out of memory.\n");
+        goto exit;
+    }
+
+    for (etc1_uint32 y = 0; y < height; y++) {
+        memcpy(pSourceImage + y * stride, row_pointers[y], stride);
+    }
+
+    *pWidth = width;
+    *pHeight = height;
+    *ppImageData = pSourceImage;
+
+    result = 0;
+    exit:
+    if (result) {
+        delete[] pSourceImage;
+    }
+    if (png_ptr) {
+        png_destroy_read_struct(&png_ptr, &info_ptr, &end_info);
+    }
+    if (pIn) {
+        fclose(pIn);
+    }
+
+    return result;
+}
+
+// Read a PNG file into a contiguous buffer.
+// Returns non-zero if an error occurred.
+// caller has to delete[] *ppImageData when done with the image.
+int readPKMFile(const char* pInput, etc1_byte** ppImageData,
+        etc1_uint32* pWidth, etc1_uint32* pHeight) {
+    int result = -1;
+    FILE* pIn = NULL;
+    etc1_byte header[ETC_PKM_HEADER_SIZE];
+    png_bytep pEncodedData = NULL;
+    png_bytep pImageData = NULL;
+
+    png_uint_32 width = 0;
+    png_uint_32 height = 0;
+    png_uint_32 stride = 0;
+    png_uint_32 encodedSize = 0;
+
+    if ((pIn = fopen(pInput, "rb")) == NULL) {
+        fprintf(stderr, "Could not open input file %s for reading: %d\n",
+                pInput, errno);
+        goto exit;
+    }
+
+    if (fread(header, sizeof(header), 1, pIn) != 1) {
+        fprintf(stderr, "Could not read header from input file %s: %d\n",
+                pInput, errno);
+        goto exit;
+    }
+
+    if (! etc1_pkm_is_valid(header)) {
+        fprintf(stderr, "Bad header PKM header for input file %s\n", pInput);
+        goto exit;
+    }
+
+    width = etc1_pkm_get_width(header);
+    height = etc1_pkm_get_height(header);
+    encodedSize = etc1_get_encoded_data_size(width, height);
+
+    pEncodedData = new png_byte[encodedSize];
+    if (!pEncodedData) {
+        fprintf(stderr, "Out of memory.\n");
+        goto exit;
+    }
+
+    if (fread(pEncodedData, encodedSize, 1, pIn) != 1) {
+        fprintf(stderr, "Could not read encoded data from input file %s: %d\n",
+                pInput, errno);
+        goto exit;
+    }
+
+    fclose(pIn);
+    pIn = NULL;
+
+    stride = width * 3;
+    pImageData = new png_byte[stride * height];
+    if (!pImageData) {
+        fprintf(stderr, "Out of memory.\n");
+        goto exit;
+    }
+
+    etc1_decode_image(pEncodedData, pImageData, width, height, 3, stride);
+
+    // Success
+    result = 0;
+    *ppImageData = pImageData;
+    pImageData = 0;
+    *pWidth = width;
+    *pHeight = height;
+
+    exit:
+    delete[] pEncodedData;
+    delete[] pImageData;
+    if (pIn) {
+        fclose(pIn);
+    }
+
+    return result;
+}
+
+
+// Encode the file.
+// Returns non-zero if an error occurred.
+
+int encode(const char* pInput, const char* pOutput, bool bEmitHeader, const char* pDiffFile) {
+    FILE* pOut = NULL;
+    etc1_uint32 width = 0;
+    etc1_uint32 height = 0;
+    etc1_uint32 encodedSize = 0;
+    int result = -1;
+    etc1_byte* pSourceImage = 0;
+    etc1_byte* pEncodedData = 0;
+    etc1_byte* pDiffImage = 0; // Used for differencing
+
+    if (read_PNG_File(pInput, &pSourceImage, &width, &height)) {
+        goto exit;
+    }
+
+    encodedSize = etc1_get_encoded_data_size(width, height);
+    pEncodedData = new etc1_byte[encodedSize];
+    if (!pEncodedData) {
+        fprintf(stderr, "Out of memory.\n");
+        goto exit;
+    }
+
+    etc1_encode_image(pSourceImage,
+            width, height, 3, width * 3, pEncodedData);
+
+    if ((pOut = fopen(pOutput, "wb")) == NULL) {
+        fprintf(stderr, "Could not open output file %s: %d\n", pOutput, errno);
+        goto exit;
+    }
+
+    if (bEmitHeader) {
+        etc1_byte header[ETC_PKM_HEADER_SIZE];
+        etc1_pkm_format_header(header, width, height);
+        if (fwrite(header, sizeof(header), 1, pOut) != 1) {
+            fprintf(stderr,
+                    "Could not write header output file %s: %d\n",
+                    pOutput, errno);
+            goto exit;
+        }
+    }
+
+    if (fwrite(pEncodedData, encodedSize, 1, pOut) != 1) {
+        fprintf(stderr,
+                "Could not write encoded data to output file %s: %d\n",
+                pOutput, errno);
+        goto exit;
+    }
+
+    fclose(pOut);
+    pOut = NULL;
+
+    if (pDiffFile) {
+        etc1_uint32 outWidth;
+        etc1_uint32 outHeight;
+        if (readPKMFile(pOutput, &pDiffImage, &outWidth, &outHeight)) {
+            goto exit;
+        }
+        if (outWidth != width || outHeight != height) {
+            fprintf(stderr, "Output file has incorrect bounds: %u, %u != %u, %u\n",
+                    outWidth, outHeight, width, height);
+            goto exit;
+        }
+        const etc1_byte* pSrc = pSourceImage;
+        etc1_byte* pDest = pDiffImage;
+        etc1_uint32 size = width * height * 3;
+        for (etc1_uint32 i = 0; i < size; i++) {
+            int diff = *pSrc++ - *pDest;
+            diff *= diff;
+            diff <<= 3;
+            if (diff < 0) {
+                diff = 0;
+            } else if (diff > 255) {
+                diff = 255;
+            }
+            *pDest++ = (png_byte) diff;
+        }
+        writePNGFile(pDiffFile, outWidth, outHeight, pDiffImage, 3 * outWidth);
+    }
+
+    // Success
+    result = 0;
+
+    exit:
+    delete[] pSourceImage;
+    delete[] pEncodedData;
+    delete[] pDiffImage;
+
+    if (pOut) {
+        fclose(pOut);
+    }
+    return result;
+}
+
+int writePNGFile(const char* pOutput, png_uint_32 width, png_uint_32 height,
+        const png_bytep pImageData, png_uint_32 imageStride) {
+    int result = -1;
+    FILE* pOut = NULL;
+    png_structp png_ptr = NULL;
+    png_infop info_ptr = NULL;
+
+    if (!(png_ptr = png_create_write_struct(PNG_LIBPNG_VER_STRING,
+            (png_voidp) NULL, user_error_fn, user_warning_fn)) || !(info_ptr
+            = png_create_info_struct(png_ptr))) {
+        fprintf(stderr, "Could not initialize PNG library for writing.\n");
+        goto exit;
+    }
+
+    if (setjmp(png_jmpbuf(png_ptr))) {
+        goto exit;
+    }
+
+    if ((pOut = fopen(pOutput, "wb")) == NULL) {
+        fprintf(stderr, "Could not open output file %s: %d\n", pOutput, errno);
+        goto exit;
+    }
+
+    png_init_io(png_ptr, pOut);
+
+    png_set_IHDR(png_ptr, info_ptr, width, height, 8, PNG_COLOR_TYPE_RGB,
+            PNG_INTERLACE_NONE, PNG_COMPRESSION_TYPE_DEFAULT,
+            PNG_FILTER_TYPE_DEFAULT);
+
+    png_write_info(png_ptr, info_ptr);
+
+    for (png_uint_32 y = 0; y < height; y++) {
+        png_write_row(png_ptr, pImageData + y * imageStride);
+    }
+    png_write_end(png_ptr, info_ptr);
+
+    result = 0;
+
+    exit: if (png_ptr) {
+        png_destroy_write_struct(&png_ptr, &info_ptr);
+    }
+
+    if (pOut) {
+        fclose(pOut);
+    }
+    return result;
+}
+
+int decode(const char* pInput, const char* pOutput) {
+    int result = -1;
+    png_bytep pImageData = NULL;
+    etc1_uint32 width = 0;
+    etc1_uint32 height = 0;
+
+    if (readPKMFile(pInput, &pImageData, &width, &height)) {
+        goto exit;
+    }
+
+    if (writePNGFile(pOutput, width, height, pImageData, width * 3)) {
+        goto exit;
+    }
+
+    // Success
+    result = 0;
+
+    exit: delete[] pImageData;
+
+    return result;
+}
+
+void multipleEncodeDecodeCheck(bool* pbEncodeDecodeSeen) {
+    if (*pbEncodeDecodeSeen) {
+        usage("At most one occurrence of --encode --encodeNoHeader or --decode is allowed.\n");
+    }
+    *pbEncodeDecodeSeen = true;
+}
+
+int main(int argc, char** argv) {
+    gpExeName = argv[0];
+    const char* pInput = NULL;
+    const char* pOutput = NULL;
+    const char* pDiffFile = NULL;
+    char* pOutputFileBuff = NULL;
+
+    bool bEncodeDecodeSeen = false;
+    bool bEncode = false;
+    bool bEncodeHeader = false;
+    bool bDecode = false;
+    bool bShowDifference = false;
+
+    for (int i = 1; i < argc; i++) {
+        const char* pArg = argv[i];
+        if (pArg[0] == '-') {
+            char c = pArg[1];
+            switch (c) {
+            case 'o':
+                if (pOutput != NULL) {
+                    usage("Only one -o flag allowed.");
+                }
+                if (i + 1 >= argc) {
+                    usage("Expected outfile after -o");
+                }
+                pOutput = argv[++i];
+                break;
+            case '-':
+                if (strcmp(pArg, "--encode") == 0) {
+                    multipleEncodeDecodeCheck(&bEncodeDecodeSeen);
+                    bEncode = true;
+                    bEncodeHeader = true;
+                } else if (strcmp(pArg, "--encodeNoHeader") == 0) {
+                    multipleEncodeDecodeCheck(&bEncodeDecodeSeen);
+                    bEncode = true;
+                    bEncodeHeader = false;
+                } else if (strcmp(pArg, "--decode") == 0) {
+                    multipleEncodeDecodeCheck(&bEncodeDecodeSeen);
+                    bDecode = true;
+                } else if (strcmp(pArg, "--showDifference") == 0) {
+                    if (bShowDifference) {
+                        usage("Only one --showDifference option allowed.\n");
+                    }
+                    bShowDifference = true;
+                    if (i + 1 >= argc) {
+                        usage("Expected difffile after --showDifference");
+                    }
+                    pDiffFile = argv[++i];
+                } else if (strcmp(pArg, "--help") == 0) {
+                    usage( NULL);
+                } else {
+                    usage("Unknown flag %s", pArg);
+                }
+
+                break;
+            default:
+                usage("Unknown flag %s", pArg);
+                break;
+            }
+        } else {
+            if (pInput != NULL) {
+                usage(
+                        "Only one input file allowed. Already have %s, now see %s",
+                        pInput, pArg);
+            }
+            pInput = pArg;
+        }
+    }
+
+    if (!bEncodeDecodeSeen) {
+        bEncode = true;
+        bEncodeHeader = true;
+    }
+    if ((! bEncode) && bShowDifference) {
+        usage("--showDifference is only valid when encoding.");
+    }
+
+    if (!pInput) {
+        usage("Expected an input file.");
+    }
+
+    if (!pOutput) {
+        const char* kDefaultExtension = bEncode ? ".pkm" : ".png";
+        size_t buffSize = strlen(pInput) + strlen(kDefaultExtension) + 1;
+        pOutputFileBuff = new char[buffSize];
+        strcpy(pOutputFileBuff, pInput);
+        if (changeExtension(pOutputFileBuff, buffSize, kDefaultExtension)) {
+            usage("Could not change extension of input file name: %s\n", pInput);
+        }
+        pOutput = pOutputFileBuff;
+    }
+
+    if (bEncode) {
+        encode(pInput, pOutput, bEncodeHeader, pDiffFile);
+    } else {
+        decode(pInput, pOutput);
+    }
+
+    delete[] pOutputFileBuff;
+
+    return 0;
+}