am 2384a4dc: am d63680fb: am 9487df9a: Merge "Remove auto-gen project.properties"

* commit '2384a4dceedc1218aaaf62bb91e4a05cdbe3425d':
  Remove auto-gen project.properties
diff --git a/apps/Development/AndroidManifest.xml b/apps/Development/AndroidManifest.xml
index ffee933..f2bf60c 100644
--- a/apps/Development/AndroidManifest.xml
+++ b/apps/Development/AndroidManifest.xml
@@ -63,8 +63,6 @@
         </activity>
         <activity android:name="PackageSummary" android:label="Package Summary">
         </activity>
-        <activity android:name="ShowActivity" android:label="Activity">
-        </activity>
         <activity android:name="AppPicker"
                 android:theme="@android:style/Theme.Dialog">
         </activity>
@@ -103,12 +101,6 @@
                 <category android:name="android.intent.category.TEST" />
             </intent-filter>
         </activity>
-        <activity android:name="DevelopmentSettings" android:label="Development Settings" >
-            <intent-filter>
-                <action android:name="android.intent.action.MAIN" />
-                <category android:name="android.intent.category.TEST" />
-            </intent-filter>
-        </activity>
 
         <activity android:name="InstrumentationList" android:label="Instrumentation">
             <intent-filter>
diff --git a/apps/Development/res/layout/accounts_tester.xml b/apps/Development/res/layout/accounts_tester.xml
index 28f1b4e..3bf408e 100644
--- a/apps/Development/res/layout/accounts_tester.xml
+++ b/apps/Development/res/layout/accounts_tester.xml
@@ -20,95 +20,56 @@
         android:layout_height="match_parent">
 
     <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
-            android:orientation="vertical"
+            android:orientation="horizontal"
             android:layout_width="match_parent"
             android:layout_height="wrap_content">
 
-        <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
-                android:orientation="horizontal"
-                android:layout_width="match_parent"
-                android:layout_height="wrap_content">
+        <TextView android:id="@+id/accounts_tester_account_types_spinner_label"
+                  android:layout_width="wrap_content"
+                  android:layout_height="wrap_content"
+                  android:text="@string/accounts_tester_select_account_type"/>
 
-            <TextView android:id="@+id/accounts_tester_account_types_spinner_label"
-                      android:layout_width="wrap_content"
-                      android:layout_height="wrap_content"
-                      android:text="@string/accounts_tester_select_account_type"/>
+        <Spinner android:id="@+id/accounts_tester_account_types_spinner"
+                 android:layout_width="wrap_content"
+                 android:layout_height="wrap_content"/>
+    </LinearLayout>
 
-            <Spinner android:id="@+id/accounts_tester_account_types_spinner"
-                     android:layout_width="wrap_content"
-                     android:layout_height="wrap_content"/>
-        </LinearLayout>
+    <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
+            android:orientation="horizontal"
+            android:layout_width="match_parent"
+            android:layout_height="wrap_content">
+        <Button
+                android:id="@+id/accounts_tester_get_accounts_by_type"
+                android:layout_width="wrap_content"
+                android:layout_height="wrap_content"
+                android:text="@string/accounts_tester_get_accounts_by_type"/>
 
-        <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
-                android:orientation="vertical"
-                android:layout_width="match_parent"
-                android:layout_height="wrap_content">
+        <Button
+                android:id="@+id/accounts_tester_get_all_accounts"
+                android:layout_width="wrap_content"
+                android:layout_height="wrap_content"
+                android:text="@string/accounts_tester_get_all_accounts"/>
 
-            <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
-                    android:orientation="horizontal"
-                    android:layout_width="match_parent"
-                    android:layout_height="wrap_content">
-                <Button
-                        android:id="@+id/accounts_tester_get_accounts_by_type"
-                        android:layout_width="wrap_content"
-                        android:layout_height="wrap_content"
-                        android:text="@string/accounts_tester_get_accounts_by_type"/>
+        <Button android:id="@+id/accounts_tester_get_auth_token_by_type_and_feature"
+                android:layout_width="wrap_content"
+                android:layout_height="wrap_content"
+                android:text="@string/accounts_tester_get_auth_token_by_type_and_feature"/>
 
-                <Button
-                        android:id="@+id/accounts_tester_get_all_accounts"
-                        android:layout_width="wrap_content"
-                        android:layout_height="wrap_content"
-                        android:text="@string/accounts_tester_get_all_accounts"/>
+    </LinearLayout>
 
-                <Button android:id="@+id/accounts_tester_add_account"
-                        android:layout_width="wrap_content"
-                        android:layout_height="wrap_content"
-                        android:text="@string/accounts_tester_add_account"/>
+    <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
+            android:orientation="horizontal"
+            android:layout_width="match_parent"
+            android:layout_height="wrap_content">
+        <Button android:id="@+id/accounts_tester_add_account"
+                android:layout_width="wrap_content"
+                android:layout_height="wrap_content"
+                android:text="@string/accounts_tester_add_account"/>
 
-                <Button android:id="@+id/accounts_tester_edit_properties"
-                        android:layout_width="wrap_content"
-                        android:layout_height="wrap_content"
-                        android:text="@string/accounts_tester_edit_properties"/>
-
-                <Button android:id="@+id/accounts_tester_get_auth_token_by_type_and_feature"
-                        android:layout_width="wrap_content"
-                        android:layout_height="wrap_content"
-                        android:text="@string/accounts_tester_get_auth_token_by_type_and_feature"/>
-
-            </LinearLayout>
-
-            <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
-                    android:orientation="horizontal"
-                    android:layout_width="match_parent"
-                    android:layout_height="wrap_content">
-
-                <TextView android:id="@+id/accounts_tester_desiredFeatures"
-                          android:layout_width="wrap_content"
-                          android:layout_height="wrap_content"
-                          android:text="@string/accounts_tester_desired_features_label"/>
-
-                <EditText android:id="@+id/accounts_tester_desired_features"
-                          android:layout_width="wrap_content"
-                          android:layout_height="wrap_content"
-                          android:minEms="15"/>
-            </LinearLayout>
-
-            <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
-                    android:orientation="horizontal"
-                    android:layout_width="match_parent"
-                    android:layout_height="wrap_content">
-
-                <TextView android:id="@+id/accounts_tester_desiredFeatures"
-                          android:layout_width="wrap_content"
-                          android:layout_height="wrap_content"
-                          android:text="@string/accounts_tester_desired_authtokentype_label"/>
-
-                <EditText android:id="@+id/accounts_tester_desired_authtokentype"
-                          android:layout_width="wrap_content"
-                          android:layout_height="wrap_content"
-                          android:minEms="15"/>
-            </LinearLayout>
-        </LinearLayout>
+        <Button android:id="@+id/accounts_tester_edit_properties"
+                android:layout_width="wrap_content"
+                android:layout_height="wrap_content"
+                android:text="@string/accounts_tester_edit_properties"/>
     </LinearLayout>
 
     <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
@@ -116,9 +77,34 @@
             android:layout_width="match_parent"
             android:layout_height="wrap_content">
 
-        <ListView android:id="@+id/accounts_tester_accounts_list"
-                  android:layout_width="match_parent" android:layout_height="match_parent"/>
+        <TextView android:id="@+id/accounts_tester_desiredFeatures"
+                  android:layout_width="wrap_content"
+                  android:layout_height="wrap_content"
+                  android:text="@string/accounts_tester_desired_features_label"/>
 
+        <EditText android:id="@+id/accounts_tester_desired_features"
+                  android:layout_width="wrap_content"
+                  android:layout_height="wrap_content"
+                  android:minEms="15"/>
     </LinearLayout>
 
+    <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
+            android:orientation="horizontal"
+            android:layout_width="match_parent"
+            android:layout_height="wrap_content">
+
+        <TextView android:id="@+id/accounts_tester_desiredFeatures"
+                  android:layout_width="wrap_content"
+                  android:layout_height="wrap_content"
+                  android:text="@string/accounts_tester_desired_authtokentype_label"/>
+
+        <EditText android:id="@+id/accounts_tester_desired_authtokentype"
+                  android:layout_width="wrap_content"
+                  android:layout_height="wrap_content"
+                  android:minEms="15"/>
+    </LinearLayout>
+
+    <ListView android:id="@+id/accounts_tester_accounts_list"
+              android:layout_width="match_parent" android:layout_height="match_parent"/>
+
 </LinearLayout>
diff --git a/apps/Development/src/com/android/development/AccountsTester.java b/apps/Development/src/com/android/development/AccountsTester.java
index b4155e7..09f4995 100644
--- a/apps/Development/src/com/android/development/AccountsTester.java
+++ b/apps/Development/src/com/android/development/AccountsTester.java
@@ -16,21 +16,39 @@
 
 package com.android.development;
 
+import android.accounts.Account;
+import android.accounts.AccountManager;
+import android.accounts.AccountManagerCallback;
+import android.accounts.AccountManagerFuture;
+import android.accounts.AuthenticatorDescription;
+import android.accounts.AuthenticatorException;
+import android.accounts.OnAccountsUpdateListener;
+import android.accounts.OperationCanceledException;
 import android.app.Activity;
-import android.app.Dialog;
 import android.app.AlertDialog;
-import android.content.*;
+import android.app.Dialog;
+import android.content.Context;
+import android.content.DialogInterface;
 import android.content.pm.PackageManager;
 import android.content.res.Resources;
-import android.accounts.*;
 import android.os.Bundle;
-import android.os.Parcelable;
 import android.os.Handler;
-import android.view.*;
-import android.widget.*;
-import android.widget.ArrayAdapter;
-import android.util.Log;
+import android.os.Parcelable;
 import android.text.TextUtils;
+import android.util.Log;
+import android.view.ContextMenu;
+import android.view.LayoutInflater;
+import android.view.MenuInflater;
+import android.view.MenuItem;
+import android.view.View;
+import android.view.ViewGroup;
+import android.widget.AdapterView;
+import android.widget.ArrayAdapter;
+import android.widget.EditText;
+import android.widget.ImageView;
+import android.widget.ListView;
+import android.widget.Spinner;
+import android.widget.TextView;
 
 import java.io.IOException;
 import java.util.ArrayList;
diff --git a/apps/Development/src/com/android/development/AppPicker.java b/apps/Development/src/com/android/development/AppPicker.java
deleted file mode 100644
index 28040c2..0000000
--- a/apps/Development/src/com/android/development/AppPicker.java
+++ /dev/null
@@ -1,143 +0,0 @@
-/* //device/java/android/android/app/ResolveListActivity.java
-**
-** Copyright 2006, 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.android.development.PackageBrowser.MyPackageInfo;
-
-import android.app.ActivityManagerNative;
-import android.app.ListActivity;
-import android.content.Context;
-import android.content.Intent;
-import android.content.pm.ApplicationInfo;
-import android.content.pm.PackageInfo;
-import android.os.Bundle;
-import android.os.RemoteException;
-import android.provider.Settings;
-import android.view.View;
-import android.view.ViewGroup;
-import android.view.LayoutInflater;
-import android.widget.BaseAdapter;
-import android.widget.ImageView;
-import android.widget.ListView;
-import android.widget.TextView;
-
-import java.text.Collator;
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.Comparator;
-import java.util.List;
-
-public class AppPicker extends ListActivity
-{
-    @Override
-    protected void onCreate(Bundle icicle)
-    {
-        super.onCreate(icicle);
-
-        mAdapter = new AppListAdapter(this);
-        if (mAdapter.getCount() <= 0) {
-            finish();
-        } else {
-            setListAdapter(mAdapter);
-        }
-    }
-    
-    @Override
-    protected void onResume()
-    {
-        super.onResume();
-    }
-
-    @Override
-    protected void onStop()
-    {
-        super.onStop();
-    }
-
-    @Override
-    protected void onListItemClick(ListView l, View v, int position, long id)
-    {
-        MyApplicationInfo app = mAdapter.itemForPosition(position);
-        Intent intent = new Intent();
-        if (app.info != null) intent.setAction(app.info.packageName);
-        setResult(RESULT_OK, intent);
-        
-        try {
-            boolean waitForDebugger = Settings.System.getInt(
-                    getContentResolver(), Settings.System.WAIT_FOR_DEBUGGER, 0) != 0;
-            ActivityManagerNative.getDefault().setDebugApp(
-                    app.info != null ? app.info.packageName : null, waitForDebugger, true);
-        } catch (RemoteException ex) {
-        }
-        
-        finish();
-    }
-
-    class MyApplicationInfo {
-        ApplicationInfo info;
-        String label;
-    }
-    
-    public class AppListAdapter extends ArrayAdapter<MyApplicationInfo> {
-        private List<MyApplicationInfo> mPackageInfoList = new ArrayList<MyApplicationInfo>();
-
-        public AppListAdapter(Context context) {
-            super(context, R.layout.package_list_item);
-            List<ApplicationInfo> pkgs = context.getPackageManager().getInstalledApplications(0);
-            for (int i=0; i<pkgs.size(); i++) {
-                MyApplicationInfo info = new MyApplicationInfo();
-                info.info = pkgs.get(i);
-                info.label = info.info.loadLabel(getPackageManager()).toString();
-                mPackageInfoList.add(info);
-            }
-            Collections.sort(mPackageInfoList, sDisplayNameComparator);
-            MyApplicationInfo info = new MyApplicationInfo();
-            info.label = "(none)";
-            mPackageInfoList.add(0, info);
-            setSource(mPackageInfoList);
-        }
-    
-        @Override
-        public void bindView(View view, MyApplicationInfo info) {
-            ImageView icon = (ImageView)view.findViewById(R.id.icon);
-            TextView name = (TextView)view.findViewById(R.id.name);
-            TextView description = (TextView)view.findViewById(R.id.description);
-            name.setText(info.label);
-            if (info.info != null) {
-                icon.setImageDrawable(info.info.loadIcon(getPackageManager()));
-                description.setText(info.info.packageName);
-            } else {
-                icon.setImageDrawable(null);
-                description.setText("");
-            }
-        }
-    }
-
-    private final static Comparator<MyApplicationInfo> sDisplayNameComparator
-            = new Comparator<MyApplicationInfo>() {
-        public final int
-        compare(MyApplicationInfo a, MyApplicationInfo b) {
-            return collator.compare(a.label, b.label);
-        }
-
-        private final Collator   collator = Collator.getInstance();
-    };
-
-    private AppListAdapter mAdapter;
-}
-
diff --git a/apps/Development/src/com/android/development/DevelopmentSettings.java b/apps/Development/src/com/android/development/DevelopmentSettings.java
deleted file mode 100644
index f907a14..0000000
--- a/apps/Development/src/com/android/development/DevelopmentSettings.java
+++ /dev/null
@@ -1,628 +0,0 @@
-/* //device/apps/Settings/src/com/android/settings/Keyguard.java
-**
-** Copyright 2006, 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 android.app.Activity;
-import android.app.ActivityManagerNative;
-import android.content.Context;
-import android.content.Intent;
-import android.content.SharedPreferences;
-import android.content.pm.PackageManager.NameNotFoundException;
-import android.os.Bundle;
-import android.os.IBinder;
-import android.os.Parcel;
-import android.os.RemoteException;
-import android.os.ServiceManager;
-import android.os.ServiceManagerNative;
-import android.os.StrictMode;
-import android.os.SystemProperties;
-import android.provider.Settings;
-import android.text.TextUtils;
-import android.util.Log;
-import android.view.IWindowManager;
-import android.view.View;
-import android.widget.AdapterView.OnItemSelectedListener;
-import android.widget.ArrayAdapter;
-import android.widget.Button;
-import android.widget.CheckBox;
-import android.widget.CompoundButton;
-import android.widget.Spinner;
-import android.widget.Toast;
-
-import java.io.FileInputStream;
-import java.io.FileOutputStream;
-import java.util.Map;
-
-public class DevelopmentSettings extends Activity {
-    private static final String TAG = "DevelopmentSettings";
-    private static final int DEBUG_APP_REQUEST = 1;
-
-    private Button mDebugAppButton;
-    private CheckBox mWaitForDebuggerCB;
-    private CheckBox mAlwaysFinishCB;
-    private Spinner mPointerLocationSpinner;
-    private Spinner mStrictModeVisualSpinner;
-    private CheckBox mShowLoadCB;
-    private CheckBox mShowCpuCB;
-    private CheckBox mEnableGLCB;
-    private CheckBox mShowUpdatesCB;
-    private CheckBox mShowBackgroundCB;
-    private CheckBox mShowSleepCB;
-    private CheckBox mShowXmppCB;
-    private CheckBox mWindowOrientationListenerLogCB;
-    private CheckBox mCompatibilityModeCB;
-    private Spinner mMaxProcsSpinner;
-    private Spinner mWindowAnimationScaleSpinner;
-    private Spinner mTransitionAnimationScaleSpinner;
-    private Spinner mFontHintingSpinner;
-
-    private String mDebugApp;
-    private boolean mWaitForDebugger;
-    private boolean mAlwaysFinish;
-    private int mPointerLocation;
-    private int mWindowOrientationListenerLog;
-    private int mProcessLimit;
-    private boolean mShowSleep;
-    private boolean mShowXmpp;
-    private boolean mCompatibilityMode;
-    private AnimationScaleSelectedListener mWindowAnimationScale
-            = new AnimationScaleSelectedListener(0);
-    private AnimationScaleSelectedListener mTransitionAnimationScale
-            = new AnimationScaleSelectedListener(1);
-    private SharedPreferences mSharedPrefs;
-    private IWindowManager mWindowManager;
-
-    private static final boolean FONT_HINTING_ENABLED = true;
-    private static final String  FONT_HINTING_FILE = "/data/misc/font-hack";
-
-    @Override
-    public void onCreate(Bundle icicle) {
-        super.onCreate(icicle);
-
-        setContentView(R.layout.development_settings);
-
-        mDebugAppButton = (Button)findViewById(R.id.debug_app);
-        mDebugAppButton.setOnClickListener(mDebugAppClicked);
-        mWaitForDebuggerCB = (CheckBox)findViewById(R.id.wait_for_debugger);
-        mWaitForDebuggerCB.setOnClickListener(mWaitForDebuggerClicked);
-        mAlwaysFinishCB = (CheckBox)findViewById(R.id.always_finish);
-        mAlwaysFinishCB.setOnClickListener(mAlwaysFinishClicked);
-        mPointerLocationSpinner = (Spinner)findViewById(R.id.pointer_location);
-        mPointerLocationSpinner.setOnItemSelectedListener(mPointerLocationChanged);
-        ArrayAdapter<String> adapter = new ArrayAdapter<String>(
-                this,
-                android.R.layout.simple_spinner_item,
-                new String[] {
-                        "No Pointer Location",
-                        "Pointer Location" });
-        adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
-        mPointerLocationSpinner.setAdapter(adapter);
-        mStrictModeVisualSpinner = (Spinner)findViewById(R.id.strictmode_visual);
-        adapter = new ArrayAdapter<String>(
-                this,
-                android.R.layout.simple_spinner_item,
-                new String[] {
-                        "StrictMode visual indicator: build variant default",
-                        "StrictMode visual indicator: on",
-                        "StrictMode visual indicator: off" });
-        adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
-        mStrictModeVisualSpinner.setAdapter(adapter);
-        mStrictModeVisualSpinner.setOnItemSelectedListener(mStrictModeVisualChanged);
-        mShowLoadCB = (CheckBox)findViewById(R.id.show_load);
-        mShowLoadCB.setOnClickListener(mShowLoadClicked);
-        mShowCpuCB = (CheckBox)findViewById(R.id.show_cpu);
-        mShowCpuCB.setOnCheckedChangeListener(new SurfaceFlingerClicker(1000));
-        mEnableGLCB = (CheckBox)findViewById(R.id.enable_gl);
-        mEnableGLCB.getLayoutParams().height = 0; // doesn't do anything
-        mEnableGLCB.setOnCheckedChangeListener(new SurfaceFlingerClicker(1004));
-        mShowUpdatesCB = (CheckBox)findViewById(R.id.show_updates);
-        mShowUpdatesCB.setOnCheckedChangeListener(new SurfaceFlingerClicker(1002));
-        mShowBackgroundCB = (CheckBox)findViewById(R.id.show_background);
-        mShowBackgroundCB.setOnCheckedChangeListener(new SurfaceFlingerClicker(1003));
-        mShowSleepCB = (CheckBox)findViewById(R.id.show_sleep);
-        mShowSleepCB.setOnClickListener(mShowSleepClicked);
-        mShowXmppCB = (CheckBox)findViewById(R.id.show_xmpp);
-        mShowXmppCB.setOnClickListener(mShowXmppClicked);
-        mWindowOrientationListenerLogCB = (CheckBox)findViewById(R.id.window_orientation_listener_log);
-        mWindowOrientationListenerLogCB.setOnClickListener(mWindowOrientationListenerLogClicked);
-        mCompatibilityModeCB = (CheckBox)findViewById(R.id.compatibility_mode);
-        mCompatibilityModeCB.setOnClickListener(mCompatibilityModeClicked);
-        mMaxProcsSpinner = (Spinner)findViewById(R.id.max_procs);
-        mMaxProcsSpinner.setOnItemSelectedListener(mMaxProcsChanged);
-        adapter = new ArrayAdapter<String>(
-                this,
-                android.R.layout.simple_spinner_item,
-                new String[] {
-                        "No App Process Limit",
-                        "Max 1 App Process",
-                        "Max 2 App Processes",
-                        "Max 3 App Processes",
-                        "Max 4 App Processes" });
-        adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
-        mMaxProcsSpinner.setAdapter(adapter);
-        mWindowAnimationScaleSpinner = setupAnimationSpinner(
-                R.id.window_animation_scale, mWindowAnimationScale, "Window");
-        mTransitionAnimationScaleSpinner = setupAnimationSpinner(
-                R.id.transition_animation_scale, mTransitionAnimationScale, "Transition");
-
-        if (FONT_HINTING_ENABLED) {
-            mFontHintingSpinner = (Spinner)findViewById(R.id.font_hinting);
-            mFontHintingSpinner.setOnItemSelectedListener(mFontHintingChanged);
-            adapter = new ArrayAdapter<String>(
-                    this,
-                    android.R.layout.simple_spinner_item,
-                    new String[] {
-                            "Light Hinting",
-                            "Medium Hinting" });
-            adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
-            mFontHintingSpinner.setAdapter(adapter);
-        }
-        mSharedPrefs = getSharedPreferences("global", 0);
-        mWindowManager = IWindowManager.Stub.asInterface(ServiceManager.getService("window"));
-    }
-
-    Spinner setupAnimationSpinner(int resid,
-            AnimationScaleSelectedListener listener, String name) {
-        Spinner spinner = (Spinner)findViewById(resid);
-        spinner.setOnItemSelectedListener(listener);
-        ArrayAdapter adapter = new ArrayAdapter<String>(
-                this,
-                android.R.layout.simple_spinner_item,
-                new String[] {
-                        name + " Animation Scale 1x",
-                        name + " Animation Scale 2x",
-                        name + " Animation Scale 5x",
-                        name + " Animation Scale 10x",
-                        name + " Animation Off" });
-        adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
-        spinner.setAdapter(adapter);
-        listener.spinner = spinner;
-        return spinner;
-    }
-    
-    @Override
-    public void onResume() {
-        super.onResume();
-        updateDebugOptions();
-        updateFinishOptions();
-        updatePointerLocationOptions();
-        updateStrictModeVisualOptions();
-        updateProcessLimitOptions();
-        updateSharedOptions();
-        updateFlingerOptions();
-        updateSleepOptions();
-        updateXmppOptions();
-        updateWindowOrientationListenerLogOptions();
-        updateCompatibilityOptions();
-
-        try {
-            FileInputStream  in = new FileInputStream( FONT_HINTING_FILE );
-            int    mode = in.read() - 48;
-            if (mode >= 0 && mode < 3)
-                mFontHintingSpinner.setSelection(mode);
-            in.close();
-        } catch (Exception e) {
-        }
-
-        mWindowAnimationScale.load();
-        mTransitionAnimationScale.load();
-    }
-
-    private void writeDebugOptions() {
-        try {
-            ActivityManagerNative.getDefault().setDebugApp(
-                mDebugApp, mWaitForDebugger, true);
-        } catch (RemoteException ex) {
-        }
-    }
-
-    private void updateDebugOptions() {
-        mDebugApp = Settings.System.getString(
-            getContentResolver(), Settings.System.DEBUG_APP);
-        mWaitForDebugger = Settings.System.getInt(
-            getContentResolver(), Settings.System.WAIT_FOR_DEBUGGER, 0) != 0;
-
-        mDebugAppButton.setText(
-            mDebugApp == null || mDebugApp.length() == 0 ? "(none)" : mDebugApp);
-        mWaitForDebuggerCB.setChecked(mWaitForDebugger);
-    }
-
-    private void writeFinishOptions() {
-        try {
-            ActivityManagerNative.getDefault().setAlwaysFinish(mAlwaysFinish);
-        } catch (RemoteException ex) {
-        }
-    }
-
-    private void updateFinishOptions() {
-        mAlwaysFinish = Settings.System.getInt(
-            getContentResolver(), Settings.System.ALWAYS_FINISH_ACTIVITIES, 0) != 0;
-        mAlwaysFinishCB.setChecked(mAlwaysFinish);
-    }
-
-    private void writePointerLocationOptions() {
-        Settings.System.putInt(getContentResolver(),
-                Settings.System.POINTER_LOCATION, mPointerLocation);
-    }
-
-    private void updatePointerLocationOptions() {
-        mPointerLocation = Settings.System.getInt(getContentResolver(),
-                Settings.System.POINTER_LOCATION, 0);
-        mPointerLocationSpinner.setSelection(mPointerLocation);
-    }
-
-    private void writeWindowOrientationListenerLogOptions() {
-        Settings.System.putInt(getContentResolver(),
-                Settings.System.WINDOW_ORIENTATION_LISTENER_LOG, mWindowOrientationListenerLog);
-    }
-
-    private void updateWindowOrientationListenerLogOptions() {
-        mWindowOrientationListenerLog = Settings.System.getInt(getContentResolver(),
-                Settings.System.WINDOW_ORIENTATION_LISTENER_LOG, 0);
-        mWindowOrientationListenerLogCB.setChecked(mWindowOrientationListenerLog != 0);
-    }
-
-    // Returns the current state of the system property that controls
-    // strictmode flashes.  One of:
-    //    0: not explicitly set one way or another
-    //    1: on
-    //    2: off
-    // These are the indices in the Spinner's ArrayAdapter.
-    private int currentStrictModeActiveIndex() {
-        if (TextUtils.isEmpty(SystemProperties.get(StrictMode.VISUAL_PROPERTY))) {
-            return 0;
-        }
-        boolean enabled = SystemProperties.getBoolean(StrictMode.VISUAL_PROPERTY, false);
-        return enabled ? 1 : 2;
-    }
-
-    private void updateStrictModeVisualOptions() {
-        mStrictModeVisualSpinner.setSelection(currentStrictModeActiveIndex());
-    }
-
-    private void writeProcessLimitOptions() {
-        try {
-            ActivityManagerNative.getDefault().setProcessLimit(mProcessLimit);
-        } catch (RemoteException ex) {
-        }
-    }
-
-    private void updateProcessLimitOptions() {
-        try {
-            mProcessLimit = ActivityManagerNative.getDefault().getProcessLimit();
-            mMaxProcsSpinner.setSelection(mProcessLimit);
-        } catch (RemoteException ex) {
-        }
-    }
-
-    private void updateSharedOptions() {
-        mShowLoadCB.setChecked(Settings.System.getInt(getContentResolver(),
-                Settings.System.SHOW_PROCESSES, 0) != 0);
-    }
-
-    private void writeCompatibilityOptions() {
-        Settings.System.putInt(getContentResolver(),
-                Settings.System.COMPATIBILITY_MODE, mCompatibilityMode ? 0 : 1);
-    }
-
-    private void updateCompatibilityOptions() {
-        mCompatibilityMode = Settings.System.getInt(
-            getContentResolver(), Settings.System.COMPATIBILITY_MODE, 1) == 0;
-        mCompatibilityModeCB.setChecked(mCompatibilityMode);
-    }
-
-    private void updateFlingerOptions() {
-        // magic communication with surface flinger.
-        try {
-            IBinder flinger = ServiceManager.getService("SurfaceFlinger");
-            if (flinger != null) {
-                Parcel data = Parcel.obtain();
-                Parcel reply = Parcel.obtain();
-                data.writeInterfaceToken("android.ui.ISurfaceComposer");
-                flinger.transact(1010, data, reply, 0);
-                int v;
-                v = reply.readInt();
-                mShowCpuCB.setChecked(v != 0);
-                v = reply.readInt();
-                mEnableGLCB.setChecked(v != 0);
-                v = reply.readInt();
-                mShowUpdatesCB.setChecked(v != 0);
-                v = reply.readInt();
-                mShowBackgroundCB.setChecked(v != 0);
-                reply.recycle();
-                data.recycle();
-            }
-        } catch (RemoteException ex) {
-        }
-    }
-
-    private void writeSleepOptions() {
-        try {
-            FileOutputStream os = new FileOutputStream(
-                "/sys/devices/platform/gpio_sleep_debug/enable", true);
-            if(mShowSleep)
-                os.write(new byte[] { (byte)'1' });
-            else
-                os.write(new byte[] { (byte)'0' });
-            os.close();
-        } catch (Exception e) {
-            Log.w(TAG, "Failed setting gpio_sleep_debug");
-        }
-    }
-
-    private void updateSleepOptions() {
-        try {
-            FileInputStream is = new FileInputStream(
-                "/sys/devices/platform/gpio_sleep_debug/enable");
-            int character = is.read();
-            mShowSleep = character == '1';
-            is.close();
-        } catch (Exception e) {
-            Log.w(TAG, "Failed reading gpio_sleep_debug");
-            mShowSleep = false;
-        }
-        mShowSleepCB.setChecked(mShowSleep);
-    }
-
-    private void writeXmppOptions() {
-        Settings.System.setShowGTalkServiceStatus(getContentResolver(), mShowXmpp);
-    }
-
-    private void updateXmppOptions() {
-        mShowXmpp = Settings.System.getShowGTalkServiceStatus(getContentResolver());
-        mShowXmppCB.setChecked(mShowXmpp);
-    }
-
-    private View.OnClickListener mDebugAppClicked = new View.OnClickListener() {
-        public void onClick(View v) {
-            Intent intent = new Intent(Intent.ACTION_MAIN);
-            intent.setClass(DevelopmentSettings.this, AppPicker.class);
-            startActivityForResult(intent, DEBUG_APP_REQUEST);
-        }
-    };
-
-    @Override
-    public void onActivityResult(int requestCode, int resultCode, Intent intent) {
-        if (requestCode == DEBUG_APP_REQUEST && resultCode == RESULT_OK) {
-            mDebugApp = intent.getAction();
-            writeDebugOptions();
-            updateDebugOptions();
-        }
-    }
-
-    private View.OnClickListener mWaitForDebuggerClicked =
-            new View.OnClickListener() {
-        public void onClick(View v) {
-            mWaitForDebugger = ((CheckBox)v).isChecked();
-            writeDebugOptions();
-            updateDebugOptions();
-        }
-    };
-
-    private View.OnClickListener mAlwaysFinishClicked =
-            new View.OnClickListener() {
-        public void onClick(View v) {
-            mAlwaysFinish = ((CheckBox)v).isChecked();
-            writeFinishOptions();
-            updateFinishOptions();
-        }
-    };
-
-    private View.OnClickListener mCompatibilityModeClicked =
-        new View.OnClickListener() {
-    public void onClick(View v) {
-        mCompatibilityMode = ((CheckBox)v).isChecked();
-        writeCompatibilityOptions();
-        updateCompatibilityOptions();
-        Toast toast = Toast.makeText(DevelopmentSettings.this,
-                R.string.development_settings_compatibility_mode_toast,
-                Toast.LENGTH_LONG);
-        toast.show();
-    }
-};
-
-    private View.OnClickListener mShowLoadClicked = new View.OnClickListener() {
-        public void onClick(View v) {
-            boolean value = ((CheckBox)v).isChecked();
-            Settings.System.putInt(getContentResolver(),
-                    Settings.System.SHOW_PROCESSES, value ? 1 : 0);
-            Intent service = (new Intent())
-                    .setClassName("android", "com.android.server.LoadAverageService");
-            if (value) {
-                startService(service);
-            } else {
-                stopService(service);
-            }
-        }
-    };
-
-    private class SurfaceFlingerClicker implements CheckBox.OnCheckedChangeListener {
-        SurfaceFlingerClicker(int code) {
-            mCode = code;
-        }
-
-        public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
-            try {
-                IBinder flinger = ServiceManager.getService("SurfaceFlinger");
-                if (flinger != null) {
-                    Parcel data = Parcel.obtain();
-                    data.writeInterfaceToken("android.ui.ISurfaceComposer");
-                    data.writeInt(isChecked ? 1 : 0);
-                    flinger.transact(mCode, data, null, 0);
-                    data.recycle();
-
-                    updateFlingerOptions();
-                }
-            } catch (RemoteException ex) {
-            }
-        }
-
-        final int mCode;
-    }
-
-    private View.OnClickListener mShowSleepClicked =
-            new View.OnClickListener() {
-        public void onClick(View v) {
-            mShowSleep = ((CheckBox)v).isChecked();
-            writeSleepOptions();
-            updateSleepOptions();
-        }
-    };
-
-    private View.OnClickListener mShowXmppClicked = new View.OnClickListener() {
-        public void onClick(View v) {
-            mShowXmpp = ((CheckBox)v).isChecked();
-            // can streamline these calls, but keeping consistent with the
-            // other development settings code.
-            writeXmppOptions();
-            updateXmppOptions();
-        }
-    };
-
-    private View.OnClickListener mWindowOrientationListenerLogClicked = new View.OnClickListener() {
-        public void onClick(View v) {
-            mWindowOrientationListenerLog = ((CheckBox)v).isChecked() ? 1 : 0;
-            writeWindowOrientationListenerLogOptions();
-        }
-    };
-
-    private Spinner.OnItemSelectedListener mPointerLocationChanged
-                                    = new Spinner.OnItemSelectedListener() {
-        public void onItemSelected(android.widget.AdapterView av, View v,
-                                    int position, long id) {
-            mPointerLocation = position;
-            writePointerLocationOptions();
-        }
-
-        public void onNothingSelected(android.widget.AdapterView av) {
-        }
-    };
-
-    private Spinner.OnItemSelectedListener mStrictModeVisualChanged
-                                    = new Spinner.OnItemSelectedListener() {
-        public void onItemSelected(android.widget.AdapterView av, View v,
-                                    int position, long id) {
-            if (position == currentStrictModeActiveIndex()) {
-                // at the existing position, so don't show a Toast.
-                return;
-            }
-
-            try {
-                switch (position) {
-                    case 0:  // default
-                        mWindowManager.setStrictModeVisualIndicatorPreference("");
-                        break;
-                    case 1:  // on
-                        mWindowManager.setStrictModeVisualIndicatorPreference("1");
-                        break;
-                    case 2:  // off
-                        mWindowManager.setStrictModeVisualIndicatorPreference("0");
-                        break;
-                }
-            } catch (RemoteException e) {
-                Log.w(TAG, "Error calling setStrictModeVisualIndicatorPreference", e);
-            }
-
-            Toast.makeText(
-                    DevelopmentSettings.this,
-                    "Setting changed; will take effect per-app next launch, or on reboot",
-                    Toast.LENGTH_LONG).show();
-        }
-
-        public void onNothingSelected(android.widget.AdapterView av) {
-        }
-    };
-
-    private Spinner.OnItemSelectedListener mMaxProcsChanged
-                                    = new Spinner.OnItemSelectedListener() {
-        public void onItemSelected(android.widget.AdapterView av, View v,
-                                    int position, long id) {
-            mProcessLimit = position;
-            writeProcessLimitOptions();
-        }
-
-        public void onNothingSelected(android.widget.AdapterView av) {
-        }
-    };
-
-    private Spinner.OnItemSelectedListener mFontHintingChanged
-                                    = new Spinner.OnItemSelectedListener() {
-        public void onItemSelected(android.widget.AdapterView  av, View v,
-                                    int position, long id) {
-            try {
-                FileOutputStream  out = new FileOutputStream( FONT_HINTING_FILE );
-                out.write(position+48);
-                out.close();
-            } catch (Exception e) {
-                Log.w(TAG, "Failed to write font hinting settings to /data/misc/font-hack");
-            }
-        }
-
-        public void onNothingSelected(android.widget.AdapterView av) {
-        }
-    };
-
-    class AnimationScaleSelectedListener implements OnItemSelectedListener {
-        final int which;
-        float scale;
-        Spinner spinner;
-        
-        AnimationScaleSelectedListener(int _which) {
-            which = _which;
-        }
-        
-        void load() {
-            try {
-                scale = mWindowManager.getAnimationScale(which);
-
-                if (scale > 0.1f && scale < 2.0f) {
-                    spinner.setSelection(0);
-                } else if (scale >= 2.0f && scale < 3.0f) {
-                    spinner.setSelection(1);
-                } else if (scale >= 4.9f && scale < 6.0f) {
-                    spinner.setSelection(2);
-                }  else if (scale >= 9.9f && scale < 11.0f) {
-                    spinner.setSelection(3);
-                } else {
-                    spinner.setSelection(4);
-                }
-            } catch (RemoteException e) {
-            }
-        }
-        
-        public void onItemSelected(android.widget.AdapterView av, View v,
-                int position, long id) {
-            switch (position) {
-                case 0: scale = 1.0f; break;
-                case 1: scale = 2.0f; break;
-                case 2: scale = 5.0f; break;
-                case 3: scale = 10.0f; break;
-                case 4: scale = 0.0f; break;
-                default: break;
-            }
-
-            try {
-                mWindowManager.setAnimationScale(which, scale);
-            } catch (RemoteException e) {
-            }
-        }
-
-        public void onNothingSelected(android.widget.AdapterView av) {
-        }
-    }
-}
diff --git a/build/Android.mk b/build/Android.mk
index 730f6a4..ddaa33e 100644
--- a/build/Android.mk
+++ b/build/Android.mk
@@ -116,6 +116,6 @@
 $(eval _psm_packaging_target :=)
 endef
 
-ANDROID_SUPPORT_LIBRARIES := android-support-v4 android-support-v13
+ANDROID_SUPPORT_LIBRARIES := android-support-v4 android-support-v7-gridlayout android-support-v13
 
 $(foreach lib, $(ANDROID_SUPPORT_LIBRARIES), $(eval $(call _package_sdk_library,$(lib))))
diff --git a/build/sdk-android-armeabi-v7a.atree b/build/sdk-android-armeabi-v7a.atree
index ddf2f65..603f146 100644
--- a/build/sdk-android-armeabi-v7a.atree
+++ b/build/sdk-android-armeabi-v7a.atree
@@ -18,4 +18,4 @@
 prebuilts/qemu-kernel/${TARGET_ARCH}/kernel-qemu-armv7 system-images/${PLATFORM_NAME}/${TARGET_CPU_ABI}/kernel-qemu
 
 # version files for the SDK updater, from development.git
-development/sdk/images_armeabi-v7a_source.properties   system-images/${PLATFORM_NAME}/${TARGET_CPU_ABI}/source.properties
+${HOST_OUT}/development/sdk/images_armeabi-v7a_source.properties system-images/${PLATFORM_NAME}/${TARGET_CPU_ABI}/source.properties
diff --git a/build/sdk-android-armeabi.atree b/build/sdk-android-armeabi.atree
index 2badd85..f641ee3 100644
--- a/build/sdk-android-armeabi.atree
+++ b/build/sdk-android-armeabi.atree
@@ -17,4 +17,4 @@
 prebuilts/qemu-kernel/${TARGET_ARCH}/kernel-qemu system-images/${PLATFORM_NAME}/${TARGET_CPU_ABI}/kernel-qemu
 
 # version files for the SDK updater, from development.git
-development/sdk/images_armeabi_source.properties   system-images/${PLATFORM_NAME}/${TARGET_CPU_ABI}/source.properties
+${HOST_OUT}/development/sdk/images_armeabi_source.properties system-images/${PLATFORM_NAME}/${TARGET_CPU_ABI}/source.properties
diff --git a/build/sdk-android-x86.atree b/build/sdk-android-x86.atree
index 8425600..9adad9b 100644
--- a/build/sdk-android-x86.atree
+++ b/build/sdk-android-x86.atree
@@ -17,4 +17,4 @@
 prebuilts/qemu-kernel/${TARGET_ARCH}/kernel-qemu system-images/${PLATFORM_NAME}/${TARGET_CPU_ABI}/kernel-qemu
 
 # version files for the SDK updater, from development.git
-development/sdk/images_x86_source.properties   system-images/${PLATFORM_NAME}/${TARGET_CPU_ABI}/source.properties
+${HOST_OUT}/development/sdk/images_x86_source.properties system-images/${PLATFORM_NAME}/${TARGET_CPU_ABI}/source.properties
diff --git a/build/sdk.atree b/build/sdk.atree
index 72808c5..2c10f44 100644
--- a/build/sdk.atree
+++ b/build/sdk.atree
@@ -52,7 +52,7 @@
 framework/dx.jar                              platform-tools/lib/dx.jar
 
 # Framework include for Renderscript
-frameworks/base/libs/rs/scriptc               platform-tools/renderscript/include
+frameworks/rs/scriptc                         platform-tools/renderscript/include
 external/clang/lib/Headers                    platform-tools/renderscript/clang-include
 external/clang/LICENSE.TXT                    platform-tools/renderscript/clang-include/LICENSE.TXT
 
@@ -99,6 +99,7 @@
 development/tools/templates/ic_launcher_ldpi.png            platforms/${PLATFORM_NAME}/templates/ic_launcher_ldpi.png
 development/tools/templates/ic_launcher_mdpi.png            platforms/${PLATFORM_NAME}/templates/ic_launcher_mdpi.png
 development/tools/templates/ic_launcher_hdpi.png            platforms/${PLATFORM_NAME}/templates/ic_launcher_hdpi.png
+development/tools/templates/ic_launcher_xhdpi.png           platforms/${PLATFORM_NAME}/templates/ic_launcher_xhdpi.png
 
 # Eclipse Editors support
 framework/layoutlib.jar       platforms/${PLATFORM_NAME}/data/layoutlib.jar
@@ -174,7 +175,6 @@
 development/samples/LunarLander                samples/${PLATFORM_NAME}/LunarLander
 development/samples/MultiResolution            samples/${PLATFORM_NAME}/MultiResolution
 development/samples/NotePad                    samples/${PLATFORM_NAME}/NotePad
-development/samples/NFCDemo                    samples/${PLATFORM_NAME}/NFCDemo
 development/samples/RandomMusicPlayer          samples/${PLATFORM_NAME}/RandomMusicPlayer
 development/samples/SpellChecker/SampleSpellCheckerService samples/${PLATFORM_NAME}/SpellChecker/SampleSpellCheckerService
 development/samples/SpellChecker/HelloSpellChecker samples/${PLATFORM_NAME}/SpellChecker/HelloSpellChecker
@@ -224,6 +224,7 @@
 development/sdk/support_source.properties                                                         extras/android/support/source.properties
 development/sdk/support_README.txt                                                                extras/android/support/README.txt
 sdk/files/sdk_files_NOTICE.txt                                                                    extras/android/support/NOTICE.txt
+
 ${OUT_DIR}/target/common/obj/PACKAGING/android-support-v4_intermediates/android-support-v4.jar    extras/android/support/v4/android-support-v4.jar
 frameworks/support/v4                                                                             extras/android/support/v4/src
 development/samples/Support4Demos                                                                 extras/android/support/samples/Support4Demos
@@ -232,7 +233,11 @@
 frameworks/support/v13                                                                            extras/android/support/v13/src
 development/samples/Support13Demos                                                                extras/android/support/samples/Support13Demos
 
-development/sdk/prebuilt/v7                                                                       extras/android/support/v7
+frameworks/support/v7/gridlayout/AndroidManifest.xml                                              extras/android/support/v7/gridlayout/AndroidManifest.xml
+frameworks/support/v7/gridlayout/project.properties                                               extras/android/support/v7/gridlayout/project.properties
+frameworks/support/v7/gridlayout/res                                                              extras/android/support/v7/gridlayout/res
+frameworks/support/v7/gridlayout/readme                                                           extras/android/support/v7/gridlayout/src/.readme
+${OUT_DIR}/target/common/obj/PACKAGING/android-support-v7-gridlayout_intermediates/android-support-v7-gridlayout.jar    extras/android/support/v7/gridlayout/libs/android-support-v7-gridlayout.jar
 
 ##############################################################################
 # Tests Component
diff --git a/build/sdk_only_whitelist.mk b/build/sdk_only_whitelist.mk
index 16bbe1b..e5eea9d 100644
--- a/build/sdk_only_whitelist.mk
+++ b/build/sdk_only_whitelist.mk
@@ -47,11 +47,13 @@
 	external/zlib \
 	frameworks/base \
 	frameworks/compile \
+	frameworks/native \
 	system/core/adb \
 	system/core/fastboot \
 	system/core/libcutils \
 	system/core/liblog \
-	system/core/libzipfile
+	system/core/libzipfile \
+	system/extras/ext4_utils
 
 # -----
 # Whitelist of platform specific projects that DO require Java
diff --git a/cmds/monkey/src/com/android/commands/monkey/Monkey.java b/cmds/monkey/src/com/android/commands/monkey/Monkey.java
index 3aa2fc1..fcf0893 100644
--- a/cmds/monkey/src/com/android/commands/monkey/Monkey.java
+++ b/cmds/monkey/src/com/android/commands/monkey/Monkey.java
@@ -32,7 +32,9 @@
 import android.os.StrictMode;
 import android.os.SystemClock;
 import android.os.SystemProperties;
+import android.os.UserId;
 import android.view.IWindowManager;
+import android.view.Surface;
 
 import java.io.BufferedReader;
 import java.io.BufferedWriter;
@@ -203,6 +205,8 @@
 
     long mDroppedFlipEvents = 0;
 
+    long mDroppedRotationEvents = 0;
+
     /** The delay between user actions. This is for the scripted monkey. **/
     long mProfileWaitTime = 5000;
 
@@ -607,7 +611,15 @@
         }
 
         mNetworkMonitor.start();
-        int crashedAtCycle = runMonkeyCycles();
+        int crashedAtCycle = 0;
+        try {
+            crashedAtCycle = runMonkeyCycles();
+        } finally {
+            // Release the rotation lock if it's still held and restore the
+            // original orientation.
+            new MonkeyRotationEvent(Surface.ROTATION_0, false).injectEvent(
+                mWm, mAm, mVerbose);
+        }
         mNetworkMonitor.stop();
 
         synchronized (this) {
@@ -661,7 +673,9 @@
             System.out.print(" trackballs=");
             System.out.print(mDroppedTrackballEvents);
             System.out.print(" flips=");
-            System.out.println(mDroppedFlipEvents);
+            System.out.print(mDroppedFlipEvents);
+            System.out.print(" rotations=");
+            System.out.println(mDroppedRotationEvents);
         }
 
         // report network stats
@@ -725,6 +739,9 @@
                 } else if (opt.equals("--pct-trackball")) {
                     int i = MonkeySourceRandom.FACTOR_TRACKBALL;
                     mFactors[i] = -nextOptionLong("trackball events percentage");
+                } else if (opt.equals("--pct-rotation")) {
+                    int i = MonkeySourceRandom.FACTOR_ROTATION;
+                    mFactors[i] = -nextOptionLong("screen rotation events percentage");
                 } else if (opt.equals("--pct-syskeys")) {
                     int i = MonkeySourceRandom.FACTOR_SYSOPS;
                     mFactors[i] = -nextOptionLong("system (key) operations percentage");
@@ -935,7 +952,8 @@
                 if (category.length() > 0) {
                     intent.addCategory(category);
                 }
-                List<ResolveInfo> mainApps = mPm.queryIntentActivities(intent, null, 0);
+                List<ResolveInfo> mainApps = mPm.queryIntentActivities(intent, null, 0,
+                        UserId.myUserId());
                 if (mainApps == null || mainApps.size() == 0) {
                     System.err.println("// Warning: no activities found for category " + category);
                     continue;
@@ -1080,6 +1098,8 @@
                         mDroppedPointerEvents++;
                     } else if (ev instanceof MonkeyFlipEvent) {
                         mDroppedFlipEvents++;
+                    } else if (ev instanceof MonkeyRotationEvent) {
+                        mDroppedRotationEvents++;
                     }
                 } else if (injectCode == MonkeyEvent.INJECT_ERROR_REMOTE_EXCEPTION) {
                     systemCrashed = true;
diff --git a/cmds/monkey/src/com/android/commands/monkey/MonkeyActivityEvent.java b/cmds/monkey/src/com/android/commands/monkey/MonkeyActivityEvent.java
index 75c3a58..0321752 100644
--- a/cmds/monkey/src/com/android/commands/monkey/MonkeyActivityEvent.java
+++ b/cmds/monkey/src/com/android/commands/monkey/MonkeyActivityEvent.java
@@ -26,10 +26,10 @@
 /**
  * monkey activity event
  */
-public class MonkeyActivityEvent extends MonkeyEvent {    
-    private ComponentName mApp; 
+public class MonkeyActivityEvent extends MonkeyEvent {
+    private ComponentName mApp;
     long mAlarmTime = 0;
-    
+
     public MonkeyActivityEvent(ComponentName app) {
         super(EVENT_TYPE_ACTIVITY);
         mApp = app;
@@ -44,11 +44,11 @@
     /**
      * @return Intent for the new activity
      */
-    private Intent getEvent() {        
+    private Intent getEvent() {
         Intent intent = new Intent(Intent.ACTION_MAIN);
         intent.addCategory(Intent.CATEGORY_LAUNCHER);
         intent.setComponent(mApp);
-        intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);        
+        intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_RESET_TASK_IF_NEEDED);
         return intent;
     }
 
@@ -66,8 +66,8 @@
         }
 
         try {
-            iam.startActivity(null, intent, null, null, 0, null, null, 0,
-                    false, false, null, null, false);
+            iam.startActivity(null, intent, null, null, null, 0,
+                    0, null, null, null);
         } catch (RemoteException e) {
             System.err.println("** Failed talking with activity manager!");
             return MonkeyEvent.INJECT_ERROR_REMOTE_EXCEPTION;
diff --git a/cmds/monkey/src/com/android/commands/monkey/MonkeyEvent.java b/cmds/monkey/src/com/android/commands/monkey/MonkeyEvent.java
index 1f703ea..0a06604 100644
--- a/cmds/monkey/src/com/android/commands/monkey/MonkeyEvent.java
+++ b/cmds/monkey/src/com/android/commands/monkey/MonkeyEvent.java
@@ -27,10 +27,11 @@
     public static final int EVENT_TYPE_KEY = 0;
     public static final int EVENT_TYPE_TOUCH = 1;
     public static final int EVENT_TYPE_TRACKBALL = 2;
-    public static final int EVENT_TYPE_ACTIVITY = 3;
-    public static final int EVENT_TYPE_FLIP = 4; // Keyboard flip
-    public static final int EVENT_TYPE_THROTTLE = 5;
-    public static final int EVENT_TYPE_NOOP = 6;
+    public static final int EVENT_TYPE_ROTATION = 3;  // Screen rotation
+    public static final int EVENT_TYPE_ACTIVITY = 4;
+    public static final int EVENT_TYPE_FLIP = 5; // Keyboard flip
+    public static final int EVENT_TYPE_THROTTLE = 6;
+    public static final int EVENT_TYPE_NOOP = 7;
 
     public static final int INJECT_SUCCESS = 1;
     public static final int INJECT_FAIL = 0;
diff --git a/cmds/monkey/src/com/android/commands/monkey/MonkeyRotationEvent.java b/cmds/monkey/src/com/android/commands/monkey/MonkeyRotationEvent.java
new file mode 100644
index 0000000..26108ec
--- /dev/null
+++ b/cmds/monkey/src/com/android/commands/monkey/MonkeyRotationEvent.java
@@ -0,0 +1,62 @@
+/*
+ * Copyright (C) 2012 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.
+ */
+
+package com.android.commands.monkey;
+
+import android.app.IActivityManager;
+import android.os.RemoteException;
+import android.view.IWindowManager;
+/**
+ * monkey screen rotation event
+ */
+public class MonkeyRotationEvent extends MonkeyEvent {
+
+    private final int mRotationDegree;
+    private final boolean mPersist;
+
+    /**
+     * Construct a rotation Event.
+     *
+     * @param degree Possible rotation degrees, see constants in
+     * anroid.view.Suface.
+     * @param persist Should we keep the rotation lock after the orientation
+     * change.
+     */
+    public MonkeyRotationEvent(int degree, boolean persist) {
+        super(EVENT_TYPE_ROTATION);
+        mRotationDegree = degree;
+        mPersist = persist;
+    }
+
+    @Override
+    public int injectEvent(IWindowManager iwm, IActivityManager iam, int verbose) {
+        if (verbose > 0) {
+            System.out.println(":Sending rotation degree=" + mRotationDegree +
+                               ", persist=" + mPersist);
+        }
+
+        // inject rotation event
+        try {
+            iwm.freezeRotation(mRotationDegree);
+            if (!mPersist) {
+                iwm.thawRotation();
+            }
+            return MonkeyEvent.INJECT_SUCCESS;
+        } catch (RemoteException ex) {
+            return MonkeyEvent.INJECT_ERROR_REMOTE_EXCEPTION;
+        }
+    }
+}
diff --git a/cmds/monkey/src/com/android/commands/monkey/MonkeySourceNetwork.java b/cmds/monkey/src/com/android/commands/monkey/MonkeySourceNetwork.java
index c5b25e6..99e7c07 100644
--- a/cmds/monkey/src/com/android/commands/monkey/MonkeySourceNetwork.java
+++ b/cmds/monkey/src/com/android/commands/monkey/MonkeySourceNetwork.java
@@ -247,13 +247,17 @@
             // Ok, it wasn't a number, see if we have a
             // keycode name for it
             keyCode = MonkeySourceRandom.getKeyCode(keyName);
-            if (keyCode == -1) {
+            if (keyCode == KeyEvent.KEYCODE_UNKNOWN) {
                 // OK, one last ditch effort to find a match.
                 // Build the KEYCODE_STRING from the string
                 // we've been given and see if that key
                 // exists.  This would allow you to do "key
                 // down menu", for example.
                 keyCode = MonkeySourceRandom.getKeyCode("KEYCODE_" + keyName.toUpperCase());
+                if (keyCode == KeyEvent.KEYCODE_UNKNOWN) {
+                    // Still unknown
+                    return -1;
+                }
             }
         }
         return keyCode;
diff --git a/cmds/monkey/src/com/android/commands/monkey/MonkeySourceNetworkViews.java b/cmds/monkey/src/com/android/commands/monkey/MonkeySourceNetworkViews.java
index 5d078c2..590f406 100644
--- a/cmds/monkey/src/com/android/commands/monkey/MonkeySourceNetworkViews.java
+++ b/cmds/monkey/src/com/android/commands/monkey/MonkeySourceNetworkViews.java
@@ -18,49 +18,34 @@
 
 import static com.android.commands.monkey.MonkeySourceNetwork.EARG;
 
-import android.accessibilityservice.IAccessibilityServiceConnection;
-import android.accessibilityservice.IEventListener;
-import android.content.Context;
-import android.content.pm.IPackageManager;
+import android.accessibilityservice.UiTestAutomationBridge;
 import android.content.pm.ApplicationInfo;
+import android.content.pm.IPackageManager;
 import android.graphics.Rect;
-import android.os.ServiceManager;
 import android.os.RemoteException;
-import android.os.SystemClock;
-import android.util.Log;
-import android.view.accessibility.AccessibilityInteractionClient;
-import android.view.accessibility.AccessibilityNodeInfo;
-import android.view.accessibility.IAccessibilityManager;
+import android.os.ServiceManager;
+import android.os.UserId;
 import android.view.accessibility.AccessibilityEvent;
-
-import dalvik.system.DexClassLoader;
+import android.view.accessibility.AccessibilityNodeInfo;
 
 import com.android.commands.monkey.MonkeySourceNetwork.CommandQueue;
 import com.android.commands.monkey.MonkeySourceNetwork.MonkeyCommand;
 import com.android.commands.monkey.MonkeySourceNetwork.MonkeyCommandReturn;
 
+import dalvik.system.DexClassLoader;
+
 import java.lang.reflect.Field;
-import java.util.concurrent.atomic.AtomicReference;
-import java.util.Map;
+import java.util.ArrayList;
 import java.util.HashMap;
 import java.util.List;
-import java.util.ArrayList;
-
+import java.util.Map;
 
 /**
  * Utility class that enables Monkey to perform view introspection when issued Monkey Network
  * Script commands over the network.
  */
 public class MonkeySourceNetworkViews {
-    private static final String TAG = "MonkeyViews";
-
-    private static final int TIMEOUT_REGISTER_EVENT_LISTENER = 2000;
-
-    private static final int NO_ID = -1;
-
-    private static volatile AtomicReference<AccessibilityEvent> sLastAccessibilityEvent
-            = new AtomicReference<AccessibilityEvent>();
-    protected static int sConnectionId;
+    protected static UiTestAutomationBridge sUiTestAutomationBridge;
     private static IPackageManager sPm =
             IPackageManager.Stub.asInterface(ServiceManager.getService("package"));
     private static Map<String, Class<?>> sClassMap = new HashMap<String, Class<?>>();
@@ -100,78 +85,16 @@
         COMMAND_MAP.put("getaccessibilityids", new GetAccessibilityIds());
     }
 
-    private static int getConnection() throws RemoteException {
-        if (sConnectionId != NO_ID) {
-            return sConnectionId;
-        }
-        IEventListener listener = new IEventListener.Stub() {
-            public void setConnection(IAccessibilityServiceConnection connection,
-                    int connectionId) {
-                sConnectionId = connectionId;
-                if (connection != null) {
-                    AccessibilityInteractionClient.getInstance().addConnection(connectionId,
-                            connection);
-                } else {
-                    AccessibilityInteractionClient.getInstance().removeConnection(connectionId);
-                }
-                synchronized (MonkeySourceNetworkViews.class) {
-                    notifyAll();
-                }
-            }
-
-            public void onInterrupt() {}
-
-            public void onAccessibilityEvent(AccessibilityEvent event) {
-                Log.d(TAG, "Accessibility Event");
-                sLastAccessibilityEvent.set(AccessibilityEvent.obtain(event));
-                synchronized (MonkeySourceNetworkViews.class) {
-                    notifyAll();
-                }
-            }
-        };
-
-        IAccessibilityManager manager = IAccessibilityManager.Stub.asInterface(
-                ServiceManager.getService(Context.ACCESSIBILITY_SERVICE));
-
-        final long beginTime = SystemClock.uptimeMillis();
-        synchronized (MonkeySourceNetworkViews.class) {
-            manager.registerEventListener(listener);
-            while (true) {
-                if (sConnectionId != NO_ID) {
-                    return sConnectionId;
-                }
-                final long elapsedTime = (SystemClock.uptimeMillis() - beginTime);
-                final long remainingTime = TIMEOUT_REGISTER_EVENT_LISTENER - elapsedTime;
-                if (remainingTime <= 0) {
-                    if (sConnectionId == NO_ID) {
-                        throw new IllegalStateException("Cound not register IEventListener.");
-                    }
-                    return sConnectionId;
-                }
-                try {
-                    MonkeySourceNetworkViews.class.wait(remainingTime);
-                } catch (InterruptedException ie) {
-                    /* ignore */
-                }
-            }
-        }
-    }
-
     /**
      * Registers the event listener for AccessibilityEvents.
      * Also sets up a communication connection so we can query the
      * accessibility service.
      */
     public static void setup() {
-        try {
-            sConnectionId = getConnection();
-        } catch (RemoteException re) {
-            Log.e(TAG,"Remote Exception encountered when"
-                  + " attempting to connect to Accessibility Service");
-        }
+        sUiTestAutomationBridge = new UiTestAutomationBridge();
+        sUiTestAutomationBridge.connect();
     }
 
-
     /**
      * Get the ID class for the given package.
      * This will cause issues if people reload a package with different
@@ -181,7 +104,7 @@
      * @return The ID class for the given package
      */
     private static Class<?> getIdClass(String packageName, String sourceDir)
-            throws RemoteException, ClassNotFoundException {
+            throws ClassNotFoundException {
         // This kind of reflection is expensive, so let's only do it
         // if we need to
         Class<?> klass = sClassMap.get(packageName);
@@ -217,7 +140,7 @@
         try {
             AccessibilityNodeInfo node = event.getSource();
             String packageName = node.getPackageName().toString();
-            ApplicationInfo appInfo = sPm.getApplicationInfo(packageName, 0);
+            ApplicationInfo appInfo = sPm.getApplicationInfo(packageName, 0, UserId.myUserId());
             Class<?> klass;
             klass = getIdClass(packageName, appInfo.sourceDir);
             return klass.getField(stringId).getInt(null);
@@ -240,15 +163,15 @@
             String windowString, String viewString) {
         int windowId = Integer.parseInt(windowString);
         int viewId = Integer.parseInt(viewString);
-        return AccessibilityInteractionClient.getInstance()
-            .findAccessibilityNodeInfoByAccessibilityId(sConnectionId, windowId, viewId);
+        return sUiTestAutomationBridge.findAccessibilityNodeInfoByAccessibilityId(windowId,
+                viewId);
     }
 
     private static AccessibilityNodeInfo getNodeByViewId(String viewId, AccessibilityEvent event)
             throws MonkeyViewException {
         int id = getId(viewId, event);
-        return AccessibilityInteractionClient.getInstance()
-            .findAccessibilityNodeInfoByViewIdInActiveWindow(sConnectionId, id);
+        return sUiTestAutomationBridge.findAccessibilityNodeInfoByViewId(
+                UiTestAutomationBridge.ACTIVE_WINDOW_ID, UiTestAutomationBridge.ROOT_NODE_ID, id);
     }
 
     /**
@@ -259,11 +182,10 @@
         //listviews
         public MonkeyCommandReturn translateCommand(List<String> command,
                                                     CommandQueue queue) {
-            AccessibilityEvent lastEvent = sLastAccessibilityEvent.get();
+            AccessibilityEvent lastEvent = sUiTestAutomationBridge.getLastAccessibilityEvent();
             if (lastEvent == null) {
                 return new MonkeyCommandReturn(false, NO_ACCESSIBILITY_EVENT);
             }
-            lastEvent.setSealed(true);
             AccessibilityNodeInfo node = lastEvent.getSource();
             /* Occasionally the API will generate an event with no source, which is essentially the
              * same as it generating no event at all */
@@ -273,7 +195,7 @@
             String packageName = node.getPackageName().toString();
             try{
                 Class<?> klass;
-                ApplicationInfo appInfo = sPm.getApplicationInfo(packageName, 0);
+                ApplicationInfo appInfo = sPm.getApplicationInfo(packageName, 0, UserId.myUserId());
                 klass = getIdClass(packageName, appInfo.sourceDir);
                 StringBuilder fieldBuilder = new StringBuilder();
                 Field[] fields = klass.getFields();
@@ -300,14 +222,13 @@
         public MonkeyCommandReturn translateCommand(List<String> command,
                                                     CommandQueue queue) {
             if (command.size() > 2) {
-                if (sConnectionId < 0) {
+                if (!sUiTestAutomationBridge.isConnected()) {
                     return new MonkeyCommandReturn(false, NO_CONNECTION);
                 }
-                AccessibilityEvent lastEvent = sLastAccessibilityEvent.get();
+                AccessibilityEvent lastEvent = sUiTestAutomationBridge.getLastAccessibilityEvent();
                 if (lastEvent == null) {
                     return new MonkeyCommandReturn(false, NO_ACCESSIBILITY_EVENT);
                 }
-                lastEvent.setSealed(true);
                 String idType = command.get(1);
                 AccessibilityNodeInfo node;
                 String viewQuery;
@@ -352,11 +273,10 @@
         // getrootview
         public MonkeyCommandReturn translateCommand(List<String> command,
                                                     CommandQueue queue) {
-            AccessibilityEvent lastEvent = sLastAccessibilityEvent.get();
+            AccessibilityEvent lastEvent = sUiTestAutomationBridge.getLastAccessibilityEvent();
             if (lastEvent == null) {
                 return new MonkeyCommandReturn(false, NO_ACCESSIBILITY_EVENT);
             }
-            lastEvent.setSealed(true);
             AccessibilityNodeInfo node = lastEvent.getSource();
             return (new GetAccessibilityIds()).query(node, new ArrayList<String>());
         }
@@ -372,13 +292,14 @@
         // getviewswithtext "some text here"
         public MonkeyCommandReturn translateCommand(List<String> command,
                                                     CommandQueue queue) {
-            if (sConnectionId < 0) {
+            if (!sUiTestAutomationBridge.isConnected()) {
                 return new MonkeyCommandReturn(false, NO_CONNECTION);
             }
             if (command.size() == 2) {
                 String text = command.get(1);
-                List<AccessibilityNodeInfo> nodes = AccessibilityInteractionClient.getInstance()
-                    .findAccessibilityNodeInfosByViewTextInActiveWindow(sConnectionId, text);
+                List<AccessibilityNodeInfo> nodes = sUiTestAutomationBridge
+                    .findAccessibilityNodeInfosByText(UiTestAutomationBridge.ACTIVE_WINDOW_ID,
+                            UiTestAutomationBridge.ROOT_NODE_ID, text);
                 ViewIntrospectionCommand idGetter = new GetAccessibilityIds();
                 List<String> emptyArgs = new ArrayList<String>();
                 StringBuilder ids = new StringBuilder();
@@ -550,7 +471,6 @@
         //queryview viewid button1 setfocused false
         public MonkeyCommandReturn query(AccessibilityNodeInfo node,
                                          List<String> args) {
-            node.setSealed(true);
             if (args.size() == 1) {
                 boolean actionPerformed;
                 if (Boolean.valueOf(args.get(0))) {
@@ -579,7 +499,7 @@
             if (args.size() == 0) {
                 int viewId;
                 try {
-                    Class klass = node.getClass();
+                    Class<?> klass = node.getClass();
                     Field field = klass.getDeclaredField("mAccessibilityViewId");
                     field.setAccessible(true);
                     viewId = ((Integer) field.get(node)).intValue();
diff --git a/cmds/monkey/src/com/android/commands/monkey/MonkeySourceRandom.java b/cmds/monkey/src/com/android/commands/monkey/MonkeySourceRandom.java
index af740b3..3d940a8 100644
--- a/cmds/monkey/src/com/android/commands/monkey/MonkeySourceRandom.java
+++ b/cmds/monkey/src/com/android/commands/monkey/MonkeySourceRandom.java
@@ -23,6 +23,7 @@
 import android.view.KeyCharacterMap;
 import android.view.KeyEvent;
 import android.view.MotionEvent;
+import android.view.Surface;
 import android.view.WindowManagerImpl;
 
 import java.util.ArrayList;
@@ -63,18 +64,26 @@
             PHYSICAL_KEY_EXISTS[SYS_KEYS[i]] = KeyCharacterMap.deviceHasKey(SYS_KEYS[i]);
         }
     }
+    /** Possible screen rotation degrees **/
+    private static final int[] SCREEN_ROTATION_DEGREES = {
+      Surface.ROTATION_0,
+      Surface.ROTATION_90,
+      Surface.ROTATION_180,
+      Surface.ROTATION_270,
+    };
 
     public static final int FACTOR_TOUCH        = 0;
     public static final int FACTOR_MOTION       = 1;
     public static final int FACTOR_PINCHZOOM    = 2;
     public static final int FACTOR_TRACKBALL    = 3;
-    public static final int FACTOR_NAV          = 4;
-    public static final int FACTOR_MAJORNAV     = 5;
-    public static final int FACTOR_SYSOPS       = 6;
-    public static final int FACTOR_APPSWITCH    = 7;
-    public static final int FACTOR_FLIP         = 8;
-    public static final int FACTOR_ANYTHING     = 9;
-    public static final int FACTORZ_COUNT       = 10;    // should be last+1
+    public static final int FACTOR_ROTATION     = 4;
+    public static final int FACTOR_NAV          = 5;
+    public static final int FACTOR_MAJORNAV     = 6;
+    public static final int FACTOR_SYSOPS       = 7;
+    public static final int FACTOR_APPSWITCH    = 8;
+    public static final int FACTOR_FLIP         = 9;
+    public static final int FACTOR_ANYTHING     = 10;
+    public static final int FACTORZ_COUNT       = 11;    // should be last+1
 
     private static final int GESTURE_TAP = 0;
     private static final int GESTURE_DRAG = 1;
@@ -102,7 +111,7 @@
      * be an expensive operation.
      *
      * @param keyName the name of the KEYCODE_VALUE to lookup.
-     * @returns the intenger keyCode value, or -1 if not found
+     * @returns the intenger keyCode value, or KeyEvent.KEYCODE_UNKNOWN if not found
      */
     public static int getKeyCode(String keyName) {
         return KeyEvent.keyCodeFromString(keyName);
@@ -116,6 +125,8 @@
         mFactors[FACTOR_TOUCH] = 15.0f;
         mFactors[FACTOR_MOTION] = 10.0f;
         mFactors[FACTOR_TRACKBALL] = 15.0f;
+        // Adjust the values if we want to enable rotation by default.
+        mFactors[FACTOR_ROTATION] = 0.0f;
         mFactors[FACTOR_NAV] = 25.0f;
         mFactors[FACTOR_MAJORNAV] = 15.0f;
         mFactors[FACTOR_SYSOPS] = 2.0f;
@@ -370,6 +381,18 @@
     }
 
     /**
+     * Generates a random screen rotation event.
+     *
+     * @param random Random number source for rotation degree.
+     */
+    private void generateRotationEvent(Random random) {
+        mQ.addLast(new MonkeyRotationEvent(
+                SCREEN_ROTATION_DEGREES[random.nextInt(
+                        SCREEN_ROTATION_DEGREES.length)],
+                random.nextBoolean()));
+    }
+
+    /**
      * generate a random event based on mFactor
      */
     private void generateEvents() {
@@ -388,6 +411,9 @@
         } else if (cls < mFactors[FACTOR_TRACKBALL]) {
             generateTrackballEvent(mRandom);
             return;
+        } else if (cls < mFactors[FACTOR_ROTATION]) {
+            generateRotationEvent(mRandom);
+            return;
         }
 
         // The remaining event categories are injected as key events
diff --git a/cmds/monkey/src/com/android/commands/monkey/MonkeySourceScript.java b/cmds/monkey/src/com/android/commands/monkey/MonkeySourceScript.java
index 4748a25..e1569f8 100644
--- a/cmds/monkey/src/com/android/commands/monkey/MonkeySourceScript.java
+++ b/cmds/monkey/src/com/android/commands/monkey/MonkeySourceScript.java
@@ -20,6 +20,7 @@
 import android.os.SystemClock;
 import android.view.KeyEvent;
 import android.view.MotionEvent;
+import android.view.Surface;
 
 import java.io.BufferedReader;
 import java.io.DataInputStream;
@@ -85,6 +86,8 @@
 
     private static final String EVENT_KEYWORD_TRACKBALL = "DispatchTrackball";
 
+    private static final String EVENT_KEYWORD_ROTATION = "RotateScreen";
+
     private static final String EVENT_KEYWORD_KEY = "DispatchKey";
 
     private static final String EVENT_KEYWORD_FLIP = "DispatchFlip";
@@ -299,6 +302,23 @@
             return;
         }
 
+        // Handle screen rotation events
+        if ((s.indexOf(EVENT_KEYWORD_ROTATION) >= 0) && args.length == 2) {
+            try {
+                int rotationDegree = Integer.parseInt(args[0]);
+                int persist = Integer.parseInt(args[1]);
+                if ((rotationDegree == Surface.ROTATION_0) ||
+                    (rotationDegree == Surface.ROTATION_90) ||
+                    (rotationDegree == Surface.ROTATION_180) ||
+                    (rotationDegree == Surface.ROTATION_270)) {
+                    mQ.addLast(new MonkeyRotationEvent(rotationDegree,
+                                                       persist != 0));
+                }
+            } catch (NumberFormatException e) {
+            }
+            return;
+        }
+
         // Handle tap event
         if ((s.indexOf(EVENT_KEYWORD_TAP) >= 0) && args.length >= 2) {
             try {
@@ -547,6 +567,9 @@
         if (s.indexOf(EVENT_KEYWORD_KEYPRESS) >= 0 && args.length == 1) {
             String key_name = args[0];
             int keyCode = MonkeySourceRandom.getKeyCode(key_name);
+            if (keyCode == KeyEvent.KEYCODE_UNKNOWN) {
+                return;
+            }
             MonkeyKeyEvent e = new MonkeyKeyEvent(KeyEvent.ACTION_DOWN, keyCode);
             mQ.addLast(e);
             e = new MonkeyKeyEvent(KeyEvent.ACTION_UP, keyCode);
@@ -772,7 +795,7 @@
 
         if (e.getEventTime() < 0) {
             return;
-        }      
+        }
         updatedDownTime = SystemClock.uptimeMillis();
         e.setDownTime(updatedDownTime);
         e.setEventTime(updatedDownTime);
diff --git a/host/windows/usb/android_winusb.inf b/host/windows/usb/android_winusb.inf
index 47cf2f7..ab25970 100755
--- a/host/windows/usb/android_winusb.inf
+++ b/host/windows/usb/android_winusb.inf
@@ -6,7 +6,7 @@
 Class               = AndroidUsbDeviceClass

 ClassGuid           = {3F966BD9-FA04-4ec5-991C-D326973B5128}

 Provider            = %ProviderName%

-DriverVer           = 12/06/2010,4.0.0000.00000

+DriverVer           = 10/19/2011,6.0.0000.00000

 CatalogFile.NTx86   = androidwinusb86.cat

 CatalogFile.NTamd64 = androidwinusba64.cat

 

@@ -26,42 +26,33 @@
 %ProviderName% = Google, NTx86, NTamd64

 

 [Google.NTx86]

-; HTC Dream

-%SingleAdbInterface%        = USB_Install, USB\VID_0BB4&PID_0C01

-%CompositeAdbInterface%     = USB_Install, USB\VID_0BB4&PID_0C02&MI_01

-%SingleBootLoaderInterface% = USB_Install, USB\VID_0BB4&PID_0FFF

-; HTC Magic

-%CompositeAdbInterface%     = USB_Install, USB\VID_0BB4&PID_0C03&MI_01

-;

-;Moto Sholes

-%SingleAdbInterface%        = USB_Install, USB\VID_22B8&PID_41DB

-%CompositeAdbInterface%     = USB_Install, USB\VID_22B8&PID_41DB&MI_01

-;

-;Google NexusOne

+

+;Google Nexus One

 %SingleAdbInterface%        = USB_Install, USB\VID_18D1&PID_0D02

 %CompositeAdbInterface%     = USB_Install, USB\VID_18D1&PID_0D02&MI_01

 %SingleAdbInterface%        = USB_Install, USB\VID_18D1&PID_4E11

 %CompositeAdbInterface%     = USB_Install, USB\VID_18D1&PID_4E12&MI_01

+

+;Google Nexus S

+%SingleAdbInterface%        = USB_Install, USB\VID_18D1&PID_4E21

 %CompositeAdbInterface%     = USB_Install, USB\VID_18D1&PID_4E22&MI_01

+%SingleAdbInterface%        = USB_Install, USB\VID_18D1&PID_4E23

+%CompositeAdbInterface%     = USB_Install, USB\VID_18D1&PID_4E24&MI_01

+

 

 [Google.NTamd64]

-; HTC Dream

-%SingleAdbInterface%        = USB_Install, USB\VID_0BB4&PID_0C01

-%CompositeAdbInterface%     = USB_Install, USB\VID_0BB4&PID_0C02&MI_01

-%SingleBootLoaderInterface% = USB_Install, USB\VID_0BB4&PID_0FFF

-; HTC Magic

-%CompositeAdbInterface%     = USB_Install, USB\VID_0BB4&PID_0C03&MI_01

-;

-;Moto Sholes

-%SingleAdbInterface%        = USB_Install, USB\VID_22B8&PID_41DB

-%CompositeAdbInterface%     = USB_Install, USB\VID_22B8&PID_41DB&MI_01

-;

-;Google NexusOne

+

+;Google Nexus One

 %SingleAdbInterface%        = USB_Install, USB\VID_18D1&PID_0D02

 %CompositeAdbInterface%     = USB_Install, USB\VID_18D1&PID_0D02&MI_01

 %SingleAdbInterface%        = USB_Install, USB\VID_18D1&PID_4E11

 %CompositeAdbInterface%     = USB_Install, USB\VID_18D1&PID_4E12&MI_01

+

+;Google Nexus S

+%SingleAdbInterface%        = USB_Install, USB\VID_18D1&PID_4E21

 %CompositeAdbInterface%     = USB_Install, USB\VID_18D1&PID_4E22&MI_01

+%SingleAdbInterface%        = USB_Install, USB\VID_18D1&PID_4E23

+%CompositeAdbInterface%     = USB_Install, USB\VID_18D1&PID_4E24&MI_01

 

 [USB_Install]

 Include = winusb.inf

diff --git a/ide/eclipse/.classpath b/ide/eclipse/.classpath
index f6bcc4c..07c0ae2 100644
--- a/ide/eclipse/.classpath
+++ b/ide/eclipse/.classpath
@@ -1,10 +1,10 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <classpath>
 	<classpathentry kind="src" path="packages/apps/Bluetooth/src"/>
+	<classpathentry kind="src" path="packages/apps/Camera/src"/>
 	<classpathentry kind="src" path="packages/apps/Browser/src"/>
 	<classpathentry kind="src" path="packages/apps/Calendar/src"/>
 	<classpathentry kind="src" path="packages/apps/Calculator/src"/>
-	<classpathentry kind="src" path="packages/apps/Camera/src"/>
 	<classpathentry kind="src" path="packages/apps/CertInstaller/src"/>
 	<classpathentry kind="src" path="packages/apps/Contacts/src"/>
 	<classpathentry kind="src" path="packages/apps/DeskClock/src"/>
@@ -24,6 +24,7 @@
 	<classpathentry kind="src" path="packages/apps/Settings/src"/>
 	<classpathentry kind="src" path="packages/apps/SoundRecorder/src"/>
 	<classpathentry kind="src" path="packages/apps/Stk/src"/>
+	<classpathentry kind="src" path="packages/apps/UnifiedEmail/src"/>
 	<classpathentry kind="src" path="packages/apps/VoiceDialer/src"/>
 	<classpathentry kind="src" path="packages/providers/CalendarProvider/src"/>
 	<classpathentry kind="src" path="packages/providers/ContactsProvider/src"/>
@@ -60,6 +61,11 @@
 	<classpathentry kind="src" path="frameworks/opt/calendar/src"/>
 	<classpathentry kind="src" path="frameworks/opt/vcard/java"/>
 	<classpathentry kind="src" path="frameworks/support/v13/java"/>
+	<classpathentry kind="src" path="frameworks/support/v13/ics"/>
+	<classpathentry kind="src" path="frameworks/support/v13/ics-mr1"/>
+	<classpathentry kind="src" path="system/media/mca/filterfw/java"/>
+	<classpathentry kind="src" path="system/media/mca/effect/java"/>
+	<classpathentry kind="src" path="system/media/mca/filterpacks/java"/>
 	<classpathentry kind="src" path="development/samples/ApiDemos/src"/>
 	<classpathentry kind="src" path="development/samples/ApiDemos/tests/src"/>
 	<classpathentry kind="src" path="development/samples/Compass/src"/>
diff --git a/ide/eclipse/android-include-paths.xml b/ide/eclipse/android-include-paths.xml
new file mode 100644
index 0000000..bb038a2
--- /dev/null
+++ b/ide/eclipse/android-include-paths.xml
@@ -0,0 +1,86 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<cdtprojectproperties>
+<section name="org.eclipse.cdt.internal.ui.wizards.settingswizards.IncludePaths">
+<language name="holder for library settings">
+
+</language>
+<language name="GNU C++">
+<includepath>${ProjDirPath}/prebuilt/darwin-x86/toolchain/arm-linux-androideabi-4.4.x/lib/gcc/arm-linux-androideabi/4.4.3/include</includepath>
+<includepath>${ProjDirPath}/system/core/include/arch/linux-arm</includepath>
+<includepath>${ProjDirPath}/system/core/include</includepath>
+<includepath>${ProjDirPath}/bionic/libc/arch-arm/include</includepath>
+<includepath>${ProjDirPath}/bionic/libc/include</includepath>
+<includepath>${ProjDirPath}/bionic/libstdc++/include</includepath>
+<includepath>${ProjDirPath}/bionic/libc/kernel/common</includepath>
+<includepath>${ProjDirPath}/bionic/libc/kernel/common/linux</includepath>
+<includepath>${ProjDirPath}/bionic/libc/kernel/arch-arm</includepath>
+<includepath>${ProjDirPath}/bionic/libm/include</includepath>
+<includepath>${ProjDirPath}/bionic/libm/include/arm</includepath>
+<includepath>${ProjDirPath}/bionic/libthread_db/include</includepath>
+<includepath>${ProjDirPath}/dalvik/libnativehelper/include</includepath>
+<includepath>${ProjDirPath}/dalvik/libnativehelper/include/nativehelper</includepath>
+<includepath>${ProjDirPath}/hardware/libhardware/include</includepath>
+<includepath>${ProjDirPath}/hardware/libhardware_legacy/include</includepath>
+<includepath>${ProjDirPath}/hardware/ril/include</includepath>
+<includepath>${ProjDirPath}/frameworks/native/include</includepath>
+<includepath>${ProjDirPath}/frameworks/native/opengl/include</includepath>
+<includepath>${ProjDirPath}/frameworks/base/include</includepath>
+<includepath>${ProjDirPath}/frameworks/base/native/include</includepath>
+<includepath>${ProjDirPath}/external/skia/include</includepath>
+<includepath>${ProjDirPath}/external/skia/include/core</includepath>
+
+</language>
+<language name="GNU C">
+<includepath>${ProjDirPath}/prebuilt/darwin-x86/toolchain/arm-linux-androideabi-4.4.x/lib/gcc/arm-linux-androideabi/4.4.3/include</includepath>
+<includepath>${ProjDirPath}/system/core/include/arch/linux-arm</includepath>
+<includepath>${ProjDirPath}/system/core/include</includepath>
+<includepath>${ProjDirPath}/bionic/libc/arch-arm/include</includepath>
+<includepath>${ProjDirPath}/bionic/libc/include</includepath>
+<includepath>${ProjDirPath}/bionic/libstdc++/include</includepath>
+<includepath>${ProjDirPath}/bionic/libc/kernel/common</includepath>
+<includepath>${ProjDirPath}/bionic/libc/kernel/common/linux</includepath>
+<includepath>${ProjDirPath}/bionic/libc/kernel/arch-arm</includepath>
+<includepath>${ProjDirPath}/bionic/libm/include</includepath>
+<includepath>${ProjDirPath}/bionic/libm/include/arm</includepath>
+<includepath>${ProjDirPath}/bionic/libthread_db/include</includepath>
+<includepath>${ProjDirPath}/dalvik/libnativehelper/include</includepath>
+<includepath>${ProjDirPath}/dalvik/libnativehelper/include/nativehelper</includepath>
+<includepath>${ProjDirPath}/hardware/libhardware/include</includepath>
+<includepath>${ProjDirPath}/hardware/libhardware_legacy/include</includepath>
+<includepath>${ProjDirPath}/hardware/ril/include</includepath>
+<includepath>${ProjDirPath}/frameworks/native/include</includepath>
+<includepath>${ProjDirPath}/frameworks/native/opengl/include</includepath>
+<includepath>${ProjDirPath}/frameworks/base/include</includepath>
+<includepath>${ProjDirPath}/frameworks/base/native/include</includepath>
+<includepath>${ProjDirPath}/external/skia/include</includepath>
+<includepath>${ProjDirPath}/external/skia/include/core</includepath>
+
+</language>
+<language name="Assembly">
+<includepath>${ProjDirPath}/prebuilt/darwin-x86/toolchain/arm-linux-androideabi-4.4.x/lib/gcc/arm-linux-androideabi/4.4.3/include</includepath>
+<includepath>${ProjDirPath}/system/core/include/arch/linux-arm</includepath>
+<includepath>${ProjDirPath}/system/core/include</includepath>
+<includepath>${ProjDirPath}/bionic/libc/arch-arm/include</includepath>
+<includepath>${ProjDirPath}/bionic/libc/include</includepath>
+<includepath>${ProjDirPath}/bionic/libstdc++/include</includepath>
+<includepath>${ProjDirPath}/bionic/libc/kernel/common</includepath>
+<includepath>${ProjDirPath}/bionic/libc/kernel/common/linux</includepath>
+<includepath>${ProjDirPath}/bionic/libc/kernel/arch-arm</includepath>
+<includepath>${ProjDirPath}/bionic/libm/include</includepath>
+<includepath>${ProjDirPath}/bionic/libm/include/arm</includepath>
+<includepath>${ProjDirPath}/bionic/libthread_db/include</includepath>
+<includepath>${ProjDirPath}/dalvik/libnativehelper/include</includepath>
+<includepath>${ProjDirPath}/dalvik/libnativehelper/include/nativehelper</includepath>
+<includepath>${ProjDirPath}/hardware/libhardware/include</includepath>
+<includepath>${ProjDirPath}/hardware/libhardware_legacy/include</includepath>
+<includepath>${ProjDirPath}/hardware/ril/include</includepath>
+<includepath>${ProjDirPath}/frameworks/native/include</includepath>
+<includepath>${ProjDirPath}/frameworks/native/opengl/include</includepath>
+<includepath>${ProjDirPath}/frameworks/base/include</includepath>
+<includepath>${ProjDirPath}/frameworks/base/native/include</includepath>
+<includepath>${ProjDirPath}/external/skia/include</includepath>
+<includepath>${ProjDirPath}/external/skia/include/core</includepath>
+
+</language>
+</section>
+</cdtprojectproperties>
diff --git a/ide/eclipse/android-symbols.xml b/ide/eclipse/android-symbols.xml
new file mode 100644
index 0000000..3fae03f
--- /dev/null
+++ b/ide/eclipse/android-symbols.xml
@@ -0,0 +1,98 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<cdtprojectproperties>
+<section name="org.eclipse.cdt.internal.ui.wizards.settingswizards.Macros">
+<language name="holder for library settings">
+
+</language>
+<language name="Assembly">
+<macro>
+<name>HAVE_ANDROID_OS</name><value>1</value>
+</macro>
+<macro>
+<name>NDEBUG</name><value>1</value>
+</macro>
+<macro>
+<name>ANDROID</name><value>1</value>
+</macro>
+<macro>
+<name>__arm__</name><value>1</value>
+</macro>
+<macro>
+<name>__OPTIMIZE__</name><value>1</value>
+</macro>
+<macro>
+<name>HAVE_FUTEX</name><value>1</value>
+</macro>
+<macro>
+<name>HAVE_PTHREADS</name><value>1</value>
+</macro>
+<macro>
+<name>EGL_TRACE</name><value>1</value>
+</macro>
+<macro>
+<name>LOG_TAG</name><value>"tag"</value>
+</macro>
+
+</language>
+<language name="GNU C++">
+<macro>
+<name>HAVE_ANDROID_OS</name><value>1</value>
+</macro>
+<macro>
+<name>NDEBUG</name><value>1</value>
+</macro>
+<macro>
+<name>ANDROID</name><value>1</value>
+</macro>
+<macro>
+<name>__arm__</name><value>1</value>
+</macro>
+<macro>
+<name>__OPTIMIZE__</name><value>1</value>
+</macro>
+<macro>
+<name>HAVE_FUTEX</name><value>1</value>
+</macro>
+<macro>
+<name>HAVE_PTHREADS</name><value>1</value>
+</macro>
+<macro>
+<name>EGL_TRACE</name><value>1</value>
+</macro>
+<macro>
+<name>LOG_TAG</name><value>"tag"</value>
+</macro>
+
+</language>
+<language name="GNU C">
+<macro>
+<name>HAVE_ANDROID_OS</name><value>1</value>
+</macro>
+<macro>
+<name>NDEBUG</name><value>1</value>
+</macro>
+<macro>
+<name>ANDROID</name><value>1</value>
+</macro>
+<macro>
+<name>__arm__</name><value>1</value>
+</macro>
+<macro>
+<name>__OPTIMIZE__</name><value>1</value>
+</macro>
+<macro>
+<name>HAVE_FUTEX</name><value>1</value>
+</macro>
+<macro>
+<name>HAVE_PTHREADS</name><value>1</value>
+</macro>
+<macro>
+<name>EGL_TRACE</name><value>1</value>
+</macro>
+<macro>
+<name>LOG_TAG</name><value>"tag"</value>
+</macro>
+
+</language>
+</section>
+</cdtprojectproperties>
diff --git a/ndk/platforms/android-9/include/android/native_activity.h b/ndk/platforms/android-9/include/android/native_activity.h
index d89bc8b..52997bf 100644
--- a/ndk/platforms/android-9/include/android/native_activity.h
+++ b/ndk/platforms/android-9/include/android/native_activity.h
@@ -60,7 +60,14 @@
     JNIEnv* env;
 
     /**
-     * The NativeActivity Java class.
+     * The NativeActivity object handle.
+     *
+     * IMPORTANT NOTE: This member is mis-named. It should really be named
+     * 'activity' instead of 'clazz', since it's a reference to the
+     * NativeActivity instance created by the system for you.
+     *
+     * We unfortunately cannot change this without breaking NDK
+     * source-compatibility.
      */
     jobject clazz;
 
diff --git a/samples/AndroidBeamDemo/Android.mk b/samples/AndroidBeamDemo/Android.mk
index f125f0f..b5f45e8 100644
--- a/samples/AndroidBeamDemo/Android.mk
+++ b/samples/AndroidBeamDemo/Android.mk
@@ -1,7 +1,7 @@
 LOCAL_PATH:= $(call my-dir)
 include $(CLEAR_VARS)
 
-LOCAL_MODULE_TAGS := samples
+LOCAL_MODULE_TAGS := samples tests
 
 # Only compile source java files in this apk.
 LOCAL_SRC_FILES := $(call all-java-files-under, src)
diff --git a/samples/AndroidBeamDemo/src/com/example/android/beam/Beam.java b/samples/AndroidBeamDemo/src/com/example/android/beam/Beam.java
index 0cc5f89..d419bac 100644
--- a/samples/AndroidBeamDemo/src/com/example/android/beam/Beam.java
+++ b/samples/AndroidBeamDemo/src/com/example/android/beam/Beam.java
@@ -73,9 +73,8 @@
         time.setToNow();
         String text = ("Beam me up!\n\n" +
                 "Beam Time: " + time.format("%H:%M:%S"));
-        NdefMessage msg = new NdefMessage(
-                new NdefRecord[] { createMimeRecord(
-                        "application/com.example.android.beam", text.getBytes())
+        NdefMessage msg = new NdefMessage(NdefRecord.createMime(
+                "application/com.example.android.beam", text.getBytes())
          /**
           * The Android Application Record (AAR) is commented out. When a device
           * receives a push with an AAR in it, the application specified in the AAR
@@ -85,7 +84,7 @@
           * uses the tag dispatch system.
           */
           //,NdefRecord.createApplicationRecord("com.example.android.beam")
-        });
+        );
         return msg;
     }
 
@@ -138,18 +137,6 @@
         mInfoText.setText(new String(msg.getRecords()[0].getPayload()));
     }
 
-    /**
-     * Creates a custom MIME type encapsulated in an NDEF record
-     *
-     * @param mimeType
-     */
-    public NdefRecord createMimeRecord(String mimeType, byte[] payload) {
-        byte[] mimeBytes = mimeType.getBytes(Charset.forName("US-ASCII"));
-        NdefRecord mimeRecord = new NdefRecord(
-                NdefRecord.TNF_MIME_MEDIA, mimeBytes, new byte[0], payload);
-        return mimeRecord;
-    }
-
     @Override
     public boolean onCreateOptionsMenu(Menu menu) {
         // If NFC is not available, we won't be needing this menu
diff --git a/samples/ApiDemos/AndroidManifest.xml b/samples/ApiDemos/AndroidManifest.xml
index bcb0fcb..4b31885 100644
--- a/samples/ApiDemos/AndroidManifest.xml
+++ b/samples/ApiDemos/AndroidManifest.xml
@@ -519,6 +519,21 @@
             </intent-filter>
         </activity>
 
+        <activity android:name=".app.IsolatedService$Controller"
+                android:label="@string/activity_isolated_service_controller"
+                android:launchMode="singleTop"
+                android:enabled="@bool/atLeastJellyBean">
+            <intent-filter>
+                <action android:name="android.intent.action.MAIN" />
+                <category android:name="android.intent.category.SAMPLE_CODE" />
+            </intent-filter>
+        </activity>
+
+        <service android:name=".app.IsolatedService" android:isolatedProcess="true"
+                android:enabled="@bool/atLeastJellyBean" />
+        <service android:name=".app.IsolatedService2" android:isolatedProcess="true"
+                android:enabled="@bool/atLeastJellyBean" />
+
         <!-- Alarm Samples -->
 
         <receiver android:name=".app.OneShotAlarm" android:process=":remote" />
@@ -886,6 +901,16 @@
             </intent-filter>
         </activity>
 
+        <!-- Accessibility Samples -->
+        <activity android:name=".accessibility.AccessibilityNodeProviderActivity"
+                android:label="@string/accessibility_node_provider"
+                android:enabled="@bool/atLeastIceCreamSandwich">
+            <intent-filter>
+                <action android:name="android.intent.action.MAIN" />
+                <category android:name="android.intent.category.SAMPLE_CODE" />
+            </intent-filter>
+        </activity>
+
         <!-- Application Updating Samples -->
 
 <!-- BEGIN_INCLUDE(app_update_declaration) -->
@@ -2179,7 +2204,29 @@
             </intent-filter>
         </activity>
 
-        <activity android:name=".view.OverscanActivity" android:label="Views/Full Screen Modes">
+        <activity android:name=".view.OverscanActivity"
+                android:label="Views/System UI Visibility/System UI Modes"
+                android:uiOptions="splitActionBarWhenNarrow">
+            <intent-filter>
+                <action android:name="android.intent.action.MAIN" />
+                <category android:name="android.intent.category.SAMPLE_CODE" />
+            </intent-filter>
+        </activity>
+
+        <activity android:name=".view.ContentBrowserActivity"
+                android:label="Views/System UI Visibility/Content Browser"
+                android:theme="@android:style/Theme.Holo.Light"
+                android:uiOptions="splitActionBarWhenNarrow">
+            <intent-filter>
+                <action android:name="android.intent.action.MAIN" />
+                <category android:name="android.intent.category.SAMPLE_CODE" />
+            </intent-filter>
+        </activity>
+
+        <activity android:name=".view.VideoPlayerActivity"
+                android:label="Views/System UI Visibility/Video Player"
+                android:theme="@android:style/Theme.Holo.Light"
+                android:uiOptions="splitActionBarWhenNarrow">
             <intent-filter>
                 <action android:name="android.intent.action.MAIN" />
                 <category android:name="android.intent.category.SAMPLE_CODE" />
diff --git a/samples/ApiDemos/_index.html b/samples/ApiDemos/_index.html
index 3c45843..421eca6 100644
--- a/samples/ApiDemos/_index.html
+++ b/samples/ApiDemos/_index.html
@@ -1,19 +1,19 @@
-<p>The API Demos application includes a variety of small applications 
+<p>The API Demos application includes a variety of small applications
 that illustrate the use of various Android APIs. It includes samples of:
 </p>
 <ul>
-  <li>Notifications</li>  
-  <li>Alarms</li>  
-  <li>Progress Dialogs</li>  
-  <li>Intents</li>  
-  <li>Menus</li>  
-  <li>Search</li>  
-  <li>Persistent application state</li>  
-  <li>Preferences</li>  
-  <li>Background Services</li>  
-  <li>App Widgets</li>  
-  <li>Voice Recognition</li>  
-  <li>And many many more...</li>  
+  <li>Notifications</li>
+  <li>Alarms</li>
+  <li>Progress Dialogs</li>
+  <li>Intents</li>
+  <li>Menus</li>
+  <li>Search</li>
+  <li>Persistent application state</li>
+  <li>Preferences</li>
+  <li>Background Services</li>
+  <li>App Widgets</li>
+  <li>Voice Recognition</li>
+  <li>And many many more...</li>
 </ul>
 
 <div class="note">
@@ -36,6 +36,7 @@
 <li><a href="src/com/example/android/apis/graphics/TouchPaint.html">Stylus and hover
 support</a></li>
 <li><a href="src/com/example/android/apis/view/Switches.html">Switch widget</a></li>
+<li><a href="src/com/example/android/apis/accessibility/AccessibilityNodeProviderActivity.html">Accessibility Node Provider</a></li>
 <li><a
   href="src/com/example/android/apis/accessibility/TaskBackService.html">Window
   Querying Accessibility Service</a></li>
diff --git a/samples/ApiDemos/res/drawable-nodpi/frantic.jpg b/samples/ApiDemos/res/drawable-nodpi/frantic.jpg
index 7038ef3..4c62333 100644
--- a/samples/ApiDemos/res/drawable-nodpi/frantic.jpg
+++ b/samples/ApiDemos/res/drawable-nodpi/frantic.jpg
Binary files differ
diff --git a/samples/ApiDemos/res/layout/accessibility_node_provider.xml b/samples/ApiDemos/res/layout/accessibility_node_provider.xml
new file mode 100644
index 0000000..cc10c9c
--- /dev/null
+++ b/samples/ApiDemos/res/layout/accessibility_node_provider.xml
@@ -0,0 +1,34 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Copyright (C) 2011 The Android Open Source Project
+
+     Licensed under the Apache License, Version 2.0 (the "License");
+     you may not use this file except in compliance with the License.
+     You may obtain a copy of the License at
+
+          http://www.apache.org/licenses/LICENSE-2.0
+
+     Unless required by applicable law or agreed to in writing, software
+     distributed under the License is distributed on an "AS IS" BASIS,
+     WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+     See the License for the specific language governing permissions and
+     limitations under the License.
+-->
+<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
+    android:layout_width="wrap_content"
+    android:layout_height="wrap_content"
+    android:orientation="vertical">
+
+    <TextView
+        android:layout_width="wrap_content"
+        android:layout_height="wrap_content"
+        android:layout_marginBottom="50dip"
+        android:text="@string/accessibility_node_provider_instructions">
+    </TextView>
+
+    <view
+        class="com.example.android.apis.accessibility.AccessibilityNodeProviderActivity$VirtualSubtreeRootView"
+        android:layout_width="wrap_content"
+        android:layout_height="wrap_content" >
+    </view>
+
+</LinearLayout>
diff --git a/samples/ApiDemos/res/layout/activity_animation.xml b/samples/ApiDemos/res/layout/activity_animation.xml
index 2432c90..2543613 100644
--- a/samples/ApiDemos/res/layout/activity_animation.xml
+++ b/samples/ApiDemos/res/layout/activity_animation.xml
@@ -28,15 +28,31 @@
         android:text="@string/activity_animation_msg"/>
 
     <Button android:id="@+id/fade_animation"
-        android:layout_width="wrap_content" android:layout_height="wrap_content" 
+        android:layout_width="wrap_content" android:layout_height="wrap_content"
         android:text="@string/activity_animation_fade">
         <requestFocus />
     </Button>
 
     <Button android:id="@+id/zoom_animation"
-        android:layout_width="wrap_content" android:layout_height="wrap_content" 
+        android:layout_width="wrap_content" android:layout_height="wrap_content"
         android:text="@string/activity_animation_zoom">
     </Button>
 
+    <Button android:id="@+id/modern_fade_animation"
+        android:layout_width="wrap_content" android:layout_height="wrap_content"
+        android:text="@string/activity_modern_animation_fade">
+        <requestFocus />
+    </Button>
+
+    <Button android:id="@+id/modern_zoom_animation"
+        android:layout_width="wrap_content" android:layout_height="wrap_content"
+        android:text="@string/activity_modern_animation_zoom">
+    </Button>
+
+    <Button android:id="@+id/zoom_thumbnail_animation"
+        android:layout_width="wrap_content" android:layout_height="wrap_content"
+        android:text="@string/activity_zoom_thumbnail_animation">
+    </Button>
+
 </LinearLayout>
 
diff --git a/samples/ApiDemos/res/layout/content_browser.xml b/samples/ApiDemos/res/layout/content_browser.xml
new file mode 100644
index 0000000..1e1ba37
--- /dev/null
+++ b/samples/ApiDemos/res/layout/content_browser.xml
@@ -0,0 +1,53 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Copyright (C) 2012 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.
+-->
+
+<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
+    android:layout_width="match_parent" android:layout_height="match_parent"
+    >
+    <view class="com.example.android.apis.view.ContentBrowserActivity$Content"
+        android:id="@+id/content"
+        android:layout_width="match_parent"
+        android:layout_height="match_parent"
+        />
+    <FrameLayout
+        android:layout_width="match_parent"
+        android:layout_height="match_parent"
+        android:fitsSystemWindows="true"
+        >
+        <TextView
+            android:layout_width="match_parent"
+            android:layout_height="wrap_content"
+            android:layout_gravity="top|center_horizontal"
+            android:textColor="#ff000000"
+            android:background="#ffa0a0a0"
+            android:textSize="16dp"
+            android:textStyle="bold"
+            android:gravity="center"
+            android:text="You Could Put Controls Here"
+            />
+        <TextView
+            android:layout_width="match_parent"
+            android:layout_height="wrap_content"
+            android:layout_gravity="bottom|center_horizontal"
+            android:textColor="#ff000000"
+            android:background="#ffa0a0a0"
+            android:textSize="16dp"
+            android:textStyle="bold"
+            android:gravity="center"
+            android:text="Or Put Them Here, Too"
+            />
+    </FrameLayout>
+</FrameLayout>
diff --git a/samples/ApiDemos/res/layout/isolated_service_controller.xml b/samples/ApiDemos/res/layout/isolated_service_controller.xml
new file mode 100644
index 0000000..fa16cea
--- /dev/null
+++ b/samples/ApiDemos/res/layout/isolated_service_controller.xml
@@ -0,0 +1,88 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Copyright (C) 2012 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.
+-->
+
+<!-- Demonstrates isolated services.
+     See corresponding Java code com.android.sdk.app.IsolatedSerice.java. -->
+
+<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
+    android:orientation="vertical" android:padding="4dip"
+    android:gravity="center_horizontal"
+    android:layout_width="match_parent" android:layout_height="match_parent">
+
+    <TextView
+        android:layout_width="match_parent" android:layout_height="wrap_content"
+        android:layout_weight="0"
+        android:paddingBottom="4dip"
+        android:gravity="center_vertical|center_horizontal"
+        android:textAppearance="?android:attr/textAppearanceMedium"
+        android:text="@string/isolated_service_controller"/>
+
+    <LinearLayout android:orientation="horizontal" android:paddingTop="16dp"
+        android:layout_width="wrap_content" android:layout_height="wrap_content">
+    
+        <Button android:id="@+id/start1"
+            android:layout_width="wrap_content" android:layout_height="wrap_content" 
+            android:text="@string/start_service_1">
+            <requestFocus />
+        </Button>
+    
+        <Button android:id="@+id/stop1"
+            android:layout_width="wrap_content" android:layout_height="wrap_content" 
+            android:text="@string/stop_service_1">
+        </Button>
+    </LinearLayout>
+
+    <LinearLayout android:orientation="horizontal"
+        android:layout_width="wrap_content" android:layout_height="wrap_content">
+        <CheckBox android:id="@+id/bind1"
+            android:layout_width="wrap_content"
+            android:layout_height="wrap_content"
+            android:text="@string/bind_service_1" />
+        <TextView android:id="@+id/status1"
+            android:layout_width="wrap_content"
+            android:layout_height="wrap_content"
+            android:paddingLeft="16dp" />
+    </LinearLayout>
+
+    <LinearLayout android:orientation="horizontal" android:paddingTop="16dp"
+        android:layout_width="wrap_content" android:layout_height="wrap_content">
+    
+        <Button android:id="@+id/start2"
+            android:layout_width="wrap_content" android:layout_height="wrap_content" 
+            android:text="@string/start_service_2">
+            <requestFocus />
+        </Button>
+    
+        <Button android:id="@+id/stop2"
+            android:layout_width="wrap_content" android:layout_height="wrap_content" 
+            android:text="@string/stop_service_2">
+        </Button>
+    </LinearLayout>
+
+    <LinearLayout android:orientation="horizontal"
+        android:layout_width="wrap_content" android:layout_height="wrap_content">
+        <CheckBox android:id="@+id/bind2"
+            android:layout_width="wrap_content"
+            android:layout_height="wrap_content"
+            android:text="@string/bind_service_2" />
+        <TextView android:id="@+id/status2"
+            android:layout_width="wrap_content"
+            android:layout_height="wrap_content"
+            android:paddingLeft="16dp" />
+    </LinearLayout>
+
+</LinearLayout>
+
diff --git a/samples/ApiDemos/res/layout/overscan.xml b/samples/ApiDemos/res/layout/overscan.xml
index 3112e18..a0329b0 100644
--- a/samples/ApiDemos/res/layout/overscan.xml
+++ b/samples/ApiDemos/res/layout/overscan.xml
@@ -33,47 +33,119 @@
         android:layout_gravity="bottom|center"
         android:background="#60000000"
         android:padding="8dp"
-        android:orientation="horizontal"
+        android:orientation="vertical"
         >
         <LinearLayout
-            android:layout_width="wrap_content"
+            android:layout_width="match_parent"
             android:layout_height="wrap_content"
-            android:layout_weight="1"
-            android:orientation="vertical"
+            android:orientation="horizontal"
+            android:baselineAligned="true"
             >
             <TextView
-                android:id="@+id/text1"
                 android:layout_width="wrap_content"
                 android:layout_height="wrap_content"
+                android:layout_weight="1"
                 android:textColor="#FFFFFFFF"
                 android:textSize="16dp"
                 android:textStyle="bold"
                 android:gravity="left"
+                android:text="Mode:"
                 />
-            <TextView
-                android:id="@+id/text2"
+            <LinearLayout
                 android:layout_width="wrap_content"
                 android:layout_height="wrap_content"
+                android:orientation="vertical"
+                android:baselineAlignedChildIndex="0"
+                >
+                <CheckBox
+                    android:id="@+id/modeLowProfile"
+                    android:layout_width="wrap_content"
+                    android:layout_height="wrap_content"
+                    android:textColor="#FFFFFFFF"
+                    android:textSize="16dp"
+                    android:textStyle="bold"
+                    android:text="LOW_PROFILE"
+                    />
+                <CheckBox
+                    android:id="@+id/modeFullscreen"
+                    android:layout_width="wrap_content"
+                    android:layout_height="wrap_content"
+                    android:textColor="#FFFFFFFF"
+                    android:textSize="16dp"
+                    android:textStyle="bold"
+                    android:text="FULLSCREEN"
+                    />
+                <CheckBox
+                    android:id="@+id/modeHideNavigation"
+                    android:layout_width="wrap_content"
+                    android:layout_height="wrap_content"
+                    android:textColor="#FFFFFFFF"
+                    android:textSize="16dp"
+                    android:textStyle="bold"
+                    android:text="HIDE_NAVIGATION"
+                    />
+            </LinearLayout>
+        </LinearLayout>
+        <LinearLayout
+            android:layout_width="match_parent"
+            android:layout_height="wrap_content"
+            android:layout_marginTop="5dp"
+            android:orientation="horizontal"
+            android:baselineAligned="true"
+            >
+            <TextView
+                android:layout_width="wrap_content"
+                android:layout_height="wrap_content"
+                android:layout_weight="1"
                 android:textColor="#FFFFFFFF"
-                android:textSize="11dp"
+                android:textSize="16dp"
                 android:textStyle="bold"
                 android:gravity="left"
+                android:text="Layout:"
                 />
+            <LinearLayout
+                android:layout_width="wrap_content"
+                android:layout_height="wrap_content"
+                android:orientation="vertical"
+                android:baselineAlignedChildIndex="0"
+                >
+                <CheckBox
+                    android:id="@+id/layoutStable"
+                    android:layout_width="wrap_content"
+                    android:layout_height="wrap_content"
+                    android:textColor="#FFFFFFFF"
+                    android:textSize="16dp"
+                    android:textStyle="bold"
+                    android:text="STABLE"
+                    />
+                <CheckBox
+                    android:id="@+id/layoutFullscreen"
+                    android:layout_width="wrap_content"
+                    android:layout_height="wrap_content"
+                    android:textColor="#FFFFFFFF"
+                    android:textSize="16dp"
+                    android:textStyle="bold"
+                    android:text="FULLSCREEN"
+                    />
+                <CheckBox
+                    android:id="@+id/layoutHideNavigation"
+                    android:layout_width="wrap_content"
+                    android:layout_height="wrap_content"
+                    android:textColor="#FFFFFFFF"
+                    android:textSize="16dp"
+                    android:textStyle="bold"
+                    android:text="HIDE_NAVIGATION"
+                    />
+            </LinearLayout>
         </LinearLayout>
         <TextView
-            android:id="@+id/switchy"
-            android:background="#C0000000"
-            android:layout_width="wrap_content"
+            android:id="@+id/metricsText"
+            android:layout_width="match_parent"
             android:layout_height="wrap_content"
-            android:layout_gravity="bottom"
-            android:layout_marginTop="4dp"
-            android:padding="10dp"
             android:textColor="#FFFFFFFF"
             android:textSize="11dp"
             android:textStyle="bold"
-            android:clickable="true"
-            android:onClick="clicked"
-            android:text="Switch"
+            android:gravity="center"
             />
     </LinearLayout>
 </FrameLayout>
diff --git a/samples/ApiDemos/res/layout/video_player.xml b/samples/ApiDemos/res/layout/video_player.xml
new file mode 100644
index 0000000..fb9479c
--- /dev/null
+++ b/samples/ApiDemos/res/layout/video_player.xml
@@ -0,0 +1,55 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Copyright (C) 2012 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.
+-->
+
+<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
+    android:layout_width="match_parent" android:layout_height="match_parent"
+    >
+    <view class="com.example.android.apis.view.VideoPlayerActivity$Content"
+        android:id="@+id/image"
+        android:src="@drawable/frantic"
+        android:layout_width="match_parent"
+        android:layout_height="match_parent"
+        android:scaleType="center"
+        />
+    <FrameLayout
+        android:layout_width="match_parent"
+        android:layout_height="match_parent"
+        android:fitsSystemWindows="true"
+        >
+        <TextView
+            android:layout_width="match_parent"
+            android:layout_height="wrap_content"
+            android:layout_gravity="top|center_horizontal"
+            android:textColor="#ff000000"
+            android:background="#ffa0a0a0"
+            android:textSize="16dp"
+            android:textStyle="bold"
+            android:gravity="center"
+            android:text="You Could Put Controls Here"
+            />
+        <TextView
+            android:layout_width="match_parent"
+            android:layout_height="wrap_content"
+            android:layout_gravity="bottom|center_horizontal"
+            android:textColor="#ff000000"
+            android:background="#ffa0a0a0"
+            android:textSize="16dp"
+            android:textStyle="bold"
+            android:gravity="center"
+            android:text="Or Put Them Here, Too"
+            />
+    </FrameLayout>
+</FrameLayout>
diff --git a/samples/ApiDemos/res/layout/webview_1.xml b/samples/ApiDemos/res/layout/webview_1.xml
index 67cea3a..e70db5f 100644
--- a/samples/ApiDemos/res/layout/webview_1.xml
+++ b/samples/ApiDemos/res/layout/webview_1.xml
@@ -29,51 +29,6 @@
             android:layout_height="wrap_content"
             android:layout_width="match_parent"
             />
-            
-        <WebView android:id="@+id/wv2"
-            android:layout_height="wrap_content"
-            android:layout_width="match_parent"
-            />
-            
-        <WebView android:id="@+id/wv3"
-            android:layout_height="wrap_content"
-            android:layout_width="match_parent"
-            />
-            
-        <WebView android:id="@+id/wv4"
-            android:layout_height="wrap_content"
-            android:layout_width="match_parent"
-            />
-            
-        <WebView android:id="@+id/wv5"
-            android:layout_height="wrap_content"
-            android:layout_width="match_parent"
-            />
-            
-        <WebView android:id="@+id/wv6"
-            android:layout_height="wrap_content"
-            android:layout_width="match_parent"
-            />
-    
-        <WebView android:id="@+id/wv7"
-            android:layout_height="wrap_content"
-            android:layout_width="match_parent"
-            />
-            
-        <WebView android:id="@+id/wv8"
-            android:layout_height="wrap_content"
-            android:layout_width="match_parent"
-            />
-            
-        <WebView android:id="@+id/wv9"
-            android:layout_height="wrap_content"
-            android:layout_width="match_parent"
-            />
-            
-        <WebView android:id="@+id/wv10"
-            android:layout_height="wrap_content"
-            android:layout_width="match_parent"
-            />
     </LinearLayout>
         
  </ScrollView>        
diff --git a/samples/ApiDemos/res/menu/content_actions.xml b/samples/ApiDemos/res/menu/content_actions.xml
new file mode 100644
index 0000000..84d783f
--- /dev/null
+++ b/samples/ApiDemos/res/menu/content_actions.xml
@@ -0,0 +1,62 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Copyright (C) 2012 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.
+-->
+<menu xmlns:android="http://schemas.android.com/apk/res/android">
+    <item android:id="@+id/action_search"
+          android:icon="@android:drawable/ic_menu_search"
+          android:title="@string/action_bar_search"
+          android:showAsAction="always"
+          android:actionViewClass="android.widget.SearchView" />
+    <item android:id="@+id/menu_item_share_action_provider_action_bar"
+          android:showAsAction="always"
+          android:title="@string/action_bar_share_with"
+          android:actionProviderClass="android.widget.ShareActionProvider" />
+    <group android:id="@+id/show_tabs_group"
+            android:checkableBehavior="single">
+        <item android:id="@+id/show_tabs"
+                android:title="Show Tabs"
+                android:showAsAction="never" />
+        <item android:id="@+id/hide_tabs"
+                android:title="Hide Tabs"
+                android:checked="true"
+                android:showAsAction="never" />
+    </group>
+    <group android:id="@+id/stable_layout_group"
+            android:checkableBehavior="all">
+        <item android:id="@+id/stable_layout"
+                android:title="Stable Layout"
+                android:checked="true"
+                android:showAsAction="never" />
+    </group>
+    <item android:id="@+id/action_share"
+          android:icon="@android:drawable/ic_menu_share"
+          android:title="@string/action_bar_share"
+          android:showAsAction="ifRoom" />
+    <item android:id="@+id/action_sort"
+          android:icon="@android:drawable/ic_menu_sort_by_size"
+          android:title="@string/action_bar_sort"
+          android:showAsAction="ifRoom">
+        <menu>
+            <item android:id="@+id/action_sort_size"
+                  android:icon="@android:drawable/ic_menu_sort_by_size"
+                  android:title="@string/action_bar_sort_size"
+                  android:onClick="onSort" />
+            <item android:id="@+id/action_sort_alpha"
+                  android:icon="@android:drawable/ic_menu_sort_alphabetically"
+                  android:title="@string/action_bar_sort_alpha"
+                  android:onClick="onSort" />
+        </menu>
+    </item>
+</menu>
diff --git a/samples/NFCDemo/res/layout/tag_divider.xml b/samples/ApiDemos/res/values-v16/bools.xml
similarity index 69%
rename from samples/NFCDemo/res/layout/tag_divider.xml
rename to samples/ApiDemos/res/values-v16/bools.xml
index b6b1b7c..4eb3b40 100644
--- a/samples/NFCDemo/res/layout/tag_divider.xml
+++ b/samples/ApiDemos/res/values-v16/bools.xml
@@ -1,6 +1,5 @@
 <?xml version="1.0" encoding="utf-8"?>
-<!--
-     Copyright (C) 2010 The Android Open Source Project
+<!-- Copyright (C) 2011 The Android Open Source Project
 
      Licensed under the Apache License, Version 2.0 (the "License");
      you may not use this file except in compliance with the License.
@@ -15,8 +14,7 @@
      limitations under the License.
 -->
 
-<View xmlns:android="http://schemas.android.com/apk/res/android"
-    android:layout_width="match_parent"
-    android:layout_height="wrap_content"
-    android:background="?android:attr/listDivider"
-/>
\ No newline at end of file
+<resources>
+    <!-- True if running under JellyBean or later. -->
+    <bool name="atLeastJellyBean">true</bool>
+</resources>
diff --git a/samples/ApiDemos/res/values/bools.xml b/samples/ApiDemos/res/values/bools.xml
index bc48079..c112fb4 100644
--- a/samples/ApiDemos/res/values/bools.xml
+++ b/samples/ApiDemos/res/values/bools.xml
@@ -29,4 +29,9 @@
          for IceCreamSandwich is true. -->
     <bool name="atLeastIceCreamSandwich">false</bool>
 
+    <!-- This resource is true if running under at least JellyBean
+         API level.  The default value is false; an alternative value
+         for JellyBean is true. -->
+    <bool name="atLeastJellyBean">false</bool>
+
 </resources>
diff --git a/samples/ApiDemos/res/values/strings.xml b/samples/ApiDemos/res/values/strings.xml
index c637655..3efba37 100644
--- a/samples/ApiDemos/res/values/strings.xml
+++ b/samples/ApiDemos/res/values/strings.xml
@@ -64,6 +64,9 @@
     <string name="activity_animation_msg">Press a button to launch an activity with a custom animation.</string>
     <string name="activity_animation_fade">Fade in</string>
     <string name="activity_animation_zoom">Zoom in</string>
+    <string name="activity_modern_animation_fade">Modern fade in</string>
+    <string name="activity_modern_animation_zoom">Modern zoom in</string>
+    <string name="activity_zoom_thumbnail_animation">Thumbnail zoom</string>
 
     <string name="activity_save_restore">App/Activity/Save &amp; Restore State</string>
     <string name="save_restore_msg">Demonstration of saving and restoring activity state in onSaveInstanceState() and onCreate().</string>
@@ -239,6 +242,20 @@
     <string name="start_service_foreground">Start Service Foreground</string>
     <string name="start_service_background">Start Service Background</string>
 
+    <string name="activity_isolated_service_controller">App/Service/Isolated Service Controller</string>
+    <string name="isolated_service_controller">This demonstrates the use of android:isolatedProcess
+            with services.  There are two services, which can be independently controlled; they will
+            each run in their own isolated process</string>
+    <string name="start_service_1">Start Service 1</string>
+    <string name="stop_service_1">Stop Service 1</string>
+    <string name="bind_service_1">Bind Service 1</string>
+    <string name="start_service_2">Start Service 2</string>
+    <string name="stop_service_2">Stop Service 2</string>
+    <string name="bind_service_2">Bind Service 2</string>
+    <string name="isolated_service_1_started">Isolated service 1 has started</string>
+    <string name="isolated_service_1_stopped">Isolated service 1 has stopped</string>
+    <string name="isolated_service_1_label">Sample Isolated Service 1</string>
+
     <string name="one_shot_received">The one-shot alarm has gone off</string>
     <string name="repeating_received">The repeating alarm has gone off</string>
 
@@ -1297,6 +1314,10 @@
     <!--  Accessibility examples strings  -->
     <!-- ============================ -->
 
+    <string name="accessibility_node_provider">Accessibility/Accessibility Node Provider</string>
+    <string name="accessibility_node_provider_instructions">Enable TalkBack and Explore-by-touch from accessibility
+        settings. Then touch the colored squares.</string>
+
     <string name="accessibility_service">Accessibility/Accessibility Service</string>
     <string name="accessibility_service_label">ClockBack</string>
     <string name="accessibility_service_instructions">
diff --git a/samples/ApiDemos/src/com/example/android/apis/accessibility/AccessibilityNodeProviderActivity.java b/samples/ApiDemos/src/com/example/android/apis/accessibility/AccessibilityNodeProviderActivity.java
new file mode 100644
index 0000000..16914c7
--- /dev/null
+++ b/samples/ApiDemos/src/com/example/android/apis/accessibility/AccessibilityNodeProviderActivity.java
@@ -0,0 +1,484 @@
+/*
+ * Copyright (C) 2011 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.example.android.apis.accessibility;
+
+import com.example.android.apis.R;
+
+import android.app.Activity;
+import android.app.Service;
+import android.content.Context;
+import android.graphics.Canvas;
+import android.graphics.Color;
+import android.graphics.Paint;
+import android.graphics.Rect;
+import android.os.Bundle;
+import android.text.TextUtils;
+import android.util.AttributeSet;
+import android.view.MotionEvent;
+import android.view.View;
+import android.view.accessibility.AccessibilityEvent;
+import android.view.accessibility.AccessibilityManager;
+import android.view.accessibility.AccessibilityNodeInfo;
+import android.view.accessibility.AccessibilityNodeProvider;
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
+
+/**
+ * This sample demonstrates how a View can expose a virtual view sub-tree
+ * rooted at it. A virtual sub-tree is composed of imaginary Views
+ * that are reported as a part of the view hierarchy for accessibility
+ * purposes. This enables custom views that draw complex content to report
+ * them selves as a tree of virtual views, thus conveying their logical
+ * structure.
+ * <p>
+ * For example, a View may draw a monthly calendar as a grid of days while
+ * each such day may contains some events. From a perspective of the View
+ * hierarchy the calendar is composed of a single View but an accessibility
+ * service would benefit of traversing the logical structure of the calendar
+ * by examining each day and each event on that day.
+ * </p>
+ */
+public class AccessibilityNodeProviderActivity extends Activity {
+    /** Called when the activity is first created. */
+    @Override
+    public void onCreate(Bundle savedInstanceState) {
+        super.onCreate(savedInstanceState);
+        setContentView(R.layout.accessibility_node_provider);
+    }
+
+   /**
+    * This class presents a View that is composed of three virtual children
+    * each of which is drawn with a different color and represents a region
+    * of the View that has different semantics compared to other such regions.
+    * While the virtual view tree exposed by this class is one level deep
+    * for simplicity, there is no bound on the complexity of that virtual
+    * sub-tree.
+    */
+    public static class VirtualSubtreeRootView extends View {
+
+        /** Paint object for drawing the virtual sub-tree */
+        private final Paint mPaint = new Paint();
+
+        /** Temporary rectangle to minimize object creation. */
+        private final Rect mTempRect = new Rect();
+
+        /** Handle to the system accessibility service. */
+        private final AccessibilityManager mAccessibilityManager;
+
+        /** The virtual children of this View. */
+        private final List<VirtualView> mChildren = new ArrayList<VirtualView>();
+
+        /** The instance of the node provider for the virtual tree - lazily instantiated. */
+        private AccessibilityNodeProvider mAccessibilityNodeProvider;
+
+        /** The last hovered child used for event dispatching. */
+        private VirtualView mLastHoveredChild;
+
+        public VirtualSubtreeRootView(Context context, AttributeSet attrs) {
+            super(context, attrs);
+            mAccessibilityManager = (AccessibilityManager) context.getSystemService(
+                    Service.ACCESSIBILITY_SERVICE);
+            createVirtualChildren();
+        }
+
+        /**
+         * {@inheritDoc}
+         */
+        @Override
+        public AccessibilityNodeProvider getAccessibilityNodeProvider() {
+            // Instantiate the provide only when requested. Since the system
+            // will call this method multiple times it is a good practice to
+            // cache the provider instance.
+            if (mAccessibilityNodeProvider == null) {
+                mAccessibilityNodeProvider = new VirtualDescendantsProvider();
+            }
+            return mAccessibilityNodeProvider;
+        }
+
+        /**
+         * {@inheritDoc}
+         */
+        @Override
+        public boolean dispatchHoverEvent(MotionEvent event) {
+            // This implementation assumes that the virtual children
+            // cannot overlap and are always visible. Do NOT use this
+            // code as a reference of how to implement hover event
+            // dispatch. Instead, refer to ViewGroup#dispatchHoverEvent.
+            boolean handled = false;
+            List<VirtualView> children = mChildren;
+            final int childCount = children.size();
+            for (int i = 0; i < childCount; i++) {
+                VirtualView child = children.get(i);
+                Rect childBounds = child.mBounds;
+                final int childCoordsX = (int) event.getX() + getScrollX();
+                final int childCoordsY = (int) event.getY() + getScrollY();
+                if (!childBounds.contains(childCoordsX, childCoordsY)) {
+                    continue;
+                }
+                final int action = event.getAction();
+                switch (action) {
+                    case MotionEvent.ACTION_HOVER_ENTER: {
+                        mLastHoveredChild = child;
+                        handled |= onHoverVirtualView(child, event);
+                        event.setAction(action);
+                    } break;
+                    case MotionEvent.ACTION_HOVER_MOVE: {
+                        if (child == mLastHoveredChild) {
+                            handled |= onHoverVirtualView(child, event);
+                            event.setAction(action);
+                        } else {
+                            MotionEvent eventNoHistory = event.getHistorySize() > 0
+                                ? MotionEvent.obtainNoHistory(event) : event;
+                            eventNoHistory.setAction(MotionEvent.ACTION_HOVER_EXIT);
+                            onHoverVirtualView(mLastHoveredChild, eventNoHistory);
+                            eventNoHistory.setAction(MotionEvent.ACTION_HOVER_ENTER);
+                            onHoverVirtualView(child, eventNoHistory);
+                            mLastHoveredChild = child;
+                            eventNoHistory.setAction(MotionEvent.ACTION_HOVER_MOVE);
+                            handled |= onHoverVirtualView(child, eventNoHistory);
+                            if (eventNoHistory != event) {
+                                eventNoHistory.recycle();
+                            } else {
+                                event.setAction(action);
+                            }
+                        }
+                    } break;
+                    case MotionEvent.ACTION_HOVER_EXIT: {
+                        mLastHoveredChild = null;
+                        handled |= onHoverVirtualView(child, event);
+                        event.setAction(action);
+                    } break;
+                }
+            }
+            if (!handled) {
+                handled |= onHoverEvent(event);
+            }
+            return handled;
+        }
+
+        /**
+         * {@inheritDoc}
+         */
+        @Override
+        protected void onLayout(boolean changed, int left, int top, int right, int bottom) {
+            // The virtual children are ordered horizontally next to
+            // each other and take the entire space of this View.
+            int offsetX = 0;
+            List<VirtualView> children = mChildren;
+            final int childCount = children.size();
+            for (int i = 0; i < childCount; i++) {
+                VirtualView child = children.get(i);
+                Rect childBounds = child.mBounds;
+                childBounds.set(offsetX, 0, offsetX + childBounds.width(), childBounds.height());
+                offsetX += childBounds.width();
+            }
+        }
+
+        /**
+         * {@inheritDoc}
+         */
+        @Override
+        protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
+            // The virtual children are ordered horizontally next to
+            // each other and take the entire space of this View.
+            int width = 0;
+            int height = 0;
+            List<VirtualView> children = mChildren;
+            final int childCount = children.size();
+            for (int i = 0; i < childCount; i++) {
+                VirtualView child = children.get(i);
+                width += child.mBounds.width();
+                height = Math.max(height, child.mBounds.height());
+            }
+            setMeasuredDimension(width, height);
+        }
+
+        /**
+         * {@inheritDoc}
+         */
+        @Override
+        protected void onDraw(Canvas canvas) {
+            // Draw the virtual children with the reusable Paint object
+            // and with the bounds and color which are child specific.
+            Rect drawingRect = mTempRect;
+            List<VirtualView> children = mChildren;
+            final int childCount = children.size();
+            for (int i = 0; i < childCount; i++) {
+                VirtualView child = children.get(i);
+                drawingRect.set(child.mBounds);
+                mPaint.setColor(child.mColor);
+                mPaint.setAlpha(child.mAlpha);
+                canvas.drawRect(drawingRect, mPaint);
+            }
+        }
+
+        /**
+         * Creates the virtual children of this View.
+         */
+        private void createVirtualChildren() {
+            // The virtual portion of the tree is one level deep. Note
+            // that implementations can use any way of representing and
+            // drawing virtual view.
+            VirtualView firstChild = new VirtualView(0, new Rect(0, 0, 150, 150), Color.RED,
+                    "Virtual view 1");
+            mChildren.add(firstChild);
+            VirtualView secondChild = new VirtualView(1, new Rect(0, 0, 150, 150), Color.GREEN,
+                    "Virtual view 2");
+            mChildren.add(secondChild);
+            VirtualView thirdChild = new VirtualView(2, new Rect(0, 0, 150, 150), Color.BLUE,
+                    "Virtual view 3");
+            mChildren.add(thirdChild);
+        }
+
+        /**
+         * Set the selected state of a virtual view.
+         *
+         * @param virtualView The virtual view whose selected state to set.
+         * @param selected Whether the virtual view is selected.
+         */
+        private void setVirtualViewSelected(VirtualView virtualView, boolean selected) {
+            virtualView.mAlpha = selected ? VirtualView.ALPHA_SELECTED : VirtualView.ALPHA_NOT_SELECTED;
+        }
+
+        /**
+         * Handle a hover over a virtual view.
+         *
+         * @param virtualView The virtual view over which is hovered.
+         * @param event The event to dispatch.
+         * @return Whether the event was handled.
+         */
+        private boolean onHoverVirtualView(VirtualView virtualView, MotionEvent event) {
+            // The implementation of hover event dispatch can be implemented
+            // in any way that is found suitable. However, each virtual View
+            // should fire a corresponding accessibility event whose source
+            // is that virtual view. Accessibility services get the event source
+            // as the entry point of the APIs for querying the window content.
+            final int action = event.getAction();
+            switch (action) {
+                case MotionEvent.ACTION_HOVER_ENTER: {
+                    sendAccessibilityEventForVirtualView(virtualView,
+                            AccessibilityEvent.TYPE_VIEW_HOVER_ENTER);
+                } break;
+                case MotionEvent.ACTION_HOVER_EXIT: {
+                    sendAccessibilityEventForVirtualView(virtualView,
+                            AccessibilityEvent.TYPE_VIEW_HOVER_EXIT);
+                } break;
+            }
+            return true;
+        }
+
+        /**
+         * Sends a properly initialized accessibility event for a virtual view..
+         *
+         * @param virtualView The virtual view.
+         * @param eventType The type of the event to send.
+         */
+        private void sendAccessibilityEventForVirtualView(VirtualView virtualView, int eventType) {
+            // If touch exploration, i.e. the user gets feedback while touching
+            // the screen, is enabled we fire accessibility events.
+            if (mAccessibilityManager.isTouchExplorationEnabled()) {
+                AccessibilityEvent event = AccessibilityEvent.obtain(eventType);
+                event.setPackageName(getContext().getPackageName());
+                event.setClassName(virtualView.getClass().getName());
+                event.setSource(VirtualSubtreeRootView.this, virtualView.mId);
+                event.getText().add(virtualView.mText);
+                getParent().requestSendAccessibilityEvent(VirtualSubtreeRootView.this, event);
+            }
+        }
+
+        /**
+         * Finds a virtual view given its id.
+         *
+         * @param id The virtual view id.
+         * @return The found virtual view.
+         */
+        private VirtualView findVirtualViewById(int id) {
+            List<VirtualView> children = mChildren;
+            final int childCount = children.size();
+            for (int i = 0; i < childCount; i++) {
+                VirtualView child = children.get(i);
+                if (child.mId == id) {
+                    return child;
+                }
+            }
+            return null;
+        }
+
+        /**
+         * Represents a virtual View.
+         */
+        private class VirtualView {
+            public static final int ALPHA_SELECTED = 255;
+            public static final int ALPHA_NOT_SELECTED = 127;
+
+            public final int mId;
+            public final int mColor;
+            public final Rect mBounds;
+            public final String mText;
+            public int mAlpha;
+
+            public VirtualView(int id, Rect bounds, int color, String text) {
+                mId = id;
+                mColor = color;
+                mBounds = bounds;
+                mText = text;
+                mAlpha = ALPHA_NOT_SELECTED;
+            }
+        }
+
+        /**
+         * This is the provider that exposes the virtual View tree to accessibility
+         * services. From the perspective of an accessibility service the
+         * {@link AccessibilityNodeInfo}s it receives while exploring the sub-tree
+         * rooted at this View will be the same as the ones it received while
+         * exploring a View containing a sub-tree composed of real Views.
+         */
+        private class VirtualDescendantsProvider extends AccessibilityNodeProvider {
+
+            /**
+             * {@inheritDoc}
+             */
+            @Override
+            public AccessibilityNodeInfo createAccessibilityNodeInfo(int virtualViewId) {
+                AccessibilityNodeInfo info = null;
+                if (virtualViewId == View.NO_ID) {
+                    // We are requested to create an AccessibilityNodeInfo describing
+                    // this View, i.e. the root of the virtual sub-tree. Note that the
+                    // host View has an AccessibilityNodeProvider which means that this
+                    // provider is responsible for creating the node info for that root.
+                    info = AccessibilityNodeInfo.obtain(VirtualSubtreeRootView.this);
+                    onInitializeAccessibilityNodeInfo(info);
+                    // Add the virtual children of the root View.
+                    List<VirtualView> children = mChildren;
+                    final int childCount = children.size();
+                    for (int i = 0; i < childCount; i++) {
+                        VirtualView child = children.get(i);
+                        info.addChild(VirtualSubtreeRootView.this, child.mId);
+                    }
+                } else {
+                    // Find the view that corresponds to the given id.
+                    VirtualView virtualView = findVirtualViewById(virtualViewId);
+                    if (virtualView == null) {
+                        return null;
+                    }
+                    // Obtain and initialize an AccessibilityNodeInfo with
+                    // information about the virtual view.
+                    info = AccessibilityNodeInfo.obtain();
+                    info.addAction(AccessibilityNodeInfo.ACTION_SELECT);
+                    info.addAction(AccessibilityNodeInfo.ACTION_CLEAR_SELECTION);
+                    info.setPackageName(getContext().getPackageName());
+                    info.setClassName(virtualView.getClass().getName());
+                    info.setSource(VirtualSubtreeRootView.this, virtualViewId);
+                    info.setBoundsInParent(virtualView.mBounds);
+                    info.setParent(VirtualSubtreeRootView.this);
+                    info.setText(virtualView.mText);
+                }
+                return info;
+            }
+
+            /**
+             * {@inheritDoc}
+             */
+            @Override
+            public List<AccessibilityNodeInfo> findAccessibilityNodeInfosByText(String searched,
+                    int virtualViewId) {
+                if (TextUtils.isEmpty(searched)) {
+                    return Collections.emptyList();
+                }
+                String searchedLowerCase = searched.toLowerCase();
+                List<AccessibilityNodeInfo> result = null;
+                if (virtualViewId == View.NO_ID) {
+                    // If the search is from the root, i.e. this View, go over the virtual
+                    // children and look for ones that contain the searched string since
+                    // this View does not contain text itself.
+                    List<VirtualView> children = mChildren;
+                    final int childCount = children.size();
+                    for (int i = 0; i < childCount; i++) {
+                        VirtualView child = children.get(i);
+                        String textToLowerCase = child.mText.toLowerCase();
+                        if (textToLowerCase.contains(searchedLowerCase)) {
+                            if (result == null) {
+                                result = new ArrayList<AccessibilityNodeInfo>();
+                            }
+                            result.add(createAccessibilityNodeInfo(child.mId));
+                        }
+                    }
+                } else {
+                    // If the search is from a virtual view, find the view. Since the tree
+                    // is one level deep we add a node info for the child to the result if
+                    // the child contains the searched text.
+                    VirtualView virtualView = findVirtualViewById(virtualViewId);
+                    if (virtualView != null) {
+                        String textToLowerCase = virtualView.mText.toLowerCase();
+                        if (textToLowerCase.contains(searchedLowerCase)) {
+                            result = new ArrayList<AccessibilityNodeInfo>();
+                            result.add(createAccessibilityNodeInfo(virtualViewId));
+                        }
+                    }
+                }
+                if (result == null) {
+                    return Collections.emptyList();
+                }
+                return result;
+            }
+
+            /**
+             * {@inheritDoc}
+             */
+            @Override
+            public boolean performAccessibilityAction(int action, int virtualViewId) {
+                if (virtualViewId == View.NO_ID) {
+                    // Perform the action on the host View.
+                    switch (action) {
+                        case AccessibilityNodeInfo.ACTION_SELECT:
+                            if (!isSelected()) {
+                                setSelected(true);
+                                return isSelected();
+                            }
+                            break;
+                        case AccessibilityNodeInfo.ACTION_CLEAR_SELECTION:
+                            if (isSelected()) {
+                                setSelected(false);
+                                return !isSelected();
+                            }
+                            break;
+                    }
+                } else {
+                    // Find the view that corresponds to the given id.
+                    VirtualView child = findVirtualViewById(virtualViewId);
+                    if (child == null) {
+                        return false;
+                    }
+                    // Perform the action on a virtual view.
+                    switch (action) {
+                        case AccessibilityNodeInfo.ACTION_SELECT:
+                            setVirtualViewSelected(child, true);
+                            invalidate();
+                            return true;
+                        case AccessibilityNodeInfo.ACTION_CLEAR_SELECTION:
+                            setVirtualViewSelected(child, false);
+                            invalidate();
+                            return true;
+                    }
+                }
+                return false;
+            }
+        }
+    }
+}
diff --git a/samples/ApiDemos/src/com/example/android/apis/accessibility/_index.html b/samples/ApiDemos/src/com/example/android/apis/accessibility/_index.html
index 713d913..df54e96 100644
--- a/samples/ApiDemos/src/com/example/android/apis/accessibility/_index.html
+++ b/samples/ApiDemos/src/com/example/android/apis/accessibility/_index.html
@@ -1,3 +1,4 @@
+<h3 id="Accessibility">Accessibility</h3>
 <dl>
   <dt><a href="ClockBackService.html">Accessibility Service</a></dt>
   <dd>
@@ -20,6 +21,12 @@
     xml files, and adding additional information to AccessibilityEvents using
     AccessibilityRecords.
   </dd>
+  <dt><a href="AccessibilityNodeProviderActivity.html">Accessibility Node Provider</a></dt>
+  <dd>Demonstrates how to develop an accessibility node provider which manages a virtual
+    View tree reported to accessibility services. The virtual subtree is rooted at a View
+    that draws complex content and reports itself as a tree of virtual views, thus conveying
+    its logical structure.
+  </dd>
 </dl>
 
 <dl>
diff --git a/samples/ApiDemos/src/com/example/android/apis/app/Animation.java b/samples/ApiDemos/src/com/example/android/apis/app/Animation.java
index bd2bd89..d50da2b 100644
--- a/samples/ApiDemos/src/com/example/android/apis/app/Animation.java
+++ b/samples/ApiDemos/src/com/example/android/apis/app/Animation.java
@@ -19,10 +19,12 @@
 // Need the following import to get access to the app resources, since this
 // class is in a sub-package.
 import com.example.android.apis.R;
-import com.example.android.apis.view.Controls1;
 
 import android.app.Activity;
+import android.app.ActivityOptions;
 import android.content.Intent;
+import android.graphics.Bitmap;
+import android.graphics.Canvas;
 import android.os.Bundle;
 import android.view.View;
 import android.view.View.OnClickListener;
@@ -44,12 +46,24 @@
         button.setOnClickListener(mFadeListener);
         button = (Button)findViewById(R.id.zoom_animation);
         button.setOnClickListener(mZoomListener);
+        if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.JELLY_BEAN) {
+            button = (Button)findViewById(R.id.modern_fade_animation);
+            button.setOnClickListener(mModernFadeListener);
+            button = (Button)findViewById(R.id.modern_zoom_animation);
+            button.setOnClickListener(mModernZoomListener);
+            button = (Button)findViewById(R.id.zoom_thumbnail_animation);
+            button.setOnClickListener(mZoomThumbnailListener);
+        } else {
+            findViewById(R.id.modern_fade_animation).setEnabled(false);
+            findViewById(R.id.modern_zoom_animation).setEnabled(false);
+            findViewById(R.id.zoom_thumbnail_animation).setEnabled(false);
+        }
     }
 
     private OnClickListener mFadeListener = new OnClickListener() {
         public void onClick(View v) {
             // Request the next activity transition (here starting a new one).
-            startActivity(new Intent(Animation.this, Controls1.class));
+            startActivity(new Intent(Animation.this, AlertDialogSamples.class));
             // Supply a custom animation.  This one will just fade the new
             // activity on top.  Note that we need to also supply an animation
             // (here just doing nothing for the same amount of time) for the
@@ -61,7 +75,7 @@
     private OnClickListener mZoomListener = new OnClickListener() {
         public void onClick(View v) {
             // Request the next activity transition (here starting a new one).
-            startActivity(new Intent(Animation.this, Controls1.class));
+            startActivity(new Intent(Animation.this, AlertDialogSamples.class));
             // This is a more complicated animation, involving transformations
             // on both this (exit) and the new (enter) activity.  Note how for
             // the duration of the animation we force the exiting activity
@@ -70,5 +84,49 @@
             overridePendingTransition(R.anim.zoom_enter, R.anim.zoom_exit);
         }
     };
+
+    private OnClickListener mModernFadeListener = new OnClickListener() {
+        public void onClick(View v) {
+            // Create the desired custom animation, involving transformations
+            // on both this (exit) and the new (enter) activity.  Note how for
+            // the duration of the animation we force the exiting activity
+            // to be Z-ordered on top (even though it really isn't) to achieve
+            // the effect we want.
+            ActivityOptions opts = ActivityOptions.makeCustomAnimation(Animation.this,
+                    R.anim.fade, R.anim.hold);
+            // Request the activity be started, using the custom animation options.
+            startActivity(new Intent(Animation.this, AlertDialogSamples.class), opts.toBundle());
+        }
+    };
+
+    private OnClickListener mModernZoomListener = new OnClickListener() {
+        public void onClick(View v) {
+            // Create a more complicated animation, involving transformations
+            // on both this (exit) and the new (enter) activity.  Note how for
+            // the duration of the animation we force the exiting activity
+            // to be Z-ordered on top (even though it really isn't) to achieve
+            // the effect we want.
+            ActivityOptions opts = ActivityOptions.makeCustomAnimation(Animation.this,
+                    R.anim.zoom_enter, R.anim.zoom_enter);
+            // Request the activity be started, using the custom animation options.
+            startActivity(new Intent(Animation.this, AlertDialogSamples.class), opts.toBundle());
+        }
+    };
+
+    private OnClickListener mZoomThumbnailListener = new OnClickListener() {
+        public void onClick(View v) {
+            // Create a thumbnail animation.  We are going to build our thumbnail
+            // just from the view that was pressed.
+            v.setDrawingCacheEnabled(true);
+            Bitmap bm = v.getDrawingCache();
+            Canvas c = new Canvas(bm);
+            //c.drawARGB(255, 255, 0, 0);
+            ActivityOptions opts = ActivityOptions.makeThumbnailScaleUpAnimation(
+                    v, bm, 0, 0, null);
+            // Request the activity be started, using the custom animation options.
+            startActivity(new Intent(Animation.this, AlertDialogSamples.class), opts.toBundle());
+            v.setDrawingCacheEnabled(false);
+        }
+    };
 }
 
diff --git a/samples/ApiDemos/src/com/example/android/apis/app/IsolatedService.java b/samples/ApiDemos/src/com/example/android/apis/app/IsolatedService.java
new file mode 100644
index 0000000..bf3c523
--- /dev/null
+++ b/samples/ApiDemos/src/com/example/android/apis/app/IsolatedService.java
@@ -0,0 +1,206 @@
+/*
+ * Copyright (C) 2012 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.app;
+
+import android.app.Activity;
+import android.app.Service;
+import android.content.ComponentName;
+import android.content.Context;
+import android.content.Intent;
+import android.content.ServiceConnection;
+import android.os.Bundle;
+import android.os.RemoteException;
+import android.os.IBinder;
+import android.os.RemoteCallbackList;
+import android.util.Log;
+import android.view.View;
+import android.view.View.OnClickListener;
+import android.widget.Button;
+import android.widget.CheckBox;
+import android.widget.TextView;
+
+// Need the following import to get access to the app resources, since this
+// class is in a sub-package.
+import com.example.android.apis.R;
+
+/**
+ * This is an example if implementing a Service that uses android:isolatedProcess.
+ */
+public class IsolatedService extends Service {
+    /**
+     * This is a list of callbacks that have been registered with the
+     * service.  Note that this is package scoped (instead of private) so
+     * that it can be accessed more efficiently from inner classes.
+     */
+    final RemoteCallbackList<IRemoteServiceCallback> mCallbacks
+            = new RemoteCallbackList<IRemoteServiceCallback>();
+    
+    int mValue = 0;
+    
+    @Override
+    public void onCreate() {
+        Log.i("IsolatedService", "Creating IsolatedService: " + this);
+    }
+
+    @Override
+    public void onDestroy() {
+        Log.i("IsolatedService", "Destroying IsolatedService: " + this);
+        // Unregister all callbacks.
+        mCallbacks.kill();
+    }
+
+    @Override
+    public IBinder onBind(Intent intent) {
+        return mBinder;
+    }
+
+    /**
+     * The IRemoteInterface is defined through IDL
+     */
+    private final IRemoteService.Stub mBinder = new IRemoteService.Stub() {
+        public void registerCallback(IRemoteServiceCallback cb) {
+            if (cb != null) mCallbacks.register(cb);
+        }
+        public void unregisterCallback(IRemoteServiceCallback cb) {
+            if (cb != null) mCallbacks.unregister(cb);
+        }
+    };
+    
+    @Override
+    public void onTaskRemoved(Intent rootIntent) {
+        Log.i("IsolatedService", "Task removed in " + this + ": " + rootIntent);
+        stopSelf();
+    }
+
+    private void broadcastValue(int value) {
+        // Broadcast to all clients the new value.
+        final int N = mCallbacks.beginBroadcast();
+        for (int i=0; i<N; i++) {
+            try {
+                mCallbacks.getBroadcastItem(i).valueChanged(value);
+            } catch (RemoteException e) {
+                // The RemoteCallbackList will take care of removing
+                // the dead object for us.
+            }
+        }
+        mCallbacks.finishBroadcast();
+    }
+    
+    // ----------------------------------------------------------------------
+    
+    public static class Controller extends Activity {
+        static class ServiceInfo {
+            final Activity mActivity;
+            final Class<?> mClz;
+            final TextView mStatus;
+            boolean mServiceBound;
+            IRemoteService mService;
+
+            ServiceInfo(Activity activity, Class<?> clz,
+                    int start, int stop, int bind, int status) {
+                mActivity = activity;
+                mClz = clz;
+                Button button = (Button)mActivity.findViewById(start);
+                button.setOnClickListener(mStartListener);
+                button = (Button)mActivity.findViewById(stop);
+                button.setOnClickListener(mStopListener);
+                CheckBox cb = (CheckBox)mActivity.findViewById(bind);
+                cb.setOnClickListener(mBindListener);
+                mStatus = (TextView)mActivity.findViewById(status);
+            }
+
+            void destroy() {
+                if (mServiceBound) {
+                    mActivity.unbindService(mConnection);
+                }
+            }
+
+            private OnClickListener mStartListener = new OnClickListener() {
+                public void onClick(View v) {
+                    mActivity.startService(new Intent(mActivity, mClz));
+                }
+            };
+
+            private OnClickListener mStopListener = new OnClickListener() {
+                public void onClick(View v) {
+                    mActivity.stopService(new Intent(mActivity, mClz));
+                }
+            };
+
+            private OnClickListener mBindListener = new OnClickListener() {
+                public void onClick(View v) {
+                    if (((CheckBox)v).isChecked()) {
+                        if (!mServiceBound) {
+                            if (mActivity.bindService(new Intent(mActivity, mClz),
+                                    mConnection, Context.BIND_AUTO_CREATE)) {
+                                mServiceBound = true;
+                                mStatus.setText("BOUND");
+                            }
+                        }
+                    } else {
+                        if (mServiceBound) {
+                            mActivity.unbindService(mConnection);
+                            mServiceBound = false;
+                            mStatus.setText("");
+                        }
+                    }
+                }
+            };
+
+            private ServiceConnection mConnection = new ServiceConnection() {
+                public void onServiceConnected(ComponentName className,
+                        IBinder service) {
+                    mService = IRemoteService.Stub.asInterface(service);
+                    if (mServiceBound) {
+                        mStatus.setText("CONNECTED");
+                    }
+                }
+
+                public void onServiceDisconnected(ComponentName className) {
+                    // This is called when the connection with the service has been
+                    // unexpectedly disconnected -- that is, its process crashed.
+                    mService = null;
+                    if (mServiceBound) {
+                        mStatus.setText("DISCONNECTED");
+                    }
+                }
+            };
+        }
+
+        ServiceInfo mService1;
+        ServiceInfo mService2;
+
+        @Override
+        protected void onCreate(Bundle savedInstanceState) {
+            super.onCreate(savedInstanceState);
+
+            setContentView(R.layout.isolated_service_controller);
+
+            mService1 = new ServiceInfo(this, IsolatedService.class, R.id.start1, R.id.stop1,
+                    R.id.bind1, R.id.status1);
+            mService2 = new ServiceInfo(this, IsolatedService2.class, R.id.start2, R.id.stop2,
+                    R.id.bind2, R.id.status2);
+        }
+
+        @Override
+        protected void onDestroy() {
+            super.onDestroy();
+            mService1.destroy();
+            mService2.destroy();
+        }
+    }
+}
diff --git a/samples/ApiDemos/src/com/example/android/apis/app/IsolatedService2.java b/samples/ApiDemos/src/com/example/android/apis/app/IsolatedService2.java
new file mode 100644
index 0000000..d313a67
--- /dev/null
+++ b/samples/ApiDemos/src/com/example/android/apis/app/IsolatedService2.java
@@ -0,0 +1,24 @@
+/*
+ * Copyright (C) 2012 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.app;
+
+/**
+ * Stub to be able to have another instance of IsolatedService running.
+ */
+public class IsolatedService2 extends IsolatedService {
+
+}
diff --git a/samples/ApiDemos/src/com/example/android/apis/app/MenuInflateFromXml.java b/samples/ApiDemos/src/com/example/android/apis/app/MenuInflateFromXml.java
index fc7b62a..877714f 100644
--- a/samples/ApiDemos/src/com/example/android/apis/app/MenuInflateFromXml.java
+++ b/samples/ApiDemos/src/com/example/android/apis/app/MenuInflateFromXml.java
@@ -23,6 +23,8 @@
 import android.view.Menu;
 import android.view.MenuInflater;
 import android.view.MenuItem;
+import android.view.View;
+import android.widget.AdapterView;
 import android.widget.ArrayAdapter;
 import android.widget.LinearLayout;
 import android.widget.Spinner;
@@ -86,6 +88,15 @@
         // so it will automatically save its instance state
         mSpinner.setId(R.id.spinner);
         mSpinner.setAdapter(adapter);
+        mSpinner.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
+            @Override
+            public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
+                invalidateOptionsMenu();
+            }
+            @Override
+            public void onNothingSelected(AdapterView<?> parent) {
+            }
+        });
         
         // Add the spinner
         layout.addView(mSpinner,
@@ -118,10 +129,6 @@
         MenuInflater inflater = getMenuInflater();
         inflater.inflate(sMenuExampleResources[mSpinner.getSelectedItemPosition()], menu);
         
-        // Disable the spinner since we've already created the menu and the user
-        // can no longer pick a different menu XML.
-        mSpinner.setEnabled(false);
-        
         // Change instructions
         mInstructionsText.setText(getResources().getString(
                 R.string.menu_from_xml_instructions_go_back));
@@ -136,6 +143,7 @@
             //                   the XML
             case R.id.jump:
                 Toast.makeText(this, "Jump up in the air!", Toast.LENGTH_SHORT).show();
+                invalidateOptionsMenu();
                 return true;
 
             case R.id.dive:
diff --git a/samples/ApiDemos/src/com/example/android/apis/nfc/ForegroundNdefPush.java b/samples/ApiDemos/src/com/example/android/apis/nfc/ForegroundNdefPush.java
index fe478ed..08eb839 100644
--- a/samples/ApiDemos/src/com/example/android/apis/nfc/ForegroundNdefPush.java
+++ b/samples/ApiDemos/src/com/example/android/apis/nfc/ForegroundNdefPush.java
@@ -25,9 +25,6 @@
 import android.os.Bundle;
 import android.widget.TextView;
 
-import java.nio.charset.Charset;
-import java.util.Locale;
-
 /**
  * An example of how to use the NFC foreground NDEF push APIs.
  */
@@ -36,51 +33,23 @@
     private TextView mText;
     private NdefMessage mMessage;
 
-    public static NdefRecord newTextRecord(String text, Locale locale, boolean encodeInUtf8) {
-        byte[] langBytes = locale.getLanguage().getBytes(Charset.forName("US-ASCII"));
-
-        Charset utfEncoding = encodeInUtf8 ? Charset.forName("UTF-8") : Charset.forName("UTF-16");
-        byte[] textBytes = text.getBytes(utfEncoding);
-
-        int utfBit = encodeInUtf8 ? 0 : (1 << 7);
-        char status = (char) (utfBit + langBytes.length);
-
-        byte[] data = new byte[1 + langBytes.length + textBytes.length]; 
-        data[0] = (byte) status;
-        System.arraycopy(langBytes, 0, data, 1, langBytes.length);
-        System.arraycopy(textBytes, 0, data, 1 + langBytes.length, textBytes.length);
-
-        return new NdefRecord(NdefRecord.TNF_WELL_KNOWN, NdefRecord.RTD_TEXT, new byte[0], data);
-    }
-
     @Override
     public void onCreate(Bundle savedState) {
         super.onCreate(savedState);
 
         mAdapter = NfcAdapter.getDefaultAdapter(this);
 
+        // Create an NDEF message a URL
+        mMessage = new NdefMessage(NdefRecord.createUri("http://www.android.com"));
+
         setContentView(R.layout.foreground_dispatch);
         mText = (TextView) findViewById(R.id.text);
+
         if (mAdapter != null) {
-            mText.setText("Tap another Android phone with NFC to push 'NDEF Push Sample'");
+            mAdapter.setNdefPushMessage(mMessage, this);
+            mText.setText("Tap another Android phone with NFC to push a URL");
         } else {
             mText.setText("This phone is not NFC enabled.");
         }
-
-        // Create an NDEF message with some sample text
-        mMessage = new NdefMessage(
-                new NdefRecord[] { newTextRecord("NDEF Push Sample", Locale.ENGLISH, true)});        
-    }
-
-    @Override
-    public void onResume() {
-        super.onResume();
-        if (mAdapter != null) mAdapter.enableForegroundNdefPush(this, mMessage);
-    }
-
-    @Override
-    public void onPause() {
-        super.onPause();
-        if (mAdapter != null) mAdapter.disableForegroundNdefPush(this);
     }
 }
diff --git a/samples/ApiDemos/src/com/example/android/apis/view/ContentBrowserActivity.java b/samples/ApiDemos/src/com/example/android/apis/view/ContentBrowserActivity.java
new file mode 100644
index 0000000..af802a6
--- /dev/null
+++ b/samples/ApiDemos/src/com/example/android/apis/view/ContentBrowserActivity.java
@@ -0,0 +1,247 @@
+/*
+ * Copyright (C) 2011 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.example.android.apis.view;
+
+import android.app.ActionBar;
+import android.app.ActionBar.Tab;
+import android.app.Activity;
+import android.app.FragmentTransaction;
+import android.content.Context;
+import android.content.Intent;
+import android.net.Uri;
+import android.os.Bundle;
+import android.os.Handler;
+import android.util.AttributeSet;
+import android.view.Menu;
+import android.view.MenuInflater;
+import android.view.MenuItem;
+import android.view.View;
+import android.view.ViewGroup;
+import android.view.Window;
+import android.widget.ScrollView;
+import android.widget.SearchView;
+import android.widget.ShareActionProvider;
+import android.widget.TextView;
+import android.widget.Toast;
+import android.widget.SearchView.OnQueryTextListener;
+
+import com.example.android.apis.R;
+
+/**
+ * This activity demonstrates how to use system UI flags to implement
+ * a content browser style of UI (such as a book reader).
+ */
+public class ContentBrowserActivity extends Activity
+        implements OnQueryTextListener, ActionBar.TabListener {
+
+    /**
+     * Implementation of a view for displaying immersive content, using system UI
+     * flags to transition in and out of modes where the user is focused on that
+     * content.
+     */
+//BEGIN_INCLUDE(content)
+    public static class Content extends ScrollView
+            implements View.OnSystemUiVisibilityChangeListener, View.OnClickListener {
+        TextView mText;
+        boolean mNavVisible;
+        int mBaseSystemUiVisibility = SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN
+                | SYSTEM_UI_FLAG_LAYOUT_STABLE;
+        int mLastSystemUiVis;
+
+        Runnable mNavHider = new Runnable() {
+            @Override public void run() {
+                setNavVisibility(false);
+            }
+        };
+
+        public Content(Context context, AttributeSet attrs) {
+            super(context, attrs);
+    
+            mText = new TextView(context);
+            mText.setText(context.getString(R.string.alert_dialog_two_buttons2ultra_msg));
+            mText.setClickable(false);
+            mText.setLongClickable(false);
+            mText.setOnClickListener(this);
+            addView(mText, new ViewGroup.LayoutParams(
+                    ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT));
+
+            setOnSystemUiVisibilityChangeListener(this);
+            setNavVisibility(true);
+        }
+
+        @Override public void onSystemUiVisibilityChange(int visibility) {
+            // Detect when we go out of low-profile mode, to also go out
+            // of full screen.  We only do this when the low profile mode
+            // is changing from its last state, and turning off.
+            int diff = mLastSystemUiVis ^ visibility;
+            mLastSystemUiVis = visibility;
+            if ((diff&SYSTEM_UI_FLAG_LOW_PROFILE) != 0
+                    && (visibility&SYSTEM_UI_FLAG_LOW_PROFILE) == 0) {
+                setNavVisibility(true);
+            }
+        }
+
+        @Override protected void onWindowVisibilityChanged(int visibility) {
+            super.onWindowVisibilityChanged(visibility);
+
+            // When we become visible, we show our navigation elements briefly
+            // before hiding them.
+            setNavVisibility(true);
+            getHandler().postDelayed(mNavHider, 2000);
+        }
+
+        @Override protected void onScrollChanged(int l, int t, int oldl, int oldt) {
+            super.onScrollChanged(l, t, oldl, oldt);
+
+            // When the user scrolls, we hide navigation elements.
+            setNavVisibility(false);
+        }
+
+        @Override public void onClick(View v) {
+            // When the user clicks, we toggle the visibility of navigation elements.
+            int curVis = getSystemUiVisibility();
+            setNavVisibility((curVis&SYSTEM_UI_FLAG_LOW_PROFILE) != 0);
+        }
+
+        void setBaseSystemUiVisibility(int visibility) {
+            mBaseSystemUiVisibility = visibility;
+        }
+
+        void setNavVisibility(boolean visible) {
+            int newVis = mBaseSystemUiVisibility;
+            if (!visible) {
+                newVis |= SYSTEM_UI_FLAG_LOW_PROFILE | SYSTEM_UI_FLAG_FULLSCREEN;
+            }
+            final boolean changed = newVis == getSystemUiVisibility();
+
+            // Unschedule any pending event to hide navigation if we are
+            // changing the visibility, or making the UI visible.
+            if (changed || visible) {
+                Handler h = getHandler();
+                if (h != null) {
+                    h.removeCallbacks(mNavHider);
+                }
+            }
+
+            // Set the new desired visibility.
+            setSystemUiVisibility(newVis);
+        }
+    }
+//END_INCLUDE(content)
+
+    Content mContent;
+
+    public ContentBrowserActivity() {
+    }
+
+    @Override
+    public void onCreate(Bundle savedInstanceState) {
+        super.onCreate(savedInstanceState);
+
+        getWindow().requestFeature(Window.FEATURE_ACTION_BAR_OVERLAY);
+
+        setContentView(R.layout.content_browser);
+        mContent = (Content)findViewById(R.id.content);
+
+        ActionBar bar = getActionBar();
+        bar.addTab(bar.newTab().setText("Tab 1").setTabListener(this));
+        bar.addTab(bar.newTab().setText("Tab 2").setTabListener(this));
+        bar.addTab(bar.newTab().setText("Tab 3").setTabListener(this));
+    }
+
+    @Override
+    public boolean onCreateOptionsMenu(Menu menu) {
+        MenuInflater inflater = getMenuInflater();
+        inflater.inflate(R.menu.content_actions, menu);
+        SearchView searchView = (SearchView) menu.findItem(R.id.action_search).getActionView();
+        searchView.setOnQueryTextListener(this);
+
+        // Set file with share history to the provider and set the share intent.
+        MenuItem actionItem = menu.findItem(R.id.menu_item_share_action_provider_action_bar);
+        ShareActionProvider actionProvider = (ShareActionProvider) actionItem.getActionProvider();
+        actionProvider.setShareHistoryFileName(ShareActionProvider.DEFAULT_SHARE_HISTORY_FILE_NAME);
+        // Note that you can set/change the intent any time,
+        // say when the user has selected an image.
+        Intent shareIntent = new Intent(Intent.ACTION_SEND);
+        shareIntent.setType("image/*");
+        Uri uri = Uri.fromFile(getFileStreamPath("shared.png"));
+        shareIntent.putExtra(Intent.EXTRA_STREAM, uri);
+        actionProvider.setShareIntent(shareIntent);
+        return true;
+    }
+
+    @Override
+    public void onAttachedToWindow() {
+        super.onAttachedToWindow();
+    }
+
+    @Override
+    protected void onResume() {
+        super.onResume();
+    }
+
+    /**
+     * This method is declared in the menu.
+     */
+    public void onSort(MenuItem item) {
+    }
+
+    @Override
+    public boolean onOptionsItemSelected(MenuItem item) {
+        switch (item.getItemId()) {
+            case R.id.show_tabs:
+                getActionBar().setNavigationMode(ActionBar.NAVIGATION_MODE_TABS);
+                item.setChecked(true);
+                return true;
+            case R.id.hide_tabs:
+                getActionBar().setNavigationMode(ActionBar.NAVIGATION_MODE_STANDARD);
+                item.setChecked(true);
+                return true;
+            case R.id.stable_layout:
+                item.setChecked(!item.isChecked());
+                mContent.setBaseSystemUiVisibility(item.isChecked()
+                        ? View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN
+                                | View.SYSTEM_UI_FLAG_LAYOUT_STABLE
+                        : View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN);
+                return true;
+        }
+        return false;
+    }
+
+    @Override
+    public boolean onQueryTextChange(String newText) {
+        return true;
+    }
+
+    @Override
+    public boolean onQueryTextSubmit(String query) {
+        Toast.makeText(this, "Searching for: " + query + "...", Toast.LENGTH_SHORT).show();
+        return true;
+    }
+
+    @Override
+    public void onTabSelected(Tab tab, FragmentTransaction ft) {
+    }
+
+    @Override
+    public void onTabUnselected(Tab tab, FragmentTransaction ft) {
+    }
+
+    @Override
+    public void onTabReselected(Tab tab, FragmentTransaction ft) {
+    }
+}
diff --git a/samples/ApiDemos/src/com/example/android/apis/view/OverscanActivity.java b/samples/ApiDemos/src/com/example/android/apis/view/OverscanActivity.java
index 464b601..7b149a0 100644
--- a/samples/ApiDemos/src/com/example/android/apis/view/OverscanActivity.java
+++ b/samples/ApiDemos/src/com/example/android/apis/view/OverscanActivity.java
@@ -16,20 +16,32 @@
 
 package com.example.android.apis.view;
 
+import android.app.ActionBar;
 import android.app.Activity;
+import android.app.FragmentTransaction;
+import android.app.ActionBar.Tab;
 import android.content.Context;
+import android.content.Intent;
+import android.net.Uri;
 import android.os.Bundle;
 import android.util.AttributeSet;
 import android.util.DisplayMetrics;
 import android.view.KeyEvent;
 import android.view.Menu;
+import android.view.MenuInflater;
 import android.view.MenuItem;
 import android.view.View;
 import android.view.View.OnClickListener;
 import android.view.Window;
 import android.view.WindowManager;
+import android.widget.CheckBox;
+import android.widget.CompoundButton;
 import android.widget.ImageView;
+import android.widget.SearchView;
+import android.widget.ShareActionProvider;
 import android.widget.TextView;
+import android.widget.Toast;
+import android.widget.SearchView.OnQueryTextListener;
 
 import com.example.android.apis.R;
 
@@ -38,8 +50,9 @@
  * the system decor, in order to better focus the user's attention or use available screen real
  * estate on the task at hand.
  */
-public class OverscanActivity extends Activity {
-    public static class IV extends ImageView {
+public class OverscanActivity extends Activity
+        implements OnQueryTextListener, ActionBar.TabListener {
+    public static class IV extends ImageView implements View.OnSystemUiVisibilityChangeListener {
         private OverscanActivity mActivity;
         public IV(Context context) {
             super(context);
@@ -48,64 +61,16 @@
             super(context, attrs);
         }
         public void setActivity(OverscanActivity act) {
+            setOnSystemUiVisibilityChangeListener(this);
             mActivity = act;
         }
+        @Override
         public void onSizeChanged(int w, int h, int oldw, int oldh) {
             mActivity.refreshSizes();
         }
-        public void onSystemUiVisibilityChanged(int visibility) {
-            mActivity.getState().onSystemUiVisibilityChanged(visibility);
-        }
-    }
-
-    private interface State {
-        void apply();
-        State next();
-        void onSystemUiVisibilityChanged(int visibility);
-    }
-    private class NormalState implements State {
-        public void apply() {
-            display("Normal");
-            setFullscreen(false);
-            mImage.setSystemUiVisibility(View.SYSTEM_UI_FLAG_VISIBLE);
-        }
-        public State next() {
-            return new FullscreenState();
-        }
-        public void onSystemUiVisibilityChanged(int visibility) {
-        }
-    }
-    private class FullscreenState implements State {
-        public void apply() {
-            display("FULLSCREEN");
-            setFullscreen(true);
-        }
-        public State next() {
-            return new FullscreenLightsOutState();
-        }
-        public void onSystemUiVisibilityChanged(int visibility) {
-        }
-    }
-    private class FullscreenLightsOutState implements State {
-        public void apply() {
-            display("FULLSCREEN + LOW_PROFILE");
-            mImage.setSystemUiVisibility(View.SYSTEM_UI_FLAG_LOW_PROFILE);
-        }
-        public State next() {
-            return new OverscanState();
-        }
-        public void onSystemUiVisibilityChanged(int visibility) {
-        }
-    }
-    private class OverscanState implements State {
-        public void apply() {
-            display("FULLSCREEN + HIDE_NAVIGATION");
-            mImage.setSystemUiVisibility(View.SYSTEM_UI_FLAG_HIDE_NAVIGATION);
-        }
-        public State next() {
-            return new NormalState();
-        }
-        public void onSystemUiVisibilityChanged(int visibility) {
+        @Override
+        public void onSystemUiVisibilityChange(int visibility) {
+            mActivity.updateCheckControls();
         }
     }
 
@@ -131,20 +96,18 @@
                 mImage.getRight(), mImage.getBottom());
     }
     void refreshSizes() {
-        mText2.setText(getDisplaySize() + " " + getViewSize());
-    }
-    private void display(String text) {
-        mText1.setText(text);
-        refreshSizes();
-    }
-    State getState() {
-        return mState;
+        mMetricsText.setText(getDisplaySize() + " " + getViewSize());
     }
 
     static int TOAST_LENGTH = 500;
     IV mImage;
-    TextView mText1, mText2;
-    State mState;
+    CheckBox[] mCheckControls = new CheckBox[6];
+    int[] mCheckFlags = new int[] { View.SYSTEM_UI_FLAG_LOW_PROFILE,
+            View.SYSTEM_UI_FLAG_FULLSCREEN, View.SYSTEM_UI_FLAG_HIDE_NAVIGATION,
+            View.SYSTEM_UI_FLAG_LAYOUT_STABLE, View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN,
+            View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION
+    };
+    TextView mMetricsText;
 
     public OverscanActivity() {
     }
@@ -153,23 +116,54 @@
     public void onCreate(Bundle savedInstanceState) {
         super.onCreate(savedInstanceState);
 
-        // we need to ask for LAYOUT_IN_SCREEN before the window decor appears
-        Window win = getWindow();
-        WindowManager.LayoutParams winParams = win.getAttributes();
-        winParams.flags |= WindowManager.LayoutParams.FLAG_LAYOUT_IN_SCREEN;
-        win.setAttributes(winParams);
+        getWindow().requestFeature(Window.FEATURE_ACTION_BAR_OVERLAY);
 
         setContentView(R.layout.overscan);
         mImage = (IV) findViewById(R.id.image);
         mImage.setActivity(this);
-        mText1 = (TextView) findViewById(R.id.text1);
-        mText2 = (TextView) findViewById(R.id.text2);
+
+        CompoundButton.OnCheckedChangeListener checkChangeListener
+                = new CompoundButton.OnCheckedChangeListener() {
+            @Override public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
+                updateSystemUi();
+            }
+        };
+        mCheckControls[0] = (CheckBox) findViewById(R.id.modeLowProfile);
+        mCheckControls[1] = (CheckBox) findViewById(R.id.modeFullscreen);
+        mCheckControls[2] = (CheckBox) findViewById(R.id.modeHideNavigation);
+        mCheckControls[3] = (CheckBox) findViewById(R.id.layoutStable);
+        mCheckControls[4] = (CheckBox) findViewById(R.id.layoutFullscreen);
+        mCheckControls[5] = (CheckBox) findViewById(R.id.layoutHideNavigation);
+        for (int i=0; i<mCheckControls.length; i++) {
+            mCheckControls[i].setOnCheckedChangeListener(checkChangeListener);
+        }
+        mMetricsText = (TextView) findViewById(R.id.metricsText);
+    }
+
+    @Override
+    public boolean onCreateOptionsMenu(Menu menu) {
+        MenuInflater inflater = getMenuInflater();
+        inflater.inflate(R.menu.content_actions, menu);
+        SearchView searchView = (SearchView) menu.findItem(R.id.action_search).getActionView();
+        searchView.setOnQueryTextListener(this);
+
+        // Set file with share history to the provider and set the share intent.
+        MenuItem actionItem = menu.findItem(R.id.menu_item_share_action_provider_action_bar);
+        ShareActionProvider actionProvider = (ShareActionProvider) actionItem.getActionProvider();
+        actionProvider.setShareHistoryFileName(ShareActionProvider.DEFAULT_SHARE_HISTORY_FILE_NAME);
+        // Note that you can set/change the intent any time,
+        // say when the user has selected an image.
+        Intent shareIntent = new Intent(Intent.ACTION_SEND);
+        shareIntent.setType("image/*");
+        Uri uri = Uri.fromFile(getFileStreamPath("shared.png"));
+        shareIntent.putExtra(Intent.EXTRA_STREAM, uri);
+        actionProvider.setShareIntent(shareIntent);
+        return true;
     }
 
     @Override
     public void onAttachedToWindow() {
-        mState = new NormalState();
-        mState.apply();
+        updateCheckControls();
     }
 
     @Override
@@ -177,8 +171,61 @@
         super.onResume();
     }
 
-    public void clicked(View v) {
-        mState = mState.next();
-        mState.apply();
+    public void onSort(MenuItem item) {
+    }
+
+    @Override
+    public boolean onQueryTextChange(String newText) {
+        return true;
+    }
+
+    @Override
+    public boolean onQueryTextSubmit(String query) {
+        Toast.makeText(this, "Searching for: " + query + "...", Toast.LENGTH_SHORT).show();
+        return true;
+    }
+
+    @Override
+    public boolean onOptionsItemSelected(MenuItem item) {
+        switch (item.getItemId()) {
+            case R.id.show_tabs:
+                getActionBar().setNavigationMode(ActionBar.NAVIGATION_MODE_TABS);
+                item.setChecked(true);
+                return true;
+            case R.id.hide_tabs:
+                getActionBar().setNavigationMode(ActionBar.NAVIGATION_MODE_STANDARD);
+                item.setChecked(true);
+                return true;
+        }
+        return false;
+    }
+
+    @Override
+    public void onTabSelected(Tab tab, FragmentTransaction ft) {
+    }
+
+    @Override
+    public void onTabUnselected(Tab tab, FragmentTransaction ft) {
+    }
+
+    @Override
+    public void onTabReselected(Tab tab, FragmentTransaction ft) {
+    }
+
+    public void updateCheckControls() {
+        int visibility = mImage.getSystemUiVisibility();
+        for (int i=0; i<mCheckControls.length; i++) {
+            mCheckControls[i].setChecked((visibility&mCheckFlags[i]) != 0);
+        }
+    }
+
+    public void updateSystemUi() {
+        int visibility = 0;
+        for (int i=0; i<mCheckControls.length; i++) {
+            if (mCheckControls[i].isChecked()) {
+                visibility |= mCheckFlags[i];
+            }
+        }
+        mImage.setSystemUiVisibility(visibility);
     }
 }
diff --git a/samples/ApiDemos/src/com/example/android/apis/view/VideoPlayerActivity.java b/samples/ApiDemos/src/com/example/android/apis/view/VideoPlayerActivity.java
new file mode 100644
index 0000000..0263ca6
--- /dev/null
+++ b/samples/ApiDemos/src/com/example/android/apis/view/VideoPlayerActivity.java
@@ -0,0 +1,236 @@
+/*
+ * Copyright (C) 2011 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.example.android.apis.view;
+
+import android.app.ActionBar;
+import android.app.ActionBar.Tab;
+import android.app.Activity;
+import android.app.FragmentTransaction;
+import android.content.Context;
+import android.content.Intent;
+import android.net.Uri;
+import android.os.Bundle;
+import android.os.Handler;
+import android.util.AttributeSet;
+import android.view.Menu;
+import android.view.MenuInflater;
+import android.view.MenuItem;
+import android.view.View;
+import android.view.ViewGroup;
+import android.view.Window;
+import android.widget.ImageView;
+import android.widget.ScrollView;
+import android.widget.SearchView;
+import android.widget.ShareActionProvider;
+import android.widget.TextView;
+import android.widget.Toast;
+import android.widget.SearchView.OnQueryTextListener;
+
+import com.example.android.apis.R;
+
+/**
+ * This activity demonstrates how to use system UI flags to implement
+ * a video player style of UI (where the navigation bar should be hidden
+ * when the user isn't interacting with the screen to achieve full screen
+ * video playback).
+ */
+public class VideoPlayerActivity extends Activity
+        implements OnQueryTextListener, ActionBar.TabListener {
+
+    /**
+     * Implementation of a view for displaying full-screen video playback,
+     * using system UI flags to transition in and out of modes where the entire
+     * screen can be filled with content (at the expense of no user interaction).
+     */
+//BEGIN_INCLUDE(content)
+    public static class Content extends ImageView implements
+            View.OnSystemUiVisibilityChangeListener, View.OnClickListener {
+        TextView mText;
+        boolean mNavVisible;
+        int mBaseSystemUiVisibility = SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN
+                | SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION | SYSTEM_UI_FLAG_LAYOUT_STABLE;
+        int mLastSystemUiVis;
+
+        Runnable mNavHider = new Runnable() {
+            @Override public void run() {
+                setNavVisibility(false);
+            }
+        };
+
+        public Content(Context context, AttributeSet attrs) {
+            super(context, attrs);
+            setOnSystemUiVisibilityChangeListener(this);
+            setOnClickListener(this);
+            setNavVisibility(true);
+        }
+
+        @Override public void onSystemUiVisibilityChange(int visibility) {
+            // Detect when we go out of low-profile mode, to also go out
+            // of full screen.  We only do this when the low profile mode
+            // is changing from its last state, and turning off.
+            int diff = mLastSystemUiVis ^ visibility;
+            mLastSystemUiVis = visibility;
+            if ((diff&SYSTEM_UI_FLAG_LOW_PROFILE) != 0
+                    && (visibility&SYSTEM_UI_FLAG_LOW_PROFILE) == 0) {
+                setNavVisibility(true);
+            }
+        }
+
+        @Override protected void onWindowVisibilityChanged(int visibility) {
+            super.onWindowVisibilityChanged(visibility);
+
+            // When we become visible, we show our navigation elements briefly
+            // before hiding them.
+            setNavVisibility(true);
+        }
+
+        @Override public void onClick(View v) {
+            // When the user clicks, we make the navigation visible.  In a real
+            // implementation, this would probably toggle between pause/play.
+            setNavVisibility(true);
+        }
+
+        void setBaseSystemUiVisibility(int visibility) {
+            mBaseSystemUiVisibility = visibility;
+        }
+
+        void setNavVisibility(boolean visible) {
+            int newVis = mBaseSystemUiVisibility;
+            if (!visible) {
+                newVis |= SYSTEM_UI_FLAG_LOW_PROFILE | SYSTEM_UI_FLAG_FULLSCREEN
+                        | SYSTEM_UI_FLAG_HIDE_NAVIGATION;
+            }
+
+            // If we are now visible, schedule a timer for us to go invisible.
+            if (visible) {
+                Handler h = getHandler();
+                if (h != null) {
+                    h.removeCallbacks(mNavHider);
+                    h.postDelayed(mNavHider, 3000);
+                }
+            }
+
+            // Set the new desired visibility.
+            setSystemUiVisibility(newVis);
+        }
+    }
+//END_INCLUDE(content)
+
+    Content mContent;
+
+    public VideoPlayerActivity() {
+    }
+
+    @Override
+    public void onCreate(Bundle savedInstanceState) {
+        super.onCreate(savedInstanceState);
+
+        getWindow().requestFeature(Window.FEATURE_ACTION_BAR_OVERLAY);
+
+        setContentView(R.layout.video_player);
+        mContent = (Content)findViewById(R.id.content);
+
+        ActionBar bar = getActionBar();
+        bar.addTab(bar.newTab().setText("Tab 1").setTabListener(this));
+        bar.addTab(bar.newTab().setText("Tab 2").setTabListener(this));
+        bar.addTab(bar.newTab().setText("Tab 3").setTabListener(this));
+    }
+
+    @Override
+    public boolean onCreateOptionsMenu(Menu menu) {
+        MenuInflater inflater = getMenuInflater();
+        inflater.inflate(R.menu.content_actions, menu);
+        SearchView searchView = (SearchView) menu.findItem(R.id.action_search).getActionView();
+        searchView.setOnQueryTextListener(this);
+
+        // Set file with share history to the provider and set the share intent.
+        MenuItem actionItem = menu.findItem(R.id.menu_item_share_action_provider_action_bar);
+        ShareActionProvider actionProvider = (ShareActionProvider) actionItem.getActionProvider();
+        actionProvider.setShareHistoryFileName(ShareActionProvider.DEFAULT_SHARE_HISTORY_FILE_NAME);
+        // Note that you can set/change the intent any time,
+        // say when the user has selected an image.
+        Intent shareIntent = new Intent(Intent.ACTION_SEND);
+        shareIntent.setType("image/*");
+        Uri uri = Uri.fromFile(getFileStreamPath("shared.png"));
+        shareIntent.putExtra(Intent.EXTRA_STREAM, uri);
+        actionProvider.setShareIntent(shareIntent);
+        return true;
+    }
+
+    @Override
+    public void onAttachedToWindow() {
+        super.onAttachedToWindow();
+    }
+
+    @Override
+    protected void onResume() {
+        super.onResume();
+    }
+
+    /**
+     * This method is declared in the menu.
+     */
+    public void onSort(MenuItem item) {
+    }
+
+    @Override
+    public boolean onOptionsItemSelected(MenuItem item) {
+        switch (item.getItemId()) {
+            case R.id.show_tabs:
+                getActionBar().setNavigationMode(ActionBar.NAVIGATION_MODE_TABS);
+                item.setChecked(true);
+                return true;
+            case R.id.hide_tabs:
+                getActionBar().setNavigationMode(ActionBar.NAVIGATION_MODE_STANDARD);
+                item.setChecked(true);
+                return true;
+            case R.id.stable_layout:
+                item.setChecked(!item.isChecked());
+                mContent.setBaseSystemUiVisibility(item.isChecked()
+                        ? View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN
+                                | View.SYSTEM_UI_FLAG_LAYOUT_STABLE
+                                | View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION
+                        : View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN
+                                | View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION);
+                return true;
+        }
+        return false;
+    }
+
+    @Override
+    public boolean onQueryTextChange(String newText) {
+        return true;
+    }
+
+    @Override
+    public boolean onQueryTextSubmit(String query) {
+        Toast.makeText(this, "Searching for: " + query + "...", Toast.LENGTH_SHORT).show();
+        return true;
+    }
+
+    @Override
+    public void onTabSelected(Tab tab, FragmentTransaction ft) {
+    }
+
+    @Override
+    public void onTabUnselected(Tab tab, FragmentTransaction ft) {
+    }
+
+    @Override
+    public void onTabReselected(Tab tab, FragmentTransaction ft) {
+    }
+}
diff --git a/samples/ApiDemos/src/com/example/android/apis/view/WebView1.java b/samples/ApiDemos/src/com/example/android/apis/view/WebView1.java
index d6a4efe..1426b65 100644
--- a/samples/ApiDemos/src/com/example/android/apis/view/WebView1.java
+++ b/samples/ApiDemos/src/com/example/android/apis/view/WebView1.java
@@ -24,7 +24,7 @@
 
 
 /**
- * Sample creating 10 webviews.
+ * Sample creating 1 webviews.
  */
 public class WebView1 extends Activity {
     
@@ -40,32 +40,5 @@
         
         wv = (WebView) findViewById(R.id.wv1);
         wv.loadData("<a href='x'>Hello World! - 1</a>", mimeType, null);
-        
-        wv = (WebView) findViewById(R.id.wv2);
-        wv.loadData("<a href='x'>Hello World! - 2</a>", mimeType, null);
-        
-        wv = (WebView) findViewById(R.id.wv3);
-        wv.loadData("<a href='x'>Hello World! - 3</a>", mimeType, null);
-        
-        wv = (WebView) findViewById(R.id.wv4);
-        wv.loadData("<a href='x'>Hello World! - 4</a>", mimeType, null);
-        
-        wv = (WebView) findViewById(R.id.wv5);
-        wv.loadData("<a href='x'>Hello World! - 5</a>", mimeType, null);
-        
-        wv = (WebView) findViewById(R.id.wv6);
-        wv.loadData("<a href='x'>Hello World! - 6</a>", mimeType, null);
-        
-        wv = (WebView) findViewById(R.id.wv7);
-        wv.loadData("<a href='x'>Hello World! - 7</a>", mimeType, null);
-        
-        wv = (WebView) findViewById(R.id.wv8);
-        wv.loadData("<a href='x'>Hello World! - 8</a>", mimeType, null);
-        
-        wv = (WebView) findViewById(R.id.wv9);
-        wv.loadData("<a href='x'>Hello World! - 9</a>", mimeType, null);
-        
-        wv = (WebView) findViewById(R.id.wv10);
-        wv.loadData("<a href='x'>Hello World! - 10</a>", mimeType, null);
     }
 }
diff --git a/samples/BrowserPlugin/jni/RenderingThread.cpp b/samples/BrowserPlugin/jni/RenderingThread.cpp
index 1307e90..5e27f28 100644
--- a/samples/BrowserPlugin/jni/RenderingThread.cpp
+++ b/samples/BrowserPlugin/jni/RenderingThread.cpp
@@ -26,6 +26,8 @@
 
 #include "ANPNativeWindow_npapi.h"
 
+#include <android/native_window.h>
+
 extern ANPLogInterfaceV0           gLogI;
 extern ANPNativeWindowInterfaceV0  gNativeWindowI;
 
diff --git a/samples/GlobalTime/Android.mk b/samples/GlobalTime/Android.mk
deleted file mode 100644
index a390faa..0000000
--- a/samples/GlobalTime/Android.mk
+++ /dev/null
@@ -1,13 +0,0 @@
-LOCAL_PATH:= $(call my-dir)
-include $(CLEAR_VARS)
-
-LOCAL_MODULE_TAGS := optional
-
-LOCAL_SRC_FILES := $(call all-subdir-java-files)
-
-LOCAL_PACKAGE_NAME := GlobalTime
-
-# TODO: build fails with this set
-# LOCAL_SDK_VERSION := current
-
-include $(BUILD_PACKAGE)
diff --git a/samples/GlobalTime/AndroidManifest.xml b/samples/GlobalTime/AndroidManifest.xml
deleted file mode 100644
index 7aee91b..0000000
--- a/samples/GlobalTime/AndroidManifest.xml
+++ /dev/null
@@ -1,13 +0,0 @@
-<manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.android.globaltime">
-    <application android:icon="@drawable/app_global_time"
-            android:label="Global Time">
-        <activity android:name="GlobalTime"
-                android:theme="@style/Theme">
-            <intent-filter>
-                <action android:name="android.intent.action.MAIN" />
-                <category android:name="android.intent.category.DEFAULT" />
-                <category android:name="android.intent.category.LAUNCHER" />                                            
-            </intent-filter>
-        </activity>
-    </application>
-</manifest>
diff --git a/samples/GlobalTime/MODULE_LICENSE_APACHE2 b/samples/GlobalTime/MODULE_LICENSE_APACHE2
deleted file mode 100644
index e69de29..0000000
--- a/samples/GlobalTime/MODULE_LICENSE_APACHE2
+++ /dev/null
diff --git a/samples/GlobalTime/NOTICE b/samples/GlobalTime/NOTICE
deleted file mode 100644
index c5b1efa..0000000
--- a/samples/GlobalTime/NOTICE
+++ /dev/null
@@ -1,190 +0,0 @@
-
-   Copyright (c) 2005-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.
-
-   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.
-
-
-                                 Apache License
-                           Version 2.0, January 2004
-                        http://www.apache.org/licenses/
-
-   TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
-
-   1. Definitions.
-
-      "License" shall mean the terms and conditions for use, reproduction,
-      and distribution as defined by Sections 1 through 9 of this document.
-
-      "Licensor" shall mean the copyright owner or entity authorized by
-      the copyright owner that is granting the License.
-
-      "Legal Entity" shall mean the union of the acting entity and all
-      other entities that control, are controlled by, or are under common
-      control with that entity. For the purposes of this definition,
-      "control" means (i) the power, direct or indirect, to cause the
-      direction or management of such entity, whether by contract or
-      otherwise, or (ii) ownership of fifty percent (50%) or more of the
-      outstanding shares, or (iii) beneficial ownership of such entity.
-
-      "You" (or "Your") shall mean an individual or Legal Entity
-      exercising permissions granted by this License.
-
-      "Source" form shall mean the preferred form for making modifications,
-      including but not limited to software source code, documentation
-      source, and configuration files.
-
-      "Object" form shall mean any form resulting from mechanical
-      transformation or translation of a Source form, including but
-      not limited to compiled object code, generated documentation,
-      and conversions to other media types.
-
-      "Work" shall mean the work of authorship, whether in Source or
-      Object form, made available under the License, as indicated by a
-      copyright notice that is included in or attached to the work
-      (an example is provided in the Appendix below).
-
-      "Derivative Works" shall mean any work, whether in Source or Object
-      form, that is based on (or derived from) the Work and for which the
-      editorial revisions, annotations, elaborations, or other modifications
-      represent, as a whole, an original work of authorship. For the purposes
-      of this License, Derivative Works shall not include works that remain
-      separable from, or merely link (or bind by name) to the interfaces of,
-      the Work and Derivative Works thereof.
-
-      "Contribution" shall mean any work of authorship, including
-      the original version of the Work and any modifications or additions
-      to that Work or Derivative Works thereof, that is intentionally
-      submitted to Licensor for inclusion in the Work by the copyright owner
-      or by an individual or Legal Entity authorized to submit on behalf of
-      the copyright owner. For the purposes of this definition, "submitted"
-      means any form of electronic, verbal, or written communication sent
-      to the Licensor or its representatives, including but not limited to
-      communication on electronic mailing lists, source code control systems,
-      and issue tracking systems that are managed by, or on behalf of, the
-      Licensor for the purpose of discussing and improving the Work, but
-      excluding communication that is conspicuously marked or otherwise
-      designated in writing by the copyright owner as "Not a Contribution."
-
-      "Contributor" shall mean Licensor and any individual or Legal Entity
-      on behalf of whom a Contribution has been received by Licensor and
-      subsequently incorporated within the Work.
-
-   2. Grant of Copyright License. Subject to the terms and conditions of
-      this License, each Contributor hereby grants to You a perpetual,
-      worldwide, non-exclusive, no-charge, royalty-free, irrevocable
-      copyright license to reproduce, prepare Derivative Works of,
-      publicly display, publicly perform, sublicense, and distribute the
-      Work and such Derivative Works in Source or Object form.
-
-   3. Grant of Patent License. Subject to the terms and conditions of
-      this License, each Contributor hereby grants to You a perpetual,
-      worldwide, non-exclusive, no-charge, royalty-free, irrevocable
-      (except as stated in this section) patent license to make, have made,
-      use, offer to sell, sell, import, and otherwise transfer the Work,
-      where such license applies only to those patent claims licensable
-      by such Contributor that are necessarily infringed by their
-      Contribution(s) alone or by combination of their Contribution(s)
-      with the Work to which such Contribution(s) was submitted. If You
-      institute patent litigation against any entity (including a
-      cross-claim or counterclaim in a lawsuit) alleging that the Work
-      or a Contribution incorporated within the Work constitutes direct
-      or contributory patent infringement, then any patent licenses
-      granted to You under this License for that Work shall terminate
-      as of the date such litigation is filed.
-
-   4. Redistribution. You may reproduce and distribute copies of the
-      Work or Derivative Works thereof in any medium, with or without
-      modifications, and in Source or Object form, provided that You
-      meet the following conditions:
-
-      (a) You must give any other recipients of the Work or
-          Derivative Works a copy of this License; and
-
-      (b) You must cause any modified files to carry prominent notices
-          stating that You changed the files; and
-
-      (c) You must retain, in the Source form of any Derivative Works
-          that You distribute, all copyright, patent, trademark, and
-          attribution notices from the Source form of the Work,
-          excluding those notices that do not pertain to any part of
-          the Derivative Works; and
-
-      (d) If the Work includes a "NOTICE" text file as part of its
-          distribution, then any Derivative Works that You distribute must
-          include a readable copy of the attribution notices contained
-          within such NOTICE file, excluding those notices that do not
-          pertain to any part of the Derivative Works, in at least one
-          of the following places: within a NOTICE text file distributed
-          as part of the Derivative Works; within the Source form or
-          documentation, if provided along with the Derivative Works; or,
-          within a display generated by the Derivative Works, if and
-          wherever such third-party notices normally appear. The contents
-          of the NOTICE file are for informational purposes only and
-          do not modify the License. You may add Your own attribution
-          notices within Derivative Works that You distribute, alongside
-          or as an addendum to the NOTICE text from the Work, provided
-          that such additional attribution notices cannot be construed
-          as modifying the License.
-
-      You may add Your own copyright statement to Your modifications and
-      may provide additional or different license terms and conditions
-      for use, reproduction, or distribution of Your modifications, or
-      for any such Derivative Works as a whole, provided Your use,
-      reproduction, and distribution of the Work otherwise complies with
-      the conditions stated in this License.
-
-   5. Submission of Contributions. Unless You explicitly state otherwise,
-      any Contribution intentionally submitted for inclusion in the Work
-      by You to the Licensor shall be under the terms and conditions of
-      this License, without any additional terms or conditions.
-      Notwithstanding the above, nothing herein shall supersede or modify
-      the terms of any separate license agreement you may have executed
-      with Licensor regarding such Contributions.
-
-   6. Trademarks. This License does not grant permission to use the trade
-      names, trademarks, service marks, or product names of the Licensor,
-      except as required for reasonable and customary use in describing the
-      origin of the Work and reproducing the content of the NOTICE file.
-
-   7. Disclaimer of Warranty. Unless required by applicable law or
-      agreed to in writing, Licensor provides the Work (and each
-      Contributor provides its Contributions) on an "AS IS" BASIS,
-      WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
-      implied, including, without limitation, any warranties or conditions
-      of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
-      PARTICULAR PURPOSE. You are solely responsible for determining the
-      appropriateness of using or redistributing the Work and assume any
-      risks associated with Your exercise of permissions under this License.
-
-   8. Limitation of Liability. In no event and under no legal theory,
-      whether in tort (including negligence), contract, or otherwise,
-      unless required by applicable law (such as deliberate and grossly
-      negligent acts) or agreed to in writing, shall any Contributor be
-      liable to You for damages, including any direct, indirect, special,
-      incidental, or consequential damages of any character arising as a
-      result of this License or out of the use or inability to use the
-      Work (including but not limited to damages for loss of goodwill,
-      work stoppage, computer failure or malfunction, or any and all
-      other commercial damages or losses), even if such Contributor
-      has been advised of the possibility of such damages.
-
-   9. Accepting Warranty or Additional Liability. While redistributing
-      the Work or Derivative Works thereof, You may choose to offer,
-      and charge a fee for, acceptance of support, warranty, indemnity,
-      or other liability obligations and/or rights consistent with this
-      License. However, in accepting such obligations, You may act only
-      on Your own behalf and on Your sole responsibility, not on behalf
-      of any other Contributor, and only if You agree to indemnify,
-      defend, and hold each Contributor harmless for any liability
-      incurred by, or claims asserted against, such Contributor by reason
-      of your accepting any such warranty or additional liability.
-
-   END OF TERMS AND CONDITIONS
-
diff --git a/samples/GlobalTime/assets/cities_en.dat b/samples/GlobalTime/assets/cities_en.dat
deleted file mode 100644
index c982ef4..0000000
--- a/samples/GlobalTime/assets/cities_en.dat
+++ /dev/null
Binary files differ
diff --git a/samples/GlobalTime/assets/earth.raw b/samples/GlobalTime/assets/earth.raw
deleted file mode 100644
index f884e75..0000000
--- a/samples/GlobalTime/assets/earth.raw
+++ /dev/null
Binary files differ
diff --git a/samples/GlobalTime/assets/lights.dat b/samples/GlobalTime/assets/lights.dat
deleted file mode 100644
index 14d4f36..0000000
--- a/samples/GlobalTime/assets/lights.dat
+++ /dev/null
Binary files differ
diff --git a/samples/GlobalTime/assets/tz512.raw b/samples/GlobalTime/assets/tz512.raw
deleted file mode 100644
index 3ce1d5c..0000000
--- a/samples/GlobalTime/assets/tz512.raw
+++ /dev/null
Binary files differ
diff --git a/samples/GlobalTime/assets/world.gles b/samples/GlobalTime/assets/world.gles
deleted file mode 100644
index 815db1e..0000000
--- a/samples/GlobalTime/assets/world.gles
+++ /dev/null
Binary files differ
diff --git a/samples/GlobalTime/res/drawable-hdpi/app_global_time.png b/samples/GlobalTime/res/drawable-hdpi/app_global_time.png
deleted file mode 100755
index 46c658e..0000000
--- a/samples/GlobalTime/res/drawable-hdpi/app_global_time.png
+++ /dev/null
Binary files differ
diff --git a/samples/GlobalTime/res/drawable-mdpi/app_global_time.png b/samples/GlobalTime/res/drawable-mdpi/app_global_time.png
deleted file mode 100644
index 914977d..0000000
--- a/samples/GlobalTime/res/drawable-mdpi/app_global_time.png
+++ /dev/null
Binary files differ
diff --git a/samples/GlobalTime/res/layout/global_time.xml b/samples/GlobalTime/res/layout/global_time.xml
deleted file mode 100644
index 6bb3c79..0000000
--- a/samples/GlobalTime/res/layout/global_time.xml
+++ /dev/null
@@ -1,22 +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.
--->
-
-<EditText xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/text"
-    android:layout_width="match_parent" android:layout_height="match_parent"
-    android:textSize="18sp"
-    android:text="@string/global_time_text_text" />
-
-
diff --git a/samples/GlobalTime/res/values/strings.xml b/samples/GlobalTime/res/values/strings.xml
deleted file mode 100644
index d35c059..0000000
--- a/samples/GlobalTime/res/values/strings.xml
+++ /dev/null
@@ -1,24 +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.
-*/
--->
-
-<resources>
-
-    <string name="global_time_text_text">Global Time</string>
-
-</resources>
diff --git a/samples/GlobalTime/res/values/styles.xml b/samples/GlobalTime/res/values/styles.xml
deleted file mode 100644
index 6051f0f..0000000
--- a/samples/GlobalTime/res/values/styles.xml
+++ /dev/null
@@ -1,26 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!--
-/* //device/apps/Calendar/assets/res/any/styles.xml
-**
-** Copyright 2006, 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.
-*/
--->
-<resources>
-    <style name="Theme" parent="android:Theme.Black">
-        <item name="android:windowNoTitle">true</item>
-        <item name="android:windowBackground">@null</item>
-        <!-- <item name="android:windowFrame">@null</item> -->
-    </style>
-</resources>
diff --git a/samples/GlobalTime/src/com/android/globaltime/Annulus.java b/samples/GlobalTime/src/com/android/globaltime/Annulus.java
deleted file mode 100644
index b811d88..0000000
--- a/samples/GlobalTime/src/com/android/globaltime/Annulus.java
+++ /dev/null
@@ -1,101 +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.globaltime;
-
-import javax.microedition.khronos.opengles.GL10;
-
-/**
- * A class that draws a ring with a given center and inner and outer radii.
- * The inner and outer rings each have a color and the remaining pixels are
- * colored by interpolation.  GlobalTime uses this class to simulate an
- * "atmosphere" around the earth.
- */
-public class Annulus extends Shape {
-
-    /**
-     * Constructs an annulus.
-     * 
-     * @param centerX the X coordinate of the center point
-     * @param centerY the Y coordinate of the center point
-     * @param Z the fixed Z for the entire ring
-     * @param innerRadius the inner radius
-     * @param outerRadius the outer radius
-     * @param rInner the red channel of the color of the inner ring
-     * @param gInner the green channel of the color of the inner ring
-     * @param bInner the blue channel of the color of the inner ring
-     * @param aInner the alpha channel of the color of the inner ring
-     * @param rOuter the red channel of the color of the outer ring
-     * @param gOuter the green channel of the color of the outer ring
-     * @param bOuter the blue channel of the color of the outer ring
-     * @param aOuter the alpha channel of the color of the outer ring
-     * @param sectors the number of sectors used to approximate curvature
-     */
-    public Annulus(float centerX, float centerY, float Z,
-        float innerRadius, float outerRadius,
-        float rInner, float gInner, float bInner, float aInner,
-        float rOuter, float gOuter, float bOuter, float aOuter,
-        int sectors) {
-        super(GL10.GL_TRIANGLES, GL10.GL_UNSIGNED_SHORT,
-              false, false, true);
-
-        int radii = sectors + 1;
-
-        int[] vertices = new int[2 * 3 * radii];
-        int[] colors = new int[2 * 4 * radii];
-        short[] indices = new short[2 * 3 * radii];
-
-        int vidx = 0;
-        int cidx = 0;
-        int iidx = 0;
-
-        for (int i = 0; i < radii; i++) {
-            float theta = (i * TWO_PI) / (radii - 1);
-            float cosTheta = (float) Math.cos(theta);
-            float sinTheta = (float) Math.sin(theta);
-
-            vertices[vidx++] = toFixed(centerX + innerRadius * cosTheta);
-            vertices[vidx++] = toFixed(centerY + innerRadius * sinTheta);
-            vertices[vidx++] = toFixed(Z);
-
-            vertices[vidx++] = toFixed(centerX + outerRadius * cosTheta);
-            vertices[vidx++] = toFixed(centerY + outerRadius * sinTheta);
-            vertices[vidx++] = toFixed(Z);
-        
-            colors[cidx++] = toFixed(rInner);
-            colors[cidx++] = toFixed(gInner);
-            colors[cidx++] = toFixed(bInner);
-            colors[cidx++] = toFixed(aInner);
-
-            colors[cidx++] = toFixed(rOuter);
-            colors[cidx++] = toFixed(gOuter);
-            colors[cidx++] = toFixed(bOuter);
-            colors[cidx++] = toFixed(aOuter);
-        }
-
-        for (int i = 0; i < sectors; i++) {
-            indices[iidx++] = (short) (2 * i);
-            indices[iidx++] = (short) (2 * i + 1);
-            indices[iidx++] = (short) (2 * i + 2);
-
-            indices[iidx++] = (short) (2 * i + 1);
-            indices[iidx++] = (short) (2 * i + 3);
-            indices[iidx++] = (short) (2 * i + 2);
-        }
-        
-        allocateBuffers(vertices, null, null, colors, indices);
-    }
-}
diff --git a/samples/GlobalTime/src/com/android/globaltime/City.java b/samples/GlobalTime/src/com/android/globaltime/City.java
deleted file mode 100644
index 0b4cb84..0000000
--- a/samples/GlobalTime/src/com/android/globaltime/City.java
+++ /dev/null
@@ -1,241 +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.globaltime;
-
-import java.io.DataInputStream;
-import java.io.IOException;
-import java.io.InputStream;
-import java.util.Arrays;
-import java.util.Comparator;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.Map;
-import java.util.TimeZone;
-
-/**
- * A class representing a city, with an associated position, time zone name,
- * and raw offset from UTC.
- */
-public  class City implements Comparable<City> {
-
-    private static Map<String,City> cities = new HashMap<String,City>();
-    private static City[] citiesByRawOffset;
-
-    private String name;
-    private String timeZoneID;
-    private TimeZone timeZone = null;
-    private int rawOffset;
-    private float latitude, longitude;
-    private float x, y, z;
-    
-    /**
-     * Loads the city database.  The cities must be stored in order by raw
-     * offset from UTC.
-     */
-    public static void loadCities(InputStream is) throws IOException {
-        DataInputStream dis = new DataInputStream(is);
-        int numCities = dis.readInt();
-        citiesByRawOffset = new City[numCities];
-
-        byte[] buf = new byte[24];
-        for (int i = 0; i < numCities; i++) {
-            String name = dis.readUTF();
-            String tzid = dis.readUTF();
-            dis.read(buf);
-  
-//          The code below is a faster version of:            
-//          int rawOffset = dis.readInt();
-//          float latitude = dis.readFloat();
-//          float longitude = dis.readFloat();
-//          float cx = dis.readFloat();
-//          float cy = dis.readFloat();
-//          float cz = dis.readFloat();
-
-            int rawOffset =
-                       (buf[ 0] << 24) |       ((buf[ 1] & 0xff) << 16) |
-                      ((buf[ 2] & 0xff) << 8) | (buf[ 3] & 0xff);
-            int ilat = (buf[ 4] << 24) |       ((buf[ 5] & 0xff) << 16) |
-                      ((buf[ 6] & 0xff) << 8) | (buf[ 7] & 0xff);
-            int ilon = (buf[ 8] << 24) |       ((buf[ 9] & 0xff) << 16) |
-                      ((buf[10] & 0xff) << 8) | (buf[11] & 0xff);
-            int icx =  (buf[12] << 24) |       ((buf[13] & 0xff) << 16) |
-                      ((buf[14] & 0xff) << 8) | (buf[15] & 0xff);
-            int icy =  (buf[16] << 24) |       ((buf[17] & 0xff) << 16) |
-                      ((buf[18] & 0xff) << 8) | (buf[19] & 0xff);
-            int icz =  (buf[20] << 24) |       ((buf[21] & 0xff) << 16) |
-                      ((buf[22] & 0xff) << 8) | (buf[23] & 0xff);
-            float latitude = Float.intBitsToFloat(ilat);
-            float longitude = Float.intBitsToFloat(ilon);
-            float cx = Float.intBitsToFloat(icx);
-            float cy = Float.intBitsToFloat(icy);
-            float cz = Float.intBitsToFloat(icz);
-
-            City city = new City(name, tzid, rawOffset,
-                                 latitude, longitude, cx, cy, cz);
-
-            cities.put(name, city);
-            citiesByRawOffset[i] = city;
-        }
-    }
-    
-    /**
-     * Returns the cities, ordered by name.
-     */
-    public static City[] getCitiesByName() {
-        City[] ocities = new City[cities.size()];
-        Iterator<City> iter = cities.values().iterator();
-        int idx = 0;
-        while (iter.hasNext()) {
-            ocities[idx++] = iter.next();
-        }
-        Arrays.sort(ocities);
-        return ocities;
-    }
-    
-    /**
-     * Returns the cities, ordered by offset, accounting for summer/daylight
-     * savings time.  This requires reading the entire time zone database
-     * behind the scenes.
-     */
-    public static City[] getCitiesByOffset() {
-        City[] ocities = new City[cities.size()];
-        Iterator<City> iter = cities.values().iterator();
-        int idx = 0;
-        while (iter.hasNext()) {
-            ocities[idx++] = iter.next();
-        }
-        Arrays.sort(ocities, new Comparator() {
-                public int compare(Object o1, Object o2) {
-                    long now = System.currentTimeMillis();
-                    City c1 = (City)o1;
-                    City c2 = (City)o2;
-                    TimeZone tz1 = c1.getTimeZone();
-                    TimeZone tz2 = c2.getTimeZone();
-                    int off1 = tz1.getOffset(now);
-                    int off2 = tz2.getOffset(now);
-                    if (off1 == off2) {
-                        float dlat = c2.getLatitude() - c1.getLatitude();
-                        if (dlat < 0.0f) return -1;
-                        if (dlat > 0.0f) return 1;
-                        return 0;
-                    }
-                    return off1 - off2;
-                }
-            });
-        return ocities;
-    }
-    
-    
-    /**
-     * Returns the cities, ordered by offset, accounting for summer/daylight
-     * savings time.  This does not require reading the time zone database
-     * since the cities are pre-sorted.
-     */
-    public static City[] getCitiesByRawOffset() {
-        return citiesByRawOffset;
-    }
-    
-    /**
-     * Returns an Iterator over all cities, in raw offset order.
-     */
-    public static Iterator<City> iterator() {
-        return cities.values().iterator();
-    }
-    
-    /**
-     * Returns the total number of cities.
-     */
-    public static int numCities() {
-        return cities.size();
-    }
-    
-    /**
-     * Constructs a city with the given name, time zone name, raw offset,
-     * latitude, longitude, and 3D (X, Y, Z) coordinate.
-     */
-    public City(String name, String timeZoneID,
-                int rawOffset,
-                float latitude, float longitude,
-                float x, float y, float z) {
-        this.name = name;
-        this.timeZoneID = timeZoneID;
-        this.rawOffset = rawOffset;
-        this.latitude = latitude;
-        this.longitude = longitude;
-        this.x = x;
-        this.y = y;
-        this.z = z;
-    }
-    
-    public String getName() {
-        return name;
-    }
-    
-    public TimeZone getTimeZone() {
-        if (timeZone == null) {
-            timeZone = TimeZone.getTimeZone(timeZoneID);
-        }
-        return timeZone;
-    }
-    
-    public float getLongitude() {
-        return longitude;
-    }
-    
-    public float getLatitude() {
-        return latitude;
-    }
-    
-    public float getX() {
-        return x;
-    }
-    
-    public float getY() {
-        return y;
-    }
-    
-    public float getZ() {
-        return z;
-    }
-    
-    public float getRawOffset() {
-        return rawOffset / 3600000.0f;
-    }
-
-    public int getRawOffsetMillis() {
-        return rawOffset;
-    }
-    
-    /**
-     * Returns this city's offset from UTC, taking summer/daylight savigns
-     * time into account.
-     */
-    public float getOffset() {
-        long now = System.currentTimeMillis();
-        if (timeZone == null) {
-            timeZone = TimeZone.getTimeZone(timeZoneID);
-        }
-        return timeZone.getOffset(now) / 3600000.0f;
-    }
-    
-    /**
-     * Compares this city to another by name.
-     */
-    public int compareTo(City o) {
-        return name.compareTo(o.name);
-    }
-}
diff --git a/samples/GlobalTime/src/com/android/globaltime/Clock.java b/samples/GlobalTime/src/com/android/globaltime/Clock.java
deleted file mode 100644
index 9aad71a..0000000
--- a/samples/GlobalTime/src/com/android/globaltime/Clock.java
+++ /dev/null
@@ -1,332 +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.globaltime;
-
-import java.util.Calendar;
-import java.util.Date;
-import java.util.TimeZone;
-
-import android.graphics.Canvas;
-import android.graphics.Paint;
-import android.graphics.Path;
-import android.graphics.RectF;
-import android.text.format.DateUtils;
-import android.view.animation.AccelerateDecelerateInterpolator;
-import android.view.animation.Interpolator;
-
-/**
- * A class that draws an analog clock face with information about the current
- * time in a given city.
- */
-public class Clock {
-
-    static final int MILLISECONDS_PER_MINUTE = 60 * 1000;
-    static final int MILLISECONDS_PER_HOUR = 60 * 60 * 1000;
-
-    private City mCity = null;
-    private long mCitySwitchTime;
-    private long mTime;
-
-    private float mColorRed = 1.0f;
-    private float mColorGreen = 1.0f;
-    private float mColorBlue = 1.0f;
-
-    private long mOldOffset;
-
-    private Interpolator mClockHandInterpolator =
-        new AccelerateDecelerateInterpolator();
-
-    public Clock() {
-        // Empty constructor
-    }
-
-    /**
-     * Adds a line to the given Path.  The line extends from
-     * radius r0 to radius r1 about the center point (cx, cy),
-     * at an angle given by pos.
-     * 
-     * @param path the Path to draw to
-     * @param radius the radius of the outer rim of the clock
-     * @param pos the angle, with 0 and 1 at 12:00
-     * @param cx the X coordinate of the clock center
-     * @param cy the Y coordinate of the clock center
-     * @param r0 the starting radius for the line
-     * @param r1 the ending radius for the line
-     */
-    private static void drawLine(Path path,
-        float radius, float pos, float cx, float cy, float r0, float r1) {
-        float theta = pos * Shape.TWO_PI - Shape.PI_OVER_TWO;
-        float dx = (float) Math.cos(theta);
-        float dy = (float) Math.sin(theta);
-        float p0x = cx + dx * r0;
-        float p0y = cy + dy * r0;
-        float p1x = cx + dx * r1;
-        float p1y = cy + dy * r1;
-
-        float ox =  (p1y - p0y);
-        float oy = -(p1x - p0x);
-
-        float norm = (radius / 2.0f) / (float) Math.sqrt(ox * ox + oy * oy);
-        ox *= norm;
-        oy *= norm;
-
-        path.moveTo(p0x - ox, p0y - oy);
-        path.lineTo(p1x - ox, p1y - oy);
-        path.lineTo(p1x + ox, p1y + oy);
-        path.lineTo(p0x + ox, p0y + oy);
-        path.close();
-    }
-
-    /**
-     * Adds a vertical arrow to the given Path.
-     * 
-     * @param path the Path to draw to
-     */
-    private static void drawVArrow(Path path,
-        float cx, float cy, float width, float height) {
-        path.moveTo(cx - width / 2.0f, cy);
-        path.lineTo(cx, cy + height);
-        path.lineTo(cx + width / 2.0f, cy);
-        path.close();
-    }
-
-    /**
-     * Adds a horizontal arrow to the given Path.
-     * 
-     * @param path the Path to draw to
-     */
-    private static void drawHArrow(Path path,
-        float cx, float cy, float width, float height) {
-        path.moveTo(cx, cy - height / 2.0f);
-        path.lineTo(cx + width, cy);
-        path.lineTo(cx, cy + height / 2.0f);
-        path.close();
-    }
-
-    /**
-     * Returns an offset in milliseconds to be subtracted from the current time
-     * in order to obtain an smooth interpolation between the previously
-     * displayed time and the current time.
-     */
-    private long getOffset(float lerp) {
-        long doffset = (long) (mCity.getOffset() *
-            (float) MILLISECONDS_PER_HOUR - mOldOffset);
-        int sign;
-        if (doffset < 0) {
-            doffset = -doffset;
-            sign = -1;
-        } else {
-            sign = 1;
-        }
-
-        while (doffset > 12L * MILLISECONDS_PER_HOUR) {
-            doffset -= 12L * MILLISECONDS_PER_HOUR;
-        }
-        if (doffset > 6L * MILLISECONDS_PER_HOUR) {
-            doffset = 12L * MILLISECONDS_PER_HOUR - doffset;
-            sign = -sign;
-        }
-
-        // Interpolate doffset towards 0
-        doffset = (long)((1.0f - lerp)*doffset);
-
-        // Keep the same seconds count
-        long dh = doffset / (MILLISECONDS_PER_HOUR);
-        doffset -= dh * MILLISECONDS_PER_HOUR;
-        long dm = doffset / MILLISECONDS_PER_MINUTE;
-        doffset = sign * (60 * dh + dm) * MILLISECONDS_PER_MINUTE;
-    
-        return doffset;
-    }
-
-    /**
-     * Set the city to be displayed.  setCity(null) resets things so the clock
-     * hand animation won't occur next time.
-     */
-    public void setCity(City city) {
-        if (mCity != city) {
-            if (mCity != null) {
-                mOldOffset =
-                    (long) (mCity.getOffset() * (float) MILLISECONDS_PER_HOUR);
-            } else if (city != null) {
-                mOldOffset =
-                    (long) (city.getOffset() * (float) MILLISECONDS_PER_HOUR);
-            } else {
-                mOldOffset = 0L; // this will never be used
-            }
-            this.mCitySwitchTime = System.currentTimeMillis();
-            this.mCity = city;
-        }
-    }
-
-    public void setTime(long time) {
-        this.mTime = time;
-    }
-
-    /**
-     * Draws the clock face.
-     * 
-     * @param canvas the Canvas to draw to
-     * @param cx the X coordinate of the clock center
-     * @param cy the Y coordinate of the clock center
-     * @param radius the radius of the clock face
-     * @param alpha the translucency of the clock face
-     * @param textAlpha the translucency of the text
-     * @param showCityName if true, display the city name
-     * @param showTime if true, display the time digitally
-     * @param showUpArrow if true, display an up arrow
-     * @param showDownArrow if true, display a down arrow
-     * @param showLeftRightArrows if true, display left and right arrows
-     * @param prefixChars number of characters of the city name to draw in bold
-     */
-    public void drawClock(Canvas canvas,
-        float cx, float cy, float radius, float alpha, float textAlpha,
-        boolean showCityName, boolean showTime,
-        boolean showUpArrow,  boolean showDownArrow, boolean showLeftRightArrows,
-        int prefixChars) {
-        Paint paint = new Paint();
-        paint.setAntiAlias(true);
-
-        int iradius = (int)radius;
-
-        TimeZone tz = mCity.getTimeZone();
-
-        // Compute an interpolated time to animate between the previously
-        // displayed time and the current time
-        float lerp = Math.min(1.0f,
-            (System.currentTimeMillis() - mCitySwitchTime) / 500.0f);
-        lerp = mClockHandInterpolator.getInterpolation(lerp);
-        long doffset = lerp < 1.0f ? getOffset(lerp) : 0L;
-    
-        // Determine the interpolated time for the given time zone
-        Calendar cal = Calendar.getInstance(tz);
-        cal.setTimeInMillis(mTime - doffset);
-        int hour = cal.get(Calendar.HOUR_OF_DAY);
-        int minute = cal.get(Calendar.MINUTE);
-        int second = cal.get(Calendar.SECOND);
-        int milli = cal.get(Calendar.MILLISECOND);
-
-        float offset = tz.getRawOffset() / (float) MILLISECONDS_PER_HOUR;
-        float daylightOffset = tz.inDaylightTime(new Date(mTime)) ?
-            tz.getDSTSavings() / (float) MILLISECONDS_PER_HOUR : 0.0f;
-
-        float absOffset = offset < 0 ? -offset : offset;
-        int offsetH = (int) absOffset;
-        int offsetM = (int) (60.0f * (absOffset - offsetH));
-        hour %= 12;
-
-        // Get the city name and digital time strings
-        String cityName = mCity.getName();
-        cal.setTimeInMillis(mTime);
-        String time = DateUtils.timeString(cal.getTimeInMillis()) + " "  +
-            DateUtils.getDayOfWeekString(cal.get(Calendar.DAY_OF_WEEK),
-                    DateUtils.LENGTH_SHORT) + " " +
-            " (UTC" +
-            (offset >= 0 ? "+" : "-") +
-            offsetH +
-            (offsetM == 0 ? "" : ":" + offsetM) +
-            (daylightOffset == 0 ? "" : "+" + daylightOffset) +
-            ")";
-
-        float th = paint.getTextSize();
-        float tw;
-
-        // Set the text color
-        paint.setARGB((int) (textAlpha * 255.0f),
-                      (int) (mColorRed * 255.0f),
-                      (int) (mColorGreen * 255.0f),
-                      (int) (mColorBlue * 255.0f));
-
-        tw = paint.measureText(cityName);
-        if (showCityName) {
-            // Increment prefixChars to include any spaces
-            for (int i = 0; i < prefixChars; i++) {
-                if (cityName.charAt(i) == ' ') {
-                    ++prefixChars;
-                }
-            }
-
-            // Draw the city name
-            canvas.drawText(cityName, cx - tw / 2, cy - radius - th, paint);
-            // Overstrike the first 'prefixChars' characters
-            canvas.drawText(cityName.substring(0, prefixChars),
-                            cx - tw / 2 + 1, cy - radius - th, paint);
-        }
-        tw = paint.measureText(time);
-        if (showTime) {
-            canvas.drawText(time, cx - tw / 2, cy + radius + th + 5, paint);
-        }
-
-        paint.setARGB((int)(alpha * 255.0f),
-                      (int)(mColorRed * 255.0f),
-                      (int)(mColorGreen * 255.0f),
-                      (int)(mColorBlue * 255.0f));
-
-        paint.setStyle(Paint.Style.FILL);
-        canvas.drawOval(new RectF(cx - 2, cy - 2, cx + 2, cy + 2), paint);
-
-        paint.setStyle(Paint.Style.STROKE);
-        paint.setStrokeWidth(radius * 0.12f);
-
-        canvas.drawOval(new RectF(cx - iradius, cy - iradius,
-                                  cx + iradius, cy + iradius),
-                        paint);
-
-        float r0 = radius * 0.1f;
-        float r1 = radius * 0.4f;
-        float r2 = radius * 0.6f;
-        float r3 = radius * 0.65f;
-        float r4 = radius * 0.7f;
-        float r5 = radius * 0.9f;
-
-        Path path = new Path();
-
-        float ss = second + milli / 1000.0f;
-        float mm = minute + ss / 60.0f;
-        float hh = hour + mm / 60.0f;
-
-        // Tics for the hours
-        for (int i = 0; i < 12; i++) {
-            drawLine(path, radius * 0.12f, i / 12.0f, cx, cy, r4, r5);
-        }
-
-        // Hour hand
-        drawLine(path, radius * 0.12f, hh / 12.0f, cx, cy, r0, r1); 
-        // Minute hand
-        drawLine(path, radius * 0.12f, mm / 60.0f, cx, cy, r0, r2); 
-        // Second hand
-        drawLine(path, radius * 0.036f, ss / 60.0f, cx, cy, r0, r3); 
-
-        if (showUpArrow) {
-            drawVArrow(path, cx + radius * 1.13f, cy - radius,
-                radius * 0.15f, -radius * 0.1f);
-        }
-        if (showDownArrow) {
-            drawVArrow(path, cx + radius * 1.13f, cy + radius,
-                radius * 0.15f, radius * 0.1f);
-        }
-        if (showLeftRightArrows) {
-            drawHArrow(path, cx - radius * 1.3f, cy, -radius * 0.1f,
-                radius * 0.15f);
-            drawHArrow(path, cx + radius * 1.3f, cy,  radius * 0.1f,
-                radius * 0.15f);
-        }
-
-        paint.setStyle(Paint.Style.FILL);
-        canvas.drawPath(path, paint);
-    }
-}
diff --git a/samples/GlobalTime/src/com/android/globaltime/GLView.java b/samples/GlobalTime/src/com/android/globaltime/GLView.java
deleted file mode 100644
index 4253717..0000000
--- a/samples/GlobalTime/src/com/android/globaltime/GLView.java
+++ /dev/null
@@ -1,927 +0,0 @@
-/*
- * Copyright (C) 2006 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.globaltime;
-
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-import java.util.HashMap;
-import javax.microedition.khronos.opengles.GL10;
-
-import android.graphics.Canvas;
-import android.graphics.Paint;
-import android.view.KeyEvent;
-
-class Message {
-
-    private String mText;
-    private long mExpirationTime;
-
-    public Message(String text, long expirationTime) {
-        this.mText = text;
-        this.mExpirationTime = expirationTime;
-    }
-
-    public String getText() {
-        return mText;
-    }
-
-    public long getExpirationTime() {
-        return mExpirationTime;
-    }
-}
-
-/**
- * A helper class to simplify writing an Activity that renders using
- * OpenGL ES.
- *
- * <p> A GLView object stores common elements of GL state and allows
- * them to be modified interactively.  This is particularly useful for
- * determining the proper settings of parameters such as the view
- * frustum and light intensities during application development.
- *
- * <p> A GLView is not an actual View; instead, it is meant to be
- * called from within a View to perform event processing on behalf of the
- * actual View.
- *
- * <p> By passing key events to the GLView object from the View,
- * the application can automatically allow certain parameters to
- * be user-controlled from the keyboard.  Key events may be passed as
- * shown below:
- *
- * <pre>
- * GLView mGlView = new GLView();
- *
- * public boolean onKeyDown(int keyCode, KeyEvent event) {
- *     // Hand the key to the GLView object first
- *     if (mGlView.processKey(keyCode)) {
- *         return;
- *     }
- *  
- *     switch (keyCode) {
- *     case KeyEvent.KEY_CODE_X:
- *         // perform app processing
- *         break;
- *     
- *     default:
- *         super.onKeyDown(keyCode, event);
- *         break;
- *     }
- * }
- * </pre>
- *
- * <p> During drawing of a frame, the GLView object should be given the
- * opportunity to manage GL parameters as shown below:
- * 
- * OpenGLContext mGLContext; // initialization not shown
- * int mNumTrianglesDrawn = 0;
- * 
- * protected void onDraw(Canvas canvas) {
- *     int w = getWidth();
- *     int h = getHeight();
- *         
- *     float ratio = (float) w / h;
- *     mGLView.setAspectRatio(ratio);
- *
- *     GL10 gl = (GL10) mGLContext.getGL();
- *     mGLContext.waitNative(canvas, this);
- *     
- *     // Enable a light for the GLView to manipulate
- *     gl.glEnable(GL10.GL_LIGHTING);
- *     gl.glEnable(GL10.GL_LIGHT0);
- *         
- *     // Allow the GLView to set GL parameters
- *     mGLView.setTextureParameters(gl);
- *     mGLView.setProjection(gl);
- *     mGLView.setView(gl);
- *     mGLView.setLights(gl, GL10.GL_LIGHT0);
- *         
- *     // Draw some stuff (not shown)
- *     mNumTrianglesDrawn += <num triangles just drawn>;
- *     
- *     // Wait for GL drawing to complete
- *     mGLContext.waitGL();
- *     
- *     // Inform the GLView of what was drawn, and ask it to display statistics
- *     mGLView.setNumTriangles(mNumTrianglesDrawn);
- *     mGLView.showMessages(canvas);
- *     mGLView.showStatistics(canvas, w);
- * }      
- * </pre>
- *
- * <p> At the end of each frame, following the call to
- * GLContext.waitGL, the showStatistics and showMessages methods
- * will cause additional information to be displayed.
- *
- * <p> To enter the interactive command mode, the 'tab' key must be
- * pressed twice in succession.  A subsequent press of the 'tab' key
- * exits the interactive command mode.  Entering a multi-letter code
- * sets the parameter to be modified. The 'newline' key erases the
- * current code, and the 'del' key deletes the last letter of
- * the code. The parameter value may be modified by pressing the
- * keypad left or up to decrement the value and right or down to
- * increment the value.  The current value will be displayed as an
- * overlay above the GL rendered content.
- * 
- * <p> The supported keyboard commands are as follows:
- *
- * <ul>
- * <li>     h - display a list of commands
- * <li>    fn - near frustum 
- * <li>    ff - far frustum 
- * <li>    tx - translate x
- * <li>    ty - translate y
- * <li>    tz - translate z
- * <li>     z - zoom (frustum size)
- * <li>    la - ambient light (all RGB channels)
- * <li>   lar - ambient light red channel
- * <li>   lag - ambient light green channel
- * <li>   lab - ambient light blue channel
- * <li>    ld - diffuse light (all RGB channels)
- * <li>   ldr - diffuse light red channel
- * <li>   ldg - diffuse light green channel
- * <li>   ldb - diffuse light blue channel
- * <li>    ls - specular light (all RGB channels)
- * <li>   lsr - specular light red channel
- * <li>   lsg - specular light green channel
- * <li>   lsb - specular light blue channel
- * <li>   lma - light model ambient (all RGB channels)
- * <li>  lmar - light model ambient light red channel
- * <li>  lmag - light model ambient green channel
- * <li>  lmab - light model ambient blue channel
- * <li>  tmin - texture min filter
- * <li>  tmag - texture mag filter
- * <li>  tper - texture perspective correction
- * </ul>
- * 
- * {@hide}
- */
-public class GLView {
-
-    private static final int DEFAULT_DURATION_MILLIS = 1000;
-    private static final int STATE_KEY = KeyEvent.KEYCODE_TAB;
-    private static final int HAVE_NONE = 0;
-    private static final int HAVE_ONE = 1;
-    private static final int HAVE_TWO = 2;
-
-    private static final float MESSAGE_Y_SPACING = 12.0f;
-
-    private int mState = HAVE_NONE;
-
-    private static final int NEAR_FRUSTUM  = 0;
-    private static final int FAR_FRUSTUM   = 1;
-    private static final int TRANSLATE_X   = 2;
-    private static final int TRANSLATE_Y   = 3;
-    private static final int TRANSLATE_Z   = 4;
-    private static final int ZOOM_EXPONENT = 5;
-
-    private static final int AMBIENT_INTENSITY = 6;
-    private static final int AMBIENT_RED = 7;
-    private static final int AMBIENT_GREEN = 8;
-    private static final int AMBIENT_BLUE = 9;
-
-    private static final int DIFFUSE_INTENSITY = 10;
-    private static final int DIFFUSE_RED = 11;
-    private static final int DIFFUSE_GREEN = 12;
-    private static final int DIFFUSE_BLUE = 13;
-
-    private static final int SPECULAR_INTENSITY = 14;
-    private static final int SPECULAR_RED = 15;
-    private static final int SPECULAR_GREEN = 16;
-    private static final int SPECULAR_BLUE = 17;
-
-    private static final int LIGHT_MODEL_AMBIENT_INTENSITY = 18;
-    private static final int LIGHT_MODEL_AMBIENT_RED = 19;
-    private static final int LIGHT_MODEL_AMBIENT_GREEN = 20;
-    private static final int LIGHT_MODEL_AMBIENT_BLUE = 21;
-
-    private static final int TEXTURE_MIN_FILTER = 22;
-    private static final int TEXTURE_MAG_FILTER = 23;
-    private static final int TEXTURE_PERSPECTIVE_CORRECTION = 24;
-
-    private static final String[] commands = { 
-        "fn",
-        "ff",
-        "tx",
-        "ty",
-        "tz",
-        "z",
-        "la", "lar", "lag", "lab",
-        "ld", "ldr", "ldg", "ldb",
-        "ls", "lsr", "lsg", "lsb",
-        "lma", "lmar", "lmag", "lmab",
-        "tmin", "tmag", "tper"
-   };
-
-    private static final String[] labels = {
-        "Near Frustum",
-        "Far Frustum",
-        "Translate X",
-        "Translate Y",
-        "Translate Z",
-        "Zoom",
-        "Ambient Intensity",
-        "Ambient Red",
-        "Ambient Green",
-        "Ambient Blue",
-        "Diffuse Intensity",
-        "Diffuse Red",
-        "Diffuse Green",
-        "Diffuse Blue",
-        "Specular Intenstity",
-        "Specular Red",
-        "Specular Green",
-        "Specular Blue",
-        "Light Model Ambient Intensity",
-        "Light Model Ambient Red",
-        "Light Model Ambient Green",
-        "Light Model Ambient Blue",
-        "Texture Min Filter",
-        "Texture Mag Filter",
-        "Texture Perspective Correction",
-    };
-
-    private static final float[] defaults = {
-        5.0f, 100.0f,
-        0.0f, 0.0f, -50.0f,
-        0,
-        0.125f,	1.0f, 1.0f, 1.0f,
-        0.125f,	1.0f, 1.0f, 1.0f,
-        0.125f,	1.0f, 1.0f, 1.0f,
-        0.125f,	1.0f, 1.0f, 1.0f,
-        GL10.GL_NEAREST, GL10.GL_NEAREST,
-        GL10.GL_FASTEST
-    };
-
-    private static final float[] increments = {
-        0.01f, 0.5f,
-        0.125f, 0.125f, 0.125f,
-        1.0f,
-        0.03125f, 0.1f, 0.1f, 0.1f,
-        0.03125f, 0.1f, 0.1f, 0.1f,
-        0.03125f, 0.1f, 0.1f, 0.1f,
-        0.03125f, 0.1f, 0.1f, 0.1f,
-        0, 0, 0
-    };
-
-    private float[] params = new float[commands.length];
-
-    private static final float mZoomScale = 0.109f;
-    private static final float mZoomBase  = 1.01f;
-
-    private int             mParam = -1;
-    private float           mIncr = 0;
-
-    private Paint           mPaint = new Paint();
-
-    private float           mAspectRatio = 1.0f;
-
-    private float           mZoom;
-
-    // private boolean         mPerspectiveCorrection = false;
-    // private int             mTextureMinFilter = GL10.GL_NEAREST;
-    // private int             mTextureMagFilter = GL10.GL_NEAREST;
-
-    // Counters for FPS calculation
-    private boolean         mDisplayFPS = false;
-    private boolean         mDisplayCounts = false;
-    private int             mFramesFPS = 10;
-    private long[]          mTimes = new long[mFramesFPS];
-    private int             mTimesIdx = 0;
-
-    private Map<String,Message> mMessages = new HashMap<String,Message>();
-
-    /**
-     * Constructs a new GLView.
-     */
-    public GLView() {
-        mPaint.setColor(0xffffffff);
-        reset();
-    }
-
-    /**
-     * Sets the aspect ratio (width/height) of the screen.
-     *
-     * @param aspectRatio the screen width divided by the screen height
-     */
-    public void setAspectRatio(float aspectRatio) {
-        this.mAspectRatio = aspectRatio;
-    }
-    
-    /**
-     * Sets the overall ambient light intensity.  This intensity will
-     * be used to modify the ambient light value for each of the red,
-     * green, and blue channels passed to glLightfv(...GL_AMBIENT...).
-     * The default value is 0.125f.
-     *
-     * @param intensity a floating-point value controlling the overall
-     * ambient light intensity.
-     */
-    public void setAmbientIntensity(float intensity) {
-        params[AMBIENT_INTENSITY] = intensity;
-    }
-
-    /**
-     * Sets the light model ambient intensity.  This intensity will be
-     * used to modify the ambient light value for each of the red,
-     * green, and blue channels passed to
-     * glLightModelfv(GL_LIGHT_MODEL_AMBIENT...).  The default value
-     * is 0.125f.
-     *
-     * @param intensity a floating-point value controlling the overall
-     * light model ambient intensity.
-     */
-    public void setLightModelAmbientIntensity(float intensity) {
-        params[LIGHT_MODEL_AMBIENT_INTENSITY] = intensity;
-    }
-
-    /**
-     * Sets the ambient color for the red, green, and blue channels
-     * that will be multiplied by the value of setAmbientIntensity and
-     * passed to glLightfv(...GL_AMBIENT...).  The default values are
-     * {1, 1, 1}.
-     *
-     * @param ambient an arry of three floats containing ambient
-     * red, green, and blue intensity values.
-     */
-    public void setAmbientColor(float[] ambient) {
-        params[AMBIENT_RED]   = ambient[0];
-        params[AMBIENT_GREEN] = ambient[1];
-        params[AMBIENT_BLUE]  = ambient[2];
-    }
-
-    /**
-     * Sets the overall diffuse light intensity.  This intensity will
-     * be used to modify the diffuse light value for each of the red,
-     * green, and blue channels passed to glLightfv(...GL_DIFFUSE...).
-     * The default value is 0.125f.
-     *
-     * @param intensity a floating-point value controlling the overall
-     * ambient light intensity.
-     */
-    public void setDiffuseIntensity(float intensity) {
-        params[DIFFUSE_INTENSITY] = intensity;
-    }
-
-    /**
-     * Sets the diffuse color for the red, green, and blue channels
-     * that will be multiplied by the value of setDiffuseIntensity and
-     * passed to glLightfv(...GL_DIFFUSE...).  The default values are
-     * {1, 1, 1}.
-     *
-     * @param diffuse an array of three floats containing diffuse
-     * red, green, and blue intensity values.
-     */
-    public void setDiffuseColor(float[] diffuse) {
-        params[DIFFUSE_RED]   = diffuse[0];
-        params[DIFFUSE_GREEN] = diffuse[1];
-        params[DIFFUSE_BLUE]  = diffuse[2];
-    }
-
-    /**
-     * Sets the overall specular light intensity.  This intensity will
-     * be used to modify the diffuse light value for each of the red,
-     * green, and blue channels passed to glLightfv(...GL_SPECULAR...).
-     * The default value is 0.125f.
-     *
-     * @param intensity a floating-point value controlling the overall
-     * ambient light intensity.
-     */
-    public void setSpecularIntensity(float intensity) {
-        params[SPECULAR_INTENSITY] = intensity;
-    }
-
-    /**
-     * Sets the specular color for the red, green, and blue channels
-     * that will be multiplied by the value of setSpecularIntensity and
-     * passed to glLightfv(...GL_SPECULAR...).  The default values are
-     * {1, 1, 1}.
-     *
-     * @param specular an array of three floats containing specular
-     * red, green, and blue intensity values.
-     */
-    public void setSpecularColor(float[] specular) {
-        params[SPECULAR_RED]   = specular[0];
-        params[SPECULAR_GREEN] = specular[1];
-        params[SPECULAR_BLUE]  = specular[2];
-    }
-
-    /**
-     * Returns the current X translation of the modelview
-     * transformation as passed to glTranslatef.  The default value is
-     * 0.0f.
-     *
-     * @return the X modelview translation as a float.
-     */
-    public float getTranslateX() {
-        return params[TRANSLATE_X];
-    }
-
-    /**
-     * Returns the current Y translation of the modelview
-     * transformation as passed to glTranslatef.  The default value is
-     * 0.0f.
-     *
-     * @return the Y modelview translation as a float.
-     */
-    public float getTranslateY() {
-        return params[TRANSLATE_Y];
-    }
-
-    /**
-     * Returns the current Z translation of the modelview
-     * transformation as passed to glTranslatef.  The default value is
-     * -50.0f.
-     *
-     * @return the Z modelview translation as a float.
-     */
-    public float getTranslateZ() {
-        return params[TRANSLATE_Z];
-    }
-
-    /**
-     * Sets the position of the near frustum clipping plane as passed
-     * to glFrustumf.  The default value is 5.0f;
-     *
-     * @param nearFrustum the near frustum clipping plane distance as
-     * a float.
-     */
-    public void setNearFrustum(float nearFrustum) {
-        params[NEAR_FRUSTUM] = nearFrustum;
-    }
-
-    /**
-     * Sets the position of the far frustum clipping plane as passed
-     * to glFrustumf.  The default value is 100.0f;
-     *
-     * @param farFrustum the far frustum clipping plane distance as a
-     * float.
-     */
-    public void setFarFrustum(float farFrustum) {
-        params[FAR_FRUSTUM] = farFrustum;
-    }
-
-    private void computeZoom() {
-        mZoom = mZoomScale*(float)Math.pow(mZoomBase, -params[ZOOM_EXPONENT]);
-    }
-
-    /**
-     * Resets all parameters to their default values.
-     */
-    public void reset() {
-        for (int i = 0; i < params.length; i++) {
-            params[i] = defaults[i];
-        }
-        computeZoom();
-    }
-
-    private void removeExpiredMessages() {
-        long now = System.currentTimeMillis();
-
-        List<String> toBeRemoved = new ArrayList<String>();
-
-        Iterator<String> keyIter = mMessages.keySet().iterator();
-        while (keyIter.hasNext()) {
-            String key = keyIter.next();
-            Message msg = mMessages.get(key);
-            if (msg.getExpirationTime() < now) {
-                toBeRemoved.add(key);
-            }
-        }
-
-        Iterator<String> tbrIter = toBeRemoved.iterator();
-        while (tbrIter.hasNext()) {
-            String key = tbrIter.next();
-            mMessages.remove(key);
-        }
-    }
-    
-    /**
-     * Displays the message overlay on the given Canvas.  The
-     * GLContext.waitGL method should be called prior to calling this
-     * method.  The interactive command display is drawn by this
-     * method.
-     *
-     * @param canvas the Canvas on which messages are to appear.
-     */
-    public void showMessages(Canvas canvas) {
-        removeExpiredMessages();
-
-        float y = 10.0f;
-
-        List<String> l = new ArrayList<String>();
-        l.addAll(mMessages.keySet());
-        Collections.sort(l);
-
-        Iterator<String> iter = l.iterator();
-        while (iter.hasNext()) {
-            String key = iter.next();
-            String text = mMessages.get(key).getText();
-            canvas.drawText(text, 10.0f, y, mPaint);
-            y += MESSAGE_Y_SPACING;
-        }
-    }
-
-    private int mTriangles;
-
-    /**
-     * Sets the number of triangles drawn in the previous frame for
-     * display by the showStatistics method.  The number of triangles
-     * is not computed by GLView but must be supplied by the
-     * calling Activity.
-     *
-     * @param triangles an Activity-supplied estimate of the number of 
-     * triangles drawn in the previous frame.
-     */
-    public void setNumTriangles(int triangles) {
-        this.mTriangles = triangles;
-    }
-
-    /**
-     * Displays statistics on frames and triangles per second. The
-     * GLContext.waitGL method should be called prior to calling this
-     * method.
-     *
-     * @param canvas the Canvas on which statistics are to appear.
-     * @param width the width of the Canvas.
-     */
-    public void showStatistics(Canvas canvas, int width) {	
-        long endTime = mTimes[mTimesIdx] = System.currentTimeMillis();
-        mTimesIdx = (mTimesIdx + 1) % mFramesFPS;
-
-        float th = mPaint.getTextSize();
-
-        if (mDisplayFPS) {
-            // Use end time from mFramesFPS frames ago
-            long startTime = mTimes[mTimesIdx];
-            String fps = "" + (1000.0f*mFramesFPS/(endTime - startTime));
-
-            // Normalize fps to XX.XX format
-            if (fps.indexOf(".") == 1) {
-                fps = " " + fps;
-            }
-            int len = fps.length();
-            if (len == 2) {
-                fps += ".00";
-            } else if (len == 4) {
-                fps += "0";
-            } else if (len > 5) {
-                fps = fps.substring(0, 5);
-            }
-
-            canvas.drawText(fps + " fps", width - 60.0f, 10.0f, mPaint);
-        }
-
-        if (mDisplayCounts) {
-            canvas.drawText(mTriangles + " triangles",
-                            width - 100.0f, 10.0f + th + 5, mPaint);
-        }
-    }
-
-    private void addMessage(String key, String text, int durationMillis) {
-        long expirationTime = System.currentTimeMillis() + durationMillis;
-
-        mMessages.put(key, new Message(text, expirationTime));
-    }
-
-    private void addMessage(String key, String text) {
-        addMessage(key, text, DEFAULT_DURATION_MILLIS);
-    }
-
-    private void addMessage(String text) {
-        addMessage(text, text, DEFAULT_DURATION_MILLIS);
-    }
-
-    private void clearMessages() {
-        mMessages.clear();
-    }
-
-    String command = "";
-
-    private void toggleFilter() {
-        if (params[mParam] == GL10.GL_NEAREST) {
-            params[mParam] = GL10.GL_LINEAR;
-        } else {
-            params[mParam] = GL10.GL_NEAREST;
-        }
-        addMessage(commands[mParam],
-                   "Texture " + 
-                   (mParam == TEXTURE_MIN_FILTER ? "min" : "mag") +
-                   " filter = " +
-                   (params[mParam] == GL10.GL_NEAREST ?
-                    "nearest" : "linear"));
-    }
-
-    private void togglePerspectiveCorrection() {
-        if (params[mParam] == GL10.GL_NICEST) {
-            params[mParam] = GL10.GL_FASTEST;
-        } else {
-            params[mParam] = GL10.GL_NICEST;
-        }
-        addMessage(commands[mParam],
-                   "Texture perspective correction = " +
-                   (params[mParam] == GL10.GL_FASTEST ?
-                    "fastest" : "nicest"));
-    }
-
-    private String valueString() {
-        if (mParam == TEXTURE_MIN_FILTER ||
-            mParam == TEXTURE_MAG_FILTER) {
-            if (params[mParam] == GL10.GL_NEAREST) {
-                return "nearest";
-            }
-            if (params[mParam] == GL10.GL_LINEAR) {
-                return "linear";
-            }
-        }
-        if (mParam == TEXTURE_PERSPECTIVE_CORRECTION) {
-            if (params[mParam] == GL10.GL_FASTEST) {
-                return "fastest";
-            }
-            if (params[mParam] == GL10.GL_NICEST) {
-                return "nicest";
-            }
-        }
-        return "" + params[mParam];
-    }
-
-    /**
-     * 
-     * @return true if the view 
-     */
-    public boolean hasMessages() {
-        return mState == HAVE_TWO || mDisplayFPS || mDisplayCounts;
-    }
-    
-    /**
-     * Process a key stroke.  The calling Activity should pass all
-     * keys from its onKeyDown method to this method.  If the key is
-     * part of a GLView command, true is returned and the calling
-     * Activity should ignore the key event.  Otherwise, false is
-     * returned and the calling Activity may process the key event
-     * normally.
-     *
-     * @param keyCode the key code as passed to Activity.onKeyDown.
-     *
-     * @return true if the key is part of a GLView command sequence,
-     * false otherwise.
-     */
-    public boolean processKey(int keyCode) {
-        // Pressing the state key twice enters the UI
-        // Pressing it again exits the UI
-        if ((keyCode == STATE_KEY) || 
-            (keyCode == KeyEvent.KEYCODE_SLASH) || 
-            (keyCode == KeyEvent.KEYCODE_PERIOD))
-        {
-            mState = (mState + 1) % 3;
-            if (mState == HAVE_NONE) {
-                clearMessages();
-            }
-            if (mState == HAVE_TWO) {
-                clearMessages();
-                addMessage("aaaa", "GL", Integer.MAX_VALUE);
-                addMessage("aaab", "", Integer.MAX_VALUE);
-                command = "";
-            }
-            return true;
-        } else {
-            if (mState == HAVE_ONE) {
-                mState = HAVE_NONE;
-                return false;
-            }
-        }
-
-        // If we're not in the UI, exit without handling the key
-        if (mState != HAVE_TWO) {
-            return false;
-        }
-
-        if (keyCode == KeyEvent.KEYCODE_ENTER) {
-            command = "";
-        } else if (keyCode == KeyEvent.KEYCODE_DEL) {
-            if (command.length() > 0) {
-                command = command.substring(0, command.length() - 1);
-            }
-
-        } else if (keyCode >= KeyEvent.KEYCODE_A &&
-                   keyCode <= KeyEvent.KEYCODE_Z) {
-            command += "" + (char)(keyCode - KeyEvent.KEYCODE_A + 'a');
-        }
-
-        addMessage("aaaa", "GL " + command, Integer.MAX_VALUE);
-
-        if (command.equals("h")) {
-            addMessage("aaaa", "GL", Integer.MAX_VALUE);
-            addMessage("h - help");
-            addMessage("fn/ff - frustum near/far clip Z");
-            addMessage("la/lar/lag/lab - abmient intensity/r/g/b");
-            addMessage("ld/ldr/ldg/ldb - diffuse intensity/r/g/b");
-            addMessage("ls/lsr/lsg/lsb - specular intensity/r/g/b");
-            addMessage("s - toggle statistics display");
-            addMessage("tmin/tmag - texture min/mag filter");
-            addMessage("tpersp - texture perspective correction");
-            addMessage("tx/ty/tz - view translate x/y/z");
-            addMessage("z - zoom");
-            command = "";
-            return true;
-        } else if (command.equals("s")) {
-            mDisplayCounts = !mDisplayCounts;
-            mDisplayFPS = !mDisplayFPS;
-            command = "";
-            return true;
-        }
-
-        mParam = -1;
-        for (int i = 0; i < commands.length; i++) {
-            if (command.equals(commands[i])) {
-                mParam = i;
-                mIncr = increments[i];
-            }
-        }
-        if (mParam == -1) {
-            return true;
-        }
-
-        boolean addMessage = true;
-
-        // Increment or decrement
-        if (keyCode == KeyEvent.KEYCODE_DPAD_RIGHT ||
-            keyCode == KeyEvent.KEYCODE_DPAD_DOWN) {
-            if (mParam == ZOOM_EXPONENT) {
-                params[mParam] += mIncr;
-                computeZoom();
-            } else if ((mParam == TEXTURE_MIN_FILTER) ||
-                       (mParam == TEXTURE_MAG_FILTER)) {
-                toggleFilter();
-            } else if (mParam == TEXTURE_PERSPECTIVE_CORRECTION) {
-                togglePerspectiveCorrection();
-            } else {
-                params[mParam] += mIncr;
-            }
-        } else if (keyCode == KeyEvent.KEYCODE_DPAD_UP ||
-                   keyCode == KeyEvent.KEYCODE_DPAD_LEFT) {
-            if (mParam == ZOOM_EXPONENT) {
-                params[mParam] -= mIncr;
-                computeZoom();
-            } else if ((mParam == TEXTURE_MIN_FILTER) ||
-                       (mParam == TEXTURE_MAG_FILTER)) {
-                toggleFilter();
-            } else if (mParam == TEXTURE_PERSPECTIVE_CORRECTION) {
-                togglePerspectiveCorrection();
-            } else {
-                params[mParam] -= mIncr;
-            }
-        }
-	
-        if (addMessage) {
-            addMessage(commands[mParam],
-                       labels[mParam] + ": " + valueString());
-        }
-
-        return true;
-    }
-
-    /**
-     * Zoom in by a given number of steps.  A negative value of steps
-     * zooms out.  Each step zooms in by 1%.
-     *
-     * @param steps the number of steps to zoom by.
-     */
-    public void zoom(int steps) {
-        params[ZOOM_EXPONENT] += steps;
-        computeZoom();
-    }
-		
-    /**
-     * Set the projection matrix using glFrustumf.  The left and right
-     * clipping planes are set at -+(aspectRatio*zoom), the bottom and
-     * top clipping planes are set at -+zoom, and the near and far
-     * clipping planes are set to the values set by setNearFrustum and
-     * setFarFrustum or interactively.
-     *
-     * <p> GL side effects:
-     * <ul>
-     *    <li>overwrites the matrix mode</li>
-     *    <li>overwrites the projection matrix</li>
-     * </ul>
-     *
-     * @param gl a GL10 instance whose projection matrix is to be modified.
-     */
-    public void setProjection(GL10 gl) {
-        gl.glMatrixMode(GL10.GL_PROJECTION);
-        gl.glLoadIdentity();
-
-        if (mAspectRatio >= 1.0f) {
-            gl.glFrustumf(-mAspectRatio*mZoom, mAspectRatio*mZoom,
-                          -mZoom, mZoom,
-                          params[NEAR_FRUSTUM], params[FAR_FRUSTUM]);
-        } else {
-            gl.glFrustumf(-mZoom, mZoom,
-                          -mZoom / mAspectRatio, mZoom / mAspectRatio,
-                          params[NEAR_FRUSTUM], params[FAR_FRUSTUM]);
-        }
-    }
-
-    /**
-     * Set the modelview matrix using glLoadIdentity and glTranslatef.
-     * The translation values are set interactively.
-     *
-     * <p> GL side effects:
-     * <ul>
-     * <li>overwrites the matrix mode</li>
-     * <li>overwrites the modelview matrix</li>
-     * </ul>
-     *
-     * @param gl a GL10 instance whose modelview matrix is to be modified.
-     */
-    public void setView(GL10 gl) {
-        gl.glMatrixMode(GL10.GL_MODELVIEW);
-        gl.glLoadIdentity();
-
-        // Move the viewpoint backwards
-        gl.glTranslatef(params[TRANSLATE_X],
-                        params[TRANSLATE_Y],
-                        params[TRANSLATE_Z]);
-    }
-
-    /**
-     * Sets texture parameters.
-     *
-     * <p> GL side effects:
-     * <ul>
-     * <li>sets the GL_PERSPECTIVE_CORRECTION_HINT</li>
-     * <li>sets the GL_TEXTURE_MIN_FILTER texture parameter</li>
-     * <li>sets the GL_TEXTURE_MAX_FILTER texture parameter</li>
-     * </ul>
-     *
-     * @param gl a GL10 instance whose texture parameters are to be modified.
-     */
-    public void setTextureParameters(GL10 gl) {
-        gl.glHint(GL10.GL_PERSPECTIVE_CORRECTION_HINT,
-                  (int)params[TEXTURE_PERSPECTIVE_CORRECTION]);
-        gl.glTexParameterf(GL10.GL_TEXTURE_2D,
-                           GL10.GL_TEXTURE_MIN_FILTER,
-                           params[TEXTURE_MIN_FILTER]);
-        gl.glTexParameterf(GL10.GL_TEXTURE_2D,
-                           GL10.GL_TEXTURE_MAG_FILTER,
-                           params[TEXTURE_MAG_FILTER]);
-    }
-
-    /**
-     * Sets the lighting parameters for the given light.
-     *
-     * <p> GL side effects:
-     * <ul>
-     * <li>sets the GL_LIGHT_MODEL_AMBIENT intensities
-     * <li>sets the GL_AMBIENT intensities for the given light</li>
-     * <li>sets the GL_DIFFUSE intensities for the given light</li>
-     * <li>sets the GL_SPECULAR intensities for the given light</li>
-     * </ul>
-     *
-     * @param gl a GL10 instance whose texture parameters are to be modified.
-     */
-    public void setLights(GL10 gl, int lightNum) {
-        float[] light = new float[4];
-        light[3] = 1.0f;
-
-        float lmi = params[LIGHT_MODEL_AMBIENT_INTENSITY];
-        light[0] = params[LIGHT_MODEL_AMBIENT_RED]*lmi;
-        light[1] = params[LIGHT_MODEL_AMBIENT_GREEN]*lmi;
-        light[2] = params[LIGHT_MODEL_AMBIENT_BLUE]*lmi;
-        gl.glLightModelfv(GL10.GL_LIGHT_MODEL_AMBIENT, light, 0);
-	
-        float ai = params[AMBIENT_INTENSITY];
-        light[0] = params[AMBIENT_RED]*ai;
-        light[1] = params[AMBIENT_GREEN]*ai;
-        light[2] = params[AMBIENT_BLUE]*ai;
-        gl.glLightfv(lightNum, GL10.GL_AMBIENT, light, 0);
-
-        float di = params[DIFFUSE_INTENSITY];
-        light[0] = params[DIFFUSE_RED]*di;
-        light[1] = params[DIFFUSE_GREEN]*di;
-        light[2] = params[DIFFUSE_BLUE]*di;
-        gl.glLightfv(lightNum, GL10.GL_DIFFUSE, light, 0);
-
-        float si = params[SPECULAR_INTENSITY];
-        light[0] = params[SPECULAR_RED]*si;
-        light[1] = params[SPECULAR_GREEN]*si;
-        light[2] = params[SPECULAR_BLUE]*si;
-        gl.glLightfv(lightNum, GL10.GL_SPECULAR, light, 0);
-    }
-}
diff --git a/samples/GlobalTime/src/com/android/globaltime/GlobalTime.java b/samples/GlobalTime/src/com/android/globaltime/GlobalTime.java
deleted file mode 100644
index e27ee56..0000000
--- a/samples/GlobalTime/src/com/android/globaltime/GlobalTime.java
+++ /dev/null
@@ -1,1488 +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.globaltime;
-
-import java.io.ByteArrayInputStream;
-import java.io.FileNotFoundException;
-import java.io.IOException;
-import java.io.InputStream;
-import java.util.ArrayList;
-import java.util.Calendar;
-import java.util.List;
-import java.util.Locale;
-import java.util.TimeZone;
-
-import javax.microedition.khronos.egl.*;
-import javax.microedition.khronos.opengles.*;
-
-import android.app.Activity;
-import android.content.Context;
-import android.content.res.AssetManager;
-import android.graphics.Canvas;
-import android.opengl.Object3D;
-import android.os.Bundle;
-import android.os.Handler;
-import android.os.Looper;
-import android.os.Message;
-import android.os.MessageQueue;
-import android.util.Log;
-import android.view.KeyEvent;
-import android.view.MotionEvent;
-import android.view.SurfaceHolder;
-import android.view.SurfaceView;
-import android.view.animation.AccelerateDecelerateInterpolator;
-import android.view.animation.DecelerateInterpolator;
-import android.view.animation.Interpolator;
-
-/**
- * The main View of the GlobalTime Activity.
- */
-class GTView extends SurfaceView implements SurfaceHolder.Callback {
-
-    /**
-     * A TimeZone object used to compute the current UTC time.
-     */
-    private static final TimeZone UTC_TIME_ZONE = TimeZone.getTimeZone("utc");
-
-    /**
-     * The Sun's color is close to that of a 5780K blackbody.
-     */
-    private static final float[] SUNLIGHT_COLOR = {
-        1.0f, 0.9375f, 0.91015625f, 1.0f
-    };
-
-    /**
-     * The inclination of the earth relative to the plane of the ecliptic
-     * is 23.45 degrees.
-     */
-    private static final float EARTH_INCLINATION = 23.45f * Shape.PI / 180.0f;
-
-    /** Seconds in a day */
-    private static final int SECONDS_PER_DAY = 24 * 60 * 60;
-
-    /** Flag for the depth test */
-    private static final boolean PERFORM_DEPTH_TEST= false;
-
-    /** Use raw time zone offsets, disregarding "summer time."  If false,
-     * current offsets will be used, which requires a much longer startup time
-     * in order to sort the city database.
-     */
-    private static final boolean USE_RAW_OFFSETS = true;
-
-    /**
-     * The earth's atmosphere.
-     */
-    private static final Annulus ATMOSPHERE =
-        new Annulus(0.0f, 0.0f, 1.75f, 0.9f, 1.08f, 0.4f, 0.4f, 0.8f, 0.0f,
-            0.0f, 0.0f, 0.0f, 1.0f, 50);
-
-    /**
-     * The tesselation of the earth by latitude.
-     */
-    private static final int SPHERE_LATITUDES = 25;
-
-    /**
-     * The tesselation of the earth by longitude.
-     */
-    private static int SPHERE_LONGITUDES = 25;
-
-    /**
-     * A flattened version of the earth.  The normals are computed identically
-     * to those of the round earth, allowing the day/night lighting to be
-     * applied to the flattened surface.
-     */
-    private static Sphere worldFlat = new LatLongSphere(0.0f, 0.0f, 0.0f, 1.0f,
-        SPHERE_LATITUDES, SPHERE_LONGITUDES,
-        0.0f, 360.0f, true, true, false, true);
-
-    /**
-     * The earth.
-     */
-    private Object3D mWorld;
-
-    /**
-     * Geometry of the city lights
-     */
-    private PointCloud mLights;
-
-    /**
-     * True if the activiy has been initialized.
-     */
-    boolean mInitialized = false;
-
-    /**
-     * True if we're in alphabetic entry mode.
-     */
-    private boolean mAlphaKeySet = false;
-
-    private EGLContext mEGLContext;
-    private EGLSurface mEGLSurface;
-    private EGLDisplay mEGLDisplay;
-    private EGLConfig  mEGLConfig;
-    GLView  mGLView;
-
-    // Rotation and tilt of the Earth
-    private float mRotAngle = 0.0f;
-    private float mTiltAngle = 0.0f;
-
-    // Rotational velocity of the orbiting viewer
-    private float mRotVelocity = 1.0f;
-
-    // Rotation of the flat view
-    private float mWrapX =  0.0f;
-    private float  mWrapVelocity =  0.0f;
-    private float mWrapVelocityFactor =  0.01f;
-
-    // Toggle switches
-    private boolean mDisplayAtmosphere = true;
-    private boolean mDisplayClock = false;
-    private boolean mClockShowing = false;
-    private boolean mDisplayLights = false;
-    private boolean mDisplayWorld = true;
-    private boolean mDisplayWorldFlat = false;
-    private boolean mSmoothShading = true;
-
-    // City search string
-    private String mCityName = "";
-
-    // List of all cities
-    private List<City> mClockCities;
-
-    // List of cities matching a user-supplied prefix
-    private List<City> mCityNameMatches = new ArrayList<City>();
-
-    private List<City> mCities;
-
-    // Start time for clock fade animation
-    private long mClockFadeTime;
-
-    // Interpolator for clock fade animation
-    private Interpolator mClockSizeInterpolator =
-        new DecelerateInterpolator(1.0f);
-
-    // Index of current clock
-    private int mCityIndex;
-
-    // Current clock
-    private Clock mClock;
-
-    // City-to-city flight animation parameters
-    private boolean mFlyToCity = false;
-    private long mCityFlyStartTime;
-    private float mCityFlightTime;
-    private float mRotAngleStart, mRotAngleDest;
-    private float mTiltAngleStart, mTiltAngleDest;
-
-    // Interpolator for flight motion animation
-    private Interpolator mFlyToCityInterpolator =
-        new AccelerateDecelerateInterpolator();
-
-    private static int sNumLights;
-    private static int[] sLightCoords;
-
-    //     static Map<Float,int[]> cityCoords = new HashMap<Float,int[]>();
-
-    // Arrays for GL calls
-    private float[] mClipPlaneEquation = new float[4];
-    private float[] mLightDir = new float[4];
-
-    // Calendar for computing the Sun's position
-    Calendar mSunCal = Calendar.getInstance(UTC_TIME_ZONE);
-
-    // Triangles drawn per frame
-    private int mNumTriangles;
-
-    private long startTime;
-
-    private static final int MOTION_NONE = 0;
-    private static final int MOTION_X = 1;
-    private static final int MOTION_Y = 2;
-
-    private static final int MIN_MANHATTAN_DISTANCE = 20;
-    private static final float ROTATION_FACTOR = 1.0f / 30.0f;
-    private static final float TILT_FACTOR = 0.35f;
-
-    // Touchscreen support
-    private float mMotionStartX;
-    private float mMotionStartY;
-    private float mMotionStartRotVelocity;
-    private float mMotionStartTiltAngle;
-    private int mMotionDirection;
-    
-    private boolean mPaused = true;
-    private boolean mHaveSurface = false;
-    private boolean mStartAnimating = false;
-    
-    public void surfaceCreated(SurfaceHolder holder) {
-        mHaveSurface = true;
-        startEGL();
-    }
-
-    public void surfaceDestroyed(SurfaceHolder holder) {
-        mHaveSurface = false;
-        stopEGL();
-    }
-
-    public void surfaceChanged(SurfaceHolder holder, int format, int w, int h) {
-        // nothing to do
-    }
-
-    /**
-     * Set up the view.
-     *
-     * @param context the Context
-     * @param am an AssetManager to retrieve the city database from
-     */
-    public GTView(Context context) {
-        super(context);
-
-        getHolder().addCallback(this);
-        getHolder().setType(SurfaceHolder.SURFACE_TYPE_GPU);
-
-        startTime = System.currentTimeMillis();
-
-        mClock = new Clock();
-
-        startEGL();
-        
-        setFocusable(true);
-        setFocusableInTouchMode(true);
-        requestFocus();
-    }
-
-    /**
-     * Creates an egl context. If the state of the activity is right, also
-     * creates the egl surface. Otherwise the surface will be created in a
-     * future call to createEGLSurface().
-     */
-    private void startEGL() {
-        EGL10 egl = (EGL10)EGLContext.getEGL();
-
-        if (mEGLContext == null) {
-            EGLDisplay dpy = egl.eglGetDisplay(EGL10.EGL_DEFAULT_DISPLAY);
-            int[] version = new int[2];
-            egl.eglInitialize(dpy, version);
-            int[] configSpec = {
-                    EGL10.EGL_DEPTH_SIZE,   16,
-                    EGL10.EGL_NONE
-            };
-            EGLConfig[] configs = new EGLConfig[1];
-            int[] num_config = new int[1];
-            egl.eglChooseConfig(dpy, configSpec, configs, 1, num_config);
-            mEGLConfig = configs[0];
-
-            mEGLContext = egl.eglCreateContext(dpy, mEGLConfig, 
-                    EGL10.EGL_NO_CONTEXT, null);
-            mEGLDisplay = dpy;
-            
-            AssetManager am = mContext.getAssets();
-            try {
-                loadAssets(am);
-            } catch (IOException ioe) {
-                ioe.printStackTrace();
-                throw new RuntimeException(ioe);
-            } catch (ArrayIndexOutOfBoundsException aioobe) {
-                aioobe.printStackTrace();
-                throw new RuntimeException(aioobe);
-            }
-        }
-        
-        if (mEGLSurface == null && !mPaused && mHaveSurface) {
-            mEGLSurface = egl.eglCreateWindowSurface(mEGLDisplay, mEGLConfig, 
-                    this, null);
-            egl.eglMakeCurrent(mEGLDisplay, mEGLSurface, mEGLSurface, 
-                    mEGLContext);
-            mInitialized = false;
-            if (mStartAnimating) {
-                startAnimating();
-                mStartAnimating = false;
-            }
-        }
-    }
-    
-    /**
-     * Destroys the egl context. If an egl surface has been created, it is
-     * destroyed as well.
-     */
-    private void stopEGL() {
-        EGL10 egl = (EGL10)EGLContext.getEGL();
-        if (mEGLSurface != null) {
-            egl.eglMakeCurrent(mEGLDisplay, 
-                    egl.EGL_NO_SURFACE, egl.EGL_NO_SURFACE, egl.EGL_NO_CONTEXT);
-            egl.eglDestroySurface(mEGLDisplay, mEGLSurface);
-            mEGLSurface = null;
-        }
-
-        if (mEGLContext != null) {
-            egl.eglDestroyContext(mEGLDisplay, mEGLContext);
-            egl.eglTerminate(mEGLDisplay);
-            mEGLContext = null;
-            mEGLDisplay = null;
-            mEGLConfig = null;
-        }
-    }
-    
-    public void onPause() {
-        mPaused = true;
-        stopAnimating();
-        stopEGL();
-    }
-    
-    public void onResume() {
-        mPaused = false;
-        startEGL();
-    }
-    
-    public void destroy() {
-        stopAnimating();
-        stopEGL();
-    }
-
-    /**
-     * Begin animation.
-     */
-    public void startAnimating() {
-        if (mEGLSurface == null) {
-            mStartAnimating = true; // will start when egl surface is created
-        } else {
-            mHandler.sendEmptyMessage(INVALIDATE);
-        }
-    }
-
-    /**
-     * Quit animation.
-     */
-    public void stopAnimating() {
-        mHandler.removeMessages(INVALIDATE);
-    }
-
-    /**
-     * Read a two-byte integer from the input stream.
-     */
-    private int readInt16(InputStream is) throws IOException {
-        int lo = is.read();
-        int hi = is.read();
-        return (hi << 8) | lo;
-    }
-
-    /**
-     * Returns the offset from UTC for the given city.  If USE_RAW_OFFSETS
-     * is true, summer/daylight savings is ignored.
-     */
-    private static float getOffset(City c) {
-        return USE_RAW_OFFSETS ? c.getRawOffset() : c.getOffset();
-    }
-
-    private InputStream cache(InputStream is) throws IOException {
-        int nbytes = is.available();
-        byte[] data = new byte[nbytes];
-        int nread = 0;
-        while (nread < nbytes) {
-            nread += is.read(data, nread, nbytes - nread);
-        }
-        return new ByteArrayInputStream(data);
-    }
-
-    /**
-     * Load the city and lights databases.
-     *
-     * @param am the AssetManager to load from.
-     */
-    private void loadAssets(final AssetManager am) throws IOException {
-        Locale locale = Locale.getDefault();
-        String language = locale.getLanguage();
-        String country = locale.getCountry();
-
-        InputStream cis = null;
-        try {
-            // Look for (e.g.) cities_fr_FR.dat or cities_fr_CA.dat
-            cis = am.open("cities_" + language + "_" + country + ".dat");
-        } catch (FileNotFoundException e1) {
-            try {
-                // Look for (e.g.) cities_fr.dat or cities_fr.dat
-                cis = am.open("cities_" + language + ".dat");
-            } catch (FileNotFoundException e2) {
-                try {
-                    // Use English city names by default
-                    cis = am.open("cities_en.dat");
-                } catch (FileNotFoundException e3) {
-                    throw e3;
-                }
-            }
-        }
-
-        cis = cache(cis);
-        City.loadCities(cis);
-        City[] cities;
-        if (USE_RAW_OFFSETS) {
-            cities = City.getCitiesByRawOffset();
-        } else {
-            cities = City.getCitiesByOffset();
-        }
-
-        mClockCities = new ArrayList<City>(cities.length);
-        for (int i = 0; i < cities.length; i++) {
-            mClockCities.add(cities[i]);
-        }
-        mCities = mClockCities;
-        mCityIndex = 0;
-
-        this.mWorld = new Object3D() {
-                @Override
-                public InputStream readFile(String filename)
-                    throws IOException {
-                    return cache(am.open(filename));
-                }
-            };
-
-        mWorld.load("world.gles");
-
-        // lights.dat has the following format.  All integers
-        // are 16 bits, low byte first.
-        //
-        // width
-        // height
-        // N [# of lights]
-        // light 0 X [in the range 0 to (width - 1)]
-        // light 0 Y ]in the range 0 to (height - 1)]
-        // light 1 X [in the range 0 to (width - 1)]
-        // light 1 Y ]in the range 0 to (height - 1)]
-        // ...
-        // light (N - 1) X [in the range 0 to (width - 1)]
-        // light (N - 1) Y ]in the range 0 to (height - 1)]
-        //
-        // For a larger number of lights, it could make more
-        // sense to store the light positions in a bitmap
-        // and extract them manually
-        InputStream lis = am.open("lights.dat");
-        lis = cache(lis);
-
-        int lightWidth = readInt16(lis);
-        int lightHeight = readInt16(lis);
-        sNumLights = readInt16(lis);
-        sLightCoords = new int[3 * sNumLights];
-
-        int lidx = 0;
-        float lightRadius = 1.009f;
-        float lightScale = 65536.0f * lightRadius;
-
-        float[] cosTheta = new float[lightWidth];
-        float[] sinTheta = new float[lightWidth];
-        float twoPi = (float) (2.0 * Math.PI);
-        float scaleW = twoPi / lightWidth;
-        for (int i = 0; i < lightWidth; i++) {
-            float theta = twoPi - i * scaleW;
-            cosTheta[i] = (float)Math.cos(theta);
-            sinTheta[i] = (float)Math.sin(theta);
-        }
-
-        float[] cosPhi = new float[lightHeight];
-        float[] sinPhi = new float[lightHeight];
-        float scaleH = (float) (Math.PI / lightHeight);
-        for (int j = 0; j < lightHeight; j++) {
-            float phi = j * scaleH;
-            cosPhi[j] = (float)Math.cos(phi);
-            sinPhi[j] = (float)Math.sin(phi);
-        }
-
-        int nbytes = 4 * sNumLights;
-        byte[] ilights = new byte[nbytes];
-        int nread = 0;
-        while (nread < nbytes) {
-            nread += lis.read(ilights, nread, nbytes - nread);
-        }
-
-        int idx = 0;
-        for (int i = 0; i < sNumLights; i++) {
-            int lx = (((ilights[idx + 1] & 0xff) << 8) |
-                       (ilights[idx    ] & 0xff));
-            int ly = (((ilights[idx + 3] & 0xff) << 8) |
-                       (ilights[idx + 2] & 0xff));
-            idx += 4;
-
-            float sin = sinPhi[ly];
-            float x = cosTheta[lx]*sin;
-            float y = cosPhi[ly];
-            float z = sinTheta[lx]*sin;
-
-            sLightCoords[lidx++] = (int) (x * lightScale);
-            sLightCoords[lidx++] = (int) (y * lightScale);
-            sLightCoords[lidx++] = (int) (z * lightScale);
-        }
-        mLights = new PointCloud(sLightCoords);
-    }
-
-    /**
-     * Returns true if two time zone offsets are equal.  We assume distinct
-     * time zone offsets will differ by at least a few minutes.
-     */
-    private boolean tzEqual(float o1, float o2) {
-        return Math.abs(o1 - o2) < 0.001;
-    }
-
-    /**
-     * Move to a different time zone.
-     *
-     * @param incr The increment between the current and future time zones.
-     */
-    private void shiftTimeZone(int incr) {
-        // If only 1 city in the current set, there's nowhere to go
-        if (mCities.size() <= 1) {
-            return;
-        }
-
-        float offset = getOffset(mCities.get(mCityIndex));
-        do {
-            mCityIndex = (mCityIndex + mCities.size() + incr) % mCities.size();
-        } while (tzEqual(getOffset(mCities.get(mCityIndex)), offset));
-
-        offset = getOffset(mCities.get(mCityIndex));
-        locateCity(true, offset);
-        goToCity();
-    }
-
-    /**
-     * Returns true if there is another city within the current time zone
-     * that is the given increment away from the current city.
-     *
-     * @param incr the increment, +1 or -1
-     * @return
-     */
-    private boolean atEndOfTimeZone(int incr) {
-        if (mCities.size() <= 1) {
-            return true;
-        }
-
-        float offset = getOffset(mCities.get(mCityIndex));
-        int nindex = (mCityIndex + mCities.size() + incr) % mCities.size();
-        if (tzEqual(getOffset(mCities.get(nindex)), offset)) {
-            return false;
-        }
-        return true;
-    }
-
-    /**
-     * Shifts cities within the current time zone.
-     *
-     * @param incr the increment, +1 or -1
-     */
-    private void shiftWithinTimeZone(int incr) {
-        float offset = getOffset(mCities.get(mCityIndex));
-        int nindex = (mCityIndex + mCities.size() + incr) % mCities.size();
-        if (tzEqual(getOffset(mCities.get(nindex)), offset)) {
-            mCityIndex = nindex;
-            goToCity();
-        }
-    }
-
-    /**
-     * Returns true if the city name matches the given prefix, ignoring spaces.
-     */
-    private boolean nameMatches(City city, String prefix) {
-        String cityName = city.getName().replaceAll("[ ]", "");
-        return prefix.regionMatches(true, 0,
-                                    cityName, 0,
-                                    prefix.length());
-    }
-
-    /**
-     * Returns true if there are cities matching the given name prefix.
-     */
-    private boolean hasMatches(String prefix) {
-        for (int i = 0; i < mClockCities.size(); i++) {
-            City city = mClockCities.get(i);
-            if (nameMatches(city, prefix)) {
-                return true;
-            }
-        }
-
-        return false;
-    }
-
-    /**
-     * Shifts to the nearest city that matches the new prefix.
-     */
-    private void shiftByName() {
-        // Attempt to keep current city if it matches
-        City finalCity = null;
-        City currCity = mCities.get(mCityIndex);
-        if (nameMatches(currCity, mCityName)) {
-            finalCity = currCity;
-        }
-
-        mCityNameMatches.clear();
-        for (int i = 0; i < mClockCities.size(); i++) {
-            City city = mClockCities.get(i);
-            if (nameMatches(city, mCityName)) {
-                mCityNameMatches.add(city);
-            }
-        }
-
-        mCities = mCityNameMatches;
-
-        if (finalCity != null) {
-            for (int i = 0; i < mCityNameMatches.size(); i++) {
-                if (mCityNameMatches.get(i) == finalCity) {
-                    mCityIndex = i;
-                    break;
-                }
-            }
-        } else {
-            // Find the closest matching city
-            locateCity(false, 0.0f);
-        }
-        goToCity();
-    }
-
-    /**
-     * Increases or decreases the rotational speed of the earth.
-     */
-    private void incrementRotationalVelocity(float incr) {
-        if (mDisplayWorldFlat) {
-            mWrapVelocity -= incr;
-        } else {
-            mRotVelocity -= incr;
-        }
-    }
-
-    /**
-     * Clears the current matching prefix, while keeping the focus on
-     * the current city.
-     */
-    private void clearCityMatches() {
-        // Determine the global city index that matches the current city
-        if (mCityNameMatches.size() > 0) {
-            City city = mCityNameMatches.get(mCityIndex);
-            for (int i = 0; i < mClockCities.size(); i++) {
-                City ncity = mClockCities.get(i);
-                if (city.equals(ncity)) {
-                    mCityIndex = i;
-                    break;
-                }
-            }
-        }
-
-        mCityName = "";
-        mCityNameMatches.clear();
-        mCities = mClockCities;
-        goToCity();
-    }
-
-    /**
-     * Fade the clock in or out.
-     */
-    private void enableClock(boolean enabled) {
-        mClockFadeTime = System.currentTimeMillis();
-        mDisplayClock = enabled;
-        mClockShowing = true;
-        mAlphaKeySet = enabled;
-        if (enabled) {
-            // Find the closest matching city
-            locateCity(false, 0.0f);
-        }
-        clearCityMatches();
-    }
-
-    /**
-     * Use the touchscreen to alter the rotational velocity or the
-     * tilt of the earth.
-     */
-    @Override public boolean onTouchEvent(MotionEvent event) {
-        switch (event.getAction()) {
-            case MotionEvent.ACTION_DOWN:
-                mMotionStartX = event.getX();
-                mMotionStartY = event.getY();
-                mMotionStartRotVelocity = mDisplayWorldFlat ?
-                    mWrapVelocity : mRotVelocity;
-                mMotionStartTiltAngle = mTiltAngle;
-
-                // Stop the rotation
-                if (mDisplayWorldFlat) {
-                    mWrapVelocity = 0.0f;
-                } else {
-                    mRotVelocity = 0.0f;
-                }
-                mMotionDirection = MOTION_NONE;
-                break;
-
-            case MotionEvent.ACTION_MOVE:
-                // Disregard motion events when the clock is displayed
-                float dx = event.getX() - mMotionStartX;
-                float dy = event.getY() - mMotionStartY;
-                float delx = Math.abs(dx);
-                float dely = Math.abs(dy);
-
-                // Determine the direction of motion (major axis)
-                // Once if has been determined, it's locked in until
-                // we receive ACTION_UP or ACTION_CANCEL
-                if ((mMotionDirection == MOTION_NONE) &&
-                    (delx + dely > MIN_MANHATTAN_DISTANCE)) {
-                    if (delx > dely) {
-                        mMotionDirection = MOTION_X;
-                    } else {
-                        mMotionDirection = MOTION_Y;
-                    }
-                }
-
-                // If the clock is displayed, don't actually rotate or tilt;
-                // just use mMotionDirection to record whether motion occurred
-                if (!mDisplayClock) {
-                    if (mMotionDirection == MOTION_X) {
-                        if (mDisplayWorldFlat) {
-                            mWrapVelocity = mMotionStartRotVelocity +
-                                dx * ROTATION_FACTOR;
-                        } else {
-                            mRotVelocity = mMotionStartRotVelocity +
-                                dx * ROTATION_FACTOR;
-                        }
-                        mClock.setCity(null);
-                    } else if (mMotionDirection == MOTION_Y &&
-                        !mDisplayWorldFlat) {
-                        mTiltAngle = mMotionStartTiltAngle + dy * TILT_FACTOR;
-                        if (mTiltAngle < -90.0f) {
-                            mTiltAngle = -90.0f;
-                        }
-                        if (mTiltAngle > 90.0f) {
-                            mTiltAngle = 90.0f;
-                        }
-                        mClock.setCity(null);
-                    }
-                }
-                break;
-
-            case MotionEvent.ACTION_UP:
-                mMotionDirection = MOTION_NONE;
-                break;
-
-            case MotionEvent.ACTION_CANCEL:
-                mTiltAngle = mMotionStartTiltAngle;
-                if (mDisplayWorldFlat) {
-                    mWrapVelocity = mMotionStartRotVelocity;
-                } else {
-                    mRotVelocity = mMotionStartRotVelocity;
-                }
-                mMotionDirection = MOTION_NONE;
-                break;
-        }
-        return true;
-    }
-
-    @Override public boolean onKeyDown(int keyCode, KeyEvent event) {
-        if (mInitialized && mGLView.processKey(keyCode)) {
-            boolean drawing = (mClockShowing || mGLView.hasMessages());
-            this.setWillNotDraw(!drawing);
-            return true;
-        }
-
-        boolean handled = false;
-
-        // If we're not in alphabetical entry mode, convert letters
-        // to their digit equivalents
-        if (!mAlphaKeySet) {
-            char numChar = event.getNumber();
-            if (numChar >= '0' && numChar <= '9') {
-                keyCode = KeyEvent.KEYCODE_0 + (numChar - '0');
-            }
-        }
-
-        switch (keyCode) {
-        // The 'space' key toggles the clock
-        case KeyEvent.KEYCODE_SPACE:
-            mAlphaKeySet = !mAlphaKeySet;
-            enableClock(mAlphaKeySet);
-            handled = true;
-            break;
-
-        // The 'left' and 'right' buttons shift time zones if the clock is
-        // displayed, otherwise they alters the rotational speed of the earthh
-        case KeyEvent.KEYCODE_DPAD_LEFT:
-            if (mDisplayClock) {
-                shiftTimeZone(-1);
-            } else {
-                mClock.setCity(null);
-                incrementRotationalVelocity(1.0f);
-            }
-            handled = true;
-            break;
-
-        case KeyEvent.KEYCODE_DPAD_RIGHT:
-            if (mDisplayClock) {
-                shiftTimeZone(1);
-            } else {
-                mClock.setCity(null);
-                incrementRotationalVelocity(-1.0f);
-            }
-            handled = true;
-            break;
-
-        // The 'up' and 'down' buttons shift cities within a time zone if the
-        // clock is displayed, otherwise they tilt the earth
-        case KeyEvent.KEYCODE_DPAD_UP:
-            if (mDisplayClock) {
-                shiftWithinTimeZone(-1);
-            } else {
-                mClock.setCity(null);
-                if (!mDisplayWorldFlat) {
-                    mTiltAngle += 360.0f / 48.0f;
-                }
-            }
-            handled = true;
-            break;
-
-        case KeyEvent.KEYCODE_DPAD_DOWN:
-            if (mDisplayClock) {
-                shiftWithinTimeZone(1);
-            } else {
-                mClock.setCity(null);
-                if (!mDisplayWorldFlat) {
-                    mTiltAngle -= 360.0f / 48.0f;
-                }
-            }
-            handled = true;
-            break;
-
-        // The center key stops the earth's rotation, then toggles between the
-        // round and flat views of the earth
-        case KeyEvent.KEYCODE_DPAD_CENTER:
-            if ((!mDisplayWorldFlat && mRotVelocity == 0.0f) ||
-                (mDisplayWorldFlat && mWrapVelocity == 0.0f)) {
-                mDisplayWorldFlat = !mDisplayWorldFlat;
-            } else {
-                if (mDisplayWorldFlat) {
-                    mWrapVelocity = 0.0f;
-                } else {
-                    mRotVelocity = 0.0f;
-                }
-            }
-            handled = true;
-            break;
-
-        // The 'L' key toggles the city lights
-        case KeyEvent.KEYCODE_L:
-            if (!mAlphaKeySet && !mDisplayWorldFlat) {
-                mDisplayLights = !mDisplayLights;
-                handled = true;
-            }
-            break;
-
-
-        // The 'W' key toggles the earth (just for fun)
-        case KeyEvent.KEYCODE_W:
-            if (!mAlphaKeySet && !mDisplayWorldFlat) {
-                mDisplayWorld = !mDisplayWorld;
-                handled = true;
-            }
-            break;
-
-        // The 'A' key toggles the atmosphere
-        case KeyEvent.KEYCODE_A:
-            if (!mAlphaKeySet && !mDisplayWorldFlat) {
-                mDisplayAtmosphere = !mDisplayAtmosphere;
-                handled = true;
-            }
-            break;
-
-        // The '2' key zooms out
-        case KeyEvent.KEYCODE_2:
-            if (!mAlphaKeySet && !mDisplayWorldFlat && mInitialized) {
-                mGLView.zoom(-2);
-                handled = true;
-            }
-            break;
-
-        // The '8' key zooms in
-        case KeyEvent.KEYCODE_8:
-            if (!mAlphaKeySet && !mDisplayWorldFlat && mInitialized) {
-                mGLView.zoom(2);
-                handled = true;
-            }
-            break;
-        }
-
-        // Handle letters in city names
-        if (!handled && mAlphaKeySet) {
-            switch (keyCode) {
-            // Add a letter to the city name prefix
-            case KeyEvent.KEYCODE_A:
-            case KeyEvent.KEYCODE_B:
-            case KeyEvent.KEYCODE_C:
-            case KeyEvent.KEYCODE_D:
-            case KeyEvent.KEYCODE_E:
-            case KeyEvent.KEYCODE_F:
-            case KeyEvent.KEYCODE_G:
-            case KeyEvent.KEYCODE_H:
-            case KeyEvent.KEYCODE_I:
-            case KeyEvent.KEYCODE_J:
-            case KeyEvent.KEYCODE_K:
-            case KeyEvent.KEYCODE_L:
-            case KeyEvent.KEYCODE_M:
-            case KeyEvent.KEYCODE_N:
-            case KeyEvent.KEYCODE_O:
-            case KeyEvent.KEYCODE_P:
-            case KeyEvent.KEYCODE_Q:
-            case KeyEvent.KEYCODE_R:
-            case KeyEvent.KEYCODE_S:
-            case KeyEvent.KEYCODE_T:
-            case KeyEvent.KEYCODE_U:
-            case KeyEvent.KEYCODE_V:
-            case KeyEvent.KEYCODE_W:
-            case KeyEvent.KEYCODE_X:
-            case KeyEvent.KEYCODE_Y:
-            case KeyEvent.KEYCODE_Z:
-                char c = (char)(keyCode - KeyEvent.KEYCODE_A + 'A');
-                if (hasMatches(mCityName + c)) {
-                    mCityName += c;
-                    shiftByName();
-                }
-                handled = true;
-                break;
-
-            // Remove a letter from the city name prefix
-            case KeyEvent.KEYCODE_DEL:
-                if (mCityName.length() > 0) {
-                    mCityName = mCityName.substring(0, mCityName.length() - 1);
-                    shiftByName();
-                } else {
-                    clearCityMatches();
-                }
-                handled = true;
-                break;
-
-            // Clear the city name prefix
-            case KeyEvent.KEYCODE_ENTER:
-                clearCityMatches();
-                handled = true;
-                break;
-            }
-        }
-
-        boolean drawing = (mClockShowing ||
-            ((mGLView != null) && (mGLView.hasMessages())));
-        this.setWillNotDraw(!drawing);
-
-        // Let the system handle other keypresses
-        if (!handled) {
-            return super.onKeyDown(keyCode, event);
-        }
-        return true;
-    }
-
-    /**
-     * Initialize OpenGL ES drawing.
-     */
-    private synchronized void init(GL10 gl) {
-        mGLView = new GLView();
-        mGLView.setNearFrustum(5.0f);
-        mGLView.setFarFrustum(50.0f);
-        mGLView.setLightModelAmbientIntensity(0.225f);
-        mGLView.setAmbientIntensity(0.0f);
-        mGLView.setDiffuseIntensity(1.5f);
-        mGLView.setDiffuseColor(SUNLIGHT_COLOR);
-        mGLView.setSpecularIntensity(0.0f);
-        mGLView.setSpecularColor(SUNLIGHT_COLOR);
-
-        if (PERFORM_DEPTH_TEST) {
-            gl.glEnable(GL10.GL_DEPTH_TEST);
-        }
-        gl.glDisable(GL10.GL_SCISSOR_TEST);
-        gl.glClearColor(0, 0, 0, 1);
-        gl.glHint(GL10.GL_POINT_SMOOTH_HINT, GL10.GL_NICEST);
-
-        mInitialized = true;
-    }
-
-    /**
-     * Computes the vector from the center of the earth to the sun for a
-     * particular moment in time.
-     */
-    private void computeSunDirection() {
-        mSunCal.setTimeInMillis(System.currentTimeMillis());
-        int day = mSunCal.get(Calendar.DAY_OF_YEAR);
-        int seconds = 3600 * mSunCal.get(Calendar.HOUR_OF_DAY) +
-            60 * mSunCal.get(Calendar.MINUTE) + mSunCal.get(Calendar.SECOND);
-        day += (float) seconds / SECONDS_PER_DAY;
-
-        // Approximate declination of the sun, changes sinusoidally
-        // during the year.  The winter solstice occurs 10 days before
-        // the start of the year.
-        float decl = (float) (EARTH_INCLINATION *
-            Math.cos(Shape.TWO_PI * (day + 10) / 365.0));
-
-        // Subsolar latitude, convert from (-PI/2, PI/2) -> (0, PI) form
-        float phi = decl + Shape.PI_OVER_TWO;
-        // Subsolar longitude
-        float theta = Shape.TWO_PI * seconds / SECONDS_PER_DAY;
-
-        float sinPhi = (float) Math.sin(phi);
-        float cosPhi = (float) Math.cos(phi);
-        float sinTheta = (float) Math.sin(theta);
-        float cosTheta = (float) Math.cos(theta);
-
-        // Convert from polar to rectangular coordinates
-        float x = cosTheta * sinPhi;
-        float y = cosPhi;
-        float z = sinTheta * sinPhi;
-
-        // Directional light -> w == 0
-        mLightDir[0] = x;
-        mLightDir[1] = y;
-        mLightDir[2] = z;
-        mLightDir[3] = 0.0f;
-    }
-
-    /**
-     * Computes the approximate spherical distance between two
-     * (latitude, longitude) coordinates.
-     */
-    private float distance(float lat1, float lon1,
-                           float lat2, float lon2) {
-        lat1 *= Shape.DEGREES_TO_RADIANS;
-        lat2 *= Shape.DEGREES_TO_RADIANS;
-        lon1 *= Shape.DEGREES_TO_RADIANS;
-        lon2 *= Shape.DEGREES_TO_RADIANS;
-
-        float r = 6371.0f; // Earth's radius in km
-        float dlat = lat2 - lat1;
-        float dlon = lon2 - lon1;
-        double sinlat2 = Math.sin(dlat / 2.0f);
-        sinlat2 *= sinlat2;
-        double sinlon2 = Math.sin(dlon / 2.0f);
-        sinlon2 *= sinlon2;
-
-        double a = sinlat2 + Math.cos(lat1) * Math.cos(lat2) * sinlon2;
-        double c = 2.0 * Math.atan2(Math.sqrt(a), Math.sqrt(1 - a));
-        return (float) (r * c);
-    }
-
-    /**
-     * Locates the closest city to the currently displayed center point,
-     * optionally restricting the search to cities within a given time zone.
-     */
-    private void locateCity(boolean useOffset, float offset) {
-        float mindist = Float.MAX_VALUE;
-        int minidx = -1;
-        for (int i = 0; i < mCities.size(); i++) {
-            City city = mCities.get(i);
-            if (useOffset && !tzEqual(getOffset(city), offset)) {
-                continue;
-            }
-            float dist = distance(city.getLatitude(), city.getLongitude(),
-                mTiltAngle, mRotAngle - 90.0f);
-            if (dist < mindist) {
-                mindist = dist;
-                minidx = i;
-            }
-        }
-
-        mCityIndex = minidx;
-    }
-
-    /**
-     * Animates the earth to be centered at the current city.
-     */
-    private void goToCity() {
-        City city = mCities.get(mCityIndex);
-        float dist = distance(city.getLatitude(), city.getLongitude(),
-            mTiltAngle, mRotAngle - 90.0f);
-
-        mFlyToCity = true;
-        mCityFlyStartTime = System.currentTimeMillis();
-        mCityFlightTime = dist / 5.0f; // 5000 km/sec
-        mRotAngleStart = mRotAngle;
-        mRotAngleDest = city.getLongitude() + 90;
-
-        if (mRotAngleDest - mRotAngleStart > 180.0f) {
-            mRotAngleDest -= 360.0f;
-        } else if (mRotAngleStart - mRotAngleDest > 180.0f) {
-            mRotAngleDest += 360.0f;
-        }
-
-        mTiltAngleStart = mTiltAngle;
-        mTiltAngleDest = city.getLatitude();
-        mRotVelocity = 0.0f;
-    }
-
-    /**
-     * Returns a linearly interpolated value between two values.
-     */
-    private float lerp(float a, float b, float lerp) {
-        return a + (b - a)*lerp;
-    }
-
-    /**
-     * Draws the city lights, using a clip plane to restrict the lights
-     * to the night side of the earth.
-     */
-    private void drawCityLights(GL10 gl, float brightness) {
-        gl.glEnable(GL10.GL_POINT_SMOOTH);
-        gl.glDisable(GL10.GL_DEPTH_TEST);
-        gl.glDisable(GL10.GL_LIGHTING);
-        gl.glDisable(GL10.GL_DITHER);
-        gl.glShadeModel(GL10.GL_FLAT);
-        gl.glEnable(GL10.GL_BLEND);
-        gl.glBlendFunc(GL10.GL_SRC_ALPHA, GL10.GL_ONE_MINUS_SRC_ALPHA);
-        gl.glPointSize(1.0f);
-
-        float ls = lerp(0.8f, 0.3f, brightness);
-        gl.glColor4f(ls * 1.0f, ls * 1.0f, ls * 0.8f, 1.0f);
-
-        if (mDisplayWorld) {
-            mClipPlaneEquation[0] = -mLightDir[0];
-            mClipPlaneEquation[1] = -mLightDir[1];
-            mClipPlaneEquation[2] = -mLightDir[2];
-            mClipPlaneEquation[3] = 0.0f;
-            // Assume we have glClipPlanef() from OpenGL ES 1.1
-            ((GL11) gl).glClipPlanef(GL11.GL_CLIP_PLANE0,
-                mClipPlaneEquation, 0);
-            gl.glEnable(GL11.GL_CLIP_PLANE0);
-        }
-        mLights.draw(gl);
-        if (mDisplayWorld) {
-            gl.glDisable(GL11.GL_CLIP_PLANE0);
-        }
-
-        mNumTriangles += mLights.getNumTriangles()*2;
-    }
-
-    /**
-     * Draws the atmosphere.
-     */
-    private void drawAtmosphere(GL10 gl) {
-        gl.glDisable(GL10.GL_LIGHTING);
-        gl.glDisable(GL10.GL_CULL_FACE);
-        gl.glDisable(GL10.GL_DITHER);
-        gl.glDisable(GL10.GL_DEPTH_TEST);
-        gl.glShadeModel(mSmoothShading ? GL10.GL_SMOOTH : GL10.GL_FLAT);
-
-        // Draw the atmospheric layer
-        float tx = mGLView.getTranslateX();
-        float ty = mGLView.getTranslateY();
-        float tz = mGLView.getTranslateZ();
-
-        gl.glMatrixMode(GL10.GL_MODELVIEW);
-        gl.glLoadIdentity();
-        gl.glTranslatef(tx, ty, tz);
-
-        // Blend in the atmosphere a bit
-        gl.glEnable(GL10.GL_BLEND);
-        gl.glBlendFunc(GL10.GL_SRC_ALPHA, GL10.GL_ONE_MINUS_SRC_ALPHA);
-        ATMOSPHERE.draw(gl);
-
-        mNumTriangles += ATMOSPHERE.getNumTriangles();
-    }
-
-    /**
-     * Draws the world in a 2D map view.
-     */
-    private void drawWorldFlat(GL10 gl) {
-        gl.glDisable(GL10.GL_BLEND);
-        gl.glEnable(GL10.GL_DITHER);
-        gl.glShadeModel(mSmoothShading ? GL10.GL_SMOOTH : GL10.GL_FLAT);
-
-        gl.glTranslatef(mWrapX - 2, 0.0f, 0.0f);
-        worldFlat.draw(gl);
-        gl.glTranslatef(2.0f, 0.0f, 0.0f);
-        worldFlat.draw(gl);
-        mNumTriangles += worldFlat.getNumTriangles() * 2;
-
-        mWrapX += mWrapVelocity * mWrapVelocityFactor;
-        while (mWrapX < 0.0f) {
-            mWrapX += 2.0f;
-        }
-        while (mWrapX > 2.0f) {
-            mWrapX -= 2.0f;
-        }
-    }
-
-    /**
-     * Draws the world in a 2D round view.
-     */
-    private void drawWorldRound(GL10 gl) {
-        gl.glDisable(GL10.GL_BLEND);
-        gl.glEnable(GL10.GL_DITHER);
-        gl.glShadeModel(mSmoothShading ? GL10.GL_SMOOTH : GL10.GL_FLAT);
-
-        mWorld.draw(gl);
-        mNumTriangles += mWorld.getNumTriangles();
-    }
-
-    /**
-     * Draws the clock.
-     *
-     * @param canvas the Canvas to draw to
-     * @param now the current time
-     * @param w the width of the screen
-     * @param h the height of the screen
-     * @param lerp controls the animation, between 0.0 and 1.0
-     */
-    private void drawClock(Canvas canvas,
-                           long now,
-                           int w, int h,
-                           float lerp) {
-        float clockAlpha = lerp(0.0f, 0.8f, lerp);
-        mClockShowing = clockAlpha > 0.0f;
-        if (clockAlpha > 0.0f) {
-            City city = mCities.get(mCityIndex);
-            mClock.setCity(city);
-            mClock.setTime(now);
-
-            float cx = w / 2.0f;
-            float cy = h / 2.0f;
-            float smallRadius = 18.0f;
-            float bigRadius = 0.75f * 0.5f * Math.min(w, h);
-            float radius = lerp(smallRadius, bigRadius, lerp);
-
-            // Only display left/right arrows if we are in a name search
-            boolean scrollingByName =
-                (mCityName.length() > 0) && (mCities.size() > 1);
-            mClock.drawClock(canvas, cx, cy, radius,
-                             clockAlpha,
-                             1.0f,
-                             lerp == 1.0f, lerp == 1.0f,
-                             !atEndOfTimeZone(-1),
-                             !atEndOfTimeZone(1),
-                             scrollingByName,
-                             mCityName.length());
-        }
-    }
-
-    /**
-     * Draws the 2D layer.
-     */
-    @Override protected void onDraw(Canvas canvas) {
-        long now = System.currentTimeMillis();
-        if (startTime != -1) {
-            startTime = -1;
-        }
-
-        int w = getWidth();
-        int h = getHeight();
-
-        // Interpolator for clock size, clock alpha, night lights intensity
-        float lerp = Math.min((now - mClockFadeTime)/1000.0f, 1.0f);
-        if (!mDisplayClock) {
-            // Clock is receding
-            lerp = 1.0f - lerp;
-        }
-        lerp = mClockSizeInterpolator.getInterpolation(lerp);
-
-        // we don't need to make sure OpenGL rendering is done because
-        // we're drawing in to a different surface
-
-        drawClock(canvas, now, w, h, lerp);
-
-        mGLView.showMessages(canvas);
-        mGLView.showStatistics(canvas, w);
-    }
-
-    /**
-     * Draws the 3D layer.
-     */
-    protected void drawOpenGLScene() {
-        long now = System.currentTimeMillis();
-        mNumTriangles = 0;
-
-        EGL10 egl = (EGL10)EGLContext.getEGL();
-        GL10 gl = (GL10)mEGLContext.getGL();
-
-        if (!mInitialized) {
-            init(gl);
-        }
-
-        int w = getWidth();
-        int h = getHeight();
-        gl.glViewport(0, 0, w, h);
-
-        gl.glEnable(GL10.GL_LIGHTING);
-        gl.glEnable(GL10.GL_LIGHT0);
-        gl.glEnable(GL10.GL_CULL_FACE);
-        gl.glFrontFace(GL10.GL_CCW);
-
-        float ratio = (float) w / h;
-        mGLView.setAspectRatio(ratio);
-
-        mGLView.setTextureParameters(gl);
-
-        if (PERFORM_DEPTH_TEST) {
-            gl.glClear(GL10.GL_COLOR_BUFFER_BIT | GL10.GL_DEPTH_BUFFER_BIT);
-        } else {
-            gl.glClear(GL10.GL_COLOR_BUFFER_BIT);
-        }
-
-        if (mDisplayWorldFlat) {
-            gl.glMatrixMode(GL10.GL_PROJECTION);
-            gl.glLoadIdentity();
-            gl.glFrustumf(-1.0f, 1.0f, -1.0f / ratio, 1.0f / ratio, 1.0f, 2.0f);
-            gl.glMatrixMode(GL10.GL_MODELVIEW);
-            gl.glLoadIdentity();
-            gl.glTranslatef(0.0f, 0.0f, -1.0f);
-        } else {
-            mGLView.setProjection(gl);
-            mGLView.setView(gl);
-        }
-
-        if (!mDisplayWorldFlat) {
-            if (mFlyToCity) {
-                float lerp = (now - mCityFlyStartTime)/mCityFlightTime;
-                if (lerp >= 1.0f) {
-                    mFlyToCity = false;
-                }
-                lerp = Math.min(lerp, 1.0f);
-                lerp = mFlyToCityInterpolator.getInterpolation(lerp);
-                mRotAngle = lerp(mRotAngleStart, mRotAngleDest, lerp);
-                mTiltAngle = lerp(mTiltAngleStart, mTiltAngleDest, lerp);
-            }
-
-            // Rotate the viewpoint around the earth
-            gl.glMatrixMode(GL10.GL_MODELVIEW);
-            gl.glRotatef(mTiltAngle, 1, 0, 0);
-            gl.glRotatef(mRotAngle, 0, 1, 0);
-
-            // Increment the rotation angle
-            mRotAngle += mRotVelocity;
-            if (mRotAngle < 0.0f) {
-                mRotAngle += 360.0f;
-            }
-            if (mRotAngle > 360.0f) {
-                mRotAngle -= 360.0f;
-            }
-        }
-
-        // Draw the world with lighting
-        gl.glLightfv(GL10.GL_LIGHT0, GL10.GL_POSITION, mLightDir, 0);
-        mGLView.setLights(gl, GL10.GL_LIGHT0);
-
-        if (mDisplayWorldFlat) {
-            drawWorldFlat(gl);
-        } else if (mDisplayWorld) {
-            drawWorldRound(gl);
-        }
-
-        if (mDisplayLights && !mDisplayWorldFlat) {
-            // Interpolator for clock size, clock alpha, night lights intensity
-            float lerp = Math.min((now - mClockFadeTime)/1000.0f, 1.0f);
-            if (!mDisplayClock) {
-                // Clock is receding
-                lerp = 1.0f - lerp;
-            }
-            lerp = mClockSizeInterpolator.getInterpolation(lerp);
-            drawCityLights(gl, lerp);
-        }
-
-        if (mDisplayAtmosphere && !mDisplayWorldFlat) {
-            drawAtmosphere(gl);
-        }
-        mGLView.setNumTriangles(mNumTriangles);
-        egl.eglSwapBuffers(mEGLDisplay, mEGLSurface);
-
-        if (egl.eglGetError() == EGL11.EGL_CONTEXT_LOST) {
-            // we lost the gpu, quit immediately
-            Context c = getContext();
-            if (c instanceof Activity) {
-                ((Activity)c).finish();
-            }
-        }
-    }
-
-
-    private static final int INVALIDATE = 1;
-    private static final int ONE_MINUTE = 60000;
-
-    /**
-     * Controls the animation using the message queue.  Every time we receive
-     * an INVALIDATE message, we redraw and place another message in the queue.
-     */
-    private final Handler mHandler = new Handler() {
-        private long mLastSunPositionTime = 0;
-
-        @Override public void handleMessage(Message msg) {
-            if (msg.what == INVALIDATE) {
-
-                // Use the message's time, it's good enough and
-                // allows us to avoid a system call.
-                if ((msg.getWhen() - mLastSunPositionTime) >= ONE_MINUTE) {
-                    // Recompute the sun's position once per minute
-                    // Place the light at the Sun's direction
-                    computeSunDirection();
-                    mLastSunPositionTime = msg.getWhen();
-                }
-
-                // Draw the GL scene
-                drawOpenGLScene();
-
-                // Send an update for the 2D overlay if needed
-                if (mInitialized &&
-                                (mClockShowing || mGLView.hasMessages())) {
-                    invalidate();
-                }
-
-                // Just send another message immediately. This works because
-                // drawOpenGLScene() does the timing for us -- it will
-                // block until the last frame has been processed.
-                // The invalidate message we're posting here will be
-                // interleaved properly with motion/key events which
-                // guarantee a prompt reaction to the user input.
-                sendEmptyMessage(INVALIDATE);
-            }
-        }
-    };
-}
-
-/**
- * The main activity class for GlobalTime.
- */
-public class GlobalTime extends Activity {
-
-    GTView gtView = null;
-
-    @Override protected void onCreate(Bundle icicle) {
-        super.onCreate(icicle);
-        gtView = new GTView(this);
-        setContentView(gtView);
-    }
-
-    @Override protected void onResume() {
-        super.onResume();
-        gtView.onResume();
-        Looper.myQueue().addIdleHandler(new Idler());
-    }
-
-    @Override protected void onPause() {
-        super.onPause();
-        gtView.onPause();
-    }
-
-    @Override protected void onStop() {
-        super.onStop();
-        gtView.destroy();
-        gtView = null;
-    }
-
-    // Allow the activity to go idle before its animation starts
-    class Idler implements MessageQueue.IdleHandler {
-        public Idler() {
-            super();
-        }
-
-        public final boolean queueIdle() {
-            if (gtView != null) {
-                gtView.startAnimating();
-            }
-            return false;
-        }
-    }
-}
diff --git a/samples/GlobalTime/src/com/android/globaltime/LatLongSphere.java b/samples/GlobalTime/src/com/android/globaltime/LatLongSphere.java
deleted file mode 100644
index b455d41..0000000
--- a/samples/GlobalTime/src/com/android/globaltime/LatLongSphere.java
+++ /dev/null
@@ -1,118 +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.globaltime;
-
-public class LatLongSphere extends Sphere {
-
-    public LatLongSphere(float centerX, float centerY, float centerZ,
-        float radius, int lats, int longs,
-        float minLongitude, float maxLongitude,
-        boolean emitTextureCoordinates,
-        boolean emitNormals,
-        boolean emitColors,
-        boolean flatten) {
-        super(emitTextureCoordinates, emitNormals, emitColors);
-
-        int tris = 2 * (lats - 1) * (longs - 1);
-        int[] vertices = new int[3 * lats * longs];
-        int[] texcoords = new int[2 * lats * longs];
-        int[] colors = new int[4 * lats * longs];
-        int[] normals = new int[3 * lats * longs];
-        short[] indices = new short[3 * tris];
-
-        int vidx = 0;
-        int tidx = 0;
-        int nidx = 0;
-        int cidx = 0;
-        int iidx = 0;
-
-        minLongitude *= DEGREES_TO_RADIANS;
-        maxLongitude *= DEGREES_TO_RADIANS;
-
-        for (int i = 0; i < longs; i++) {
-            float fi = (float) i / (longs - 1);
-            // theta is the longitude
-            float theta =
-                (maxLongitude - minLongitude) * (1.0f - fi) + minLongitude;
-            float sinTheta = (float) Math.sin(theta);
-            float cosTheta = (float) Math.cos(theta);
-
-            for (int j = 0; j < lats; j++) {
-                float fj = (float) j / (lats - 1);
-                // phi is the latitude
-                float phi = PI * fj;
-                float sinPhi = (float) Math.sin(phi);
-                float cosPhi = (float) Math.cos(phi);
-                float x = cosTheta * sinPhi;
-                float y = cosPhi;
-                float z = sinTheta * sinPhi;
-
-                if (flatten) {
-                    // Place vertices onto a flat projection
-                    vertices[vidx++] = toFixed(2.0f * fi - 1.0f);
-                    vertices[vidx++] = toFixed(0.5f - fj);
-                    vertices[vidx++] = toFixed(0.0f);
-                } else {
-                    // Place vertices onto the surface of a sphere
-                    // with the given center and radius
-                    vertices[vidx++] = toFixed(x * radius + centerX);
-                    vertices[vidx++] = toFixed(y * radius + centerY);
-                    vertices[vidx++] = toFixed(z * radius + centerZ);
-                }
-
-                if (emitTextureCoordinates) {
-                    texcoords[tidx++] = toFixed(1.0f - (theta / (TWO_PI)));
-                    texcoords[tidx++] = toFixed(fj);
-                }
-
-                if (emitNormals) {
-                    float norm = 1.0f / Shape.length(x, y, z);
-                    normals[nidx++] = toFixed(x * norm);
-                    normals[nidx++] = toFixed(y * norm);
-                    normals[nidx++] = toFixed(z * norm);
-                }
-
-                // 0 == black, 65536 == white
-                if (emitColors) {
-                    colors[cidx++] = (i % 2) * 65536;
-                    colors[cidx++] = 0;
-                    colors[cidx++] = (j % 2) * 65536;
-                    colors[cidx++] = 65536;
-                }
-            }
-        }
-
-        for (int i = 0; i < longs - 1; i++) {
-            for (int j = 0; j < lats - 1; j++) {
-                int base = i * lats + j;
-
-                // Ensure both triangles have the same final vertex
-                // since this vertex carries the color for flat
-                // shading
-                indices[iidx++] = (short) (base);
-                indices[iidx++] = (short) (base + 1);
-                indices[iidx++] = (short) (base + lats + 1);
-
-                indices[iidx++] = (short) (base + lats);
-                indices[iidx++] = (short) (base);
-                indices[iidx++] = (short) (base + lats + 1);
-            }
-        }
-        
-        allocateBuffers(vertices, texcoords, normals, colors, indices);
-    }
-}
diff --git a/samples/GlobalTime/src/com/android/globaltime/PointCloud.java b/samples/GlobalTime/src/com/android/globaltime/PointCloud.java
deleted file mode 100644
index 6f4fd55..0000000
--- a/samples/GlobalTime/src/com/android/globaltime/PointCloud.java
+++ /dev/null
@@ -1,60 +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.globaltime;
-
-import javax.microedition.khronos.opengles.GL10;
-
-/**
- * A class representing a set of GL_POINT objects.  GlobalTime uses this class
- * to draw city lights on the night side of the earth.
- */
-public class PointCloud extends Shape {
-
-    /**
-     * Constructs a PointCloud with a point at each of the given vertex
-     * (x, y, z) positions.
-     * @param vertices an array of (x, y, z) positions given in fixed-point.
-     */
-    public PointCloud(int[] vertices) {
-        this(vertices, 0, vertices.length);
-    }
-
-    /**
-     * Constructs a PointCloud with a point at each of the given vertex
-     * (x, y, z) positions.
-     * @param vertices an array of (x, y, z) positions given in fixed-point.
-     * @param off the starting offset of the vertices array
-     * @param len the number of elements of the vertices array to use
-     */
-    public PointCloud(int[] vertices, int off, int len) {
-        super(GL10.GL_POINTS, GL10.GL_UNSIGNED_SHORT,
-              false, false, false);
-
-        int numPoints = len / 3;
-        short[] indices = new short[numPoints];
-        for (int i = 0; i < numPoints; i++) {
-            indices[i] = (short)i;
-        }
-        
-        allocateBuffers(vertices, null, null, null, indices);
-        this.mNumIndices = mIndexBuffer.capacity();
-    }
-
-    @Override public int getNumTriangles() {
-        return mNumIndices * 2;
-    }
-}
diff --git a/samples/GlobalTime/src/com/android/globaltime/Shape.java b/samples/GlobalTime/src/com/android/globaltime/Shape.java
deleted file mode 100644
index 6c296ce..0000000
--- a/samples/GlobalTime/src/com/android/globaltime/Shape.java
+++ /dev/null
@@ -1,270 +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.globaltime;
-
-import java.nio.Buffer;
-import java.nio.ByteBuffer;
-import java.nio.ByteOrder;
-import java.nio.IntBuffer;
-import java.nio.ShortBuffer;
-
-import javax.microedition.khronos.opengles.GL10;
-
-/**
- * An abstract superclass for various three-dimensional objects to be drawn
- * using OpenGL ES.  Each subclass is responsible for setting up NIO buffers
- * containing vertices, texture coordinates, colors, normals, and indices.
- * The {@link #draw(GL10)} method draws the object to the given OpenGL context.
- */
-public abstract class Shape {
-
-    public static final int INT_BYTES = 4;
-    public static final int SHORT_BYTES = 2;
-
-    public static final float DEGREES_TO_RADIANS = (float) Math.PI / 180.0f;
-    public static final float PI = (float) Math.PI;
-    public static final float TWO_PI = (float) (2.0 * Math.PI);
-    public static final float PI_OVER_TWO = (float) (Math.PI / 2.0);
-
-    protected int mPrimitive;
-    protected int mIndexDatatype;
-
-    protected boolean mEmitTextureCoordinates;
-    protected boolean mEmitNormals;
-    protected boolean mEmitColors;
-
-    protected IntBuffer mVertexBuffer;
-    protected IntBuffer mTexcoordBuffer;
-    protected IntBuffer mColorBuffer;
-    protected IntBuffer mNormalBuffer;
-    protected Buffer mIndexBuffer;
-    protected int mNumIndices = -1;
-
-    /**
-     * Constructs a Shape.
-     * 
-     * @param primitive a GL primitive type understood by glDrawElements,
-     * such as GL10.GL_TRIANGLES
-     * @param indexDatatype the GL datatype for the  index buffer, such as
-     * GL10.GL_UNSIGNED_SHORT
-     * @param emitTextureCoordinates true to enable use of the texture
-     * coordinate buffer
-     * @param emitNormals true to enable use of the normal buffer
-     * @param emitColors true to enable use of the color buffer
-     */
-    protected Shape(int primitive,
-        int indexDatatype,
-        boolean emitTextureCoordinates,
-        boolean emitNormals,
-        boolean emitColors) {
-        mPrimitive = primitive;
-        mIndexDatatype = indexDatatype;
-        mEmitTextureCoordinates = emitTextureCoordinates;
-        mEmitNormals = emitNormals;
-        mEmitColors = emitColors;
-    }
-
-    /**
-     * Converts the given floating-point value to fixed-point.
-     */
-    public static int toFixed(float x) {
-        return (int) (x * 65536.0);
-    }
-
-    /**
-     * Converts the given fixed-point value to floating-point.
-     */
-    public static float toFloat(int x) {
-        return (float) (x / 65536.0);
-    }
-
-    /**
-     * Computes the cross-product of two vectors p and q and places
-     * the result in out. 
-     */
-    public static void cross(float[] p, float[] q, float[] out) {
-        out[0] = p[1] * q[2] - p[2] * q[1];
-        out[1] = p[2] * q[0] - p[0] * q[2];
-        out[2] = p[0] * q[1] - p[1] * q[0];
-    }
-
-    /**
-     * Returns the length of a vector, given as three floats.
-     */
-    public static float length(float vx, float vy, float vz) {
-        return (float) Math.sqrt(vx * vx + vy * vy + vz * vz);
-    }
-
-    /**
-     * Returns the length of a vector, given as an array of three floats.
-     */
-    public static float length(float[] v) { 
-        return length(v[0], v[1], v[2]);
-    }
-
-    /**
-     * Normalizes the given vector of three floats to have length == 1.0.
-     * Vectors with length zero are unaffected.
-     */
-    public static void normalize(float[] v) {
-        float length = length(v);
-        if (length != 0.0f) {
-            float norm = 1.0f / length;
-            v[0] *= norm;
-            v[1] *= norm;
-            v[2] *= norm;
-        }
-    }
-
-    /**
-     * Returns the number of triangles associated with this shape.
-     */
-    public int getNumTriangles() {
-        if (mPrimitive == GL10.GL_TRIANGLES) {
-            return mIndexBuffer.capacity() / 3;
-        } else if (mPrimitive == GL10.GL_TRIANGLE_STRIP) {
-            return mIndexBuffer.capacity() - 2;
-        }
-        return 0;
-    }
-    
-    /**
-     * Copies the given data into the instance
-     * variables mVertexBuffer, mTexcoordBuffer, mNormalBuffer, mColorBuffer,
-     * and mIndexBuffer.
-     * 
-     * @param vertices an array of fixed-point vertex coordinates
-     * @param texcoords an array of fixed-point texture coordinates
-     * @param normals an array of fixed-point normal vector coordinates
-     * @param colors an array of fixed-point color channel values
-     * @param indices an array of short indices
-     */
-    public void allocateBuffers(int[] vertices, int[] texcoords, int[] normals,
-        int[] colors, short[] indices) {
-        allocate(vertices, texcoords, normals, colors);
-        
-        ByteBuffer ibb =
-            ByteBuffer.allocateDirect(indices.length * SHORT_BYTES);
-        ibb.order(ByteOrder.nativeOrder());
-        ShortBuffer shortIndexBuffer = ibb.asShortBuffer();
-        shortIndexBuffer.put(indices);
-        shortIndexBuffer.position(0);
-        this.mIndexBuffer = shortIndexBuffer;
-    }
-    
-    /**
-     * Copies the given data into the instance
-     * variables mVertexBuffer, mTexcoordBuffer, mNormalBuffer, mColorBuffer,
-     * and mIndexBuffer.
-     * 
-     * @param vertices an array of fixed-point vertex coordinates
-     * @param texcoords an array of fixed-point texture coordinates
-     * @param normals an array of fixed-point normal vector coordinates
-     * @param colors an array of fixed-point color channel values
-     * @param indices an array of int indices
-     */
-    public void allocateBuffers(int[] vertices, int[] texcoords, int[] normals,
-        int[] colors, int[] indices) {
-        allocate(vertices, texcoords, normals, colors);
-        
-        ByteBuffer ibb =
-            ByteBuffer.allocateDirect(indices.length * INT_BYTES);
-        ibb.order(ByteOrder.nativeOrder());
-        IntBuffer intIndexBuffer = ibb.asIntBuffer();
-        intIndexBuffer.put(indices);
-        intIndexBuffer.position(0);
-        this.mIndexBuffer = intIndexBuffer;
-    }
-    
-    /**
-     * Allocate the vertex, texture coordinate, normal, and color buffer.
-     */
-    private void allocate(int[] vertices, int[] texcoords, int[] normals,
-        int[] colors) {
-        ByteBuffer vbb =
-            ByteBuffer.allocateDirect(vertices.length * INT_BYTES);
-        vbb.order(ByteOrder.nativeOrder());
-        mVertexBuffer = vbb.asIntBuffer();
-        mVertexBuffer.put(vertices);
-        mVertexBuffer.position(0);
-
-        if ((texcoords != null) && mEmitTextureCoordinates) {
-            ByteBuffer tbb =
-                ByteBuffer.allocateDirect(texcoords.length * INT_BYTES);
-            tbb.order(ByteOrder.nativeOrder());
-            mTexcoordBuffer = tbb.asIntBuffer();
-            mTexcoordBuffer.put(texcoords);
-            mTexcoordBuffer.position(0);
-        }
-
-        if ((normals != null) && mEmitNormals) {
-            ByteBuffer nbb =
-                ByteBuffer.allocateDirect(normals.length * INT_BYTES);
-            nbb.order(ByteOrder.nativeOrder());
-            mNormalBuffer = nbb.asIntBuffer();
-            mNormalBuffer.put(normals);
-            mNormalBuffer.position(0);
-        }
-
-        if ((colors != null) && mEmitColors) {
-            ByteBuffer cbb =
-                ByteBuffer.allocateDirect(colors.length * INT_BYTES);
-            cbb.order(ByteOrder.nativeOrder());
-            mColorBuffer = cbb.asIntBuffer();
-            mColorBuffer.put(colors);
-            mColorBuffer.position(0);
-        }
-    }
-
-    /**
-     * Draws the shape to the given OpenGL ES 1.0 context.  Texture coordinates,
-     * normals, and colors are emitted according the the preferences set for
-     * this shape.
-     */
-    public void draw(GL10 gl) {
-        gl.glVertexPointer(3, GL10.GL_FIXED, 0, mVertexBuffer);
-        gl.glEnableClientState(GL10.GL_VERTEX_ARRAY);
-
-        if (mEmitTextureCoordinates) {
-            gl.glEnableClientState(GL10.GL_TEXTURE_COORD_ARRAY);
-            gl.glTexCoordPointer(2, GL10.GL_FIXED, 0, mTexcoordBuffer);
-            gl.glEnable(GL10.GL_TEXTURE_2D);
-        } else {
-            gl.glDisableClientState(GL10.GL_TEXTURE_COORD_ARRAY);
-            gl.glDisable(GL10.GL_TEXTURE_2D);
-        }
-
-        if (mEmitNormals) {
-            gl.glEnableClientState(GL10.GL_NORMAL_ARRAY);
-            gl.glNormalPointer(GL10.GL_FIXED, 0, mNormalBuffer);
-        } else {
-            gl.glDisableClientState(GL10.GL_NORMAL_ARRAY);
-        }
-
-        if (mEmitColors) {
-            gl.glEnableClientState(GL10.GL_COLOR_ARRAY);
-            gl.glColorPointer(4, GL10.GL_FIXED, 0, mColorBuffer);
-        } else {
-            gl.glDisableClientState(GL10.GL_COLOR_ARRAY);
-        }
-
-        gl.glDrawElements(mPrimitive,
-                          mNumIndices > 0 ? mNumIndices : mIndexBuffer.capacity(),
-                          mIndexDatatype,
-                          mIndexBuffer);
-    }
-}
diff --git a/samples/GlobalTime/src/com/android/globaltime/Sphere.java b/samples/GlobalTime/src/com/android/globaltime/Sphere.java
deleted file mode 100644
index 4dff05d..0000000
--- a/samples/GlobalTime/src/com/android/globaltime/Sphere.java
+++ /dev/null
@@ -1,28 +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.globaltime;
-
-import javax.microedition.khronos.opengles.GL10;
-
-public class Sphere extends Shape {
-
-    public Sphere(boolean emitTextureCoordinates,
-        boolean emitNormals, boolean emitColors) {
-        super(GL10.GL_TRIANGLES, GL10.GL_UNSIGNED_SHORT,
-              emitTextureCoordinates, emitNormals, emitColors);
-    }
-}
diff --git a/samples/GlobalTime/src/com/android/globaltime/Texture.java b/samples/GlobalTime/src/com/android/globaltime/Texture.java
deleted file mode 100644
index ee3af00..0000000
--- a/samples/GlobalTime/src/com/android/globaltime/Texture.java
+++ /dev/null
@@ -1,43 +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.globaltime;
-
-import java.nio.ByteBuffer;
-
-public class Texture {
-
-    private ByteBuffer data;
-    private int width, height;
-
-    public Texture(ByteBuffer data, int width, int height) {
-        this.data = data;
-        this.width = width;
-        this.height = height;
-    }
-
-    public ByteBuffer getData() {
-        return data;
-    }
-
-    public int getWidth() {
-        return width;
-    }
-
-    public int getHeight() {
-        return height;
-    }
-}
diff --git a/samples/NFCDemo/Android.mk b/samples/NFCDemo/Android.mk
deleted file mode 100644
index 60815a2..0000000
--- a/samples/NFCDemo/Android.mk
+++ /dev/null
@@ -1,18 +0,0 @@
-LOCAL_PATH:= $(call my-dir)
-include $(CLEAR_VARS)
-
-LOCAL_MODULE_TAGS := samples tests
-
-LOCAL_STATIC_JAVA_LIBRARIES := guava
-
-# Only compile source java files in this apk.
-LOCAL_SRC_FILES := $(call all-java-files-under, src)
-
-LOCAL_PACKAGE_NAME := NFCDemo
-
-LOCAL_SDK_VERSION := current
-
-include $(BUILD_PACKAGE)
-
-# Use the following include to make our test apk.
-include $(call all-makefiles-under,$(LOCAL_PATH))
diff --git a/samples/NFCDemo/AndroidManifest.xml b/samples/NFCDemo/AndroidManifest.xml
deleted file mode 100644
index 044690b..0000000
--- a/samples/NFCDemo/AndroidManifest.xml
+++ /dev/null
@@ -1,49 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!-- Copyright (C) 2010 The Android Open Source Project
-
-     Licensed under the Apache License, Version 2.0 (the "License");
-     you may not use this file except in compliance with the License.
-     You may obtain a copy of the License at
-
-          http://www.apache.org/licenses/LICENSE-2.0
-
-     Unless required by applicable law or agreed to in writing, software
-     distributed under the License is distributed on an "AS IS" BASIS,
-     WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-     See the License for the specific language governing permissions and
-     limitations under the License.
--->
-
-<!-- Declare the contents of this Android application.  The namespace
-     attribute brings in the Android platform namespace, and the package
-     supplies a unique name for the application.  When writing your
-     own application, the package name must be changed from "com.example.*"
-     to come from a domain that you own or have control over. -->
-<manifest xmlns:android="http://schemas.android.com/apk/res/android"
-    package="com.example.android.nfc"
->
-    <uses-permission android:name="android.permission.NFC" />
-    <uses-permission android:name="android.permission.CALL_PHONE" />
-    <application
-        android:icon="@drawable/icon"
-        android:label="@string/app_name"
-    >
-    <activity android:name=".simulator.FakeTagsActivity"
-        android:theme="@android:style/Theme.NoTitleBar">
-        <intent-filter>
-            <action android:name="android.intent.action.MAIN" />
-            <category android:name="android.intent.category.LAUNCHER" />
-        </intent-filter>
-    </activity>
-        <activity android:name="TagViewer"
-            android:theme="@android:style/Theme.NoTitleBar"
-        >
-            <intent-filter>
-                <action android:name="android.nfc.action.TAG_DISCOVERED"/>
-                <category android:name="android.intent.category.DEFAULT"/>
-            </intent-filter>
-        </activity>
-    </application>
-    <uses-sdk android:minSdkVersion="9" />
-    <uses-feature android:name="android.hardware.nfc" android:required="true" />
-</manifest>
diff --git a/samples/NFCDemo/NOTICE b/samples/NFCDemo/NOTICE
deleted file mode 100644
index 171b575..0000000
--- a/samples/NFCDemo/NOTICE
+++ /dev/null
@@ -1,209 +0,0 @@
-
-   Copyright (c) 2010-2011, The Android Open Source Project
-
-   Licensed under the Apache License, Version 2.0 (the "License");
-   you may not use this file except in compliance with the License.
-
-   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.
-
-
-                                 Apache License
-                           Version 2.0, January 2004
-                        http://www.apache.org/licenses/
-
-   TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
-
-   1. Definitions.
-
-      "License" shall mean the terms and conditions for use, reproduction,
-      and distribution as defined by Sections 1 through 9 of this document.
-
-      "Licensor" shall mean the copyright owner or entity authorized by
-      the copyright owner that is granting the License.
-
-      "Legal Entity" shall mean the union of the acting entity and all
-      other entities that control, are controlled by, or are under common
-      control with that entity. For the purposes of this definition,
-      "control" means (i) the power, direct or indirect, to cause the
-      direction or management of such entity, whether by contract or
-      otherwise, or (ii) ownership of fifty percent (50%) or more of the
-      outstanding shares, or (iii) beneficial ownership of such entity.
-
-      "You" (or "Your") shall mean an individual or Legal Entity
-      exercising permissions granted by this License.
-
-      "Source" form shall mean the preferred form for making modifications,
-      including but not limited to software source code, documentation
-      source, and configuration files.
-
-      "Object" form shall mean any form resulting from mechanical
-      transformation or translation of a Source form, including but
-      not limited to compiled object code, generated documentation,
-      and conversions to other media types.
-
-      "Work" shall mean the work of authorship, whether in Source or
-      Object form, made available under the License, as indicated by a
-      copyright notice that is included in or attached to the work
-      (an example is provided in the Appendix below).
-
-      "Derivative Works" shall mean any work, whether in Source or Object
-      form, that is based on (or derived from) the Work and for which the
-      editorial revisions, annotations, elaborations, or other modifications
-      represent, as a whole, an original work of authorship. For the purposes
-      of this License, Derivative Works shall not include works that remain
-      separable from, or merely link (or bind by name) to the interfaces of,
-      the Work and Derivative Works thereof.
-
-      "Contribution" shall mean any work of authorship, including
-      the original version of the Work and any modifications or additions
-      to that Work or Derivative Works thereof, that is intentionally
-      submitted to Licensor for inclusion in the Work by the copyright owner
-      or by an individual or Legal Entity authorized to submit on behalf of
-      the copyright owner. For the purposes of this definition, "submitted"
-      means any form of electronic, verbal, or written communication sent
-      to the Licensor or its representatives, including but not limited to
-      communication on electronic mailing lists, source code control systems,
-      and issue tracking systems that are managed by, or on behalf of, the
-      Licensor for the purpose of discussing and improving the Work, but
-      excluding communication that is conspicuously marked or otherwise
-      designated in writing by the copyright owner as "Not a Contribution."
-
-      "Contributor" shall mean Licensor and any individual or Legal Entity
-      on behalf of whom a Contribution has been received by Licensor and
-      subsequently incorporated within the Work.
-
-   2. Grant of Copyright License. Subject to the terms and conditions of
-      this License, each Contributor hereby grants to You a perpetual,
-      worldwide, non-exclusive, no-charge, royalty-free, irrevocable
-      copyright license to reproduce, prepare Derivative Works of,
-      publicly display, publicly perform, sublicense, and distribute the
-      Work and such Derivative Works in Source or Object form.
-
-   3. Grant of Patent License. Subject to the terms and conditions of
-      this License, each Contributor hereby grants to You a perpetual,
-      worldwide, non-exclusive, no-charge, royalty-free, irrevocable
-      (except as stated in this section) patent license to make, have made,
-      use, offer to sell, sell, import, and otherwise transfer the Work,
-      where such license applies only to those patent claims licensable
-      by such Contributor that are necessarily infringed by their
-      Contribution(s) alone or by combination of their Contribution(s)
-      with the Work to which such Contribution(s) was submitted. If You
-      institute patent litigation against any entity (including a
-      cross-claim or counterclaim in a lawsuit) alleging that the Work
-      or a Contribution incorporated within the Work constitutes direct
-      or contributory patent infringement, then any patent licenses
-      granted to You under this License for that Work shall terminate
-      as of the date such litigation is filed.
-
-   4. Redistribution. You may reproduce and distribute copies of the
-      Work or Derivative Works thereof in any medium, with or without
-      modifications, and in Source or Object form, provided that You
-      meet the following conditions:
-
-      (a) You must give any other recipients of the Work or
-          Derivative Works a copy of this License; and
-
-      (b) You must cause any modified files to carry prominent notices
-          stating that You changed the files; and
-
-      (c) You must retain, in the Source form of any Derivative Works
-          that You distribute, all copyright, patent, trademark, and
-          attribution notices from the Source form of the Work,
-          excluding those notices that do not pertain to any part of
-          the Derivative Works; and
-
-      (d) If the Work includes a "NOTICE" text file as part of its
-          distribution, then any Derivative Works that You distribute must
-          include a readable copy of the attribution notices contained
-          within such NOTICE file, excluding those notices that do not
-          pertain to any part of the Derivative Works, in at least one
-          of the following places: within a NOTICE text file distributed
-          as part of the Derivative Works; within the Source form or
-          documentation, if provided along with the Derivative Works; or,
-          within a display generated by the Derivative Works, if and
-          wherever such third-party notices normally appear. The contents
-          of the NOTICE file are for informational purposes only and
-          do not modify the License. You may add Your own attribution
-          notices within Derivative Works that You distribute, alongside
-          or as an addendum to the NOTICE text from the Work, provided
-          that such additional attribution notices cannot be construed
-          as modifying the License.
-
-      You may add Your own copyright statement to Your modifications and
-      may provide additional or different license terms and conditions
-      for use, reproduction, or distribution of Your modifications, or
-      for any such Derivative Works as a whole, provided Your use,
-      reproduction, and distribution of the Work otherwise complies with
-      the conditions stated in this License.
-
-   5. Submission of Contributions. Unless You explicitly state otherwise,
-      any Contribution intentionally submitted for inclusion in the Work
-      by You to the Licensor shall be under the terms and conditions of
-      this License, without any additional terms or conditions.
-      Notwithstanding the above, nothing herein shall supersede or modify
-      the terms of any separate license agreement you may have executed
-      with Licensor regarding such Contributions.
-
-   6. Trademarks. This License does not grant permission to use the trade
-      names, trademarks, service marks, or product names of the Licensor,
-      except as required for reasonable and customary use in describing the
-      origin of the Work and reproducing the content of the NOTICE file.
-
-   7. Disclaimer of Warranty. Unless required by applicable law or
-      agreed to in writing, Licensor provides the Work (and each
-      Contributor provides its Contributions) on an "AS IS" BASIS,
-      WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
-      implied, including, without limitation, any warranties or conditions
-      of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
-      PARTICULAR PURPOSE. You are solely responsible for determining the
-      appropriateness of using or redistributing the Work and assume any
-      risks associated with Your exercise of permissions under this License.
-
-   8. Limitation of Liability. In no event and under no legal theory,
-      whether in tort (including negligence), contract, or otherwise,
-      unless required by applicable law (such as deliberate and grossly
-      negligent acts) or agreed to in writing, shall any Contributor be
-      liable to You for damages, including any direct, indirect, special,
-      incidental, or consequential damages of any character arising as a
-      result of this License or out of the use or inability to use the
-      Work (including but not limited to damages for loss of goodwill,
-      work stoppage, computer failure or malfunction, or any and all
-      other commercial damages or losses), even if such Contributor
-      has been advised of the possibility of such damages.
-
-   9. Accepting Warranty or Additional Liability. While redistributing
-      the Work or Derivative Works thereof, You may choose to offer,
-      and charge a fee for, acceptance of support, warranty, indemnity,
-      or other liability obligations and/or rights consistent with this
-      License. However, in accepting such obligations, You may act only
-      on Your own behalf and on Your sole responsibility, not on behalf
-      of any other Contributor, and only if You agree to indemnify,
-      defend, and hold each Contributor harmless for any liability
-      incurred by, or claims asserted against, such Contributor by reason
-      of your accepting any such warranty or additional liability.
-
-   END OF TERMS AND CONDITIONS
-
-This product also includes the following third-party components:
-
- * Guava (libs/guava-10.0.1.jar)
-   http://code.google.com/p/guava-libraries/
-
-   Copyright 2004-2011 The Guava Authors
-
-   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.
-
diff --git a/samples/NFCDemo/_index.html b/samples/NFCDemo/_index.html
deleted file mode 100644
index 07978f2..0000000
--- a/samples/NFCDemo/_index.html
+++ /dev/null
@@ -1,129 +0,0 @@
-<p>
-  Near-field Communication or NFC is a standard defined by the
-  <a href=http://www.nfc-forum.org/home>NFC Forum
-  </a>.
-  NFC Data Exchange Format (NDEF) defines a common data format between NFC-compliant devices and tags.
-  This demo application shows how to read a NDEF Tags using using Android 2.3 SDK APIs.
-  The NFC Tags consist of data encoded in NDEF Message format specified by NFC Forum Type 2 Specification.
-  Each NDEF message consists of one or more NDEF Records.
-
-  You need a NFC compliant device and a NFC compliant Tag to use this sample app. Or else, you could use
-  the FakeTagsActivity displayed at launch of this sample app, to generate fake Tag broadcasts from the emulator.
-</p>
-
-<p>The application includes:
-</p>
-  <ul>
-    <li>
-      <a href="src/com/example/android/nfc/TagViewer.html">
-        <code>TagViewer
-        </code>
-      </a>
-      &mdash; an
-      <code>Activity
-      </code> that handles a broadcast of a new tag that the device
-      just discovered, parses it, and displays its record contents in a
-      <code>ListActivity
-      </code>
-    </li>
-    <li>
-      <a href="src/com/example/android/nfc/NdefMessageParser.html">
-        <code> NdefMessageParser
-        </code>
-      </a>
-      &mdash; parses the record type of records within the NDEF message.
-    </li>
-    <li>
-      <a href="src/com/example/android/nfc/record/ParsedNdefRecord.html">
-        <code>ParsedNdefRecord
-        </code>
-      </a>
-      &mdash; an interface implemented by all parsed NdefRecord types.
-    </li>
-    <li>
-      <a href="src/com/example/android/nfc/record/SmartPoster.html">
-        <code>SmartPoster
-        </code>
-      </a>
-      &mdash; a representation of an NFC Forum Smart Poster Record Type.
-    </li>
-    <li>
-      <a href="src/com/example/android/nfc/record/TextRecord.html">
-        <code>TextRecord
-        </code>
-      </a>
-      &mdash; a representation of an NFC Forum Text Record Type.
-    </li>
-    <li>
-      <a href="src/com/example/android/nfc/record/UriRecord.html">
-        <code>UriRecord
-        </code>
-      </a>
-      &mdash; a representation of an NFC Forum Uri Record Type.
-    </li>
-    <li>
-      <a href="src/com/example/android/nfc/simulator/FakeTagsActivity.html">
-        <code>FakeTagsActivity
-        </code>
-      </a>
-      &mdash; A activity that launches tags as if they had been scanned.
-      This is useful if you don't have access to NFC enabled device or tag.
-    </li>
-    <li>
-      <a href="src/com/example/android/nfc/simulator/MockNdefMessages.html">
-        <code>MockNdefMessages
-        </code>
-      </a>
-      &mdash; this class provides a list of fake NFC Ndef format Tags.
-    </li>
-
-  </ul>
-<p>If you are developing an application that uses the NFC API, remember that the feature
-  is supported only on Android 2.3 (API level 9) and higher versions of the platform. Also,
-  among devices running Android 2.3 (API level 9) or higher, not all devices will offer NFC
-  support. To ensure that your application can only be installed on devices that are capable
-  of supporting NFC, remember to add the following to the application's manifest before
-  publishing to Google Play:
-</p>
-<ul>
-  <li>
-    <code>&lt;uses-sdk android:minSdkVersion="9" /&gt;
-    </code>,
-    which indicates to Google Play and the platform that your application requires
-    Android 2.3 or higher. For more information, see
-    <a href="../../../guide/appendix/api-levels.html">API Levels
-    </a>
-    and the documentation for the
-    <a href="../../../guide/topics/manifest/uses-sdk-element.html">
-      <code>&lt;uses-sdk&gt;
-      </code>
-    </a> element.
-  </li>
-</ul>
-<p>To control how Google Play filters your application
-  from devices that do not support NFC, remember to add the following to the application's manifest
-  <ul>
-    <li>
-      <code>&lt;uses-feature android:name="android.hardware.nfc" /&gt;
-      </code>,
-      which tells Google Play that your application uses the NFC API. The declaration
-      should include an
-      <code>android:required
-      </code> attribute that indicates whether you want
-      Google Play to filter the application from devices that do not offer NFC support. Other
-      <code>&lt;uses-feature&gt;
-      </code> declarations may also be needed, depending on your
-      implementation. For more information, see the documentation for the
-      <a href="../../../guide/topics/manifest/uses-feature-element.html">
-        <code>&lt;uses-feature&gt;
-        </code>
-      </a> element.
-    </li>
-  </ul>
-<p>For more information about using the NFC API, see the
-  <a href="../../../reference/android/nfc/package-summary.html">
-    <code>android.nfc</code>
-    </a>
-   documentation.
-</p>
-<img alt="" src="../images/NfcDemo.png"/>
diff --git a/samples/NFCDemo/libs/guava-10.0.1.jar b/samples/NFCDemo/libs/guava-10.0.1.jar
deleted file mode 100644
index d107c0f..0000000
--- a/samples/NFCDemo/libs/guava-10.0.1.jar
+++ /dev/null
Binary files differ
diff --git a/samples/NFCDemo/res/drawable/icon.png b/samples/NFCDemo/res/drawable/icon.png
deleted file mode 100644
index a07c69f..0000000
--- a/samples/NFCDemo/res/drawable/icon.png
+++ /dev/null
Binary files differ
diff --git a/samples/NFCDemo/res/layout/tag_text.xml b/samples/NFCDemo/res/layout/tag_text.xml
deleted file mode 100644
index 59cbbfb..0000000
--- a/samples/NFCDemo/res/layout/tag_text.xml
+++ /dev/null
@@ -1,28 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!--
-     Copyright (C) 2010 The Android Open Source Project
-
-     Licensed under the Apache License, Version 2.0 (the "License");
-     you may not use this file except in compliance with the License.
-     You may obtain a copy of the License at
-
-          http://www.apache.org/licenses/LICENSE-2.0
-
-     Unless required by applicable law or agreed to in writing, software
-     distributed under the License is distributed on an "AS IS" BASIS,
-     WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-     See the License for the specific language governing permissions and
-     limitations under the License.
--->
-
-<TextView xmlns:android="http://schemas.android.com/apk/res/android"
-    android:id="@+id/text"
-    android:layout_width="match_parent"
-    android:minHeight="?android:attr/listPreferredItemHeight"
-    android:layout_height="wrap_content"
-    android:padding="4dip"
-    android:textAppearance="?android:attr/textAppearanceMedium"
-    android:maxLines="5"
-    android:ellipsize="end"
-    android:gravity="center_vertical"
-/>
\ No newline at end of file
diff --git a/samples/NFCDemo/res/layout/tag_viewer.xml b/samples/NFCDemo/res/layout/tag_viewer.xml
deleted file mode 100644
index a429ef9..0000000
--- a/samples/NFCDemo/res/layout/tag_viewer.xml
+++ /dev/null
@@ -1,32 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!--
-     Copyright (C) 2010 The Android Open Source Project
-
-     Licensed under the Apache License, Version 2.0 (the "License");
-     you may not use this file except in compliance with the License.
-     You may obtain a copy of the License at
-
-          http://www.apache.org/licenses/LICENSE-2.0
-
-     Unless required by applicable law or agreed to in writing, software
-     distributed under the License is distributed on an "AS IS" BASIS,
-     WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-     See the License for the specific language governing permissions and
-     limitations under the License.
--->
-<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
-    android:layout_width="match_parent" android:layout_height="match_parent"
-    android:orientation="vertical">
-    <!-- Title -->
-    <TextView android:id="@+id/title" android:layout_width="wrap_content"
-        android:layout_height="wrap_content" android:singleLine="true"
-        android:textAppearance="?android:attr/textAppearanceMedium"
-        android:textStyle="bold" android:shadowColor="#BB000000"
-        android:shadowRadius="2.75" android:gravity="center_vertical" />
-    <!-- Content -->
-    <ScrollView android:layout_width="match_parent"
-        android:layout_height="0dip" android:layout_weight="1">
-        <LinearLayout android:id="@+id/list" android:layout_width="match_parent"
-            android:layout_height="wrap_content" android:orientation="vertical" />
-    </ScrollView>
-</LinearLayout>
\ No newline at end of file
diff --git a/samples/NFCDemo/res/raw/discovered_tag_notification.ogg b/samples/NFCDemo/res/raw/discovered_tag_notification.ogg
deleted file mode 100755
index 7bf5df7..0000000
--- a/samples/NFCDemo/res/raw/discovered_tag_notification.ogg
+++ /dev/null
Binary files differ
diff --git a/samples/NFCDemo/res/values/strings.xml b/samples/NFCDemo/res/values/strings.xml
deleted file mode 100644
index 251d2f6..0000000
--- a/samples/NFCDemo/res/values/strings.xml
+++ /dev/null
@@ -1,28 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!-- Copyright (C) 2010 The Android Open Source Project
-
-     Licensed under the Apache License, Version 2.0 (the "License");
-     you may not use this file except in compliance with the License.
-     You may obtain a copy of the License at
-
-          http://www.apache.org/licenses/LICENSE-2.0
-
-     Unless required by applicable law or agreed to in writing, software
-     distributed under the License is distributed on an "AS IS" BASIS,
-     WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-     See the License for the specific language governing permissions and
-     limitations under the License.
--->
-
-<resources xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">
-
-    <!-- The title of the NFC tag application -->
-    <string name="app_name">NFCDemo</string>
-
-    <!-- The title for the activity that shows a tag that was just scanned -->
-    <string name="title_scanned_tag">New tag collected</string>
-
-    <!-- Heading for the text of the content in the "my tag" feature. -->
-    <string name="tag_text">Text</string>
-
-</resources>
diff --git a/samples/NFCDemo/src/com/example/android/nfc/NdefMessageParser.java b/samples/NFCDemo/src/com/example/android/nfc/NdefMessageParser.java
deleted file mode 100644
index 7372810..0000000
--- a/samples/NFCDemo/src/com/example/android/nfc/NdefMessageParser.java
+++ /dev/null
@@ -1,57 +0,0 @@
-/*
- * Copyright (C) 2010 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License"); you may not
- * use this file except in compliance with the License. You may obtain a copy of
- * the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
- * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
- * License for the specific language governing permissions and limitations under
- * the License.
- */
-package com.example.android.nfc;
-
-import android.nfc.NdefMessage;
-import android.nfc.NdefRecord;
-
-import com.example.android.nfc.record.ParsedNdefRecord;
-import com.example.android.nfc.record.SmartPoster;
-import com.example.android.nfc.record.TextRecord;
-import com.example.android.nfc.record.UriRecord;
-
-import java.util.ArrayList;
-import java.util.List;
-
-/**
- * Utility class for creating {@link ParsedNdefMessage}s.
- */
-public class NdefMessageParser {
-
-    // Utility class
-    private NdefMessageParser() {
-
-    }
-
-    /** Parse an NdefMessage */
-    public static List<ParsedNdefRecord> parse(NdefMessage message) {
-        return getRecords(message.getRecords());
-    }
-
-    public static List<ParsedNdefRecord> getRecords(NdefRecord[] records) {
-        List<ParsedNdefRecord> elements = new ArrayList<ParsedNdefRecord>();
-        for (NdefRecord record : records) {
-            if (UriRecord.isUri(record)) {
-                elements.add(UriRecord.parse(record));
-            } else if (TextRecord.isText(record)) {
-                elements.add(TextRecord.parse(record));
-            } else if (SmartPoster.isPoster(record)) {
-                elements.add(SmartPoster.parse(record));
-            }
-        }
-        return elements;
-    }
-}
diff --git a/samples/NFCDemo/src/com/example/android/nfc/TagViewer.java b/samples/NFCDemo/src/com/example/android/nfc/TagViewer.java
deleted file mode 100644
index 01dc0bd..0000000
--- a/samples/NFCDemo/src/com/example/android/nfc/TagViewer.java
+++ /dev/null
@@ -1,124 +0,0 @@
-/*
- * Copyright (C) 2010 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package com.example.android.nfc;
-
-import android.app.Activity;
-import android.content.Intent;
-import android.nfc.NdefMessage;
-import android.nfc.NdefRecord;
-import android.nfc.NfcAdapter;
-import android.os.Bundle;
-import android.os.Parcelable;
-import android.util.Log;
-import android.view.LayoutInflater;
-import android.view.WindowManager;
-import android.widget.LinearLayout;
-import android.widget.TextView;
-
-import com.example.android.nfc.record.ParsedNdefRecord;
-
-import java.util.List;
-
-/**
- * An {@link Activity} which handles a broadcast of a new tag that the device
- * just discovered.
- */
-public class TagViewer extends Activity {
-
-    static final String TAG = "ViewTag";
-
-    /**
-     * This activity will finish itself in this amount of time if the user
-     * doesn't do anything.
-     */
-    static final int ACTIVITY_TIMEOUT_MS = 1 * 1000;
-
-    TextView mTitle;
-
-    LinearLayout mTagContent;
-
-    @Override
-    protected void onCreate(Bundle savedInstanceState) {
-        super.onCreate(savedInstanceState);
-        setContentView(R.layout.tag_viewer);
-        mTagContent = (LinearLayout) findViewById(R.id.list);
-        mTitle = (TextView) findViewById(R.id.title);
-        resolveIntent(getIntent());
-    }
-
-    void resolveIntent(Intent intent) {
-        // Parse the intent
-        String action = intent.getAction();
-        if (NfcAdapter.ACTION_TAG_DISCOVERED.equals(action)) {
-            // When a tag is discovered we send it to the service to be save. We
-            // include a PendingIntent for the service to call back onto. This
-            // will cause this activity to be restarted with onNewIntent(). At
-            // that time we read it from the database and view it.
-            Parcelable[] rawMsgs = intent.getParcelableArrayExtra(NfcAdapter.EXTRA_NDEF_MESSAGES);
-            NdefMessage[] msgs;
-            if (rawMsgs != null) {
-                msgs = new NdefMessage[rawMsgs.length];
-                for (int i = 0; i < rawMsgs.length; i++) {
-                    msgs[i] = (NdefMessage) rawMsgs[i];
-                }
-            } else {
-                // Unknown tag type
-                byte[] empty = new byte[] {};
-                NdefRecord record = new NdefRecord(NdefRecord.TNF_UNKNOWN, empty, empty, empty);
-                NdefMessage msg = new NdefMessage(new NdefRecord[] {record});
-                msgs = new NdefMessage[] {msg};
-            }
-            // Setup the views
-            setTitle(R.string.title_scanned_tag);
-            buildTagViews(msgs);
-        } else {
-            Log.e(TAG, "Unknown intent " + intent);
-            finish();
-            return;
-        }
-    }
-
-    void buildTagViews(NdefMessage[] msgs) {
-        if (msgs == null || msgs.length == 0) {
-            return;
-        }
-        LayoutInflater inflater = LayoutInflater.from(this);
-        LinearLayout content = mTagContent;
-        // Clear out any old views in the content area, for example if you scan
-        // two tags in a row.
-        content.removeAllViews();
-        // Parse the first message in the list
-        // Build views for all of the sub records
-        List<ParsedNdefRecord> records = NdefMessageParser.parse(msgs[0]);
-        final int size = records.size();
-        for (int i = 0; i < size; i++) {
-            ParsedNdefRecord record = records.get(i);
-            content.addView(record.getView(this, inflater, content, i));
-            inflater.inflate(R.layout.tag_divider, content, true);
-        }
-    }
-
-    @Override
-    public void onNewIntent(Intent intent) {
-        setIntent(intent);
-        resolveIntent(intent);
-    }
-
-    @Override
-    public void setTitle(CharSequence title) {
-        mTitle.setText(title);
-    }
-}
diff --git a/samples/NFCDemo/src/com/example/android/nfc/record/ParsedNdefRecord.java b/samples/NFCDemo/src/com/example/android/nfc/record/ParsedNdefRecord.java
deleted file mode 100644
index b706ae8..0000000
--- a/samples/NFCDemo/src/com/example/android/nfc/record/ParsedNdefRecord.java
+++ /dev/null
@@ -1,33 +0,0 @@
-/*
- * Copyright (C) 2010 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.example.android.nfc.record;
-
-import android.app.Activity;
-import android.view.LayoutInflater;
-import android.view.View;
-import android.view.ViewGroup;
-
-
-public interface ParsedNdefRecord {
-
-    /**
-     * Returns a view to display this record.
-     */
-    public View getView(Activity activity, LayoutInflater inflater, ViewGroup parent,
-            int offset);
-
-}
diff --git a/samples/NFCDemo/src/com/example/android/nfc/record/SmartPoster.java b/samples/NFCDemo/src/com/example/android/nfc/record/SmartPoster.java
deleted file mode 100644
index f86d3ef..0000000
--- a/samples/NFCDemo/src/com/example/android/nfc/record/SmartPoster.java
+++ /dev/null
@@ -1,222 +0,0 @@
-/*
- * Copyright (C) 2010 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package com.example.android.nfc.record;
-
-import android.app.Activity;
-import android.nfc.FormatException;
-import android.nfc.NdefMessage;
-import android.nfc.NdefRecord;
-import android.view.LayoutInflater;
-import android.view.View;
-import android.view.ViewGroup;
-import android.view.ViewGroup.LayoutParams;
-import android.widget.LinearLayout;
-
-import com.google.common.base.Charsets;
-import com.google.common.base.Preconditions;
-import com.google.common.collect.ImmutableMap;
-import com.google.common.collect.Iterables;
-
-import com.example.android.nfc.NdefMessageParser;
-import com.example.android.nfc.R;
-
-import java.util.Arrays;
-import java.util.NoSuchElementException;
-
-/**
- * A representation of an NFC Forum "Smart Poster".
- */
-public class SmartPoster implements ParsedNdefRecord {
-
-    /**
-     * NFC Forum Smart Poster Record Type Definition section 3.2.1.
-     *
-     * "The Title record for the service (there can be many of these in
-     * different languages, but a language MUST NOT be repeated). This record is
-     * optional."
-     */
-    private final TextRecord mTitleRecord;
-
-    /**
-     * NFC Forum Smart Poster Record Type Definition section 3.2.1.
-     *
-     * "The URI record. This is the core of the Smart Poster, and all other
-     * records are just metadata about this record. There MUST be one URI record
-     * and there MUST NOT be more than one."
-     */
-    private final UriRecord mUriRecord;
-
-    /**
-     * NFC Forum Smart Poster Record Type Definition section 3.2.1.
-     *
-     * "The Action record. This record describes how the service should be
-     * treated. For example, the action may indicate that the device should save
-     * the URI as a bookmark or open a browser. The Action record is optional.
-     * If it does not exist, the device may decide what to do with the service.
-     * If the action record exists, it should be treated as a strong suggestion;
-     * the UI designer may ignore it, but doing so will induce a different user
-     * experience from device to device."
-     */
-    private final RecommendedAction mAction;
-
-    /**
-     * NFC Forum Smart Poster Record Type Definition section 3.2.1.
-     *
-     * "The Type record. If the URI references an external entity (e.g., via a
-     * URL), the Type record may be used to declare the MIME type of the entity.
-     * This can be used to tell the mobile device what kind of an object it can
-     * expect before it opens the connection. The Type record is optional."
-     */
-    private final String mType;
-
-    private SmartPoster(UriRecord uri, TextRecord title, RecommendedAction action, String type) {
-        mUriRecord = Preconditions.checkNotNull(uri);
-        mTitleRecord = title;
-        mAction = Preconditions.checkNotNull(action);
-        mType = type;
-    }
-
-    public UriRecord getUriRecord() {
-        return mUriRecord;
-    }
-
-    /**
-     * Returns the title of the smart poster. This may be {@code null}.
-     */
-    public TextRecord getTitle() {
-        return mTitleRecord;
-    }
-
-    public static SmartPoster parse(NdefRecord record) {
-        Preconditions.checkArgument(record.getTnf() == NdefRecord.TNF_WELL_KNOWN);
-        Preconditions.checkArgument(Arrays.equals(record.getType(), NdefRecord.RTD_SMART_POSTER));
-        try {
-            NdefMessage subRecords = new NdefMessage(record.getPayload());
-            return parse(subRecords.getRecords());
-        } catch (FormatException e) {
-            throw new IllegalArgumentException(e);
-        }
-    }
-
-    public static SmartPoster parse(NdefRecord[] recordsRaw) {
-        try {
-            Iterable<ParsedNdefRecord> records = NdefMessageParser.getRecords(recordsRaw);
-            UriRecord uri = Iterables.getOnlyElement(Iterables.filter(records, UriRecord.class));
-            TextRecord title = getFirstIfExists(records, TextRecord.class);
-            RecommendedAction action = parseRecommendedAction(recordsRaw);
-            String type = parseType(recordsRaw);
-            return new SmartPoster(uri, title, action, type);
-        } catch (NoSuchElementException e) {
-            throw new IllegalArgumentException(e);
-        }
-    }
-
-    public static boolean isPoster(NdefRecord record) {
-        try {
-            parse(record);
-            return true;
-        } catch (IllegalArgumentException e) {
-            return false;
-        }
-    }
-
-    public View getView(Activity activity, LayoutInflater inflater, ViewGroup parent, int offset) {
-        if (mTitleRecord != null) {
-            // Build a container to hold the title and the URI
-            LinearLayout container = new LinearLayout(activity);
-            container.setOrientation(LinearLayout.VERTICAL);
-            container.setLayoutParams(new LayoutParams(LayoutParams.MATCH_PARENT,
-                LayoutParams.WRAP_CONTENT));
-            container.addView(mTitleRecord.getView(activity, inflater, container, offset));
-            inflater.inflate(R.layout.tag_divider, container);
-            container.addView(mUriRecord.getView(activity, inflater, container, offset));
-            return container;
-        } else {
-            // Just a URI, return a view for it directly
-            return mUriRecord.getView(activity, inflater, parent, offset);
-        }
-    }
-
-    /**
-     * Returns the first element of {@code elements} which is an instance of
-     * {@code type}, or {@code null} if no such element exists.
-     */
-    private static <T> T getFirstIfExists(Iterable<?> elements, Class<T> type) {
-        Iterable<T> filtered = Iterables.filter(elements, type);
-        T instance = null;
-        if (!Iterables.isEmpty(filtered)) {
-            instance = Iterables.get(filtered, 0);
-        }
-        return instance;
-    }
-
-    private enum RecommendedAction {
-        UNKNOWN((byte) -1), DO_ACTION((byte) 0), SAVE_FOR_LATER((byte) 1), OPEN_FOR_EDITING(
-            (byte) 2);
-
-        private static final ImmutableMap<Byte, RecommendedAction> LOOKUP;
-        static {
-            ImmutableMap.Builder<Byte, RecommendedAction> builder = ImmutableMap.builder();
-            for (RecommendedAction action : RecommendedAction.values()) {
-                builder.put(action.getByte(), action);
-            }
-            LOOKUP = builder.build();
-        }
-
-        private final byte mAction;
-
-        private RecommendedAction(byte val) {
-            this.mAction = val;
-        }
-
-        private byte getByte() {
-            return mAction;
-        }
-    }
-
-    private static NdefRecord getByType(byte[] type, NdefRecord[] records) {
-        for (NdefRecord record : records) {
-            if (Arrays.equals(type, record.getType())) {
-                return record;
-            }
-        }
-        return null;
-    }
-
-    private static final byte[] ACTION_RECORD_TYPE = new byte[] {'a', 'c', 't'};
-
-    private static RecommendedAction parseRecommendedAction(NdefRecord[] records) {
-        NdefRecord record = getByType(ACTION_RECORD_TYPE, records);
-        if (record == null) {
-            return RecommendedAction.UNKNOWN;
-        }
-        byte action = record.getPayload()[0];
-        if (RecommendedAction.LOOKUP.containsKey(action)) {
-            return RecommendedAction.LOOKUP.get(action);
-        }
-        return RecommendedAction.UNKNOWN;
-    }
-
-    private static final byte[] TYPE_TYPE = new byte[] {'t'};
-
-    private static String parseType(NdefRecord[] records) {
-        NdefRecord type = getByType(TYPE_TYPE, records);
-        if (type == null) {
-            return null;
-        }
-        return new String(type.getPayload(), Charsets.UTF_8);
-    }
-}
diff --git a/samples/NFCDemo/src/com/example/android/nfc/record/TextRecord.java b/samples/NFCDemo/src/com/example/android/nfc/record/TextRecord.java
deleted file mode 100644
index 8041cca..0000000
--- a/samples/NFCDemo/src/com/example/android/nfc/record/TextRecord.java
+++ /dev/null
@@ -1,104 +0,0 @@
-/*
- * Copyright (C) 2010 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License"); you may not
- * use this file except in compliance with the License. You may obtain a copy of
- * the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
- * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
- * License for the specific language governing permissions and limitations under
- * the License.
- */
-package com.example.android.nfc.record;
-
-import android.app.Activity;
-import android.nfc.NdefRecord;
-import android.view.LayoutInflater;
-import android.view.View;
-import android.view.ViewGroup;
-import android.widget.TextView;
-
-import com.google.common.base.Preconditions;
-
-import com.example.android.nfc.R;
-
-import java.io.UnsupportedEncodingException;
-import java.util.Arrays;
-
-/**
- * An NFC Text Record
- */
-public class TextRecord implements ParsedNdefRecord {
-
-    /** ISO/IANA language code */
-    private final String mLanguageCode;
-
-    private final String mText;
-
-    private TextRecord(String languageCode, String text) {
-        mLanguageCode = Preconditions.checkNotNull(languageCode);
-        mText = Preconditions.checkNotNull(text);
-    }
-
-    public View getView(Activity activity, LayoutInflater inflater, ViewGroup parent, int offset) {
-        TextView text = (TextView) inflater.inflate(R.layout.tag_text, parent, false);
-        text.setText(mText);
-        return text;
-    }
-
-    public String getText() {
-        return mText;
-    }
-
-    /**
-     * Returns the ISO/IANA language code associated with this text element.
-     */
-    public String getLanguageCode() {
-        return mLanguageCode;
-    }
-
-    // TODO: deal with text fields which span multiple NdefRecords
-    public static TextRecord parse(NdefRecord record) {
-        Preconditions.checkArgument(record.getTnf() == NdefRecord.TNF_WELL_KNOWN);
-        Preconditions.checkArgument(Arrays.equals(record.getType(), NdefRecord.RTD_TEXT));
-        try {
-            byte[] payload = record.getPayload();
-            /*
-             * payload[0] contains the "Status Byte Encodings" field, per the
-             * NFC Forum "Text Record Type Definition" section 3.2.1.
-             *
-             * bit7 is the Text Encoding Field.
-             *
-             * if (Bit_7 == 0): The text is encoded in UTF-8 if (Bit_7 == 1):
-             * The text is encoded in UTF16
-             *
-             * Bit_6 is reserved for future use and must be set to zero.
-             *
-             * Bits 5 to 0 are the length of the IANA language code.
-             */
-            String textEncoding = ((payload[0] & 0200) == 0) ? "UTF-8" : "UTF-16";
-            int languageCodeLength = payload[0] & 0077;
-            String languageCode = new String(payload, 1, languageCodeLength, "US-ASCII");
-            String text =
-                new String(payload, languageCodeLength + 1,
-                    payload.length - languageCodeLength - 1, textEncoding);
-            return new TextRecord(languageCode, text);
-        } catch (UnsupportedEncodingException e) {
-            // should never happen unless we get a malformed tag.
-            throw new IllegalArgumentException(e);
-        }
-    }
-
-    public static boolean isText(NdefRecord record) {
-        try {
-            parse(record);
-            return true;
-        } catch (IllegalArgumentException e) {
-            return false;
-        }
-    }
-}
diff --git a/samples/NFCDemo/src/com/example/android/nfc/record/UriRecord.java b/samples/NFCDemo/src/com/example/android/nfc/record/UriRecord.java
deleted file mode 100644
index 452ebb2..0000000
--- a/samples/NFCDemo/src/com/example/android/nfc/record/UriRecord.java
+++ /dev/null
@@ -1,159 +0,0 @@
-/*
- * Copyright (C) 2010 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package com.example.android.nfc.record;
-
-import android.app.Activity;
-import android.net.Uri;
-import android.nfc.NdefRecord;
-import android.view.LayoutInflater;
-import android.view.View;
-import android.view.ViewGroup;
-import android.widget.TextView;
-
-import com.google.common.base.Preconditions;
-import com.google.common.collect.BiMap;
-import com.google.common.collect.ImmutableBiMap;
-import com.google.common.primitives.Bytes;
-
-import com.example.android.nfc.R;
-
-import java.nio.charset.Charset;
-import java.util.Arrays;
-
-/**
- * A parsed record containing a Uri.
- */
-public class UriRecord implements ParsedNdefRecord {
-
-    private static final String TAG = "UriRecord";
-
-    public static final String RECORD_TYPE = "UriRecord";
-
-    /**
-     * NFC Forum "URI Record Type Definition"
-     *
-     * This is a mapping of "URI Identifier Codes" to URI string prefixes,
-     * per section 3.2.2 of the NFC Forum URI Record Type Definition document.
-     */
-    private static final BiMap<Byte, String> URI_PREFIX_MAP = ImmutableBiMap.<Byte, String>builder()
-            .put((byte) 0x00, "")
-            .put((byte) 0x01, "http://www.")
-            .put((byte) 0x02, "https://www.")
-            .put((byte) 0x03, "http://")
-            .put((byte) 0x04, "https://")
-            .put((byte) 0x05, "tel:")
-            .put((byte) 0x06, "mailto:")
-            .put((byte) 0x07, "ftp://anonymous:anonymous@")
-            .put((byte) 0x08, "ftp://ftp.")
-            .put((byte) 0x09, "ftps://")
-            .put((byte) 0x0A, "sftp://")
-            .put((byte) 0x0B, "smb://")
-            .put((byte) 0x0C, "nfs://")
-            .put((byte) 0x0D, "ftp://")
-            .put((byte) 0x0E, "dav://")
-            .put((byte) 0x0F, "news:")
-            .put((byte) 0x10, "telnet://")
-            .put((byte) 0x11, "imap:")
-            .put((byte) 0x12, "rtsp://")
-            .put((byte) 0x13, "urn:")
-            .put((byte) 0x14, "pop:")
-            .put((byte) 0x15, "sip:")
-            .put((byte) 0x16, "sips:")
-            .put((byte) 0x17, "tftp:")
-            .put((byte) 0x18, "btspp://")
-            .put((byte) 0x19, "btl2cap://")
-            .put((byte) 0x1A, "btgoep://")
-            .put((byte) 0x1B, "tcpobex://")
-            .put((byte) 0x1C, "irdaobex://")
-            .put((byte) 0x1D, "file://")
-            .put((byte) 0x1E, "urn:epc:id:")
-            .put((byte) 0x1F, "urn:epc:tag:")
-            .put((byte) 0x20, "urn:epc:pat:")
-            .put((byte) 0x21, "urn:epc:raw:")
-            .put((byte) 0x22, "urn:epc:")
-            .put((byte) 0x23, "urn:nfc:")
-            .build();
-
-    private final Uri mUri;
-
-    private UriRecord(Uri uri) {
-        this.mUri = Preconditions.checkNotNull(uri);
-    }
-
-    public View getView(Activity activity, LayoutInflater inflater, ViewGroup parent, int offset) {
-        TextView text = (TextView) inflater.inflate(R.layout.tag_text, parent, false);
-        text.setText(mUri.toString());
-        return text;
-    }
-
-    public Uri getUri() {
-        return mUri;
-    }
-
-    /**
-     * Convert {@link android.nfc.NdefRecord} into a {@link android.net.Uri}.
-     * This will handle both TNF_WELL_KNOWN / RTD_URI and TNF_ABSOLUTE_URI.
-     *
-     * @throws IllegalArgumentException if the NdefRecord is not a record
-     *         containing a URI.
-     */
-    public static UriRecord parse(NdefRecord record) {
-        short tnf = record.getTnf();
-        if (tnf == NdefRecord.TNF_WELL_KNOWN) {
-            return parseWellKnown(record);
-        } else if (tnf == NdefRecord.TNF_ABSOLUTE_URI) {
-            return parseAbsolute(record);
-        }
-        throw new IllegalArgumentException("Unknown TNF " + tnf);
-    }
-
-    /** Parse and absolute URI record */
-    private static UriRecord parseAbsolute(NdefRecord record) {
-        byte[] payload = record.getPayload();
-        Uri uri = Uri.parse(new String(payload, Charset.forName("UTF-8")));
-        return new UriRecord(uri);
-    }
-
-    /** Parse an well known URI record */
-    private static UriRecord parseWellKnown(NdefRecord record) {
-        Preconditions.checkArgument(Arrays.equals(record.getType(), NdefRecord.RTD_URI));
-        byte[] payload = record.getPayload();
-        /*
-         * payload[0] contains the URI Identifier Code, per the
-         * NFC Forum "URI Record Type Definition" section 3.2.2.
-         *
-         * payload[1]...payload[payload.length - 1] contains the rest of
-         * the URI.
-         */
-        String prefix = URI_PREFIX_MAP.get(payload[0]);
-        byte[] fullUri =
-            Bytes.concat(prefix.getBytes(Charset.forName("UTF-8")), Arrays.copyOfRange(payload, 1,
-                payload.length));
-        Uri uri = Uri.parse(new String(fullUri, Charset.forName("UTF-8")));
-        return new UriRecord(uri);
-    }
-
-    public static boolean isUri(NdefRecord record) {
-        try {
-            parse(record);
-            return true;
-        } catch (IllegalArgumentException e) {
-            return false;
-        }
-    }
-
-    private static final byte[] EMPTY = new byte[0];
-}
diff --git a/samples/NFCDemo/src/com/example/android/nfc/simulator/FakeTagsActivity.java b/samples/NFCDemo/src/com/example/android/nfc/simulator/FakeTagsActivity.java
deleted file mode 100644
index 313bab4..0000000
--- a/samples/NFCDemo/src/com/example/android/nfc/simulator/FakeTagsActivity.java
+++ /dev/null
@@ -1,108 +0,0 @@
-/*
- * Copyright (C) 2010 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License
- */
-package com.example.android.nfc.simulator;
-
-import android.app.ListActivity;
-import android.content.Intent;
-import android.nfc.NdefMessage;
-import android.nfc.NdefRecord;
-import android.nfc.NfcAdapter;
-import android.os.Bundle;
-import android.view.View;
-import android.widget.ArrayAdapter;
-import android.widget.ListView;
-
-import com.google.common.base.Charsets;
-import com.google.common.base.Preconditions;
-import com.google.common.primitives.Bytes;
-
-import java.nio.charset.Charset;
-import java.util.Locale;
-
-/**
- * A activity that launches tags as if they had been scanned.
- */
-public class FakeTagsActivity extends ListActivity {
-
-    static final String TAG = "FakeTagsActivity";
-
-    static final byte[] UID = new byte[] {0x05, 0x00, 0x03, 0x08};
-
-    ArrayAdapter<TagDescription> mAdapter;
-
-    public static NdefRecord newTextRecord(String text, Locale locale, boolean encodeInUtf8) {
-        Preconditions.checkNotNull(text);
-        Preconditions.checkNotNull(locale);
-        final byte[] langBytes = locale.getLanguage().getBytes(Charsets.US_ASCII);
-        final Charset utfEncoding = encodeInUtf8 ? Charsets.UTF_8 : Charset.forName("UTF-16");
-        final byte[] textBytes = text.getBytes(utfEncoding);
-        final int utfBit = encodeInUtf8 ? 0 : (1 << 7);
-        final char status = (char) (utfBit + langBytes.length);
-        final byte[] data = Bytes.concat(new byte[] {(byte) status}, langBytes, textBytes);
-        return new NdefRecord(NdefRecord.TNF_WELL_KNOWN, NdefRecord.RTD_TEXT, new byte[0], data);
-    }
-
-    public static NdefRecord newMimeRecord(String type, byte[] data) {
-        Preconditions.checkNotNull(type);
-        Preconditions.checkNotNull(data);
-        final byte[] typeBytes = type.getBytes(Charsets.US_ASCII);
-        return new NdefRecord(NdefRecord.TNF_MIME_MEDIA, typeBytes, new byte[0], data);
-    }
-
-    static final class TagDescription {
-
-        public String title;
-
-        public NdefMessage[] msgs;
-
-        public TagDescription(String title, byte[] bytes) {
-            this.title = title;
-            try {
-                msgs = new NdefMessage[] {new NdefMessage(bytes)};
-            } catch (final Exception e) {
-                throw new RuntimeException("Failed to create tag description", e);
-            }
-        }
-
-        @Override
-        public String toString() {
-            return title;
-        }
-    }
-
-    @Override
-    public void onCreate(Bundle savedState) {
-        super.onCreate(savedState);
-        final ArrayAdapter<TagDescription> adapter = new ArrayAdapter<TagDescription>(
-            this, android.R.layout.simple_list_item_1, android.R.id.text1);
-        adapter.add(
-            new TagDescription("Broadcast NFC Text Tag", MockNdefMessages.ENGLISH_PLAIN_TEXT));
-        adapter.add(new TagDescription(
-            "Broadcast NFC SmartPoster URL & text", MockNdefMessages.SMART_POSTER_URL_AND_TEXT));
-        adapter.add(new TagDescription(
-            "Broadcast NFC SmartPoster URL", MockNdefMessages.SMART_POSTER_URL_NO_TEXT));
-        setListAdapter(adapter);
-        mAdapter = adapter;
-    }
-
-    @Override
-    public void onListItemClick(ListView l, View v, int position, long id) {
-        final TagDescription description = mAdapter.getItem(position);
-        final Intent intent = new Intent(NfcAdapter.ACTION_TAG_DISCOVERED);
-        intent.putExtra(NfcAdapter.EXTRA_NDEF_MESSAGES, description.msgs);
-        startActivity(intent);
-    }
-}
diff --git a/samples/NFCDemo/src/com/example/android/nfc/simulator/MockNdefMessages.java b/samples/NFCDemo/src/com/example/android/nfc/simulator/MockNdefMessages.java
deleted file mode 100644
index 52a122f..0000000
--- a/samples/NFCDemo/src/com/example/android/nfc/simulator/MockNdefMessages.java
+++ /dev/null
@@ -1,59 +0,0 @@
-/*
- * Copyright (C) 2010 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package com.example.android.nfc.simulator;
-
-/**
- * This class provides a list of fake NFC Ndef format Tags.
- */
-public class MockNdefMessages {
-
-    /**
-     * A Smart Poster containing a URL and no text.
-     */
-    public static final byte[] SMART_POSTER_URL_NO_TEXT =
-        new byte[] {(byte) 0xd1, (byte) 0x02, (byte) 0x0f, (byte) 0x53, (byte) 0x70, (byte) 0xd1,
-            (byte) 0x01, (byte) 0x0b, (byte) 0x55, (byte) 0x01, (byte) 0x67, (byte) 0x6f,
-            (byte) 0x6f, (byte) 0x67, (byte) 0x6c, (byte) 0x65, (byte) 0x2e, (byte) 0x63,
-            (byte) 0x6f, (byte) 0x6d};
-
-    /**
-     * A plain text tag in english.
-     */
-    public static final byte[] ENGLISH_PLAIN_TEXT =
-        new byte[] {(byte) 0xd1, (byte) 0x01, (byte) 0x1c, (byte) 0x54, (byte) 0x02, (byte) 0x65,
-            (byte) 0x6e, (byte) 0x53, (byte) 0x6f, (byte) 0x6d, (byte) 0x65, (byte) 0x20,
-            (byte) 0x72, (byte) 0x61, (byte) 0x6e, (byte) 0x64, (byte) 0x6f, (byte) 0x6d,
-            (byte) 0x20, (byte) 0x65, (byte) 0x6e, (byte) 0x67, (byte) 0x6c, (byte) 0x69,
-            (byte) 0x73, (byte) 0x68, (byte) 0x20, (byte) 0x74, (byte) 0x65, (byte) 0x78,
-            (byte) 0x74, (byte) 0x2e};
-
-    /**
-     * Smart Poster containing a URL and Text.
-     */
-    public static final byte[] SMART_POSTER_URL_AND_TEXT =
-        new byte[] {(byte) 0xd1, (byte) 0x02, (byte) 0x1c, (byte) 0x53, (byte) 0x70, (byte) 0x91,
-            (byte) 0x01, (byte) 0x09, (byte) 0x54, (byte) 0x02, (byte) 0x65, (byte) 0x6e,
-            (byte) 0x47, (byte) 0x6f, (byte) 0x6f, (byte) 0x67, (byte) 0x6c, (byte) 0x65,
-            (byte) 0x51, (byte) 0x01, (byte) 0x0b, (byte) 0x55, (byte) 0x01, (byte) 0x67,
-            (byte) 0x6f, (byte) 0x6f, (byte) 0x67, (byte) 0x6c, (byte) 0x65, (byte) 0x2e,
-            (byte) 0x63, (byte) 0x6f, (byte) 0x6d};
-
-    /**
-     * All the mock Ndef tags.
-     */
-    public static final byte[][] ALL_MOCK_MESSAGES =
-        new byte[][] {SMART_POSTER_URL_NO_TEXT, ENGLISH_PLAIN_TEXT, SMART_POSTER_URL_AND_TEXT};
-}
diff --git a/samples/RenderScript/Balls/src/com/example/android/rs/balls/ball_physics.rs b/samples/RenderScript/Balls/src/com/example/android/rs/balls/ball_physics.rs
index ee6ab1d..0d9bdc3 100644
--- a/samples/RenderScript/Balls/src/com/example/android/rs/balls/ball_physics.rs
+++ b/samples/RenderScript/Balls/src/com/example/android/rs/balls/ball_physics.rs
@@ -58,7 +58,7 @@
                     //ballOut->color.rgb = 1.f;
                     //ballOut->arcID = -1;
                     //ballOut->arcStr = 0;
-                    return;
+                    continue;
                 }
                 // Collision
                 float2 axis = normalize(vec);
diff --git a/samples/RenderScript/Balls/src/com/example/android/rs/balls/balls.rs b/samples/RenderScript/Balls/src/com/example/android/rs/balls/balls.rs
index d61557c..39bebbf 100644
--- a/samples/RenderScript/Balls/src/com/example/android/rs/balls/balls.rs
+++ b/samples/RenderScript/Balls/src/com/example/android/rs/balls/balls.rs
@@ -58,11 +58,11 @@
     if (frame & 1) {
         bc.ain = rsGetAllocation(balls2);
         bc.aout = rsGetAllocation(balls1);
-        bout = balls2;
+        bout = balls1;
     } else {
         bc.ain = rsGetAllocation(balls1);
         bc.aout = rsGetAllocation(balls2);
-        bout = balls1;
+        bout = balls2;
     }
 
     bc.dimX = rsAllocationGetDimX(bc.ain);
diff --git a/samples/RenderScript/Levels/Android.mk b/samples/RenderScript/Levels/Android.mk
new file mode 100644
index 0000000..3f1445d
--- /dev/null
+++ b/samples/RenderScript/Levels/Android.mk
@@ -0,0 +1,26 @@
+#
+# Copyright (C) 2012 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.
+#
+
+LOCAL_PATH := $(call my-dir)
+include $(CLEAR_VARS)
+
+LOCAL_MODULE_TAGS := optional
+
+LOCAL_SRC_FILES := $(call all-java-files-under, src) $(call all-renderscript-files-under, src)
+
+LOCAL_PACKAGE_NAME := LevelsRS
+
+include $(BUILD_PACKAGE)
diff --git a/samples/RenderScript/Levels/AndroidManifest.xml b/samples/RenderScript/Levels/AndroidManifest.xml
new file mode 100644
index 0000000..8294048
--- /dev/null
+++ b/samples/RenderScript/Levels/AndroidManifest.xml
@@ -0,0 +1,43 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+/*
+* Copyright (C) 2012 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.
+*/
+-->
+
+<manifest xmlns:android="http://schemas.android.com/apk/res/android"
+    package="com.android.rs.levels">
+    <uses-sdk android:minSdkVersion="14" />
+    <application android:label="Levels RS"
+                 android:hardwareAccelerated="true">
+
+        <activity android:name="LevelsRSActivity"
+                  android:label="Levels RS">
+            <intent-filter>
+                <action android:name="android.intent.action.MAIN" />
+                <category android:name="android.intent.category.LAUNCHER" />
+            </intent-filter>
+        </activity>
+
+        <activity android:name="LevelsDalvikActivity"
+                  android:label="Levels Dalvik">
+            <intent-filter>
+                <action android:name="android.intent.action.MAIN" />
+                <category android:name="android.intent.category.LAUNCHER" />
+            </intent-filter>
+        </activity>
+
+    </application>
+</manifest>
diff --git a/samples/RenderScript/Levels/res/drawable-nodpi/city.png b/samples/RenderScript/Levels/res/drawable-nodpi/city.png
new file mode 100644
index 0000000..856eeff
--- /dev/null
+++ b/samples/RenderScript/Levels/res/drawable-nodpi/city.png
Binary files differ
diff --git a/samples/RenderScript/Levels/res/layout/main.xml b/samples/RenderScript/Levels/res/layout/main.xml
new file mode 100644
index 0000000..a6a075c
--- /dev/null
+++ b/samples/RenderScript/Levels/res/layout/main.xml
@@ -0,0 +1,140 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Copyright (C) 2012 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"
+            android:id="@+id/toplevel">
+    <SurfaceView
+        android:id="@+id/surface"
+        android:layout_width="1dip"
+        android:layout_height="1dip" />
+    <ScrollView
+        android:layout_width="fill_parent"
+        android:layout_height="fill_parent">
+            <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
+                android:orientation="vertical"
+                android:layout_width="fill_parent"
+                android:layout_height="fill_parent">
+            <ImageView
+                android:id="@+id/display"
+                android:layout_width="wrap_content"
+                android:layout_height="wrap_content" />
+            <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
+                android:orientation="horizontal"
+                android:layout_width="fill_parent"
+                android:layout_height="wrap_content">
+                    <Button
+                        android:layout_width="wrap_content"
+                        android:layout_height="wrap_content"
+                        android:text="@string/benchmark"
+                        android:onClick="benchmark"/>
+                    <TextView
+                        android:id="@+id/benchmarkText"
+                        android:layout_width="match_parent"
+                        android:layout_height="wrap_content"
+                        android:textSize="8pt"
+                        android:text="@string/saturation"/>
+            </LinearLayout>
+            <TextView
+                android:id="@+id/inSaturationText"
+                android:layout_width="match_parent"
+                android:layout_height="wrap_content"
+                android:textSize="8pt"
+                android:layout_marginLeft="10sp"
+                android:layout_marginTop="15sp"
+                android:text="@string/saturation"/>
+             <SeekBar
+                android:id="@+id/inSaturation"
+                android:layout_marginLeft="10sp"
+                android:layout_marginRight="10sp"
+                android:layout_width="match_parent"
+                android:layout_height="wrap_content"/>
+            <TextView
+                android:id="@+id/outWhiteText"
+                android:layout_width="match_parent"
+                android:layout_height="wrap_content"
+                android:layout_marginLeft="10sp"
+                android:layout_marginTop="15sp"
+                android:textSize="8pt"
+                android:text="@string/out_white"/>
+            <SeekBar
+                android:id="@+id/outWhite"
+                android:layout_marginLeft="10sp"
+                android:layout_marginRight="10sp"
+                android:layout_width="match_parent"
+                android:layout_height="wrap_content"/>
+            <TextView
+                android:id="@+id/inWhiteText"
+                android:layout_width="match_parent"
+                android:layout_height="wrap_content"
+                android:textSize="8pt"
+                android:layout_marginLeft="10sp"
+                android:layout_marginTop="15sp"
+                android:text="@string/in_white"/>
+            <SeekBar
+                android:id="@+id/inWhite"
+                android:layout_marginLeft="10sp"
+                android:layout_marginRight="10sp"
+                android:layout_width="match_parent"
+                android:layout_height="wrap_content"/>
+            <TextView
+                android:id="@+id/outBlackText"
+                android:layout_width="match_parent"
+                android:layout_height="wrap_content"
+                android:textSize="8pt"
+                android:layout_marginLeft="10sp"
+                android:layout_marginTop="15sp"
+                android:text="@string/out_black"/>
+            <SeekBar
+                android:id="@+id/outBlack"
+                android:layout_marginLeft="10sp"
+                android:layout_marginRight="10sp"
+                android:layout_width="match_parent"
+                android:layout_height="wrap_content"/>
+            <TextView
+                android:id="@+id/inBlackText"
+                android:layout_width="match_parent"
+                android:layout_height="wrap_content"
+                android:textSize="8pt"
+                android:layout_marginLeft="10sp"
+                android:layout_marginTop="15sp"
+                android:text="@string/in_black"/>
+            <SeekBar
+                android:id="@+id/inBlack"
+                android:layout_marginLeft="10sp"
+                android:layout_marginRight="10sp"
+                android:layout_width="match_parent"
+                android:layout_height="wrap_content"/>
+            <TextView
+                android:id="@+id/inGammaText"
+                android:layout_width="match_parent"
+                android:layout_height="wrap_content"
+                android:textSize="8pt"
+                android:layout_marginLeft="10sp"
+                android:layout_marginTop="15sp"
+                android:text="@string/gamma"/>
+            <SeekBar
+                android:id="@+id/inGamma"
+                android:layout_marginLeft="10sp"
+                android:layout_marginRight="10sp"
+                android:layout_width="match_parent"
+                android:layout_height="wrap_content"/>
+            </LinearLayout>
+    </ScrollView>
+</LinearLayout>
+
diff --git a/samples/RenderScript/Levels/res/layout/rs.xml b/samples/RenderScript/Levels/res/layout/rs.xml
new file mode 100644
index 0000000..6fde1b9
--- /dev/null
+++ b/samples/RenderScript/Levels/res/layout/rs.xml
@@ -0,0 +1,140 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Copyright (C) 2012 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"
+            android:id="@+id/toplevel">
+    <SurfaceView
+        android:id="@+id/surface"
+        android:layout_width="1dip"
+        android:layout_height="1dip" />
+    <ScrollView
+        android:layout_width="fill_parent"
+        android:layout_height="fill_parent">
+            <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
+                android:orientation="vertical"
+                android:layout_width="fill_parent"
+                android:layout_height="fill_parent">
+            <TextureView
+                android:id="@+id/display"
+                android:layout_width="800sp"
+                android:layout_height="423sp" />
+            <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
+                android:orientation="horizontal"
+                android:layout_width="fill_parent"
+                android:layout_height="wrap_content">
+                    <Button
+                        android:layout_width="wrap_content"
+                        android:layout_height="wrap_content"
+                        android:text="@string/benchmark"
+                        android:onClick="benchmark"/>
+                    <TextView
+                        android:id="@+id/benchmarkText"
+                        android:layout_width="match_parent"
+                        android:layout_height="wrap_content"
+                        android:textSize="8pt"
+                        android:text="@string/saturation"/>
+            </LinearLayout>
+            <TextView
+                android:id="@+id/inSaturationText"
+                android:layout_width="match_parent"
+                android:layout_height="wrap_content"
+                android:textSize="8pt"
+                android:layout_marginLeft="10sp"
+                android:layout_marginTop="15sp"
+                android:text="@string/saturation"/>
+             <SeekBar
+                android:id="@+id/inSaturation"
+                android:layout_marginLeft="10sp"
+                android:layout_marginRight="10sp"
+                android:layout_width="match_parent"
+                android:layout_height="wrap_content"/>
+            <TextView
+                android:id="@+id/outWhiteText"
+                android:layout_width="match_parent"
+                android:layout_height="wrap_content"
+                android:layout_marginLeft="10sp"
+                android:layout_marginTop="15sp"
+                android:textSize="8pt"
+                android:text="@string/out_white"/>
+            <SeekBar
+                android:id="@+id/outWhite"
+                android:layout_marginLeft="10sp"
+                android:layout_marginRight="10sp"
+                android:layout_width="match_parent"
+                android:layout_height="wrap_content"/>
+            <TextView
+                android:id="@+id/inWhiteText"
+                android:layout_width="match_parent"
+                android:layout_height="wrap_content"
+                android:textSize="8pt"
+                android:layout_marginLeft="10sp"
+                android:layout_marginTop="15sp"
+                android:text="@string/in_white"/>
+            <SeekBar
+                android:id="@+id/inWhite"
+                android:layout_marginLeft="10sp"
+                android:layout_marginRight="10sp"
+                android:layout_width="match_parent"
+                android:layout_height="wrap_content"/>
+            <TextView
+                android:id="@+id/outBlackText"
+                android:layout_width="match_parent"
+                android:layout_height="wrap_content"
+                android:textSize="8pt"
+                android:layout_marginLeft="10sp"
+                android:layout_marginTop="15sp"
+                android:text="@string/out_black"/>
+            <SeekBar
+                android:id="@+id/outBlack"
+                android:layout_marginLeft="10sp"
+                android:layout_marginRight="10sp"
+                android:layout_width="match_parent"
+                android:layout_height="wrap_content"/>
+            <TextView
+                android:id="@+id/inBlackText"
+                android:layout_width="match_parent"
+                android:layout_height="wrap_content"
+                android:textSize="8pt"
+                android:layout_marginLeft="10sp"
+                android:layout_marginTop="15sp"
+                android:text="@string/in_black"/>
+            <SeekBar
+                android:id="@+id/inBlack"
+                android:layout_marginLeft="10sp"
+                android:layout_marginRight="10sp"
+                android:layout_width="match_parent"
+                android:layout_height="wrap_content"/>
+            <TextView
+                android:id="@+id/inGammaText"
+                android:layout_width="match_parent"
+                android:layout_height="wrap_content"
+                android:textSize="8pt"
+                android:layout_marginLeft="10sp"
+                android:layout_marginTop="15sp"
+                android:text="@string/gamma"/>
+            <SeekBar
+                android:id="@+id/inGamma"
+                android:layout_marginLeft="10sp"
+                android:layout_marginRight="10sp"
+                android:layout_width="match_parent"
+                android:layout_height="wrap_content"/>
+            </LinearLayout>
+    </ScrollView>
+</LinearLayout>
+
diff --git a/samples/RenderScript/Levels/res/values/strings.xml b/samples/RenderScript/Levels/res/values/strings.xml
new file mode 100644
index 0000000..0552d3b
--- /dev/null
+++ b/samples/RenderScript/Levels/res/values/strings.xml
@@ -0,0 +1,32 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+/*
+* Copyright (C) 2012 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.
+*/
+-->
+
+<resources xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">
+    <!-- General -->
+    <skip />
+    <!--slider label -->
+    <string name="in_white">In White</string>
+    <string name="out_white">Out White</string>
+    <string name="in_black">In Black</string>
+    <string name="out_black">Out Black</string>
+    <string name="gamma">Gamma</string>
+    <string name="saturation">Saturation</string>
+    <string name="benchmark">Benchmark</string>
+
+</resources>
diff --git a/samples/RenderScript/Levels/src/com/android/rs/levels/LevelsDalvikActivity.java b/samples/RenderScript/Levels/src/com/android/rs/levels/LevelsDalvikActivity.java
new file mode 100644
index 0000000..8d94bf8
--- /dev/null
+++ b/samples/RenderScript/Levels/src/com/android/rs/levels/LevelsDalvikActivity.java
@@ -0,0 +1,239 @@
+/*
+ * Copyright (C) 2012 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.rs.levels;
+
+import android.app.Activity;
+import android.graphics.Bitmap;
+import android.graphics.BitmapFactory;
+import android.graphics.Canvas;
+import android.os.Bundle;
+import android.renderscript.Matrix3f;
+import android.util.Log;
+import android.view.View;
+import android.widget.ImageView;
+import android.widget.SeekBar;
+import android.widget.TextView;
+
+public class LevelsDalvikActivity extends Activity
+                                  implements SeekBar.OnSeekBarChangeListener {
+    private final String TAG = "Img";
+    private Bitmap mBitmapIn;
+    private Bitmap mBitmapOut;
+    private float mInBlack = 0.0f;
+    private SeekBar mInBlackSeekBar;
+    private float mOutBlack = 0.0f;
+    private SeekBar mOutBlackSeekBar;
+    private float mInWhite = 255.0f;
+    private SeekBar mInWhiteSeekBar;
+    private float mOutWhite = 255.0f;
+    private SeekBar mOutWhiteSeekBar;
+    private float mGamma = 1.0f;
+    private SeekBar mGammaSeekBar;
+    private float mSaturation = 1.0f;
+    private SeekBar mSaturationSeekBar;
+    private TextView mBenchmarkResult;
+    private ImageView mDisplayView;
+
+    Matrix3f satMatrix = new Matrix3f();
+    float mInWMinInB;
+    float mOutWMinOutB;
+    float mOverInWMinInB;
+
+    int mInPixels[];
+    int mOutPixels[];
+
+    private void setLevels() {
+        mInWMinInB = mInWhite - mInBlack;
+        mOutWMinOutB = mOutWhite - mOutBlack;
+        mOverInWMinInB = 1.f / mInWMinInB;
+    }
+
+    private void setSaturation() {
+        float rWeight = 0.299f;
+        float gWeight = 0.587f;
+        float bWeight = 0.114f;
+        float oneMinusS = 1.0f - mSaturation;
+
+        satMatrix.set(0, 0, oneMinusS * rWeight + mSaturation);
+        satMatrix.set(0, 1, oneMinusS * rWeight);
+        satMatrix.set(0, 2, oneMinusS * rWeight);
+        satMatrix.set(1, 0, oneMinusS * gWeight);
+        satMatrix.set(1, 1, oneMinusS * gWeight + mSaturation);
+        satMatrix.set(1, 2, oneMinusS * gWeight);
+        satMatrix.set(2, 0, oneMinusS * bWeight);
+        satMatrix.set(2, 1, oneMinusS * bWeight);
+        satMatrix.set(2, 2, oneMinusS * bWeight + mSaturation);
+    }
+
+    public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) {
+        if (fromUser) {
+            if (seekBar == mInBlackSeekBar) {
+                mInBlack = (float)progress;
+                setLevels();
+            } else if (seekBar == mOutBlackSeekBar) {
+                mOutBlack = (float)progress;
+                setLevels();
+            } else if (seekBar == mInWhiteSeekBar) {
+                mInWhite = (float)progress + 127.0f;
+                setLevels();
+            } else if (seekBar == mOutWhiteSeekBar) {
+                mOutWhite = (float)progress + 127.0f;
+                setLevels();
+            } else if (seekBar == mGammaSeekBar) {
+                mGamma = (float)progress/100.0f;
+                mGamma = Math.max(mGamma, 0.1f);
+                mGamma = 1.0f / mGamma;
+            } else if (seekBar == mSaturationSeekBar) {
+                mSaturation = (float)progress / 50.0f;
+                setSaturation();
+            }
+
+            filter();
+            mDisplayView.invalidate();
+        }
+    }
+
+    public void onStartTrackingTouch(SeekBar seekBar) {
+    }
+
+    public void onStopTrackingTouch(SeekBar seekBar) {
+    }
+
+    @Override
+    protected void onCreate(Bundle savedInstanceState) {
+        super.onCreate(savedInstanceState);
+        setContentView(R.layout.main);
+
+        mBitmapIn = loadBitmap(R.drawable.city);
+        mBitmapOut = loadBitmap(R.drawable.city);
+
+        mDisplayView = (ImageView) findViewById(R.id.display);
+        mDisplayView.setImageBitmap(mBitmapOut);
+
+        mInBlackSeekBar = (SeekBar)findViewById(R.id.inBlack);
+        mInBlackSeekBar.setOnSeekBarChangeListener(this);
+        mInBlackSeekBar.setMax(128);
+        mInBlackSeekBar.setProgress(0);
+        mOutBlackSeekBar = (SeekBar)findViewById(R.id.outBlack);
+        mOutBlackSeekBar.setOnSeekBarChangeListener(this);
+        mOutBlackSeekBar.setMax(128);
+        mOutBlackSeekBar.setProgress(0);
+
+        mInWhiteSeekBar = (SeekBar)findViewById(R.id.inWhite);
+        mInWhiteSeekBar.setOnSeekBarChangeListener(this);
+        mInWhiteSeekBar.setMax(128);
+        mInWhiteSeekBar.setProgress(128);
+        mOutWhiteSeekBar = (SeekBar)findViewById(R.id.outWhite);
+        mOutWhiteSeekBar.setOnSeekBarChangeListener(this);
+        mOutWhiteSeekBar.setMax(128);
+        mOutWhiteSeekBar.setProgress(128);
+
+        mGammaSeekBar = (SeekBar)findViewById(R.id.inGamma);
+        mGammaSeekBar.setOnSeekBarChangeListener(this);
+        mGammaSeekBar.setMax(150);
+        mGammaSeekBar.setProgress(100);
+
+        mSaturationSeekBar = (SeekBar)findViewById(R.id.inSaturation);
+        mSaturationSeekBar.setOnSeekBarChangeListener(this);
+        mSaturationSeekBar.setProgress(50);
+
+        mBenchmarkResult = (TextView) findViewById(R.id.benchmarkText);
+        mBenchmarkResult.setText("Result: not run");
+
+        mInPixels = new int[mBitmapIn.getHeight() * mBitmapIn.getWidth()];
+        mOutPixels = new int[mBitmapOut.getHeight() * mBitmapOut.getWidth()];
+        mBitmapIn.getPixels(mInPixels, 0, mBitmapIn.getWidth(), 0, 0,
+                            mBitmapIn.getWidth(), mBitmapIn.getHeight());
+
+        setLevels();
+        setSaturation();
+        filter();
+    }
+
+    private Bitmap loadBitmap(int resource) {
+        final BitmapFactory.Options options = new BitmapFactory.Options();
+        options.inPreferredConfig = Bitmap.Config.ARGB_8888;
+        Bitmap b = BitmapFactory.decodeResource(getResources(), resource, options);
+        Bitmap b2 = Bitmap.createBitmap(b.getWidth(), b.getHeight(), b.getConfig());
+        Canvas c = new Canvas(b2);
+        c.drawBitmap(b, 0, 0, null);
+        b.recycle();
+        return b2;
+    }
+
+
+
+    private void filter() {
+        final float[] m = satMatrix.getArray();
+
+        for (int i=0; i < mInPixels.length; i++) {
+            float r = (float)(mInPixels[i] & 0xff);
+            float g = (float)((mInPixels[i] >> 8) & 0xff);
+            float b = (float)((mInPixels[i] >> 16) & 0xff);
+
+            float tr = r * m[0] + g * m[3] + b * m[6];
+            float tg = r * m[1] + g * m[4] + b * m[7];
+            float tb = r * m[2] + g * m[5] + b * m[8];
+            r = tr;
+            g = tg;
+            b = tb;
+
+            if (r < 0.f) r = 0.f;
+            if (r > 255.f) r = 255.f;
+            if (g < 0.f) g = 0.f;
+            if (g > 255.f) g = 255.f;
+            if (b < 0.f) b = 0.f;
+            if (b > 255.f) b = 255.f;
+
+            r = (r - mInBlack) * mOverInWMinInB;
+            g = (g - mInBlack) * mOverInWMinInB;
+            b = (b - mInBlack) * mOverInWMinInB;
+
+            if (mGamma != 1.0f) {
+                r = (float)java.lang.Math.pow(r, mGamma);
+                g = (float)java.lang.Math.pow(g, mGamma);
+                b = (float)java.lang.Math.pow(b, mGamma);
+            }
+
+            r = (r * mOutWMinOutB) + mOutBlack;
+            g = (g * mOutWMinOutB) + mOutBlack;
+            b = (b * mOutWMinOutB) + mOutBlack;
+
+            if (r < 0.f) r = 0.f;
+            if (r > 255.f) r = 255.f;
+            if (g < 0.f) g = 0.f;
+            if (g > 255.f) g = 255.f;
+            if (b < 0.f) b = 0.f;
+            if (b > 255.f) b = 255.f;
+
+            mOutPixels[i] = ((int)r) + (((int)g) << 8) + (((int)b) << 16)
+                            + (mInPixels[i] & 0xff000000);
+        }
+
+        mBitmapOut.setPixels(mOutPixels, 0, mBitmapOut.getWidth(), 0, 0,
+                             mBitmapOut.getWidth(), mBitmapOut.getHeight());
+    }
+
+    public void benchmark(View v) {
+        filter();
+        long t = java.lang.System.currentTimeMillis();
+        filter();
+        t = java.lang.System.currentTimeMillis() - t;
+        mDisplayView.invalidate();
+        mBenchmarkResult.setText("Result: " + t + " ms");
+    }
+}
diff --git a/samples/RenderScript/Levels/src/com/android/rs/levels/LevelsRSActivity.java b/samples/RenderScript/Levels/src/com/android/rs/levels/LevelsRSActivity.java
new file mode 100644
index 0000000..d63ee44
--- /dev/null
+++ b/samples/RenderScript/Levels/src/com/android/rs/levels/LevelsRSActivity.java
@@ -0,0 +1,232 @@
+/*
+ * Copyright (C) 2012 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.rs.levels;
+
+import android.app.Activity;
+import android.graphics.Bitmap;
+import android.graphics.BitmapFactory;
+import android.graphics.Canvas;
+import android.os.Bundle;
+import android.graphics.SurfaceTexture;
+import android.renderscript.Allocation;
+import android.renderscript.Matrix3f;
+import android.renderscript.RenderScript;
+import android.util.Log;
+import android.view.TextureView;
+import android.view.View;
+import android.widget.ImageView;
+import android.widget.SeekBar;
+import android.widget.TextView;
+
+public class LevelsRSActivity extends Activity
+                              implements SeekBar.OnSeekBarChangeListener,
+                                         TextureView.SurfaceTextureListener
+{
+    private final String TAG = "Img";
+    private Bitmap mBitmapIn;
+    private float mInBlack = 0.0f;
+    private SeekBar mInBlackSeekBar;
+    private float mOutBlack = 0.0f;
+    private SeekBar mOutBlackSeekBar;
+    private float mInWhite = 255.0f;
+    private SeekBar mInWhiteSeekBar;
+    private float mOutWhite = 255.0f;
+    private SeekBar mOutWhiteSeekBar;
+    private float mGamma = 1.0f;
+    private SeekBar mGammaSeekBar;
+    private float mSaturation = 1.0f;
+    private SeekBar mSaturationSeekBar;
+    private TextView mBenchmarkResult;
+    private TextureView mDisplayView;
+
+    Matrix3f satMatrix = new Matrix3f();
+    float mInWMinInB;
+    float mOutWMinOutB;
+    float mOverInWMinInB;
+
+    private RenderScript mRS;
+    private Allocation mInPixelsAllocation;
+    private Allocation mOutPixelsAllocation;
+    private ScriptC_levels mScript;
+
+    private void setLevels() {
+        mInWMinInB = mInWhite - mInBlack;
+        mOutWMinOutB = mOutWhite - mOutBlack;
+        mOverInWMinInB = 1.f / mInWMinInB;
+
+        mScript.set_inBlack(mInBlack);
+        mScript.set_outBlack(mOutBlack);
+        mScript.set_inWMinInB(mInWMinInB);
+        mScript.set_outWMinOutB(mOutWMinOutB);
+        mScript.set_overInWMinInB(mOverInWMinInB);
+    }
+
+    private void setSaturation() {
+        float rWeight = 0.299f;
+        float gWeight = 0.587f;
+        float bWeight = 0.114f;
+        float oneMinusS = 1.0f - mSaturation;
+
+        satMatrix.set(0, 0, oneMinusS * rWeight + mSaturation);
+        satMatrix.set(0, 1, oneMinusS * rWeight);
+        satMatrix.set(0, 2, oneMinusS * rWeight);
+        satMatrix.set(1, 0, oneMinusS * gWeight);
+        satMatrix.set(1, 1, oneMinusS * gWeight + mSaturation);
+        satMatrix.set(1, 2, oneMinusS * gWeight);
+        satMatrix.set(2, 0, oneMinusS * bWeight);
+        satMatrix.set(2, 1, oneMinusS * bWeight);
+        satMatrix.set(2, 2, oneMinusS * bWeight + mSaturation);
+        mScript.set_colorMat(satMatrix);
+    }
+
+    public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) {
+        if (fromUser) {
+            if (seekBar == mInBlackSeekBar) {
+                mInBlack = (float)progress;
+                setLevels();
+            } else if (seekBar == mOutBlackSeekBar) {
+                mOutBlack = (float)progress;
+                setLevels();
+            } else if (seekBar == mInWhiteSeekBar) {
+                mInWhite = (float)progress + 127.0f;
+                setLevels();
+            } else if (seekBar == mOutWhiteSeekBar) {
+                mOutWhite = (float)progress + 127.0f;
+                setLevels();
+            } else if (seekBar == mGammaSeekBar) {
+                mGamma = (float)progress/100.0f;
+                mGamma = Math.max(mGamma, 0.1f);
+                mGamma = 1.0f / mGamma;
+                mScript.set_gamma(mGamma);
+            } else if (seekBar == mSaturationSeekBar) {
+                mSaturation = (float)progress / 50.0f;
+                setSaturation();
+            }
+
+            filter();
+            mDisplayView.invalidate();
+        }
+    }
+
+    public void onStartTrackingTouch(SeekBar seekBar) {
+    }
+
+    public void onStopTrackingTouch(SeekBar seekBar) {
+    }
+
+    @Override
+    protected void onCreate(Bundle savedInstanceState) {
+        super.onCreate(savedInstanceState);
+        setContentView(R.layout.rs);
+
+        mBitmapIn = loadBitmap(R.drawable.city);
+        mDisplayView = (TextureView) findViewById(R.id.display);
+
+        mInBlackSeekBar = (SeekBar)findViewById(R.id.inBlack);
+        mInBlackSeekBar.setOnSeekBarChangeListener(this);
+        mInBlackSeekBar.setMax(128);
+        mInBlackSeekBar.setProgress(0);
+        mOutBlackSeekBar = (SeekBar)findViewById(R.id.outBlack);
+        mOutBlackSeekBar.setOnSeekBarChangeListener(this);
+        mOutBlackSeekBar.setMax(128);
+        mOutBlackSeekBar.setProgress(0);
+
+        mInWhiteSeekBar = (SeekBar)findViewById(R.id.inWhite);
+        mInWhiteSeekBar.setOnSeekBarChangeListener(this);
+        mInWhiteSeekBar.setMax(128);
+        mInWhiteSeekBar.setProgress(128);
+        mOutWhiteSeekBar = (SeekBar)findViewById(R.id.outWhite);
+        mOutWhiteSeekBar.setOnSeekBarChangeListener(this);
+        mOutWhiteSeekBar.setMax(128);
+        mOutWhiteSeekBar.setProgress(128);
+
+        mGammaSeekBar = (SeekBar)findViewById(R.id.inGamma);
+        mGammaSeekBar.setOnSeekBarChangeListener(this);
+        mGammaSeekBar.setMax(150);
+        mGammaSeekBar.setProgress(100);
+
+        mSaturationSeekBar = (SeekBar)findViewById(R.id.inSaturation);
+        mSaturationSeekBar.setOnSeekBarChangeListener(this);
+        mSaturationSeekBar.setProgress(50);
+
+        mBenchmarkResult = (TextView) findViewById(R.id.benchmarkText);
+        mBenchmarkResult.setText("Result: not run");
+
+        mRS = RenderScript.create(this);
+        mInPixelsAllocation = Allocation.createFromBitmap(mRS, mBitmapIn,
+                                                          Allocation.MipmapControl.MIPMAP_NONE,
+                                                          Allocation.USAGE_SCRIPT);
+        mOutPixelsAllocation = Allocation.createTyped(mRS, mInPixelsAllocation.getType(),
+                                                      Allocation.USAGE_SCRIPT |
+                                                      Allocation.USAGE_IO_OUTPUT);
+        mDisplayView.setSurfaceTextureListener(this);
+
+        mScript = new ScriptC_levels(mRS, getResources(), R.raw.levels);
+        mScript.set_gamma(mGamma);
+
+        setSaturation();
+        setLevels();
+    }
+
+    private Bitmap loadBitmap(int resource) {
+        final BitmapFactory.Options options = new BitmapFactory.Options();
+        options.inPreferredConfig = Bitmap.Config.ARGB_8888;
+        Bitmap b = BitmapFactory.decodeResource(getResources(), resource, options);
+        Bitmap b2 = Bitmap.createBitmap(b.getWidth(), b.getHeight(), b.getConfig());
+        Canvas c = new Canvas(b2);
+        c.drawBitmap(b, 0, 0, null);
+        b.recycle();
+        return b2;
+    }
+
+    private void filter() {
+        mScript.forEach_root(mInPixelsAllocation, mOutPixelsAllocation);
+        mOutPixelsAllocation.ioSendOutput();
+        mRS.finish();
+    }
+
+    public void benchmark(View v) {
+        filter();
+        long t = java.lang.System.currentTimeMillis();
+        filter();
+        t = java.lang.System.currentTimeMillis() - t;
+        mDisplayView.invalidate();
+        mBenchmarkResult.setText("Result: " + t + " ms");
+    }
+
+
+    @Override
+    public void onSurfaceTextureAvailable(SurfaceTexture surface, int width, int height) {
+        mOutPixelsAllocation.setSurfaceTexture(surface);
+        filter();
+    }
+
+    @Override
+    public void onSurfaceTextureSizeChanged(SurfaceTexture surface, int width, int height) {
+        mOutPixelsAllocation.setSurfaceTexture(surface);
+    }
+
+    @Override
+    public boolean onSurfaceTextureDestroyed(SurfaceTexture surface) {
+        mOutPixelsAllocation.setSurfaceTexture(null);
+        return true;
+    }
+
+    @Override
+    public void onSurfaceTextureUpdated(SurfaceTexture surface) {
+    }
+}
diff --git a/samples/RenderScript/Levels/src/com/android/rs/levels/levels.rs b/samples/RenderScript/Levels/src/com/android/rs/levels/levels.rs
new file mode 100644
index 0000000..eecb4f1
--- /dev/null
+++ b/samples/RenderScript/Levels/src/com/android/rs/levels/levels.rs
@@ -0,0 +1,40 @@
+/*
+ * Copyright (C) 2012 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.
+ */
+
+#pragma version(1)
+#pragma rs java_package_name(com.android.rs.levels)
+
+float inBlack;
+float outBlack;
+float inWMinInB;
+float outWMinOutB;
+float overInWMinInB;
+float gamma;
+rs_matrix3x3 colorMat;
+
+void root(const uchar4 *in, uchar4 *out, uint32_t x, uint32_t y) {
+    float3 pixel = convert_float4(in[0]).rgb;
+    pixel = rsMatrixMultiply(&colorMat, pixel);
+    pixel = clamp(pixel, 0.f, 255.f);
+    pixel = (pixel - inBlack) * overInWMinInB;
+    if (gamma != 1.0f)
+        pixel = pow(pixel, (float3)gamma);
+    pixel = pixel * outWMinOutB + outBlack;
+    pixel = clamp(pixel, 0.f, 255.f);
+    out->xyz = convert_uchar3(pixel);
+    out->w = 0xff;
+}
+
diff --git a/samples/RenderScript/MiscSamples/res/drawable/checker.png b/samples/RenderScript/MiscSamples/res/drawable-nodpi/checker.png
similarity index 100%
rename from samples/RenderScript/MiscSamples/res/drawable/checker.png
rename to samples/RenderScript/MiscSamples/res/drawable-nodpi/checker.png
Binary files differ
diff --git a/samples/RenderScript/MiscSamples/res/drawable/cubemap_test.png b/samples/RenderScript/MiscSamples/res/drawable-nodpi/cubemap_test.png
similarity index 100%
rename from samples/RenderScript/MiscSamples/res/drawable/cubemap_test.png
rename to samples/RenderScript/MiscSamples/res/drawable-nodpi/cubemap_test.png
Binary files differ
diff --git a/samples/RenderScript/MiscSamples/res/drawable/data.png b/samples/RenderScript/MiscSamples/res/drawable-nodpi/data.png
similarity index 100%
rename from samples/RenderScript/MiscSamples/res/drawable/data.png
rename to samples/RenderScript/MiscSamples/res/drawable-nodpi/data.png
Binary files differ
diff --git a/samples/RenderScript/MiscSamples/res/drawable/leaf.png b/samples/RenderScript/MiscSamples/res/drawable-nodpi/leaf.png
similarity index 100%
rename from samples/RenderScript/MiscSamples/res/drawable/leaf.png
rename to samples/RenderScript/MiscSamples/res/drawable-nodpi/leaf.png
Binary files differ
diff --git a/samples/RenderScript/MiscSamples/res/drawable/test_pattern.png b/samples/RenderScript/MiscSamples/res/drawable-nodpi/test_pattern.png
similarity index 100%
rename from samples/RenderScript/MiscSamples/res/drawable/test_pattern.png
rename to samples/RenderScript/MiscSamples/res/drawable-nodpi/test_pattern.png
Binary files differ
diff --git a/samples/RenderScript/MiscSamples/res/drawable/torusmap.png b/samples/RenderScript/MiscSamples/res/drawable-nodpi/torusmap.png
similarity index 100%
rename from samples/RenderScript/MiscSamples/res/drawable/torusmap.png
rename to samples/RenderScript/MiscSamples/res/drawable-nodpi/torusmap.png
Binary files differ
diff --git a/samples/SimpleJNI/jni/native.cpp b/samples/SimpleJNI/jni/native.cpp
index 4d2e4e0..853c3d9 100644
--- a/samples/SimpleJNI/jni/native.cpp
+++ b/samples/SimpleJNI/jni/native.cpp
@@ -24,7 +24,7 @@
 static jint
 add(JNIEnv *env, jobject thiz, jint a, jint b) {
 int result = a + b;
-    LOGI("%d + %d = %d", a, b, result);
+    ALOGI("%d + %d = %d", a, b, result);
     return result;
 }
 
@@ -44,11 +44,11 @@
 
     clazz = env->FindClass(className);
     if (clazz == NULL) {
-        LOGE("Native registration unable to find class '%s'", className);
+        ALOGE("Native registration unable to find class '%s'", className);
         return JNI_FALSE;
     }
     if (env->RegisterNatives(clazz, gMethods, numMethods) < 0) {
-        LOGE("RegisterNatives failed for '%s'", className);
+        ALOGE("RegisterNatives failed for '%s'", className);
         return JNI_FALSE;
     }
 
@@ -89,16 +89,16 @@
     jint result = -1;
     JNIEnv* env = NULL;
     
-    LOGI("JNI_OnLoad");
+    ALOGI("JNI_OnLoad");
 
     if (vm->GetEnv(&uenv.venv, JNI_VERSION_1_4) != JNI_OK) {
-        LOGE("ERROR: GetEnv failed");
+        ALOGE("ERROR: GetEnv failed");
         goto bail;
     }
     env = uenv.env;
 
     if (registerNatives(env) != JNI_TRUE) {
-        LOGE("ERROR: registerNatives failed");
+        ALOGE("ERROR: registerNatives failed");
         goto bail;
     }
     
diff --git a/samples/Support4Demos/AndroidManifest.xml b/samples/Support4Demos/AndroidManifest.xml
index 6d71b03..cb34be2 100644
--- a/samples/Support4Demos/AndroidManifest.xml
+++ b/samples/Support4Demos/AndroidManifest.xml
@@ -242,5 +242,26 @@
             </intent-filter>
         </activity>
 
+        <activity android:name=".app.SharingSupport"
+                  android:label="@string/sharing_support_title">
+            <intent-filter>
+                <action android:name="android.intent.action.MAIN" />
+                <category android:name="com.example.android.supportv4.SUPPORT4_SAMPLE_CODE" />
+            </intent-filter>
+        </activity>
+
+        <activity android:name=".app.SharingReceiverSupport"
+                  android:label="@string/sharing_receiver_title">
+            <intent-filter>
+                <action android:name="android.intent.action.SEND" />
+                <action android:name="android.intent.action.SEND_MULTIPLE" />
+                <data android:mimeType="text/plain" />
+                <category android:name="android.intent.category.DEFAULT" />
+            </intent-filter>
+        </activity>
+
+        <provider android:authorities="com.example.supportv4.content.sharingsupportprovider"
+                  android:name=".content.SharingSupportProvider" />
+
     </application>
 </manifest>
diff --git a/samples/Support4Demos/res/layout/sharing_receiver_support.xml b/samples/Support4Demos/res/layout/sharing_receiver_support.xml
new file mode 100644
index 0000000..a7b4c38
--- /dev/null
+++ b/samples/Support4Demos/res/layout/sharing_receiver_support.xml
@@ -0,0 +1,31 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Copyright (C) 2011 The Android Open Source Project
+
+     Licensed under the Apache License, Version 2.0 (the "License");
+     you may not use this file except in compliance with the License.
+     You may obtain a copy of the License at
+
+          http://www.apache.org/licenses/LICENSE-2.0
+
+     Unless required by applicable law or agreed to in writing, software
+     distributed under the License is distributed on an "AS IS" BASIS,
+     WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+     See the License for the specific language governing permissions and
+     limitations under the License.
+-->
+<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
+              android:orientation="vertical"
+              android:padding="16dp"
+              android:layout_width="match_parent"
+              android:layout_height="match_parent">
+    <TextView android:id="@+id/app_info"
+              android:layout_width="match_parent"
+              android:layout_height="wrap_content"
+              android:gravity="center_vertical"/>
+    <ScrollView android:layout_width="match_parent"
+                android:layout_height="match_parent">
+        <TextView android:id="@+id/text"
+                  android:layout_width="match_parent"
+                  android:layout_height="wrap_content" />
+    </ScrollView>
+</LinearLayout>
diff --git a/samples/Support4Demos/res/layout/sharing_support.xml b/samples/Support4Demos/res/layout/sharing_support.xml
new file mode 100644
index 0000000..8b88dca
--- /dev/null
+++ b/samples/Support4Demos/res/layout/sharing_support.xml
@@ -0,0 +1,36 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Copyright (C) 2011 The Android Open Source Project
+
+     Licensed under the Apache License, Version 2.0 (the "License");
+     you may not use this file except in compliance with the License.
+     You may obtain a copy of the License at
+
+          http://www.apache.org/licenses/LICENSE-2.0
+
+     Unless required by applicable law or agreed to in writing, software
+     distributed under the License is distributed on an "AS IS" BASIS,
+     WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+     See the License for the specific language governing permissions and
+     limitations under the License.
+-->
+<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
+              android:orientation="vertical"
+              android:padding="16dp"
+              android:layout_width="match_parent"
+              android:layout_height="match_parent">
+    <Button android:id="@+id/share_text"
+            android:text="@string/share_text"
+            android:layout_width="match_parent"
+            android:layout_height="wrap_content"
+            android:onClick="onShareTextClick" />
+    <Button android:id="@+id/share_file"
+            android:text="@string/share_file"
+            android:layout_width="match_parent"
+            android:layout_height="wrap_content"
+            android:onClick="onShareFileClick" />
+    <Button android:id="@+id/share_multiple_file"
+            android:text="@string/share_multiple_file"
+            android:layout_width="match_parent"
+            android:layout_height="wrap_content"
+            android:onClick="onShareMultipleFileClick" />
+</LinearLayout>
diff --git a/samples/Support4Demos/res/values/strings.xml b/samples/Support4Demos/res/values/strings.xml
index f8f4a4f..8cd91f6 100644
--- a/samples/Support4Demos/res/values/strings.xml
+++ b/samples/Support4Demos/res/values/strings.xml
@@ -123,4 +123,10 @@
     <string name="accessibility_delegate_button">Button</string>
     <string name="accessibility_delegate_custom_text_added">Custom text added via an accessibility delegate.</string>
 
+    <string name="share_text">Share some text</string>
+    <string name="share_file">Share a file</string>
+    <string name="share_multiple_file">Share multiple files</string>
+    <string name="sharing_support_title">ShareCompat Demo</string>
+    <string name="sharing_receiver_title">ShareCompat Receiver</string>
+
 </resources>
diff --git a/samples/Support4Demos/src/com/example/android/supportv4/app/SharingReceiverSupport.java b/samples/Support4Demos/src/com/example/android/supportv4/app/SharingReceiverSupport.java
new file mode 100644
index 0000000..d1efa2d
--- /dev/null
+++ b/samples/Support4Demos/src/com/example/android/supportv4/app/SharingReceiverSupport.java
@@ -0,0 +1,90 @@
+/*
+ * Copyright (C) 2011 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.example.android.supportv4.app;
+
+import com.example.android.supportv4.R;
+
+import android.app.Activity;
+import android.graphics.drawable.Drawable;
+import android.net.Uri;
+import android.os.Bundle;
+import android.support.v4.app.ShareCompat;
+import android.util.Log;
+import android.widget.TextView;
+
+import java.io.BufferedReader;
+import java.io.FileNotFoundException;
+import java.io.IOException;
+import java.io.InputStreamReader;
+
+/**
+ * This example shows a simple way to handle data shared with your app through the
+ * use of the support library's ShareCompat features. It will display shared text
+ * content as well as the application label and icon of the app that shared the content.
+ */
+public class SharingReceiverSupport extends Activity {
+    private static final String TAG = "SharingReceiverSupport";
+    private static final int ICON_SIZE = 32; // dip
+
+    @Override
+    protected void onCreate(Bundle b) {
+        super.onCreate(b);
+        setContentView(R.layout.sharing_receiver_support);
+
+        final float density = getResources().getDisplayMetrics().density;
+        final int iconSize = (int) (ICON_SIZE * density + 0.5f);
+
+        ShareCompat.IntentReader intentReader = ShareCompat.IntentReader.from(this);
+
+        // The following provides attribution for the app that shared the data with us.
+        TextView info = (TextView) findViewById(R.id.app_info);
+        Drawable d = intentReader.getCallingActivityIcon();
+        d.setBounds(0, 0, iconSize, iconSize);
+        info.setCompoundDrawables(d, null, null, null);
+        info.setText(intentReader.getCallingApplicationLabel());
+
+        TextView tv = (TextView) findViewById(R.id.text);
+        StringBuilder txt = new StringBuilder("Received share!\nText was: ");
+
+        txt.append(intentReader.getText());
+        txt.append("\n");
+
+        txt.append("Streams included:\n");
+        final int N = intentReader.getStreamCount();
+        for (int i = 0; i < N; i++) {
+            Uri uri = intentReader.getStream(i);
+            txt.append("Share included stream " + i + ": " + uri + "\n");
+            try {
+                BufferedReader reader = new BufferedReader(new InputStreamReader(
+                        getContentResolver().openInputStream(uri)));
+                try {
+                    txt.append(reader.readLine() + "\n");
+                } catch (IOException e) {
+                    Log.e(TAG, "Reading stream threw exception", e);
+                } finally {
+                    reader.close();
+                }
+            } catch (FileNotFoundException e) {
+                Log.e(TAG, "File not found from share.", e);
+            } catch (IOException e) {
+                Log.d(TAG, "I/O Error", e);
+            }
+        }
+
+        tv.setText(txt.toString());
+    }
+}
diff --git a/samples/Support4Demos/src/com/example/android/supportv4/app/SharingSupport.java b/samples/Support4Demos/src/com/example/android/supportv4/app/SharingSupport.java
new file mode 100644
index 0000000..ec099a8
--- /dev/null
+++ b/samples/Support4Demos/src/com/example/android/supportv4/app/SharingSupport.java
@@ -0,0 +1,113 @@
+/*
+ * Copyright (C) 2011 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.example.android.supportv4.app;
+
+import com.example.android.supportv4.R;
+import com.example.android.supportv4.content.SharingSupportProvider;
+
+import android.app.Activity;
+import android.net.Uri;
+import android.os.Bundle;
+import android.support.v4.app.ShareCompat;
+import android.support.v4.view.MenuItemCompat;
+import android.view.Menu;
+import android.view.MenuItem;
+import android.view.View;
+
+import java.io.FileNotFoundException;
+import java.io.FileWriter;
+import java.io.IOException;
+
+/**
+ * This example illustrates the use of the ShareCompat feature of the support library.
+ * ShareCompat offers several pieces of functionality to assist in sharing content between
+ * apps and is especially suited for sharing content to social apps that the user has installed.
+ *
+ * <p>Two other classes are relevant to this code sample: {@link SharingReceiverSupport} is
+ * an activity that has been configured to receive ACTION_SEND and ACTION_SEND_MULTIPLE
+ * sharing intents with a type of text/plain. It provides an example of writing a sharing
+ * target using ShareCompat features. {@link SharingSupportProvider} is a simple
+ * {@link android.content.ContentProvider} that provides access to two text files
+ * created by this app to share as content streams.</p>
+ */
+public class SharingSupport extends Activity {
+    @Override
+    protected void onCreate(Bundle b) {
+        super.onCreate(b);
+        setContentView(R.layout.sharing_support);
+    }
+
+    @Override
+    public boolean onCreateOptionsMenu(Menu menu) {
+        ShareCompat.IntentBuilder b = ShareCompat.IntentBuilder.from(this);
+        b.setType("text/plain").setText("Share from menu");
+        MenuItem item = menu.add("Share");
+        ShareCompat.configureMenuItem(item, b);
+        MenuItemCompat.setShowAsAction(item, MenuItemCompat.SHOW_AS_ACTION_IF_ROOM);
+        return true;
+    }
+
+    public void onShareTextClick(View v) {
+        ShareCompat.IntentBuilder.from(this)
+                .setType("text/plain")
+                .setText("I'm sharing!")
+                .startChooser();
+    }
+
+    public void onShareFileClick(View v) {
+        try {
+            // This file will be accessed by the target of the share through
+            // the ContentProvider SharingSupportProvider.
+            FileWriter fw = new FileWriter(getFilesDir() + "/foo.txt");
+            fw.write("This is a file share");
+            fw.close();
+
+            ShareCompat.IntentBuilder.from(this)
+                    .setType("text/plain")
+                    .setStream(Uri.parse(SharingSupportProvider.CONTENT_URI + "/foo.txt"))
+                    .startChooser();
+        } catch (FileNotFoundException e) {
+            e.printStackTrace();
+        } catch (IOException e) {
+            e.printStackTrace();
+        }
+    }
+
+    public void onShareMultipleFileClick(View v) {
+        try {
+            // These files will be accessed by the target of the share through
+            // the ContentProvider SharingSupportProvider.
+            FileWriter fw = new FileWriter(getFilesDir() + "/foo.txt");
+            fw.write("This is a file share");
+            fw.close();
+
+            fw = new FileWriter(getFilesDir() + "/bar.txt");
+            fw.write("This is another file share");
+            fw.close();
+
+            ShareCompat.IntentBuilder.from(this)
+                    .setType("text/plain")
+                    .addStream(Uri.parse(SharingSupportProvider.CONTENT_URI + "/foo.txt"))
+                    .addStream(Uri.parse(SharingSupportProvider.CONTENT_URI + "/bar.txt"))
+                    .startChooser();
+        } catch (FileNotFoundException e) {
+            e.printStackTrace();
+        } catch (IOException e) {
+            e.printStackTrace();
+        }
+    }
+}
diff --git a/samples/Support4Demos/src/com/example/android/supportv4/content/SharingSupportProvider.java b/samples/Support4Demos/src/com/example/android/supportv4/content/SharingSupportProvider.java
new file mode 100644
index 0000000..596fd6c
--- /dev/null
+++ b/samples/Support4Demos/src/com/example/android/supportv4/content/SharingSupportProvider.java
@@ -0,0 +1,89 @@
+/*
+ * Copyright (C) 2011 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.example.android.supportv4.content;
+
+import android.content.ContentProvider;
+import android.content.ContentValues;
+import android.database.Cursor;
+import android.net.Uri;
+import android.os.ParcelFileDescriptor;
+import android.util.Log;
+
+import java.io.File;
+import java.io.FileNotFoundException;
+
+/**
+ * This simple ContentProvider provides access to the two example files shared
+ * by the ShareCompat example {@link com.example.android.supportv4.app.SharingSupport}.
+ */
+public class SharingSupportProvider extends ContentProvider {
+    public static final Uri CONTENT_URI =
+            Uri.parse("content://com.example.supportv4.content.sharingsupportprovider");
+
+    private static final String TAG = "SharingSupportProvider";
+
+    @Override
+    public boolean onCreate() {
+        return true;
+    }
+
+    @Override
+    public Cursor query(Uri uri, String[] projection, String selection, String[] selectionArgs,
+            String sortOrder) {
+        return null;
+    }
+
+    @Override
+    public String getType(Uri uri) {
+        if (uri.equals(Uri.withAppendedPath(CONTENT_URI, "foo.txt")) ||
+                uri.equals(Uri.withAppendedPath(CONTENT_URI, "bar.txt"))) {
+            return "text/plain";
+        }
+        return null;
+    }
+
+    @Override
+    public Uri insert(Uri uri, ContentValues values) {
+        return null;
+    }
+
+    @Override
+    public int delete(Uri uri, String selection, String[] selectionArgs) {
+        return 0;
+    }
+
+    @Override
+    public int update(Uri uri, ContentValues values, String selection, String[] selectionArgs) {
+        return 0;
+    }
+
+    @Override
+    public ParcelFileDescriptor openFile(Uri uri, String mode) {
+        String path = uri.getPath();
+        if (mode.equals("r") &&
+                (path.equals("/foo.txt") || path.equals("/bar.txt"))) {
+            try {
+                return ParcelFileDescriptor.open(
+                        new File(getContext().getFilesDir() + path),
+                        ParcelFileDescriptor.MODE_READ_ONLY);
+            } catch (FileNotFoundException e) {
+                Log.e(TAG, "Bad file " + uri);
+            }
+        }
+        return null;
+    }
+}
diff --git a/samples/XmlAdapters/src/com/example/android/xmladapters/ImageDownloader.java b/samples/XmlAdapters/src/com/example/android/xmladapters/ImageDownloader.java
index eb91fcb..e0143bd 100644
--- a/samples/XmlAdapters/src/com/example/android/xmladapters/ImageDownloader.java
+++ b/samples/XmlAdapters/src/com/example/android/xmladapters/ImageDownloader.java
@@ -41,6 +41,7 @@
 import java.lang.ref.WeakReference;
 import java.util.HashMap;
 import java.util.LinkedHashMap;
+import java.util.Map;
 import java.util.concurrent.ConcurrentHashMap;
 
 /**
@@ -62,7 +63,7 @@
         new LinkedHashMap<String, Bitmap>(HARD_CACHE_CAPACITY / 2, 0.75f, true) {
         private static final long serialVersionUID = -7190622541619388252L;
         @Override
-        protected boolean removeEldestEntry(LinkedHashMap.Entry<String, Bitmap> eldest) {
+        protected boolean removeEldestEntry(Map.Entry<String, Bitmap> eldest) {
             if (size() > HARD_CACHE_CAPACITY) {
                 // Entries push-out of hard reference cache are transferred to soft reference cache
                 sSoftBitmapCache.put(eldest.getKey(), new SoftReference<Bitmap>(eldest.getValue()));
diff --git a/sdk/images_armeabi-v7a_source.prop_template b/sdk/images_armeabi-v7a_source.prop_template
index ae67647..86fc2a0 100644
--- a/sdk/images_armeabi-v7a_source.prop_template
+++ b/sdk/images_armeabi-v7a_source.prop_template
@@ -4,3 +4,4 @@
 AndroidVersion.ApiLevel=${PLATFORM_SDK_VERSION}
 AndroidVersion.CodeName=${PLATFORM_VERSION_CODENAME}
 SystemImage.Abi=armeabi-v7a
+SystemImage.GpuSupport=true
diff --git a/sdk/images_armeabi_source.prop_template b/sdk/images_armeabi_source.prop_template
index b100e53..8644d10 100644
--- a/sdk/images_armeabi_source.prop_template
+++ b/sdk/images_armeabi_source.prop_template
@@ -4,3 +4,4 @@
 AndroidVersion.ApiLevel=${PLATFORM_SDK_VERSION}
 AndroidVersion.CodeName=${PLATFORM_VERSION_CODENAME}
 SystemImage.Abi=armeabi
+SystemImage.GpuSupport=true
diff --git a/sdk/images_x86_source.prop_template b/sdk/images_x86_source.prop_template
index 62e2e0d..a587cd1 100644
--- a/sdk/images_x86_source.prop_template
+++ b/sdk/images_x86_source.prop_template
@@ -4,3 +4,4 @@
 AndroidVersion.ApiLevel=${PLATFORM_SDK_VERSION}
 AndroidVersion.CodeName=${PLATFORM_VERSION_CODENAME}
 SystemImage.Abi=x86
+SystemImage.GpuSupport=true
diff --git a/sdk/prebuilt/v7/gridlayout/.classpath b/sdk/prebuilt/v7/gridlayout/.classpath
deleted file mode 100644
index a4f1e40..0000000
--- a/sdk/prebuilt/v7/gridlayout/.classpath
+++ /dev/null
@@ -1,8 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>

-<classpath>

-	<classpathentry kind="src" path="src"/>

-	<classpathentry kind="src" path="gen"/>

-	<classpathentry kind="con" path="com.android.ide.eclipse.adt.ANDROID_FRAMEWORK"/>

-	<classpathentry kind="con" path="com.android.ide.eclipse.adt.LIBRARIES"/>

-	<classpathentry kind="output" path="bin/classes"/>

-</classpath>

diff --git a/sdk/prebuilt/v7/gridlayout/.project b/sdk/prebuilt/v7/gridlayout/.project
deleted file mode 100644
index ed51f1d..0000000
--- a/sdk/prebuilt/v7/gridlayout/.project
+++ /dev/null
@@ -1,33 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>

-<projectDescription>

-	<name>gridlayout_v7</name>

-	<comment></comment>

-	<projects>

-	</projects>

-	<buildSpec>

-		<buildCommand>

-			<name>com.android.ide.eclipse.adt.ResourceManagerBuilder</name>

-			<arguments>

-			</arguments>

-		</buildCommand>

-		<buildCommand>

-			<name>com.android.ide.eclipse.adt.PreCompilerBuilder</name>

-			<arguments>

-			</arguments>

-		</buildCommand>

-		<buildCommand>

-			<name>org.eclipse.jdt.core.javabuilder</name>

-			<arguments>

-			</arguments>

-		</buildCommand>

-		<buildCommand>

-			<name>com.android.ide.eclipse.adt.ApkBuilder</name>

-			<arguments>

-			</arguments>

-		</buildCommand>

-	</buildSpec>

-	<natures>

-		<nature>com.android.ide.eclipse.adt.AndroidNature</nature>

-		<nature>org.eclipse.jdt.core.javanature</nature>

-	</natures>

-</projectDescription>

diff --git a/sdk/prebuilt/v7/gridlayout/AndroidManifest.xml b/sdk/prebuilt/v7/gridlayout/AndroidManifest.xml
deleted file mode 100644
index c3f7168..0000000
--- a/sdk/prebuilt/v7/gridlayout/AndroidManifest.xml
+++ /dev/null
@@ -1,9 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<manifest xmlns:android="http://schemas.android.com/apk/res/android"
-    package="android.support.v7.gridlayout"
-    android:versionCode="1"
-    android:versionName="1.0" >
-
-    <uses-sdk android:minSdkVersion="7" />
-
-</manifest>
diff --git a/sdk/prebuilt/v7/gridlayout/README.txt b/sdk/prebuilt/v7/gridlayout/README.txt
deleted file mode 100644
index 86853b0..0000000
--- a/sdk/prebuilt/v7/gridlayout/README.txt
+++ /dev/null
@@ -1,8 +0,0 @@
-Library Project including GridLayout.
-
-This can be used by an Android project to provide
-access to GridLayout on applications running on API 7+
-
-There is technically no source, but the src folder is necessary
-to ensure that the build system works. The content is actually
-located in libs/android-support-v7-gridlayout.jar
diff --git a/sdk/prebuilt/v7/gridlayout/libs/android-support-v7-gridlayout.jar b/sdk/prebuilt/v7/gridlayout/libs/android-support-v7-gridlayout.jar
deleted file mode 100644
index ecef47d..0000000
--- a/sdk/prebuilt/v7/gridlayout/libs/android-support-v7-gridlayout.jar
+++ /dev/null
Binary files differ
diff --git a/sdk/prebuilt/v7/gridlayout/project.properties b/sdk/prebuilt/v7/gridlayout/project.properties
deleted file mode 100644
index 5ca3505..0000000
--- a/sdk/prebuilt/v7/gridlayout/project.properties
+++ /dev/null
@@ -1,15 +0,0 @@
-# This file is automatically generated by Android Tools.
-# Do not modify this file -- YOUR CHANGES WILL BE ERASED!
-#
-# This file must be checked in Version Control Systems.
-#
-# To customize properties used by the Ant build system edit
-# "ant.properties", and override values to adapt the script to your
-# project structure.
-#
-# To enable ProGuard to shrink and obfuscate your code, uncomment this (available properties: sdk.dir, user.home):
-#proguard.config=${sdk.dir}/tools/proguard/proguard-android.txt:proguard-project.txt
-
-# Project target.
-target=android-7
-android.library=true
diff --git a/sdk/prebuilt/v7/gridlayout/res/values/attrs.xml b/sdk/prebuilt/v7/gridlayout/res/values/attrs.xml
deleted file mode 100644
index ad2ef4e..0000000
--- a/sdk/prebuilt/v7/gridlayout/res/values/attrs.xml
+++ /dev/null
@@ -1,198 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<resources>
-
-    <declare-styleable name="GridLayout">
-
-        <!--
-              support versions. All attributes not present in ViewGroup/View are
-              redefined in the support library namespace.
-        -->
-
-
-        <!--
-        The orientation property is not used during layout. It is only used to
-        allocate row and column parameters when they are not specified by its children's
-        layout parameters. GridLayout works like LinearLayout in this case;
-        putting all the components either in a single row or in a single column -
-        depending on the value of this flag. In the horizontal case, a columnCount
-        property may be additionally supplied to force new rows to be created when a
-        row is full. The rowCount attribute may be used similarly in the vertical case.
-        The default is horizontal.
-        -->
-        <attr name="orientation">
-
-            <!-- Defines an horizontal widget. -->
-            <enum name="horizontal" value="0" />
-            <!-- Defines a vertical widget. -->
-            <enum name="vertical" value="1" />
-        </attr>
-        <!-- The maximum number of rows to create when automatically positioning children. -->
-        <attr name="rowCount" format="integer" />
-        <!-- The maximum number of columns to create when automatically positioning children. -->
-        <attr name="columnCount" format="integer" />
-        <!--
-        When set to true, tells GridLayout to use default margins when none are specified
-        in a view's layout parameters.
-        The default value is false.
-        See {@link android.widget.GridLayout#setUseDefaultMargins(boolean)}.
-        -->
-        <attr name="useDefaultMargins" format="boolean" />
-        <!--
-        When set to alignMargins, causes alignment to take place between the outer
-        boundary of a view, as defined by its margins. When set to alignBounds,
-        causes alignment to take place between the edges of the view.
-        The default is alignMargins.
-        See {@link android.widget.GridLayout#setAlignmentMode(int)}.
-        -->
-        <attr name="alignmentMode">
-
-            <!--
-            Align the bounds of the children.
-            See {@link android.widget.GridLayout#ALIGN_BOUNDS}.
-            -->
-            <enum name="alignBounds" value="0" />
-            <!--
-            Align the margins of the children.
-            See {@link android.widget.GridLayout#ALIGN_MARGINS}.
-            -->
-            <enum name="alignMargins" value="1" />
-        </attr>
-        <!--
-        When set to true, forces row boundaries to appear in the same order
-        as row indices.
-        The default is true.
-        See {@link android.widget.GridLayout#setRowOrderPreserved(boolean)}.
-        -->
-        <attr name="rowOrderPreserved" format="boolean" />
-        <!--
-        When set to true, forces column boundaries to appear in the same order
-        as column indices.
-        The default is true.
-        See {@link android.widget.GridLayout#setColumnOrderPreserved(boolean)}.
-        -->
-        <attr name="columnOrderPreserved" format="boolean" />
-    </declare-styleable>
-    <declare-styleable name="GridLayout_Layout">
-
-        <!--
-              support versions. All attributes not present in MarginLayout are
-              redefined in the support library name space.
-        -->
-
-
-        <!-- START MarginLayout layoutparams -->
-
-        <attr name="android:layout_width" />
-        <attr name="android:layout_height" />
-        <!--
-              Specifies extra space on the left, top, right and bottom
-              sides of this view. This space is outside this view's bounds.
-        -->
-        <attr name="android:layout_margin" />
-        <!--
-              Specifies extra space on the left side of this view.
-              This space is outside this view's bounds.
-        -->
-        <attr name="android:layout_marginLeft" />
-        <!--
-              Specifies extra space on the top side of this view.
-              This space is outside this view's bounds.
-        -->
-        <attr name="android:layout_marginTop" />
-        <!--
-              Specifies extra space on the right side of this view.
-              This space is outside this view's bounds.
-        -->
-        <attr name="android:layout_marginRight" />
-        <!--
-              Specifies extra space on the bottom side of this view.
-              This space is outside this view's bounds.
-        -->
-        <attr name="android:layout_marginBottom" />
-        <!--
-              Specifies extra space on the start side of this view.
-              This space is outside this view's bounds.
-        -->
-        <attr name="android:layout_marginStart" />
-        <!--
-              Specifies extra space on the end side of this view.
-              This space is outside this view's bounds.
-        -->
-        <attr name="android:layout_marginEnd" />
-
-        <!-- END MarginLayout layoutparams -->
-
-
-        <!--
-        The row boundary delimiting the top of the group of cells
-        occupied by this view.
-        -->
-        <attr name="layout_row" format="integer" />
-        <!--
-        The row span: the difference between the bottom and top
-        boundaries delimiting the group of cells occupied by this view.
-        The default is one.
-        See {@link android.widget.GridLayout.Spec}.
-        -->
-        <attr name="layout_rowSpan" format="integer" min="1" />
-        <!--
-        The column boundary delimiting the left of the group of cells
-        occupied by this view.
-        -->
-        <attr name="layout_column" format="integer" />
-        <!--
-        The column span: the difference between the right and left
-        boundaries delimiting the group of cells occupied by this view.
-        The default is one.
-        See {@link android.widget.GridLayout.Spec}.
-        -->
-        <attr name="layout_columnSpan" format="integer" min="1" />
-        <!--
-        Gravity specifies how a component should be placed in its group of cells.
-        The default is LEFT | BASELINE.
-        See {@link android.widget.GridLayout.LayoutParams#setGravity(int)}.
-        -->
-        <attr name="layout_gravity">
-
-            <!-- Push object to the top of its container, not changing its size. -->
-            <flag name="top" value="0x30" />
-            <!-- Push object to the bottom of its container, not changing its size. -->
-            <flag name="bottom" value="0x50" />
-            <!-- Push object to the left of its container, not changing its size. -->
-            <flag name="left" value="0x03" />
-            <!-- Push object to the right of its container, not changing its size. -->
-            <flag name="right" value="0x05" />
-            <!-- Place object in the vertical center of its container, not changing its size. -->
-            <flag name="center_vertical" value="0x10" />
-            <!-- Grow the vertical size of the object if needed so it completely fills its container. -->
-            <flag name="fill_vertical" value="0x70" />
-            <!-- Place object in the horizontal center of its container, not changing its size. -->
-            <flag name="center_horizontal" value="0x01" />
-            <!-- Grow the horizontal size of the object if needed so it completely fills its container. -->
-            <flag name="fill_horizontal" value="0x07" />
-            <!-- Place the object in the center of its container in both the vertical and horizontal axis, not changing its size. -->
-            <flag name="center" value="0x11" />
-            <!-- Grow the horizontal and vertical size of the object if needed so it completely fills its container. -->
-            <flag name="fill" value="0x77" />
-            <!--
-             Additional option that can be set to have the top and/or bottom edges of
-             the child clipped to its container's bounds.
-             The clip will be based on the vertical gravity: a top gravity will clip the bottom
-             edge, a bottom gravity will clip the top edge, and neither will clip both edges.
-            -->
-            <flag name="clip_vertical" value="0x80" />
-            <!--
-             Additional option that can be set to have the left and/or right edges of
-             the child clipped to its container's bounds.
-             The clip will be based on the horizontal gravity: a left gravity will clip the right
-             edge, a right gravity will clip the left edge, and neither will clip both edges.
-            -->
-            <flag name="clip_horizontal" value="0x08" />
-            <!-- Push object to the beginning of its container, not changing its size. -->
-            <flag name="start" value="0x00800003" />
-            <!-- Push object to the end of its container, not changing its size. -->
-            <flag name="end" value="0x00800005" />
-        </attr>
-    </declare-styleable>
-
-</resources>
diff --git a/sdk/prebuilt/v7/gridlayout/res/values/dimens.xml b/sdk/prebuilt/v7/gridlayout/res/values/dimens.xml
deleted file mode 100644
index fda3feb..0000000
--- a/sdk/prebuilt/v7/gridlayout/res/values/dimens.xml
+++ /dev/null
@@ -1,7 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<resources>
-
-    <!-- The default gap between components in a layout. -->
-    <dimen name="default_gap">16dip</dimen>
-
-</resources>
diff --git a/sdk/prebuilt/v7/gridlayout/src/.readme b/sdk/prebuilt/v7/gridlayout/src/.readme
deleted file mode 100644
index 4bcebad..0000000
--- a/sdk/prebuilt/v7/gridlayout/src/.readme
+++ /dev/null
@@ -1,2 +0,0 @@
-This hidden file is there to ensure there is an src folder.
-Once we support binary library this will go away.
\ No newline at end of file
diff --git a/sdk/support_source.properties b/sdk/support_source.properties
index 7ea8c5d..b4e5eb6 100644
--- a/sdk/support_source.properties
+++ b/sdk/support_source.properties
@@ -1,9 +1,8 @@
 Pkg.UserSrc=false
-Pkg.Revision=7
+Pkg.Revision=8
 Extra.Vendor=android
 Extra.VendorId=android
 Extra.VendorDisplay=Android
 Extra.NameDisplay=Android Support Library
 Extra.Path=support
 Extra.OldPaths=compatibility
-
diff --git a/testrunner/create_test.py b/testrunner/create_test.py
index faea013..90da254 100755
--- a/testrunner/create_test.py
+++ b/testrunner/create_test.py
@@ -121,20 +121,21 @@
   _PrintMessage("Created %s" % tests_manifest_path)
 
 
-def _GenerateTestMK(mk, mapping=None):
+def _GenerateTestMK(mk, app_path, mapping=None):
   """Create and populate tests/Android.mk with variable values from Android.mk.
 
   Does nothing if tests/Android.mk already exists.
 
   Args:
     mk: AndroidMK object for application makefile
+    app_path: path to the application being tested
     mapping: optional user defined mapping of variable values, replaces
         values stored in mk
   Raises:
     IOError: tests/Android.mk cannot be opened for writing
   """
   # skip if file already exists
-  tests_path = "%s/%s" % (mk.app_path, TestsConsts.TESTS_FOLDER)
+  tests_path = "%s/%s" % (app_path, TestsConsts.TESTS_FOLDER)
   tests_mk_path = "%s/%s" % (tests_path, mk.FILENAME)
   if os.path.exists(tests_mk_path):
     _PrintMessage("%s already exists, not overwritten" % tests_mk_path)
@@ -142,7 +143,7 @@
 
   # append test build if not existent in makefile
   if not mk.HasInclude(TestsConsts.MK_BUILD_INCLUDE):
-    mk_path = "%s/%s" % (mk.app_path, mk.FILENAME)
+    mk_path = "%s/%s" % (app_path, mk.FILENAME)
     mk_file = open(mk_path, mode="a")
     mk_file.write(TestsConsts.MK_BUILD_STRING)
     mk_file.close()
@@ -224,12 +225,12 @@
     sys.exit()
 
   try:
-    mk = android_mk.AndroidMK(app_path=app_path)
+    mk = android_mk.CreateAndroidMK(path=app_path)
     manifest = android_manifest.AndroidManifest(app_path=app_path)
     _ValidateInputFiles(mk, manifest)
 
     module_name = mk.GetVariable(mk.PACKAGE_NAME)
-    _GenerateTestMK(mk)
+    _GenerateTestMK(mk, app_path)
     _GenerateTestManifest(manifest, module_name)
   except Exception, e:
     _PrintError("Error: %s" % e)
diff --git a/testrunner/runtest.py b/testrunner/runtest.py
index 6226350..6c1b1b6 100755
--- a/testrunner/runtest.py
+++ b/testrunner/runtest.py
@@ -69,7 +69,7 @@
       "for a list of tests, or you can launch one or more tests.")
 
   # default value for make -jX
-  _DEFAULT_JOBS = 4
+  _DEFAULT_JOBS = 16
 
   _DALVIK_VERIFIER_OFF_PROP = "dalvik.vm.dexopt-flags = v=n"
 
@@ -233,8 +233,9 @@
     self._TurnOffVerifier(tests)
     self._DoFullBuild(tests)
 
-    target_set = Set()
-    extra_args_set = Set()
+    target_set = []
+
+    extra_args_set = []
     for test_suite in tests:
       self._AddBuildTarget(test_suite, target_set, extra_args_set)
 
@@ -260,8 +261,8 @@
           logger.Log(cmd)
           run_command.RunCommand(cmd, return_output=False)
 
-      target_build_string = " ".join(list(target_set))
-      extra_args_string = " ".join(list(extra_args_set))
+      target_build_string = " ".join(target_set)
+      extra_args_string = " ".join(extra_args_set)
 
       # mmm cannot be used from python, so perform a similar operation using
       # ONE_SHOT_MAKEFILE
@@ -315,7 +316,7 @@
     if not test_suite.IsFullMake():
       build_dir = test_suite.GetBuildPath()
       if self._AddBuildTargetPath(build_dir, target_set):
-        extra_args_set.add(test_suite.GetExtraBuildArgs())
+        extra_args_set.append(test_suite.GetExtraBuildArgs())
       for path in test_suite.GetBuildDependencies(self._options):
         self._AddBuildTargetPath(path, target_set)
 
@@ -323,7 +324,7 @@
     if build_dir is not None:
       build_file_path = os.path.join(build_dir, "Android.mk")
       if os.path.isfile(os.path.join(self._root_path, build_file_path)):
-        target_set.add(build_file_path)
+        target_set.append(build_file_path)
         return True
       else:
         logger.Log("%s has no Android.mk, skipping" % build_dir)
@@ -382,18 +383,33 @@
         if self._options.preview:
           logger.Log("adb shell \"echo %s >> /data/local.prop\""
                      % self._DALVIK_VERIFIER_OFF_PROP)
+          logger.Log("adb shell chmod 644 /data/local.prop")
           logger.Log("adb reboot")
           logger.Log("adb wait-for-device")
         else:
           logger.Log("Turning off dalvik verifier and rebooting")
           self._adb.SendShellCommand("\"echo %s >> /data/local.prop\""
                                      % self._DALVIK_VERIFIER_OFF_PROP)
-          self._adb.SendCommand("reboot")
-          # wait for device to go offline
-          time.sleep(10)
-          self._adb.SendCommand("wait-for-device", timeout_time=60,
-                                retry_count=3)
-          self._adb.EnableAdbRoot()
+
+          self._ChmodReboot()
+      elif not self._options.preview:
+        # check the permissions on the file
+        permout = self._adb.SendShellCommand("ls -l /data/local.prop")
+        if not "-rw-r--r--" in permout:
+          logger.Log("Fixing permissions on /data/local.prop and rebooting")
+          self._ChmodReboot()
+
+  def _ChmodReboot(self):
+    """Perform a chmod of /data/local.prop and reboot.
+    """
+    self._adb.SendShellCommand("chmod 644 /data/local.prop")
+    self._adb.SendCommand("reboot")
+    # wait for device to go offline
+    time.sleep(10)
+    self._adb.SendCommand("wait-for-device", timeout_time=60,
+                          retry_count=3)
+    self._adb.EnableAdbRoot()
+
 
   def RunTests(self):
     """Main entry method - executes the tests according to command line args."""
diff --git a/testrunner/test_defs.xml b/testrunner/test_defs.xml
index 4321796..4de369b 100644
--- a/testrunner/test_defs.xml
+++ b/testrunner/test_defs.xml
@@ -136,6 +136,11 @@
     build_path="frameworks/base/services/input/tests"
     description="Framework libinput unit tests." />
 
+<test name="volley"
+    build_path="frameworks/support/volley/tests"
+    package="com.android.volley.tests"
+    continuous="true" />
+
 <!--  end of framework tests -->
 
 <!-- media framework tests -->
@@ -253,12 +258,6 @@
     package="android.tests.sigtest.tests"
     suite="cts" />
 
-<test name="cts-apidemos"
-    build_path="cts/tests/ApiDemosReferenceTest"
-    package="android.apidemos.cts"
-    coverage_target="ApiDemos"
-    suite="cts" />
-
 <test name="cts-app"
     build_path="cts/tests/tests/app"
     package="com.android.cts.app"
@@ -319,7 +318,7 @@
 <test name="cts-net"
     build_path="cts/tests/tests/net"
     package="com.android.cts.net"
-    runner="android.test.InstrumentationCtsTestRunner"
+    runner="android.test.InstrumentationTestRunner"
     coverage_target="framework"
     suite="cts" />
 
@@ -330,36 +329,6 @@
     coverage_target="framework"
     suite="cts" />
 
-<test name="cts-perf1"
-    build_path="cts/tests/tests/performance"
-    package="com.android.cts.performance"
-    runner="android.test.InstrumentationCtsTestRunner"
-    suite="cts" />
-
-<test name="cts-perf2"
-    build_path="cts/tests/tests/performance2"
-    package="com.android.cts.performance2"
-    runner="android.test.InstrumentationCtsTestRunner"
-    suite="cts" />
-
-<test name="cts-perf3"
-    build_path="cts/tests/tests/performance3"
-    package="com.android.cts.performance3"
-    runner="android.test.InstrumentationCtsTestRunner"
-    suite="cts" />
-
-<test name="cts-perf4"
-    build_path="cts/tests/tests/performance4"
-    package="com.android.cts.performance4"
-    runner="android.test.InstrumentationCtsTestRunner"
-    suite="cts" />
-
-<test name="cts-perf5"
-    build_path="cts/tests/tests/performance5"
-    package="com.android.cts.performance5"
-    runner="android.test.InstrumentationCtsTestRunner"
-    suite="cts" />
-
 <test name="cts-provider"
     build_path="cts/tests/tests/provider"
     package="com.android.cts.provider"
@@ -446,6 +415,14 @@
     coverage_target="CalendarProvider"
     continuous="true" />
 
+<test name="camera-functional"
+    build_path="packages/apps/Camera"
+    package="com.google.android.camera.tests"
+    runner="com.android.camera.CameraTestRunner"
+    coverage_target="Camera"
+    description="Camera functional test"
+    continuous="true" />
+
 <test name="contactsprov"
     build_path="packages/providers/ContactsProvider"
     package="com.android.providers.contacts.tests"
@@ -559,7 +536,7 @@
 
 <!-- host java tests -->
 <test-host name="cts-appsecurity"
-    build_path="cts/tests/appsecurity-tests"
+    build_path="cts/hostsidetests/appsecurity"
     class="com.android.cts.appsecurity.AppSecurityTests"
     jar_name="CtsAppSecurityTests.jar"
     suite="cts" />
diff --git a/testrunner/test_defs/host_test.py b/testrunner/test_defs/host_test.py
index 273042a..ca65c2a 100644
--- a/testrunner/test_defs/host_test.py
+++ b/testrunner/test_defs/host_test.py
@@ -32,7 +32,8 @@
   _JUNIT_JAR_NAME = "junit.jar"
   _HOSTTESTLIB_NAME = "hosttestlib.jar"
   _DDMLIB_NAME = "ddmlib-prebuilt.jar"
-  _lib_names = [_JUNIT_JAR_NAME, _HOSTTESTLIB_NAME, _DDMLIB_NAME]
+  _TRADEFED_NAME = "tradefed-prebuilt.jar"
+  _lib_names = [_JUNIT_JAR_NAME, _HOSTTESTLIB_NAME, _DDMLIB_NAME, _TRADEFED_NAME]
 
   _JUNIT_BUILD_PATH = os.path.join("external", "junit")
   _HOSTTESTLIB_BUILD_PATH = os.path.join("development", "tools", "hosttestlib")
diff --git a/tools/a3dconvert/Android.mk b/tools/a3dconvert/Android.mk
index f85c70b..c7a8d9c 100644
--- a/tools/a3dconvert/Android.mk
+++ b/tools/a3dconvert/Android.mk
@@ -29,16 +29,9 @@
     ColladaGeometry.cpp \
     ColladaLoader.cpp
 
-# Needed to maintain libRS dependencies
-intermediates := $(call intermediates-dir-for,STATIC_LIBRARIES,libRS,HOST,)
-librs_generated_headers := \
-    $(intermediates)/rsgApiStructs.h \
-    $(intermediates)/rsgApiFuncDecl.h
-LOCAL_GENERATED_SOURCES := $(librs_generated_headers)
-
 LOCAL_C_INCLUDES += external/collada/include
 LOCAL_C_INCLUDES += external/collada/include/1.4
-LOCAL_C_INCLUDES += frameworks/base/libs/rs
+LOCAL_C_INCLUDES += frameworks/rs
 LOCAL_C_INCLUDES += $(intermediates)
 
 LOCAL_LDLIBS := -ldl -lpthread
diff --git a/tools/a3dconvert/ColladaConditioner.cpp b/tools/a3dconvert/ColladaConditioner.cpp
index 0a99e0e..afebb8c 100644
--- a/tools/a3dconvert/ColladaConditioner.cpp
+++ b/tools/a3dconvert/ColladaConditioner.cpp
@@ -204,15 +204,27 @@
 
 bool ColladaConditioner::stripGeometry(DAE *dae) {
     bool convertSuceeded = true;
-    int geometryElementCount = (int)(dae->getDatabase()->getElementCount(NULL,
-                                                                         "library_geometries" ));
 
+    int error = 0;
+
+    // How many geometry elements are there?
+    int geometryElementCount = (int)(dae->getDatabase()->getElementCount(NULL, "geometry" ));
     for(int currentGeometry = 0; currentGeometry < geometryElementCount; currentGeometry++) {
 
+        // Find the next geometry element
+        domGeometry *thisGeometry = 0;
         daeElement * element = 0;
-        int error = dae->getDatabase()->getElement(&element, currentGeometry,
-                                                   NULL, "library_geometries");
-        daeBool removed = daeElement::removeFromParent(element);
+        error = dae->getDatabase()->getElement(&element, currentGeometry, NULL, "geometry");
+        thisGeometry = (domGeometry *) element;
+
+        // Get the mesh out of the geometry
+        domMesh *thisMesh = thisGeometry->getMesh();
+
+        if (thisMesh == NULL){
+            continue;
+        }
+
+        daeBool removed = daeElement::removeFromParent(thisMesh);
         convertSuceeded = convertSuceeded && removed;
     }
     return convertSuceeded;
diff --git a/tools/a3dconvert/SimpleMesh.h b/tools/a3dconvert/SimpleMesh.h
index c87bb7d..91b4823 100644
--- a/tools/a3dconvert/SimpleMesh.h
+++ b/tools/a3dconvert/SimpleMesh.h
@@ -106,13 +106,18 @@
             uint32_t vertexPos = i*vertexSize;
             float *vertexPtr = dataPtr + vertexPos;
 
+            uint32_t elemIndex = 0;
             for (uint32_t c = 0; c < mChannels.size(); c ++) {
                 // Skip empty channels
                 if (mChannels[c].mData.size() == 0) {
                     continue;
                 }
+                // This will address vector element alignment issues
+                uint32_t elemlOffset = vertexDataElem->getFieldOffsetBytes(elemIndex)/sizeof(float);
+                elemIndex ++;
+                float *channelPtr = vertexPtr + elemlOffset;
                 for (uint32_t cStride = 0; cStride < mChannels[c].mStride; cStride ++) {
-                    *(vertexPtr++) = mChannels[c].mData[i * mChannels[c].mStride + cStride];
+                    *(channelPtr++) = mChannels[c].mData[i * mChannels[c].mStride + cStride];
                 }
             }
         }
diff --git a/tools/a3dconvert/a3dconvert.cpp b/tools/a3dconvert/a3dconvert.cpp
index 3535b17..aa8ee0e 100644
--- a/tools/a3dconvert/a3dconvert.cpp
+++ b/tools/a3dconvert/a3dconvert.cpp
@@ -42,23 +42,11 @@
     }
 }
 
-// We only care to implement allocation memory initialization and destruction
-// because we need no other renderscript hal features for serialization
-static RsdHalFunctions FunctionTable = {
-    NULL, NULL, NULL, NULL, NULL, NULL, NULL,
-    { NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,NULL },
-    {
-        rsdAllocationInit,
-        rsdAllocationDestroy,
-        NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL
-    },
-    { NULL, NULL, NULL }, { NULL, NULL, NULL }, { NULL, NULL, NULL },
-    { NULL, NULL, NULL }, { NULL, NULL, NULL }, { NULL, NULL },
-    { NULL, NULL, NULL},
-};
-
-// No-op initizlizer for rs context hal since we only
+static RsdHalFunctions FunctionTable;
 bool rsdHalInit(Context *rsc, uint32_t version_major, uint32_t version_minor) {
+    memset(&FunctionTable, 0, sizeof(FunctionTable));
+    FunctionTable.allocation.init = rsdAllocationInit;
+    FunctionTable.allocation.destroy = rsdAllocationDestroy;
     rsc->mHal.funcs = FunctionTable;
     return true;
 }
diff --git a/tools/elftree/Android.mk b/tools/elftree/Android.mk
index 0bba0f2..c2199aa 100644
--- a/tools/elftree/Android.mk
+++ b/tools/elftree/Android.mk
@@ -14,6 +14,10 @@
 
 LOCAL_PATH := $(call my-dir)
 
+supported_platforms := linux-x86 darwin-x86
+cur_platform := $(filter $(HOST_OS)-$(HOST_ARCH),$(supported_platforms))
+
+ifdef cur_platform
 
 # Target executable
 # TODO: Requires libelf for target
@@ -35,5 +39,10 @@
 LOCAL_MODULE := elftree
 LOCAL_SRC_FILES := elftree.c
 LOCAL_C_INCLUDES := external/elfutils/libelf
+# to fix compatibility issues in elf headers across different platforms
+LOCAL_CFLAGS += \
+	-include external/elfutils/host-$(HOST_OS)-fixup/AndroidFixup.h
 LOCAL_STATIC_LIBRARIES := libelf
 include $(BUILD_HOST_EXECUTABLE)
+
+endif #cur_platform
diff --git a/tools/emulator/opengl/host/include/libOpenglRender/render_api_platform_types.h b/tools/emulator/opengl/host/include/libOpenglRender/render_api_platform_types.h
index 6f2a8a5..38324e1 100644
--- a/tools/emulator/opengl/host/include/libOpenglRender/render_api_platform_types.h
+++ b/tools/emulator/opengl/host/include/libOpenglRender/render_api_platform_types.h
@@ -1,3 +1,19 @@
+/*
+* Copyright 2011 The Android Open Source Project
+*
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+
 #ifndef _RENDER_API_PLATFORM_TYPES_H
 #define _RENDER_API_PLATFORM_TYPES_H
 
diff --git a/tools/emulator/opengl/host/libs/GLESv2_dec/GL2Decoder.cpp b/tools/emulator/opengl/host/libs/GLESv2_dec/GL2Decoder.cpp
index e867cf8..a777c50 100644
--- a/tools/emulator/opengl/host/libs/GLESv2_dec/GL2Decoder.cpp
+++ b/tools/emulator/opengl/host/libs/GLESv2_dec/GL2Decoder.cpp
@@ -1,3 +1,19 @@
+/*
+* Copyright 2011 The Android Open Source Project
+*
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+
 #include "GL2Decoder.h"
 #include <EGL/egl.h>
 #include <GLES2/gl2.h>
diff --git a/tools/emulator/opengl/host/libs/GLESv2_dec/GL2Decoder.h b/tools/emulator/opengl/host/libs/GLESv2_dec/GL2Decoder.h
index 24d01da..dcf2c07 100644
--- a/tools/emulator/opengl/host/libs/GLESv2_dec/GL2Decoder.h
+++ b/tools/emulator/opengl/host/libs/GLESv2_dec/GL2Decoder.h
@@ -1,3 +1,19 @@
+/*
+* Copyright 2011 The Android Open Source Project
+*
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+
 #ifndef _GL2_DECODER_H_
 #define _GL2_DECODER_H_
 
diff --git a/tools/emulator/opengl/host/libs/Translator/EGL/EglDisplay.cpp b/tools/emulator/opengl/host/libs/Translator/EGL/EglDisplay.cpp
index c2b515e..99f9d8b 100644
--- a/tools/emulator/opengl/host/libs/Translator/EGL/EglDisplay.cpp
+++ b/tools/emulator/opengl/host/libs/Translator/EGL/EglDisplay.cpp
@@ -17,7 +17,6 @@
 #include "EglOsApi.h"
 #include <GLcommon/GLutils.h>
 #include <utils/threads.h>
-#include <assert.h>
 
 EglDisplay::EglDisplay(EGLNativeInternalDisplayType dpy,bool isDefault) :
     m_dpy(dpy),
@@ -142,11 +141,8 @@
 
 SurfacePtr EglDisplay::getSurface(EGLSurface surface) {
     android::Mutex::Autolock mutex(m_lock);
-    /* surface is "key" in map<unsigned int, SurfacePtr>.
-       In 64-bit the upper 32-bit should be all zero.  Assert for that. */
-    uintptr_t hndlptr = (uintptr_t)surface;
-    unsigned int hndl = (unsigned int)hndlptr;
-    assert(sizeof(hndl) == sizeof(hndlptr) || hndl == hndlptr);
+    /* surface is "key" in map<unsigned int, SurfacePtr>. */
+    unsigned int hndl = ToTargetCompatibleHandle((uintptr_t)surface);
     SurfacesHndlMap::iterator it = m_surfaces.find(hndl);
     return it != m_surfaces.end() ?
                                   (*it).second :
@@ -155,11 +151,8 @@
 
 ContextPtr EglDisplay::getContext(EGLContext ctx) {
     android::Mutex::Autolock mutex(m_lock);
-    /* ctx is "key" in map<unsigned int, ContextPtr>.
-       In 64-bit the upper 32-bit should be all zero.  Assert for that. */
-    uintptr_t hndlptr = (uintptr_t)ctx;
-    unsigned int hndl = (unsigned int)hndlptr;
-    assert(sizeof(hndl) == sizeof(hndlptr) || hndl == hndlptr);
+    /* ctx is "key" in map<unsigned int, ContextPtr>. */
+    unsigned int hndl = ToTargetCompatibleHandle((uintptr_t)ctx);
     ContextsHndlMap::iterator it = m_contexts.find(hndl);
     return it != m_contexts.end() ?
                                   (*it).second :
@@ -168,11 +161,8 @@
 
 bool EglDisplay::removeSurface(EGLSurface s) {
     android::Mutex::Autolock mutex(m_lock);
-    /* s is "key" in map<unsigned int, SurfacePtr>.
-       In 64-bit the upper 32-bit should be all zero.  Assert for that. */
-    uintptr_t hndlptr = (uintptr_t)s;
-    unsigned int hndl = (unsigned int)hndlptr;
-    assert(sizeof(hndl) == sizeof(hndlptr) || hndl == hndlptr);
+    /* s is "key" in map<unsigned int, SurfacePtr>. */
+    unsigned int hndl = ToTargetCompatibleHandle((uintptr_t)s);
     SurfacesHndlMap::iterator it = m_surfaces.find(hndl);
     if(it != m_surfaces.end()) {
         m_surfaces.erase(it);
@@ -200,11 +190,8 @@
 
 bool EglDisplay::removeContext(EGLContext ctx) {
     android::Mutex::Autolock mutex(m_lock);
-    /* ctx is "key" in map<unsigned int, ContextPtr>.
-       In 64-bit the upper 32-bit should be all zero.  Assert for that. */
-    uintptr_t hndlptr = (uintptr_t)ctx;
-    unsigned int hndl = (unsigned int)hndlptr;
-    assert(sizeof(hndl) == sizeof(hndlptr) || hndl == hndlptr);
+    /* ctx is "key" in map<unsigned int, ContextPtr>. */
+    unsigned int hndl = ToTargetCompatibleHandle((uintptr_t)ctx);
     ContextsHndlMap::iterator it = m_contexts.find(hndl);
     if(it != m_contexts.end()) {
         m_contexts.erase(it);
@@ -307,22 +294,16 @@
 
 ImagePtr EglDisplay::getImage(EGLImageKHR img) {
     android::Mutex::Autolock mutex(m_lock);
-    /* img is "key" in map<unsigned int, ImagePtr>.
-       In 64-bit the upper 32-bit should be all zero.  Assert for that. */
-    uintptr_t hndlptr = (uintptr_t)img;
-    unsigned int hndl = (unsigned int)hndlptr;
-    assert(sizeof(hndl) == sizeof(hndlptr) || hndl == hndlptr);
+    /* img is "key" in map<unsigned int, ImagePtr>. */
+    unsigned int hndl = ToTargetCompatibleHandle((uintptr_t)img);
     ImagesHndlMap::iterator i( m_eglImages.find(hndl) );
     return (i != m_eglImages.end()) ? (*i).second :ImagePtr(NULL);
 }
 
 bool EglDisplay:: destroyImageKHR(EGLImageKHR img) {
     android::Mutex::Autolock mutex(m_lock);
-    /* img is "key" in map<unsigned int, ImagePtr>.
-       In 64-bit the upper 32-bit should be all zero.  Assert for that. */
-    uintptr_t hndlptr = (uintptr_t)img;
-    unsigned int hndl = (unsigned int)hndlptr;
-    assert(sizeof(hndl) == sizeof(hndlptr) || hndl == hndlptr);
+    /* img is "key" in map<unsigned int, ImagePtr>. */
+    unsigned int hndl = ToTargetCompatibleHandle((uintptr_t)img);
     ImagesHndlMap::iterator i( m_eglImages.find(hndl) );
     if (i != m_eglImages.end())
     {
diff --git a/tools/emulator/opengl/host/libs/Translator/EGL/MacNative.h b/tools/emulator/opengl/host/libs/Translator/EGL/MacNative.h
index 63145ec..82ab667 100644
--- a/tools/emulator/opengl/host/libs/Translator/EGL/MacNative.h
+++ b/tools/emulator/opengl/host/libs/Translator/EGL/MacNative.h
@@ -1,8 +1,5 @@
-#ifndef  MAC_NATIVE_H
-#define  MAC_NATIVE_H
-
 /*
-* Copyright (C) 2011 The Android Open Source Project
+* Copyright 2011 The Android Open Source Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
@@ -17,6 +14,9 @@
 * limitations under the License.
 */
 
+#ifndef  MAC_NATIVE_H
+#define  MAC_NATIVE_H
+
 typedef enum {                               // Mac equivalence
                  MAC_HAS_DOUBLE_BUFFER = 5,  // NSOpenGLPFADoubleBuffer
                  MAC_DRAW_TO_WINDOW    = 80, // NSOpenGLPFAWindow
diff --git a/tools/emulator/opengl/host/libs/Translator/EGL/MacPixelFormatsAttribs.h b/tools/emulator/opengl/host/libs/Translator/EGL/MacPixelFormatsAttribs.h
index 112aeec..692ac22 100644
--- a/tools/emulator/opengl/host/libs/Translator/EGL/MacPixelFormatsAttribs.h
+++ b/tools/emulator/opengl/host/libs/Translator/EGL/MacPixelFormatsAttribs.h
@@ -1,8 +1,5 @@
-#ifndef MAC_PIXELS_FORMATS_ATTRIBS_H	
-#define MAC_PIXELS_FORMATS_ATTRIBS_H	
-
 /*
-* Copyright (C) 2011 The Android Open Source Project
+* Copyright 2011 The Android Open Source Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
@@ -17,6 +14,9 @@
 * limitations under the License.
 */
 
+#ifndef MAC_PIXELS_FORMATS_ATTRIBS_H
+#define MAC_PIXELS_FORMATS_ATTRIBS_H
+
 #include <Cocoa/Cocoa.h>
 NSOpenGLPixelFormatAttribute** getPixelFormatsAttributes(int* size);
 
diff --git a/tools/emulator/opengl/host/libs/Translator/EGL/MacPixelFormatsAttribs.m b/tools/emulator/opengl/host/libs/Translator/EGL/MacPixelFormatsAttribs.m
index abbaf08..f5bc49c 100644
--- a/tools/emulator/opengl/host/libs/Translator/EGL/MacPixelFormatsAttribs.m
+++ b/tools/emulator/opengl/host/libs/Translator/EGL/MacPixelFormatsAttribs.m
@@ -1,7 +1,5 @@
-#include "MacPixelFormatsAttribs.h"
-
 /*
-* Copyright (C) 2011 The Android Open Source Project
+* Copyright 2011 The Android Open Source Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
@@ -16,6 +14,8 @@
 * limitations under the License.
 */
 
+#include "MacPixelFormatsAttribs.h"
+
 static NSOpenGLPixelFormatAttribute attrs32_1[] =
 {
     NSOpenGLPFADoubleBuffer,
diff --git a/tools/emulator/opengl/host/libs/Translator/GLES_CM/GLEScmImp.cpp b/tools/emulator/opengl/host/libs/Translator/GLES_CM/GLEScmImp.cpp
index ae90377..b78a022 100644
--- a/tools/emulator/opengl/host/libs/Translator/GLES_CM/GLEScmImp.cpp
+++ b/tools/emulator/opengl/host/libs/Translator/GLES_CM/GLEScmImp.cpp
@@ -35,7 +35,6 @@
 #include <GLES/glext.h>
 #include <cmath>
 #include <map>
-#include <assert.h>
 
 extern "C" {
 
@@ -1656,9 +1655,7 @@
 {
     GET_CTX();
     SET_ERROR_IF(!GLEScmValidate::textureTargetLimited(target),GL_INVALID_ENUM);
-    uintptr_t imagehndlptr = (uintptr_t)image;
-    unsigned int imagehndl = (unsigned int)imagehndlptr;
-    assert(sizeof(imagehndl) == sizeof(imagehndlptr) || imagehndl == imagehndlptr);
+    unsigned int imagehndl = ToTargetCompatibleHandle((uintptr_t)image);
     EglImage *img = s_eglIface->eglAttachEGLImage(imagehndl);
     if (img) {
         // Create the texture object in the underlying EGL implementation,
@@ -1694,9 +1691,7 @@
 {
     GET_CTX();
     SET_ERROR_IF(target != GL_RENDERBUFFER_OES,GL_INVALID_ENUM);
-    uintptr_t imagehndlptr = (uintptr_t)image;
-    unsigned int imagehndl = (unsigned int)imagehndlptr;
-    assert(sizeof(imagehndl) == sizeof(imagehndlptr) || imagehndl == imagehndlptr);
+    unsigned int imagehndl = ToTargetCompatibleHandle((uintptr_t)image);
     EglImage *img = s_eglIface->eglAttachEGLImage(imagehndl);
     SET_ERROR_IF(!img,GL_INVALID_VALUE);
     SET_ERROR_IF(!ctx->shareGroup().Ptr(),GL_INVALID_OPERATION);
diff --git a/tools/emulator/opengl/host/libs/Translator/GLES_V2/GLESv2Context.h b/tools/emulator/opengl/host/libs/Translator/GLES_V2/GLESv2Context.h
index 9cfc067..75af864 100644
--- a/tools/emulator/opengl/host/libs/Translator/GLES_V2/GLESv2Context.h
+++ b/tools/emulator/opengl/host/libs/Translator/GLES_V2/GLESv2Context.h
@@ -1,8 +1,5 @@
-#ifndef GLES_V2_CONTEXT_H
-#define GLES_V2_CONTEXT_H
-
 /*
-* Copyright (C) 2011 The Android Open Source Project
+* Copyright 2011 The Android Open Source Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
@@ -17,6 +14,9 @@
 * limitations under the License.
 */
 
+#ifndef GLES_V2_CONTEXT_H
+#define GLES_V2_CONTEXT_H
+
 #include <GLcommon/GLDispatch.h>
 #include <GLcommon/GLEScontext.h>
 #include <GLcommon/objectNameManager.h>
diff --git a/tools/emulator/opengl/host/libs/Translator/GLES_V2/GLESv2Imp.cpp b/tools/emulator/opengl/host/libs/Translator/GLES_V2/GLESv2Imp.cpp
index 7401f00..412584d 100644
--- a/tools/emulator/opengl/host/libs/Translator/GLES_V2/GLESv2Imp.cpp
+++ b/tools/emulator/opengl/host/libs/Translator/GLES_V2/GLESv2Imp.cpp
@@ -32,7 +32,6 @@
 #include "ProgramData.h"
 #include <GLcommon/TextureUtils.h>
 #include <GLcommon/FramebufferData.h>
-#include <assert.h>
 
 extern "C" {
 
@@ -2009,9 +2008,7 @@
 {
     GET_CTX();
     SET_ERROR_IF(!GLESv2Validate::textureTargetLimited(target),GL_INVALID_ENUM);
-    uintptr_t imagehndlptr = (uintptr_t)image;
-    unsigned int imagehndl = (unsigned int)imagehndlptr;
-    assert(sizeof(imagehndl) == sizeof(imagehndlptr) || imagehndl == imagehndlptr);
+    unsigned int imagehndl = ToTargetCompatibleHandle((uintptr_t)image);
     EglImage *img = s_eglIface->eglAttachEGLImage(imagehndl);
     if (img) {
         // Create the texture object in the underlying EGL implementation,
@@ -2036,7 +2033,7 @@
             texData->height = img->height;
             texData->border = img->border;
             texData->internalFormat = img->internalFormat;
-            texData->sourceEGLImage = (unsigned int)imagehndl;
+            texData->sourceEGLImage = imagehndl;
             texData->eglImageDetach = s_eglIface->eglDetachEGLImage;
             texData->oldGlobal = oldGlobal;
         }
@@ -2047,9 +2044,7 @@
 {
     GET_CTX();
     SET_ERROR_IF(target != GL_RENDERBUFFER_OES,GL_INVALID_ENUM);
-    uintptr_t imagehndlptr = (uintptr_t)image;
-    unsigned int imagehndl = (unsigned int)imagehndlptr;
-    assert(sizeof(imagehndl) == sizeof(imagehndlptr) || imagehndl == imagehndlptr);
+    unsigned int imagehndl = ToTargetCompatibleHandle((uintptr_t)image);
     EglImage *img = s_eglIface->eglAttachEGLImage(imagehndl);
     SET_ERROR_IF(!img,GL_INVALID_VALUE);
     SET_ERROR_IF(!ctx->shareGroup().Ptr(),GL_INVALID_OPERATION);
diff --git a/tools/emulator/opengl/host/libs/Translator/GLES_V2/GLESv2Validate.h b/tools/emulator/opengl/host/libs/Translator/GLES_V2/GLESv2Validate.h
index c62149b..b7cd07d 100644
--- a/tools/emulator/opengl/host/libs/Translator/GLES_V2/GLESv2Validate.h
+++ b/tools/emulator/opengl/host/libs/Translator/GLES_V2/GLESv2Validate.h
@@ -1,8 +1,5 @@
-#ifndef GLES_V2_VALIDATE_H
-#define GLES_V2_VALIDATE_H
-
 /*
-* Copyright (C) 2011 The Android Open Source Project
+* Copyright 2011 The Android Open Source Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
@@ -17,6 +14,9 @@
 * limitations under the License.
 */
 
+#ifndef GLES_V2_VALIDATE_H
+#define GLES_V2_VALIDATE_H
+
 #include <GLES2/gl2.h>
 #include <GLES2/gl2ext.h>
 #include <GLcommon/GLESvalidate.h>
diff --git a/tools/emulator/opengl/host/libs/Translator/GLES_V2/ShaderParser.cpp b/tools/emulator/opengl/host/libs/Translator/GLES_V2/ShaderParser.cpp
index 82cf5b5..a80326d 100644
--- a/tools/emulator/opengl/host/libs/Translator/GLES_V2/ShaderParser.cpp
+++ b/tools/emulator/opengl/host/libs/Translator/GLES_V2/ShaderParser.cpp
@@ -1,3 +1,19 @@
+/*
+* Copyright 2011 The Android Open Source Project
+*
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+
 #include "ShaderParser.h"
 #include <string.h>
 
diff --git a/tools/emulator/opengl/host/libs/Translator/GLES_V2/ShaderParser.h b/tools/emulator/opengl/host/libs/Translator/GLES_V2/ShaderParser.h
index 8c0ff3e..7b538c3 100644
--- a/tools/emulator/opengl/host/libs/Translator/GLES_V2/ShaderParser.h
+++ b/tools/emulator/opengl/host/libs/Translator/GLES_V2/ShaderParser.h
@@ -1,3 +1,19 @@
+/*
+* Copyright 2011 The Android Open Source Project
+*
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+
 #ifndef SHADER_PARSER_H
 #define SHADER_PARSER_H
 
diff --git a/tools/emulator/opengl/host/libs/Translator/GLcommon/DummyGLfuncs.cpp b/tools/emulator/opengl/host/libs/Translator/GLcommon/DummyGLfuncs.cpp
index 722aca0..e4b632d 100644
--- a/tools/emulator/opengl/host/libs/Translator/GLcommon/DummyGLfuncs.cpp
+++ b/tools/emulator/opengl/host/libs/Translator/GLcommon/DummyGLfuncs.cpp
@@ -1,7 +1,5 @@
-#include "DummyGLfuncs.h"
-
 /*
-* Copyright (C) 2011 The Android Open Source Project
+* Copyright 2011 The Android Open Source Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
@@ -16,6 +14,8 @@
 * limitations under the License.
 */
 
+#include "DummyGLfuncs.h"
+
     void GLAPIENTRY dummy_glActiveTexture ( GLenum texture ){}
     void GLAPIENTRY dummy_glBindBuffer (GLenum target, GLuint buffer){}
     void GLAPIENTRY dummy_glBindTexture (GLenum target, GLuint texture){}
diff --git a/tools/emulator/opengl/host/libs/Translator/GLcommon/DummyGLfuncs.h b/tools/emulator/opengl/host/libs/Translator/GLcommon/DummyGLfuncs.h
index c7e3519..f72107c 100644
--- a/tools/emulator/opengl/host/libs/Translator/GLcommon/DummyGLfuncs.h
+++ b/tools/emulator/opengl/host/libs/Translator/GLcommon/DummyGLfuncs.h
@@ -1,8 +1,5 @@
-#ifndef DUMMY_GL_FUNCS_H
-#define DUMMY_GL_FUNCS_H
-
 /*
-* Copyright (C) 2011 The Android Open Source Project
+* Copyright 2011 The Android Open Source Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
@@ -17,6 +14,9 @@
 * limitations under the License.
 */
 
+#ifndef DUMMY_GL_FUNCS_H
+#define DUMMY_GL_FUNCS_H
+
 #include <GLES/gl.h>
 #include <GLES2/gl2.h>
 
diff --git a/tools/emulator/opengl/host/libs/Translator/GLcommon/GLEScontext.cpp b/tools/emulator/opengl/host/libs/Translator/GLcommon/GLEScontext.cpp
index c213903..cff639e 100644
--- a/tools/emulator/opengl/host/libs/Translator/GLcommon/GLEScontext.cpp
+++ b/tools/emulator/opengl/host/libs/Translator/GLcommon/GLEScontext.cpp
@@ -1,3 +1,19 @@
+/*
+* Copyright 2011 The Android Open Source Project
+*
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+
 #include <GLcommon/GLEScontext.h>
 #include <GLcommon/GLconversion_macros.h>
 #include <GLcommon/GLESmacros.h>
@@ -7,7 +23,6 @@
 #include <GLcommon/TextureUtils.h>
 #include <GLcommon/FramebufferData.h>
 #include <strings.h>
-#include <assert.h>
 
 //decleration
 static void convertFixedDirectLoop(const char* dataIn,unsigned int strideIn,void* dataOut,unsigned int nBytes,unsigned int strideOut,int attribSize);
@@ -174,9 +189,7 @@
 const GLvoid* GLEScontext::setPointer(GLenum arrType,GLint size,GLenum type,GLsizei stride,const GLvoid* data,bool normalize) {
     GLuint bufferName = m_arrayBuffer;
     if(bufferName) {
-        uintptr_t offsetptr = (uintptr_t)data;
-        unsigned int offset = offsetptr;
-        assert(sizeof(offset) == sizeof(offsetptr) || offset == offsetptr);
+        unsigned int offset = ToTargetCompatibleHandle((uintptr_t)data);
         GLESbuffer* vbo = static_cast<GLESbuffer*>(m_shareGroup->getObjectData(VERTEXBUFFER,bufferName).Ptr());
         m_map[arrType]->setBuffer(size,type,stride,vbo,bufferName,offset,normalize);
         return  static_cast<const unsigned char*>(vbo->getData()) +  offset;
diff --git a/tools/emulator/opengl/host/libs/Translator/GLcommon/GLESvalidate.cpp b/tools/emulator/opengl/host/libs/Translator/GLcommon/GLESvalidate.cpp
index 281333f..882d95b 100644
--- a/tools/emulator/opengl/host/libs/Translator/GLcommon/GLESvalidate.cpp
+++ b/tools/emulator/opengl/host/libs/Translator/GLcommon/GLESvalidate.cpp
@@ -1,3 +1,19 @@
+/*
+* Copyright 2011 The Android Open Source Project
+*
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+
 #include <GLcommon/GLESvalidate.h>
 #include <GLES/gl.h>
 #include <GLES/glext.h>
diff --git a/tools/emulator/opengl/host/libs/Translator/include/EGL/eglinternalplatform.h b/tools/emulator/opengl/host/libs/Translator/include/EGL/eglinternalplatform.h
index c387043..953284a 100644
--- a/tools/emulator/opengl/host/libs/Translator/include/EGL/eglinternalplatform.h
+++ b/tools/emulator/opengl/host/libs/Translator/include/EGL/eglinternalplatform.h
@@ -1,8 +1,5 @@
-#ifndef EGL_INTERNAL_PLATFORM_H
-#define EGL_INTERNAL_PLATFORM_H
-
 /*
-* Copyright (C) 2011 The Android Open Source Project
+* Copyright 2011 The Android Open Source Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
@@ -17,6 +14,9 @@
 * limitations under the License.
 */
 
+#ifndef EGL_INTERNAL_PLATFORM_H
+#define EGL_INTERNAL_PLATFORM_H
+
 class SrfcInfo; //defined in Egl{$platform}Api.cpp
 typedef SrfcInfo* SURFACE;
 typedef SURFACE EGLNativeSurfaceType;
diff --git a/tools/emulator/opengl/host/libs/Translator/include/GLcommon/GLEScontext.h b/tools/emulator/opengl/host/libs/Translator/include/GLcommon/GLEScontext.h
index 59e367f..fbc118f 100644
--- a/tools/emulator/opengl/host/libs/Translator/include/GLcommon/GLEScontext.h
+++ b/tools/emulator/opengl/host/libs/Translator/include/GLcommon/GLEScontext.h
@@ -1,3 +1,19 @@
+/*
+* Copyright 2011 The Android Open Source Project
+*
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+
 #ifndef GLES_CONTEXT_H
 #define GLES_CONTEXT_H
 
diff --git a/tools/emulator/opengl/host/libs/Translator/include/GLcommon/GLutils.h b/tools/emulator/opengl/host/libs/Translator/include/GLcommon/GLutils.h
index 7e2a038..2aed646 100644
--- a/tools/emulator/opengl/host/libs/Translator/include/GLcommon/GLutils.h
+++ b/tools/emulator/opengl/host/libs/Translator/include/GLcommon/GLutils.h
@@ -16,6 +16,9 @@
 #ifndef GL_UTILS_H
 #define GL_UTILS_H
 
+#include <inttypes.h>
+#include <assert.h>
+
 typedef enum{
              GLES_1_1 = 1,
              GLES_2_0 = 2,
@@ -32,4 +35,17 @@
 
 bool isPowerOf2(int num);
 
+inline
+unsigned int ToTargetCompatibleHandle(uintptr_t hostHandle)
+{
+    // The host and target handles can have different sizes (e.g. 32-bit
+    // target handle for ARM, and 64-bit host handle on x86_64).
+    // This function checks that the input host handle value can be
+    // converted into a target handle one without losing any bits.
+    //
+    unsigned int targetHandle = (unsigned int)hostHandle;
+    assert(sizeof(targetHandle) == sizeof(hostHandle) || targetHandle == hostHandle);
+    return targetHandle;
+}
+
 #endif
diff --git a/tools/emulator/opengl/host/tools/emugen/ApiGen.cpp b/tools/emulator/opengl/host/tools/emugen/ApiGen.cpp
index bc921fc..bf2d244 100644
--- a/tools/emulator/opengl/host/tools/emugen/ApiGen.cpp
+++ b/tools/emulator/opengl/host/tools/emugen/ApiGen.cpp
@@ -462,7 +462,8 @@
     size_t n = size();
 
     // unsupport printout
-    fprintf(fp, "static void enc_unsupported()\n{\n\tLOGE(\"Function is unsupported\\n\");\n}\n\n");
+    fprintf(fp,
+            "static void enc_unsupported()\n{\n\tALOGE(\"Function is unsupported\\n\");\n}\n\n");
 
     // entry points;
     for (size_t i = 0; i < n; i++) {
diff --git a/tools/emulator/opengl/shared/OpenglCodecCommon/ErrorLog.h b/tools/emulator/opengl/shared/OpenglCodecCommon/ErrorLog.h
index 5e9c7b3..6f41fd7 100644
--- a/tools/emulator/opengl/shared/OpenglCodecCommon/ErrorLog.h
+++ b/tools/emulator/opengl/shared/OpenglCodecCommon/ErrorLog.h
@@ -18,9 +18,9 @@
 
 #if (HAVE_ANDROID_OS == 1)
 #    include <cutils/log.h>
-#    define ERR(...)    LOGE(__VA_ARGS__)
+#    define ERR(...)    ALOGE(__VA_ARGS__)
 #    ifdef EMUGL_DEBUG
-#        define DBG(...)    LOGD(__VA_ARGS__)
+#        define DBG(...)    ALOGD(__VA_ARGS__)
 #    else
 #        define DBG(...)    ((void)0)
 #    endif
diff --git a/tools/emulator/opengl/shared/OpenglCodecCommon/GLErrorLog.h b/tools/emulator/opengl/shared/OpenglCodecCommon/GLErrorLog.h
index 3f30b22..5654aea 100644
--- a/tools/emulator/opengl/shared/OpenglCodecCommon/GLErrorLog.h
+++ b/tools/emulator/opengl/shared/OpenglCodecCommon/GLErrorLog.h
@@ -1,3 +1,19 @@
+/*
+* Copyright 2011 The Android Open Source Project
+*
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+
 #ifndef __GL_ERROR_LOG_H__
 #define __GL_ERROR_LOG_H__
 
diff --git a/tools/emulator/opengl/system/GLESv1/gl.cpp b/tools/emulator/opengl/system/GLESv1/gl.cpp
index 43577e0..8ecb504 100644
--- a/tools/emulator/opengl/system/GLESv1/gl.cpp
+++ b/tools/emulator/opengl/system/GLESv1/gl.cpp
@@ -1,10 +1,25 @@
+/*
+* Copyright 2011 The Android Open Source Project
+*
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+
 #include "EGLClientIface.h"
 #include "HostConnection.h"
 #include "GLEncoder.h"
 #include "GLES/gl.h"
 #include "GLES/glext.h"
 #include "ErrorLog.h"
-#include <private/ui/android_natives_priv.h>
 #include "gralloc_cb.h"
 #include "ThreadInfo.h"
 
@@ -23,12 +38,12 @@
 #define DEFINE_AND_VALIDATE_HOST_CONNECTION(ret) \
     HostConnection *hostCon = HostConnection::get(); \
     if (!hostCon) { \
-        LOGE("egl: Failed to get host connection\n"); \
+        ALOGE("egl: Failed to get host connection\n"); \
         return ret; \
     } \
     renderControl_encoder_context_t *rcEnc = hostCon->rcEncoder(); \
     if (!rcEnc) { \
-        LOGE("egl: Failed to get renderControl encoder context\n"); \
+        ALOGE("egl: Failed to get renderControl encoder context\n"); \
         return ret; \
     }
 
diff --git a/tools/emulator/opengl/system/GLESv1_enc/GLEncoder.cpp b/tools/emulator/opengl/system/GLESv1_enc/GLEncoder.cpp
index 4a36537..4414f24 100644
--- a/tools/emulator/opengl/system/GLESv1_enc/GLEncoder.cpp
+++ b/tools/emulator/opengl/system/GLESv1_enc/GLEncoder.cpp
@@ -16,7 +16,6 @@
 #include "GLEncoder.h"
 #include "glUtils.h"
 #include "FixedBuffer.h"
-#include <private/ui/android_natives_priv.h>
 #include <cutils/log.h>
 #include <assert.h>
 
@@ -30,14 +29,14 @@
 static GLubyte *gExtensionsString= (GLubyte *) ""; // no extensions at this point;
 
 #define SET_ERROR_IF(condition,err) if((condition)) {                            \
-        LOGE("%s:%s:%d GL error 0x%x\n", __FILE__, __FUNCTION__, __LINE__, err); \
+        ALOGE("%s:%s:%d GL error 0x%x\n", __FILE__, __FUNCTION__, __LINE__, err); \
         ctx->setError(err);                                    \
         return;                                                  \
     }
 
 
 #define RET_AND_SET_ERROR_IF(condition,err,ret) if((condition)) {                \
-        LOGE("%s:%s:%d GL error 0x%x\n", __FILE__, __FUNCTION__, __LINE__, err); \
+        ALOGE("%s:%s:%d GL error 0x%x\n", __FILE__, __FUNCTION__, __LINE__, err); \
         ctx->setError(err);                                    \
         return ret;                                              \
     }
@@ -258,7 +257,7 @@
 {
     GLEncoder *ctx = (GLEncoder *)self;
     ctx->m_glPixelStorei_enc(ctx, param, value);
-    LOG_ASSERT(ctx->m_state, "GLEncoder::s_glPixelStorei");
+    ALOG_ASSERT(ctx->m_state, "GLEncoder::s_glPixelStorei");
     ctx->m_state->setPixelStore(param, value);
 }
 
@@ -537,7 +536,7 @@
     }
 
     if (!has_immediate_arrays && !has_indirect_arrays) {
-        LOGE("glDrawElements: no data bound to the command - ignoring\n");
+        ALOGE("glDrawElements: no data bound to the command - ignoring\n");
         return;
     }
 
@@ -580,7 +579,7 @@
             }
             break;
         default:
-            LOGE("unsupported index buffer type %d\n", type);
+            ALOGE("unsupported index buffer type %d\n", type);
         }
         if (has_indirect_arrays || 1) {
             ctx->sendVertexData(minIndex, maxIndex - minIndex + 1);
@@ -588,12 +587,12 @@
                                       count * glSizeof(type));
             // XXX - OPTIMIZATION (see the other else branch) should be implemented
             if(!has_indirect_arrays) {
-                //LOGD("unoptimized drawelements !!!\n");
+                //ALOGD("unoptimized drawelements !!!\n");
             }
         } else {
             // we are all direct arrays and immidate mode index array -
             // rebuild the arrays and the index array;
-            LOGE("glDrawElements: direct index & direct buffer data - will be implemented in later versions;\n");
+            ALOGE("glDrawElements: direct index & direct buffer data - will be implemented in later versions;\n");
         }
     }
 }
@@ -605,7 +604,7 @@
     GLenum err;
 
     if ((err = state->setActiveTextureUnit(texture)) != GL_NO_ERROR) {
-        LOGE("%s:%s:%d GL error %#x\n", __FILE__, __FUNCTION__, __LINE__, err);
+        ALOGE("%s:%s:%d GL error %#x\n", __FILE__, __FUNCTION__, __LINE__, err);
         ctx->setError(err);
         return;
     }
@@ -621,7 +620,7 @@
 
     GLboolean firstUse;
     if ((err = state->bindTexture(target, texture, &firstUse)) != GL_NO_ERROR) {
-        LOGE("%s:%s:%d GL error %#x\n", __FILE__, __FUNCTION__, __LINE__, err);
+        ALOGE("%s:%s:%d GL error %#x\n", __FILE__, __FUNCTION__, __LINE__, err);
         ctx->setError(err);
         return;
     }
diff --git a/tools/emulator/opengl/system/GLESv2/gl2.cpp b/tools/emulator/opengl/system/GLESv2/gl2.cpp
index f852a9b..b32dd74 100644
--- a/tools/emulator/opengl/system/GLESv2/gl2.cpp
+++ b/tools/emulator/opengl/system/GLESv2/gl2.cpp
@@ -1,10 +1,25 @@
+/*
+* Copyright 2011 The Android Open Source Project
+*
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+
 #include "EGLClientIface.h"
 #include "HostConnection.h"
 #include "GL2Encoder.h"
 #include "GLES/gl.h"
 #include "GLES/glext.h"
 #include "ErrorLog.h"
-#include <private/ui/android_natives_priv.h>
 #include "gralloc_cb.h"
 #include "ThreadInfo.h"
 
@@ -23,12 +38,12 @@
 #define DEFINE_AND_VALIDATE_HOST_CONNECTION(ret) \
     HostConnection *hostCon = HostConnection::get(); \
     if (!hostCon) { \
-        LOGE("egl: Failed to get host connection\n"); \
+        ALOGE("egl: Failed to get host connection\n"); \
         return ret; \
     } \
     renderControl_encoder_context_t *rcEnc = hostCon->rcEncoder(); \
     if (!rcEnc) { \
-        LOGE("egl: Failed to get renderControl encoder context\n"); \
+        ALOGE("egl: Failed to get renderControl encoder context\n"); \
         return ret; \
     }
 
diff --git a/tools/emulator/opengl/system/GLESv2_enc/GL2Encoder.cpp b/tools/emulator/opengl/system/GLESv2_enc/GL2Encoder.cpp
index c9fb396..d8fedf3 100644
--- a/tools/emulator/opengl/system/GLESv2_enc/GL2Encoder.cpp
+++ b/tools/emulator/opengl/system/GLESv2_enc/GL2Encoder.cpp
@@ -15,7 +15,6 @@
 */
 
 #include "GL2Encoder.h"
-#include <private/ui/android_natives_priv.h>
 #include <assert.h>
 #include <ctype.h>
 
@@ -29,14 +28,14 @@
 static GLubyte *gExtensionsString= (GLubyte *) ""; // no extensions at this point;
 
 #define SET_ERROR_IF(condition,err) if((condition)) {                            \
-        LOGE("%s:%s:%d GL error 0x%x\n", __FILE__, __FUNCTION__, __LINE__, err); \
+        ALOGE("%s:%s:%d GL error 0x%x\n", __FILE__, __FUNCTION__, __LINE__, err); \
         ctx->setError(err);                                    \
         return;                                                  \
     }
 
 
 #define RET_AND_SET_ERROR_IF(condition,err,ret) if((condition)) {                \
-        LOGE("%s:%s:%d GL error 0x%x\n", __FILE__, __FUNCTION__, __LINE__, err); \
+        ALOGE("%s:%s:%d GL error 0x%x\n", __FILE__, __FUNCTION__, __LINE__, err); \
         ctx->setError(err);                                    \
         return ret;                                              \
     }
@@ -471,7 +470,7 @@
     }
 
     if (!has_immediate_arrays && !has_indirect_arrays) {
-        LOGE("glDrawElements: no data bound to the command - ignoring\n");
+        ALOGE("glDrawElements: no data bound to the command - ignoring\n");
         return;
     }
 
@@ -514,7 +513,7 @@
             }
             break;
         default:
-            LOGE("unsupported index buffer type %d\n", type);
+            ALOGE("unsupported index buffer type %d\n", type);
         }
         if (has_indirect_arrays || 1) {
             ctx->sendVertexAttributes(minIndex, maxIndex - minIndex + 1);
@@ -522,12 +521,12 @@
                                     count * glSizeof(type));
             // XXX - OPTIMIZATION (see the other else branch) should be implemented
             if(!has_indirect_arrays) {
-                //LOGD("unoptimized drawelements !!!\n");
+                //ALOGD("unoptimized drawelements !!!\n");
             }
         } else {
             // we are all direct arrays and immidate mode index array -
             // rebuild the arrays and the index array;
-            LOGE("glDrawElements: direct index & direct buffer data - will be implemented in later versions;\n");
+            ALOGE("glDrawElements: direct index & direct buffer data - will be implemented in later versions;\n");
         }
     }
 }
diff --git a/tools/emulator/opengl/system/OpenglSystemCommon/EGLClientIface.h b/tools/emulator/opengl/system/OpenglSystemCommon/EGLClientIface.h
index 1089340..3c8cb55 100644
--- a/tools/emulator/opengl/system/OpenglSystemCommon/EGLClientIface.h
+++ b/tools/emulator/opengl/system/OpenglSystemCommon/EGLClientIface.h
@@ -1,3 +1,19 @@
+/*
+* Copyright 2011 The Android Open Source Project
+*
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+
 #ifndef _SYSTEM_COMMON_EGL_CLIENT_IFACE_H
 #define _SYSTEM_COMMON_EGL_CLIENT_IFACE_H
 
diff --git a/tools/emulator/opengl/system/OpenglSystemCommon/HostConnection.cpp b/tools/emulator/opengl/system/OpenglSystemCommon/HostConnection.cpp
index 3355d9f..940f5ae 100644
--- a/tools/emulator/opengl/system/OpenglSystemCommon/HostConnection.cpp
+++ b/tools/emulator/opengl/system/OpenglSystemCommon/HostConnection.cpp
@@ -63,12 +63,12 @@
         if (useQemuPipe) {
             QemuPipeStream *stream = new QemuPipeStream(STREAM_BUFFER_SIZE);
             if (!stream) {
-                LOGE("Failed to create QemuPipeStream for host connection!!!\n");
+                ALOGE("Failed to create QemuPipeStream for host connection!!!\n");
                 delete con;
                 return NULL;
             }
             if (stream->connect() < 0) {
-                LOGE("Failed to connect to host (QemuPipeStream)!!!\n");
+                ALOGE("Failed to connect to host (QemuPipeStream)!!!\n");
                 delete stream;
                 delete con;
                 return NULL;
@@ -79,13 +79,13 @@
         {
             TcpStream *stream = new TcpStream(STREAM_BUFFER_SIZE);
             if (!stream) {
-                LOGE("Failed to create TcpStream for host connection!!!\n");
+                ALOGE("Failed to create TcpStream for host connection!!!\n");
                 delete con;
                 return NULL;
             }
 
             if (stream->connect("10.0.2.2", STREAM_PORT_NUM) < 0) {
-                LOGE("Failed to connect to host (TcpStream)!!!\n");
+                ALOGE("Failed to connect to host (TcpStream)!!!\n");
                 delete stream;
                 delete con;
                 return NULL;
@@ -99,7 +99,7 @@
         *pClientFlags = 0;
         con->m_stream->commitBuffer(sizeof(unsigned int));
 
-        LOGD("HostConnection::get() New Host Connection established %p, tid %d\n", con, gettid());
+        ALOGD("HostConnection::get() New Host Connection established %p, tid %d\n", con, gettid());
         tinfo->hostConn = con;
     }
 
diff --git a/tools/emulator/opengl/system/OpenglSystemCommon/gralloc_cb.h b/tools/emulator/opengl/system/OpenglSystemCommon/gralloc_cb.h
index 530e004..e879409 100644
--- a/tools/emulator/opengl/system/OpenglSystemCommon/gralloc_cb.h
+++ b/tools/emulator/opengl/system/OpenglSystemCommon/gralloc_cb.h
@@ -1,3 +1,19 @@
+/*
+* Copyright 2011 The Android Open Source Project
+*
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+
 #ifndef __GRALLOC_CB_H__
 #define __GRALLOC_CB_H__
 
diff --git a/tools/emulator/opengl/system/egl/egl.cfg b/tools/emulator/opengl/system/egl/egl.cfg
index 951a2e8..9d3f2dc 100644
--- a/tools/emulator/opengl/system/egl/egl.cfg
+++ b/tools/emulator/opengl/system/egl/egl.cfg
@@ -1,2 +1 @@
-0 1 emulation
-0 0 android
+0 0 emulation
diff --git a/tools/emulator/opengl/system/egl/egl.cpp b/tools/emulator/opengl/system/egl/egl.cpp
index 49223a0..5aa5bda 100644
--- a/tools/emulator/opengl/system/egl/egl.cpp
+++ b/tools/emulator/opengl/system/egl/egl.cpp
@@ -29,7 +29,7 @@
 #include "GL2Encoder.h"
 #endif
 
-#include <private/ui/android_natives_priv.h>
+#include <system/window.h>
 
 template<typename T>
 static T setErrorFunc(GLint error, T returnValue) {
@@ -65,12 +65,12 @@
 
 #define setErrorReturn(error, retVal)     \
     {                                                \
-        LOGE("tid %d: %s(%d): error 0x%x (%s)", gettid(), __FUNCTION__, __LINE__, error, eglStrError(error));     \
+        ALOGE("tid %d: %s(%d): error 0x%x (%s)", gettid(), __FUNCTION__, __LINE__, error, eglStrError(error));     \
         return setErrorFunc(error, retVal);            \
     }
 
 #define RETURN_ERROR(ret,err)           \
-    LOGE("tid %d: %s(%d): error 0x%x (%s)", gettid(), __FUNCTION__, __LINE__, err, eglStrError(err));    \
+    ALOGE("tid %d: %s(%d): error 0x%x (%s)", gettid(), __FUNCTION__, __LINE__, err, eglStrError(err));    \
     getEGLThreadInfo()->eglError = err;    \
     return ret;
 
@@ -107,12 +107,12 @@
 #define DEFINE_AND_VALIDATE_HOST_CONNECTION(ret) \
     HostConnection *hostCon = HostConnection::get(); \
     if (!hostCon) { \
-        LOGE("egl: Failed to get host connection\n"); \
+        ALOGE("egl: Failed to get host connection\n"); \
         return ret; \
     } \
     renderControl_encoder_context_t *rcEnc = hostCon->rcEncoder(); \
     if (!rcEnc) { \
-        LOGE("egl: Failed to get renderControl encoder context\n"); \
+        ALOGE("egl: Failed to get renderControl encoder context\n"); \
         return ret; \
     }
 
@@ -271,7 +271,7 @@
     rcSurface = rcEnc->rcCreateWindowSurface(rcEnc, (uint32_t)config,
             getWidth(), getHeight());
     if (!rcSurface) {
-        LOGE("rcCreateWindowSurface returned 0");
+        ALOGE("rcCreateWindowSurface returned 0");
         return EGL_FALSE;
     }
     rcEnc->rcSetWindowColorBuffer(rcEnc, rcSurface,
@@ -375,14 +375,14 @@
     rcSurface = rcEnc->rcCreateWindowSurface(rcEnc, (uint32_t)config,
             getWidth(), getHeight());
     if (!rcSurface) {
-        LOGE("rcCreateWindowSurface returned 0");
+        ALOGE("rcCreateWindowSurface returned 0");
         return EGL_FALSE;
     }
 
     rcColorBuffer = rcEnc->rcCreateColorBuffer(rcEnc, getWidth(), getHeight(),
             pixelFormat);
     if (!rcColorBuffer) {
-        LOGE("rcCreateColorBuffer returned 0");
+        ALOGE("rcCreateColorBuffer returned 0");
         return EGL_FALSE;
     }
 
@@ -747,7 +747,7 @@
             break;
         //TODO: complete other attributes
         default:
-            LOGE("eglQuerySurface %x  EGL_BAD_ATTRIBUTE", attribute);
+            ALOGE("eglQuerySurface %x  EGL_BAD_ATTRIBUTE", attribute);
             ret = setErrorFunc(EGL_BAD_ATTRIBUTE, EGL_FALSE);
             break;
     }
@@ -784,14 +784,14 @@
 EGLSurface eglCreatePbufferFromClientBuffer(EGLDisplay dpy, EGLenum buftype, EGLClientBuffer buffer, EGLConfig config, const EGLint *attrib_list)
 {
     //TODO
-    LOGW("%s not implemented", __FUNCTION__);
+    ALOGW("%s not implemented", __FUNCTION__);
     return 0;
 }
 
 EGLBoolean eglSurfaceAttrib(EGLDisplay dpy, EGLSurface surface, EGLint attribute, EGLint value)
 {
     //TODO
-    LOGW("%s not implemented", __FUNCTION__);
+    ALOGW("%s not implemented", __FUNCTION__);
     return 0;
 }
 
@@ -829,7 +829,7 @@
 EGLBoolean eglReleaseTexImage(EGLDisplay dpy, EGLSurface surface, EGLint buffer)
 {
     //TODO
-    LOGW("%s not implemented", __FUNCTION__);
+    ALOGW("%s not implemented", __FUNCTION__);
     return 0;
 }
 
@@ -876,7 +876,7 @@
     DEFINE_AND_VALIDATE_HOST_CONNECTION(EGL_NO_CONTEXT);
     uint32_t rcContext = rcEnc->rcCreateContext(rcEnc, (uint32_t)config, rcShareCtx, version);
     if (!rcContext) {
-        LOGE("rcCreateContext returned 0");
+        ALOGE("rcCreateContext returned 0");
         setErrorReturn(EGL_BAD_ALLOC, EGL_NO_CONTEXT);
     }
 
@@ -948,7 +948,7 @@
 
     DEFINE_AND_VALIDATE_HOST_CONNECTION(EGL_FALSE);
     if (rcEnc->rcMakeCurrent(rcEnc, ctxHandle, drawHandle, readHandle) == EGL_FALSE) {
-        LOGE("rcMakeCurrent returned EGL_FALSE");
+        ALOGE("rcMakeCurrent returned EGL_FALSE");
         setErrorReturn(EGL_BAD_CONTEXT, EGL_FALSE);
     }
 
@@ -1062,7 +1062,7 @@
                 *value = EGL_BACK_BUFFER; //single buffer not supported
             break;
         default:
-            LOGE("eglQueryContext %x  EGL_BAD_ATTRIBUTE", attribute);
+            ALOGE("eglQueryContext %x  EGL_BAD_ATTRIBUTE", attribute);
             setErrorReturn(EGL_BAD_ATTRIBUTE, EGL_FALSE);
             break;
     }
diff --git a/tools/emulator/opengl/system/egl/eglDisplay.cpp b/tools/emulator/opengl/system/egl/eglDisplay.cpp
index 7beeb8e..2497548 100644
--- a/tools/emulator/opengl/system/egl/eglDisplay.cpp
+++ b/tools/emulator/opengl/system/egl/eglDisplay.cpp
@@ -88,7 +88,7 @@
                                          &s_gles_lib);
         if (!m_gles_iface) {
             pthread_mutex_unlock(&m_lock);
-            LOGE("Failed to load gles1 iface");
+            ALOGE("Failed to load gles1 iface");
             return false;
         }
 
@@ -106,7 +106,7 @@
         HostConnection *hcon = HostConnection::get();
         if (!hcon) {
             pthread_mutex_unlock(&m_lock);
-            LOGE("Failed to establish connection with the host\n");
+            ALOGE("Failed to establish connection with the host\n");
             return false;
         }
 
@@ -116,7 +116,7 @@
         renderControl_encoder_context_t *rcEnc = hcon->rcEncoder();
         if (!rcEnc) {
             pthread_mutex_unlock(&m_lock);
-            LOGE("Failed to get renderControl encoder instance");
+            ALOGE("Failed to get renderControl encoder instance");
             return false;
         }
 
@@ -228,13 +228,13 @@
 {
     void *lib = dlopen(libName, RTLD_NOW);
     if (!lib) {
-        LOGE("Failed to dlopen %s", libName);
+        ALOGE("Failed to dlopen %s", libName);
         return NULL;
     }
 
     init_emul_gles_t init_gles_func = (init_emul_gles_t)dlsym(lib,"init_emul_gles");
     if (!init_gles_func) {
-        LOGE("Failed to find init_emul_gles");
+        ALOGE("Failed to find init_emul_gles");
         dlclose((void*)lib);
         return NULL;
     }
@@ -385,7 +385,7 @@
         return m_extensionString;
     }
     else {
-        LOGE("[%s] Unknown name %d\n", __FUNCTION__, name);
+        ALOGE("[%s] Unknown name %d\n", __FUNCTION__, name);
         return NULL;
     }
 }
@@ -397,7 +397,7 @@
 {
     if (attribIdx == ATTRIBUTE_NONE)
     {
-        LOGE("[%s] Bad attribute idx\n", __FUNCTION__);
+        ALOGE("[%s] Bad attribute idx\n", __FUNCTION__);
         return EGL_FALSE;
     }
     *value = *(m_configs + (int)config*m_numConfigAttribs + attribIdx);
@@ -430,7 +430,7 @@
 {
     if (attribIdx == ATTRIBUTE_NONE)
     {
-        LOGE("[%s] Bad attribute idx\n", __FUNCTION__);
+        ALOGE("[%s] Bad attribute idx\n", __FUNCTION__);
         return EGL_FALSE;
     }
     *(m_configs + (int)config*m_numConfigAttribs + attribIdx) = value;
@@ -456,7 +456,7 @@
         getAttribValue(config, m_attribs.valueFor(EGL_GREEN_SIZE), &greenSize) &&
         getAttribValue(config, m_attribs.valueFor(EGL_ALPHA_SIZE), &alphaSize)) )
     {
-        LOGE("Couldn't find value for one of the pixel format attributes");
+        ALOGE("Couldn't find value for one of the pixel format attributes");
         return EGL_FALSE;
     }
 
@@ -480,7 +480,7 @@
         getAttribValue(config, m_attribs.valueFor(EGL_GREEN_SIZE), &greenSize) &&
         getAttribValue(config, m_attribs.valueFor(EGL_ALPHA_SIZE), &alphaSize)) )
     {
-        LOGE("Couldn't find value for one of the pixel format attributes");
+        ALOGE("Couldn't find value for one of the pixel format attributes");
         return EGL_FALSE;
     }
 
diff --git a/tools/emulator/opengl/system/gralloc/gralloc.cpp b/tools/emulator/opengl/system/gralloc/gralloc.cpp
index bf098eb..baad99b 100644
--- a/tools/emulator/opengl/system/gralloc/gralloc.cpp
+++ b/tools/emulator/opengl/system/gralloc/gralloc.cpp
@@ -35,13 +35,13 @@
 #define DEBUG  0
 
 #if DEBUG >= 1
-#  define D(...)   LOGD(__VA_ARGS__)
+#  define D(...)   ALOGD(__VA_ARGS__)
 #else
 #  define D(...)   ((void)0)
 #endif
 
 #if DEBUG >= 2
-#  define DD(...)  LOGD(__VA_ARGS__)
+#  define DD(...)  ALOGD(__VA_ARGS__)
 #else
 #  define DD(...)  ((void)0)
 #endif
@@ -113,12 +113,12 @@
 #define DEFINE_AND_VALIDATE_HOST_CONNECTION \
     HostConnection *hostCon = HostConnection::get(); \
     if (!hostCon) { \
-        LOGE("gralloc: Failed to get host connection\n"); \
+        ALOGE("gralloc: Failed to get host connection\n"); \
         return -EIO; \
     } \
     renderControl_encoder_context_t *rcEnc = hostCon->rcEncoder(); \
     if (!rcEnc) { \
-        LOGE("gralloc: Failed to get renderControl encoder context\n"); \
+        ALOGE("gralloc: Failed to get renderControl encoder context\n"); \
         return -EIO; \
     }
 
@@ -209,7 +209,7 @@
 
         fd = ashmem_create_region("gralloc-buffer", ashmem_size);
         if (fd < 0) {
-            LOGE("gralloc_alloc failed to create ashmem region: %s\n", strerror(errno));
+            ALOGE("gralloc_alloc failed to create ashmem region: %s\n", strerror(errno));
             return -errno;
         }
     }
@@ -515,7 +515,7 @@
     private_module_t *gr = (private_module_t *)module;
     cb_handle_t *cb = (cb_handle_t *)handle;
     if (!gr || !cb_handle_t::validate(cb)) {
-        LOGE("gralloc_lock bad handle\n");
+        ALOGE("gralloc_lock bad handle\n");
         return -EINVAL;
     }
 
@@ -534,7 +534,7 @@
          (!sw_read && !sw_write) ||
          (sw_read && !sw_read_allowed) ||
          (sw_write && !sw_write_allowed) ) {
-        LOGE("gralloc_lock usage mismatch usage=0x%x cb->usage=0x%x\n", usage, cb->usage);
+        ALOGE("gralloc_lock usage mismatch usage=0x%x cb->usage=0x%x\n", usage, cb->usage);
         return -EINVAL;
     }
 
@@ -571,7 +571,7 @@
         if (hostSyncStatus < 0) {
             // host failed the color buffer sync - probably since it was already
             // locked for write access. fail the lock.
-            LOGE("gralloc_lock cacheFlush failed postCount=%d sw_read=%d\n",
+            ALOGE("gralloc_lock cacheFlush failed postCount=%d sw_read=%d\n",
                  postCount, sw_read);
             return -EBUSY;
         }
@@ -681,7 +681,7 @@
         // return error if connection with host can not be established
         HostConnection *hostCon = HostConnection::get();
         if (!hostCon) {
-            LOGE("gralloc: failed to get host connection while opening %s\n", name);
+            ALOGE("gralloc: failed to get host connection while opening %s\n", name);
             return -EIO;
         }
 
@@ -817,7 +817,7 @@
     if (atoi(prop) > 0) {
         return;
     }
-    LOGD("Emulator without GPU emulation detected.");
+    ALOGD("Emulator without GPU emulation detected.");
     module = dlopen("/system/lib/hw/gralloc.default.so", RTLD_LAZY|RTLD_LOCAL);
     if (module != NULL) {
         sFallback = reinterpret_cast<gralloc_module_t*>(dlsym(module, HAL_MODULE_INFO_SYM_AS_STR));
@@ -826,6 +826,6 @@
         }
     }
     if (sFallback == NULL) {
-        LOGE("Could not find software fallback module!?");
+        ALOGE("Could not find software fallback module!?");
     }
 }
diff --git a/tools/emulator/opengl/system/renderControl_enc/renderControl_types.h b/tools/emulator/opengl/system/renderControl_enc/renderControl_types.h
index cb8e416..da215bb 100644
--- a/tools/emulator/opengl/system/renderControl_enc/renderControl_types.h
+++ b/tools/emulator/opengl/system/renderControl_enc/renderControl_types.h
@@ -1,3 +1,19 @@
+/*
+* Copyright 2011 The Android Open Source Project
+*
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+
 #include <stdint.h>
 #include <EGL/egl.h>
 #include "glUtils.h"
diff --git a/tools/emulator/opengl/tests/gles_android_wrapper/ApiInitializer.h b/tools/emulator/opengl/tests/gles_android_wrapper/ApiInitializer.h
index 7dc5006..793c735 100644
--- a/tools/emulator/opengl/tests/gles_android_wrapper/ApiInitializer.h
+++ b/tools/emulator/opengl/tests/gles_android_wrapper/ApiInitializer.h
@@ -1,3 +1,19 @@
+/*
+* Copyright 2011 The Android Open Source Project
+*
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+
 #ifndef _API_INITIALIZER_H_
 #define _API_INITIALIZER_H_
 #include <stdlib.h>
diff --git a/tools/emulator/opengl/tests/gles_android_wrapper/ServerConnection.cpp b/tools/emulator/opengl/tests/gles_android_wrapper/ServerConnection.cpp
index 1204264..ff4e390 100644
--- a/tools/emulator/opengl/tests/gles_android_wrapper/ServerConnection.cpp
+++ b/tools/emulator/opengl/tests/gles_android_wrapper/ServerConnection.cpp
@@ -83,7 +83,7 @@
         QemuPipeStream*  pipeStream = new QemuPipeStream(bufsize);
 
         if (pipeStream->connect() < 0) {
-            LOGE("couldn't connect to host server\n");
+            ALOGE("couldn't connect to host server\n");
             delete pipeStream;
             return -1;
         }
@@ -102,7 +102,7 @@
         }
 
         if (tcpStream->connect(hostname, CODEC_SERVER_PORT) < 0) {
-            LOGE("couldn't connect to %s\n", hostname);
+            ALOGE("couldn't connect to %s\n", hostname);
             free(hostname);
             delete tcpStream;
             return -1;
diff --git a/tools/emulator/opengl/tests/gles_android_wrapper/egl.cpp b/tools/emulator/opengl/tests/gles_android_wrapper/egl.cpp
index 1ee2b6a..1e2e456 100644
--- a/tools/emulator/opengl/tests/gles_android_wrapper/egl.cpp
+++ b/tools/emulator/opengl/tests/gles_android_wrapper/egl.cpp
@@ -58,7 +58,7 @@
 {
     void *driverLib = dlopen(driverLibName, RTLD_NOW | RTLD_LOCAL);
     if (driverLib == NULL) {
-        LOGE("failed to load %s : %s\n", driverLibName, dlerror());
+        ALOGE("failed to load %s : %s\n", driverLibName, dlerror());
         return -1;
     }
 
@@ -66,13 +66,13 @@
     createFcn_t createFcn;
     createFcn = (createFcn_t) dlsym(driverLib, "createFromLib");
     if (createFcn == NULL) {
-        LOGE("failed to load createFromLib constructor function\n");
+        ALOGE("failed to load createFromLib constructor function\n");
         return -1;
     }
 
     void *implLib = dlopen(implLibName, RTLD_NOW | RTLD_LOCAL);
     if (implLib == NULL) {
-        LOGE("couldn't open %s", implLibName);
+        ALOGE("couldn't open %s", implLibName);
         return -2;
     }
     *dispatchTable = createFcn(implLib, accessor);
@@ -85,7 +85,7 @@
 
     // XXX - we do not dlclose the driver library, so its not initialized when
     // later loaded by android - is this required?
-    LOGD("loading %s into %s complete\n", implLibName, driverLibName);
+    ALOGD("loading %s into %s complete\n", implLibName, driverLibName);
     return 0;
 
 }
@@ -112,20 +112,20 @@
             // we need to obtain our process name from the command line;
             FILE *fp = fopen("/proc/self/cmdline", "rt");
             if (fp == NULL) {
-                LOGE("couldn't open /proc/self/cmdline\n");
+                ALOGE("couldn't open /proc/self/cmdline\n");
                 return NULL;
             }
 
             char line[1000];
             if (fgets(line, sizeof(line), fp) == NULL) {
-                LOGE("couldn't read the self cmdline from \n");
+                ALOGE("couldn't read the self cmdline from \n");
                 fclose(fp);
                 return NULL;
             }
             fclose(fp);
 
             if (line[0] == '\0') {
-                LOGE("cmdline is empty\n");
+                ALOGE("cmdline is empty\n");
                 return NULL;
             }
 
@@ -155,11 +155,11 @@
 {
     const char *procname = getProcName();
     if (procname == NULL) return false;
-    LOGD("isNeedEncode? for %s\n", procname);
+    ALOGD("isNeedEncode? for %s\n", procname);
     // check on our whitelist
     FILE *fp = fopen(GLES_EMUL_TARGETS_FILE, "rt");
     if (fp == NULL) {
-        LOGE("couldn't open %s\n", GLES_EMUL_TARGETS_FILE);
+        ALOGE("couldn't open %s\n", GLES_EMUL_TARGETS_FILE);
         return false;
     }
 
@@ -173,7 +173,7 @@
             char c = line[procnameLen];
             if (c == '\0' || c == ' ' || c == '\t' || c == '\n') {
                 found = true;
-                LOGD("should use encoder for %s\n", procname);
+                ALOGD("should use encoder for %s\n", procname);
                 break;
             }
         }
@@ -187,7 +187,7 @@
     //
     // Load our back-end implementation of EGL/GLES
     //
-    LOGD("Loading egl dispatch for %s\n", getProcName());
+    ALOGD("Loading egl dispatch for %s\n", getProcName());
 
     void *gles_android = dlopen("/system/lib/egl/libGLES_android.so", RTLD_NOW | RTLD_LOCAL);
     if (!gles_android) {
@@ -213,7 +213,7 @@
         // initialize a connection to the server, and the GLESv1/v2 encoders;
         ServerConnection * connection = ServerConnection::s_getServerConnection();
         if (connection == NULL) {
-            LOGE("couldn't create server connection\n");
+            ALOGE("couldn't create server connection\n");
             s_needEncode = false;
         }
     }
@@ -231,7 +231,7 @@
     }
 
     if (!s_needEncode) {
-        LOGD("Initializing native opengl for %s\n", getProcName());
+        ALOGD("Initializing native opengl for %s\n", getProcName());
         initApi<gl_wrapper_context_t>(GLESv1_DRIVER, GLES_android_LIB, &g_gl_dispatch, getGLContext);
         // try to initialize gl2 from GLES, though its probably going to fail
         initApi<gl2_wrapper_context_t>(GLESv2_DRIVER, GLES_android_LIB, &g_gl2_dispatch, getGL2Context);
@@ -313,7 +313,7 @@
             if (attribs[i + 1] & EGL_OPENGL_ES2_BIT) {
                 attribs[i + 1] &= ~EGL_OPENGL_ES2_BIT;
                 attribs[i + 1] |= EGL_OPENGL_ES_BIT;
-                LOGD("removing ES2 bit 0x%x\n", attribs[i + 1]);
+                ALOGD("removing ES2 bit 0x%x\n", attribs[i + 1]);
                 if (isES2 != NULL) *isES2 = true;
             }
         }
@@ -331,11 +331,11 @@
                                               configs,
                                               config_size,
                                               num_config);
-        LOGD("eglChooseConfig: %d configs found\n", *num_config);
+        ALOGD("eglChooseConfig: %d configs found\n", *num_config);
         if (*num_config == 0 && attribs != NULL) {
-            LOGD("requested attributes:\n");
+            ALOGD("requested attributes:\n");
             for (int i = 0; attribs[i] != EGL_NONE; i++) {
-                LOGD("%d: 0x%x\n", i, attribs[i]);
+                ALOGD("%d: 0x%x\n", i, attribs[i]);
             }
         }
 
diff --git a/tools/emulator/opengl/tests/gles_android_wrapper/gles.cpp b/tools/emulator/opengl/tests/gles_android_wrapper/gles.cpp
index f0a22aa..c0949c8 100644
--- a/tools/emulator/opengl/tests/gles_android_wrapper/gles.cpp
+++ b/tools/emulator/opengl/tests/gles_android_wrapper/gles.cpp
@@ -27,7 +27,7 @@
 {
     s_dispatch = create_gles_dispatch(gles_android);
     if (s_dispatch == NULL) {
-        LOGE("failed to create gles dispatch\n");
+        ALOGE("failed to create gles dispatch\n");
     }
 }
 
diff --git a/tools/emulator/opengl/tests/gles_android_wrapper/glesv1_emul_ifc.cpp b/tools/emulator/opengl/tests/gles_android_wrapper/glesv1_emul_ifc.cpp
index 41e7b7a..26c98a8 100644
--- a/tools/emulator/opengl/tests/gles_android_wrapper/glesv1_emul_ifc.cpp
+++ b/tools/emulator/opengl/tests/gles_android_wrapper/glesv1_emul_ifc.cpp
@@ -1,3 +1,19 @@
+/*
+* Copyright 2011 The Android Open Source Project
+*
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+
 #include <stdlib.h>
 #include "ApiInitializer.h"
 #include <dlfcn.h>
diff --git a/tools/emulator/opengl/tests/gles_android_wrapper/glesv2_emul_ifc.cpp b/tools/emulator/opengl/tests/gles_android_wrapper/glesv2_emul_ifc.cpp
index cf0dfed..4ae13dd 100644
--- a/tools/emulator/opengl/tests/gles_android_wrapper/glesv2_emul_ifc.cpp
+++ b/tools/emulator/opengl/tests/gles_android_wrapper/glesv2_emul_ifc.cpp
@@ -1,3 +1,19 @@
+/*
+* Copyright 2011 The Android Open Source Project
+*
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+
 #include <stdlib.h>
 #include "ApiInitializer.h"
 #include <dlfcn.h>
diff --git a/tools/emulator/opengl/tests/translator_tests/GLES_CM/triangleCM.cpp b/tools/emulator/opengl/tests/translator_tests/GLES_CM/triangleCM.cpp
index 7d681ad..7547cd0 100644
--- a/tools/emulator/opengl/tests/translator_tests/GLES_CM/triangleCM.cpp
+++ b/tools/emulator/opengl/tests/translator_tests/GLES_CM/triangleCM.cpp
@@ -1,3 +1,19 @@
+/*
+* Copyright 2011 The Android Open Source Project
+*
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+
 #include <stdio.h>
 #include <string.h>
 #include <stdlib.h>
diff --git a/tools/emulator/opengl/tests/translator_tests/GLES_V2/triangleV2.cpp b/tools/emulator/opengl/tests/translator_tests/GLES_V2/triangleV2.cpp
index d231b36..59535c5 100644
--- a/tools/emulator/opengl/tests/translator_tests/GLES_V2/triangleV2.cpp
+++ b/tools/emulator/opengl/tests/translator_tests/GLES_V2/triangleV2.cpp
@@ -1,3 +1,19 @@
+/*
+* Copyright 2011 The Android Open Source Project
+*
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+
 #include <stdio.h>
 #include <string.h>
 #include <stdlib.h>
diff --git a/tools/emulator/opengl/tests/translator_tests/MacCommon/setup_gl.m b/tools/emulator/opengl/tests/translator_tests/MacCommon/setup_gl.m
index 43b72ba..a300943 100644
--- a/tools/emulator/opengl/tests/translator_tests/MacCommon/setup_gl.m
+++ b/tools/emulator/opengl/tests/translator_tests/MacCommon/setup_gl.m
@@ -1,3 +1,19 @@
+/*
+* Copyright 2011 The Android Open Source Project
+*
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+
 #include <stdio.h>
 #include <Cocoa/Cocoa.h>
 
diff --git a/tools/emulator/system/camera/Android.mk b/tools/emulator/system/camera/Android.mk
index 2e5c19c..61e1e83 100755
--- a/tools/emulator/system/camera/Android.mk
+++ b/tools/emulator/system/camera/Android.mk
@@ -36,11 +36,13 @@
 
 LOCAL_C_INCLUDES += external/jpeg \
 					external/skia/include/core/ \
+					frameworks/native/include/media/hardware \
 					frameworks/base/core/jni/android/graphics
 
 LOCAL_SRC_FILES := \
 	EmulatedCameraHal.cpp \
     EmulatedCameraFactory.cpp \
+    EmulatedBaseCamera.cpp \
     EmulatedCamera.cpp \
 	EmulatedCameraDevice.cpp \
 	EmulatedQemuCamera.cpp \
diff --git a/tools/emulator/system/camera/CallbackNotifier.cpp b/tools/emulator/system/camera/CallbackNotifier.cpp
index f974b86..140c872 100755
--- a/tools/emulator/system/camera/CallbackNotifier.cpp
+++ b/tools/emulator/system/camera/CallbackNotifier.cpp
@@ -22,7 +22,7 @@
 #define LOG_NDEBUG 0
 #define LOG_TAG "EmulatedCamera_CallbackNotifier"
 #include <cutils/log.h>
-#include <media/stagefright/MetadataBufferType.h>
+#include <MetadataBufferType.h>
 #include "EmulatedCameraDevice.h"
 #include "CallbackNotifier.h"
 #include "JpegCompressor.h"
@@ -80,7 +80,7 @@
     const char* strs[lCameraMessagesNum];
     const int translated = GetMessageStrings(msg, strs, lCameraMessagesNum);
     for (int n = 0; n < translated; n++) {
-        LOGV("    %s", strs[n]);
+        ALOGV("    %s", strs[n]);
     }
 }
 
@@ -113,7 +113,7 @@
                                     camera_request_memory get_memory,
                                     void* user)
 {
-    LOGV("%s: %p, %p, %p, %p (%p)",
+    ALOGV("%s: %p, %p, %p, %p (%p)",
          __FUNCTION__, notify_cb, data_cb, data_cb_timestamp, get_memory, user);
 
     Mutex::Autolock locker(&mObjectLock);
@@ -126,29 +126,29 @@
 
 void CallbackNotifier::enableMessage(uint msg_type)
 {
-    LOGV("%s: msg_type = 0x%x", __FUNCTION__, msg_type);
+    ALOGV("%s: msg_type = 0x%x", __FUNCTION__, msg_type);
     PrintMessages(msg_type);
 
     Mutex::Autolock locker(&mObjectLock);
     mMessageEnabler |= msg_type;
-    LOGV("**** Currently enabled messages:");
+    ALOGV("**** Currently enabled messages:");
     PrintMessages(mMessageEnabler);
 }
 
 void CallbackNotifier::disableMessage(uint msg_type)
 {
-    LOGV("%s: msg_type = 0x%x", __FUNCTION__, msg_type);
+    ALOGV("%s: msg_type = 0x%x", __FUNCTION__, msg_type);
     PrintMessages(msg_type);
 
     Mutex::Autolock locker(&mObjectLock);
     mMessageEnabler &= ~msg_type;
-    LOGV("**** Currently enabled messages:");
+    ALOGV("**** Currently enabled messages:");
     PrintMessages(mMessageEnabler);
 }
 
 status_t CallbackNotifier::enableVideoRecording(int fps)
 {
-    LOGV("%s: FPS = %d", __FUNCTION__, fps);
+    ALOGV("%s: FPS = %d", __FUNCTION__, fps);
 
     Mutex::Autolock locker(&mObjectLock);
     mVideoRecEnabled = true;
@@ -160,7 +160,7 @@
 
 void CallbackNotifier::disableVideoRecording()
 {
-    LOGV("%s:", __FUNCTION__);
+    ALOGV("%s:", __FUNCTION__);
 
     Mutex::Autolock locker(&mObjectLock);
     mVideoRecEnabled = false;
@@ -215,7 +215,7 @@
             mDataCBTimestamp(timestamp, CAMERA_MSG_VIDEO_FRAME,
                                cam_buff, 0, mCBOpaque);
         } else {
-            LOGE("%s: Memory failure in CAMERA_MSG_VIDEO_FRAME", __FUNCTION__);
+            ALOGE("%s: Memory failure in CAMERA_MSG_VIDEO_FRAME", __FUNCTION__);
         }
     }
 
@@ -227,7 +227,7 @@
             mDataCB(CAMERA_MSG_PREVIEW_FRAME, cam_buff, 0, NULL, mCBOpaque);
             cam_buff->release(cam_buff);
         } else {
-            LOGE("%s: Memory failure in CAMERA_MSG_PREVIEW_FRAME", __FUNCTION__);
+            ALOGE("%s: Memory failure in CAMERA_MSG_PREVIEW_FRAME", __FUNCTION__);
         }
     }
 
@@ -261,10 +261,10 @@
                     mDataCB(CAMERA_MSG_COMPRESSED_IMAGE, jpeg_buff, 0, NULL, mCBOpaque);
                     jpeg_buff->release(jpeg_buff);
                 } else {
-                    LOGE("%s: Memory failure in CAMERA_MSG_VIDEO_FRAME", __FUNCTION__);
+                    ALOGE("%s: Memory failure in CAMERA_MSG_VIDEO_FRAME", __FUNCTION__);
                 }
             } else {
-                LOGE("%s: Compression failure in CAMERA_MSG_VIDEO_FRAME", __FUNCTION__);
+                ALOGE("%s: Compression failure in CAMERA_MSG_VIDEO_FRAME", __FUNCTION__);
             }
         }
     }
diff --git a/tools/emulator/system/camera/EmulatedBaseCamera.cpp b/tools/emulator/system/camera/EmulatedBaseCamera.cpp
new file mode 100644
index 0000000..19d398e
--- /dev/null
+++ b/tools/emulator/system/camera/EmulatedBaseCamera.cpp
@@ -0,0 +1,73 @@
+/*
+ * Copyright (C) 2012 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.
+ */
+
+/*
+ * Contains implementation of a class EmulatedBaseCamera that encapsulates
+ * functionality common to all emulated camera device versions ("fake",
+ * "webcam", "video file", "cam2.0" etc.).  Instances of this class (for each
+ * emulated camera) are created during the construction of the
+ * EmulatedCameraFactory instance.  This class serves as an entry point for all
+ * camera API calls that are common across all versions of the
+ * camera_device_t/camera_module_t structures.
+ */
+
+#define LOG_NDEBUG 0
+#define LOG_TAG "EmulatedCamera_BaseCamera"
+#include <cutils/log.h>
+
+#include "EmulatedBaseCamera.h"
+
+namespace android {
+
+EmulatedBaseCamera::EmulatedBaseCamera(int cameraId,
+        uint32_t cameraVersion,
+        struct hw_device_t* device,
+        struct hw_module_t* module)
+        : mCameraInfo(NULL),
+          mCameraID(cameraId),
+          mCameraDeviceVersion(cameraVersion)
+{
+    /*
+     * Initialize camera_device descriptor for this object.
+     */
+
+    /* Common header */
+    device->tag = HARDWARE_DEVICE_TAG;
+    device->version = cameraVersion;
+    device->module = module;
+    device->close = NULL; // Must be filled in by child implementation
+}
+
+EmulatedBaseCamera::~EmulatedBaseCamera()
+{
+}
+
+status_t EmulatedBaseCamera::getCameraInfo(struct camera_info* info)
+{
+    ALOGV("%s", __FUNCTION__);
+
+    info->device_version = mCameraDeviceVersion;
+    if (mCameraDeviceVersion >= HARDWARE_DEVICE_API_VERSION(2, 0)) {
+        info->static_camera_characteristics = mCameraInfo;
+    } else {
+        info->static_camera_characteristics = (camera_metadata_t*)0xcafef00d;
+    }
+
+    return NO_ERROR;
+}
+
+
+} /* namespace android */
diff --git a/tools/emulator/system/camera/EmulatedBaseCamera.h b/tools/emulator/system/camera/EmulatedBaseCamera.h
new file mode 100644
index 0000000..5888ca0
--- /dev/null
+++ b/tools/emulator/system/camera/EmulatedBaseCamera.h
@@ -0,0 +1,101 @@
+/*
+ * Copyright (C) 2012 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.
+ */
+
+#ifndef HW_EMULATOR_CAMERA_EMULATED_BASE_CAMERA_H
+#define HW_EMULATOR_CAMERA_EMULATED_BASE_CAMERA_H
+
+#include <hardware/camera_common.h>
+#include <utils/Errors.h>
+
+namespace android {
+
+/*
+ * Contains declaration of a class EmulatedBaseCamera that encapsulates
+ * functionality common to all emulated camera device versions ("fake",
+ * "webcam", "video file", etc.).  Instances of this class (for each emulated
+ * camera) are created during the construction of the EmulatedCameraFactory
+ * instance.  This class serves as an entry point for all camera API calls that
+ * are common across all versions of the camera_device_t/camera_module_t
+ * structures.
+ */
+
+class EmulatedBaseCamera {
+  public:
+    EmulatedBaseCamera(int cameraId,
+            uint32_t cameraVersion,
+            struct hw_device_t* device,
+            struct hw_module_t* module);
+
+    virtual ~EmulatedBaseCamera();
+
+    /****************************************************************************
+     * Public API
+     ***************************************************************************/
+
+  public:
+    /* Initializes EmulatedCamera instance.
+     * Return:
+     *  NO_ERROR on success, or an appropriate error status on failure.
+     */
+    virtual status_t Initialize() = 0;
+
+    /****************************************************************************
+     * Camera API implementation
+     ***************************************************************************/
+
+  public:
+    /* Creates connection to the emulated camera device.
+     * This method is called in response to hw_module_methods_t::open callback.
+     * NOTE: When this method is called the object is locked.
+     * Note that failures in this method are reported as negative EXXX statuses.
+     */
+    virtual status_t connectCamera(hw_device_t** device) = 0;
+
+    /* Closes connection to the emulated camera.
+     * This method is called in response to camera_device::close callback.
+     * NOTE: When this method is called the object is locked.
+     * Note that failures in this method are reported as negative EXXX statuses.
+     */
+    virtual status_t closeCamera() = 0;
+
+    /* Gets camera information.
+     * This method is called in response to camera_module_t::get_camera_info
+     * callback.
+     * NOTE: When this method is called the object is locked.
+     * Note that failures in this method are reported as negative EXXX statuses.
+     */
+    virtual status_t getCameraInfo(struct camera_info* info) = 0;
+
+    /****************************************************************************
+     * Data members
+     ***************************************************************************/
+
+  protected:
+    /* Fixed camera information for camera2 devices. Must be valid to access if
+     * mCameraDeviceVersion is >= HARDWARE_DEVICE_API_VERSION(2,0)  */
+    camera_metadata_t *mCameraInfo;
+
+  private:
+    /* Zero-based ID assigned to this camera. */
+    int mCameraID;
+
+    /* Version of the camera device HAL implemented by this camera */
+    int mCameraDeviceVersion;
+};
+
+} /* namespace android */
+
+#endif /* HW_EMULATOR_CAMERA_EMULATED_BASE_CAMERA_H */
diff --git a/tools/emulator/system/camera/EmulatedCamera.cpp b/tools/emulator/system/camera/EmulatedCamera.cpp
index 02b4683..28aede1 100755
--- a/tools/emulator/system/camera/EmulatedCamera.cpp
+++ b/tools/emulator/system/camera/EmulatedCamera.cpp
@@ -28,7 +28,7 @@
 #include <cutils/log.h>
 #include <ui/Rect.h>
 #include "EmulatedCamera.h"
-#include "EmulatedFakeCameraDevice.h"
+//#include "EmulatedFakeCameraDevice.h"
 #include "Converters.h"
 
 /* Defines whether we should trace parameter changes. */
@@ -58,22 +58,17 @@
  */
 static char* AddValue(const char* param, const char* val);
 
-EmulatedCamera::EmulatedCamera(int cameraId, struct hw_module_t* module)
-        : mPreviewWindow(),
-          mCallbackNotifier(),
-          mCameraID(cameraId)
+EmulatedCamera::EmulatedCamera(int cameraId,
+                               struct hw_module_t* module)
+        : EmulatedBaseCamera(cameraId,
+                HARDWARE_DEVICE_API_VERSION(1, 0),
+                &common,
+                module),
+          mPreviewWindow(),
+          mCallbackNotifier()
 {
-    /*
-     * Initialize camera_device descriptor for this object.
-     */
-
-    /* Common header */
-    common.tag = HARDWARE_DEVICE_TAG;
-    common.version = 0;
-    common.module = module;
+    /* camera_device v1 fields. */
     common.close = EmulatedCamera::close;
-
-    /* camera_device fields. */
     ops = &mDeviceOps;
     priv = this;
 }
@@ -99,12 +94,8 @@
      * Fake required parameters.
      */
 
-    mParameters.set(CameraParameters::KEY_SUPPORTED_JPEG_THUMBNAIL_SIZES,
-                    "320x240,0x0");
-    mParameters.set(CameraParameters::KEY_MAX_EXPOSURE_COMPENSATION, "6");
-    mParameters.set(CameraParameters::KEY_MIN_EXPOSURE_COMPENSATION, "-6");
-    mParameters.set(CameraParameters::KEY_EXPOSURE_COMPENSATION_STEP, "0.5");
-    mParameters.set(CameraParameters::KEY_EXPOSURE_COMPENSATION, "0");
+    mParameters.set(CameraParameters::KEY_SUPPORTED_JPEG_THUMBNAIL_SIZES, "320x240,0x0");
+
     mParameters.set(CameraParameters::KEY_JPEG_THUMBNAIL_WIDTH, "512");
     mParameters.set(CameraParameters::KEY_JPEG_THUMBNAIL_HEIGHT, "384");
     mParameters.set(CameraParameters::KEY_JPEG_QUALITY, "90");
@@ -137,10 +128,36 @@
                     CameraParameters::PIXEL_FORMAT_JPEG);
     mParameters.setPictureFormat(CameraParameters::PIXEL_FORMAT_JPEG);
 
-    /*
-     * Not supported features
-     */
+    /* Set exposure compensation. */
+    mParameters.set(CameraParameters::KEY_MAX_EXPOSURE_COMPENSATION, "6");
+    mParameters.set(CameraParameters::KEY_MIN_EXPOSURE_COMPENSATION, "-6");
+    mParameters.set(CameraParameters::KEY_EXPOSURE_COMPENSATION_STEP, "0.5");
+    mParameters.set(CameraParameters::KEY_EXPOSURE_COMPENSATION, "0");
 
+    /* Sets the white balance modes and the device-dependent scale factors. */
+    char supported_white_balance[1024];
+    snprintf(supported_white_balance, sizeof(supported_white_balance),
+             "%s,%s,%s,%s",
+             CameraParameters::WHITE_BALANCE_AUTO,
+             CameraParameters::WHITE_BALANCE_INCANDESCENT,
+             CameraParameters::WHITE_BALANCE_DAYLIGHT,
+             CameraParameters::WHITE_BALANCE_TWILIGHT);
+    mParameters.set(CameraParameters::KEY_SUPPORTED_WHITE_BALANCE,
+                    supported_white_balance);
+    mParameters.set(CameraParameters::KEY_WHITE_BALANCE,
+                    CameraParameters::WHITE_BALANCE_AUTO);
+    getCameraDevice()->initializeWhiteBalanceModes(
+            CameraParameters::WHITE_BALANCE_AUTO, 1.0f, 1.0f);
+    getCameraDevice()->initializeWhiteBalanceModes(
+            CameraParameters::WHITE_BALANCE_INCANDESCENT, 1.38f, 0.60f);
+    getCameraDevice()->initializeWhiteBalanceModes(
+            CameraParameters::WHITE_BALANCE_DAYLIGHT, 1.09f, 0.92f);
+    getCameraDevice()->initializeWhiteBalanceModes(
+            CameraParameters::WHITE_BALANCE_TWILIGHT, 0.92f, 1.22f);
+    getCameraDevice()->setWhiteBalanceMode(CameraParameters::WHITE_BALANCE_AUTO);
+
+    /* Not supported features
+     */
     mParameters.set(CameraParameters::KEY_SUPPORTED_FOCUS_MODES,
                     CameraParameters::FOCUS_MODE_FIXED);
     mParameters.set(CameraParameters::KEY_FOCUS_MODE,
@@ -172,11 +189,11 @@
 
 status_t EmulatedCamera::connectCamera(hw_device_t** device)
 {
-    LOGV("%s", __FUNCTION__);
+    ALOGV("%s", __FUNCTION__);
 
     status_t res = EINVAL;
     EmulatedCameraDevice* const camera_dev = getCameraDevice();
-    LOGE_IF(camera_dev == NULL, "%s: No camera device instance.", __FUNCTION__);
+    ALOGE_IF(camera_dev == NULL, "%s: No camera device instance.", __FUNCTION__);
 
     if (camera_dev != NULL) {
         /* Connect to the camera device. */
@@ -191,14 +208,14 @@
 
 status_t EmulatedCamera::closeCamera()
 {
-    LOGV("%s", __FUNCTION__);
+    ALOGV("%s", __FUNCTION__);
 
     return cleanupCamera();
 }
 
 status_t EmulatedCamera::getCameraInfo(struct camera_info* info)
 {
-    LOGV("%s", __FUNCTION__);
+    ALOGV("%s", __FUNCTION__);
 
     const char* valstr = NULL;
 
@@ -221,7 +238,7 @@
         info->orientation = 0;
     }
 
-    return NO_ERROR;
+    return EmulatedBaseCamera::getCameraInfo(info);
 }
 
 status_t EmulatedCamera::setPreviewWindow(struct preview_stream_ops* window)
@@ -301,7 +318,7 @@
 
 status_t EmulatedCamera::setAutoFocus()
 {
-    LOGV("%s", __FUNCTION__);
+    ALOGV("%s", __FUNCTION__);
 
     /* TODO: Future enhancements. */
     return NO_ERROR;
@@ -309,7 +326,7 @@
 
 status_t EmulatedCamera::cancelAutoFocus()
 {
-    LOGV("%s", __FUNCTION__);
+    ALOGV("%s", __FUNCTION__);
 
     /* TODO: Future enhancements. */
     return NO_ERROR;
@@ -317,7 +334,7 @@
 
 status_t EmulatedCamera::takePicture()
 {
-    LOGV("%s", __FUNCTION__);
+    ALOGV("%s", __FUNCTION__);
 
     status_t res;
     int width, height;
@@ -336,7 +353,7 @@
         /* We only have JPEG converted for NV21 format. */
         org_fmt = V4L2_PIX_FMT_NV21;
     } else {
-        LOGE("%s: Unsupported pixel format %s", __FUNCTION__, pix_fmt);
+        ALOGE("%s: Unsupported pixel format %s", __FUNCTION__, pix_fmt);
         return EINVAL;
     }
     /* Get JPEG quality. */
@@ -359,7 +376,7 @@
      * enabled. */
     EmulatedCameraDevice* const camera_dev = getCameraDevice();
     if (camera_dev->isStarted()) {
-        LOGW("%s: Camera device is started", __FUNCTION__);
+        ALOGW("%s: Camera device is started", __FUNCTION__);
         camera_dev->stopDeliveringFrames();
         camera_dev->stopDevice();
     }
@@ -369,7 +386,7 @@
      */
 
     /* Start camera device for the picture frame. */
-    LOGD("Starting camera for picture: %.4s(%s)[%dx%d]",
+    ALOGD("Starting camera for picture: %.4s(%s)[%dx%d]",
          reinterpret_cast<const char*>(&org_fmt), pix_fmt, width, height);
     res = camera_dev->startDevice(width, height, org_fmt);
     if (res != NO_ERROR) {
@@ -394,20 +411,23 @@
 
 status_t EmulatedCamera::cancelPicture()
 {
-    LOGV("%s", __FUNCTION__);
+    ALOGV("%s", __FUNCTION__);
 
     return NO_ERROR;
 }
 
 status_t EmulatedCamera::setParameters(const char* parms)
 {
-    LOGV("%s", __FUNCTION__);
+    ALOGV("%s", __FUNCTION__);
     PrintParamDiff(mParameters, parms);
 
     CameraParameters new_param;
     String8 str8_param(parms);
     new_param.unflatten(str8_param);
 
+    /*
+     * Check for new exposure compensation parameter.
+     */
     int new_exposure_compensation = new_param.getInt(
             CameraParameters::KEY_EXPOSURE_COMPENSATION);
     const int min_exposure_compensation = new_param.getInt(
@@ -435,6 +455,24 @@
                     exposure_value);
         }
     }
+
+    const char* new_white_balance = new_param.get(
+            CameraParameters::KEY_WHITE_BALANCE);
+    const char* supported_white_balance = new_param.get(
+            CameraParameters::KEY_SUPPORTED_WHITE_BALANCE);
+
+    if ((supported_white_balance != NULL) && (new_white_balance != NULL) &&
+        (strstr(supported_white_balance, new_white_balance) != NULL)) {
+
+        const char* current_white_balance = mParameters.get(
+                CameraParameters::KEY_WHITE_BALANCE);
+        if ((current_white_balance == NULL) ||
+            (strcmp(current_white_balance, new_white_balance) != 0)) {
+            ALOGV("Setting white balance to %s", new_white_balance);
+            getCameraDevice()->setWhiteBalanceMode(new_white_balance);
+        }
+    }
+
     mParameters = new_param;
 
     return NO_ERROR;
@@ -453,7 +491,7 @@
         strncpy(ret_str, params.string(), params.length()+1);
         return ret_str;
     } else {
-        LOGE("%s: Unable to allocate string for %s", __FUNCTION__, params.string());
+        ALOGE("%s: Unable to allocate string for %s", __FUNCTION__, params.string());
         /* Apparently, we can't return NULL fron this routine. */
         return &lNoParam;
     }
@@ -469,7 +507,7 @@
 
 status_t EmulatedCamera::sendCommand(int32_t cmd, int32_t arg1, int32_t arg2)
 {
-    LOGV("%s: cmd = %d, arg1 = %d, arg2 = %d", __FUNCTION__, cmd, arg1, arg2);
+    ALOGV("%s: cmd = %d, arg1 = %d, arg2 = %d", __FUNCTION__, cmd, arg1, arg2);
 
     /* TODO: Future enhancements. */
     return 0;
@@ -477,14 +515,14 @@
 
 void EmulatedCamera::releaseCamera()
 {
-    LOGV("%s", __FUNCTION__);
+    ALOGV("%s", __FUNCTION__);
 
     cleanupCamera();
 }
 
 status_t EmulatedCamera::dumpCamera(int fd)
 {
-    LOGV("%s", __FUNCTION__);
+    ALOGV("%s", __FUNCTION__);
 
     /* TODO: Future enhancements. */
     return -EINVAL;
@@ -496,7 +534,7 @@
 
 status_t EmulatedCamera::doStartPreview()
 {
-    LOGV("%s", __FUNCTION__);
+    ALOGV("%s", __FUNCTION__);
 
     EmulatedCameraDevice* camera_dev = getCameraDevice();
     if (camera_dev->isStarted()) {
@@ -547,7 +585,7 @@
         pix_fmt = mParameters.getPreviewFormat();
     }
     if (pix_fmt == NULL) {
-        LOGE("%s: Unable to obtain video format", __FUNCTION__);
+        ALOGE("%s: Unable to obtain video format", __FUNCTION__);
         mPreviewWindow.stopPreview();
         return EINVAL;
     }
@@ -561,11 +599,11 @@
     } else if (strcmp(pix_fmt, CameraParameters::PIXEL_FORMAT_YUV420SP) == 0) {
         org_fmt = V4L2_PIX_FMT_NV21;
     } else {
-        LOGE("%s: Unsupported pixel format %s", __FUNCTION__, pix_fmt);
+        ALOGE("%s: Unsupported pixel format %s", __FUNCTION__, pix_fmt);
         mPreviewWindow.stopPreview();
         return EINVAL;
     }
-    LOGD("Starting camera: %dx%d -> %.4s(%s)",
+    ALOGD("Starting camera: %dx%d -> %.4s(%s)",
          width, height, reinterpret_cast<const char*>(&org_fmt), pix_fmt);
     res = camera_dev->startDevice(width, height, org_fmt);
     if (res != NO_ERROR) {
@@ -584,7 +622,7 @@
 
 status_t EmulatedCamera::doStopPreview()
 {
-    LOGV("%s", __FUNCTION__);
+    ALOGV("%s", __FUNCTION__);
 
     status_t res = NO_ERROR;
     if (mPreviewWindow.isPreviewEnabled()) {
@@ -652,7 +690,7 @@
 {
     EmulatedCamera* ec = reinterpret_cast<EmulatedCamera*>(dev->priv);
     if (ec == NULL) {
-        LOGE("%s: Unexpected NULL camera device", __FUNCTION__);
+        ALOGE("%s: Unexpected NULL camera device", __FUNCTION__);
         return -EINVAL;
     }
     return ec->setPreviewWindow(window);
@@ -668,7 +706,7 @@
 {
     EmulatedCamera* ec = reinterpret_cast<EmulatedCamera*>(dev->priv);
     if (ec == NULL) {
-        LOGE("%s: Unexpected NULL camera device", __FUNCTION__);
+        ALOGE("%s: Unexpected NULL camera device", __FUNCTION__);
         return;
     }
     ec->setCallbacks(notify_cb, data_cb, data_cb_timestamp, get_memory, user);
@@ -678,7 +716,7 @@
 {
     EmulatedCamera* ec = reinterpret_cast<EmulatedCamera*>(dev->priv);
     if (ec == NULL) {
-        LOGE("%s: Unexpected NULL camera device", __FUNCTION__);
+        ALOGE("%s: Unexpected NULL camera device", __FUNCTION__);
         return;
     }
     ec->enableMsgType(msg_type);
@@ -688,7 +726,7 @@
 {
     EmulatedCamera* ec = reinterpret_cast<EmulatedCamera*>(dev->priv);
     if (ec == NULL) {
-        LOGE("%s: Unexpected NULL camera device", __FUNCTION__);
+        ALOGE("%s: Unexpected NULL camera device", __FUNCTION__);
         return;
     }
     ec->disableMsgType(msg_type);
@@ -698,7 +736,7 @@
 {
     EmulatedCamera* ec = reinterpret_cast<EmulatedCamera*>(dev->priv);
     if (ec == NULL) {
-        LOGE("%s: Unexpected NULL camera device", __FUNCTION__);
+        ALOGE("%s: Unexpected NULL camera device", __FUNCTION__);
         return -EINVAL;
     }
     return ec->isMsgTypeEnabled(msg_type);
@@ -708,7 +746,7 @@
 {
     EmulatedCamera* ec = reinterpret_cast<EmulatedCamera*>(dev->priv);
     if (ec == NULL) {
-        LOGE("%s: Unexpected NULL camera device", __FUNCTION__);
+        ALOGE("%s: Unexpected NULL camera device", __FUNCTION__);
         return -EINVAL;
     }
     return ec->startPreview();
@@ -718,7 +756,7 @@
 {
     EmulatedCamera* ec = reinterpret_cast<EmulatedCamera*>(dev->priv);
     if (ec == NULL) {
-        LOGE("%s: Unexpected NULL camera device", __FUNCTION__);
+        ALOGE("%s: Unexpected NULL camera device", __FUNCTION__);
         return;
     }
     ec->stopPreview();
@@ -728,7 +766,7 @@
 {
     EmulatedCamera* ec = reinterpret_cast<EmulatedCamera*>(dev->priv);
     if (ec == NULL) {
-        LOGE("%s: Unexpected NULL camera device", __FUNCTION__);
+        ALOGE("%s: Unexpected NULL camera device", __FUNCTION__);
         return -EINVAL;
     }
     return ec->isPreviewEnabled();
@@ -739,7 +777,7 @@
 {
     EmulatedCamera* ec = reinterpret_cast<EmulatedCamera*>(dev->priv);
     if (ec == NULL) {
-        LOGE("%s: Unexpected NULL camera device", __FUNCTION__);
+        ALOGE("%s: Unexpected NULL camera device", __FUNCTION__);
         return -EINVAL;
     }
     return ec->storeMetaDataInBuffers(enable);
@@ -749,7 +787,7 @@
 {
     EmulatedCamera* ec = reinterpret_cast<EmulatedCamera*>(dev->priv);
     if (ec == NULL) {
-        LOGE("%s: Unexpected NULL camera device", __FUNCTION__);
+        ALOGE("%s: Unexpected NULL camera device", __FUNCTION__);
         return -EINVAL;
     }
     return ec->startRecording();
@@ -759,7 +797,7 @@
 {
     EmulatedCamera* ec = reinterpret_cast<EmulatedCamera*>(dev->priv);
     if (ec == NULL) {
-        LOGE("%s: Unexpected NULL camera device", __FUNCTION__);
+        ALOGE("%s: Unexpected NULL camera device", __FUNCTION__);
         return;
     }
     ec->stopRecording();
@@ -769,7 +807,7 @@
 {
     EmulatedCamera* ec = reinterpret_cast<EmulatedCamera*>(dev->priv);
     if (ec == NULL) {
-        LOGE("%s: Unexpected NULL camera device", __FUNCTION__);
+        ALOGE("%s: Unexpected NULL camera device", __FUNCTION__);
         return -EINVAL;
     }
     return ec->isRecordingEnabled();
@@ -780,7 +818,7 @@
 {
     EmulatedCamera* ec = reinterpret_cast<EmulatedCamera*>(dev->priv);
     if (ec == NULL) {
-        LOGE("%s: Unexpected NULL camera device", __FUNCTION__);
+        ALOGE("%s: Unexpected NULL camera device", __FUNCTION__);
         return;
     }
     ec->releaseRecordingFrame(opaque);
@@ -790,7 +828,7 @@
 {
     EmulatedCamera* ec = reinterpret_cast<EmulatedCamera*>(dev->priv);
     if (ec == NULL) {
-        LOGE("%s: Unexpected NULL camera device", __FUNCTION__);
+        ALOGE("%s: Unexpected NULL camera device", __FUNCTION__);
         return -EINVAL;
     }
     return ec->setAutoFocus();
@@ -800,7 +838,7 @@
 {
     EmulatedCamera* ec = reinterpret_cast<EmulatedCamera*>(dev->priv);
     if (ec == NULL) {
-        LOGE("%s: Unexpected NULL camera device", __FUNCTION__);
+        ALOGE("%s: Unexpected NULL camera device", __FUNCTION__);
         return -EINVAL;
     }
     return ec->cancelAutoFocus();
@@ -810,7 +848,7 @@
 {
     EmulatedCamera* ec = reinterpret_cast<EmulatedCamera*>(dev->priv);
     if (ec == NULL) {
-        LOGE("%s: Unexpected NULL camera device", __FUNCTION__);
+        ALOGE("%s: Unexpected NULL camera device", __FUNCTION__);
         return -EINVAL;
     }
     return ec->takePicture();
@@ -820,7 +858,7 @@
 {
     EmulatedCamera* ec = reinterpret_cast<EmulatedCamera*>(dev->priv);
     if (ec == NULL) {
-        LOGE("%s: Unexpected NULL camera device", __FUNCTION__);
+        ALOGE("%s: Unexpected NULL camera device", __FUNCTION__);
         return -EINVAL;
     }
     return ec->cancelPicture();
@@ -830,7 +868,7 @@
 {
     EmulatedCamera* ec = reinterpret_cast<EmulatedCamera*>(dev->priv);
     if (ec == NULL) {
-        LOGE("%s: Unexpected NULL camera device", __FUNCTION__);
+        ALOGE("%s: Unexpected NULL camera device", __FUNCTION__);
         return -EINVAL;
     }
     return ec->setParameters(parms);
@@ -840,7 +878,7 @@
 {
     EmulatedCamera* ec = reinterpret_cast<EmulatedCamera*>(dev->priv);
     if (ec == NULL) {
-        LOGE("%s: Unexpected NULL camera device", __FUNCTION__);
+        ALOGE("%s: Unexpected NULL camera device", __FUNCTION__);
         return NULL;
     }
     return ec->getParameters();
@@ -850,7 +888,7 @@
 {
     EmulatedCamera* ec = reinterpret_cast<EmulatedCamera*>(dev->priv);
     if (ec == NULL) {
-        LOGE("%s: Unexpected NULL camera device", __FUNCTION__);
+        ALOGE("%s: Unexpected NULL camera device", __FUNCTION__);
         return;
     }
     ec->putParameters(params);
@@ -863,7 +901,7 @@
 {
     EmulatedCamera* ec = reinterpret_cast<EmulatedCamera*>(dev->priv);
     if (ec == NULL) {
-        LOGE("%s: Unexpected NULL camera device", __FUNCTION__);
+        ALOGE("%s: Unexpected NULL camera device", __FUNCTION__);
         return -EINVAL;
     }
     return ec->sendCommand(cmd, arg1, arg2);
@@ -873,7 +911,7 @@
 {
     EmulatedCamera* ec = reinterpret_cast<EmulatedCamera*>(dev->priv);
     if (ec == NULL) {
-        LOGE("%s: Unexpected NULL camera device", __FUNCTION__);
+        ALOGE("%s: Unexpected NULL camera device", __FUNCTION__);
         return;
     }
     ec->releaseCamera();
@@ -883,7 +921,7 @@
 {
     EmulatedCamera* ec = reinterpret_cast<EmulatedCamera*>(dev->priv);
     if (ec == NULL) {
-        LOGE("%s: Unexpected NULL camera device", __FUNCTION__);
+        ALOGE("%s: Unexpected NULL camera device", __FUNCTION__);
         return -EINVAL;
     }
     return ec->dumpCamera(fd);
@@ -894,7 +932,7 @@
     EmulatedCamera* ec =
         reinterpret_cast<EmulatedCamera*>(reinterpret_cast<struct camera_device*>(device)->priv);
     if (ec == NULL) {
-        LOGE("%s: Unexpected NULL camera device", __FUNCTION__);
+        ALOGE("%s: Unexpected NULL camera device", __FUNCTION__);
         return -EINVAL;
     }
     return ec->closeCamera();
@@ -954,7 +992,7 @@
     const size_t len1 = strlen(param);
     const size_t len2 = strlen(val);
     char* ret = reinterpret_cast<char*>(malloc(len1 + len2 + 2));
-    LOGE_IF(ret == NULL, "%s: Memory failure", __FUNCTION__);
+    ALOGE_IF(ret == NULL, "%s: Memory failure", __FUNCTION__);
     if (ret != NULL) {
         memcpy(ret, param, len1);
         ret[len1] = ',';
@@ -986,13 +1024,13 @@
             const char* in_current = current.get(tmp);
             if (in_current != NULL) {
                 if (strcmp(in_current, val)) {
-                    LOGD("=== Value changed: %s: %s -> %s", tmp, in_current, val);
+                    ALOGD("=== Value changed: %s: %s -> %s", tmp, in_current, val);
                 }
             } else {
-                LOGD("+++ New parameter: %s=%s", tmp, val);
+                ALOGD("+++ New parameter: %s=%s", tmp, val);
             }
         } else {
-            LOGW("No value separator in %s", tmp);
+            ALOGW("No value separator in %s", tmp);
         }
         wrk = next + 1;
         next = strchr(wrk, ';');
diff --git a/tools/emulator/system/camera/EmulatedCamera.h b/tools/emulator/system/camera/EmulatedCamera.h
index 0a7584e..9825d5d 100755
--- a/tools/emulator/system/camera/EmulatedCamera.h
+++ b/tools/emulator/system/camera/EmulatedCamera.h
@@ -18,31 +18,32 @@
 #define HW_EMULATOR_CAMERA_EMULATED_CAMERA_H
 
 /*
- * Contains declaration of a class EmulatedCamera that encapsulates functionality
- * common to all emulated cameras ("fake", "webcam", "video file", etc.).
- * Instances of this class (for each emulated camera) are created during the
- * construction of the EmulatedCameraFactory instance.
- * This class serves as an entry point for all camera API calls that defined
- * by camera_device_ops_t API.
+ * Contains declaration of a class EmulatedCamera that encapsulates
+ * functionality common to all version 1.0 emulated camera devices ("fake",
+ * "webcam", "video file", etc.).  Instances of this class (for each emulated
+ * camera) are created during the construction of the EmulatedCameraFactory
+ * instance.  This class serves as an entry point for all camera API calls that
+ * defined by camera_device_ops_t API.
  */
 
 #include <camera/CameraParameters.h>
+#include "EmulatedBaseCamera.h"
 #include "EmulatedCameraDevice.h"
 #include "PreviewWindow.h"
 #include "CallbackNotifier.h"
 
 namespace android {
 
-/* Encapsulates functionality common to all emulated cameras ("fake", "webcam",
- * "file stream", etc.).
+/* Encapsulates functionality common to all version 1.0 emulated camera devices
+ * ("fake", "webcam", "file stream", etc.).
  *
  * Note that EmulatedCameraFactory instantiates object of this class just once,
  * when EmulatedCameraFactory instance gets constructed. Connection to /
- * disconnection from the actual camera device is handled by calls to connectDevice(),
- * and closeCamera() methods of this class that are ivoked in response to
- * hw_module_methods_t::open, and camera_device::close callbacks.
+ * disconnection from the actual camera device is handled by calls to
+ * connectDevice(), and closeCamera() methods of this class that are ivoked in
+ * response to hw_module_methods_t::open, and camera_device::close callbacks.
  */
-class EmulatedCamera : public camera_device {
+class EmulatedCamera : public camera_device, public EmulatedBaseCamera {
 public:
     /* Constructs EmulatedCamera instance.
      * Param:
@@ -50,7 +51,8 @@
      *      instance in camera factory's array.
      *  module - Emulated camera HAL module descriptor.
      */
-    EmulatedCamera(int cameraId, struct hw_module_t* module);
+    EmulatedCamera(int cameraId,
+                   struct hw_module_t* module);
 
     /* Destructs EmulatedCamera instance. */
     virtual ~EmulatedCamera();
@@ -69,10 +71,7 @@
      ***************************************************************************/
 
 public:
-    /* Initializes EmulatedCamera instance.
-     * Return:
-     *  NO_ERROR on success, or an appropriate error status on failure.
-     */
+    /** Override of base class method */
     virtual status_t Initialize();
 
     /* Next frame is available in the camera device.
@@ -105,26 +104,13 @@
      ***************************************************************************/
 
 public:
-    /* Creates connection to the emulated camera device.
-     * This method is called in response to hw_module_methods_t::open callback.
-     * NOTE: When this method is called the object is locked.
-     * Note that failures in this method are reported as negave EXXX statuses.
-     */
+    /** Override of base class method */
     virtual status_t connectCamera(hw_device_t** device);
 
-    /* Closes connection to the emulated camera.
-     * This method is called in response to camera_device::close callback.
-     * NOTE: When this method is called the object is locked.
-     * Note that failures in this method are reported as negave EXXX statuses.
-     */
+    /** Override of base class method */
     virtual status_t closeCamera();
 
-    /* Gets camera information.
-     * This method is called in response to camera_module_t::get_camera_info
-     * callback.
-     * NOTE: When this method is called the object is locked.
-     * Note that failures in this method are reported as negave EXXX statuses.
-     */
+    /** Override of base class method */
     virtual status_t getCameraInfo(struct camera_info* info);
 
     /****************************************************************************
@@ -388,9 +374,6 @@
     /* Callback notifier. */
     CallbackNotifier                mCallbackNotifier;
 
-    /* Zero-based ID assigned to this camera. */
-    int                             mCameraID;
-
 private:
     /* Registered callbacks implementing camera API. */
     static camera_device_ops_t      mDeviceOps;
diff --git a/tools/emulator/system/camera/EmulatedCameraCommon.h b/tools/emulator/system/camera/EmulatedCameraCommon.h
index 907985a..c1d575c 100755
--- a/tools/emulator/system/camera/EmulatedCameraCommon.h
+++ b/tools/emulator/system/camera/EmulatedCameraCommon.h
@@ -34,12 +34,12 @@
     /* Constructor that prints an "entry" trace message. */
     explicit HWERoutineTracker(const char* name)
             : mName(name) {
-        LOGV("Entering %s", mName);
+        ALOGV("Entering %s", mName);
     }
 
     /* Destructor that prints a "leave" trace message. */
     ~HWERoutineTracker() {
-        LOGV("Leaving %s", mName);
+        ALOGV("Leaving %s", mName);
     }
 
 private:
diff --git a/tools/emulator/system/camera/EmulatedCameraDevice.cpp b/tools/emulator/system/camera/EmulatedCameraDevice.cpp
index 71464d2..5c52808 100755
--- a/tools/emulator/system/camera/EmulatedCameraDevice.cpp
+++ b/tools/emulator/system/camera/EmulatedCameraDevice.cpp
@@ -29,25 +29,33 @@
 #include <sys/select.h>
 #include <cmath>
 #include "EmulatedCameraDevice.h"
-#include "Converters.h"
 
 namespace android {
 
+const float GAMMA_CORRECTION = 2.2f;
 EmulatedCameraDevice::EmulatedCameraDevice(EmulatedCamera* camera_hal)
     : mObjectLock(),
       mCurFrameTimestamp(0),
       mCameraHAL(camera_hal),
       mCurrentFrame(NULL),
       mExposureCompensation(1.0f),
+      mWhiteBalanceScale(NULL),
+      mSupportedWhiteBalanceScale(),
       mState(ECDS_CONSTRUCTED)
 {
 }
 
 EmulatedCameraDevice::~EmulatedCameraDevice()
 {
+    ALOGV("EmulatedCameraDevice destructor");
     if (mCurrentFrame != NULL) {
         delete[] mCurrentFrame;
     }
+    for (int i = 0; i < mSupportedWhiteBalanceScale.size(); ++i) {
+        if (mSupportedWhiteBalanceScale.valueAt(i) != NULL) {
+            delete[] mSupportedWhiteBalanceScale.valueAt(i);
+        }
+    }
 }
 
 /****************************************************************************
@@ -57,7 +65,7 @@
 status_t EmulatedCameraDevice::Initialize()
 {
     if (isInitialized()) {
-        LOGW("%s: Emulated camera device is already initialized: mState = %d",
+        ALOGW("%s: Emulated camera device is already initialized: mState = %d",
              __FUNCTION__, mState);
         return NO_ERROR;
     }
@@ -65,7 +73,7 @@
     /* Instantiate worker thread object. */
     mWorkerThread = new WorkerThread(this);
     if (getWorkerThread() == NULL) {
-        LOGE("%s: Unable to instantiate worker thread object", __FUNCTION__);
+        ALOGE("%s: Unable to instantiate worker thread object", __FUNCTION__);
         return ENOMEM;
     }
 
@@ -76,52 +84,85 @@
 
 status_t EmulatedCameraDevice::startDeliveringFrames(bool one_burst)
 {
-    LOGV("%s", __FUNCTION__);
+    ALOGV("%s", __FUNCTION__);
 
     if (!isStarted()) {
-        LOGE("%s: Device is not started", __FUNCTION__);
+        ALOGE("%s: Device is not started", __FUNCTION__);
         return EINVAL;
     }
 
     /* Frames will be delivered from the thread routine. */
     const status_t res = startWorkerThread(one_burst);
-    LOGE_IF(res != NO_ERROR, "%s: startWorkerThread failed", __FUNCTION__);
+    ALOGE_IF(res != NO_ERROR, "%s: startWorkerThread failed", __FUNCTION__);
     return res;
 }
 
 status_t EmulatedCameraDevice::stopDeliveringFrames()
 {
-    LOGV("%s", __FUNCTION__);
+    ALOGV("%s", __FUNCTION__);
 
     if (!isStarted()) {
-        LOGW("%s: Device is not started", __FUNCTION__);
+        ALOGW("%s: Device is not started", __FUNCTION__);
         return NO_ERROR;
     }
 
     const status_t res = stopWorkerThread();
-    LOGE_IF(res != NO_ERROR, "%s: startWorkerThread failed", __FUNCTION__);
+    ALOGE_IF(res != NO_ERROR, "%s: startWorkerThread failed", __FUNCTION__);
     return res;
 }
 
 void EmulatedCameraDevice::setExposureCompensation(const float ev) {
-    LOGV("%s", __FUNCTION__);
+    ALOGV("%s", __FUNCTION__);
 
     if (!isStarted()) {
-        LOGW("%s: Fake camera device is not started.", __FUNCTION__);
+        ALOGW("%s: Fake camera device is not started.", __FUNCTION__);
     }
 
-    mExposureCompensation = std::pow(2.0f, ev);
-    LOGV("New exposure compensation is %f", mExposureCompensation);
+    mExposureCompensation = std::pow(2.0f, ev / GAMMA_CORRECTION);
+    ALOGV("New exposure compensation is %f", mExposureCompensation);
+}
+
+void EmulatedCameraDevice::initializeWhiteBalanceModes(const char* mode,
+                                                       const float r_scale,
+                                                       const float b_scale) {
+    ALOGV("%s with %s, %f, %f", __FUNCTION__, mode, r_scale, b_scale);
+    float* value = new float[3];
+    value[0] = r_scale; value[1] = 1.0f; value[2] = b_scale;
+    mSupportedWhiteBalanceScale.add(String8(mode), value);
+}
+
+void EmulatedCameraDevice::setWhiteBalanceMode(const char* mode) {
+    ALOGV("%s with white balance %s", __FUNCTION__, mode);
+    mWhiteBalanceScale =
+            mSupportedWhiteBalanceScale.valueFor(String8(mode));
+}
+
+/* Computes the pixel value after adjusting the white balance to the current
+ * one. The input the y, u, v channel of the pixel and the adjusted value will
+ * be stored in place. The adjustment is done in RGB space.
+ */
+void EmulatedCameraDevice::changeWhiteBalance(uint8_t& y,
+                                              uint8_t& u,
+                                              uint8_t& v) const {
+    float r_scale = mWhiteBalanceScale[0];
+    float b_scale = mWhiteBalanceScale[2];
+    int r = static_cast<float>(YUV2R(y, u, v)) / r_scale;
+    int g = YUV2G(y, u, v);
+    int b = static_cast<float>(YUV2B(y, u, v)) / b_scale;
+
+    y = RGB2Y(r, g, b);
+    u = RGB2U(r, g, b);
+    v = RGB2V(r, g, b);
 }
 
 status_t EmulatedCameraDevice::getCurrentPreviewFrame(void* buffer)
 {
     if (!isStarted()) {
-        LOGE("%s: Device is not started", __FUNCTION__);
+        ALOGE("%s: Device is not started", __FUNCTION__);
         return EINVAL;
     }
     if (mCurrentFrame == NULL || buffer == NULL) {
-        LOGE("%s: No framebuffer", __FUNCTION__);
+        ALOGE("%s: No framebuffer", __FUNCTION__);
         return EINVAL;
     }
 
@@ -141,7 +182,7 @@
             return NO_ERROR;
 
         default:
-            LOGE("%s: Unknown pixel format %.4s",
+            ALOGE("%s: Unknown pixel format %.4s",
                  __FUNCTION__, reinterpret_cast<const char*>(&mPixelFormat));
             return EINVAL;
     }
@@ -165,7 +206,7 @@
             break;
 
         default:
-            LOGE("%s: Unknown pixel format %.4s",
+            ALOGE("%s: Unknown pixel format %.4s",
                  __FUNCTION__, reinterpret_cast<const char*>(&pix_fmt));
             return EINVAL;
     }
@@ -179,10 +220,10 @@
     /* Allocate framebuffer. */
     mCurrentFrame = new uint8_t[mFrameBufferSize];
     if (mCurrentFrame == NULL) {
-        LOGE("%s: Unable to allocate framebuffer", __FUNCTION__);
+        ALOGE("%s: Unable to allocate framebuffer", __FUNCTION__);
         return ENOMEM;
     }
-    LOGV("%s: Allocated %p %d bytes for %d pixels in %.4s[%dx%d] frame",
+    ALOGV("%s: Allocated %p %d bytes for %d pixels in %.4s[%dx%d] frame",
          __FUNCTION__, mCurrentFrame, mFrameBufferSize, mTotalPixels,
          reinterpret_cast<const char*>(&mPixelFormat), mFrameWidth, mFrameHeight);
     return NO_ERROR;
@@ -205,29 +246,29 @@
 
 status_t EmulatedCameraDevice::startWorkerThread(bool one_burst)
 {
-    LOGV("%s", __FUNCTION__);
+    ALOGV("%s", __FUNCTION__);
 
     if (!isInitialized()) {
-        LOGE("%s: Emulated camera device is not initialized", __FUNCTION__);
+        ALOGE("%s: Emulated camera device is not initialized", __FUNCTION__);
         return EINVAL;
     }
 
     const status_t res = getWorkerThread()->startThread(one_burst);
-    LOGE_IF(res != NO_ERROR, "%s: Unable to start worker thread", __FUNCTION__);
+    ALOGE_IF(res != NO_ERROR, "%s: Unable to start worker thread", __FUNCTION__);
     return res;
 }
 
 status_t EmulatedCameraDevice::stopWorkerThread()
 {
-    LOGV("%s", __FUNCTION__);
+    ALOGV("%s", __FUNCTION__);
 
     if (!isInitialized()) {
-        LOGE("%s: Emulated camera device is not initialized", __FUNCTION__);
+        ALOGE("%s: Emulated camera device is not initialized", __FUNCTION__);
         return EINVAL;
     }
 
     const status_t res = getWorkerThread()->stopThread();
-    LOGE_IF(res != NO_ERROR, "%s: Unable to stop worker thread", __FUNCTION__);
+    ALOGE_IF(res != NO_ERROR, "%s: Unable to stop worker thread", __FUNCTION__);
     return res;
 }
 
@@ -244,19 +285,19 @@
 
 status_t EmulatedCameraDevice::WorkerThread::readyToRun()
 {
-    LOGV("Starting emulated camera device worker thread...");
+    ALOGV("Starting emulated camera device worker thread...");
 
-    LOGW_IF(mThreadControl >= 0 || mControlFD >= 0,
+    ALOGW_IF(mThreadControl >= 0 || mControlFD >= 0,
             "%s: Thread control FDs are opened", __FUNCTION__);
     /* Create a pair of FDs that would be used to control the thread. */
     int thread_fds[2];
     if (pipe(thread_fds) == 0) {
         mThreadControl = thread_fds[1];
         mControlFD = thread_fds[0];
-        LOGV("Emulated device's worker thread has been started.");
+        ALOGV("Emulated device's worker thread has been started.");
         return NO_ERROR;
     } else {
-        LOGE("%s: Unable to create thread control FDs: %d -> %s",
+        ALOGE("%s: Unable to create thread control FDs: %d -> %s",
              __FUNCTION__, errno, strerror(errno));
         return errno;
     }
@@ -264,7 +305,7 @@
 
 status_t EmulatedCameraDevice::WorkerThread::stopThread()
 {
-    LOGV("Stopping emulated camera device's worker thread...");
+    ALOGV("Stopping emulated camera device's worker thread...");
 
     status_t res = EINVAL;
     if (mThreadControl >= 0) {
@@ -285,18 +326,18 @@
                     close(mControlFD);
                     mControlFD = -1;
                 }
-                LOGV("Emulated camera device's worker thread has been stopped.");
+                ALOGV("Emulated camera device's worker thread has been stopped.");
             } else {
-                LOGE("%s: requestExitAndWait failed: %d -> %s",
+                ALOGE("%s: requestExitAndWait failed: %d -> %s",
                      __FUNCTION__, res, strerror(-res));
             }
         } else {
-            LOGE("%s: Unable to send THREAD_STOP message: %d -> %s",
+            ALOGE("%s: Unable to send THREAD_STOP message: %d -> %s",
                  __FUNCTION__, errno, strerror(errno));
             res = errno ? errno : EINVAL;
         }
     } else {
-        LOGE("%s: Thread control FDs are not opened", __FUNCTION__);
+        ALOGE("%s: Thread control FDs are not opened", __FUNCTION__);
     }
 
     return res;
@@ -322,7 +363,7 @@
     }
     int res = TEMP_FAILURE_RETRY(select(fd_num, fds, NULL, NULL, tvp));
     if (res < 0) {
-        LOGE("%s: select returned %d and failed: %d -> %s",
+        ALOGE("%s: select returned %d and failed: %d -> %s",
              __FUNCTION__, res, errno, strerror(errno));
         return ERROR;
     } else if (res == 0) {
@@ -333,21 +374,21 @@
         ControlMessage msg;
         res = TEMP_FAILURE_RETRY(read(mControlFD, &msg, sizeof(msg)));
         if (res != sizeof(msg)) {
-            LOGE("%s: Unexpected message size %d, or an error %d -> %s",
+            ALOGE("%s: Unexpected message size %d, or an error %d -> %s",
                  __FUNCTION__, res, errno, strerror(errno));
             return ERROR;
         }
         /* THREAD_STOP is the only message expected here. */
         if (msg == THREAD_STOP) {
-            LOGV("%s: THREAD_STOP message is received", __FUNCTION__);
+            ALOGV("%s: THREAD_STOP message is received", __FUNCTION__);
             return EXIT_THREAD;
         } else {
-            LOGE("Unknown worker thread message %d", msg);
+            ALOGE("Unknown worker thread message %d", msg);
             return ERROR;
         }
     } else {
         /* Must be an FD. */
-        LOGW_IF(fd < 0 || !FD_ISSET(fd, fds), "%s: Undefined 'select' result",
+        ALOGW_IF(fd < 0 || !FD_ISSET(fd, fds), "%s: Undefined 'select' result",
                 __FUNCTION__);
         return READY;
     }
diff --git a/tools/emulator/system/camera/EmulatedCameraDevice.h b/tools/emulator/system/camera/EmulatedCameraDevice.h
index 357c9e6..b7cdcb7 100755
--- a/tools/emulator/system/camera/EmulatedCameraDevice.h
+++ b/tools/emulator/system/camera/EmulatedCameraDevice.h
@@ -27,7 +27,10 @@
  */
 
 #include <utils/threads.h>
+#include <utils/KeyedVector.h>
+#include <utils/String8.h>
 #include "EmulatedCameraCommon.h"
+#include "Converters.h"
 
 namespace android {
 
@@ -116,6 +119,21 @@
      */
     virtual status_t Initialize();
 
+    /* Initializes the white balance modes parameters.
+     * The parameters are passed by each individual derived camera API to
+     * represent that different camera manufacturers may have different
+     * preferences on the white balance parameters. Green channel in the RGB
+     * color space is fixed to keep the luminance to be reasonably constant.
+     *
+     * Param:
+     * mode the text describing the current white balance mode
+     * r_scale the scale factor for the R channel in RGB space
+     * b_scale the scale factor for the B channel in RGB space.
+     */
+    void initializeWhiteBalanceModes(const char* mode,
+                                     const float r_scale,
+                                     const float b_scale);
+
     /* Starts delivering frames captured from the camera device.
      * This method will start the worker thread that would be pulling frames from
      * the camera device, and will deliver the pulled frames back to the emulated
@@ -145,7 +163,11 @@
 
     /* Sets the exposure compensation for the camera device.
      */
-    virtual void setExposureCompensation(const float ev);
+    void setExposureCompensation(const float ev);
+
+    /* Sets the white balance mode for the device.
+     */
+    void setWhiteBalanceMode(const char* mode);
 
     /* Gets current framebuffer, converted into preview frame format.
      * This method must be called on a connected instance of this class with a
@@ -170,7 +192,7 @@
      */
     inline int getFrameWidth() const
     {
-        LOGE_IF(!isStarted(), "%s: Device is not started", __FUNCTION__);
+        ALOGE_IF(!isStarted(), "%s: Device is not started", __FUNCTION__);
         return mFrameWidth;
     }
 
@@ -182,7 +204,7 @@
      */
     inline int getFrameHeight() const
     {
-        LOGE_IF(!isStarted(), "%s: Device is not started", __FUNCTION__);
+        ALOGE_IF(!isStarted(), "%s: Device is not started", __FUNCTION__);
         return mFrameHeight;
     }
 
@@ -193,7 +215,7 @@
      */
     inline size_t getFrameBufferSize() const
     {
-        LOGE_IF(!isStarted(), "%s: Device is not started", __FUNCTION__);
+        ALOGE_IF(!isStarted(), "%s: Device is not started", __FUNCTION__);
         return mFrameBufferSize;
     }
 
@@ -204,7 +226,7 @@
      */
     inline int getPixelNum() const
     {
-        LOGE_IF(!isStarted(), "%s: Device is not started", __FUNCTION__);
+        ALOGE_IF(!isStarted(), "%s: Device is not started", __FUNCTION__);
         return mTotalPixels;
     }
 
@@ -230,7 +252,7 @@
      */
     inline uint32_t getOriginalPixelFormat() const
     {
-        LOGE_IF(!isStarted(), "%s: Device is not started", __FUNCTION__);
+        ALOGE_IF(!isStarted(), "%s: Device is not started", __FUNCTION__);
         return mPixelFormat;
     }
 
@@ -269,6 +291,24 @@
      */
     virtual void commonStopDevice();
 
+    /** Computes a luminance value after taking the exposure compensation.
+     * value into account.
+     *
+     * Param:
+     * inputY - The input luminance value.
+     * Return:
+     * The luminance value after adjusting the exposure compensation.
+     */
+    inline uint8_t changeExposure(const uint8_t& inputY) const {
+        return static_cast<uint8_t>(clamp(static_cast<float>(inputY) *
+                                    mExposureCompensation));
+    }
+
+    /** Computes the pixel value in YUV space after adjusting to the current
+     * white balance mode.
+     */
+    void changeWhiteBalance(uint8_t& y, uint8_t& u, uint8_t& v) const;
+
     /****************************************************************************
      * Worker thread management.
      * Typicaly when emulated camera device starts capturing frames from the
@@ -332,7 +372,7 @@
 
             inline ~WorkerThread()
             {
-                LOGW_IF(mThreadControl >= 0 || mControlFD >= 0,
+                ALOGW_IF(mThreadControl >= 0 || mControlFD >= 0,
                         "%s: Control FDs are opened in the destructor",
                         __FUNCTION__);
                 if (mThreadControl >= 0) {
@@ -478,6 +518,10 @@
     /* Exposure compensation value */
     float                       mExposureCompensation;
 
+    float*                      mWhiteBalanceScale;
+
+    DefaultKeyedVector<String8, float*>      mSupportedWhiteBalanceScale;
+
     /* Defines possible states of the emulated camera device object.
      */
     enum EmulatedCameraDeviceState {
diff --git a/tools/emulator/system/camera/EmulatedCameraFactory.cpp b/tools/emulator/system/camera/EmulatedCameraFactory.cpp
index 5c5c5de..fbb05b5 100755
--- a/tools/emulator/system/camera/EmulatedCameraFactory.cpp
+++ b/tools/emulator/system/camera/EmulatedCameraFactory.cpp
@@ -40,9 +40,8 @@
         : mQemuClient(),
           mEmulatedCameras(NULL),
           mEmulatedCameraNum(0),
-          mFakeCameraID(-1),
+          mFakeCameraNum(0),
           mConstructedOK(false)
-
 {
     /* Connect to the factory service in the emulator, and create Qemu cameras. */
     if (mQemuClient.connectClient(NULL) == NO_ERROR) {
@@ -51,17 +50,51 @@
         createQemuCameras();
     }
 
-    if (isFakeCameraEmulationOn()) {
-        /* ID fake camera with the number of created 'qemud' cameras. */
-        mFakeCameraID = mEmulatedCameraNum;
+    if (isBackFakeCameraEmulationOn()) {
+        /* Camera ID. */
+        const int camera_id = mEmulatedCameraNum;
+        /* Use fake camera to emulate back-facing camera. */
+        mEmulatedCameraNum++;
+
+        /* Make sure that array is allocated (in case there were no 'qemu'
+         * cameras created. Note that we preallocate the array so it may contain
+         * two fake cameras: one facing back, and another facing front. */
+        if (mEmulatedCameras == NULL) {
+            mEmulatedCameras = new EmulatedBaseCamera*[mEmulatedCameraNum + 1];
+            if (mEmulatedCameras == NULL) {
+                ALOGE("%s: Unable to allocate emulated camera array for %d entries",
+                     __FUNCTION__, mEmulatedCameraNum);
+                return;
+            }
+            memset(mEmulatedCameras, 0, (mEmulatedCameraNum + 1) * sizeof(EmulatedCamera*));
+        }
+
+        /* Create, and initialize the fake camera */
+        mEmulatedCameras[camera_id] =
+            new EmulatedFakeCamera(camera_id, true, &HAL_MODULE_INFO_SYM.common);
+        if (mEmulatedCameras[camera_id] != NULL) {
+            if (mEmulatedCameras[camera_id]->Initialize() != NO_ERROR) {
+                delete mEmulatedCameras[camera_id];
+                mEmulatedCameras--;
+            }
+        } else {
+            mEmulatedCameras--;
+            ALOGE("%s: Unable to instantiate fake camera class", __FUNCTION__);
+        }
+    }
+
+    if (isFrontFakeCameraEmulationOn()) {
+        /* Camera ID. */
+        const int camera_id = mEmulatedCameraNum;
+        /* Use fake camera to emulate front-facing camera. */
         mEmulatedCameraNum++;
 
         /* Make sure that array is allocated (in case there were no 'qemu'
          * cameras created. */
         if (mEmulatedCameras == NULL) {
-            mEmulatedCameras = new EmulatedCamera*[mEmulatedCameraNum];
+            mEmulatedCameras = new EmulatedBaseCamera*[mEmulatedCameraNum];
             if (mEmulatedCameras == NULL) {
-                LOGE("%s: Unable to allocate emulated camera array for %d entries",
+                ALOGE("%s: Unable to allocate emulated camera array for %d entries",
                      __FUNCTION__, mEmulatedCameraNum);
                 return;
             }
@@ -69,25 +102,21 @@
         }
 
         /* Create, and initialize the fake camera */
-        mEmulatedCameras[mFakeCameraID] =
-            new EmulatedFakeCamera(mFakeCameraID, &HAL_MODULE_INFO_SYM.common);
-        if (mEmulatedCameras[mFakeCameraID] != NULL) {
-            if (mEmulatedCameras[mFakeCameraID]->Initialize() != NO_ERROR) {
-                delete mEmulatedCameras[mFakeCameraID];
+        mEmulatedCameras[camera_id] =
+            new EmulatedFakeCamera(camera_id, false, &HAL_MODULE_INFO_SYM.common);
+        if (mEmulatedCameras[camera_id] != NULL) {
+            if (mEmulatedCameras[camera_id]->Initialize() != NO_ERROR) {
+                delete mEmulatedCameras[camera_id];
                 mEmulatedCameras--;
-                mFakeCameraID = -1;
             }
         } else {
             mEmulatedCameras--;
-            mFakeCameraID = -1;
-            LOGE("%s: Unable to instantiate fake camera class", __FUNCTION__);
+            ALOGE("%s: Unable to instantiate fake camera class", __FUNCTION__);
         }
-    } else {
-        LOGD("Fake camera emulation is disabled.");
     }
 
-    LOGV("%d cameras are being emulated. Fake camera ID is %d",
-         mEmulatedCameraNum, mFakeCameraID);
+    ALOGV("%d cameras are being emulated. %d of them are fake cameras.",
+          mEmulatedCameraNum, mFakeCameraNum);
 
     mConstructedOK = true;
 }
@@ -107,24 +136,24 @@
 /****************************************************************************
  * Camera HAL API handlers.
  *
- * Each handler simply verifies existence of an appropriate EmulatedCamera
+ * Each handler simply verifies existence of an appropriate EmulatedBaseCamera
  * instance, and dispatches the call to that instance.
  *
  ***************************************************************************/
 
 int EmulatedCameraFactory::cameraDeviceOpen(int camera_id, hw_device_t** device)
 {
-    LOGV("%s: id = %d", __FUNCTION__, camera_id);
+    ALOGV("%s: id = %d", __FUNCTION__, camera_id);
 
     *device = NULL;
 
     if (!isConstructedOK()) {
-        LOGE("%s: EmulatedCameraFactory has failed to initialize", __FUNCTION__);
+        ALOGE("%s: EmulatedCameraFactory has failed to initialize", __FUNCTION__);
         return -EINVAL;
     }
 
     if (camera_id < 0 || camera_id >= getEmulatedCameraNum()) {
-        LOGE("%s: Camera id %d is out of bounds (%d)",
+        ALOGE("%s: Camera id %d is out of bounds (%d)",
              __FUNCTION__, camera_id, getEmulatedCameraNum());
         return -EINVAL;
     }
@@ -134,15 +163,15 @@
 
 int EmulatedCameraFactory::getCameraInfo(int camera_id, struct camera_info* info)
 {
-    LOGV("%s: id = %d", __FUNCTION__, camera_id);
+    ALOGV("%s: id = %d", __FUNCTION__, camera_id);
 
     if (!isConstructedOK()) {
-        LOGE("%s: EmulatedCameraFactory has failed to initialize", __FUNCTION__);
+        ALOGE("%s: EmulatedCameraFactory has failed to initialize", __FUNCTION__);
         return -EINVAL;
     }
 
     if (camera_id < 0 || camera_id >= getEmulatedCameraNum()) {
-        LOGE("%s: Camera id %d is out of bounds (%d)",
+        ALOGE("%s: Camera id %d is out of bounds (%d)",
              __FUNCTION__, camera_id, getEmulatedCameraNum());
         return -EINVAL;
     }
@@ -164,12 +193,12 @@
      */
 
     if (module != &HAL_MODULE_INFO_SYM.common) {
-        LOGE("%s: Invalid module %p expected %p",
+        ALOGE("%s: Invalid module %p expected %p",
              __FUNCTION__, module, &HAL_MODULE_INFO_SYM.common);
         return -EINVAL;
     }
     if (name == NULL) {
-        LOGE("%s: NULL name is not expected here", __FUNCTION__);
+        ALOGE("%s: NULL name is not expected here", __FUNCTION__);
         return -EINVAL;
     }
 
@@ -230,15 +259,15 @@
     }
 
     /* Allocate the array for emulated camera instances. Note that we allocate
-     * one more entry for the fake camera emulation. */
-    mEmulatedCameras = new EmulatedCamera*[num + 1];
+     * two more entries for back and front fake camera emulation. */
+    mEmulatedCameras = new EmulatedBaseCamera*[num + 2];
     if (mEmulatedCameras == NULL) {
-        LOGE("%s: Unable to allocate emulated camera array for %d entries",
+        ALOGE("%s: Unable to allocate emulated camera array for %d entries",
              __FUNCTION__, num + 1);
         free(camera_list);
         return;
     }
-    memset(mEmulatedCameras, 0, sizeof(EmulatedCamera*) * (num + 1));
+    memset(mEmulatedCameras, 0, sizeof(EmulatedBaseCamera*) * (num + 1));
 
     /*
      * Iterate the list, creating, and initializin emulated qemu cameras for each
@@ -292,11 +321,11 @@
                     delete qemu_cam;
                 }
             } else {
-                LOGE("%s: Unable to instantiate EmulatedQemuCamera",
+                ALOGE("%s: Unable to instantiate EmulatedQemuCamera",
                      __FUNCTION__);
             }
         } else {
-            LOGW("%s: Bad camera information: %s", __FUNCTION__, cur_entry);
+            ALOGW("%s: Bad camera information: %s", __FUNCTION__, cur_entry);
         }
 
         cur_entry = next_entry;
@@ -305,13 +334,28 @@
     mEmulatedCameraNum = index;
 }
 
-bool EmulatedCameraFactory::isFakeCameraEmulationOn()
+bool EmulatedCameraFactory::isBackFakeCameraEmulationOn()
 {
-    /* Defined by 'qemu.sf.fake_camera' boot property: If property is there
-     * and contains 'off', fake camera emulation is disabled. */
+    /* Defined by 'qemu.sf.fake_camera' boot property: if property exist, and
+     * is set to 'both', or 'back', then fake camera is used to emulate back
+     * camera. */
     char prop[PROPERTY_VALUE_MAX];
-    if (property_get("qemu.sf.fake_camera", prop, NULL) <= 0 ||
-        strcmp(prop, "off")) {
+    if ((property_get("qemu.sf.fake_camera", prop, NULL) > 0) &&
+        (!strcmp(prop, "both") || !strcmp(prop, "back"))) {
+        return true;
+    } else {
+        return false;
+    }
+}
+
+bool EmulatedCameraFactory::isFrontFakeCameraEmulationOn()
+{
+    /* Defined by 'qemu.sf.fake_camera' boot property: if property exist, and
+     * is set to 'both', or 'front', then fake camera is used to emulate front
+     * camera. */
+    char prop[PROPERTY_VALUE_MAX];
+    if ((property_get("qemu.sf.fake_camera", prop, NULL) > 0) &&
+        (!strcmp(prop, "both") || !strcmp(prop, "front"))) {
         return true;
     } else {
         return false;
diff --git a/tools/emulator/system/camera/EmulatedCameraFactory.h b/tools/emulator/system/camera/EmulatedCameraFactory.h
index 19745a3..7e3d4b2 100755
--- a/tools/emulator/system/camera/EmulatedCameraFactory.h
+++ b/tools/emulator/system/camera/EmulatedCameraFactory.h
@@ -17,7 +17,7 @@
 #ifndef HW_EMULATOR_CAMERA_EMULATED_CAMERA_FACTORY_H
 #define HW_EMULATOR_CAMERA_EMULATED_CAMERA_FACTORY_H
 
-#include "EmulatedCamera.h"
+#include "EmulatedBaseCamera.h"
 #include "QemuClient.h"
 
 namespace android {
@@ -131,8 +131,11 @@
      */
     void createQemuCameras();
 
-    /* Checks if fake camera emulation is on. */
-    bool isFakeCameraEmulationOn();
+    /* Checks if fake camera emulation is on for the camera facing back. */
+    bool isBackFakeCameraEmulationOn();
+
+    /* Checks if fake camera emulation is on for the camera facing front. */
+    bool isFrontFakeCameraEmulationOn();
 
     /****************************************************************************
      * Data members.
@@ -143,13 +146,13 @@
     FactoryQemuClient   mQemuClient;
 
     /* Array of cameras available for the emulation. */
-    EmulatedCamera**    mEmulatedCameras;
+    EmulatedBaseCamera**    mEmulatedCameras;
 
-    /* Number of emulated cameras (including the fake one). */
+    /* Number of emulated cameras (including the fake ones). */
     int                 mEmulatedCameraNum;
 
-    /* Fake camera ID. */
-    int                 mFakeCameraID;
+    /* Number of emulated fake cameras. */
+    int                 mFakeCameraNum;
 
     /* Flags whether or not constructor has succeeded. */
     bool                mConstructedOK;
diff --git a/tools/emulator/system/camera/EmulatedCameraHal.cpp b/tools/emulator/system/camera/EmulatedCameraHal.cpp
index 7f3f7b8..aa0cb00 100755
--- a/tools/emulator/system/camera/EmulatedCameraHal.cpp
+++ b/tools/emulator/system/camera/EmulatedCameraHal.cpp
@@ -30,15 +30,15 @@
  */
 camera_module_t HAL_MODULE_INFO_SYM = {
     common: {
-         tag:           HARDWARE_MODULE_TAG,
-         version_major: 1,
-         version_minor: 0,
-         id:            CAMERA_HARDWARE_MODULE_ID,
-         name:          "Emulated Camera Module",
-         author:        "The Android Open Source Project",
-         methods:       &android::EmulatedCameraFactory::mCameraModuleMethods,
-         dso:           NULL,
-         reserved:      {0},
+         tag:                HARDWARE_MODULE_TAG,
+         module_api_version: CAMERA_MODULE_API_VERSION_2_0,
+         hal_api_version:    HARDWARE_HAL_API_VERSION,
+         id:                 CAMERA_HARDWARE_MODULE_ID,
+         name:               "Emulated Camera Module",
+         author:             "The Android Open Source Project",
+         methods:            &android::EmulatedCameraFactory::mCameraModuleMethods,
+         dso:                NULL,
+         reserved:           {0},
     },
     get_number_of_cameras:  android::EmulatedCameraFactory::get_number_of_cameras,
     get_camera_info:        android::EmulatedCameraFactory::get_camera_info,
diff --git a/tools/emulator/system/camera/EmulatedFakeCamera.cpp b/tools/emulator/system/camera/EmulatedFakeCamera.cpp
index 86b9d08..457850d 100755
--- a/tools/emulator/system/camera/EmulatedFakeCamera.cpp
+++ b/tools/emulator/system/camera/EmulatedFakeCamera.cpp
@@ -28,8 +28,11 @@
 
 namespace android {
 
-EmulatedFakeCamera::EmulatedFakeCamera(int cameraId, struct hw_module_t* module)
+EmulatedFakeCamera::EmulatedFakeCamera(int cameraId,
+                                       bool facingBack,
+                                       struct hw_module_t* module)
         : EmulatedCamera(cameraId, module),
+          mFacingBack(facingBack),
           mFakeCameraDevice(this)
 {
 }
@@ -49,13 +52,11 @@
         return res;
     }
 
-    /* Fake camera facing is defined by the qemu.sf.fake_camera boot property. */
-    char prop[PROPERTY_VALUE_MAX];
-    property_get("qemu.sf.fake_camera", prop, EmulatedCamera::FACING_BACK);
-    const char* facing = prop;
+    const char* facing = mFacingBack ? EmulatedCamera::FACING_BACK :
+                                       EmulatedCamera::FACING_FRONT;
 
     mParameters.set(EmulatedCamera::FACING_KEY, facing);
-    LOGD("%s: Fake camera is facing %s", __FUNCTION__, facing);
+    ALOGD("%s: Fake camera is facing %s", __FUNCTION__, facing);
 
     mParameters.set(EmulatedCamera::ORIENTATION_KEY,
                     gEmulatedCameraFactory.getFakeCameraOrientation());
diff --git a/tools/emulator/system/camera/EmulatedFakeCamera.h b/tools/emulator/system/camera/EmulatedFakeCamera.h
index 3debe9e..4bfbd70 100755
--- a/tools/emulator/system/camera/EmulatedFakeCamera.h
+++ b/tools/emulator/system/camera/EmulatedFakeCamera.h
@@ -35,7 +35,7 @@
 class EmulatedFakeCamera : public EmulatedCamera {
 public:
     /* Constructs EmulatedFakeCamera instance. */
-    EmulatedFakeCamera(int cameraId, struct hw_module_t* module);
+    EmulatedFakeCamera(int cameraId, bool facingBack, struct hw_module_t* module);
 
     /* Destructs EmulatedFakeCamera instance. */
     ~EmulatedFakeCamera();
@@ -62,6 +62,9 @@
      ***************************************************************************/
 
 protected:
+    /* Facing back (true) or front (false) switch. */
+    bool                        mFacingBack;
+
     /* Contained fake camera device object. */
     EmulatedFakeCameraDevice    mFakeCameraDevice;
 };
diff --git a/tools/emulator/system/camera/EmulatedFakeCameraDevice.cpp b/tools/emulator/system/camera/EmulatedFakeCameraDevice.cpp
index 3666827..0bc4c54 100755
--- a/tools/emulator/system/camera/EmulatedFakeCameraDevice.cpp
+++ b/tools/emulator/system/camera/EmulatedFakeCameraDevice.cpp
@@ -46,11 +46,11 @@
 {
     // Makes the image with the original exposure compensation darker.
     // So the effects of changing the exposure compensation can be seen.
-    mBlackYUV.Y = mBlackYUV.Y / 4;
-    mWhiteYUV.Y = mWhiteYUV.Y / 4;
-    mRedYUV.Y = mRedYUV.Y / 4;
-    mGreenYUV.Y = mGreenYUV.Y / 4;
-    mBlueYUV.Y = mBlueYUV.Y / 4;
+    mBlackYUV.Y = mBlackYUV.Y / 2;
+    mWhiteYUV.Y = mWhiteYUV.Y / 2;
+    mRedYUV.Y = mRedYUV.Y / 2;
+    mGreenYUV.Y = mGreenYUV.Y / 2;
+    mBlueYUV.Y = mBlueYUV.Y / 2;
 }
 
 EmulatedFakeCameraDevice::~EmulatedFakeCameraDevice()
@@ -63,15 +63,15 @@
 
 status_t EmulatedFakeCameraDevice::connectDevice()
 {
-    LOGV("%s", __FUNCTION__);
+    ALOGV("%s", __FUNCTION__);
 
     Mutex::Autolock locker(&mObjectLock);
     if (!isInitialized()) {
-        LOGE("%s: Fake camera device is not initialized.", __FUNCTION__);
+        ALOGE("%s: Fake camera device is not initialized.", __FUNCTION__);
         return EINVAL;
     }
     if (isConnected()) {
-        LOGW("%s: Fake camera device is already connected.", __FUNCTION__);
+        ALOGW("%s: Fake camera device is already connected.", __FUNCTION__);
         return NO_ERROR;
     }
 
@@ -83,15 +83,15 @@
 
 status_t EmulatedFakeCameraDevice::disconnectDevice()
 {
-    LOGV("%s", __FUNCTION__);
+    ALOGV("%s", __FUNCTION__);
 
     Mutex::Autolock locker(&mObjectLock);
     if (!isConnected()) {
-        LOGW("%s: Fake camera device is already disconnected.", __FUNCTION__);
+        ALOGW("%s: Fake camera device is already disconnected.", __FUNCTION__);
         return NO_ERROR;
     }
     if (isStarted()) {
-        LOGE("%s: Cannot disconnect from the started device.", __FUNCTION__);
+        ALOGE("%s: Cannot disconnect from the started device.", __FUNCTION__);
         return EINVAL;
     }
 
@@ -105,15 +105,15 @@
                                                int height,
                                                uint32_t pix_fmt)
 {
-    LOGV("%s", __FUNCTION__);
+    ALOGV("%s", __FUNCTION__);
 
     Mutex::Autolock locker(&mObjectLock);
     if (!isConnected()) {
-        LOGE("%s: Fake camera device is not connected.", __FUNCTION__);
+        ALOGE("%s: Fake camera device is not connected.", __FUNCTION__);
         return EINVAL;
     }
     if (isStarted()) {
-        LOGE("%s: Fake camera device is already started.", __FUNCTION__);
+        ALOGE("%s: Fake camera device is already started.", __FUNCTION__);
         return EINVAL;
     }
 
@@ -154,7 +154,7 @@
                 break;
 
             default:
-                LOGE("%s: Unknown pixel format %.4s", __FUNCTION__,
+                ALOGE("%s: Unknown pixel format %.4s", __FUNCTION__,
                      reinterpret_cast<const char*>(&mPixelFormat));
                 return EINVAL;
         }
@@ -162,7 +162,7 @@
         mUVInRow = (width / 2) * mUVStep;
         mState = ECDS_STARTED;
     } else {
-        LOGE("%s: commonStartDevice failed", __FUNCTION__);
+        ALOGE("%s: commonStartDevice failed", __FUNCTION__);
     }
 
     return res;
@@ -170,11 +170,11 @@
 
 status_t EmulatedFakeCameraDevice::stopDevice()
 {
-    LOGV("%s", __FUNCTION__);
+    ALOGV("%s", __FUNCTION__);
 
     Mutex::Autolock locker(&mObjectLock);
     if (!isStarted()) {
-        LOGW("%s: Fake camera device is not started.", __FUNCTION__);
+        ALOGW("%s: Fake camera device is not started.", __FUNCTION__);
         return NO_ERROR;
     }
 
@@ -195,7 +195,7 @@
     WorkerThread::SelectRes res =
         getWorkerThread()->Select(-1, 1000000 / mEmulatedFPS);
     if (res == WorkerThread::EXIT_THREAD) {
-        LOGV("%s: Worker thread has been terminated.", __FUNCTION__);
+        ALOGV("%s: Worker thread has been terminated.", __FUNCTION__);
         return false;
     }
 
@@ -256,6 +256,9 @@
     uint8_t* U = U_pos;
     uint8_t* V = V_pos;
 
+    YUVPixel adjustedWhite = YUVPixel(mWhiteYUV);
+    changeWhiteBalance(adjustedWhite.Y, adjustedWhite.U, adjustedWhite.V);
+
     for(int y = 0; y < mFrameHeight; y++) {
         int countx = checkxremainder;
         bool current = black;
@@ -263,7 +266,7 @@
             if (current) {
                 mBlackYUV.get(Y, U, V);
             } else {
-                mWhiteYUV.get(Y, U, V);
+                adjustedWhite.get(Y, U, V);
             }
             *Y = changeExposure(*Y);
             Y[1] = *Y;
@@ -309,6 +312,9 @@
     const int square_ystop = min(mFrameHeight, y + size);
     uint8_t* Y_pos = mCurrentFrame + y * mFrameWidth + x;
 
+    YUVPixel adjustedColor = *color;
+    changeWhiteBalance(adjustedColor.Y, adjustedColor.U, adjustedColor.V);
+
     // Draw the square.
     for (; y < square_ystop; y++) {
         const int iUV = (y / 2) * mUVInRow + (x / 2) * mUVStep;
@@ -316,7 +322,7 @@
         uint8_t* sqV = mFrameV + iUV;
         uint8_t* sqY = Y_pos;
         for (int i = x; i < square_xstop; i += 2) {
-            color->get(sqY, sqU, sqV);
+            adjustedColor.get(sqY, sqU, sqV);
             *sqY = changeExposure(*sqY);
             sqY[1] = *sqY;
             sqY += 2; sqU += mUVStep; sqV += mUVStep;
@@ -329,8 +335,11 @@
 
 void EmulatedFakeCameraDevice::drawSolid(YUVPixel* color)
 {
+    YUVPixel adjustedColor = *color;
+    changeWhiteBalance(adjustedColor.Y, adjustedColor.U, adjustedColor.V);
+
     /* All Ys are the same. */
-    memset(mCurrentFrame, changeExposure(color->Y), mTotalPixels);
+    memset(mCurrentFrame, changeExposure(adjustedColor.Y), mTotalPixels);
 
     /* Fill U, and V panes. */
     uint8_t* U = mFrameU;
@@ -364,6 +373,7 @@
             /* And the blue stripe at the bottom. */
             color = &mBlueYUV;
         }
+        changeWhiteBalance(color->Y, color->U, color->V);
 
         /* All Ys at the row are the same. */
         memset(pY, changeExposure(color->Y), mFrameWidth);
@@ -389,26 +399,26 @@
             mCurrentFrameType = 0;
         }
         if (mCurrentFrameType == 2) {
-            LOGD("********** Rotated to the SOLID COLOR frame **********");
+            ALOGD("********** Rotated to the SOLID COLOR frame **********");
             /* Solid color: lets rotate color too. */
             if (mCurrentColor == &mWhiteYUV) {
-                LOGD("----- Painting a solid RED frame -----");
+                ALOGD("----- Painting a solid RED frame -----");
                 mCurrentColor = &mRedYUV;
             } else if (mCurrentColor == &mRedYUV) {
-                LOGD("----- Painting a solid GREEN frame -----");
+                ALOGD("----- Painting a solid GREEN frame -----");
                 mCurrentColor = &mGreenYUV;
             } else if (mCurrentColor == &mGreenYUV) {
-                LOGD("----- Painting a solid BLUE frame -----");
+                ALOGD("----- Painting a solid BLUE frame -----");
                 mCurrentColor = &mBlueYUV;
             } else {
                 /* Back to white. */
-                LOGD("----- Painting a solid WHITE frame -----");
+                ALOGD("----- Painting a solid WHITE frame -----");
                 mCurrentColor = &mWhiteYUV;
             }
         } else if (mCurrentFrameType == 0) {
-            LOGD("********** Rotated to the CHECKERBOARD frame **********");
-        } else {
-            LOGD("********** Rotated to the STRIPED frame **********");
+            ALOGD("********** Rotated to the CHECKERBOARD frame **********");
+        } else if (mCurrentFrameType == 1) {
+            ALOGD("********** Rotated to the STRIPED frame **********");
         }
     }
 
diff --git a/tools/emulator/system/camera/EmulatedFakeCameraDevice.h b/tools/emulator/system/camera/EmulatedFakeCameraDevice.h
index 383118b..f66f076 100755
--- a/tools/emulator/system/camera/EmulatedFakeCameraDevice.h
+++ b/tools/emulator/system/camera/EmulatedFakeCameraDevice.h
@@ -99,6 +99,7 @@
      ***************************************************************************/
 
 private:
+
     /* Draws a black and white checker board in the current frame buffer. */
     void drawCheckerboard();
 
@@ -110,10 +111,6 @@
      */
     void drawSquare(int x, int y, int size, const YUVPixel* color);
 
-    inline uint8_t changeExposure(uint8_t inputY) {
-        return static_cast<uint8_t>(static_cast<float>(inputY) *
-                                    mExposureCompensation);
-    }
 #if EFCD_ROTATE_FRAME
     void drawSolid(YUVPixel* color);
     void drawStripes();
diff --git a/tools/emulator/system/camera/EmulatedQemuCamera.cpp b/tools/emulator/system/camera/EmulatedQemuCamera.cpp
index 611b6b5..af1e324 100755
--- a/tools/emulator/system/camera/EmulatedQemuCamera.cpp
+++ b/tools/emulator/system/camera/EmulatedQemuCamera.cpp
@@ -45,7 +45,7 @@
                                         const char* frame_dims,
                                         const char* facing_dir)
 {
-    LOGV("%s:\n   Name=%s\n   Facing '%s'\n   Dimensions=%s",
+    ALOGV("%s:\n   Name=%s\n   Facing '%s'\n   Dimensions=%s",
          __FUNCTION__, device_name, facing_dir, frame_dims);
     /* Save dimensions. */
     mFrameDims = frame_dims;
@@ -94,7 +94,7 @@
     /* Width and height are separated with 'x' */
     char* sep = strchr(first_dim, 'x');
     if (sep == NULL) {
-        LOGE("%s: Invalid first dimension format in %s",
+        ALOGE("%s: Invalid first dimension format in %s",
              __FUNCTION__, frame_dims);
         return EINVAL;
     }
@@ -105,7 +105,7 @@
     mParameters.setPreviewSize(x, y);
     mParameters.setPictureSize(x, y);
 
-    LOGV("%s: Qemu camera %s is initialized. Current frame is %dx%d",
+    ALOGV("%s: Qemu camera %s is initialized. Current frame is %dx%d",
          __FUNCTION__, device_name, x, y);
 
     return NO_ERROR;
diff --git a/tools/emulator/system/camera/EmulatedQemuCameraDevice.cpp b/tools/emulator/system/camera/EmulatedQemuCameraDevice.cpp
index 57dbc98..07837af 100755
--- a/tools/emulator/system/camera/EmulatedQemuCameraDevice.cpp
+++ b/tools/emulator/system/camera/EmulatedQemuCameraDevice.cpp
@@ -58,7 +58,7 @@
     /* Initialize base class. */
     res = EmulatedCameraDevice::Initialize();
     if (res == NO_ERROR) {
-        LOGV("%s: Connected to the emulated camera service '%s'",
+        ALOGV("%s: Connected to the emulated camera service '%s'",
              __FUNCTION__, device_name);
         mDeviceName = device_name;
     } else {
@@ -74,15 +74,15 @@
 
 status_t EmulatedQemuCameraDevice::connectDevice()
 {
-    LOGV("%s", __FUNCTION__);
+    ALOGV("%s", __FUNCTION__);
 
     Mutex::Autolock locker(&mObjectLock);
     if (!isInitialized()) {
-        LOGE("%s: Qemu camera device is not initialized.", __FUNCTION__);
+        ALOGE("%s: Qemu camera device is not initialized.", __FUNCTION__);
         return EINVAL;
     }
     if (isConnected()) {
-        LOGW("%s: Qemu camera device '%s' is already connected.",
+        ALOGW("%s: Qemu camera device '%s' is already connected.",
              __FUNCTION__, (const char*)mDeviceName);
         return NO_ERROR;
     }
@@ -90,11 +90,11 @@
     /* Connect to the camera device via emulator. */
     const status_t res = mQemuClient.queryConnect();
     if (res == NO_ERROR) {
-        LOGV("%s: Connected to device '%s'",
+        ALOGV("%s: Connected to device '%s'",
              __FUNCTION__, (const char*)mDeviceName);
         mState = ECDS_CONNECTED;
     } else {
-        LOGE("%s: Connection to device '%s' failed",
+        ALOGE("%s: Connection to device '%s' failed",
              __FUNCTION__, (const char*)mDeviceName);
     }
 
@@ -103,16 +103,16 @@
 
 status_t EmulatedQemuCameraDevice::disconnectDevice()
 {
-    LOGV("%s", __FUNCTION__);
+    ALOGV("%s", __FUNCTION__);
 
     Mutex::Autolock locker(&mObjectLock);
     if (!isConnected()) {
-        LOGW("%s: Qemu camera device '%s' is already disconnected.",
+        ALOGW("%s: Qemu camera device '%s' is already disconnected.",
              __FUNCTION__, (const char*)mDeviceName);
         return NO_ERROR;
     }
     if (isStarted()) {
-        LOGE("%s: Cannot disconnect from the started device '%s.",
+        ALOGE("%s: Cannot disconnect from the started device '%s.",
              __FUNCTION__, (const char*)mDeviceName);
         return EINVAL;
     }
@@ -120,11 +120,11 @@
     /* Disconnect from the camera device via emulator. */
     const status_t res = mQemuClient.queryDisconnect();
     if (res == NO_ERROR) {
-        LOGV("%s: Disonnected from device '%s'",
+        ALOGV("%s: Disonnected from device '%s'",
              __FUNCTION__, (const char*)mDeviceName);
         mState = ECDS_INITIALIZED;
     } else {
-        LOGE("%s: Disconnection from device '%s' failed",
+        ALOGE("%s: Disconnection from device '%s' failed",
              __FUNCTION__, (const char*)mDeviceName);
     }
 
@@ -135,23 +135,23 @@
                                                int height,
                                                uint32_t pix_fmt)
 {
-    LOGV("%s", __FUNCTION__);
+    ALOGV("%s", __FUNCTION__);
 
     Mutex::Autolock locker(&mObjectLock);
     if (!isConnected()) {
-        LOGE("%s: Qemu camera device '%s' is not connected.",
+        ALOGE("%s: Qemu camera device '%s' is not connected.",
              __FUNCTION__, (const char*)mDeviceName);
         return EINVAL;
     }
     if (isStarted()) {
-        LOGW("%s: Qemu camera device '%s' is already started.",
+        ALOGW("%s: Qemu camera device '%s' is already started.",
              __FUNCTION__, (const char*)mDeviceName);
         return NO_ERROR;
     }
 
     status_t res = EmulatedCameraDevice::commonStartDevice(width, height, pix_fmt);
     if (res != NO_ERROR) {
-        LOGE("%s: commonStartDevice failed", __FUNCTION__);
+        ALOGE("%s: commonStartDevice failed", __FUNCTION__);
         return res;
     }
 
@@ -160,7 +160,7 @@
      * RGB32 only.*/
     mPreviewFrame = new uint32_t[mTotalPixels];
     if (mPreviewFrame == NULL) {
-        LOGE("%s: Unable to allocate %d bytes for preview frame",
+        ALOGE("%s: Unable to allocate %d bytes for preview frame",
              __FUNCTION__, mTotalPixels);
         return ENOMEM;
     }
@@ -168,13 +168,13 @@
     /* Start the actual camera device. */
     res = mQemuClient.queryStart(mPixelFormat, mFrameWidth, mFrameHeight);
     if (res == NO_ERROR) {
-        LOGV("%s: Qemu camera device '%s' is started for %.4s[%dx%d] frames",
+        ALOGV("%s: Qemu camera device '%s' is started for %.4s[%dx%d] frames",
              __FUNCTION__, (const char*)mDeviceName,
              reinterpret_cast<const char*>(&mPixelFormat),
              mFrameWidth, mFrameHeight);
         mState = ECDS_STARTED;
     } else {
-        LOGE("%s: Unable to start device '%s' for %.4s[%dx%d] frames",
+        ALOGE("%s: Unable to start device '%s' for %.4s[%dx%d] frames",
              __FUNCTION__, (const char*)mDeviceName,
              reinterpret_cast<const char*>(&pix_fmt), width, height);
     }
@@ -184,11 +184,11 @@
 
 status_t EmulatedQemuCameraDevice::stopDevice()
 {
-    LOGV("%s", __FUNCTION__);
+    ALOGV("%s", __FUNCTION__);
 
     Mutex::Autolock locker(&mObjectLock);
     if (!isStarted()) {
-        LOGW("%s: Qemu camera device '%s' is not started.",
+        ALOGW("%s: Qemu camera device '%s' is not started.",
              __FUNCTION__, (const char*)mDeviceName);
         return NO_ERROR;
     }
@@ -202,10 +202,10 @@
         }
         EmulatedCameraDevice::commonStopDevice();
         mState = ECDS_CONNECTED;
-        LOGV("%s: Qemu camera device '%s' is stopped",
+        ALOGV("%s: Qemu camera device '%s' is stopped",
              __FUNCTION__, (const char*)mDeviceName);
     } else {
-        LOGE("%s: Unable to stop device '%s'",
+        ALOGE("%s: Unable to stop device '%s'",
              __FUNCTION__, (const char*)mDeviceName);
     }
 
@@ -218,7 +218,7 @@
 
 status_t EmulatedQemuCameraDevice::getCurrentPreviewFrame(void* buffer)
 {
-    LOGW_IF(mPreviewFrame == NULL, "%s: No preview frame", __FUNCTION__);
+    ALOGW_IF(mPreviewFrame == NULL, "%s: No preview frame", __FUNCTION__);
     if (mPreviewFrame != NULL) {
         memcpy(buffer, mPreviewFrame, mTotalPixels * 4);
         return 0;
@@ -237,21 +237,25 @@
     WorkerThread::SelectRes res =
         getWorkerThread()->Select(-1, 1000000 / mEmulatedFPS);
     if (res == WorkerThread::EXIT_THREAD) {
-        LOGV("%s: Worker thread has been terminated.", __FUNCTION__);
+        ALOGV("%s: Worker thread has been terminated.", __FUNCTION__);
         return false;
     }
 
     /* Query frames from the service. */
     status_t query_res = mQemuClient.queryFrame(mCurrentFrame, mPreviewFrame,
                                                  mFrameBufferSize,
-                                                 mTotalPixels * 4);
+                                                 mTotalPixels * 4,
+                                                 mWhiteBalanceScale[0],
+                                                 mWhiteBalanceScale[1],
+                                                 mWhiteBalanceScale[2],
+                                                 mExposureCompensation);
     if (query_res == NO_ERROR) {
         /* Timestamp the current frame, and notify the camera HAL. */
         mCurFrameTimestamp = systemTime(SYSTEM_TIME_MONOTONIC);
         mCameraHAL->onNextFrameAvailable(mCurrentFrame, mCurFrameTimestamp, this);
         return true;
     } else {
-        LOGE("%s: Unable to get current video frame: %s",
+        ALOGE("%s: Unable to get current video frame: %s",
              __FUNCTION__, strerror(query_res));
         mCameraHAL->onCameraDeviceError(CAMERA_ERROR_SERVER_DIED);
         return false;
diff --git a/tools/emulator/system/camera/JpegCompressor.cpp b/tools/emulator/system/camera/JpegCompressor.cpp
index 0e538a1..8eec52d 100644
--- a/tools/emulator/system/camera/JpegCompressor.cpp
+++ b/tools/emulator/system/camera/JpegCompressor.cpp
@@ -44,7 +44,7 @@
                                               int height,
                                               int quality)
 {
-    LOGV("%s: %p[%dx%d]", __FUNCTION__, image, width, height);
+    ALOGV("%s: %p[%dx%d]", __FUNCTION__, image, width, height);
     void* pY = const_cast<void*>(image);
     int offsets[2];
     offsets[0] = 0;
@@ -52,11 +52,11 @@
     mStrides[0] = width;
     mStrides[1] = width;
     if (encode(&mStream, pY, width, height, offsets, quality)) {
-        LOGV("%s: Compressed JPEG: %d[%dx%d] -> %d bytes",
+        ALOGV("%s: Compressed JPEG: %d[%dx%d] -> %d bytes",
              __FUNCTION__, (width * height * 12) / 8, width, height, mStream.getOffset());
         return NO_ERROR;
     } else {
-        LOGE("%s: JPEG compression failed", __FUNCTION__);
+        ALOGE("%s: JPEG compression failed", __FUNCTION__);
         return errno ? errno : EINVAL;
     }
 }
diff --git a/tools/emulator/system/camera/PreviewWindow.cpp b/tools/emulator/system/camera/PreviewWindow.cpp
index fb708d5..eac3586 100755
--- a/tools/emulator/system/camera/PreviewWindow.cpp
+++ b/tools/emulator/system/camera/PreviewWindow.cpp
@@ -49,7 +49,7 @@
 status_t PreviewWindow::setPreviewWindow(struct preview_stream_ops* window,
                                          int preview_fps)
 {
-    LOGV("%s: current: %p -> new: %p", __FUNCTION__, mPreviewWindow, window);
+    ALOGV("%s: current: %p -> new: %p", __FUNCTION__, mPreviewWindow, window);
 
     status_t res = NO_ERROR;
     Mutex::Autolock locker(&mObjectLock);
@@ -70,7 +70,7 @@
         } else {
             window = NULL;
             res = -res; // set_usage returns a negative errno.
-            LOGE("%s: Error setting preview window usage %d -> %s",
+            ALOGE("%s: Error setting preview window usage %d -> %s",
                  __FUNCTION__, res, strerror(res));
         }
     }
@@ -81,7 +81,7 @@
 
 status_t PreviewWindow::startPreview()
 {
-    LOGV("%s", __FUNCTION__);
+    ALOGV("%s", __FUNCTION__);
 
     Mutex::Autolock locker(&mObjectLock);
     mPreviewEnabled = true;
@@ -91,7 +91,7 @@
 
 void PreviewWindow::stopPreview()
 {
-    LOGV("%s", __FUNCTION__);
+    ALOGV("%s", __FUNCTION__);
 
     Mutex::Autolock locker(&mObjectLock);
     mPreviewEnabled = false;
@@ -117,7 +117,7 @@
         /* Need to set / adjust buffer geometry for the preview window.
          * Note that in the emulator preview window uses only RGB for pixel
          * formats. */
-        LOGV("%s: Adjusting preview windows %p geometry to %dx%d",
+        ALOGV("%s: Adjusting preview windows %p geometry to %dx%d",
              __FUNCTION__, mPreviewWindow, mPreviewFrameWidth,
              mPreviewFrameHeight);
         res = mPreviewWindow->set_buffers_geometry(mPreviewWindow,
@@ -125,7 +125,7 @@
                                                    mPreviewFrameHeight,
                                                    HAL_PIXEL_FORMAT_RGBA_8888);
         if (res != NO_ERROR) {
-            LOGE("%s: Error in set_buffers_geometry %d -> %s",
+            ALOGE("%s: Error in set_buffers_geometry %d -> %s",
                  __FUNCTION__, -res, strerror(-res));
             return;
         }
@@ -140,7 +140,7 @@
     int stride = 0;
     res = mPreviewWindow->dequeue_buffer(mPreviewWindow, &buffer, &stride);
     if (res != NO_ERROR || buffer == NULL) {
-        LOGE("%s: Unable to dequeue preview window buffer: %d -> %s",
+        ALOGE("%s: Unable to dequeue preview window buffer: %d -> %s",
             __FUNCTION__, -res, strerror(-res));
         return;
     }
@@ -148,7 +148,7 @@
     /* Let the preview window to lock the buffer. */
     res = mPreviewWindow->lock_buffer(mPreviewWindow, buffer);
     if (res != NO_ERROR) {
-        LOGE("%s: Unable to lock preview window buffer: %d -> %s",
+        ALOGE("%s: Unable to lock preview window buffer: %d -> %s",
              __FUNCTION__, -res, strerror(-res));
         mPreviewWindow->cancel_buffer(mPreviewWindow, buffer);
         return;
@@ -161,7 +161,7 @@
     GraphicBufferMapper& grbuffer_mapper(GraphicBufferMapper::get());
     res = grbuffer_mapper.lock(*buffer, GRALLOC_USAGE_SW_WRITE_OFTEN, rect, &img);
     if (res != NO_ERROR) {
-        LOGE("%s: grbuffer_mapper.lock failure: %d -> %s",
+        ALOGE("%s: grbuffer_mapper.lock failure: %d -> %s",
              __FUNCTION__, res, strerror(res));
         mPreviewWindow->cancel_buffer(mPreviewWindow, buffer);
         return;
@@ -174,7 +174,7 @@
         /* Show it. */
         mPreviewWindow->enqueue_buffer(mPreviewWindow, buffer);
     } else {
-        LOGE("%s: Unable to obtain preview frame: %d", __FUNCTION__, res);
+        ALOGE("%s: Unable to obtain preview frame: %d", __FUNCTION__, res);
         mPreviewWindow->cancel_buffer(mPreviewWindow, buffer);
     }
     grbuffer_mapper.unlock(*buffer);
diff --git a/tools/emulator/system/camera/QemuClient.cpp b/tools/emulator/system/camera/QemuClient.cpp
index fd49585..17e6f98 100755
--- a/tools/emulator/system/camera/QemuClient.cpp
+++ b/tools/emulator/system/camera/QemuClient.cpp
@@ -27,7 +27,7 @@
 
 #define LOG_QUERIES 0
 #if LOG_QUERIES
-#define LOGQ(...)   LOGD(__VA_ARGS__)
+#define LOGQ(...)   ALOGD(__VA_ARGS__)
 #else
 #define LOGQ(...)   (void(0))
 
@@ -86,7 +86,7 @@
 
     /* Query name cannot be NULL or an empty string. */
     if (name == NULL || *name == '\0') {
-        LOGE("%s: NULL or an empty string is passed as query name.",
+        ALOGE("%s: NULL or an empty string is passed as query name.",
              __FUNCTION__);
         mQueryDeliveryStatus = EINVAL;
         return EINVAL;
@@ -100,7 +100,7 @@
         /* Preallocated buffer was too small. Allocate a bigger query buffer. */
         mQuery = new char[required];
         if (mQuery == NULL) {
-            LOGE("%s: Unable to allocate %d bytes for query buffer",
+            ALOGE("%s: Unable to allocate %d bytes for query buffer",
                  __FUNCTION__, required);
             mQueryDeliveryStatus = ENOMEM;
             return ENOMEM;
@@ -131,7 +131,7 @@
      * with a ':'. If there is no more data in the reply, the prefix will be
      * zero-terminated, and the terminator will be inculded in the reply. */
     if (mReplyBuffer == NULL || mReplySize < 3) {
-        LOGE("%s: Invalid reply to the query", __FUNCTION__);
+        ALOGE("%s: Invalid reply to the query", __FUNCTION__);
         mQueryDeliveryStatus = EINVAL;
         return EINVAL;
     }
@@ -142,7 +142,7 @@
     } else if (!memcmp(mReplyBuffer, "ko", 2)) {
         mReplyStatus = 0;
     } else {
-        LOGE("%s: Invalid query reply: '%s'", __FUNCTION__, mReplyBuffer);
+        ALOGE("%s: Invalid query reply: '%s'", __FUNCTION__, mReplyBuffer);
         mQueryDeliveryStatus = EINVAL;
         return EINVAL;
     }
@@ -152,7 +152,7 @@
         /* There are extra data. Make sure they are separated from the status
          * with a ':' */
         if (mReplyBuffer[2] != ':') {
-            LOGE("%s: Invalid query reply: '%s'", __FUNCTION__, mReplyBuffer);
+            ALOGE("%s: Invalid query reply: '%s'", __FUNCTION__, mReplyBuffer);
             mQueryDeliveryStatus = EINVAL;
             return EINVAL;
         }
@@ -162,7 +162,7 @@
         /* Make sure reply buffer containing just 'ok'/'ko' ends with
          * zero-terminator. */
         if (mReplyBuffer[2] != '\0') {
-            LOGE("%s: Invalid query reply: '%s'", __FUNCTION__, mReplyBuffer);
+            ALOGE("%s: Invalid query reply: '%s'", __FUNCTION__, mReplyBuffer);
             mQueryDeliveryStatus = EINVAL;
             return EINVAL;
         }
@@ -212,11 +212,11 @@
 
 status_t QemuClient::connectClient(const char* param)
 {
-    LOGV("%s: '%s'", __FUNCTION__, param ? param : "");
+    ALOGV("%s: '%s'", __FUNCTION__, param ? param : "");
 
     /* Make sure that client is not connected already. */
     if (mPipeFD >= 0) {
-        LOGE("%s: Qemu client is already connected", __FUNCTION__);
+        ALOGE("%s: Qemu client is already connected", __FUNCTION__);
         return EINVAL;
     }
 
@@ -237,7 +237,7 @@
         delete[] connection_str;
     }
     if (mPipeFD < 0) {
-        LOGE("%s: Unable to connect to the camera service '%s': %s",
+        ALOGE("%s: Unable to connect to the camera service '%s': %s",
              __FUNCTION__, param ? param : "Factory", strerror(errno));
         return errno ? errno : EINVAL;
     }
@@ -247,7 +247,7 @@
 
 void QemuClient::disconnectClient()
 {
-    LOGV("%s", __FUNCTION__);
+    ALOGV("%s", __FUNCTION__);
 
     if (mPipeFD >= 0) {
         close(mPipeFD);
@@ -258,7 +258,7 @@
 status_t QemuClient::sendMessage(const void* data, size_t data_size)
 {
     if (mPipeFD < 0) {
-        LOGE("%s: Qemu client is not connected", __FUNCTION__);
+        ALOGE("%s: Qemu client is not connected", __FUNCTION__);
         return EINVAL;
     }
 
@@ -270,7 +270,7 @@
     if (written == data_size) {
         return NO_ERROR;
     } else {
-        LOGE("%s: Error sending data via qemu pipe: '%s'",
+        ALOGE("%s: Error sending data via qemu pipe: '%s'",
              __FUNCTION__, strerror(errno));
         return errno ? errno : EIO;
     }
@@ -282,7 +282,7 @@
     *data_size = 0;
 
     if (mPipeFD < 0) {
-        LOGE("%s: Qemu client is not connected", __FUNCTION__);
+        ALOGE("%s: Qemu client is not connected", __FUNCTION__);
         return EINVAL;
     }
 
@@ -294,7 +294,7 @@
     char payload_size_str[9];
     int rd_res = qemud_fd_read(mPipeFD, payload_size_str, 8);
     if (rd_res != 8) {
-        LOGE("%s: Unable to obtain payload size: %s",
+        ALOGE("%s: Unable to obtain payload size: %s",
              __FUNCTION__, strerror(errno));
         return errno ? errno : EIO;
     }
@@ -304,14 +304,14 @@
     payload_size_str[8] = '\0';
     payload_size = strtol(payload_size_str, NULL, 16);
     if (errno) {
-        LOGE("%s: Invalid payload size '%s'", __FUNCTION__, payload_size_str);
+        ALOGE("%s: Invalid payload size '%s'", __FUNCTION__, payload_size_str);
         return EIO;
     }
 
     /* Allocate payload data buffer, and read the payload there. */
     *data = malloc(payload_size);
     if (*data == NULL) {
-        LOGE("%s: Unable to allocate %d bytes payload buffer",
+        ALOGE("%s: Unable to allocate %d bytes payload buffer",
              __FUNCTION__, payload_size);
         return ENOMEM;
     }
@@ -320,7 +320,7 @@
         *data_size = payload_size;
         return NO_ERROR;
     } else {
-        LOGE("%s: Read size %d doesnt match expected payload size %d: %s",
+        ALOGE("%s: Read size %d doesnt match expected payload size %d: %s",
              __FUNCTION__, rd_res, payload_size, strerror(errno));
         free(*data);
         *data = NULL;
@@ -332,7 +332,7 @@
 {
     /* Make sure that query has been successfuly constructed. */
     if (query->mQueryDeliveryStatus != NO_ERROR) {
-        LOGE("%s: Query is invalid", __FUNCTION__);
+        ALOGE("%s: Query is invalid", __FUNCTION__);
         return query->mQueryDeliveryStatus;
     }
 
@@ -348,17 +348,17 @@
             LOGQ("Response to query '%s': Status = '%.2s', %d bytes in response",
                  query->mQuery, query->mReplyBuffer, query->mReplySize);
         } else {
-            LOGE("%s Response to query '%s' has failed: %s",
+            ALOGE("%s Response to query '%s' has failed: %s",
                  __FUNCTION__, query->mQuery, strerror(res));
         }
     } else {
-        LOGE("%s: Send query '%s' failed: %s",
+        ALOGE("%s: Send query '%s' failed: %s",
              __FUNCTION__, query->mQuery, strerror(res));
     }
 
     /* Complete the query, and return its completion handling status. */
     const status_t res1 = query->completeQuery(res);
-    LOGE_IF(res1 != NO_ERROR && res1 != res,
+    ALOGE_IF(res1 != NO_ERROR && res1 != res,
             "%s: Error %d in query '%s' completion",
             __FUNCTION__, res1, query->mQuery);
     return res1;
@@ -386,18 +386,18 @@
 
 status_t FactoryQemuClient::listCameras(char** list)
 {
-    LOGV("%s", __FUNCTION__);
+    ALOGV("%s", __FUNCTION__);
 
     QemuQuery query(mQueryList);
     if (doQuery(&query) || !query.isQuerySucceeded()) {
-        LOGE("%s: List cameras query failed: %s", __FUNCTION__,
+        ALOGE("%s: List cameras query failed: %s", __FUNCTION__,
              query.mReplyData ? query.mReplyData : "No error message");
         return query.getCompletionStatus();
     }
 
     /* Make sure there is a list returned. */
     if (query.mReplyDataSize == 0) {
-        LOGE("%s: No camera list is returned.", __FUNCTION__);
+        ALOGE("%s: No camera list is returned.", __FUNCTION__);
         return EINVAL;
     }
 
@@ -405,10 +405,10 @@
     *list = (char*)malloc(query.mReplyDataSize);
     if (*list != NULL) {
         memcpy(*list, query.mReplyData, query.mReplyDataSize);
-        LOGD("Emulated camera list: %s", *list);
+        ALOGD("Emulated camera list: %s", *list);
         return NO_ERROR;
     } else {
-        LOGE("%s: Unable to allocate %d bytes",
+        ALOGE("%s: Unable to allocate %d bytes",
              __FUNCTION__, query.mReplyDataSize);
         return ENOMEM;
     }
@@ -445,12 +445,12 @@
 
 status_t CameraQemuClient::queryConnect()
 {
-    LOGV("%s", __FUNCTION__);
+    ALOGV("%s", __FUNCTION__);
 
     QemuQuery query(mQueryConnect);
     doQuery(&query);
     const status_t res = query.getCompletionStatus();
-    LOGE_IF(res != NO_ERROR, "%s: Query failed: %s",
+    ALOGE_IF(res != NO_ERROR, "%s: Query failed: %s",
             __FUNCTION__, query.mReplyData ? query.mReplyData :
                                              "No error message");
     return res;
@@ -458,12 +458,12 @@
 
 status_t CameraQemuClient::queryDisconnect()
 {
-    LOGV("%s", __FUNCTION__);
+    ALOGV("%s", __FUNCTION__);
 
     QemuQuery query(mQueryDisconnect);
     doQuery(&query);
     const status_t res = query.getCompletionStatus();
-    LOGE_IF(res != NO_ERROR, "%s: Query failed: %s",
+    ALOGE_IF(res != NO_ERROR, "%s: Query failed: %s",
             __FUNCTION__, query.mReplyData ? query.mReplyData :
                                              "No error message");
     return res;
@@ -473,7 +473,7 @@
                                       int width,
                                       int height)
 {
-    LOGV("%s", __FUNCTION__);
+    ALOGV("%s", __FUNCTION__);
 
     char query_str[256];
     snprintf(query_str, sizeof(query_str), "%s dim=%dx%d pix=%d",
@@ -481,7 +481,7 @@
     QemuQuery query(query_str);
     doQuery(&query);
     const status_t res = query.getCompletionStatus();
-    LOGE_IF(res != NO_ERROR, "%s: Query failed: %s",
+    ALOGE_IF(res != NO_ERROR, "%s: Query failed: %s",
             __FUNCTION__, query.mReplyData ? query.mReplyData :
                                              "No error message");
     return res;
@@ -489,12 +489,12 @@
 
 status_t CameraQemuClient::queryStop()
 {
-    LOGV("%s", __FUNCTION__);
+    ALOGV("%s", __FUNCTION__);
 
     QemuQuery query(mQueryStop);
     doQuery(&query);
     const status_t res = query.getCompletionStatus();
-    LOGE_IF(res != NO_ERROR, "%s: Query failed: %s",
+    ALOGE_IF(res != NO_ERROR, "%s: Query failed: %s",
             __FUNCTION__, query.mReplyData ? query.mReplyData :
                                              "No error message");
     return res;
@@ -503,19 +503,24 @@
 status_t CameraQemuClient::queryFrame(void* vframe,
                                       void* pframe,
                                       size_t vframe_size,
-                                      size_t pframe_size)
+                                      size_t pframe_size,
+                                      float r_scale,
+                                      float g_scale,
+                                      float b_scale,
+                                      float exposure_comp)
 {
-    LOGV("%s", __FUNCTION__);
+    ALOGV("%s", __FUNCTION__);
 
     char query_str[256];
-    snprintf(query_str, sizeof(query_str), "%s video=%d preview=%d",
+    snprintf(query_str, sizeof(query_str), "%s video=%d preview=%d whiteb=%g,%g,%g expcomp=%g",
              mQueryFrame, (vframe && vframe_size) ? vframe_size : 0,
-                           (pframe && pframe_size) ? pframe_size : 0);
+             (pframe && pframe_size) ? pframe_size : 0, r_scale, g_scale, b_scale,
+             exposure_comp);
     QemuQuery query(query_str);
     doQuery(&query);
     const status_t res = query.getCompletionStatus();
     if( res != NO_ERROR) {
-        LOGE("%s: Query failed: %s",
+        ALOGE("%s: Query failed: %s",
              __FUNCTION__, query.mReplyData ? query.mReplyData :
                                               "No error message");
         return res;
@@ -531,7 +536,7 @@
             memcpy(vframe, frame, vframe_size);
             cur_offset += vframe_size;
         } else {
-            LOGE("%s: Reply %d bytes is to small to contain %d bytes video frame",
+            ALOGE("%s: Reply %d bytes is to small to contain %d bytes video frame",
                  __FUNCTION__, query.mReplyDataSize - cur_offset, vframe_size);
             return EINVAL;
         }
@@ -542,7 +547,7 @@
             memcpy(pframe, frame + cur_offset, pframe_size);
             cur_offset += pframe_size;
         } else {
-            LOGE("%s: Reply %d bytes is to small to contain %d bytes preview frame",
+            ALOGE("%s: Reply %d bytes is to small to contain %d bytes preview frame",
                  __FUNCTION__, query.mReplyDataSize - cur_offset, pframe_size);
             return EINVAL;
         }
diff --git a/tools/emulator/system/camera/QemuClient.h b/tools/emulator/system/camera/QemuClient.h
index c0b8e61..1644321 100755
--- a/tools/emulator/system/camera/QemuClient.h
+++ b/tools/emulator/system/camera/QemuClient.h
@@ -401,13 +401,19 @@
      *  pframe, pframe_size - Define buffer, allocated to receive a preview frame.
      *      Any of these parameters can be 0, indicating that the caller is
      *      interested only in video frame.
+     *  r_scale, g_scale, b_scale - White balance scale.
+     *  exposure_comp - Expsoure compensation.
      * Return:
      *  NO_ERROR on success, or an appropriate error status on failure.
      */
     status_t queryFrame(void* vframe,
                         void* pframe,
                         size_t vframe_size,
-                        size_t pframe_size);
+                        size_t pframe_size,
+                        float r_scale,
+                        float g_scale,
+                        float b_scale,
+                        float exposure_comp);
 
     /****************************************************************************
      * Names of the queries available for the emulated camera.
diff --git a/tools/emulator/system/camera/media_codecs.xml b/tools/emulator/system/camera/media_codecs.xml
new file mode 100644
index 0000000..53f27c1
--- /dev/null
+++ b/tools/emulator/system/camera/media_codecs.xml
@@ -0,0 +1,99 @@
+<?xml version="1.0" encoding="utf-8" ?>
+<!-- Copyright (C) 2012 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.
+-->
+
+<!--
+<!DOCTYPE MediaCodecs [
+<!ELEMENT MediaCodecs (Decoders,Encoders)>
+<!ELEMENT Decoders (MediaCodec*)>
+<!ELEMENT Encoders (MediaCodec*)>
+<!ELEMENT MediaCodec (Type*,Quirk*)>
+<!ATTLIST MediaCodec name CDATA #REQUIRED>
+<!ATTLIST MediaCodec type CDATA>
+<!ELEMENT Type EMPTY>
+<!ATTLIST Type name CDATA #REQUIRED>
+<!ELEMENT Quirk EMPTY>
+<!ATTLIST Quirk name CDATA #REQUIRED>
+]>
+
+There's a simple and a complex syntax to declare the availability of a
+media codec:
+
+A codec that properly follows the OpenMax spec and therefore doesn't have any
+quirks and that only supports a single content type can be declared like so:
+
+    <MediaCodec name="OMX.foo.bar" type="something/interesting" />
+
+If a codec has quirks OR supports multiple content types, the following syntax
+can be used:
+
+    <MediaCodec name="OMX.foo.bar" >
+        <Type name="something/interesting" />
+        <Type name="something/else" />
+        ...
+        <Quirk name="requires-allocate-on-input-ports" />
+        <Quirk name="requires-allocate-on-output-ports" />
+        <Quirk name="output-buffers-are-unreadable" />
+    </MediaCodec>
+
+Only the three quirks included above are recognized at this point:
+
+"requires-allocate-on-input-ports"
+    must be advertised if the component does not properly support specification
+    of input buffers using the OMX_UseBuffer(...) API but instead requires
+    OMX_AllocateBuffer to be used.
+
+"requires-allocate-on-output-ports"
+    must be advertised if the component does not properly support specification
+    of output buffers using the OMX_UseBuffer(...) API but instead requires
+    OMX_AllocateBuffer to be used.
+
+"output-buffers-are-unreadable"
+    must be advertised if the emitted output buffers of a decoder component
+    are not readable, i.e. use a custom format even though abusing one of
+    the official OMX colorspace constants.
+    Clients of such decoders will not be able to access the decoded data,
+    naturally making the component much less useful. The only use for
+    a component with this quirk is to render the output to the screen.
+    Audio decoders MUST NOT advertise this quirk.
+    Video decoders that advertise this quirk must be accompanied by a
+    corresponding color space converter for thumbnail extraction,
+    matching surfaceflinger support that can render the custom format to
+    a texture and possibly other code, so just DON'T USE THIS QUIRK.
+
+-->
+
+<MediaCodecs>
+    <Decoders>
+        <MediaCodec name="OMX.google.mp3.decoder" type="audio/mpeg" />
+        <MediaCodec name="OMX.google.amrnb.decoder" type="audio/3gpp" />
+        <MediaCodec name="OMX.google.amrwb.decoder" type="audio/amr-wb" />
+        <MediaCodec name="OMX.google.aac.decoder" type="audio/mp4a-latm" />
+        <MediaCodec name="OMX.google.g711.alaw.decoder" type="audio/g711-alaw" />
+        <MediaCodec name="OMX.google.g711.mlaw.decoder" type="audio/g711-mlaw" />
+        <MediaCodec name="OMX.google.vorbis.decoder" type="audio/vorbis" />
+
+        <MediaCodec name="OMX.google.mpeg4.decoder" type="video/mp4v-es" />
+        <MediaCodec name="OMX.google.h263.decoder" type="video/3gpp" />
+        <MediaCodec name="OMX.google.h264.decoder" type="video/avc" />
+        <MediaCodec name="OMX.google.vpx.decoder" type="video/x-vnd.on2.vp8" />
+    </Decoders>
+
+    <Encoders>
+        <MediaCodec name="OMX.google.amrnb.encoder" type="audio/3gpp" />
+        <MediaCodec name="OMX.google.amrwb.encoder" type="audio/amr-wb" />
+        <MediaCodec name="OMX.google.aac.encoder" type="audio/mp4a-latm" />
+    </Encoders>
+</MediaCodecs>
diff --git a/tools/emulator/system/gps/gps_qemu.c b/tools/emulator/system/gps/gps_qemu.c
index a4699d3..eebe8d6 100644
--- a/tools/emulator/system/gps/gps_qemu.c
+++ b/tools/emulator/system/gps/gps_qemu.c
@@ -42,7 +42,7 @@
 #define  GPS_DEBUG  0
 
 #if GPS_DEBUG
-#  define  D(...)   LOGD(__VA_ARGS__)
+#  define  D(...)   ALOGD(__VA_ARGS__)
 #else
 #  define  D(...)   ((void)0)
 #endif
@@ -686,13 +686,13 @@
         nevents = epoll_wait( epoll_fd, events, 2, -1 );
         if (nevents < 0) {
             if (errno != EINTR)
-                LOGE("epoll_wait() unexpected error: %s", strerror(errno));
+                ALOGE("epoll_wait() unexpected error: %s", strerror(errno));
             continue;
         }
         D("gps thread received %d events", nevents);
         for (ne = 0; ne < nevents; ne++) {
             if ((events[ne].events & (EPOLLERR|EPOLLHUP)) != 0) {
-                LOGE("EPOLLERR or EPOLLHUP after epoll_wait() !?");
+                ALOGE("EPOLLERR or EPOLLHUP after epoll_wait() !?");
                 return;
             }
             if ((events[ne].events & EPOLLIN) != 0) {
@@ -738,7 +738,7 @@
                             if (errno == EINTR)
                                 continue;
                             if (errno != EWOULDBLOCK)
-                                LOGE("error while reading from gps daemon socket: %s:", strerror(errno));
+                                ALOGE("error while reading from gps daemon socket: %s:", strerror(errno));
                             break;
                         }
                         D("received %d bytes: %.*s", ret, ret, buff);
@@ -749,7 +749,7 @@
                 }
                 else
                 {
-                    LOGE("epoll_wait() returned unkown fd %d ?", fd);
+                    ALOGE("epoll_wait() returned unkown fd %d ?", fd);
                 }
             }
         }
@@ -775,14 +775,14 @@
     D("gps emulation will read from '%s' qemud channel", QEMU_CHANNEL_NAME );
 
     if ( socketpair( AF_LOCAL, SOCK_STREAM, 0, state->control ) < 0 ) {
-        LOGE("could not create thread control socket pair: %s", strerror(errno));
+        ALOGE("could not create thread control socket pair: %s", strerror(errno));
         goto Fail;
     }
 
     state->thread = callbacks->create_thread_cb( "gps_state_thread", gps_state_thread, state );
 
     if ( !state->thread ) {
-        LOGE("could not create gps thread: %s", strerror(errno));
+        ALOGE("could not create gps thread: %s", strerror(errno));
         goto Fail;
     }
 
@@ -930,7 +930,7 @@
     .open = open_gps
 };
 
-const struct hw_module_t HAL_MODULE_INFO_SYM = {
+struct hw_module_t HAL_MODULE_INFO_SYM = {
     .tag = HARDWARE_MODULE_TAG,
     .version_major = 1,
     .version_minor = 0,
diff --git a/tools/emulator/system/lights/lights_qemu.c b/tools/emulator/system/lights/lights_qemu.c
index d6576a0..94fe8cc 100644
--- a/tools/emulator/system/lights/lights_qemu.c
+++ b/tools/emulator/system/lights/lights_qemu.c
@@ -44,12 +44,12 @@
 /* Set to 1 to enable debug messages to the log */
 #define DEBUG 0
 #if DEBUG
-# define D(...) LOGD(__VA_ARGS__)
+# define D(...) ALOGD(__VA_ARGS__)
 #else
 # define D(...) do{}while(0)
 #endif
 
-#define  E(...)  LOGE(__VA_ARGS__)
+#define  E(...)  ALOGE(__VA_ARGS__)
 
 /* Get brightness(0~255) from state. */
 static int
@@ -202,7 +202,7 @@
 /*
  * The emulator lights Module
  */
-const struct hw_module_t HAL_MODULE_INFO_SYM = {
+struct hw_module_t HAL_MODULE_INFO_SYM = {
     .tag = HARDWARE_MODULE_TAG,
     .version_major = 1,
     .version_minor = 0,
diff --git a/tools/emulator/system/qemu-props/qemu-props.c b/tools/emulator/system/qemu-props/qemu-props.c
index 3f086a1..56d510f 100644
--- a/tools/emulator/system/qemu-props/qemu-props.c
+++ b/tools/emulator/system/qemu-props/qemu-props.c
@@ -28,7 +28,7 @@
 
 #if DEBUG
 #  include <cutils/log.h>
-#  define  DD(...)    LOGI(__VA_ARGS__)
+#  define  DD(...)    ALOGI(__VA_ARGS__)
 #else
 #  define  DD(...)    ((void)0)
 #endif
diff --git a/tools/emulator/system/qemud/qemud.c b/tools/emulator/system/qemud/qemud.c
index dc04de8..e836376 100644
--- a/tools/emulator/system/qemud/qemud.c
+++ b/tools/emulator/system/qemud/qemud.c
@@ -87,7 +87,7 @@
 #if DEBUG
 #  define LOG_TAG  "qemud"
 #  include <cutils/log.h>
-#  define  D(...)   LOGD(__VA_ARGS__)
+#  define  D(...)   ALOGD(__VA_ARGS__)
 #else
 #  define  D(...)  ((void)0)
 #  define  T(...)  ((void)0)
diff --git a/tools/emulator/system/sensors/sensors_qemu.c b/tools/emulator/system/sensors/sensors_qemu.c
index 9a776c7..d2c5aa5 100644
--- a/tools/emulator/system/sensors/sensors_qemu.c
+++ b/tools/emulator/system/sensors/sensors_qemu.c
@@ -39,12 +39,12 @@
 #include <hardware/sensors.h>
 
 #if 0
-#define  D(...)  LOGD(__VA_ARGS__)
+#define  D(...)  ALOGD(__VA_ARGS__)
 #else
 #define  D(...)  ((void)0)
 #endif
 
-#define  E(...)  LOGE(__VA_ARGS__)
+#define  E(...)  ALOGE(__VA_ARGS__)
 
 #include <hardware/qemud.h>
 
@@ -206,7 +206,7 @@
 }
 
 static int
-control__close(struct hw_device_t *dev) 
+control__close(struct hw_device_t *dev)
 {
     SensorPoll*  ctl = (void*)dev;
     close(ctl->fd);
@@ -281,7 +281,7 @@
             return i;
         }
     }
-    LOGE("No sensor to return!!! pendingSensors=%08x", data->pendingSensors);
+    ALOGE("No sensor to return!!! pendingSensors=%08x", data->pendingSensors);
     // we may end-up in a busy loop, slow things down, just in case.
     usleep(100000);
     return -EINVAL;
@@ -350,7 +350,7 @@
         }
 
         /* "temperature:<celsius>" */
-        if (sscanf(buff, "temperature:%g", params+0) == 2) {
+        if (sscanf(buff, "temperature:%g", params+0) == 1) {
             new_sensors |= SENSORS_TEMPERATURE;
             data->sensors[ID_TEMPERATURE].temperature = params[0];
             continue;
@@ -397,12 +397,12 @@
 }
 
 static int
-data__close(struct hw_device_t *dev) 
+data__close(struct hw_device_t *dev)
 {
     SensorPoll* data = (SensorPoll*)dev;
     if (data) {
         if (data->events_fd >= 0) {
-            //LOGD("(device close) about to close fd=%d", data->events_fd);
+            //ALOGD("(device close) about to close fd=%d", data->events_fd);
             close(data->events_fd);
         }
         free(data);
@@ -545,7 +545,7 @@
 static struct sensor_t  sSensorList[MAX_NUM_SENSORS];
 
 static int sensors__get_sensors_list(struct sensors_module_t* module,
-        struct sensor_t const** list) 
+        struct sensor_t const** list)
 {
     int  fd = qemud_channel_open(SENSORS_SERVICE_NAME);
     char buffer[12];
@@ -623,7 +623,7 @@
     .open = open_sensors
 };
 
-const struct sensors_module_t HAL_MODULE_INFO_SYM = {
+struct sensors_module_t HAL_MODULE_INFO_SYM = {
     .common = {
         .tag = HARDWARE_MODULE_TAG,
         .version_major = 1,
diff --git a/tools/etc1tool/Android.mk b/tools/etc1tool/Android.mk
index a66af25..c51d47c 100644
--- a/tools/etc1tool/Android.mk
+++ b/tools/etc1tool/Android.mk
@@ -17,8 +17,6 @@
 #LOCAL_WHOLE_STATIC_LIBRARIES := 
 LOCAL_STATIC_LIBRARIES := \
 	libhost \
-	libutils \
-	libcutils \
 	libexpat \
 	libpng \
 	libETC1
diff --git a/tools/findunused/findunusedresources b/tools/findunused/findunusedresources
index 84c0f82..6db99d5 100755
--- a/tools/findunused/findunusedresources
+++ b/tools/findunused/findunusedresources
@@ -35,6 +35,7 @@
     if [ -d $app/res ]
     then
         appname=$(basename $app)
+        iappname=$(grep LOCAL_PACKAGE_NAME $app/Android.mk | sed 's/.*:= *//')
         resources=
         for res in $(echo $app/res/* $(find $ANDROID_BUILD_TOP/vendor -type d -wholename $ANDROID_BUILD_TOP/vendor/*/$appname/res | grep overlay))
         do
@@ -51,7 +52,7 @@
         fi
 
         # find the R.java file that contains all the generated resource identifiers
-        rDotJava=$(find $ANDROID_BUILD_TOP/out/target/common/obj/APPS/${appname}_intermediates/ -name R.java)
+        rDotJava=$(find $ANDROID_BUILD_TOP/out/target/common/obj/APPS/${iappname}_intermediates/ -name R.java)
 
         # Simplistically process the content of the file to get the names of all the constants,
         # and try to find a reference to each constant.
diff --git a/tools/glesv2debugger/.classpath b/tools/glesv2debugger/.classpath
deleted file mode 100755
index 4ba3585..0000000
--- a/tools/glesv2debugger/.classpath
+++ /dev/null
@@ -1,11 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<classpath>
-	<classpathentry kind="lib" path="lib/sdklib.jar"/>
-	<classpathentry kind="lib" path="lib/liblzf.jar"/>
-	<classpathentry kind="lib" path="lib/host-libprotobuf-java-2.3.0-lite.jar"/>
-	<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.6"/>
-	<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
-	<classpathentry kind="src" path="src"/>
-	<classpathentry kind="src" path="test"/>
-	<classpathentry kind="output" path="bin"/>
-</classpath>
diff --git a/tools/glesv2debugger/.gitignore b/tools/glesv2debugger/.gitignore
deleted file mode 100644
index 574bfc7..0000000
--- a/tools/glesv2debugger/.gitignore
+++ /dev/null
@@ -1,4 +0,0 @@
-lib/*.jar
-bin/*
-.settings/*
-
diff --git a/tools/glesv2debugger/.project b/tools/glesv2debugger/.project
deleted file mode 100755
index 0c974ca..0000000
--- a/tools/glesv2debugger/.project
+++ /dev/null
@@ -1,28 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<projectDescription>
-	<name>GLESv2DebuggerClient</name>
-	<comment></comment>
-	<projects>
-	</projects>
-	<buildSpec>
-		<buildCommand>
-			<name>org.eclipse.jdt.core.javabuilder</name>
-			<arguments>
-			</arguments>
-		</buildCommand>
-		<buildCommand>
-			<name>org.eclipse.pde.ManifestBuilder</name>
-			<arguments>
-			</arguments>
-		</buildCommand>
-		<buildCommand>
-			<name>org.eclipse.pde.SchemaBuilder</name>
-			<arguments>
-			</arguments>
-		</buildCommand>
-	</buildSpec>
-	<natures>
-		<nature>org.eclipse.pde.PluginNature</nature>
-		<nature>org.eclipse.jdt.core.javanature</nature>
-	</natures>
-</projectDescription>
diff --git a/tools/glesv2debugger/META-INF/MANIFEST.MF b/tools/glesv2debugger/META-INF/MANIFEST.MF
deleted file mode 100644
index cf42bdb..0000000
--- a/tools/glesv2debugger/META-INF/MANIFEST.MF
+++ /dev/null
@@ -1,15 +0,0 @@
-Manifest-Version: 1.0
-Bundle-ManifestVersion: 2
-Bundle-Name: GLESv2DebuggerClient
-Bundle-SymbolicName: GLESv2DebuggerClient; singleton:=true
-Bundle-Version: 1.0.0.qualifier
-Bundle-Activator: com.android.glesv2debugger.Activator
-Require-Bundle: org.eclipse.ui,
- org.eclipse.core.runtime,
- org.junit
-Bundle-ActivationPolicy: lazy
-Bundle-RequiredExecutionEnvironment: JavaSE-1.6
-Bundle-ClassPath: lib/host-libprotobuf-java-2.3.0-lite.jar,
- lib/liblzf.jar,
- lib/sdklib.jar,
- .
diff --git a/tools/glesv2debugger/README.android b/tools/glesv2debugger/README.android
deleted file mode 100644
index ae95463..0000000
--- a/tools/glesv2debugger/README.android
+++ /dev/null
@@ -1,20 +0,0 @@
-The following is taken from slide 3 & 4 of https://docs.google.com/a/google.com/present/edit?id=0AcZLV3icFYi0ZGZxa3NqZndfMGRqa2tiOXB4&authkey=CMfb8ukI&hl=en
-The spec doc is at https://docs.google.com/a/google.com/document/d/1dsASXCF9Suq8KOGcxwB2mAwgdRlrFj4QhMxkfaRJlA0/edit?hl=en&authkey=CPj4tKkO#
-
-
-Building and Running
-
-Debugger server is linked into EGL, code is in framework/base/opengl/libs/GLES2_dbg and already included in latest master builds, no action needed.
-Use development/tools/glesv2debugger/setup.sh to build and copy the jars: libprotobuf-java-2.3.0-lite, liblzf, sdklib into development/tools/glesv2debugger/lib
-Install Eclipse SDK for Eclipse: Eclipse->Help->Install New Software. Select "All Available Sites" in the "Work with:" drop down, then find "Eclipse SDK". (If Eclipse reports dependency conflicts, try install updates first)
-Debugger client is an Eclipse plug-in, code is at development/tools/glesv2debugger, built in Eclipse
-Optional: build glsl_compiler and copy to plug-in working directory; this is used for shader syntax check
-
-
-"Attaching" to a Process
-
-adb shell setprop debug.egl.debug_proc <process name> before running process. ie: com.example.android.apis
-EGL checks /proc/<proc_id>/cmdline for match during init and sets debug functions in eglMakeCurrent
-EGL will bind to socket and wait for incoming connection, so need to adb forward tcp:5039 tcp:5039. Port can be overridden by adb shell setprop debug.egl.debug_port <port>
-If create socket failed, EGL will try to open /data/local/tmp/dump.gles2dbg for write, and exit when 8MB is written. The relevant properties are ...debug_forceUseFile, ...debug_maxFileSize, and ...debug_filePath
-Now manually start the process on device; on host, open development/tools/glesv2debugger/.project and run/debug as Eclipse application, then Window->Show View->Other->Debug->OpenGL ES 2.0 Debugger, then Connect or Open File
diff --git a/tools/glesv2debugger/build.properties b/tools/glesv2debugger/build.properties
deleted file mode 100644
index 39d82d2..0000000
--- a/tools/glesv2debugger/build.properties
+++ /dev/null
@@ -1,11 +0,0 @@
-source.. = src/,\

-           test/

-output.. = bin/

-bin.includes = plugin.xml,\

-               META-INF/,\

-               .,\

-               icons/,\
-               contexts.xml,\
-               lib/host-libprotobuf-java-2.3.0-lite.jar,\
-               lib/liblzf.jar,\
-               lib/sdklib.jar
diff --git a/tools/glesv2debugger/contexts.xml b/tools/glesv2debugger/contexts.xml
deleted file mode 100644
index 02e26e4..0000000
--- a/tools/glesv2debugger/contexts.xml
+++ /dev/null
@@ -1,12 +0,0 @@
-<contexts>
-	<context id="viewer" title="Sample View">
-		<description>This is the context help for the sample view with a table viewer. It was generated by a PDE template.</description>
-		<topic href="/PLUGINS_ROOT/org.eclipse.platform.doc.isv/guide/ua_help_context.htm" label="Context-sensitive help">
-			<enablement>
-				<with variable="platform">
-	            	<test property="org.eclipse.core.runtime.isBundleInstalled" args="org.eclipse.platform.doc.isv"/>
-	     		</with>
-			</enablement>
-		</topic>
-	</context>
-</contexts>
diff --git a/tools/glesv2debugger/generate_GLEnum_java.py b/tools/glesv2debugger/generate_GLEnum_java.py
deleted file mode 100755
index cf543c8..0000000
--- a/tools/glesv2debugger/generate_GLEnum_java.py
+++ /dev/null
@@ -1,73 +0,0 @@
-#!/usr/bin/python
-# -*- coding: utf-8 -*-
-
-#
-# Copyright 2011, The Android Open Source Project
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-#     http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-#
-
-if __name__ == "__main__":
-    externs = []
-    lines = open("../../../frameworks/base/opengl/libs/enums.in").readlines()
-    output = open("src/com/android/glesv2debugger/GLEnum.java", "w")
-    i = 0
-    output.write(
-"""/*
- ** Copyright 2011, The Android Open Source Project
- **
- ** Licensed under the Apache License, Version 2.0 (the "License");
- ** you may not use this file except in compliance with the License.
- ** You may obtain a copy of the License at
- **
- **     http://www.apache.org/licenses/LICENSE-2.0
- **
- ** Unless required by applicable law or agreed to in writing, software
- ** distributed under the License is distributed on an "AS IS" BASIS,
- ** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- ** See the License for the specific language governing permissions and
- ** limitations under the License.
- */
-
-// auto generated by generate_GLEnum_java.py"
-
-package com.android.glesv2debugger;
-
-public enum GLEnum {
-""")
-    
-    index = 0
-    for line in lines:
-        value = line[line.find("(") + 1: line.find(",")]
-        name = line[line.find(",") + 1: line.find(")")]    
-        output.write("    %s(%s),\n" % (name, value))
-
-    output.write("""    ;
-
-    public final int value;
-    GLEnum(final int value) {
-        this.value = value;
-    }
-
-    private static final java.util.HashMap<Integer, GLEnum> reverseMap = new java.util.HashMap<Integer, GLEnum>();
-    static {
-        for (GLEnum e : GLEnum.values())
-        reverseMap.put(e.value, e);
-    }
-
-    public static GLEnum valueOf(final int value) {
-        return reverseMap.get(value);
-    }
-}""")
-
-
diff --git a/tools/glesv2debugger/generate_MessageFormatter_java.py b/tools/glesv2debugger/generate_MessageFormatter_java.py
deleted file mode 100755
index dfbf2ea..0000000
--- a/tools/glesv2debugger/generate_MessageFormatter_java.py
+++ /dev/null
@@ -1,281 +0,0 @@
-#!/usr/bin/python
-# -*- coding: utf-8 -*-
-
-#
-# Copyright 2011, The Android Open Source Project
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-#     http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-#
-
-import os
-import sys
-
-def RemoveAnnotation(line):
-    if line.find(":") >= 0:
-        annotation = line[line.find(":"): line.find(" ", line.find(":"))]
-        return line.replace(annotation, "*")
-    else:
-        return line
-        
-if __name__ == "__main__":
-    externs = []
-    lines = open("../../../frameworks/base/opengl/libs/GLES2_dbg/gl2_api_annotated.in").readlines()
-    output = open("src/com/android/glesv2debugger/MessageFormatter.java", "w")
-    
-    i = 0
-    output.write(
-"""/*
- ** Copyright 2011, The Android Open Source Project
- **
- ** Licensed under the Apache License, Version 2.0 (the "License");
- ** you may not use this file except in compliance with the License.
- ** You may obtain a copy of the License at
- **
- **     http://www.apache.org/licenses/LICENSE-2.0
- **
- ** Unless required by applicable law or agreed to in writing, software
- ** distributed under the License is distributed on an "AS IS" BASIS,
- ** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- ** See the License for the specific language governing permissions and
- ** limitations under the License.
- */
-
-// auto generated by generate_MessageFormatter_java.py"
-
-package com.android.glesv2debugger;
-
-import java.nio.ByteBuffer;
-
-public class MessageFormatter {
-
-    static String formatFloats(int count, final ByteBuffer data) {
-        if (data.remaining() == 0)
-            return "{}";
-        data.order(SampleView.targetByteOrder);
-        String ret = "{";
-        for (int i = 0; i < count; i++) {
-            ret += Float.intBitsToFloat(data.getInt());
-            if (i < count - 1)
-                ret += ", ";
-        }
-        return ret + "}";
-    }
-
-    static String formatInts(int count, final ByteBuffer data) {
-        if (data.remaining() == 0)
-            return "{}";
-        data.order(SampleView.targetByteOrder);
-        String ret = "{";
-        for (int i = 0; i < count; i++) {
-            ret += data.getInt();
-            if (i < count - 1)
-                ret += ", ";
-        }
-        return ret + "}";
-    }
-
-    static String formatUInts(int count, final ByteBuffer data) {
-        if (data.remaining() == 0)
-            return "{}";
-        data.order(SampleView.targetByteOrder);
-        String ret = "{";
-        for (int i = 0; i < count; i++) {
-            long bits = data.getInt() & 0xffffffff;
-            ret += bits;
-            if (i < count - 1)
-                ret += ", ";
-        }
-        return ret + "}";
-    }
-
-    static String formatMatrix(int columns, int count, final ByteBuffer data) {
-        if (data.remaining() == 0)
-            return "{}";
-        data.order(SampleView.targetByteOrder);
-        String ret = "{";
-        for (int i = 0; i < count; i++) {
-            ret += Float.intBitsToFloat(data.getInt());
-            if (i < count - 1)
-                ret += ", ";
-            if (i % columns == columns - 1)
-                ret += "\\n                                             ";
-        }
-        return ret + "}";
-    }
-
-    public static String format(final DebuggerMessage.Message msg,
-                                final boolean code) {
-        String str;
-        switch (msg.getFunction()) {
-""")
-    #in source code these turn into program_%d etc.
-    nameReplaces = ["program", "shader", "texture", "buffer", "framebuffer", "renderbuffer"]
-    for line in lines:
-        if line.find("API_ENTRY(") >= 0: # a function prototype
-            returnType = line[0: line.find(" API_ENTRY(")].replace("const ", "")
-            functionName = line[line.find("(") + 1: line.find(")")] #extract GL function name
-            parameterList = line[line.find(")(") + 2: line.find(") {")]
-
-            parameters = parameterList.split(',')
-            paramIndex = 0
-
-            formatString = "%s"
-            formatArgs = ""
-            if returnType != "void":
-                if returnType == "GLenum":
-                    formatArgs += '\
-                    (code ? "%s" : GLEnum.valueOf(msg.getRet()))\n' % (functionName)
-                elif returnType.find("*") >= 0:
-                    formatArgs += '\
-                    (code ? "%s" : "0x" + Integer.toHexString(msg.getRet()))\n' % (functionName)
-                else:
-                    formatArgs += '\
-                    (code ? "%s" : msg.getRet())\n' % (functionName)
-            else:
-                formatArgs += '\
-                    (code ? "%s" : "void")\n' % (functionName)
-
-            formatString += "("
-
-            if parameterList == "void":
-                parameters = []
-            inout = ""
-
-            paramNames = []
-
-            for parameter in parameters:
-                parameter = parameter.replace("const","")
-                parameter = parameter.strip()
-                paramType = parameter.split(' ')[0]
-                paramName = parameter.split(' ')[1]
-                annotation = ""
-
-                formatString += "%s%s"
-                formatArgs += '\
-                    , (code ? "/*%s*/ " : "%s=")\n' % (paramName, paramName)
-                if parameter.find(":") >= 0:
-                    assert inout == "" # only one parameter should be annotated
-                    inout = paramType.split(":")[2]
-                    annotation = paramType.split(":")[1]
-                    paramType = paramType.split(":")[0]
-                    count = 1
-                    countArg = ""
-                    if annotation.find("*") >= 0: # [1,n] * param
-                        count = int(annotation.split("*")[0])
-                        countArg = annotation.split("*")[1]
-                        assert countArg in paramNames
-                    elif annotation in paramNames:
-                        count = 1
-                        countArg = annotation
-                    elif annotation == "GLstring":
-                        annotation = annotation
-                    else:
-                        count = int(annotation)
-                    dataFormatter = ""
-                    if paramType == "GLfloat":
-                        dataFormatter = "formatFloats"
-                    elif paramType == "GLint":
-                        dataFormatter = "formatInts"
-                    elif paramType == "GLuint":
-                        dataFormatter = "formatUInts"
-                    elif annotation == "GLstring":
-                        assert paramType == "GLchar"
-                    elif paramType.find("void") >= 0:
-                        assert 1
-                    else:
-                        assert 0
-                    if functionName.find("Matrix") >= 0:
-                        columns = int(functionName[functionName.find("fv") - 1: functionName.find("fv")])
-                        assert columns * columns == count
-                        assert countArg != ""
-                        assert paramType == "GLfloat"
-                        formatArgs += '\
-                    , (code ? "(GLfloat [])" : "") + formatMatrix(%d, %d * msg.getArg%d(), msg.getData().asReadOnlyByteBuffer())' % (
-                        columns, count, paramNames.index(countArg))
-                    elif annotation == "GLstring":
-                        formatArgs += '\
-                    , (code ? "\\"" : "") + msg.getData().toStringUtf8() + (code ? "\\"" : "")'
-                    elif paramType.find("void") >= 0:
-                        formatArgs += '\
-                    , (code ? "arg%d" : "0x" + Integer.toHexString(msg.getArg%d()))' % (paramIndex, paramIndex)
-                    elif countArg == "":
-                        formatArgs += '\
-                    , (code ? "(%s [])" : "") + %s(%d, msg.getData().asReadOnlyByteBuffer())' % (
-                        paramType, dataFormatter, count)
-                    else:
-                        formatArgs += '\
-                    , (code ? "(%s [])" : "") +  %s(%d * msg.getArg%d(), msg.getData().asReadOnlyByteBuffer())' % (
-                        paramType, dataFormatter, count, paramNames.index(countArg))
-                else:
-                    if paramType == "GLfloat" or paramType == "GLclampf":
-                        formatArgs += "\
-                    , Float.intBitsToFloat(msg.getArg%d())" % (paramIndex)
-                    elif paramType == "GLenum": 
-                        formatArgs += "\
-                    , GLEnum.valueOf(msg.getArg%d())" % (paramIndex)
-                    elif paramType.find("*") >= 0:
-                        formatArgs += '\
-                    , (code ? "arg%d" : "0x" + Integer.toHexString(msg.getArg%d()))' % (paramIndex, paramIndex)
-                    elif paramName in nameReplaces:
-                        formatArgs += '\
-                    , (code ? "%s_" : "") + msg.getArg%d()' % (paramName, paramIndex)
-                    else:
-                        formatArgs += "\
-                    , msg.getArg%d()" % (paramIndex)
-                if paramIndex < len(parameters) - 1:
-                    formatString += ", "
-                    formatArgs += '\n'
-                paramNames.append(paramName)
-                paramIndex += 1  
-
-                
-            formatString += ")"
-             
-            output.write("            case %s:\n" % (functionName))
-            if line.find("*") >= 0 and (line.find("*") < line.find(":") or line.find("*") > line.rfind(":")):
-                sys.stderr.write(line)
-                output.write("                // FIXME: this function uses pointers, debugger may send data in msg.data\n")
-            output.write('\
-                str = String.format("%s",\n%s);\n\
-                break;\n' % (formatString, formatArgs))
-
-
-    output.write("""            default:
-                str = msg.toString();
-        }
-        return str;
-    }
-}""")
-
-'''    print """/*
-package GLESv2Debugger;
-
-public class MessageFormatterCustom {
-
-    public static String format(final DebuggerMessage.Message msg) {
-        String str;
-        switch (msg.getFunction()) {"""
-
-    for extern in externs:
-        print "        case %s" % (extern)
-        print "            // TODO:"
-
-print """        default:
-            str = msg.toString();
-        }
-        return str;
-    }
-}
-*/"""    '''
-        
-        
diff --git a/tools/glesv2debugger/generate_MessageParser_java.py b/tools/glesv2debugger/generate_MessageParser_java.py
deleted file mode 100755
index b6e8282..0000000
--- a/tools/glesv2debugger/generate_MessageParser_java.py
+++ /dev/null
@@ -1,304 +0,0 @@
-#!/usr/bin/python
-# -*- coding: utf-8 -*-
-
-#
-# Copyright 2011, The Android Open Source Project
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-#     http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-#
-
-import os
-import sys
-
-def RemoveAnnotation(line):
-    if line.find(":") >= 0:
-        annotation = line[line.find(":"): line.find(" ", line.find(":"))]
-        return line.replace(annotation, "*")
-    else:
-        return line
-
-if __name__ == "__main__":
-    externs = []
-    lines = open("../../../frameworks/base/opengl/libs/GLES2_dbg/gl2_api_annotated.in").readlines()
-    output = open("src/com/android/glesv2debugger/MessageParser.java", "w")
-
-    i = 0
-    output.write("""\
-/*
- ** Copyright 2011, The Android Open Source Project
- **
- ** Licensed under the Apache License, Version 2.0 (the "License");
- ** you may not use this file except in compliance with the License.
- ** You may obtain a copy of the License at
- **
- **     http://www.apache.org/licenses/LICENSE-2.0
- **
- ** Unless required by applicable law or agreed to in writing, software
- ** distributed under the License is distributed on an "AS IS" BASIS,
- ** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- ** See the License for the specific language governing permissions and
- ** limitations under the License.
- */
-
-// auto generated by generate_MessageParser_java.py,
-//  which also prints skeleton code for MessageParserEx.java
-
-package com.android.glesv2debugger;
-
-import com.android.glesv2debugger.DebuggerMessage.Message;
-import com.android.glesv2debugger.DebuggerMessage.Message.Function;
-import com.google.protobuf.ByteString;
-
-import java.nio.ByteBuffer;
-
-public abstract class MessageParser {
-
-    String args;
-
-    String[] getList()
-    {
-        String arg = args;
-        args = args.substring(args.lastIndexOf('}') + 1);
-        final int comma = args.indexOf(',');
-        if (comma >= 0)
-            args = args.substring(comma + 1).trim();
-        else
-            args = null;
-
-        final int comment = arg.indexOf('=');
-        if (comment >= 0)
-            arg = arg.substring(comment + 1);
-        arg = arg.trim();
-        assert arg.charAt(0) == '{';
-        arg = arg.substring(1, arg.lastIndexOf('}')).trim();
-        return arg.split("\\s*,\\s*");
-    }
-
-    ByteString parseFloats(int count) {
-        ByteBuffer buffer = ByteBuffer.allocate(count * 4);
-        buffer.order(SampleView.targetByteOrder);
-        String [] arg = getList();
-        for (int i = 0; i < count; i++)
-            buffer.putFloat(Float.parseFloat(arg[i].trim()));
-        buffer.rewind();
-        return ByteString.copyFrom(buffer);
-    }
-
-    ByteString parseInts(int count) {
-        ByteBuffer buffer = ByteBuffer.allocate(count * 4);
-        buffer.order(SampleView.targetByteOrder);
-        String [] arg = getList();
-        for (int i = 0; i < count; i++)
-            buffer.putInt(Integer.parseInt(arg[i].trim()));
-        buffer.rewind();
-        return ByteString.copyFrom(buffer);
-    }
-
-    ByteString parseUInts(int count) {
-        ByteBuffer buffer = ByteBuffer.allocate(count * 4);
-        buffer.order(SampleView.targetByteOrder);
-        String [] arg = getList();
-        for (int i = 0; i < count; i++)
-            buffer.putInt((int)(Long.parseLong(arg[i].trim()) & 0xffffffff));
-        buffer.rewind();
-        return ByteString.copyFrom(buffer);
-    }
-
-    ByteString parseMatrix(int columns, int count) {
-        return parseFloats(columns * columns * count);
-    }
-
-    ByteString parseString() {
-        // TODO: escape sequence and proper string literal
-        String arg = args.substring(args.indexOf('"') + 1, args.lastIndexOf('"'));
-        args = args.substring(args.lastIndexOf('"'));
-        int comma = args.indexOf(',');
-        if (comma >= 0)
-            args = args.substring(comma + 1).trim();
-        else
-            args = null;
-        return ByteString.copyFromUtf8(arg);
-    }
-
-    String getArgument()
-    {
-        final int comma = args.indexOf(',');
-        String arg = null;
-        if (comma >= 0)
-        {
-            arg = args.substring(0, comma);
-            args = args.substring(comma + 1);
-        }
-        else
-        {
-            arg = args;
-            args = null;
-        }
-        final int comment = arg.indexOf('=');
-        if (comment >= 0)
-            arg = arg.substring(comment + 1);
-        return arg.trim();
-    }
-
-    int parseArgument()
-    {
-        String arg = getArgument();
-        if (arg.startsWith("GL_"))
-            return GLEnum.valueOf(arg).value;
-        else if (arg.toLowerCase().startsWith("0x"))
-            return Integer.parseInt(arg.substring(2), 16);
-        else
-            return Integer.parseInt(arg);
-    }
-
-    int parseFloat()
-    {
-        String arg = getArgument();
-        return Float.floatToRawIntBits(Float.parseFloat(arg));
-    }
-
-    public void parse(final Message.Builder builder, String string) {
-        int lparen = string.indexOf("("), rparen = string.lastIndexOf(")");
-        String s = string.substring(0, lparen).trim();
-        args = string.substring(lparen + 1, rparen);
-        String[] t = s.split(" ");
-        Function function = Function.valueOf(t[t.length - 1]);
-        builder.setFunction(function);
-        switch (function) {
-""")
-
-    abstractParsers = ""
-
-    for line in lines:
-        if line.find("API_ENTRY(") >= 0: # a function prototype
-            returnType = line[0: line.find(" API_ENTRY(")].replace("const ", "")
-            functionName = line[line.find("(") + 1: line.find(")")] #extract GL function name
-            parameterList = line[line.find(")(") + 2: line.find(") {")]
-
-            parameters = parameterList.split(',')
-            paramIndex = 0
-
-            #if returnType != "void":
-            #else:
-
-            if parameterList == "void":
-                parameters = []
-            inout = ""
-
-            paramNames = []
-            abstract = False
-            argumentSetters = ""
-            output.write("\
-            case %s:\n" % (functionName))
-
-            for parameter in parameters:
-                parameter = parameter.replace("const","")
-                parameter = parameter.strip()
-                paramType = parameter.split(' ')[0]
-                paramName = parameter.split(' ')[1]
-                annotation = ""
-
-                argumentParser = ""
-
-                if parameter.find(":") >= 0:
-                    dataSetter = ""
-                    assert inout == "" # only one parameter should be annotated
-                    inout = paramType.split(":")[2]
-                    annotation = paramType.split(":")[1]
-                    paramType = paramType.split(":")[0]
-                    count = 1
-                    countArg = ""
-                    if annotation.find("*") >= 0: # [1,n] * param
-                        count = int(annotation.split("*")[0])
-                        countArg = annotation.split("*")[1]
-                        assert countArg in paramNames
-                    elif annotation in paramNames:
-                        count = 1
-                        countArg = annotation
-                    elif annotation == "GLstring":
-                        annotation = annotation
-                    else:
-                        count = int(annotation)
-
-                    if paramType == "GLfloat":
-                        argumentParser = "parseFloats"
-                    elif paramType == "GLint":
-                        argumentParser = "parseInts"
-                    elif paramType == "GLuint":
-                        argumentParser = "parseUInts"
-                    elif annotation == "GLstring":
-                        assert paramType == 'GLchar'
-                    elif paramType.find("void") >= 0:
-                        assert 1
-                    else:
-                        assert 0
-
-                    if functionName.find('Matrix') >= 0:
-                        columns = int(functionName[functionName.find("fv") - 1: functionName.find("fv")])
-                        assert columns * columns == count
-                        assert countArg != ""
-                        assert paramType == "GLfloat"
-                        dataSetter = "builder.setData(parseMatrix(%d, builder.getArg%d()));" % (
-                            columns, paramNames.index(countArg))
-                    elif annotation == "GLstring":
-                        dataSetter = "builder.setData(parseString());"
-                    elif paramType.find("void") >= 0:
-                        dataSetter = "// TODO"
-                        abstract = True
-                    elif countArg == "":
-                        dataSetter = "builder.setData(%s(%d));" % (argumentParser, count)
-                    else:
-                        dataSetter = "builder.setData(%s(%d * builder.getArg%d()));" % (
-                            argumentParser, count, paramNames.index(countArg))
-                    argumentSetters += "\
-                %s // %s %s\n" % (dataSetter, paramType, paramName)
-                else:
-                    if paramType == "GLfloat" or paramType == "GLclampf":
-                        argumentSetters += "\
-                builder.setArg%d(parseFloat()); // %s %s\n" % (
-                    paramIndex, paramType, paramName)
-                    elif paramType.find("*") >= 0:
-                        argumentSetters += "\
-                // TODO: %s %s\n" % (paramType, paramName)
-                        abstract = True
-                    else:
-                        argumentSetters += "\
-                builder.setArg%d(parseArgument()); // %s %s\n" % (
-                    paramIndex, paramType, paramName)
-                paramNames.append(paramName)
-                paramIndex += 1
-
-            if not abstract:
-                output.write("%s" % argumentSetters)
-            else:
-                output.write("\
-                parse_%s(builder);\n" % functionName)
-                abstractParsers += "\
-    abstract void parse_%s(Message.Builder builder);\n" % functionName
-                print """\
-    @Override
-    void parse_%s(Message.Builder builder) {
-%s    }
-""" % (functionName, argumentSetters) # print skeleton code for MessageParserEx
-
-            output.write("\
-                break;\n")
-    output.write("""\
-            default:
-                assert false;
-        }
-    }
-""")
-    output.write(abstractParsers)
-    output.write("\
-}""")
diff --git a/tools/glesv2debugger/icons/sample.gif b/tools/glesv2debugger/icons/sample.gif
deleted file mode 100644
index 34fb3c9..0000000
--- a/tools/glesv2debugger/icons/sample.gif
+++ /dev/null
Binary files differ
diff --git a/tools/glesv2debugger/plugin.xml b/tools/glesv2debugger/plugin.xml
deleted file mode 100644
index f1512a5..0000000
--- a/tools/glesv2debugger/plugin.xml
+++ /dev/null
@@ -1,34 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>

-<?eclipse version="3.4"?>

-<plugin>

-

-   <extension

-         point="org.eclipse.ui.views">

-      <view

-            name="OpenGL ES 2.0 Debugger"

-            icon="icons/sample.gif"

-            category="org.eclipse.debug.ui"

-            class="com.android.glesv2debugger.SampleView"

-            id="glesv2debuggerclient.views.SampleView">

-      </view>

-   </extension>

-   <extension

-         point="org.eclipse.ui.perspectiveExtensions">

-      <perspectiveExtension

-            targetID="org.eclipse.jdt.ui.JavaPerspective">

-         <view

-               ratio="0.5"

-               relative="org.eclipse.ui.views.TaskList"

-               relationship="right"

-               id="glesv2debuggerclient.views.SampleView">

-         </view>

-      </perspectiveExtension>

-   </extension>

-   <extension

-         point="org.eclipse.help.contexts">

-      <contexts

-            file="contexts.xml">

-      </contexts>

-   </extension>

-

-</plugin>

diff --git a/tools/glesv2debugger/setup.sh b/tools/glesv2debugger/setup.sh
deleted file mode 100755
index 839019d..0000000
--- a/tools/glesv2debugger/setup.sh
+++ /dev/null
@@ -1,35 +0,0 @@
-source ../../../build/envsetup.sh
-pushd ../../../
-
-# need lunch before building jars
-if [ -z "$TARGET_PRODUCT" ]; then
-    lunch
-fi
-
-pushd external/liblzf/
-mm
-popd
-
-pushd external/protobuf/
-mm
-popd
-
-pushd sdk/sdkmanager/libs/sdklib
-mm
-popd
-
-# glsl_compiler is optional
-# make glsl_compiler -j3
-
-popd
-
-mkdir -p lib
-cp "$ANDROID_HOST_OUT/framework/host-libprotobuf-java-2.3.0-lite.jar" lib/
-cp "$ANDROID_HOST_OUT/framework/liblzf.jar" lib/
-cp "$ANDROID_HOST_OUT/framework/sdklib.jar" lib/
-
-# optional; usually for linux
-#cp "$ANDROID_HOST_OUT/bin/glsl_compiler" ~/
-
-# optional; usually for mac, need to replace eclipse.app with actual path
-#cp "$ANDROID_HOST_OUT/bin/glsl_compiler" eclipse.app/Contents/MacOS
diff --git a/tools/glesv2debugger/src/META-INF/MANIFEST.MF b/tools/glesv2debugger/src/META-INF/MANIFEST.MF
deleted file mode 100644
index 212b27a..0000000
--- a/tools/glesv2debugger/src/META-INF/MANIFEST.MF
+++ /dev/null
@@ -1,3 +0,0 @@
-Manifest-Version: 1.0

-Created-By: 1.6.0_22 (Sun Microsystems Inc.)

-

diff --git a/tools/glesv2debugger/src/com/android/glesv2debugger/Activator.java b/tools/glesv2debugger/src/com/android/glesv2debugger/Activator.java
deleted file mode 100644
index 6083c0f..0000000
--- a/tools/glesv2debugger/src/com/android/glesv2debugger/Activator.java
+++ /dev/null
@@ -1,83 +0,0 @@
-/*

- ** Copyright 2011, The Android Open Source Project

- **

- ** Licensed under the Apache License, Version 2.0 (the "License");

- ** you may not use this file except in compliance with the License.

- ** You may obtain a copy of the License at

- **

- **     http://www.apache.org/licenses/LICENSE-2.0

- **

- ** Unless required by applicable law or agreed to in writing, software

- ** distributed under the License is distributed on an "AS IS" BASIS,

- ** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.

- ** See the License for the specific language governing permissions and

- ** limitations under the License.

- */

-

-package com.android.glesv2debugger;

-

-import org.eclipse.jface.resource.ImageDescriptor;

-import org.eclipse.ui.plugin.AbstractUIPlugin;

-import org.osgi.framework.BundleContext;

-

-/**

- * The activator class controls the plug-in life cycle

- */

-public class Activator extends AbstractUIPlugin {

-

-    // The plug-in ID

-    public static final String PLUGIN_ID = "GLESv2DebuggerClient"; //$NON-NLS-1$

-

-    // The shared instance

-    private static Activator plugin;

-

-    /**

-     * The constructor

-     */

-    public Activator() {

-    }

-

-    /*

-     * (non-Javadoc)

-     * @see

-     * org.eclipse.ui.plugin.AbstractUIPlugin#start(org.osgi.framework.BundleContext

-     * )

-     */

-    @Override

-    public void start(BundleContext context) throws Exception {

-        super.start(context);

-        plugin = this;

-    }

-

-    /*

-     * (non-Javadoc)

-     * @see

-     * org.eclipse.ui.plugin.AbstractUIPlugin#stop(org.osgi.framework.BundleContext

-     * )

-     */

-    @Override

-    public void stop(BundleContext context) throws Exception {

-        plugin = null;

-        super.stop(context);

-    }

-

-    /**

-     * Returns the shared instance

-     * 

-     * @return the shared instance

-     */

-    public static Activator getDefault() {

-        return plugin;

-    }

-

-    /**

-     * Returns an image descriptor for the image file at the given plug-in

-     * relative path

-     * 

-     * @param path the path

-     * @return the image descriptor

-     */

-    public static ImageDescriptor getImageDescriptor(String path) {

-        return imageDescriptorFromPlugin(PLUGIN_ID, path);

-    }

-}

diff --git a/tools/glesv2debugger/src/com/android/glesv2debugger/BreakpointOption.java b/tools/glesv2debugger/src/com/android/glesv2debugger/BreakpointOption.java
deleted file mode 100644
index e8405f9..0000000
--- a/tools/glesv2debugger/src/com/android/glesv2debugger/BreakpointOption.java
+++ /dev/null
@@ -1,191 +0,0 @@
-/*
- ** Copyright 2011, The Android Open Source Project
- **
- ** Licensed under the Apache License, Version 2.0 (the "License");
- ** you may not use this file except in compliance with the License.
- ** You may obtain a copy of the License at
- **
- **     http://www.apache.org/licenses/LICENSE-2.0
- **
- ** Unless required by applicable law or agreed to in writing, software
- ** distributed under the License is distributed on an "AS IS" BASIS,
- ** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- ** See the License for the specific language governing permissions and
- ** limitations under the License.
- */
-
-package com.android.glesv2debugger;
-
-import com.android.glesv2debugger.DebuggerMessage.Message;
-import com.android.glesv2debugger.DebuggerMessage.Message.Function;
-import com.android.glesv2debugger.DebuggerMessage.Message.Prop;
-import com.android.glesv2debugger.DebuggerMessage.Message.Type;
-
-import org.eclipse.jface.dialogs.InputDialog;
-import org.eclipse.jface.window.Window;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.custom.ScrolledComposite;
-import org.eclipse.swt.events.SelectionEvent;
-import org.eclipse.swt.events.SelectionListener;
-import org.eclipse.swt.graphics.Point;
-import org.eclipse.swt.layout.FillLayout;
-import org.eclipse.swt.layout.GridLayout;
-import org.eclipse.swt.layout.RowLayout;
-import org.eclipse.swt.widgets.Button;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Group;
-import org.eclipse.swt.widgets.Shell;
-
-import java.io.IOException;
-
-public class BreakpointOption extends ScrolledComposite implements SelectionListener,
-        ProcessMessage {
-
-    SampleView sampleView;
-    Button[] buttonsBreak = new Button[Function.values().length];
-    /** cache of buttonsBreak[Function.getNumber()].getSelection */
-    boolean[] breakpoints = new boolean[Function.values().length];
-
-    BreakpointOption(SampleView sampleView, Composite parent) {
-        super(parent, SWT.NO_BACKGROUND | SWT.V_SCROLL | SWT.H_SCROLL);
-        this.sampleView = sampleView;
-
-        Composite composite = new Composite(this, 0);
-        GridLayout layout = new GridLayout();
-        layout.numColumns = 4;
-        composite.setLayout(layout);
-        this.setLayout(new FillLayout());
-
-        for (int i = 0; i < Function.values().length; i++) {
-            Group group = new Group(composite, 0);
-            group.setLayout(new RowLayout());
-            group.setText(Function.values()[i].toString());
-            Button btn = new Button(group, SWT.CHECK);
-            btn.addSelectionListener(this);
-            btn.setText("Break");
-            btn.setSelection(false);
-            breakpoints[Function.values()[i].getNumber()] = btn.getSelection();
-            buttonsBreak[Function.values()[i].getNumber()] = btn;
-        }
-
-        Point size = composite.computeSize(SWT.DEFAULT, SWT.DEFAULT);
-        composite.setSize(size);
-        this.setContent(composite);
-        this.setExpandHorizontal(true);
-        this.setExpandVertical(true);
-        this.setMinSize(size);
-        this.layout();
-    }
-
-    void setBreakpoint(final int contextId, final Function function, final boolean enabled) {
-        Message.Builder builder = Message.newBuilder();
-        builder.setContextId(contextId);
-        builder.setType(Type.Response);
-        builder.setExpectResponse(false);
-        builder.setFunction(Function.SETPROP);
-        builder.setProp(Prop.ExpectResponse);
-        builder.setArg0(function.getNumber());
-        builder.setArg1(enabled ? 1 : 0);
-        sampleView.messageQueue.addCommand(builder.build());
-        breakpoints[function.getNumber()] = enabled;
-    }
-
-    @Override
-    public void widgetSelected(SelectionEvent e) {
-        Button btn = (Button) e.widget;
-        Group group = (Group) btn.getParent();
-        int contextId = 0;
-        if (sampleView.current != null)
-            contextId = sampleView.current.contextId;
-        setBreakpoint(contextId, Function.valueOf(group.getText()), btn.getSelection());
-    }
-
-    @Override
-    public void widgetDefaultSelected(SelectionEvent e) {
-    }
-
-    private Function lastFunction = Function.NEG;
-
-    public boolean processMessage(final MessageQueue queue, final Message msg) throws IOException {
-        if (!breakpoints[msg.getFunction().getNumber()])
-            return false;
-        // use DefaultProcessMessage just to register the GL call
-        // but do not send response
-        final int contextId = msg.getContextId();
-        if (msg.getType() == Type.BeforeCall || msg.getType() == Type.AfterCall)
-            queue.defaultProcessMessage(msg, true, false);
-        final Message.Builder builder = Message.newBuilder();
-        builder.setContextId(contextId);
-        builder.setType(Type.Response);
-        builder.setExpectResponse(true);
-        final Shell shell = sampleView.getViewSite().getShell();
-        final boolean send[] = new boolean[1];
-        shell.getDisplay().syncExec(new Runnable() {
-            @Override
-            public void run() {
-                String call = MessageFormatter.format(msg, false);
-                call = call.substring(0, call.indexOf("(")) + ' ' +
-                        msg.getFunction() + call.substring(call.indexOf("("));
-                if (msg.hasData() && msg.getFunction() == Function.glShaderSource)
-                {
-                    int index = call.indexOf("string=") + 7;
-                    String ptr = call.substring(index, call.indexOf(',', index));
-                    call = call.replace(ptr, '"' + msg.getData().toStringUtf8() + '"');
-                }
-                if (msg.getType() == Type.AfterCall)
-                {
-                    call = "skip " + call;
-                    builder.setFunction(Function.SKIP);
-                }
-                else if (msg.getType() == Type.BeforeCall)
-                {
-                    call = "continue " + call;
-                    builder.setFunction(Function.CONTINUE);
-                }
-                else
-                {
-                    assert msg.getType() == Type.AfterGeneratedCall;
-                    assert msg.getFunction() == lastFunction;
-                    call = "skip " + call;
-                    builder.setFunction(Function.SKIP);
-                }
-                InputDialog inputDialog = new InputDialog(shell,
-                            msg.getFunction().toString() + " " + msg.getType().toString(),
-                        "(s)kip, (c)continue, (r)emove bp or glFunction(...)",
-                            call, null);
-                if (Window.OK == inputDialog.open())
-                {
-                    String s = inputDialog.getValue().substring(0, 1).toLowerCase();
-                    if (s.startsWith("s"))
-                    {
-                        builder.setFunction(Function.SKIP);
-                        // AfterCall is skipped, so push BeforeCall to complete
-                        if (queue.getPartialMessage(contextId) != null)
-                            queue.completePartialMessage(contextId);
-                    }
-                    else if (s.startsWith("c"))
-                        builder.setFunction(Function.CONTINUE);
-                    else if (s.startsWith("r"))
-                    {
-                        Button btn = buttonsBreak[msg.getFunction().getNumber()];
-                        btn.setSelection(false);
-                        setBreakpoint(msg.getContextId(), msg.getFunction(), false);
-                        builder.setExpectResponse(false);
-                    }
-                    else
-                    {
-                        MessageParserEx.instance.parse(builder, inputDialog.getValue());
-                        lastFunction = builder.getFunction();
-                        builder.setExpectResponse(true);
-                        // AfterCall is skipped, so push BeforeCall to complete
-                        if (queue.getPartialMessage(contextId) != null)
-                            queue.completePartialMessage(contextId);
-                    }
-                }
-                // else defaults to continue BeforeCall and skip AfterCall
-            }
-        });
-        queue.sendMessage(builder.build());
-        return true;
-    }
-}
diff --git a/tools/glesv2debugger/src/com/android/glesv2debugger/CodeGen.java b/tools/glesv2debugger/src/com/android/glesv2debugger/CodeGen.java
deleted file mode 100644
index 28f3a54..0000000
--- a/tools/glesv2debugger/src/com/android/glesv2debugger/CodeGen.java
+++ /dev/null
@@ -1,1236 +0,0 @@
-/*
- ** Copyright 2011, The Android Open Source Project
- **
- ** Licensed under the Apache License, Version 2.0 (the "License");
- ** you may not use this file except in compliance with the License.
- ** You may obtain a copy of the License at
- **
- **     http://www.apache.org/licenses/LICENSE-2.0
- **
- ** Unless required by applicable law or agreed to in writing, software
- ** distributed under the License is distributed on an "AS IS" BASIS,
- ** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- ** See the License for the specific language governing permissions and
- ** limitations under the License.
- */
-
-package com.android.glesv2debugger;
-
-import com.android.glesv2debugger.DebuggerMessage.Message;
-import com.android.glesv2debugger.DebuggerMessage.Message.Function;
-import com.android.sdklib.util.SparseIntArray;
-
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.jface.dialogs.ProgressMonitorDialog;
-import org.eclipse.jface.operation.IRunnableWithProgress;
-import org.eclipse.swt.widgets.Shell;
-
-import java.io.FileOutputStream;
-import java.io.FileWriter;
-import java.io.IOException;
-import java.io.PrintWriter;
-import java.lang.reflect.InvocationTargetException;
-import java.nio.ByteBuffer;
-
-public class CodeGen implements IRunnableWithProgress {
-    private FileWriter codeFile, makeFile, namesHeaderFile, namesSourceFile;
-    private PrintWriter code, make, namesHeader, namesSource;
-    private FileOutputStream dataOut;
-    private SparseIntArray bufferNames,
-            framebufferNames, programNames, textureNames, shaderNames, renderbufferNames;
-
-    /** return true if msg was a texture upload */
-    private boolean codeGenTextureUpload(final Message msg, final boolean replaceCopy) {
-        String s = null;
-        switch (msg.getFunction()) {
-            case glCompressedTexImage2D:
-                s = MessageFormatter.format(msg, true).replace("arg7", "texData");
-                break;
-            case glCompressedTexSubImage2D:
-            case glTexImage2D:
-            case glTexSubImage2D:
-                s = MessageFormatter.format(msg, true).replace("arg8", "texData");
-                break;
-            case glCopyTexImage2D:
-                if (!replaceCopy) {
-                    code.write(MessageFormatter.format(msg, true));
-                    code.write(";CHKERR;\n");
-                    return true;
-                }
-                assert msg.getArg2() == msg.getPixelFormat(); // TODO
-                s = "//" + MessageFormatter.format(msg, true) + "\n";
-                s += String.format("glTexImage2D(%s, %d, %s, %d, %d, %d, %s, %s, texData);CHKERR;",
-                        GLEnum.valueOf(msg.getArg0()), msg.getArg1(),
-                        GLEnum.valueOf(msg.getArg2()), msg.getArg5(), msg.getArg6(),
-                        msg.getArg7(), GLEnum.valueOf(msg.getPixelFormat()),
-                        GLEnum.valueOf(msg.getPixelType()));
-                break;
-            case glCopyTexSubImage2D:
-                if (!replaceCopy) {
-                    code.write(MessageFormatter.format(msg, true));
-                    code.write(";CHKERR;\n");
-                    return true;
-                }
-                // FIXME: check the texture format & type, and convert
-                s = "//" + MessageFormatter.format(msg, true) + "\n";
-                s += String.format(
-                        "glTexSubImage2D(%s, %d, %d, %d, %d, %d, %s, %s, texData);CHKERR;",
-                        GLEnum.valueOf(msg.getArg0()), msg.getArg1(), msg.getArg2(),
-                        msg.getArg3(), msg.getArg6(), msg.getArg7(),
-                        GLEnum.valueOf(msg.getPixelFormat()), GLEnum.valueOf(msg.getPixelType()));
-                break;
-            default:
-                return false;
-        }
-
-        if (msg.hasData()) {
-            final byte[] data = MessageProcessor.lzfDecompressChunks(msg.getData());
-            try {
-                code.write("{\n");
-                code.format("    void * texData = malloc(%d);CHKERR;\n", data.length);
-                code.format("    FILE * texFile = fopen(\"/sdcard/frame_data.bin\", \"rb\");CHKERR;\n");
-                code.format("    assert(texFile);CHKERR;\n");
-                code.format("    fseek(texFile, %d, SEEK_SET);CHKERR;\n", dataOut.getChannel()
-                        .position());
-                dataOut.write(data);
-                code.format("    fread(texData, %d, 1, texFile);CHKERR;\n", data.length);
-                code.format("    fclose(texFile);CHKERR;\n");
-                code.format("    " + s + ";\n");
-                code.format("    free(texData);CHKERR;\n");
-                code.format("}\n");
-            } catch (IOException e) {
-                e.printStackTrace();
-                assert false;
-            }
-        } else
-            code.write(s.replace("texData", "NULL") + ";\n");
-        return true;
-    }
-
-    private void codeGenServerState(final GLServerState serverState) {
-        code.write("// CodeGenServerState\n");
-        for (int i = 0; i < serverState.enableDisables.size(); i++) {
-            final GLEnum key = GLEnum.valueOf(serverState.enableDisables.keyAt(i));
-            if (serverState.enableDisables.valueAt(i) == 0)
-                code.format("glDisable(%s);CHKERR;\n", key);
-            else
-                code.format("glEnable(%s);CHKERR;\n", key);
-        }
-        for (int i = 0; i < serverState.lastSetter.size(); i++) {
-            final Function key = Function.valueOf(serverState.lastSetter.keyAt(i));
-            final Message msg = serverState.lastSetter.valueAt(i);
-            if (msg == null) {
-                code.format("// %s is default\n", key);
-                continue;
-            }
-            final String s = MessageFormatter.format(msg, true);
-            code.write(s);
-            code.write(";\n");
-        }
-        // TODO: stencil and integers
-    }
-
-    private void codeGenServerShader(final GLServerShader serverShader) {
-        code.write("// CodeGenServerShader\n");
-        for (int i = 0; i < serverShader.shaders.size(); i++) {
-            final int name = serverShader.shaders.keyAt(i);
-            final GLShader shader = serverShader.shaders.valueAt(i);
-            final String id = "shader_" + name;
-            if (shaderNames.indexOfKey(name) < 0) {
-                namesSource.format("GLuint %s = 0;\n", id);
-                namesHeader.format("extern GLuint %s;\n", id);
-            }
-            code.format("%s = glCreateShader(%s);CHKERR;\n", id, shader.type);
-            shaderNames.put(name, name);
-
-            if (shader.source != null) {
-                final String src = shader.source.replace("\r", "").replace("\n", "\\n\\\n")
-                        .replace("\"", "\\\"");
-                code.format("glShaderSource(%s, 1, (const GLchar *[]){\"%s\"}, NULL);CHKERR;\n",
-                                id, src);
-                code.format("glCompileShader(%s);CHKERR;\n", id);
-            }
-        }
-
-        for (int i = 0; i < serverShader.programs.size(); i++) {
-            final int name = serverShader.programs.keyAt(i);
-            final GLProgram program = serverShader.programs.valueAt(i);
-            final String id = "program_" + name;
-            if (programNames.indexOfKey(name) < 0) {
-                namesSource.format("GLuint %s = 0;\n", id);
-                namesHeader.format("extern GLuint %s;\n", id);
-            }
-            code.format("%s = glCreateProgram();CHKERR;\n", id);
-            programNames.put(name, name);
-            code.format("glAttachShader(%s, shader_%d);CHKERR;\n", id,
-                    program.vert);
-            code.format("glAttachShader(%s, shader_%d);CHKERR;\n", id,
-                    program.frag);
-            code.format("glLinkProgram(%s);CHKERR;\n", id);
-            if (serverShader.current == program)
-                code.format("glUseProgram(%s);CHKERR;\n", id);
-        }
-    }
-
-    private void codeGenServerTexture(final GLServerTexture serverTexture, final boolean replaceCopy) {
-        code.write("// CodeGenServerTexture\n");
-        for (int i = 0; i < serverTexture.textures.size(); i++) {
-            final int name = serverTexture.textures.keyAt(i);
-            final GLTexture tex = serverTexture.textures.valueAt(i);
-            final String id = "texture_" + name;
-            if (textureNames.indexOfKey(name) < 0) {
-                namesHeader.format("extern GLuint %s;\n", id);
-                namesSource.format("GLuint %s = 0;\n", id);
-            }
-            code.format("%s = 0;\n", id);
-            textureNames.put(name, name);
-
-            if (name == 0)
-                continue;
-            code.format("glGenTextures(1, &%s);CHKERR;\n", id);
-            String s = String.format("glBindTexture(%s, texture_%d);CHKERR;\n", tex.target,
-                    tex.name);
-            code.write(s);
-            for (final Message msg : tex.contentChanges) {
-                if (codeGenTextureUpload(msg, replaceCopy))
-                    continue;
-                switch (msg.getFunction()) {
-                    case glGenerateMipmap:
-                        s = MessageFormatter.format(msg, true);
-                        break;
-                    default:
-                        assert false;
-                }
-                code.write(s + ";\n");
-            }
-            code.format("glTexParameteriv(%s, GL_TEXTURE_WRAP_S, (GLint[]){%s});CHKERR;\n",
-                    tex.target, tex.wrapS);
-            code.format("glTexParameteriv(%s, GL_TEXTURE_WRAP_T, (GLint[]){%s});CHKERR;\n",
-                    tex.target, tex.wrapT);
-            code.format("glTexParameteriv(%s, GL_TEXTURE_MIN_FILTER, (GLint[]){%s});CHKERR;\n",
-                    tex.target, tex.min);
-            code.format("glTexParameteriv(%s, GL_TEXTURE_MAG_FILTER, (GLint[]){%s});CHKERR;\n",
-                    tex.target, tex.mag);
-        }
-        for (int i = 0; i < serverTexture.tmu2D.length; i++) {
-            code.format("glActiveTexture(%s);CHKERR;\n",
-                    GLEnum.valueOf(GLEnum.GL_TEXTURE0.value + i));
-            code.format("glBindTexture(GL_TEXTURE_2D, texture_%d);CHKERR;\n",
-                    serverTexture.tmu2D[i]);
-        }
-        for (int i = 0; i < serverTexture.tmuCube.length; i++) {
-            code.format("glActiveTexture(%s);CHKERR;\n",
-                    GLEnum.valueOf(GLEnum.GL_TEXTURE0.value + i));
-            code.format("glBindTexture(GL_TEXTURE_CUBE_MAP, texture_%d);CHKERR;\n",
-                    serverTexture.tmuCube[i]);
-        }
-        code.format("glActiveTexture(%s);CHKERR;\n", serverTexture.activeTexture);
-        if (serverTexture.tex2D == null)
-            code.format("glBindTexture(GL_TEXTURE_2D, 0);CHKERR;\n");
-        else
-            code.format("glBindTexture(GL_TEXTURE_2D, texture_%d);CHKERR;\n",
-                    serverTexture.tex2D.name);
-        if (serverTexture.texCube == null)
-            code.format("glBindTexture(GL_TEXTURE_CUBE_MAP, 0);CHKERR;\n");
-        else
-            code.format("glBindTexture(GL_TEXTURE_CUBE_MAP, texture_%d);CHKERR;\n",
-                    serverTexture.texCube.name);
-    }
-
-    private void codeGenBufferData(final ByteBuffer buffer, final String call) {
-        ByteBuffer bfr = buffer;
-        if (buffer.isReadOnly()) {
-            bfr = ByteBuffer.allocate(buffer.capacity());
-            bfr.put(buffer);
-        }
-        final byte[] data = bfr.array();
-        try {
-            code.write("{\n");
-            code.format("    void * bufferData = malloc(%d);\n", data.length);
-            code.format("    FILE * bufferFile = fopen(\"/sdcard/frame_data.bin\", \"rb\");\n");
-            code.format("    assert(bufferFile);\n");
-            code.format("    fseek(bufferFile, %d, SEEK_SET);\n", dataOut.getChannel()
-                    .position());
-            dataOut.write(data);
-            code.format("    fread(bufferData, %d, 1, bufferFile);\n", data.length);
-            code.format("    fclose(bufferFile);\n");
-            code.format("    " + call + ";CHKERR;\n");
-            code.format("    free(bufferData);\n");
-            code.format("}\n");
-        } catch (IOException e) {
-            e.printStackTrace();
-            assert false;
-        }
-    }
-
-    private void codeGenServerVertex(final GLServerVertex v) {
-        code.write("// CodeGenServerVertex\n");
-        for (int i = 0; i < v.buffers.size(); i++) {
-            final int name = v.buffers.keyAt(i);
-            final String id = "buffer_" + name;
-            final GLBuffer buffer = v.buffers.valueAt(i);
-            if (bufferNames.indexOfKey(name) < 0) {
-                namesHeader.format("extern GLuint %s;\n", id);
-                namesSource.format("GLuint %s = 0;\n", id);
-            }
-            code.format("%s = 0;\n", id);
-            bufferNames.put(name, name);
-            if (name == 0)
-                continue;
-            code.format("glGenBuffers(1, &%s);CHKERR;\n", id);
-            if (buffer.target != null) {
-                code.format("glBindBuffer(%s, %s);CHKERR;\n", buffer.target, id);
-                if (buffer.data != null) {
-                    String s = String.format("glBufferData(%s, %d, bufferData, %s)", buffer.target,
-                            buffer.data.capacity(), buffer.usage);
-                    codeGenBufferData(buffer.data, s);
-                }
-            }
-        }
-        // TODO: use MAX_VERTEX_ATTRIBS
-        for (int i = 0; i < v.defaultAttribs.length; i++)
-            code.format("glVertexAttrib4f(%d, %f, %f, %f, %f);CHKERR;\n", i,
-                    v.defaultAttribs[i][0],
-                    v.defaultAttribs[i][1], v.defaultAttribs[i][2], v.defaultAttribs[i][3]);
-        for (int i = 0; i < v.attribPointers.length; i++) {
-            final GLAttribPointer att = v.attribPointers[i];
-            if (att.type == null)
-                continue;
-            if (att.buffer != null)
-                code.format("glBindBuffer(GL_ARRAY_BUFFER, buffer_%d);CHKERR;\n", att.buffer.name);
-            else
-                code.format("glBindBuffer(GL_ARRAY_BUFFER, 0);CHKERR;\n");
-            code.format("glVertexAttribPointer(%d, %d, %s, %b, %d, (const GLvoid *)%d);CHKERR;\n",
-                    i, att.size, att.type, att.normalized, att.stride, att.ptr);
-        }
-        if (v.attribBuffer != null)
-            code.format("glBindBuffer(GL_ARRAY_BUFFER, buffer_%d);CHKERR;\n", v.attribBuffer.name);
-        else
-            code.write("glBindBuffer(GL_ARRAY_BUFFER, 0);CHKERR;\n");
-        if (v.indexBuffer != null)
-            code.format("glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, buffer_%d);CHKERR;\n",
-                    v.indexBuffer.name);
-        else
-            code.write("glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0);CHKERR;\n");
-    }
-
-    private void codeGenGenNames(final Message msg) {
-        final ByteBuffer names = msg.getData().asReadOnlyByteBuffer();
-        names.order(SampleView.targetByteOrder);
-        SparseIntArray namesArray = null;
-        for (int i = 0; i < msg.getArg0(); i++) {
-            String id = "";
-            final int name = names.getInt();
-            switch (msg.getFunction()) {
-                case glGenBuffers:
-                    id = "buffer";
-                    namesArray = bufferNames;
-                    break;
-                case glGenFramebuffers:
-                    id = "framebuffer";
-                    namesArray = framebufferNames;
-                    break;
-                case glGenRenderbuffers:
-                    id = "renderbuffer";
-                    namesArray = renderbufferNames;
-                    break;
-                case glGenTextures:
-                    id = "texture";
-                    namesArray = textureNames;
-                    break;
-                default:
-                    assert false;
-            }
-            id += "_" + name;
-            if (namesArray.indexOfKey(name) < 0) {
-                namesHeader.format("extern GLuint %s;\n", id);
-                namesSource.format("GLuint %s = 0;\n", id);
-            }
-            code.format("%s = 0;\n", id);
-            namesArray.put(name, name);
-            code.format("%s(1, &%s);CHKERR;\n", msg.getFunction(), id);
-        }
-    }
-
-    private void codeGenDeleteNames(final Message msg) {
-        final ByteBuffer names = msg.getData().asReadOnlyByteBuffer();
-        names.order(SampleView.targetByteOrder);
-        SparseIntArray namesArray = null;
-        for (int i = 0; i < msg.getArg0(); i++) {
-            String id = null;
-            final int name = names.getInt();
-            switch (msg.getFunction()) {
-                case glDeleteBuffers:
-                    id = "buffer";
-                    namesArray = bufferNames;
-                    break;
-                case glDeleteFramebuffers:
-                    id = "framebuffer";
-                    namesArray = framebufferNames;
-                    break;
-                case glDeleteRenderbuffers:
-                    id = "renderbuffer";
-                    namesArray = renderbufferNames;
-                    break;
-                case glDeleteTextures:
-                    id = "texture";
-                    namesArray = textureNames;
-                    break;
-                default:
-                    assert false;
-            }
-            id += "_" + name;
-            code.format("%s = 0;\n", id);
-            namesArray.put(name, 0);
-            code.format("%s(1, &%s);CHKERR;\n", msg.getFunction(), id);
-        }
-    }
-
-    private void codeGenBindNames(final Message msg) {
-        String id = null;
-        SparseIntArray namesArray = null;
-        final int name = msg.getArg1();
-        switch (msg.getFunction()) {
-            case glBindBuffer:
-                id = "buffer";
-                namesArray = bufferNames;
-                break;
-            case glBindFramebuffer:
-                id = "framebuffer";
-                namesArray = framebufferNames;
-                break;
-            case glBindRenderbuffer:
-                id = "renderbuffer";
-                namesArray = renderbufferNames;
-                break;
-            case glBindTexture:
-                id = "texture";
-                namesArray = textureNames;
-                break;
-            default:
-                assert false;
-        }
-        id += "_" + name;
-        if (namesArray.indexOfKey(name) < 0) {
-            namesHeader.format("extern GLuint %s;\n", id);
-            namesSource.format("GLuint %s = 0;\n", id);
-        } else if (namesArray.get(name) != name)
-            code.format("%s = %d;\n", id, name); // name was deleted
-        namesArray.put(name, name);
-        code.write(MessageFormatter.format(msg, true));
-        code.write(";CHKERR;\n");
-    }
-
-    private void codeGenDrawArrays(final GLServerVertex v, final MessageData msgData)
-            throws IOException {
-        final int maxAttrib = msgData.msg.getArg7();
-        if (maxAttrib < 1) {
-            code.write("// no vertex data\n");
-            return;
-        }
-        final byte[] data = msgData.msg.getData().toByteArray();
-        final GLEnum mode = GLEnum.valueOf(msgData.msg.getArg0());
-        final int first = msgData.msg.getArg1(), count = msgData.msg.getArg2();
-        int attribDataStride = 0;
-        for (int i = 0; i < maxAttrib; i++) {
-            final GLAttribPointer att = v.attribPointers[i];
-            if (!att.enabled)
-                continue;
-            if (att.buffer != null)
-                continue;
-            attribDataStride += att.elemSize;
-        }
-        assert attribDataStride * count == data.length;
-        code.write("{\n");
-        if (attribDataStride > 0) {
-            code.format("    FILE * attribFile = fopen(\"/sdcard/frame_data.bin\", \"rb\");CHKERR;\n");
-            code.format("    assert(attribFile);CHKERR;\n");
-            code.format("    fseek(attribFile, %d, SEEK_SET);CHKERR;\n", dataOut.getChannel()
-                    .position());
-            dataOut.write(data);
-            code.format("    char * const attribData = (char *)malloc(%d);\n", first
-                    * attribDataStride + data.length);
-            code.format("    assert(attribData);\n");
-            code.format("    fread(attribData + %d, %d, 1, attribFile);\n",
-                    first * attribDataStride, data.length);
-            code.format("    fclose(attribFile);\n");
-            code.format("    glBindBuffer(GL_ARRAY_BUFFER, 0);CHKERR;\n");
-            int attribDataOffset = 0;
-            for (int i = 0; i < maxAttrib; i++) {
-                final GLAttribPointer att = v.attribPointers[i];
-                if (!att.enabled)
-                    continue;
-                if (att.buffer != null)
-                    continue;
-                code.format(
-                        "    glVertexAttribPointer(%d, %d, %s, %b, %d, attribData + %d);CHKERR;\n",
-                        i, att.size, att.type, att.normalized,
-                        attribDataStride, attribDataOffset);
-                attribDataOffset += att.elemSize;
-            }
-            if (v.attribBuffer != null)
-                code.format("    glBindBuffer(GL_ARRAY_BUFFER, %d);CHKERR;\n",
-                        v.attribBuffer.name);
-        }
-        code.format("    glDrawArrays(%s, %d, %d);CHKERR;\n", mode, first, count);
-        if (attribDataStride > 0)
-            code.format("    free(attribData);CHKERR;\n");
-        code.write("};\n");
-    }
-
-    private void codeGenDrawElements(final GLServerVertex v, final MessageData msgData)
-            throws IOException {
-        final int maxAttrib = msgData.msg.getArg7();
-        if (maxAttrib < 1) {
-            code.write("// no vertex data\n");
-            return;
-        }
-        final GLEnum mode = GLEnum.valueOf(msgData.msg.getArg0());
-        final int count = msgData.msg.getArg1();
-        final GLEnum type = GLEnum.valueOf(msgData.msg.getArg2());
-        String typeName = "GLubyte";
-        if (type == GLEnum.GL_UNSIGNED_SHORT)
-            typeName = "GLushort";
-        int attribDataStride = 0;
-        for (int i = 0; i < maxAttrib; i++) {
-            final GLAttribPointer att = v.attribPointers[i];
-            if (!att.enabled)
-                continue;
-            if (att.buffer != null)
-                continue;
-            attribDataStride += att.elemSize;
-        }
-        code.write("{\n");
-        if (v.indexBuffer == null || attribDataStride > 0) {
-            // need to load user pointer indices and/or attributes
-            final byte[] element = new byte[attribDataStride];
-            final ByteBuffer data = msgData.msg.getData().asReadOnlyByteBuffer();
-            data.order(SampleView.targetByteOrder);
-            final ByteBuffer indexData = ByteBuffer.allocate(count * GLServerVertex.typeSize(type));
-            indexData.order(SampleView.targetByteOrder);
-            final ByteBuffer attribData = ByteBuffer.allocate(count * attribDataStride);
-            attribData.order(SampleView.targetByteOrder);
-            int maxIndex = -1;
-            ByteBuffer indexSrc = data;
-            if (v.indexBuffer != null) {
-                indexSrc = v.indexBuffer.data;
-                indexSrc.position(msgData.msg.getArg3());
-            }
-            indexSrc.order(SampleView.targetByteOrder);
-            for (int i = 0; i < count; i++) {
-                int index = -1;
-                if (type == GLEnum.GL_UNSIGNED_BYTE) {
-                    byte idx = indexSrc.get();
-                    index = idx & 0xff;
-                    indexData.put(idx);
-                } else if (type == GLEnum.GL_UNSIGNED_SHORT) {
-                    short idx = indexSrc.getShort();
-                    index = idx & 0xffff;
-                    indexData.putShort(idx);
-                } else
-                    assert false;
-                data.get(element);
-                attribData.put(element);
-                if (index > maxIndex)
-                    maxIndex = index;
-            }
-            code.format("    FILE * attribFile = fopen(\"/sdcard/frame_data.bin\", \"rb\");CHKERR;\n");
-            code.format("    assert(attribFile);CHKERR;\n");
-            code.format("    fseek(attribFile, 0x%X, SEEK_SET);CHKERR;\n",
-                    dataOut.getChannel().position());
-            dataOut.write(indexData.array());
-            code.format("    %s * const indexData = (%s *)malloc(%d);\n", typeName, typeName,
-                    indexData.capacity());
-            code.format("    assert(indexData);\n");
-            code.format("    fread(indexData, %d, 1, attribFile);\n", indexData.capacity());
-            if (attribDataStride > 0) {
-                code.format("    glBindBuffer(GL_ARRAY_BUFFER, 0);CHKERR;\n");
-                for (int i = 0; i < maxAttrib; i++) {
-                    final GLAttribPointer att = v.attribPointers[i];
-                    if (!att.enabled)
-                        continue;
-                    if (att.buffer != null)
-                        continue;
-                    code.format("    char * const attrib%d = (char *)malloc(%d);\n",
-                            i, att.elemSize * (maxIndex + 1));
-                    code.format("    assert(attrib%d);\n", i);
-                    code.format(
-                            "    glVertexAttribPointer(%d, %d, %s, %b, %d, attrib%d);CHKERR;\n",
-                            i, att.size, att.type, att.normalized, att.elemSize, i);
-                }
-                dataOut.write(attribData.array());
-                code.format("    for (%s i = 0; i < %d; i++) {\n", typeName, count);
-                for (int i = 0; i < maxAttrib; i++) {
-                    final GLAttribPointer att = v.attribPointers[i];
-                    if (!att.enabled)
-                        continue;
-                    if (att.buffer != null)
-                        continue;
-                    code.format(
-                            "        fread(attrib%d + indexData[i] * %d, %d, 1, attribFile);\n",
-                            i, att.elemSize, att.elemSize);
-                }
-                code.format("    }\n");
-                if (v.attribBuffer != null)
-                    code.format("    glBindBuffer(GL_ARRAY_BUFFER, %d);CHKERR;\n",
-                            v.attribBuffer.name);
-            }
-            code.format("    fclose(attribFile);\n");
-        }
-        if (v.indexBuffer != null)
-            code.format("    glDrawElements(%s, %d, %s, (const void *)%d);CHKERR;\n",
-                    mode, count, type, msgData.msg.getArg3());
-        else {
-            code.format("    glDrawElements(%s, %d, %s, indexData);CHKERR;\n",
-                    mode, count, type);
-            code.format("    free(indexData);\n");
-        }
-        for (int i = 0; i < maxAttrib; i++) {
-            final GLAttribPointer att = v.attribPointers[i];
-            if (!att.enabled)
-                continue;
-            if (att.buffer != null)
-                continue;
-            code.format("    free(attrib%d);\n", i);
-        }
-        code.write("};\n");
-    }
-
-    private void codeGenDraw(final GLServerVertex v, final MessageData msgData)
-            throws IOException {
-        final int maxAttrib = msgData.msg.getArg7();
-        if (maxAttrib < 1) {
-            code.write("// no vertex data\n");
-            return;
-        }
-        final int count = msgData.attribs[0].length / 4;
-        final GLEnum mode = GLEnum.valueOf(msgData.msg.getArg0());
-        final ByteBuffer attribData = ByteBuffer.allocate(maxAttrib * count * 16);
-        attribData.order(SampleView.targetByteOrder);
-        for (int i = 0; i < count; i++)
-            for (int j = 0; j < maxAttrib; j++)
-                for (int k = 0; k < 4; k++)
-                    attribData.putFloat(msgData.attribs[j][i * 4 + k]);
-        assert attribData.remaining() == 0;
-        code.write("{\n");
-        code.format("    FILE * attribFile = fopen(\"/sdcard/frame_data.bin\", \"rb\");CHKERR;\n");
-        code.format("    assert(attribFile);CHKERR;\n");
-        code.format("    fseek(attribFile, 0x%X, SEEK_SET);CHKERR;\n",
-                dataOut.getChannel().position());
-        dataOut.write(attribData.array());
-        code.format("    char * const attribData = (char *)malloc(%d);\n", attribData.capacity());
-        code.format("    assert(attribData);\n");
-        code.format("    fread(attribData, %d, 1, attribFile);\n", attribData.capacity());
-        code.format("    fclose(attribFile);\n");
-        code.format("    glBindBuffer(GL_ARRAY_BUFFER, 0);CHKERR;\n");
-        for (int i = 0; i < maxAttrib; i++) {
-            final GLAttribPointer att = v.attribPointers[i];
-            assert msgData.attribs[i].length == count * 4;
-            code.format(
-                    "    glVertexAttribPointer(%d, %d, GL_FLOAT, GL_FALSE, %d, attribData + %d);CHKERR;\n",
-                        i, att.size, maxAttrib * 16, i * 16);
-        }
-        code.format("    glDrawArrays(%s, 0, %d);CHKERR;\n", mode, count);
-        code.format("    free(attribData);\n");
-        if (v.attribBuffer != null)
-            code.format("    glBindBuffer(GL_ARRAY_BUFFER, %d);CHKERR;\n",
-                        v.attribBuffer.name);
-        code.write("};\n");
-    }
-
-    private void codeGenFunction(final Context ctx, final MessageData msgData)
-            throws IOException {
-        final Message msg = msgData.msg;
-        String call = MessageFormatter.format(msg, true);
-        switch (msg.getFunction()) {
-            case glActiveTexture:
-            case glAttachShader:
-            case glBindAttribLocation:
-                break;
-            case glBindBuffer:
-            case glBindFramebuffer:
-            case glBindRenderbuffer:
-            case glBindTexture:
-                codeGenBindNames(msg);
-                return;
-            case glBlendColor:
-            case glBlendEquation:
-            case glBlendEquationSeparate:
-            case glBlendFunc:
-            case glBlendFuncSeparate:
-                break;
-            case glBufferData:
-                call = MessageFormatter.format(msg, true).replace("arg2", "bufferData");
-                codeGenBufferData(msg.getData().asReadOnlyByteBuffer(), call);
-                return;
-            case glBufferSubData:
-                call = MessageFormatter.format(msg, true).replace("arg3", "bufferData");
-                codeGenBufferData(msg.getData().asReadOnlyByteBuffer(), call);
-                return;
-            case glCheckFramebufferStatus:
-            case glClear:
-            case glClearColor:
-            case glClearDepthf:
-            case glClearStencil:
-            case glColorMask:
-            case glCompileShader:
-                break;
-            case glCompressedTexImage2D:
-            case glCompressedTexSubImage2D:
-            case glCopyTexImage2D:
-            case glCopyTexSubImage2D:
-                codeGenTextureUpload(msg, false);
-                return;
-            case glCreateProgram:
-                namesHeader.format("extern GLuint program_%d;\n", msg.getRet());
-                namesSource.format("GLuint program_%d = 0;\n", msg.getRet());
-                code.format("program_%d = glCreateProgram();CHKERR;\n", msg.getRet());
-                return;
-            case glCreateShader:
-                namesHeader.format("extern GLuint shader_%d;\n", msg.getRet());
-                namesSource.format("GLuint shader_%d = 0;\n", msg.getRet());
-                code.format("shader_%d = %s;\n", msg.getRet(), call);
-                return;
-            case glCullFace:
-                break;
-            case glDeleteBuffers:
-            case glDeleteFramebuffers:
-            case glDeleteProgram:
-                programNames.put(msg.getArg0(), 0);
-                break;
-            case glDeleteRenderbuffers:
-                codeGenDeleteNames(msg);
-                return;
-            case glDeleteShader:
-                shaderNames.put(msg.getArg0(), 0);
-                return;
-            case glDeleteTextures:
-                codeGenDeleteNames(msg);
-                return;
-            case glDepthFunc:
-            case glDepthMask:
-            case glDepthRangef:
-            case glDetachShader:
-            case glDisable:
-            case glDisableVertexAttribArray:
-                break;
-            case glDrawArrays:
-                // CodeGenDraw(ctx.serverVertex, msgData);
-                codeGenDrawArrays(ctx.serverVertex, msgData);
-                return;
-            case glDrawElements:
-                // CodeGenDraw(ctx.serverVertex, msgData);
-                codeGenDrawElements(ctx.serverVertex, msgData);
-                return;
-            case glEnable:
-            case glEnableVertexAttribArray:
-            case glFinish:
-            case glFlush:
-            case glFramebufferRenderbuffer:
-            case glFramebufferTexture2D:
-            case glFrontFace:
-                break;
-            case glGenBuffers:
-                codeGenGenNames(msg);
-                return;
-            case glGenerateMipmap:
-                break;
-            case glGenFramebuffers:
-            case glGenRenderbuffers:
-            case glGenTextures:
-                codeGenGenNames(msg);
-                return;
-            case glGetActiveAttrib:
-            case glGetActiveUniform:
-            case glGetAttachedShaders:
-                break;
-            case glGetAttribLocation:
-                call = String.format("assert(%d == %s)", msg.getRet(), call);
-                break;
-            case glGetBooleanv:
-            case glGetBufferParameteriv:
-                return; // TODO
-            case glGetError:
-                code.write("CHKERR;\n");
-                return;
-            case glGetFloatv:
-            case glGetFramebufferAttachmentParameteriv:
-            case glGetIntegerv:
-            case glGetProgramiv:
-            case glGetProgramInfoLog:
-            case glGetRenderbufferParameteriv:
-            case glGetShaderiv:
-            case glGetShaderInfoLog:
-            case glGetShaderPrecisionFormat:
-            case glGetShaderSource:
-            case glGetString:
-            case glGetTexParameterfv:
-            case glGetTexParameteriv:
-            case glGetUniformfv:
-            case glGetUniformiv:
-                return;
-            case glGetUniformLocation:
-                call = String.format("assert(%d == %s)", msg.getRet(), call);
-                break;
-            case glGetVertexAttribfv:
-            case glGetVertexAttribiv:
-            case glGetVertexAttribPointerv:
-                return; // TODO
-            case glHint:
-            case glIsBuffer:
-            case glIsEnabled:
-            case glIsFramebuffer:
-            case glIsProgram:
-            case glIsRenderbuffer:
-            case glIsShader:
-            case glIsTexture:
-            case glLineWidth:
-            case glLinkProgram:
-            case glPixelStorei:
-            case glPolygonOffset:
-                break;
-            case glReadPixels:
-                return; // TODO
-            case glReleaseShaderCompiler:
-            case glRenderbufferStorage:
-            case glSampleCoverage:
-            case glScissor:
-                break;
-            case glShaderBinary:
-                return; // TODO
-            case glShaderSource:
-                call = String.format(
-                        "glShaderSource(shader_%d, 1, (const char * []){\"%s\"}, NULL)",
-                        msg.getArg0(),
-                        msg.getData().toStringUtf8().replace("\r", "").replace("\n", "\\n\\\n")
-                                .replace("\"", "\\\"")
-                                );
-                break;
-            case glStencilFunc:
-            case glStencilFuncSeparate:
-            case glStencilMask:
-            case glStencilMaskSeparate:
-            case glStencilOp:
-            case glStencilOpSeparate:
-                break;
-            case glTexImage2D:
-                codeGenTextureUpload(msg, false);
-                return;
-            case glTexParameterf:
-                break;
-            case glTexParameterfv:
-                return; // TODO
-            case glTexParameteri:
-                break;
-            case glTexParameteriv:
-                return; // TODO
-            case glTexSubImage2D:
-                codeGenTextureUpload(msg, false);
-                return;
-            case glUniform1f:
-            case glUniform1fv:
-            case glUniform1i:
-            case glUniform1iv:
-            case glUniform2f:
-            case glUniform2fv:
-            case glUniform2i:
-            case glUniform2iv:
-            case glUniform3f:
-            case glUniform3fv:
-            case glUniform3i:
-            case glUniform3iv:
-            case glUniform4f:
-            case glUniform4fv:
-            case glUniform4i:
-            case glUniform4iv:
-            case glUniformMatrix2fv:
-            case glUniformMatrix3fv:
-            case glUniformMatrix4fv:
-            case glUseProgram:
-            case glValidateProgram:
-            case glVertexAttrib1f:
-            case glVertexAttrib1fv:
-            case glVertexAttrib2f:
-            case glVertexAttrib2fv:
-            case glVertexAttrib3f:
-            case glVertexAttrib3fv:
-            case glVertexAttrib4f:
-            case glVertexAttrib4fv:
-                break;
-            case glVertexAttribPointer:
-                // if it's user pointer, then CodeGenDrawArrays/Elements will
-                // replace it with loaded data just before the draw
-                call = call.replace("arg5", "(const void *)0x" +
-                        Integer.toHexString(msg.getArg5()));
-                break;
-            case glViewport:
-                break;
-            case eglSwapBuffers:
-                return;
-            default:
-                assert false;
-                return;
-        }
-        if (call.indexOf("glEnable(/*cap*/ GL_TEXTURE_2D)") >= 0)
-            return;
-        else if (call.indexOf("glDisable(/*cap*/ GL_TEXTURE_2D)") >= 0)
-            return;
-        else if (call.indexOf("glActiveTexture(/*texture*/ GL_TEXTURE_2D)") >= 0)
-            return;
-        code.write(call + ";CHKERR;\n");
-    }
-
-    private void codeGenSetup(final Context ctx) {
-        try {
-            codeFile = new FileWriter("frame_setup.cpp", false);
-            code = new PrintWriter(codeFile);
-            dataOut = new FileOutputStream("frame_data.bin", false);
-            namesHeaderFile = new FileWriter("frame_names.h", false);
-            namesHeader = new PrintWriter(namesHeaderFile);
-            namesSourceFile = new FileWriter("frame_names.cpp", false);
-            namesSource = new PrintWriter(namesSourceFile);
-        } catch (IOException e) {
-            e.printStackTrace();
-            assert false;
-        }
-        bufferNames = new SparseIntArray();
-        framebufferNames = new SparseIntArray();
-        programNames = new SparseIntArray();
-        textureNames = new SparseIntArray();
-        shaderNames = new SparseIntArray();
-        renderbufferNames = new SparseIntArray();
-
-        namesHeader.write("#include <stdlib.h>\n");
-        namesHeader.write("#include <stdio.h>\n");
-        namesHeader.write("#include <assert.h>\n");
-        namesHeader.write("#include <GLES2/gl2.h>\n");
-        namesHeader.write("#include <GLES2/gl2ext.h>\n");
-        namesHeader.write("#define CHKERR assert(GL_NO_ERROR == glGetError());/**/\n");
-        namesHeader.write("void FrameSetup();\n");
-        namesHeader.write("extern const unsigned int FrameCount;\n");
-        namesHeader.write("extern const GLuint program_0;\n");
-
-        namesSource.write("/*\n" + 
-        " * Copyright (C) 2011 The Android Open Source Project\n" + 
-        " *\n" + 
-        " * Licensed under the Apache License, Version 2.0 (the \"License\");\n" + 
-        " * you may not use this file except in compliance with the License.\n" + 
-        " * You may obtain a copy of the License at\n" + 
-        " *\n" + 
-        " *      http://www.apache.org/licenses/LICENSE-2.0\n" + 
-        " *\n" + 
-        " * Unless required by applicable law or agreed to in writing, software\n" + 
-        " * distributed under the License is distributed on an \"AS IS\" BASIS,\n" + 
-        " * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n" + 
-        " * See the License for the specific language governing permissions and\n" + 
-        " * limitations under the License.\n" + 
-        " */\n" + 
-        "\n" + 
-        "#include <stdlib.h>\n" + 
-        "#include <stdio.h>\n" + 
-        "\n" + 
-        "#include <EGL/egl.h>\n" + 
-        "#include <GLES2/gl2.h>\n" + 
-        "#include <GLES2/gl2ext.h>\n" + 
-        "\n" + 
-        "#include <ui/FramebufferNativeWindow.h>\n" + 
-        "#include <ui/EGLUtils.h>\n" + 
-        "\n" + 
-        "#include <private/ui/android_natives_priv.h>\n" + 
-        "\n" + 
-        "#include <surfaceflinger/Surface.h>\n" + 
-        "#include <surfaceflinger/ISurface.h>\n" + 
-        "#include <surfaceflinger/SurfaceComposerClient.h>\n" + 
-        "\n" + 
-        "using namespace android;\n" + 
-        "\n" + 
-        "static void checkEglError(const char* op, EGLBoolean returnVal = EGL_TRUE)\n" + 
-        "{\n" + 
-        "    if (returnVal != EGL_TRUE) {\n" + 
-        "        fprintf(stderr, \"%s() returned %d\\n\", op, returnVal);\n" + 
-        "    }\n" + 
-        "\n" + 
-        "    for (EGLint error = eglGetError(); error != EGL_SUCCESS; error\n" + 
-        "            = eglGetError()) {\n" + 
-        "        fprintf(stderr, \"after %s() eglError %s (0x%x)\\n\", op, EGLUtils::strerror(error),\n" + 
-        "                error);\n" + 
-        "    }\n" + 
-        "}\n" + 
-        "\n" + 
-        "static EGLDisplay dpy;\n" + 
-        "static EGLSurface surface;\n" + 
-        "\n" + 
-        "#include \"frame_names.h\"\n" + 
-        "const GLuint program_0 = 0;\n" + 
-        "int main(int argc, char** argv)\n" + 
-        "{\n" + 
-        "    EGLBoolean returnValue;\n" + 
-        "    EGLConfig myConfig = {0};\n" + 
-        "\n" + 
-        "    EGLint context_attribs[] = { EGL_CONTEXT_CLIENT_VERSION, 2, EGL_NONE };\n" + 
-        "    EGLint majorVersion;\n" + 
-        "    EGLint minorVersion;\n" + 
-        "    EGLContext context;\n" + 
-        "    EGLint w, h;\n" + 
-        "\n" + 
-        "\n" + 
-        "    checkEglError(\"<init>\");\n" + 
-        "    dpy = eglGetDisplay(EGL_DEFAULT_DISPLAY);\n" + 
-        "    checkEglError(\"eglGetDisplay\");\n" + 
-        "    if (dpy == EGL_NO_DISPLAY) {\n" + 
-        "        printf(\"eglGetDisplay returned EGL_NO_DISPLAY.\\n\");\n" + 
-        "        return 0;\n" + 
-        "    }\n" + 
-        "\n" + 
-        "    returnValue = eglInitialize(dpy, &majorVersion, &minorVersion);\n" + 
-        "    checkEglError(\"eglInitialize\", returnValue);\n" + 
-        "    if (returnValue != EGL_TRUE) {\n" + 
-        "        printf(\"eglInitialize failed\\n\");\n" + 
-        "        return 0;\n" + 
-        "    }\n" + 
-        "\n" + 
-        "    sp<SurfaceComposerClient> spClient;\n" + 
-        "    sp<SurfaceControl> spControl;\n" + 
-        "    sp<Surface> spSurface;\n" + 
-        "\n" + 
-        "    // create a client to surfaceflinger\n" + 
-        "    spClient = new SurfaceComposerClient();\n" + 
-        "\n" + 
-        "    spControl = spClient->createSurface(getpid(), 0, 1280, 752, PIXEL_FORMAT_RGBX_8888);\n" + 
-        "    spClient->openTransaction();\n" + 
-        "    spControl->setLayer(350000);\n" + 
-        "    spControl->show();\n" + 
-        "    spClient->closeTransaction();\n" + 
-        "\n" + 
-        "    spSurface = spControl->getSurface();\n" + 
-        "    EGLNativeWindowType window = spSurface.get();\n" + 
-        "\n" + 
-        "    printf(\"window=%p\\n\", window);\n" + 
-        "    EGLint attrib_list[] = {\n" + 
-        "        EGL_SURFACE_TYPE, EGL_WINDOW_BIT,\n" + 
-        "        EGL_RENDERABLE_TYPE, EGL_OPENGL_ES2_BIT,\n" + 
-        "        EGL_BUFFER_SIZE, 32,\n" + 
-        "        EGL_RED_SIZE, 8,\n" + 
-        "        EGL_GREEN_SIZE, 8,\n" + 
-        "        EGL_BLUE_SIZE, 8,\n" + 
-        "        EGL_NONE\n" + 
-        "    };\n" + 
-        "\n" + 
-        "    EGLConfig configs[12] = {0};\n" + 
-        "    int num_config = -1;\n" + 
-        "    eglChooseConfig(dpy, attrib_list, configs, sizeof(configs) / sizeof(*configs), &num_config);\n" + 
-        "    printf(\"eglChooseConfig %d \\n\", num_config);\n" + 
-        "\n" + 
-        "    surface = eglCreateWindowSurface(dpy, configs[0], window, NULL);\n" + 
-        "    checkEglError(\"eglCreateWindowSurface\");\n" + 
-        "    if (surface == EGL_NO_SURFACE) {\n" + 
-        "        printf(\"gelCreateWindowSurface failed.\\n\");\n" + 
-        "        return 0;\n" + 
-        "    }\n" + 
-        "\n" + 
-        "    context = eglCreateContext(dpy, configs[0], EGL_NO_CONTEXT, context_attribs);\n" + 
-        "    checkEglError(\"eglCreateContext\");\n" + 
-        "    if (context == EGL_NO_CONTEXT) {\n" + 
-        "        printf(\"eglCreateContext failed\\n\");\n" + 
-        "        return 0;\n" + 
-        "    }\n" + 
-        "    printf(\"context=%p \\n\", context);\n" + 
-        "\n" + 
-        "    returnValue = eglMakeCurrent(dpy, surface, surface, context);\n" + 
-        "    checkEglError(\"eglMakeCurrent\", returnValue);\n" + 
-        "    if (returnValue != EGL_TRUE) {\n" + 
-        "        return 0;\n" + 
-        "    }\n" + 
-        "\n" + 
-        "    glClearColor(1,1,1,1);\n" + 
-        "    glClear(GL_COLOR_BUFFER_BIT);\n" + 
-        "\n" + 
-        "    FrameSetup();\n" + 
-        "    while (true)\n" + 
-        "        for (unsigned int i = 0; i < FrameCount; i++) {\n" + 
-        "            Frames[i]();\n" + 
-        "            eglSwapBuffers(dpy, surface);\n" + 
-        "            printf(\"press ENTER after Frame%d \\n\", i);\n" + 
-        "            getchar();\n" + 
-        "        }\n" + 
-        "\n" + 
-        "    return 0;\n" + 
-        "}");
-
-        code.write("#include \"frame_names.h\"\n");
-        code.write("void FrameSetup(){\n");
-
-        codeGenServerState(ctx.serverState);
-        codeGenServerShader(ctx.serverShader);
-        codeGenServerTexture(ctx.serverTexture, true);
-        codeGenServerVertex(ctx.serverVertex);
-
-        code.write("}\n");
-
-        try {
-            codeFile.close();
-            makeFile = new FileWriter("Android.mk", false);
-            make = new PrintWriter(makeFile);
-            make.write("LOCAL_PATH:= $(call my-dir)\n" +
-                    "include $(CLEAR_VARS)\n" +
-                    "LOCAL_SRC_FILES := \\\n");
-        } catch (IOException e) {
-            e.printStackTrace();
-            assert false;
-        }
-    }
-
-    private void codeGenCleanup() {
-        make.write("    frame_setup.cpp \\\n");
-        make.write("    frame_names.cpp \\\n");
-        make.write("#\n");
-        make.write(
-                "LOCAL_SHARED_LIBRARIES := \\\n" + 
-                "    libcutils \\\n" + 
-                "    libutils \\\n" + 
-                "    libEGL \\\n" + 
-                "    libGLESv2 \\\n" + 
-                "    libui \\\n" + 
-                "    libhardware \\\n" + 
-                "    libgui\n" + 
-                "\n" + 
-                "LOCAL_MODULE:= gles2dbg\n" + 
-                "\n" + 
-                "LOCAL_MODULE_TAGS := optional\n" + 
-                "\n" + 
-                "LOCAL_CFLAGS := -DGL_GLEXT_PROTOTYPES -O0 -g -DDEBUG -UNDEBUG\n" + 
-                "\n" + 
-                "include $(BUILD_EXECUTABLE)");
-        try {
-            dataOut.flush();
-            dataOut.close();
-            codeFile.close();
-            makeFile.close();
-            namesHeaderFile.close();
-            namesSourceFile.close();
-        } catch (IOException e) {
-            e.printStackTrace();
-            assert false;
-        }
-        dataOut = null;
-        code = null;
-        codeFile = null;
-        make = null;
-        makeFile = null;
-
-        bufferNames = null;
-        framebufferNames = null;
-        programNames = null;
-        textureNames = null;
-        shaderNames = null;
-        renderbufferNames = null;
-    }
-
-    private DebugContext dbgCtx;
-    private int count;
-    private IProgressMonitor progress;
-
-    @Override
-    public void run(IProgressMonitor monitor) {
-        progress.beginTask("CodeGenFrames", count + 2);
-        Context ctx = dbgCtx.getFrame(0).startContext.clone();
-        codeGenSetup(ctx);
-        progress.worked(1);
-        for (int i = 0; i < count; i++) {
-            try {
-                codeFile = new FileWriter("frame" + i + ".cpp", false);
-                code = new PrintWriter(codeFile);
-            } catch (IOException e1) {
-                e1.printStackTrace();
-                assert false;
-            }
-            make.format("    frame%d.cpp \\\n", i);
-
-            code.write("#include \"frame_names.h\"\n");
-            code.format("void Frame%d(){\n", i);
-            final Frame frame = dbgCtx.getFrame(i);
-            for (int j = 0; j < frame.size(); j++) {
-                final MessageData msgData = frame.get(j);
-                code.format("/* frame function %d: %s %s*/\n", j, msgData.msg.getFunction(),
-                        MessageFormatter.format(msgData.msg, false));
-                ctx.processMessage(msgData.msg);
-                try {
-                    codeGenFunction(ctx, msgData);
-                } catch (IOException e) {
-                    e.printStackTrace();
-                    assert false;
-                }
-            }
-            code.write("}\n");
-            try {
-                codeFile.close();
-            } catch (IOException e) {
-                e.printStackTrace();
-                assert false;
-            }
-            progress.worked(1);
-        }
-        for (int i = 0; i < count; i++)
-            namesHeader.format("void Frame%d();\n", i);
-        namesHeader.format("extern void (* Frames[%d])();\n", count);
-        namesSource.format("void (* Frames[%d])() = {\n", count);
-        for (int i = 0; i < count; i++) {
-            namesSource.format("    Frame%d,\n", i);
-        }
-        namesSource.write("};\n");
-        namesSource.format("const unsigned int FrameCount = %d;\n", count);
-        codeGenCleanup();
-        progress.worked(1);
-    }
-
-    void codeGenFrames(final DebugContext dbgCtx, int count, final Shell shell) {
-        this.dbgCtx = dbgCtx;
-        this.count = count;
-        ProgressMonitorDialog dialog = new ProgressMonitorDialog(shell);
-        this.progress = dialog.getProgressMonitor();
-        try {
-            dialog.run(false, true, this);
-        } catch (InvocationTargetException e) {
-            e.printStackTrace();
-            assert false;
-        } catch (InterruptedException e) {
-            e.printStackTrace();
-        }
-        this.dbgCtx = null;
-        this.count = 0;
-        progress = null;
-    }
-
-    void codeGenFrame(final Frame frame) {
-        Context ctx = frame.startContext.clone();
-        codeGenSetup(ctx);
-        try {
-            codeFile = new FileWriter("frame0.cpp", false);
-            code = new PrintWriter(codeFile);
-        } catch (IOException e1) {
-            e1.printStackTrace();
-            assert false;
-        }
-        make.format("    frame0.cpp \\\n");
-        code.write("#include \"frame_names.h\"\n");
-        code.format("void Frame0(){\n");
-        for (int i = 0; i < frame.size(); i++) {
-            final MessageData msgData = frame.get(i);
-            code.format("/* frame function %d: %s %s*/\n", i, msgData.msg.getFunction(),
-                    MessageFormatter.format(msgData.msg, false));
-            ctx.processMessage(msgData.msg);
-            try {
-                codeGenFunction(ctx, msgData);
-            } catch (IOException e) {
-                e.printStackTrace();
-                assert false;
-            }
-        }
-        code.write("}\n");
-        namesHeader.write("void Frame0();\n");
-        namesHeader.write("extern void (* Frames[1])();\n");
-        namesSource.write("void (* Frames[1])() = {Frame0};\n");
-        namesSource.write("const unsigned int FrameCount = 1;\n");
-        codeGenCleanup();
-    }
-}
diff --git a/tools/glesv2debugger/src/com/android/glesv2debugger/Context.java b/tools/glesv2debugger/src/com/android/glesv2debugger/Context.java
deleted file mode 100644
index 122695b..0000000
--- a/tools/glesv2debugger/src/com/android/glesv2debugger/Context.java
+++ /dev/null
@@ -1,532 +0,0 @@
-/*
- ** Copyright 2011, The Android Open Source Project
- **
- ** Licensed under the Apache License, Version 2.0 (the "License");
- ** you may not use this file except in compliance with the License.
- ** You may obtain a copy of the License at
- **
- **     http://www.apache.org/licenses/LICENSE-2.0
- **
- ** Unless required by applicable law or agreed to in writing, software
- ** distributed under the License is distributed on an "AS IS" BASIS,
- ** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- ** See the License for the specific language governing permissions and
- ** limitations under the License.
- */
-
-package com.android.glesv2debugger;
-
-import com.android.glesv2debugger.DebuggerMessage.Message;
-import com.android.glesv2debugger.DebuggerMessage.Message.DataType;
-import com.android.glesv2debugger.DebuggerMessage.Message.Function;
-import com.android.glesv2debugger.DebuggerMessage.Message.Prop;
-import com.android.sdklib.util.SparseArray;
-import com.android.sdklib.util.SparseIntArray;
-import com.google.protobuf.ByteString;
-
-import org.eclipse.jface.viewers.ISelectionChangedListener;
-import org.eclipse.jface.viewers.ITreeContentProvider;
-import org.eclipse.jface.viewers.LabelProvider;
-import org.eclipse.jface.viewers.SelectionChangedEvent;
-import org.eclipse.jface.viewers.StructuredSelection;
-import org.eclipse.jface.viewers.Viewer;
-import org.eclipse.swt.graphics.Image;
-import org.eclipse.swt.widgets.Display;
-
-import java.io.FileNotFoundException;
-import java.io.IOException;
-import java.io.RandomAccessFile;
-import java.lang.reflect.Array;
-import java.lang.reflect.Field;
-import java.nio.ByteBuffer;
-import java.nio.ByteOrder;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.Map;
-import java.util.Set;
-
-class Frame {
-    public final long filePosition;
-    private int callsCount;
-
-    final Context startContext;
-    private ArrayList<MessageData> calls = new ArrayList<MessageData>();
-
-    Frame(final Context context, final long filePosition) {
-        this.startContext = context.clone();
-        this.filePosition = filePosition;
-    }
-
-    void add(final MessageData msgData) {
-        calls.add(msgData);
-    }
-
-    void increaseCallsCount() {
-        callsCount++;
-    }
-
-    Context computeContext(final MessageData call) {
-        Context ctx = startContext.clone();
-        for (int i = 0; i < calls.size(); i++)
-            if (call == calls.get(i))
-                return ctx;
-            else
-                ctx.processMessage(calls.get(i).msg);
-        assert false;
-        return ctx;
-    }
-
-    int size() {
-        return callsCount;
-    }
-
-    MessageData get(final int i) {
-        return calls.get(i);
-    }
-
-    ArrayList<MessageData> get() {
-        return calls;
-    }
-
-    void unload() {
-        if (calls == null)
-            return;
-        calls.clear();
-        calls = null;
-    }
-
-    void load(final RandomAccessFile file) {
-        if (calls != null && calls.size() == callsCount)
-            return;
-        try {
-            Context ctx = startContext.clone();
-            calls = new ArrayList<MessageData>(callsCount);
-            final long oriPosition = file.getFilePointer();
-            file.seek(filePosition);
-            for (int i = 0; i < callsCount; i++) {
-                int len = file.readInt();
-                if (SampleView.targetByteOrder == ByteOrder.LITTLE_ENDIAN)
-                    len = Integer.reverseBytes(len);
-                final byte[] data = new byte[len];
-                file.read(data);
-                Message msg = Message.parseFrom(data);
-                ctx.processMessage(msg);
-                final MessageData msgData = new MessageData(Display.getCurrent(), msg, ctx);
-                calls.add(msgData);
-            }
-            file.seek(oriPosition);
-        } catch (IOException e) {
-            e.printStackTrace();
-            assert false;
-        }
-    }
-}
-
-class DebugContext {
-    boolean uiUpdate = false;
-    final int contextId;
-    Context currentContext;
-    private ArrayList<Frame> frames = new ArrayList<Frame>(128);
-    private Frame lastFrame;
-    private Frame loadedFrame;
-    private RandomAccessFile file;
-
-    DebugContext(final int contextId) {
-        this.contextId = contextId;
-        currentContext = new Context(contextId);
-        try {
-            file = new RandomAccessFile("0x" + Integer.toHexString(contextId) +
-                    ".gles2dbg", "rw");
-        } catch (FileNotFoundException e) {
-            e.printStackTrace();
-            assert false;
-        }
-    }
-
-    /** write message to file; if frame not null, then increase its call count */
-    void saveMessage(final Message msg, final RandomAccessFile file, Frame frame) {
-        synchronized (file) {
-            if (frame != null)
-                frame.increaseCallsCount();
-            final byte[] data = msg.toByteArray();
-            final ByteBuffer len = ByteBuffer.allocate(4);
-            len.order(SampleView.targetByteOrder);
-            len.putInt(data.length);
-            try {
-                if (SampleView.targetByteOrder == ByteOrder.BIG_ENDIAN)
-                    file.writeInt(data.length);
-                else
-                    file.writeInt(Integer.reverseBytes(data.length));
-                file.write(data);
-            } catch (IOException e) {
-                e.printStackTrace();
-                assert false;
-            }
-        }
-    }
-
-    /**
-     * Caches new Message, and formats into MessageData for current frame; this
-     * function is called exactly once for each new Message
-     */
-    void processMessage(final Message newMsg) {
-        Message msg = newMsg;
-        if (msg.getFunction() == Function.SETPROP) {
-            // GL impl. consts should have been sent before any GL call messages
-            assert frames.size() == 0;
-            assert lastFrame == null;
-            assert msg.getProp() == Prop.GLConstant;
-            switch (GLEnum.valueOf(msg.getArg0())) {
-                case GL_MAX_VERTEX_ATTRIBS:
-                    currentContext.serverVertex = new GLServerVertex(msg.getArg1());
-                    break;
-                case GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS:
-                    currentContext.serverTexture = new GLServerTexture(currentContext,
-                            msg.getArg1());
-                    break;
-                default:
-                    assert false;
-                    return;
-            }
-            saveMessage(msg, file, null);
-            return;
-        }
-
-        if (lastFrame == null) {
-            // first real message after the GL impl. consts
-            synchronized (file) {
-                try {
-                    lastFrame = new Frame(currentContext, file.getFilePointer());
-                } catch (IOException e) {
-                    e.printStackTrace();
-                    assert false;
-                }
-            }
-            synchronized (frames) {
-                frames.add(lastFrame);
-            }
-            assert loadedFrame == null;
-            loadedFrame = lastFrame;
-        }
-        currentContext.processMessage(msg);
-        if (msg.hasDataType() && msg.getDataType() == DataType.ReferencedImage) {
-            // decode referenced image so it doesn't rely on context later on
-            final byte[] referenced = MessageProcessor.lzfDecompressChunks(msg.getData());
-            currentContext.readPixelRef = MessageProcessor.decodeReferencedImage(
-                        currentContext.readPixelRef, referenced);
-            final byte[] decoded = MessageProcessor.lzfCompressChunks(
-                        currentContext.readPixelRef, referenced.length);
-            msg = msg.toBuilder().setDataType(DataType.NonreferencedImage)
-                        .setData(ByteString.copyFrom(decoded)).build();
-        }
-        saveMessage(msg, file, lastFrame);
-        if (loadedFrame == lastFrame) {
-            // frame selected for view, so format MessageData
-            final MessageData msgData = new MessageData(Display.getCurrent(), msg, currentContext);
-            lastFrame.add(msgData);
-            uiUpdate = true;
-        }
-        if (msg.getFunction() != Function.eglSwapBuffers)
-            return;
-        synchronized (frames) {
-            if (loadedFrame != lastFrame)
-                lastFrame.unload();
-            try {
-                frames.add(lastFrame = new Frame(currentContext, file.getFilePointer()));
-                // file.getChannel().force(false);
-                uiUpdate = true;
-            } catch (IOException e) {
-                e.printStackTrace();
-                assert false;
-            }
-        }
-        return;
-    }
-
-    Frame getFrame(int index) {
-        synchronized (frames) {
-            Frame newFrame = frames.get(index);
-            if (loadedFrame != null && loadedFrame != lastFrame && newFrame != loadedFrame) {
-                loadedFrame.unload();
-                uiUpdate = true;
-            }
-            loadedFrame = newFrame;
-            synchronized (file) {
-                loadedFrame.load(file);
-            }
-            return loadedFrame;
-        }
-    }
-
-    int frameCount() {
-        synchronized (frames) {
-            return frames.size();
-        }
-    }
-}
-
-/** aggregate of GL states */
-public class Context implements Cloneable {
-    public final int contextId;
-    public ArrayList<Context> shares = new ArrayList<Context>(); // self too
-    public GLServerVertex serverVertex;
-    public GLServerShader serverShader = new GLServerShader(this);
-    public GLServerState serverState = new GLServerState(this);
-    public GLServerTexture serverTexture;
-
-    byte[] readPixelRef = new byte[0];
-
-    public Context(int contextId) {
-        this.contextId = contextId;
-        shares.add(this);
-    }
-
-    @Override
-    public Context clone() {
-        try {
-            Context copy = (Context) super.clone();
-            // FIXME: context sharing list clone
-            copy.shares = new ArrayList<Context>(1);
-            copy.shares.add(copy);
-            if (serverVertex != null)
-                copy.serverVertex = serverVertex.clone();
-            copy.serverShader = serverShader.clone(copy);
-            copy.serverState = serverState.clone();
-            if (serverTexture != null)
-                copy.serverTexture = serverTexture.clone(copy);
-            // don't need to clone readPixelsRef, since referenced images
-            // are decoded when they are encountered
-            return copy;
-        } catch (CloneNotSupportedException e) {
-            e.printStackTrace();
-            assert false;
-            return null;
-        }
-    }
-
-    /** mainly updating states */
-    public void processMessage(Message msg) {
-        if (serverVertex.process(msg))
-            return;
-        if (serverShader.processMessage(msg))
-            return;
-        if (serverState.processMessage(msg))
-            return;
-        if (serverTexture.processMessage(msg))
-            return;
-    }
-}
-
-class ContextViewProvider extends LabelProvider implements ITreeContentProvider,
-        ISelectionChangedListener {
-    Context context;
-    final SampleView sampleView;
-
-    ContextViewProvider(final SampleView sampleView) {
-        this.sampleView = sampleView;
-    }
-
-    @Override
-    public void dispose() {
-    }
-
-    @Override
-    public String getText(Object obj) {
-        if (obj == null)
-            return "null";
-        if (obj instanceof Entry) {
-            Entry entry = (Entry) obj;
-            String objStr = "null (or default)";
-            if (entry.obj != null) {
-                objStr = entry.obj.toString();
-                if (entry.obj instanceof Message)
-                    objStr = MessageFormatter.format((Message) entry.obj, false);
-            }
-            return entry.name + " = " + objStr;
-        }
-        return obj.toString();
-    }
-
-    @Override
-    public Image getImage(Object obj) {
-        if (!(obj instanceof Entry))
-            return null;
-        final Entry entry = (Entry) obj;
-        if (!(entry.obj instanceof Message))
-            return null;
-        final Message msg = (Message) entry.obj;
-        switch (msg.getFunction()) {
-            case glTexImage2D:
-            case glTexSubImage2D:
-            case glCopyTexImage2D:
-            case glCopyTexSubImage2D: {
-                entry.image = new MessageData(Display.getCurrent(), msg, null).getImage();
-                if (entry.image == null)
-                    return null;
-                return new Image(Display.getCurrent(), entry.image.getImageData().scaledTo(96, 96));
-            }
-            default:
-                return null;
-        }
-    }
-
-    @Override
-    public void selectionChanged(SelectionChangedEvent event) {
-        StructuredSelection selection = (StructuredSelection) event
-                .getSelection();
-        if (null == selection)
-            return;
-        final Object obj = selection.getFirstElement();
-        if (!(obj instanceof Entry))
-            return;
-        final Entry entry = (Entry) obj;
-        if (entry.image == null)
-            return;
-        sampleView.tabFolder.setSelection(sampleView.tabItemImage);
-        sampleView.canvas.setBackgroundImage(entry.image);
-        sampleView.canvas.redraw();
-    }
-
-    @Override
-    public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
-        context = (Context) newInput;
-    }
-
-    class Entry {
-        String name;
-        Object obj;
-        Image image;
-
-        Entry(String name, Object obj) {
-            this.name = name;
-            this.obj = obj;
-        }
-    }
-
-    @Override
-    public Object[] getElements(Object inputElement) {
-        if (inputElement != context)
-            return null;
-        return getChildren(new Entry("Context", inputElement));
-    }
-
-    @Override
-    public Object[] getChildren(Object parentElement) {
-        if (!(parentElement instanceof Entry))
-            return null;
-        Entry entry = (Entry) parentElement;
-        ArrayList<Object> children = new ArrayList<Object>();
-        if (entry.obj == context.serverState.enableDisables) {
-            for (int i = 0; i < context.serverState.enableDisables.size(); i++) {
-                final int key = context.serverState.enableDisables.keyAt(i);
-                final int value = context.serverState.enableDisables.valueAt(i);
-                children.add(GLEnum.valueOf(key).name() + " = " + value);
-            }
-        } else if (entry.obj == context.serverState.integers) {
-            for (int i = 0; i < context.serverState.integers.size(); i++) {
-                final int key = context.serverState.integers.keyAt(i);
-                final Message val = context.serverState.integers.valueAt(i);
-                if (val != null)
-                    children.add(GLEnum.valueOf(key).name() + " : " +
-                            MessageFormatter.format(val, false));
-                else
-                    children.add(GLEnum.valueOf(key).name() + " : default");
-            }
-        } else if (entry.obj == context.serverState.lastSetter) {
-            for (int i = 0; i < context.serverState.lastSetter.size(); i++) {
-                final int key = context.serverState.lastSetter.keyAt(i);
-                final Message msg = context.serverState.lastSetter.valueAt(i);
-                if (msg == null)
-                    children.add(Function.valueOf(key).name() + " : default");
-                else
-                    children.add(Function.valueOf(key).name() + " : "
-                            + MessageFormatter.format(msg, false));
-            }
-        } else if (entry.obj instanceof SparseArray) {
-            SparseArray<?> sa = (SparseArray<?>) entry.obj;
-            for (int i = 0; i < sa.size(); i++)
-                children.add(new Entry("[" + sa.keyAt(i) + "]", sa.valueAt(i)));
-        } else if (entry.obj instanceof Map) {
-            Set<?> set = ((Map<?, ?>) entry.obj).entrySet();
-            for (Object o : set) {
-                Map.Entry e = (Map.Entry) o;
-                children.add(new Entry(e.getKey().toString(), e.getValue()));
-            }
-        } else if (entry.obj instanceof SparseIntArray) {
-            SparseIntArray sa = (SparseIntArray) entry.obj;
-            for (int i = 0; i < sa.size(); i++)
-                children.add("[" + sa.keyAt(i) + "] = " + sa.valueAt(i));
-        } else if (entry.obj instanceof Collection) {
-            Collection<?> collection = (Collection<?>) entry.obj;
-            for (Object o : collection)
-                children.add(new Entry("[?]", o));
-        } else if (entry.obj.getClass().isArray()) {
-            for (int i = 0; i < Array.getLength(entry.obj); i++)
-                children.add(new Entry("[" + i + "]", Array.get(entry.obj, i)));
-        } else {
-            Field[] fields = entry.obj.getClass().getFields();
-            for (Field f : fields) {
-                try {
-                    children.add(new Entry(f.getName(), f.get(entry.obj)));
-                } catch (IllegalArgumentException e) {
-                    e.printStackTrace();
-                } catch (IllegalAccessException e) {
-                    e.printStackTrace();
-                }
-            }
-        }
-        return children.toArray();
-    }
-
-    @Override
-    public Object getParent(Object element) {
-        return null;
-    }
-
-    @Override
-    public boolean hasChildren(Object element) {
-        if (element == null)
-            return false;
-        if (!(element instanceof Entry))
-            return false;
-        Object obj = ((Entry) element).obj;
-        if (obj == null)
-            return false;
-        if (obj instanceof SparseArray)
-            return ((SparseArray<?>) obj).size() > 0;
-        else if (obj instanceof SparseIntArray)
-            return ((SparseIntArray) obj).size() > 0;
-        else if (obj instanceof Collection)
-            return ((Collection<?>) obj).size() > 0;
-        else if (obj instanceof Map)
-            return ((Map<?, ?>) obj).size() > 0;
-        else if (obj.getClass().isArray())
-            return Array.getLength(obj) > 0;
-        else if (obj instanceof Message)
-            return false;
-        else if (isPrimitive(obj))
-            return false;
-        else if (obj.getClass().equals(String.class))
-            return false;
-        else if (obj.getClass().equals(Message.class))
-            return false;
-        else if (obj instanceof GLEnum)
-            return false;
-        return obj.getClass().getFields().length > 0;
-    }
-
-    static boolean isPrimitive(final Object obj) {
-        final Class<? extends Object> c = obj.getClass();
-        if (c.isPrimitive())
-            return true;
-        if (c == Integer.class)
-            return true;
-        if (c == Boolean.class)
-            return true;
-        if (c == Float.class)
-            return true;
-        if (c == Short.class)
-            return true;
-        return false;
-    }
-}
diff --git a/tools/glesv2debugger/src/com/android/glesv2debugger/DebuggerMessage.java b/tools/glesv2debugger/src/com/android/glesv2debugger/DebuggerMessage.java
deleted file mode 100644
index 94133f5..0000000
--- a/tools/glesv2debugger/src/com/android/glesv2debugger/DebuggerMessage.java
+++ /dev/null
@@ -1,1713 +0,0 @@
-// Generated by the protocol buffer compiler.  DO NOT EDIT!
-// source: debugger_message.proto
-
-package com.android.glesv2debugger;
-
-public final class DebuggerMessage {
-  private DebuggerMessage() {}
-  public static void registerAllExtensions(
-      com.google.protobuf.ExtensionRegistryLite registry) {
-  }
-  public static final class Message extends
-      com.google.protobuf.GeneratedMessageLite {
-    // Use Message.newBuilder() to construct.
-    private Message() {
-      initFields();
-    }
-    private Message(boolean noInit) {}
-    
-    private static final Message defaultInstance;
-    public static Message getDefaultInstance() {
-      return defaultInstance;
-    }
-    
-    public Message getDefaultInstanceForType() {
-      return defaultInstance;
-    }
-    
-    public enum Function
-        implements com.google.protobuf.Internal.EnumLite {
-      glActiveTexture(0, 0),
-      glAttachShader(1, 1),
-      glBindAttribLocation(2, 2),
-      glBindBuffer(3, 3),
-      glBindFramebuffer(4, 4),
-      glBindRenderbuffer(5, 5),
-      glBindTexture(6, 6),
-      glBlendColor(7, 7),
-      glBlendEquation(8, 8),
-      glBlendEquationSeparate(9, 9),
-      glBlendFunc(10, 10),
-      glBlendFuncSeparate(11, 11),
-      glBufferData(12, 12),
-      glBufferSubData(13, 13),
-      glCheckFramebufferStatus(14, 14),
-      glClear(15, 15),
-      glClearColor(16, 16),
-      glClearDepthf(17, 17),
-      glClearStencil(18, 18),
-      glColorMask(19, 19),
-      glCompileShader(20, 20),
-      glCompressedTexImage2D(21, 21),
-      glCompressedTexSubImage2D(22, 22),
-      glCopyTexImage2D(23, 23),
-      glCopyTexSubImage2D(24, 24),
-      glCreateProgram(25, 25),
-      glCreateShader(26, 26),
-      glCullFace(27, 27),
-      glDeleteBuffers(28, 28),
-      glDeleteFramebuffers(29, 29),
-      glDeleteProgram(30, 30),
-      glDeleteRenderbuffers(31, 31),
-      glDeleteShader(32, 32),
-      glDeleteTextures(33, 33),
-      glDepthFunc(34, 34),
-      glDepthMask(35, 35),
-      glDepthRangef(36, 36),
-      glDetachShader(37, 37),
-      glDisable(38, 38),
-      glDisableVertexAttribArray(39, 39),
-      glDrawArrays(40, 40),
-      glDrawElements(41, 41),
-      glEnable(42, 42),
-      glEnableVertexAttribArray(43, 43),
-      glFinish(44, 44),
-      glFlush(45, 45),
-      glFramebufferRenderbuffer(46, 46),
-      glFramebufferTexture2D(47, 47),
-      glFrontFace(48, 48),
-      glGenBuffers(49, 49),
-      glGenerateMipmap(50, 50),
-      glGenFramebuffers(51, 51),
-      glGenRenderbuffers(52, 52),
-      glGenTextures(53, 53),
-      glGetActiveAttrib(54, 54),
-      glGetActiveUniform(55, 55),
-      glGetAttachedShaders(56, 56),
-      glGetAttribLocation(57, 57),
-      glGetBooleanv(58, 58),
-      glGetBufferParameteriv(59, 59),
-      glGetError(60, 60),
-      glGetFloatv(61, 61),
-      glGetFramebufferAttachmentParameteriv(62, 62),
-      glGetIntegerv(63, 63),
-      glGetProgramiv(64, 64),
-      glGetProgramInfoLog(65, 65),
-      glGetRenderbufferParameteriv(66, 66),
-      glGetShaderiv(67, 67),
-      glGetShaderInfoLog(68, 68),
-      glGetShaderPrecisionFormat(69, 69),
-      glGetShaderSource(70, 70),
-      glGetString(71, 71),
-      glGetTexParameterfv(72, 72),
-      glGetTexParameteriv(73, 73),
-      glGetUniformfv(74, 74),
-      glGetUniformiv(75, 75),
-      glGetUniformLocation(76, 76),
-      glGetVertexAttribfv(77, 77),
-      glGetVertexAttribiv(78, 78),
-      glGetVertexAttribPointerv(79, 79),
-      glHint(80, 80),
-      glIsBuffer(81, 81),
-      glIsEnabled(82, 82),
-      glIsFramebuffer(83, 83),
-      glIsProgram(84, 84),
-      glIsRenderbuffer(85, 85),
-      glIsShader(86, 86),
-      glIsTexture(87, 87),
-      glLineWidth(88, 88),
-      glLinkProgram(89, 89),
-      glPixelStorei(90, 90),
-      glPolygonOffset(91, 91),
-      glReadPixels(92, 92),
-      glReleaseShaderCompiler(93, 93),
-      glRenderbufferStorage(94, 94),
-      glSampleCoverage(95, 95),
-      glScissor(96, 96),
-      glShaderBinary(97, 97),
-      glShaderSource(98, 98),
-      glStencilFunc(99, 99),
-      glStencilFuncSeparate(100, 100),
-      glStencilMask(101, 101),
-      glStencilMaskSeparate(102, 102),
-      glStencilOp(103, 103),
-      glStencilOpSeparate(104, 104),
-      glTexImage2D(105, 105),
-      glTexParameterf(106, 106),
-      glTexParameterfv(107, 107),
-      glTexParameteri(108, 108),
-      glTexParameteriv(109, 109),
-      glTexSubImage2D(110, 110),
-      glUniform1f(111, 111),
-      glUniform1fv(112, 112),
-      glUniform1i(113, 113),
-      glUniform1iv(114, 114),
-      glUniform2f(115, 115),
-      glUniform2fv(116, 116),
-      glUniform2i(117, 117),
-      glUniform2iv(118, 118),
-      glUniform3f(119, 119),
-      glUniform3fv(120, 120),
-      glUniform3i(121, 121),
-      glUniform3iv(122, 122),
-      glUniform4f(123, 123),
-      glUniform4fv(124, 124),
-      glUniform4i(125, 125),
-      glUniform4iv(126, 126),
-      glUniformMatrix2fv(127, 127),
-      glUniformMatrix3fv(128, 128),
-      glUniformMatrix4fv(129, 129),
-      glUseProgram(130, 130),
-      glValidateProgram(131, 131),
-      glVertexAttrib1f(132, 132),
-      glVertexAttrib1fv(133, 133),
-      glVertexAttrib2f(134, 134),
-      glVertexAttrib2fv(135, 135),
-      glVertexAttrib3f(136, 136),
-      glVertexAttrib3fv(137, 137),
-      glVertexAttrib4f(138, 138),
-      glVertexAttrib4fv(139, 139),
-      glVertexAttribPointer(140, 140),
-      glViewport(141, 141),
-      eglGetDisplay(142, 142),
-      eglInitialize(143, 143),
-      eglTerminate(144, 144),
-      eglGetConfigs(145, 145),
-      eglChooseConfig(146, 146),
-      eglGetConfigAttrib(147, 147),
-      eglCreateWindowSurface(148, 148),
-      eglCreatePixmapSurface(149, 149),
-      eglCreatePbufferSurface(150, 150),
-      eglDestroySurface(151, 151),
-      eglQuerySurface(152, 152),
-      eglCreateContext(153, 153),
-      eglDestroyContext(154, 154),
-      eglMakeCurrent(155, 155),
-      eglGetCurrentContext(156, 156),
-      eglGetCurrentSurface(157, 157),
-      eglGetCurrentDisplay(158, 158),
-      eglQueryContext(159, 159),
-      eglWaitGL(160, 160),
-      eglWaitNative(161, 161),
-      eglSwapBuffers(162, 162),
-      eglCopyBuffers(163, 163),
-      eglGetError(164, 164),
-      eglQueryString(165, 165),
-      eglGetProcAddress(166, 166),
-      eglSurfaceAttrib(167, 167),
-      eglBindTexImage(168, 168),
-      eglReleaseTexImage(169, 169),
-      eglSwapInterval(170, 170),
-      eglBindAPI(171, 171),
-      eglQueryAPI(172, 172),
-      eglWaitClient(173, 173),
-      eglReleaseThread(174, 174),
-      eglCreatePbufferFromClientBuffer(175, 175),
-      eglLockSurfaceKHR(176, 176),
-      eglUnlockSurfaceKHR(177, 177),
-      eglCreateImageKHR(178, 178),
-      eglDestroyImageKHR(179, 179),
-      eglCreateSyncKHR(180, 180),
-      eglDestroySyncKHR(181, 181),
-      eglClientWaitSyncKHR(182, 182),
-      eglGetSyncAttribKHR(183, 183),
-      eglSetSwapRectangleANDROID(184, 184),
-      eglGetRenderBufferANDROID(185, 185),
-      ACK(186, 186),
-      NEG(187, 187),
-      CONTINUE(188, 188),
-      SKIP(189, 189),
-      SETPROP(190, 190),
-      ;
-      
-      
-      public final int getNumber() { return value; }
-      
-      public static Function valueOf(int value) {
-        switch (value) {
-          case 0: return glActiveTexture;
-          case 1: return glAttachShader;
-          case 2: return glBindAttribLocation;
-          case 3: return glBindBuffer;
-          case 4: return glBindFramebuffer;
-          case 5: return glBindRenderbuffer;
-          case 6: return glBindTexture;
-          case 7: return glBlendColor;
-          case 8: return glBlendEquation;
-          case 9: return glBlendEquationSeparate;
-          case 10: return glBlendFunc;
-          case 11: return glBlendFuncSeparate;
-          case 12: return glBufferData;
-          case 13: return glBufferSubData;
-          case 14: return glCheckFramebufferStatus;
-          case 15: return glClear;
-          case 16: return glClearColor;
-          case 17: return glClearDepthf;
-          case 18: return glClearStencil;
-          case 19: return glColorMask;
-          case 20: return glCompileShader;
-          case 21: return glCompressedTexImage2D;
-          case 22: return glCompressedTexSubImage2D;
-          case 23: return glCopyTexImage2D;
-          case 24: return glCopyTexSubImage2D;
-          case 25: return glCreateProgram;
-          case 26: return glCreateShader;
-          case 27: return glCullFace;
-          case 28: return glDeleteBuffers;
-          case 29: return glDeleteFramebuffers;
-          case 30: return glDeleteProgram;
-          case 31: return glDeleteRenderbuffers;
-          case 32: return glDeleteShader;
-          case 33: return glDeleteTextures;
-          case 34: return glDepthFunc;
-          case 35: return glDepthMask;
-          case 36: return glDepthRangef;
-          case 37: return glDetachShader;
-          case 38: return glDisable;
-          case 39: return glDisableVertexAttribArray;
-          case 40: return glDrawArrays;
-          case 41: return glDrawElements;
-          case 42: return glEnable;
-          case 43: return glEnableVertexAttribArray;
-          case 44: return glFinish;
-          case 45: return glFlush;
-          case 46: return glFramebufferRenderbuffer;
-          case 47: return glFramebufferTexture2D;
-          case 48: return glFrontFace;
-          case 49: return glGenBuffers;
-          case 50: return glGenerateMipmap;
-          case 51: return glGenFramebuffers;
-          case 52: return glGenRenderbuffers;
-          case 53: return glGenTextures;
-          case 54: return glGetActiveAttrib;
-          case 55: return glGetActiveUniform;
-          case 56: return glGetAttachedShaders;
-          case 57: return glGetAttribLocation;
-          case 58: return glGetBooleanv;
-          case 59: return glGetBufferParameteriv;
-          case 60: return glGetError;
-          case 61: return glGetFloatv;
-          case 62: return glGetFramebufferAttachmentParameteriv;
-          case 63: return glGetIntegerv;
-          case 64: return glGetProgramiv;
-          case 65: return glGetProgramInfoLog;
-          case 66: return glGetRenderbufferParameteriv;
-          case 67: return glGetShaderiv;
-          case 68: return glGetShaderInfoLog;
-          case 69: return glGetShaderPrecisionFormat;
-          case 70: return glGetShaderSource;
-          case 71: return glGetString;
-          case 72: return glGetTexParameterfv;
-          case 73: return glGetTexParameteriv;
-          case 74: return glGetUniformfv;
-          case 75: return glGetUniformiv;
-          case 76: return glGetUniformLocation;
-          case 77: return glGetVertexAttribfv;
-          case 78: return glGetVertexAttribiv;
-          case 79: return glGetVertexAttribPointerv;
-          case 80: return glHint;
-          case 81: return glIsBuffer;
-          case 82: return glIsEnabled;
-          case 83: return glIsFramebuffer;
-          case 84: return glIsProgram;
-          case 85: return glIsRenderbuffer;
-          case 86: return glIsShader;
-          case 87: return glIsTexture;
-          case 88: return glLineWidth;
-          case 89: return glLinkProgram;
-          case 90: return glPixelStorei;
-          case 91: return glPolygonOffset;
-          case 92: return glReadPixels;
-          case 93: return glReleaseShaderCompiler;
-          case 94: return glRenderbufferStorage;
-          case 95: return glSampleCoverage;
-          case 96: return glScissor;
-          case 97: return glShaderBinary;
-          case 98: return glShaderSource;
-          case 99: return glStencilFunc;
-          case 100: return glStencilFuncSeparate;
-          case 101: return glStencilMask;
-          case 102: return glStencilMaskSeparate;
-          case 103: return glStencilOp;
-          case 104: return glStencilOpSeparate;
-          case 105: return glTexImage2D;
-          case 106: return glTexParameterf;
-          case 107: return glTexParameterfv;
-          case 108: return glTexParameteri;
-          case 109: return glTexParameteriv;
-          case 110: return glTexSubImage2D;
-          case 111: return glUniform1f;
-          case 112: return glUniform1fv;
-          case 113: return glUniform1i;
-          case 114: return glUniform1iv;
-          case 115: return glUniform2f;
-          case 116: return glUniform2fv;
-          case 117: return glUniform2i;
-          case 118: return glUniform2iv;
-          case 119: return glUniform3f;
-          case 120: return glUniform3fv;
-          case 121: return glUniform3i;
-          case 122: return glUniform3iv;
-          case 123: return glUniform4f;
-          case 124: return glUniform4fv;
-          case 125: return glUniform4i;
-          case 126: return glUniform4iv;
-          case 127: return glUniformMatrix2fv;
-          case 128: return glUniformMatrix3fv;
-          case 129: return glUniformMatrix4fv;
-          case 130: return glUseProgram;
-          case 131: return glValidateProgram;
-          case 132: return glVertexAttrib1f;
-          case 133: return glVertexAttrib1fv;
-          case 134: return glVertexAttrib2f;
-          case 135: return glVertexAttrib2fv;
-          case 136: return glVertexAttrib3f;
-          case 137: return glVertexAttrib3fv;
-          case 138: return glVertexAttrib4f;
-          case 139: return glVertexAttrib4fv;
-          case 140: return glVertexAttribPointer;
-          case 141: return glViewport;
-          case 142: return eglGetDisplay;
-          case 143: return eglInitialize;
-          case 144: return eglTerminate;
-          case 145: return eglGetConfigs;
-          case 146: return eglChooseConfig;
-          case 147: return eglGetConfigAttrib;
-          case 148: return eglCreateWindowSurface;
-          case 149: return eglCreatePixmapSurface;
-          case 150: return eglCreatePbufferSurface;
-          case 151: return eglDestroySurface;
-          case 152: return eglQuerySurface;
-          case 153: return eglCreateContext;
-          case 154: return eglDestroyContext;
-          case 155: return eglMakeCurrent;
-          case 156: return eglGetCurrentContext;
-          case 157: return eglGetCurrentSurface;
-          case 158: return eglGetCurrentDisplay;
-          case 159: return eglQueryContext;
-          case 160: return eglWaitGL;
-          case 161: return eglWaitNative;
-          case 162: return eglSwapBuffers;
-          case 163: return eglCopyBuffers;
-          case 164: return eglGetError;
-          case 165: return eglQueryString;
-          case 166: return eglGetProcAddress;
-          case 167: return eglSurfaceAttrib;
-          case 168: return eglBindTexImage;
-          case 169: return eglReleaseTexImage;
-          case 170: return eglSwapInterval;
-          case 171: return eglBindAPI;
-          case 172: return eglQueryAPI;
-          case 173: return eglWaitClient;
-          case 174: return eglReleaseThread;
-          case 175: return eglCreatePbufferFromClientBuffer;
-          case 176: return eglLockSurfaceKHR;
-          case 177: return eglUnlockSurfaceKHR;
-          case 178: return eglCreateImageKHR;
-          case 179: return eglDestroyImageKHR;
-          case 180: return eglCreateSyncKHR;
-          case 181: return eglDestroySyncKHR;
-          case 182: return eglClientWaitSyncKHR;
-          case 183: return eglGetSyncAttribKHR;
-          case 184: return eglSetSwapRectangleANDROID;
-          case 185: return eglGetRenderBufferANDROID;
-          case 186: return ACK;
-          case 187: return NEG;
-          case 188: return CONTINUE;
-          case 189: return SKIP;
-          case 190: return SETPROP;
-          default: return null;
-        }
-      }
-      
-      public static com.google.protobuf.Internal.EnumLiteMap<Function>
-          internalGetValueMap() {
-        return internalValueMap;
-      }
-      private static com.google.protobuf.Internal.EnumLiteMap<Function>
-          internalValueMap =
-            new com.google.protobuf.Internal.EnumLiteMap<Function>() {
-              public Function findValueByNumber(int number) {
-                return Function.valueOf(number)
-      ;        }
-            };
-      
-      private final int index;
-      private final int value;
-      private Function(int index, int value) {
-        this.index = index;
-        this.value = value;
-      }
-      
-      // @@protoc_insertion_point(enum_scope:com.android.glesv2debugger.Message.Function)
-    }
-    
-    public enum Type
-        implements com.google.protobuf.Internal.EnumLite {
-      BeforeCall(0, 0),
-      AfterCall(1, 1),
-      AfterGeneratedCall(2, 2),
-      Response(3, 3),
-      CompleteCall(4, 4),
-      ;
-      
-      
-      public final int getNumber() { return value; }
-      
-      public static Type valueOf(int value) {
-        switch (value) {
-          case 0: return BeforeCall;
-          case 1: return AfterCall;
-          case 2: return AfterGeneratedCall;
-          case 3: return Response;
-          case 4: return CompleteCall;
-          default: return null;
-        }
-      }
-      
-      public static com.google.protobuf.Internal.EnumLiteMap<Type>
-          internalGetValueMap() {
-        return internalValueMap;
-      }
-      private static com.google.protobuf.Internal.EnumLiteMap<Type>
-          internalValueMap =
-            new com.google.protobuf.Internal.EnumLiteMap<Type>() {
-              public Type findValueByNumber(int number) {
-                return Type.valueOf(number)
-      ;        }
-            };
-      
-      private final int index;
-      private final int value;
-      private Type(int index, int value) {
-        this.index = index;
-        this.value = value;
-      }
-      
-      // @@protoc_insertion_point(enum_scope:com.android.glesv2debugger.Message.Type)
-    }
-    
-    public enum DataType
-        implements com.google.protobuf.Internal.EnumLite {
-      ReferencedImage(0, 0),
-      NonreferencedImage(1, 1),
-      ;
-      
-      
-      public final int getNumber() { return value; }
-      
-      public static DataType valueOf(int value) {
-        switch (value) {
-          case 0: return ReferencedImage;
-          case 1: return NonreferencedImage;
-          default: return null;
-        }
-      }
-      
-      public static com.google.protobuf.Internal.EnumLiteMap<DataType>
-          internalGetValueMap() {
-        return internalValueMap;
-      }
-      private static com.google.protobuf.Internal.EnumLiteMap<DataType>
-          internalValueMap =
-            new com.google.protobuf.Internal.EnumLiteMap<DataType>() {
-              public DataType findValueByNumber(int number) {
-                return DataType.valueOf(number)
-      ;        }
-            };
-      
-      private final int index;
-      private final int value;
-      private DataType(int index, int value) {
-        this.index = index;
-        this.value = value;
-      }
-      
-      // @@protoc_insertion_point(enum_scope:com.android.glesv2debugger.Message.DataType)
-    }
-    
-    public enum Prop
-        implements com.google.protobuf.Internal.EnumLite {
-      CaptureDraw(0, 0),
-      TimeMode(1, 1),
-      ExpectResponse(2, 2),
-      CaptureSwap(3, 3),
-      GLConstant(4, 4),
-      ;
-      
-      
-      public final int getNumber() { return value; }
-      
-      public static Prop valueOf(int value) {
-        switch (value) {
-          case 0: return CaptureDraw;
-          case 1: return TimeMode;
-          case 2: return ExpectResponse;
-          case 3: return CaptureSwap;
-          case 4: return GLConstant;
-          default: return null;
-        }
-      }
-      
-      public static com.google.protobuf.Internal.EnumLiteMap<Prop>
-          internalGetValueMap() {
-        return internalValueMap;
-      }
-      private static com.google.protobuf.Internal.EnumLiteMap<Prop>
-          internalValueMap =
-            new com.google.protobuf.Internal.EnumLiteMap<Prop>() {
-              public Prop findValueByNumber(int number) {
-                return Prop.valueOf(number)
-      ;        }
-            };
-      
-      private final int index;
-      private final int value;
-      private Prop(int index, int value) {
-        this.index = index;
-        this.value = value;
-      }
-      
-      // @@protoc_insertion_point(enum_scope:com.android.glesv2debugger.Message.Prop)
-    }
-    
-    // required int32 context_id = 1;
-    public static final int CONTEXT_ID_FIELD_NUMBER = 1;
-    private boolean hasContextId;
-    private int contextId_ = 0;
-    public boolean hasContextId() { return hasContextId; }
-    public int getContextId() { return contextId_; }
-    
-    // required .com.android.glesv2debugger.Message.Function function = 2 [default = NEG];
-    public static final int FUNCTION_FIELD_NUMBER = 2;
-    private boolean hasFunction;
-    private com.android.glesv2debugger.DebuggerMessage.Message.Function function_;
-    public boolean hasFunction() { return hasFunction; }
-    public com.android.glesv2debugger.DebuggerMessage.Message.Function getFunction() { return function_; }
-    
-    // required .com.android.glesv2debugger.Message.Type type = 3;
-    public static final int TYPE_FIELD_NUMBER = 3;
-    private boolean hasType;
-    private com.android.glesv2debugger.DebuggerMessage.Message.Type type_;
-    public boolean hasType() { return hasType; }
-    public com.android.glesv2debugger.DebuggerMessage.Message.Type getType() { return type_; }
-    
-    // required bool expect_response = 4;
-    public static final int EXPECT_RESPONSE_FIELD_NUMBER = 4;
-    private boolean hasExpectResponse;
-    private boolean expectResponse_ = false;
-    public boolean hasExpectResponse() { return hasExpectResponse; }
-    public boolean getExpectResponse() { return expectResponse_; }
-    
-    // optional int32 ret = 5;
-    public static final int RET_FIELD_NUMBER = 5;
-    private boolean hasRet;
-    private int ret_ = 0;
-    public boolean hasRet() { return hasRet; }
-    public int getRet() { return ret_; }
-    
-    // optional int32 arg0 = 6;
-    public static final int ARG0_FIELD_NUMBER = 6;
-    private boolean hasArg0;
-    private int arg0_ = 0;
-    public boolean hasArg0() { return hasArg0; }
-    public int getArg0() { return arg0_; }
-    
-    // optional int32 arg1 = 7;
-    public static final int ARG1_FIELD_NUMBER = 7;
-    private boolean hasArg1;
-    private int arg1_ = 0;
-    public boolean hasArg1() { return hasArg1; }
-    public int getArg1() { return arg1_; }
-    
-    // optional int32 arg2 = 8;
-    public static final int ARG2_FIELD_NUMBER = 8;
-    private boolean hasArg2;
-    private int arg2_ = 0;
-    public boolean hasArg2() { return hasArg2; }
-    public int getArg2() { return arg2_; }
-    
-    // optional int32 arg3 = 9;
-    public static final int ARG3_FIELD_NUMBER = 9;
-    private boolean hasArg3;
-    private int arg3_ = 0;
-    public boolean hasArg3() { return hasArg3; }
-    public int getArg3() { return arg3_; }
-    
-    // optional int32 arg4 = 16;
-    public static final int ARG4_FIELD_NUMBER = 16;
-    private boolean hasArg4;
-    private int arg4_ = 0;
-    public boolean hasArg4() { return hasArg4; }
-    public int getArg4() { return arg4_; }
-    
-    // optional int32 arg5 = 17;
-    public static final int ARG5_FIELD_NUMBER = 17;
-    private boolean hasArg5;
-    private int arg5_ = 0;
-    public boolean hasArg5() { return hasArg5; }
-    public int getArg5() { return arg5_; }
-    
-    // optional int32 arg6 = 18;
-    public static final int ARG6_FIELD_NUMBER = 18;
-    private boolean hasArg6;
-    private int arg6_ = 0;
-    public boolean hasArg6() { return hasArg6; }
-    public int getArg6() { return arg6_; }
-    
-    // optional int32 arg7 = 19;
-    public static final int ARG7_FIELD_NUMBER = 19;
-    private boolean hasArg7;
-    private int arg7_ = 0;
-    public boolean hasArg7() { return hasArg7; }
-    public int getArg7() { return arg7_; }
-    
-    // optional int32 arg8 = 20;
-    public static final int ARG8_FIELD_NUMBER = 20;
-    private boolean hasArg8;
-    private int arg8_ = 0;
-    public boolean hasArg8() { return hasArg8; }
-    public int getArg8() { return arg8_; }
-    
-    // optional bytes data = 10;
-    public static final int DATA_FIELD_NUMBER = 10;
-    private boolean hasData;
-    private com.google.protobuf.ByteString data_ = com.google.protobuf.ByteString.EMPTY;
-    public boolean hasData() { return hasData; }
-    public com.google.protobuf.ByteString getData() { return data_; }
-    
-    // optional .com.android.glesv2debugger.Message.DataType data_type = 23;
-    public static final int DATA_TYPE_FIELD_NUMBER = 23;
-    private boolean hasDataType;
-    private com.android.glesv2debugger.DebuggerMessage.Message.DataType dataType_;
-    public boolean hasDataType() { return hasDataType; }
-    public com.android.glesv2debugger.DebuggerMessage.Message.DataType getDataType() { return dataType_; }
-    
-    // optional int32 pixel_format = 24;
-    public static final int PIXEL_FORMAT_FIELD_NUMBER = 24;
-    private boolean hasPixelFormat;
-    private int pixelFormat_ = 0;
-    public boolean hasPixelFormat() { return hasPixelFormat; }
-    public int getPixelFormat() { return pixelFormat_; }
-    
-    // optional int32 pixel_type = 25;
-    public static final int PIXEL_TYPE_FIELD_NUMBER = 25;
-    private boolean hasPixelType;
-    private int pixelType_ = 0;
-    public boolean hasPixelType() { return hasPixelType; }
-    public int getPixelType() { return pixelType_; }
-    
-    // optional int32 image_width = 26;
-    public static final int IMAGE_WIDTH_FIELD_NUMBER = 26;
-    private boolean hasImageWidth;
-    private int imageWidth_ = 0;
-    public boolean hasImageWidth() { return hasImageWidth; }
-    public int getImageWidth() { return imageWidth_; }
-    
-    // optional int32 image_height = 27;
-    public static final int IMAGE_HEIGHT_FIELD_NUMBER = 27;
-    private boolean hasImageHeight;
-    private int imageHeight_ = 0;
-    public boolean hasImageHeight() { return hasImageHeight; }
-    public int getImageHeight() { return imageHeight_; }
-    
-    // optional float time = 11;
-    public static final int TIME_FIELD_NUMBER = 11;
-    private boolean hasTime;
-    private float time_ = 0F;
-    public boolean hasTime() { return hasTime; }
-    public float getTime() { return time_; }
-    
-    // optional .com.android.glesv2debugger.Message.Prop prop = 21;
-    public static final int PROP_FIELD_NUMBER = 21;
-    private boolean hasProp;
-    private com.android.glesv2debugger.DebuggerMessage.Message.Prop prop_;
-    public boolean hasProp() { return hasProp; }
-    public com.android.glesv2debugger.DebuggerMessage.Message.Prop getProp() { return prop_; }
-    
-    // optional float clock = 22;
-    public static final int CLOCK_FIELD_NUMBER = 22;
-    private boolean hasClock;
-    private float clock_ = 0F;
-    public boolean hasClock() { return hasClock; }
-    public float getClock() { return clock_; }
-    
-    private void initFields() {
-      function_ = com.android.glesv2debugger.DebuggerMessage.Message.Function.NEG;
-      type_ = com.android.glesv2debugger.DebuggerMessage.Message.Type.BeforeCall;
-      dataType_ = com.android.glesv2debugger.DebuggerMessage.Message.DataType.ReferencedImage;
-      prop_ = com.android.glesv2debugger.DebuggerMessage.Message.Prop.CaptureDraw;
-    }
-    public final boolean isInitialized() {
-      if (!hasContextId) return false;
-      if (!hasFunction) return false;
-      if (!hasType) return false;
-      if (!hasExpectResponse) return false;
-      return true;
-    }
-    
-    public void writeTo(com.google.protobuf.CodedOutputStream output)
-                        throws java.io.IOException {
-      getSerializedSize();
-      if (hasContextId()) {
-        output.writeInt32(1, getContextId());
-      }
-      if (hasFunction()) {
-        output.writeEnum(2, getFunction().getNumber());
-      }
-      if (hasType()) {
-        output.writeEnum(3, getType().getNumber());
-      }
-      if (hasExpectResponse()) {
-        output.writeBool(4, getExpectResponse());
-      }
-      if (hasRet()) {
-        output.writeInt32(5, getRet());
-      }
-      if (hasArg0()) {
-        output.writeInt32(6, getArg0());
-      }
-      if (hasArg1()) {
-        output.writeInt32(7, getArg1());
-      }
-      if (hasArg2()) {
-        output.writeInt32(8, getArg2());
-      }
-      if (hasArg3()) {
-        output.writeInt32(9, getArg3());
-      }
-      if (hasData()) {
-        output.writeBytes(10, getData());
-      }
-      if (hasTime()) {
-        output.writeFloat(11, getTime());
-      }
-      if (hasArg4()) {
-        output.writeInt32(16, getArg4());
-      }
-      if (hasArg5()) {
-        output.writeInt32(17, getArg5());
-      }
-      if (hasArg6()) {
-        output.writeInt32(18, getArg6());
-      }
-      if (hasArg7()) {
-        output.writeInt32(19, getArg7());
-      }
-      if (hasArg8()) {
-        output.writeInt32(20, getArg8());
-      }
-      if (hasProp()) {
-        output.writeEnum(21, getProp().getNumber());
-      }
-      if (hasClock()) {
-        output.writeFloat(22, getClock());
-      }
-      if (hasDataType()) {
-        output.writeEnum(23, getDataType().getNumber());
-      }
-      if (hasPixelFormat()) {
-        output.writeInt32(24, getPixelFormat());
-      }
-      if (hasPixelType()) {
-        output.writeInt32(25, getPixelType());
-      }
-      if (hasImageWidth()) {
-        output.writeInt32(26, getImageWidth());
-      }
-      if (hasImageHeight()) {
-        output.writeInt32(27, getImageHeight());
-      }
-    }
-    
-    private int memoizedSerializedSize = -1;
-    public int getSerializedSize() {
-      int size = memoizedSerializedSize;
-      if (size != -1) return size;
-    
-      size = 0;
-      if (hasContextId()) {
-        size += com.google.protobuf.CodedOutputStream
-          .computeInt32Size(1, getContextId());
-      }
-      if (hasFunction()) {
-        size += com.google.protobuf.CodedOutputStream
-          .computeEnumSize(2, getFunction().getNumber());
-      }
-      if (hasType()) {
-        size += com.google.protobuf.CodedOutputStream
-          .computeEnumSize(3, getType().getNumber());
-      }
-      if (hasExpectResponse()) {
-        size += com.google.protobuf.CodedOutputStream
-          .computeBoolSize(4, getExpectResponse());
-      }
-      if (hasRet()) {
-        size += com.google.protobuf.CodedOutputStream
-          .computeInt32Size(5, getRet());
-      }
-      if (hasArg0()) {
-        size += com.google.protobuf.CodedOutputStream
-          .computeInt32Size(6, getArg0());
-      }
-      if (hasArg1()) {
-        size += com.google.protobuf.CodedOutputStream
-          .computeInt32Size(7, getArg1());
-      }
-      if (hasArg2()) {
-        size += com.google.protobuf.CodedOutputStream
-          .computeInt32Size(8, getArg2());
-      }
-      if (hasArg3()) {
-        size += com.google.protobuf.CodedOutputStream
-          .computeInt32Size(9, getArg3());
-      }
-      if (hasData()) {
-        size += com.google.protobuf.CodedOutputStream
-          .computeBytesSize(10, getData());
-      }
-      if (hasTime()) {
-        size += com.google.protobuf.CodedOutputStream
-          .computeFloatSize(11, getTime());
-      }
-      if (hasArg4()) {
-        size += com.google.protobuf.CodedOutputStream
-          .computeInt32Size(16, getArg4());
-      }
-      if (hasArg5()) {
-        size += com.google.protobuf.CodedOutputStream
-          .computeInt32Size(17, getArg5());
-      }
-      if (hasArg6()) {
-        size += com.google.protobuf.CodedOutputStream
-          .computeInt32Size(18, getArg6());
-      }
-      if (hasArg7()) {
-        size += com.google.protobuf.CodedOutputStream
-          .computeInt32Size(19, getArg7());
-      }
-      if (hasArg8()) {
-        size += com.google.protobuf.CodedOutputStream
-          .computeInt32Size(20, getArg8());
-      }
-      if (hasProp()) {
-        size += com.google.protobuf.CodedOutputStream
-          .computeEnumSize(21, getProp().getNumber());
-      }
-      if (hasClock()) {
-        size += com.google.protobuf.CodedOutputStream
-          .computeFloatSize(22, getClock());
-      }
-      if (hasDataType()) {
-        size += com.google.protobuf.CodedOutputStream
-          .computeEnumSize(23, getDataType().getNumber());
-      }
-      if (hasPixelFormat()) {
-        size += com.google.protobuf.CodedOutputStream
-          .computeInt32Size(24, getPixelFormat());
-      }
-      if (hasPixelType()) {
-        size += com.google.protobuf.CodedOutputStream
-          .computeInt32Size(25, getPixelType());
-      }
-      if (hasImageWidth()) {
-        size += com.google.protobuf.CodedOutputStream
-          .computeInt32Size(26, getImageWidth());
-      }
-      if (hasImageHeight()) {
-        size += com.google.protobuf.CodedOutputStream
-          .computeInt32Size(27, getImageHeight());
-      }
-      memoizedSerializedSize = size;
-      return size;
-    }
-    
-    public static com.android.glesv2debugger.DebuggerMessage.Message parseFrom(
-        com.google.protobuf.ByteString data)
-        throws com.google.protobuf.InvalidProtocolBufferException {
-      return newBuilder().mergeFrom(data).buildParsed();
-    }
-    public static com.android.glesv2debugger.DebuggerMessage.Message parseFrom(
-        com.google.protobuf.ByteString data,
-        com.google.protobuf.ExtensionRegistryLite extensionRegistry)
-        throws com.google.protobuf.InvalidProtocolBufferException {
-      return newBuilder().mergeFrom(data, extensionRegistry)
-               .buildParsed();
-    }
-    public static com.android.glesv2debugger.DebuggerMessage.Message parseFrom(byte[] data)
-        throws com.google.protobuf.InvalidProtocolBufferException {
-      return newBuilder().mergeFrom(data).buildParsed();
-    }
-    public static com.android.glesv2debugger.DebuggerMessage.Message parseFrom(
-        byte[] data,
-        com.google.protobuf.ExtensionRegistryLite extensionRegistry)
-        throws com.google.protobuf.InvalidProtocolBufferException {
-      return newBuilder().mergeFrom(data, extensionRegistry)
-               .buildParsed();
-    }
-    public static com.android.glesv2debugger.DebuggerMessage.Message parseFrom(java.io.InputStream input)
-        throws java.io.IOException {
-      return newBuilder().mergeFrom(input).buildParsed();
-    }
-    public static com.android.glesv2debugger.DebuggerMessage.Message parseFrom(
-        java.io.InputStream input,
-        com.google.protobuf.ExtensionRegistryLite extensionRegistry)
-        throws java.io.IOException {
-      return newBuilder().mergeFrom(input, extensionRegistry)
-               .buildParsed();
-    }
-    public static com.android.glesv2debugger.DebuggerMessage.Message parseDelimitedFrom(java.io.InputStream input)
-        throws java.io.IOException {
-      Builder builder = newBuilder();
-      if (builder.mergeDelimitedFrom(input)) {
-        return builder.buildParsed();
-      } else {
-        return null;
-      }
-    }
-    public static com.android.glesv2debugger.DebuggerMessage.Message parseDelimitedFrom(
-        java.io.InputStream input,
-        com.google.protobuf.ExtensionRegistryLite extensionRegistry)
-        throws java.io.IOException {
-      Builder builder = newBuilder();
-      if (builder.mergeDelimitedFrom(input, extensionRegistry)) {
-        return builder.buildParsed();
-      } else {
-        return null;
-      }
-    }
-    public static com.android.glesv2debugger.DebuggerMessage.Message parseFrom(
-        com.google.protobuf.CodedInputStream input)
-        throws java.io.IOException {
-      return newBuilder().mergeFrom(input).buildParsed();
-    }
-    public static com.android.glesv2debugger.DebuggerMessage.Message parseFrom(
-        com.google.protobuf.CodedInputStream input,
-        com.google.protobuf.ExtensionRegistryLite extensionRegistry)
-        throws java.io.IOException {
-      return newBuilder().mergeFrom(input, extensionRegistry)
-               .buildParsed();
-    }
-    
-    public static Builder newBuilder() { return Builder.create(); }
-    public Builder newBuilderForType() { return newBuilder(); }
-    public static Builder newBuilder(com.android.glesv2debugger.DebuggerMessage.Message prototype) {
-      return newBuilder().mergeFrom(prototype);
-    }
-    public Builder toBuilder() { return newBuilder(this); }
-    
-    public static final class Builder extends
-        com.google.protobuf.GeneratedMessageLite.Builder<
-          com.android.glesv2debugger.DebuggerMessage.Message, Builder> {
-      private com.android.glesv2debugger.DebuggerMessage.Message result;
-      
-      // Construct using com.android.glesv2debugger.DebuggerMessage.Message.newBuilder()
-      private Builder() {}
-      
-      private static Builder create() {
-        Builder builder = new Builder();
-        builder.result = new com.android.glesv2debugger.DebuggerMessage.Message();
-        return builder;
-      }
-      
-      protected com.android.glesv2debugger.DebuggerMessage.Message internalGetResult() {
-        return result;
-      }
-      
-      public Builder clear() {
-        if (result == null) {
-          throw new IllegalStateException(
-            "Cannot call clear() after build().");
-        }
-        result = new com.android.glesv2debugger.DebuggerMessage.Message();
-        return this;
-      }
-      
-      public Builder clone() {
-        return create().mergeFrom(result);
-      }
-      
-      public com.android.glesv2debugger.DebuggerMessage.Message getDefaultInstanceForType() {
-        return com.android.glesv2debugger.DebuggerMessage.Message.getDefaultInstance();
-      }
-      
-      public boolean isInitialized() {
-        return result.isInitialized();
-      }
-      public com.android.glesv2debugger.DebuggerMessage.Message build() {
-        if (result != null && !isInitialized()) {
-          throw newUninitializedMessageException(result);
-        }
-        return buildPartial();
-      }
-      
-      private com.android.glesv2debugger.DebuggerMessage.Message buildParsed()
-          throws com.google.protobuf.InvalidProtocolBufferException {
-        if (!isInitialized()) {
-          throw newUninitializedMessageException(
-            result).asInvalidProtocolBufferException();
-        }
-        return buildPartial();
-      }
-      
-      public com.android.glesv2debugger.DebuggerMessage.Message buildPartial() {
-        if (result == null) {
-          throw new IllegalStateException(
-            "build() has already been called on this Builder.");
-        }
-        com.android.glesv2debugger.DebuggerMessage.Message returnMe = result;
-        result = null;
-        return returnMe;
-      }
-      
-      public Builder mergeFrom(com.android.glesv2debugger.DebuggerMessage.Message other) {
-        if (other == com.android.glesv2debugger.DebuggerMessage.Message.getDefaultInstance()) return this;
-        if (other.hasContextId()) {
-          setContextId(other.getContextId());
-        }
-        if (other.hasFunction()) {
-          setFunction(other.getFunction());
-        }
-        if (other.hasType()) {
-          setType(other.getType());
-        }
-        if (other.hasExpectResponse()) {
-          setExpectResponse(other.getExpectResponse());
-        }
-        if (other.hasRet()) {
-          setRet(other.getRet());
-        }
-        if (other.hasArg0()) {
-          setArg0(other.getArg0());
-        }
-        if (other.hasArg1()) {
-          setArg1(other.getArg1());
-        }
-        if (other.hasArg2()) {
-          setArg2(other.getArg2());
-        }
-        if (other.hasArg3()) {
-          setArg3(other.getArg3());
-        }
-        if (other.hasArg4()) {
-          setArg4(other.getArg4());
-        }
-        if (other.hasArg5()) {
-          setArg5(other.getArg5());
-        }
-        if (other.hasArg6()) {
-          setArg6(other.getArg6());
-        }
-        if (other.hasArg7()) {
-          setArg7(other.getArg7());
-        }
-        if (other.hasArg8()) {
-          setArg8(other.getArg8());
-        }
-        if (other.hasData()) {
-          setData(other.getData());
-        }
-        if (other.hasDataType()) {
-          setDataType(other.getDataType());
-        }
-        if (other.hasPixelFormat()) {
-          setPixelFormat(other.getPixelFormat());
-        }
-        if (other.hasPixelType()) {
-          setPixelType(other.getPixelType());
-        }
-        if (other.hasImageWidth()) {
-          setImageWidth(other.getImageWidth());
-        }
-        if (other.hasImageHeight()) {
-          setImageHeight(other.getImageHeight());
-        }
-        if (other.hasTime()) {
-          setTime(other.getTime());
-        }
-        if (other.hasProp()) {
-          setProp(other.getProp());
-        }
-        if (other.hasClock()) {
-          setClock(other.getClock());
-        }
-        return this;
-      }
-      
-      public Builder mergeFrom(
-          com.google.protobuf.CodedInputStream input,
-          com.google.protobuf.ExtensionRegistryLite extensionRegistry)
-          throws java.io.IOException {
-        while (true) {
-          int tag = input.readTag();
-          switch (tag) {
-            case 0:
-              return this;
-            default: {
-              if (!parseUnknownField(input, extensionRegistry, tag)) {
-                return this;
-              }
-              break;
-            }
-            case 8: {
-              setContextId(input.readInt32());
-              break;
-            }
-            case 16: {
-              int rawValue = input.readEnum();
-              com.android.glesv2debugger.DebuggerMessage.Message.Function value = com.android.glesv2debugger.DebuggerMessage.Message.Function.valueOf(rawValue);
-              if (value != null) {
-                setFunction(value);
-              }
-              break;
-            }
-            case 24: {
-              int rawValue = input.readEnum();
-              com.android.glesv2debugger.DebuggerMessage.Message.Type value = com.android.glesv2debugger.DebuggerMessage.Message.Type.valueOf(rawValue);
-              if (value != null) {
-                setType(value);
-              }
-              break;
-            }
-            case 32: {
-              setExpectResponse(input.readBool());
-              break;
-            }
-            case 40: {
-              setRet(input.readInt32());
-              break;
-            }
-            case 48: {
-              setArg0(input.readInt32());
-              break;
-            }
-            case 56: {
-              setArg1(input.readInt32());
-              break;
-            }
-            case 64: {
-              setArg2(input.readInt32());
-              break;
-            }
-            case 72: {
-              setArg3(input.readInt32());
-              break;
-            }
-            case 82: {
-              setData(input.readBytes());
-              break;
-            }
-            case 93: {
-              setTime(input.readFloat());
-              break;
-            }
-            case 128: {
-              setArg4(input.readInt32());
-              break;
-            }
-            case 136: {
-              setArg5(input.readInt32());
-              break;
-            }
-            case 144: {
-              setArg6(input.readInt32());
-              break;
-            }
-            case 152: {
-              setArg7(input.readInt32());
-              break;
-            }
-            case 160: {
-              setArg8(input.readInt32());
-              break;
-            }
-            case 168: {
-              int rawValue = input.readEnum();
-              com.android.glesv2debugger.DebuggerMessage.Message.Prop value = com.android.glesv2debugger.DebuggerMessage.Message.Prop.valueOf(rawValue);
-              if (value != null) {
-                setProp(value);
-              }
-              break;
-            }
-            case 181: {
-              setClock(input.readFloat());
-              break;
-            }
-            case 184: {
-              int rawValue = input.readEnum();
-              com.android.glesv2debugger.DebuggerMessage.Message.DataType value = com.android.glesv2debugger.DebuggerMessage.Message.DataType.valueOf(rawValue);
-              if (value != null) {
-                setDataType(value);
-              }
-              break;
-            }
-            case 192: {
-              setPixelFormat(input.readInt32());
-              break;
-            }
-            case 200: {
-              setPixelType(input.readInt32());
-              break;
-            }
-            case 208: {
-              setImageWidth(input.readInt32());
-              break;
-            }
-            case 216: {
-              setImageHeight(input.readInt32());
-              break;
-            }
-          }
-        }
-      }
-      
-      
-      // required int32 context_id = 1;
-      public boolean hasContextId() {
-        return result.hasContextId();
-      }
-      public int getContextId() {
-        return result.getContextId();
-      }
-      public Builder setContextId(int value) {
-        result.hasContextId = true;
-        result.contextId_ = value;
-        return this;
-      }
-      public Builder clearContextId() {
-        result.hasContextId = false;
-        result.contextId_ = 0;
-        return this;
-      }
-      
-      // required .com.android.glesv2debugger.Message.Function function = 2 [default = NEG];
-      public boolean hasFunction() {
-        return result.hasFunction();
-      }
-      public com.android.glesv2debugger.DebuggerMessage.Message.Function getFunction() {
-        return result.getFunction();
-      }
-      public Builder setFunction(com.android.glesv2debugger.DebuggerMessage.Message.Function value) {
-        if (value == null) {
-          throw new NullPointerException();
-        }
-        result.hasFunction = true;
-        result.function_ = value;
-        return this;
-      }
-      public Builder clearFunction() {
-        result.hasFunction = false;
-        result.function_ = com.android.glesv2debugger.DebuggerMessage.Message.Function.NEG;
-        return this;
-      }
-      
-      // required .com.android.glesv2debugger.Message.Type type = 3;
-      public boolean hasType() {
-        return result.hasType();
-      }
-      public com.android.glesv2debugger.DebuggerMessage.Message.Type getType() {
-        return result.getType();
-      }
-      public Builder setType(com.android.glesv2debugger.DebuggerMessage.Message.Type value) {
-        if (value == null) {
-          throw new NullPointerException();
-        }
-        result.hasType = true;
-        result.type_ = value;
-        return this;
-      }
-      public Builder clearType() {
-        result.hasType = false;
-        result.type_ = com.android.glesv2debugger.DebuggerMessage.Message.Type.BeforeCall;
-        return this;
-      }
-      
-      // required bool expect_response = 4;
-      public boolean hasExpectResponse() {
-        return result.hasExpectResponse();
-      }
-      public boolean getExpectResponse() {
-        return result.getExpectResponse();
-      }
-      public Builder setExpectResponse(boolean value) {
-        result.hasExpectResponse = true;
-        result.expectResponse_ = value;
-        return this;
-      }
-      public Builder clearExpectResponse() {
-        result.hasExpectResponse = false;
-        result.expectResponse_ = false;
-        return this;
-      }
-      
-      // optional int32 ret = 5;
-      public boolean hasRet() {
-        return result.hasRet();
-      }
-      public int getRet() {
-        return result.getRet();
-      }
-      public Builder setRet(int value) {
-        result.hasRet = true;
-        result.ret_ = value;
-        return this;
-      }
-      public Builder clearRet() {
-        result.hasRet = false;
-        result.ret_ = 0;
-        return this;
-      }
-      
-      // optional int32 arg0 = 6;
-      public boolean hasArg0() {
-        return result.hasArg0();
-      }
-      public int getArg0() {
-        return result.getArg0();
-      }
-      public Builder setArg0(int value) {
-        result.hasArg0 = true;
-        result.arg0_ = value;
-        return this;
-      }
-      public Builder clearArg0() {
-        result.hasArg0 = false;
-        result.arg0_ = 0;
-        return this;
-      }
-      
-      // optional int32 arg1 = 7;
-      public boolean hasArg1() {
-        return result.hasArg1();
-      }
-      public int getArg1() {
-        return result.getArg1();
-      }
-      public Builder setArg1(int value) {
-        result.hasArg1 = true;
-        result.arg1_ = value;
-        return this;
-      }
-      public Builder clearArg1() {
-        result.hasArg1 = false;
-        result.arg1_ = 0;
-        return this;
-      }
-      
-      // optional int32 arg2 = 8;
-      public boolean hasArg2() {
-        return result.hasArg2();
-      }
-      public int getArg2() {
-        return result.getArg2();
-      }
-      public Builder setArg2(int value) {
-        result.hasArg2 = true;
-        result.arg2_ = value;
-        return this;
-      }
-      public Builder clearArg2() {
-        result.hasArg2 = false;
-        result.arg2_ = 0;
-        return this;
-      }
-      
-      // optional int32 arg3 = 9;
-      public boolean hasArg3() {
-        return result.hasArg3();
-      }
-      public int getArg3() {
-        return result.getArg3();
-      }
-      public Builder setArg3(int value) {
-        result.hasArg3 = true;
-        result.arg3_ = value;
-        return this;
-      }
-      public Builder clearArg3() {
-        result.hasArg3 = false;
-        result.arg3_ = 0;
-        return this;
-      }
-      
-      // optional int32 arg4 = 16;
-      public boolean hasArg4() {
-        return result.hasArg4();
-      }
-      public int getArg4() {
-        return result.getArg4();
-      }
-      public Builder setArg4(int value) {
-        result.hasArg4 = true;
-        result.arg4_ = value;
-        return this;
-      }
-      public Builder clearArg4() {
-        result.hasArg4 = false;
-        result.arg4_ = 0;
-        return this;
-      }
-      
-      // optional int32 arg5 = 17;
-      public boolean hasArg5() {
-        return result.hasArg5();
-      }
-      public int getArg5() {
-        return result.getArg5();
-      }
-      public Builder setArg5(int value) {
-        result.hasArg5 = true;
-        result.arg5_ = value;
-        return this;
-      }
-      public Builder clearArg5() {
-        result.hasArg5 = false;
-        result.arg5_ = 0;
-        return this;
-      }
-      
-      // optional int32 arg6 = 18;
-      public boolean hasArg6() {
-        return result.hasArg6();
-      }
-      public int getArg6() {
-        return result.getArg6();
-      }
-      public Builder setArg6(int value) {
-        result.hasArg6 = true;
-        result.arg6_ = value;
-        return this;
-      }
-      public Builder clearArg6() {
-        result.hasArg6 = false;
-        result.arg6_ = 0;
-        return this;
-      }
-      
-      // optional int32 arg7 = 19;
-      public boolean hasArg7() {
-        return result.hasArg7();
-      }
-      public int getArg7() {
-        return result.getArg7();
-      }
-      public Builder setArg7(int value) {
-        result.hasArg7 = true;
-        result.arg7_ = value;
-        return this;
-      }
-      public Builder clearArg7() {
-        result.hasArg7 = false;
-        result.arg7_ = 0;
-        return this;
-      }
-      
-      // optional int32 arg8 = 20;
-      public boolean hasArg8() {
-        return result.hasArg8();
-      }
-      public int getArg8() {
-        return result.getArg8();
-      }
-      public Builder setArg8(int value) {
-        result.hasArg8 = true;
-        result.arg8_ = value;
-        return this;
-      }
-      public Builder clearArg8() {
-        result.hasArg8 = false;
-        result.arg8_ = 0;
-        return this;
-      }
-      
-      // optional bytes data = 10;
-      public boolean hasData() {
-        return result.hasData();
-      }
-      public com.google.protobuf.ByteString getData() {
-        return result.getData();
-      }
-      public Builder setData(com.google.protobuf.ByteString value) {
-        if (value == null) {
-    throw new NullPointerException();
-  }
-  result.hasData = true;
-        result.data_ = value;
-        return this;
-      }
-      public Builder clearData() {
-        result.hasData = false;
-        result.data_ = getDefaultInstance().getData();
-        return this;
-      }
-      
-      // optional .com.android.glesv2debugger.Message.DataType data_type = 23;
-      public boolean hasDataType() {
-        return result.hasDataType();
-      }
-      public com.android.glesv2debugger.DebuggerMessage.Message.DataType getDataType() {
-        return result.getDataType();
-      }
-      public Builder setDataType(com.android.glesv2debugger.DebuggerMessage.Message.DataType value) {
-        if (value == null) {
-          throw new NullPointerException();
-        }
-        result.hasDataType = true;
-        result.dataType_ = value;
-        return this;
-      }
-      public Builder clearDataType() {
-        result.hasDataType = false;
-        result.dataType_ = com.android.glesv2debugger.DebuggerMessage.Message.DataType.ReferencedImage;
-        return this;
-      }
-      
-      // optional int32 pixel_format = 24;
-      public boolean hasPixelFormat() {
-        return result.hasPixelFormat();
-      }
-      public int getPixelFormat() {
-        return result.getPixelFormat();
-      }
-      public Builder setPixelFormat(int value) {
-        result.hasPixelFormat = true;
-        result.pixelFormat_ = value;
-        return this;
-      }
-      public Builder clearPixelFormat() {
-        result.hasPixelFormat = false;
-        result.pixelFormat_ = 0;
-        return this;
-      }
-      
-      // optional int32 pixel_type = 25;
-      public boolean hasPixelType() {
-        return result.hasPixelType();
-      }
-      public int getPixelType() {
-        return result.getPixelType();
-      }
-      public Builder setPixelType(int value) {
-        result.hasPixelType = true;
-        result.pixelType_ = value;
-        return this;
-      }
-      public Builder clearPixelType() {
-        result.hasPixelType = false;
-        result.pixelType_ = 0;
-        return this;
-      }
-      
-      // optional int32 image_width = 26;
-      public boolean hasImageWidth() {
-        return result.hasImageWidth();
-      }
-      public int getImageWidth() {
-        return result.getImageWidth();
-      }
-      public Builder setImageWidth(int value) {
-        result.hasImageWidth = true;
-        result.imageWidth_ = value;
-        return this;
-      }
-      public Builder clearImageWidth() {
-        result.hasImageWidth = false;
-        result.imageWidth_ = 0;
-        return this;
-      }
-      
-      // optional int32 image_height = 27;
-      public boolean hasImageHeight() {
-        return result.hasImageHeight();
-      }
-      public int getImageHeight() {
-        return result.getImageHeight();
-      }
-      public Builder setImageHeight(int value) {
-        result.hasImageHeight = true;
-        result.imageHeight_ = value;
-        return this;
-      }
-      public Builder clearImageHeight() {
-        result.hasImageHeight = false;
-        result.imageHeight_ = 0;
-        return this;
-      }
-      
-      // optional float time = 11;
-      public boolean hasTime() {
-        return result.hasTime();
-      }
-      public float getTime() {
-        return result.getTime();
-      }
-      public Builder setTime(float value) {
-        result.hasTime = true;
-        result.time_ = value;
-        return this;
-      }
-      public Builder clearTime() {
-        result.hasTime = false;
-        result.time_ = 0F;
-        return this;
-      }
-      
-      // optional .com.android.glesv2debugger.Message.Prop prop = 21;
-      public boolean hasProp() {
-        return result.hasProp();
-      }
-      public com.android.glesv2debugger.DebuggerMessage.Message.Prop getProp() {
-        return result.getProp();
-      }
-      public Builder setProp(com.android.glesv2debugger.DebuggerMessage.Message.Prop value) {
-        if (value == null) {
-          throw new NullPointerException();
-        }
-        result.hasProp = true;
-        result.prop_ = value;
-        return this;
-      }
-      public Builder clearProp() {
-        result.hasProp = false;
-        result.prop_ = com.android.glesv2debugger.DebuggerMessage.Message.Prop.CaptureDraw;
-        return this;
-      }
-      
-      // optional float clock = 22;
-      public boolean hasClock() {
-        return result.hasClock();
-      }
-      public float getClock() {
-        return result.getClock();
-      }
-      public Builder setClock(float value) {
-        result.hasClock = true;
-        result.clock_ = value;
-        return this;
-      }
-      public Builder clearClock() {
-        result.hasClock = false;
-        result.clock_ = 0F;
-        return this;
-      }
-      
-      // @@protoc_insertion_point(builder_scope:com.android.glesv2debugger.Message)
-    }
-    
-    static {
-      defaultInstance = new Message(true);
-      com.android.glesv2debugger.DebuggerMessage.internalForceInit();
-      defaultInstance.initFields();
-    }
-    
-    // @@protoc_insertion_point(class_scope:com.android.glesv2debugger.Message)
-  }
-  
-  
-  static {
-  }
-  
-  public static void internalForceInit() {}
-  
-  // @@protoc_insertion_point(outer_class_scope)
-}
diff --git a/tools/glesv2debugger/src/com/android/glesv2debugger/GLEnum.java b/tools/glesv2debugger/src/com/android/glesv2debugger/GLEnum.java
deleted file mode 100644
index 898c6e9..0000000
--- a/tools/glesv2debugger/src/com/android/glesv2debugger/GLEnum.java
+++ /dev/null
@@ -1,632 +0,0 @@
-/*
- ** Copyright 2011, The Android Open Source Project
- **
- ** Licensed under the Apache License, Version 2.0 (the "License");
- ** you may not use this file except in compliance with the License.
- ** You may obtain a copy of the License at
- **
- **     http://www.apache.org/licenses/LICENSE-2.0
- **
- ** Unless required by applicable law or agreed to in writing, software
- ** distributed under the License is distributed on an "AS IS" BASIS,
- ** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- ** See the License for the specific language governing permissions and
- ** limitations under the License.
- */
-
-// auto generated by generate_GLEnum_java.py"
-
-package com.android.glesv2debugger;
-
-public enum GLEnum {
-    GL_POINTS(0x0000),
-    GL_LINES(0x0001),
-    GL_LINE_LOOP(0x0002),
-    GL_LINE_STRIP(0x0003),
-    GL_TRIANGLES(0x0004),
-    GL_TRIANGLE_STRIP(0x0005),
-    GL_TRIANGLE_FAN(0x0006),
-    GL_ADD(0x0104),
-    GL_NEVER(0x0200),
-    GL_LESS(0x0201),
-    GL_EQUAL(0x0202),
-    GL_LEQUAL(0x0203),
-    GL_GREATER(0x0204),
-    GL_NOTEQUAL(0x0205),
-    GL_GEQUAL(0x0206),
-    GL_ALWAYS(0x0207),
-    GL_SRC_COLOR(0x0300),
-    GL_ONE_MINUS_SRC_COLOR(0x0301),
-    GL_SRC_ALPHA(0x0302),
-    GL_ONE_MINUS_SRC_ALPHA(0x0303),
-    GL_DST_ALPHA(0x0304),
-    GL_ONE_MINUS_DST_ALPHA(0x0305),
-    GL_DST_COLOR(0x0306),
-    GL_ONE_MINUS_DST_COLOR(0x0307),
-    GL_SRC_ALPHA_SATURATE(0x0308),
-    GL_FRONT(0x0404),
-    GL_BACK(0x0405),
-    GL_FRONT_AND_BACK(0x0408),
-    GL_INVALID_ENUM(0x0500),
-    GL_INVALID_VALUE(0x0501),
-    GL_INVALID_OPERATION(0x0502),
-    GL_STACK_OVERFLOW(0x0503),
-    GL_STACK_UNDERFLOW(0x0504),
-    GL_OUT_OF_MEMORY(0x0505),
-    GL_INVALID_FRAMEBUFFER_OPERATION(0x0506),
-    GL_EXP(0x0800),
-    GL_EXP2(0x0801),
-    GL_CW(0x0900),
-    GL_CCW(0x0901),
-    GL_CURRENT_COLOR(0x0B00),
-    GL_CURRENT_NORMAL(0x0B02),
-    GL_CURRENT_TEXTURE_COORDS(0x0B03),
-    GL_POINT_SMOOTH(0x0B10),
-    GL_POINT_SIZE(0x0B11),
-    GL_SMOOTH_POINT_SIZE_RANGE(0x0B12),
-    GL_LINE_SMOOTH(0x0B20),
-    GL_LINE_WIDTH(0x0B21),
-    GL_SMOOTH_LINE_WIDTH_RANGE(0x0B22),
-    GL_CULL_FACE(0x0B44),
-    GL_CULL_FACE_MODE(0x0B45),
-    GL_FRONT_FACE(0x0B46),
-    GL_LIGHTING(0x0B50),
-    GL_LIGHT_MODEL_TWO_SIDE(0x0B52),
-    GL_LIGHT_MODEL_AMBIENT(0x0B53),
-    GL_SHADE_MODEL(0x0B54),
-    GL_COLOR_MATERIAL(0x0B57),
-    GL_FOG(0x0B60),
-    GL_FOG_DENSITY(0x0B62),
-    GL_FOG_START(0x0B63),
-    GL_FOG_END(0x0B64),
-    GL_FOG_MODE(0x0B65),
-    GL_FOG_COLOR(0x0B66),
-    GL_DEPTH_RANGE(0x0B70),
-    GL_DEPTH_TEST(0x0B71),
-    GL_DEPTH_WRITEMASK(0x0B72),
-    GL_DEPTH_CLEAR_VALUE(0x0B73),
-    GL_DEPTH_FUNC(0x0B74),
-    GL_STENCIL_TEST(0x0B90),
-    GL_STENCIL_CLEAR_VALUE(0x0B91),
-    GL_STENCIL_FUNC(0x0B92),
-    GL_STENCIL_VALUE_MASK(0x0B93),
-    GL_STENCIL_FAIL(0x0B94),
-    GL_STENCIL_PASS_DEPTH_FAIL(0x0B95),
-    GL_STENCIL_PASS_DEPTH_PASS(0x0B96),
-    GL_STENCIL_REF(0x0B97),
-    GL_STENCIL_WRITEMASK(0x0B98),
-    GL_MATRIX_MODE(0x0BA0),
-    GL_NORMALIZE(0x0BA1),
-    GL_VIEWPORT(0x0BA2),
-    GL_MODELVIEW_STACK_DEPTH(0x0BA3),
-    GL_PROJECTION_STACK_DEPTH(0x0BA4),
-    GL_TEXTURE_STACK_DEPTH(0x0BA5),
-    GL_MODELVIEW_MATRIX(0x0BA6),
-    GL_PROJECTION_MATRIX(0x0BA7),
-    GL_TEXTURE_MATRIX(0x0BA8),
-    GL_ALPHA_TEST(0x0BC0),
-    GL_ALPHA_TEST_FUNC(0x0BC1),
-    GL_ALPHA_TEST_REF(0x0BC2),
-    GL_DITHER(0x0BD0),
-    GL_BLEND_DST(0x0BE0),
-    GL_BLEND_SRC(0x0BE1),
-    GL_BLEND(0x0BE2),
-    GL_LOGIC_OP_MODE(0x0BF0),
-    GL_COLOR_LOGIC_OP(0x0BF2),
-    GL_SCISSOR_BOX(0x0C10),
-    GL_SCISSOR_TEST(0x0C11),
-    GL_COLOR_CLEAR_VALUE(0x0C22),
-    GL_COLOR_WRITEMASK(0x0C23),
-    GL_PERSPECTIVE_CORRECTION_HINT(0x0C50),
-    GL_POINT_SMOOTH_HINT(0x0C51),
-    GL_LINE_SMOOTH_HINT(0x0C52),
-    GL_FOG_HINT(0x0C54),
-    GL_UNPACK_ALIGNMENT(0x0CF5),
-    GL_PACK_ALIGNMENT(0x0D05),
-    GL_ALPHA_SCALE(0x0D1C),
-    GL_MAX_LIGHTS(0x0D31),
-    GL_MAX_CLIP_PLANES(0x0D32),
-    GL_MAX_TEXTURE_SIZE(0x0D33),
-    GL_MAX_MODELVIEW_STACK_DEPTH(0x0D36),
-    GL_MAX_PROJECTION_STACK_DEPTH(0x0D38),
-    GL_MAX_TEXTURE_STACK_DEPTH(0x0D39),
-    GL_MAX_VIEWPORT_DIMS(0x0D3A),
-    GL_SUBPIXEL_BITS(0x0D50),
-    GL_RED_BITS(0x0D52),
-    GL_GREEN_BITS(0x0D53),
-    GL_BLUE_BITS(0x0D54),
-    GL_ALPHA_BITS(0x0D55),
-    GL_DEPTH_BITS(0x0D56),
-    GL_STENCIL_BITS(0x0D57),
-    GL_TEXTURE_2D(0x0DE1),
-    GL_DONT_CARE(0x1100),
-    GL_FASTEST(0x1101),
-    GL_NICEST(0x1102),
-    GL_AMBIENT(0x1200),
-    GL_DIFFUSE(0x1201),
-    GL_SPECULAR(0x1202),
-    GL_POSITION(0x1203),
-    GL_SPOT_DIRECTION(0x1204),
-    GL_SPOT_EXPONENT(0x1205),
-    GL_SPOT_CUTOFF(0x1206),
-    GL_CONSTANT_ATTENUATION(0x1207),
-    GL_LINEAR_ATTENUATION(0x1208),
-    GL_QUADRATIC_ATTENUATION(0x1209),
-    GL_BYTE(0x1400),
-    GL_UNSIGNED_BYTE(0x1401),
-    GL_SHORT(0x1402),
-    GL_UNSIGNED_SHORT(0x1403),
-    GL_INT(0x1404),
-    GL_UNSIGNED_INT(0x1405),
-    GL_FLOAT(0x1406),
-    GL_FIXED(0x140C),
-    GL_CLEAR(0x1500),
-    GL_AND(0x1501),
-    GL_AND_REVERSE(0x1502),
-    GL_COPY(0x1503),
-    GL_AND_INVERTED(0x1504),
-    GL_NOOP(0x1505),
-    GL_XOR(0x1506),
-    GL_OR(0x1507),
-    GL_NOR(0x1508),
-    GL_EQUIV(0x1509),
-    GL_INVERT(0x150A),
-    GL_OR_REVERSE(0x150B),
-    GL_COPY_INVERTED(0x150C),
-    GL_OR_INVERTED(0x150D),
-    GL_NAND(0x150E),
-    GL_SET(0x150F),
-    GL_EMISSION(0x1600),
-    GL_SHININESS(0x1601),
-    GL_AMBIENT_AND_DIFFUSE(0x1602),
-    GL_MODELVIEW(0x1700),
-    GL_PROJECTION(0x1701),
-    GL_TEXTURE(0x1702),
-    GL_COLOR_EXT(0x1800),
-    GL_DEPTH_EXT(0x1801),
-    GL_STENCIL_EXT(0x1802),
-    GL_STENCIL_INDEX(0x1901),
-    GL_DEPTH_COMPONENT(0x1902),
-    GL_ALPHA(0x1906),
-    GL_RGB(0x1907),
-    GL_RGBA(0x1908),
-    GL_LUMINANCE(0x1909),
-    GL_LUMINANCE_ALPHA(0x190A),
-    GL_FLAT(0x1D00),
-    GL_SMOOTH(0x1D01),
-    GL_KEEP(0x1E00),
-    GL_REPLACE(0x1E01),
-    GL_INCR(0x1E02),
-    GL_DECR(0x1E03),
-    GL_VENDOR(0x1F00),
-    GL_RENDERER(0x1F01),
-    GL_VERSION(0x1F02),
-    GL_EXTENSIONS(0x1F03),
-    GL_MODULATE(0x2100),
-    GL_DECAL(0x2101),
-    GL_TEXTURE_ENV_MODE(0x2200),
-    GL_TEXTURE_ENV_COLOR(0x2201),
-    GL_TEXTURE_ENV(0x2300),
-    GL_TEXTURE_GEN_MODE(0x2500),
-    GL_NEAREST(0x2600),
-    GL_LINEAR(0x2601),
-    GL_NEAREST_MIPMAP_NEAREST(0x2700),
-    GL_LINEAR_MIPMAP_NEAREST(0x2701),
-    GL_NEAREST_MIPMAP_LINEAR(0x2702),
-    GL_LINEAR_MIPMAP_LINEAR(0x2703),
-    GL_TEXTURE_MAG_FILTER(0x2800),
-    GL_TEXTURE_MIN_FILTER(0x2801),
-    GL_TEXTURE_WRAP_S(0x2802),
-    GL_TEXTURE_WRAP_T(0x2803),
-    GL_REPEAT(0x2901),
-    GL_POLYGON_OFFSET_UNITS(0x2A00),
-    GL_CLIP_PLANE0(0x3000),
-    GL_CLIP_PLANE1(0x3001),
-    GL_CLIP_PLANE2(0x3002),
-    GL_CLIP_PLANE3(0x3003),
-    GL_CLIP_PLANE4(0x3004),
-    GL_CLIP_PLANE5(0x3005),
-    GL_LIGHT0(0x4000),
-    GL_LIGHT1(0x4001),
-    GL_LIGHT2(0x4002),
-    GL_LIGHT3(0x4003),
-    GL_LIGHT4(0x4004),
-    GL_LIGHT5(0x4005),
-    GL_LIGHT6(0x4006),
-    GL_LIGHT7(0x4007),
-    GL_COVERAGE_BUFFER_BIT_NV(0x8000),
-    GL_CONSTANT_COLOR(0x8001),
-    GL_ONE_MINUS_CONSTANT_COLOR(0x8002),
-    GL_CONSTANT_ALPHA(0x8003),
-    GL_ONE_MINUS_CONSTANT_ALPHA(0x8004),
-    GL_BLEND_COLOR(0x8005),
-    GL_FUNC_ADD(0x8006),
-    GL_MIN_EXT(0x8007),
-    GL_MAX_EXT(0x8008),
-    GL_BLEND_EQUATION_RGB(0x8009),
-    GL_FUNC_SUBTRACT(0x800A),
-    GL_FUNC_REVERSE_SUBTRACT(0x800B),
-    GL_UNSIGNED_SHORT_4_4_4_4(0x8033),
-    GL_UNSIGNED_SHORT_5_5_5_1(0x8034),
-    GL_POLYGON_OFFSET_FILL(0x8037),
-    GL_POLYGON_OFFSET_FACTOR(0x8038),
-    GL_RESCALE_NORMAL(0x803A),
-    GL_RGB8(0x8051),
-    GL_RGBA4(0x8056),
-    GL_RGB5_A1(0x8057),
-    GL_RGBA8(0x8058),
-    GL_TEXTURE_BINDING_2D(0x8069),
-    GL_TEXTURE_BINDING_3D(0x806A),
-    GL_TEXTURE_3D(0x806F),
-    GL_TEXTURE_WRAP_R(0x8072),
-    GL_MAX_3D_TEXTURE_SIZE(0x8073),
-    GL_VERTEX_ARRAY(0x8074),
-    GL_NORMAL_ARRAY(0x8075),
-    GL_COLOR_ARRAY(0x8076),
-    GL_TEXTURE_COORD_ARRAY(0x8078),
-    GL_VERTEX_ARRAY_SIZE(0x807A),
-    GL_VERTEX_ARRAY_TYPE(0x807B),
-    GL_VERTEX_ARRAY_STRIDE(0x807C),
-    GL_NORMAL_ARRAY_TYPE(0x807E),
-    GL_NORMAL_ARRAY_STRIDE(0x807F),
-    GL_COLOR_ARRAY_SIZE(0x8081),
-    GL_COLOR_ARRAY_TYPE(0x8082),
-    GL_COLOR_ARRAY_STRIDE(0x8083),
-    GL_TEXTURE_COORD_ARRAY_SIZE(0x8088),
-    GL_TEXTURE_COORD_ARRAY_TYPE(0x8089),
-    GL_TEXTURE_COORD_ARRAY_STRIDE(0x808A),
-    GL_VERTEX_ARRAY_POINTER(0x808E),
-    GL_NORMAL_ARRAY_POINTER(0x808F),
-    GL_COLOR_ARRAY_POINTER(0x8090),
-    GL_TEXTURE_COORD_ARRAY_POINTER(0x8092),
-    GL_MULTISAMPLE(0x809D),
-    GL_SAMPLE_ALPHA_TO_COVERAGE(0x809E),
-    GL_SAMPLE_ALPHA_TO_ONE(0x809F),
-    GL_SAMPLE_COVERAGE(0x80A0),
-    GL_SAMPLE_BUFFERS(0x80A8),
-    GL_SAMPLES(0x80A9),
-    GL_SAMPLE_COVERAGE_VALUE(0x80AA),
-    GL_SAMPLE_COVERAGE_INVERT(0x80AB),
-    GL_BLEND_DST_RGB(0x80C8),
-    GL_BLEND_SRC_RGB(0x80C9),
-    GL_BLEND_DST_ALPHA(0x80CA),
-    GL_BLEND_SRC_ALPHA(0x80CB),
-    GL_BGRA_EXT(0x80E1),
-    GL_POINT_SIZE_MIN(0x8126),
-    GL_POINT_SIZE_MAX(0x8127),
-    GL_POINT_FADE_THRESHOLD_SIZE(0x8128),
-    GL_POINT_DISTANCE_ATTENUATION(0x8129),
-    GL_CLAMP_TO_EDGE(0x812F),
-    GL_GENERATE_MIPMAP(0x8191),
-    GL_GENERATE_MIPMAP_HINT(0x8192),
-    GL_DEPTH_COMPONENT16(0x81A5),
-    GL_DEPTH_COMPONENT24(0x81A6),
-    GL_DEPTH_COMPONENT32(0x81A7),
-    GL_UNSIGNED_SHORT_5_6_5(0x8363),
-    GL_UNSIGNED_SHORT_4_4_4_4_REV_EXT(0x8365),
-    GL_UNSIGNED_SHORT_1_5_5_5_REV_EXT(0x8366),
-    GL_UNSIGNED_INT_2_10_10_10_REV_EXT(0x8368),
-    GL_MIRRORED_REPEAT(0x8370),
-    GL_COMPRESSED_RGB_S3TC_DXT1_EXT(0x83F0),
-    GL_COMPRESSED_RGBA_S3TC_DXT1_EXT(0x83F1),
-    GL_ALIASED_POINT_SIZE_RANGE(0x846D),
-    GL_ALIASED_LINE_WIDTH_RANGE(0x846E),
-    GL_TEXTURE0(0x84C0),
-    GL_TEXTURE1(0x84C1),
-    GL_TEXTURE2(0x84C2),
-    GL_TEXTURE3(0x84C3),
-    GL_TEXTURE4(0x84C4),
-    GL_TEXTURE5(0x84C5),
-    GL_TEXTURE6(0x84C6),
-    GL_TEXTURE7(0x84C7),
-    GL_TEXTURE8(0x84C8),
-    GL_TEXTURE9(0x84C9),
-    GL_TEXTURE10(0x84CA),
-    GL_TEXTURE11(0x84CB),
-    GL_TEXTURE12(0x84CC),
-    GL_TEXTURE13(0x84CD),
-    GL_TEXTURE14(0x84CE),
-    GL_TEXTURE15(0x84CF),
-    GL_TEXTURE16(0x84D0),
-    GL_TEXTURE17(0x84D1),
-    GL_TEXTURE18(0x84D2),
-    GL_TEXTURE19(0x84D3),
-    GL_TEXTURE20(0x84D4),
-    GL_TEXTURE21(0x84D5),
-    GL_TEXTURE22(0x84D6),
-    GL_TEXTURE23(0x84D7),
-    GL_TEXTURE24(0x84D8),
-    GL_TEXTURE25(0x84D9),
-    GL_TEXTURE26(0x84DA),
-    GL_TEXTURE27(0x84DB),
-    GL_TEXTURE28(0x84DC),
-    GL_TEXTURE29(0x84DD),
-    GL_TEXTURE30(0x84DE),
-    GL_TEXTURE31(0x84DF),
-    GL_ACTIVE_TEXTURE(0x84E0),
-    GL_CLIENT_ACTIVE_TEXTURE(0x84E1),
-    GL_MAX_TEXTURE_UNITS(0x84E2),
-    GL_SUBTRACT(0x84E7),
-    GL_MAX_RENDERBUFFER_SIZE(0x84E8),
-    GL_ALL_COMPLETED_NV(0x84F2),
-    GL_FENCE_STATUS_NV(0x84F3),
-    GL_FENCE_CONDITION_NV(0x84F4),
-    GL_DEPTH_STENCIL(0x84F9),
-    GL_UNSIGNED_INT_24_8(0x84FA),
-    GL_MAX_TEXTURE_LOD_BIAS_EXT(0x84FD),
-    GL_TEXTURE_MAX_ANISOTROPY_EXT(0x84FE),
-    GL_MAX_TEXTURE_MAX_ANISOTROPY_EXT(0x84FF),
-    GL_TEXTURE_FILTER_CONTROL_EXT(0x8500),
-    GL_TEXTURE_LOD_BIAS_EXT(0x8501),
-    GL_INCR_WRAP(0x8507),
-    GL_DECR_WRAP(0x8508),
-    GL_NORMAL_MAP(0x8511),
-    GL_REFLECTION_MAP(0x8512),
-    GL_TEXTURE_CUBE_MAP(0x8513),
-    GL_TEXTURE_BINDING_CUBE_MAP(0x8514),
-    GL_TEXTURE_CUBE_MAP_POSITIVE_X(0x8515),
-    GL_TEXTURE_CUBE_MAP_NEGATIVE_X(0x8516),
-    GL_TEXTURE_CUBE_MAP_POSITIVE_Y(0x8517),
-    GL_TEXTURE_CUBE_MAP_NEGATIVE_Y(0x8518),
-    GL_TEXTURE_CUBE_MAP_POSITIVE_Z(0x8519),
-    GL_TEXTURE_CUBE_MAP_NEGATIVE_Z(0x851A),
-    GL_MAX_CUBE_MAP_TEXTURE_SIZE(0x851C),
-    GL_COMBINE(0x8570),
-    GL_COMBINE_RGB(0x8571),
-    GL_COMBINE_ALPHA(0x8572),
-    GL_RGB_SCALE(0x8573),
-    GL_ADD_SIGNED(0x8574),
-    GL_INTERPOLATE(0x8575),
-    GL_CONSTANT(0x8576),
-    GL_PRIMARY_COLOR(0x8577),
-    GL_PREVIOUS(0x8578),
-    GL_SRC0_RGB(0x8580),
-    GL_SRC1_RGB(0x8581),
-    GL_SRC2_RGB(0x8582),
-    GL_SRC0_ALPHA(0x8588),
-    GL_SRC1_ALPHA(0x8589),
-    GL_SRC2_ALPHA(0x858A),
-    GL_OPERAND0_RGB(0x8590),
-    GL_OPERAND1_RGB(0x8591),
-    GL_OPERAND2_RGB(0x8592),
-    GL_OPERAND0_ALPHA(0x8598),
-    GL_OPERAND1_ALPHA(0x8599),
-    GL_OPERAND2_ALPHA(0x859A),
-    GL_VERTEX_ARRAY_BINDING(0x85B5),
-    GL_VERTEX_ATTRIB_ARRAY_ENABLED(0x8622),
-    GL_VERTEX_ATTRIB_ARRAY_SIZE(0x8623),
-    GL_VERTEX_ATTRIB_ARRAY_STRIDE(0x8624),
-    GL_VERTEX_ATTRIB_ARRAY_TYPE(0x8625),
-    GL_CURRENT_VERTEX_ATTRIB(0x8626),
-    GL_VERTEX_ATTRIB_ARRAY_POINTER(0x8645),
-    GL_NUM_COMPRESSED_TEXTURE_FORMATS(0x86A2),
-    GL_COMPRESSED_TEXTURE_FORMATS(0x86A3),
-    GL_MAX_VERTEX_UNITS(0x86A4),
-    GL_WEIGHT_ARRAY_TYPE(0x86A9),
-    GL_WEIGHT_ARRAY_STRIDE(0x86AA),
-    GL_WEIGHT_ARRAY_SIZE(0x86AB),
-    GL_WEIGHT_ARRAY_POINTER(0x86AC),
-    GL_WEIGHT_ARRAY(0x86AD),
-    GL_DOT3_RGB(0x86AE),
-    GL_DOT3_RGBA(0x86AF),
-    GL_Z400_BINARY_AMD(0x8740),
-    GL_PROGRAM_BINARY_LENGTH(0x8741),
-    GL_BUFFER_SIZE(0x8764),
-    GL_BUFFER_USAGE(0x8765),
-    GL_ATC_RGBA_INTERPOLATED_ALPHA_AMD(0x87EE),
-    GL_3DC_X_AMD(0x87F9),
-    GL_3DC_XY_AMD(0x87FA),
-    GL_NUM_PROGRAM_BINARY_FORMATS(0x87FE),
-    GL_PROGRAM_BINARY_FORMATS(0x87FF),
-    GL_STENCIL_BACK_FUNC(0x8800),
-    GL_STENCIL_BACK_FAIL(0x8801),
-    GL_STENCIL_BACK_PASS_DEPTH_FAIL(0x8802),
-    GL_STENCIL_BACK_PASS_DEPTH_PASS(0x8803),
-    GL_WRITEONLY_RENDERING_QCOM(0x8823),
-    GL_BLEND_EQUATION_ALPHA(0x883D),
-    GL_MATRIX_PALETTE(0x8840),
-    GL_MAX_PALETTE_MATRICES(0x8842),
-    GL_CURRENT_PALETTE_MATRIX(0x8843),
-    GL_MATRIX_INDEX_ARRAY(0x8844),
-    GL_MATRIX_INDEX_ARRAY_SIZE(0x8846),
-    GL_MATRIX_INDEX_ARRAY_TYPE(0x8847),
-    GL_MATRIX_INDEX_ARRAY_STRIDE(0x8848),
-    GL_MATRIX_INDEX_ARRAY_POINTER(0x8849),
-    GL_POINT_SPRITE(0x8861),
-    GL_COORD_REPLACE(0x8862),
-    GL_MAX_VERTEX_ATTRIBS(0x8869),
-    GL_VERTEX_ATTRIB_ARRAY_NORMALIZED(0x886A),
-    GL_MAX_TEXTURE_IMAGE_UNITS(0x8872),
-    GL_ARRAY_BUFFER(0x8892),
-    GL_ELEMENT_ARRAY_BUFFER(0x8893),
-    GL_ARRAY_BUFFER_BINDING(0x8894),
-    GL_ELEMENT_ARRAY_BUFFER_BINDING(0x8895),
-    GL_VERTEX_ARRAY_BUFFER_BINDING(0x8896),
-    GL_NORMAL_ARRAY_BUFFER_BINDING(0x8897),
-    GL_COLOR_ARRAY_BUFFER_BINDING(0x8898),
-    GL_TEXTURE_COORD_ARRAY_BUFFER_BINDING(0x889A),
-    GL_WEIGHT_ARRAY_BUFFER_BINDING(0x889E),
-    GL_VERTEX_ATTRIB_ARRAY_BUFFER_BINDING(0x889F),
-    GL_WRITE_ONLY(0x88B9),
-    GL_BUFFER_ACCESS(0x88BB),
-    GL_BUFFER_MAPPED(0x88BC),
-    GL_BUFFER_MAP_POINTER(0x88BD),
-    GL_STREAM_DRAW(0x88E0),
-    GL_STATIC_DRAW(0x88E4),
-    GL_DYNAMIC_DRAW(0x88E8),
-    GL_DEPTH24_STENCIL8(0x88F0),
-    GL_POINT_SIZE_ARRAY_TYPE(0x898A),
-    GL_POINT_SIZE_ARRAY_STRIDE(0x898B),
-    GL_POINT_SIZE_ARRAY_POINTER(0x898C),
-    GL_MODELVIEW_MATRIX_FLOAT_AS_INT_BITS(0x898D),
-    GL_PROJECTION_MATRIX_FLOAT_AS_INT_BITS(0x898E),
-    GL_TEXTURE_MATRIX_FLOAT_AS_INT_BITS(0x898F),
-    GL_FRAGMENT_SHADER(0x8B30),
-    GL_VERTEX_SHADER(0x8B31),
-    GL_MAX_VERTEX_TEXTURE_IMAGE_UNITS(0x8B4C),
-    GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS(0x8B4D),
-    GL_SHADER_TYPE(0x8B4F),
-    GL_FLOAT_VEC2(0x8B50),
-    GL_FLOAT_VEC3(0x8B51),
-    GL_FLOAT_VEC4(0x8B52),
-    GL_INT_VEC2(0x8B53),
-    GL_INT_VEC3(0x8B54),
-    GL_INT_VEC4(0x8B55),
-    GL_BOOL(0x8B56),
-    GL_BOOL_VEC2(0x8B57),
-    GL_BOOL_VEC3(0x8B58),
-    GL_BOOL_VEC4(0x8B59),
-    GL_FLOAT_MAT2(0x8B5A),
-    GL_FLOAT_MAT3(0x8B5B),
-    GL_FLOAT_MAT4(0x8B5C),
-    GL_SAMPLER_2D(0x8B5E),
-    GL_SAMPLER_3D(0x8B5F),
-    GL_SAMPLER_CUBE(0x8B60),
-    GL_DELETE_STATUS(0x8B80),
-    GL_COMPILE_STATUS(0x8B81),
-    GL_LINK_STATUS(0x8B82),
-    GL_VALIDATE_STATUS(0x8B83),
-    GL_INFO_LOG_LENGTH(0x8B84),
-    GL_ATTACHED_SHADERS(0x8B85),
-    GL_ACTIVE_UNIFORMS(0x8B86),
-    GL_ACTIVE_UNIFORM_MAX_LENGTH(0x8B87),
-    GL_SHADER_SOURCE_LENGTH(0x8B88),
-    GL_ACTIVE_ATTRIBUTES(0x8B89),
-    GL_ACTIVE_ATTRIBUTE_MAX_LENGTH(0x8B8A),
-    GL_FRAGMENT_SHADER_DERIVATIVE_HINT(0x8B8B),
-    GL_SHADING_LANGUAGE_VERSION(0x8B8C),
-    GL_CURRENT_PROGRAM(0x8B8D),
-    GL_PALETTE4_RGB8(0x8B90),
-    GL_PALETTE4_RGBA8(0x8B91),
-    GL_PALETTE4_R5_G6_B5(0x8B92),
-    GL_PALETTE4_RGBA4(0x8B93),
-    GL_PALETTE4_RGB5_A1(0x8B94),
-    GL_PALETTE8_RGB8(0x8B95),
-    GL_PALETTE8_RGBA8(0x8B96),
-    GL_PALETTE8_R5_G6_B5(0x8B97),
-    GL_PALETTE8_RGBA4(0x8B98),
-    GL_PALETTE8_RGB5_A1(0x8B99),
-    GL_IMPLEMENTATION_COLOR_READ_TYPE(0x8B9A),
-    GL_IMPLEMENTATION_COLOR_READ_FORMAT(0x8B9B),
-    GL_POINT_SIZE_ARRAY(0x8B9C),
-    GL_TEXTURE_CROP_RECT(0x8B9D),
-    GL_MATRIX_INDEX_ARRAY_BUFFER_BINDING(0x8B9E),
-    GL_POINT_SIZE_ARRAY_BUFFER_BINDING(0x8B9F),
-    GL_COUNTER_TYPE_AMD(0x8BC0),
-    GL_COUNTER_RANGE_AMD(0x8BC1),
-    GL_UNSIGNED_INT64_AMD(0x8BC2),
-    GL_PERCENTAGE_AMD(0x8BC3),
-    GL_PERFMON_RESULT_AVAILABLE_AMD(0x8BC4),
-    GL_PERFMON_RESULT_SIZE_AMD(0x8BC5),
-    GL_PERFMON_RESULT_AMD(0x8BC6),
-    GL_TEXTURE_WIDTH_QCOM(0x8BD2),
-    GL_TEXTURE_HEIGHT_QCOM(0x8BD3),
-    GL_TEXTURE_DEPTH_QCOM(0x8BD4),
-    GL_TEXTURE_INTERNAL_FORMAT_QCOM(0x8BD5),
-    GL_TEXTURE_FORMAT_QCOM(0x8BD6),
-    GL_TEXTURE_TYPE_QCOM(0x8BD7),
-    GL_TEXTURE_IMAGE_VALID_QCOM(0x8BD8),
-    GL_TEXTURE_NUM_LEVELS_QCOM(0x8BD9),
-    GL_TEXTURE_TARGET_QCOM(0x8BDA),
-    GL_TEXTURE_OBJECT_VALID_QCOM(0x8BDB),
-    GL_STATE_RESTORE(0x8BDC),
-    GL_COMPRESSED_RGB_PVRTC_4BPPV1_IMG(0x8C00),
-    GL_COMPRESSED_RGB_PVRTC_2BPPV1_IMG(0x8C01),
-    GL_COMPRESSED_RGBA_PVRTC_4BPPV1_IMG(0x8C02),
-    GL_COMPRESSED_RGBA_PVRTC_2BPPV1_IMG(0x8C03),
-    GL_MODULATE_COLOR_IMG(0x8C04),
-    GL_RECIP_ADD_SIGNED_ALPHA_IMG(0x8C05),
-    GL_TEXTURE_ALPHA_MODULATE_IMG(0x8C06),
-    GL_FACTOR_ALPHA_MODULATE_IMG(0x8C07),
-    GL_FRAGMENT_ALPHA_MODULATE_IMG(0x8C08),
-    GL_ADD_BLEND_IMG(0x8C09),
-    GL_SGX_BINARY_IMG(0x8C0A),
-    GL_ATC_RGB_AMD(0x8C92),
-    GL_ATC_RGBA_EXPLICIT_ALPHA_AMD(0x8C93),
-    GL_STENCIL_BACK_REF(0x8CA3),
-    GL_STENCIL_BACK_VALUE_MASK(0x8CA4),
-    GL_STENCIL_BACK_WRITEMASK(0x8CA5),
-    GL_FRAMEBUFFER_BINDING(0x8CA6),
-    GL_RENDERBUFFER_BINDING(0x8CA7),
-    GL_FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE(0x8CD0),
-    GL_FRAMEBUFFER_ATTACHMENT_OBJECT_NAME(0x8CD1),
-    GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LEVEL(0x8CD2),
-    GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_CUBE_MAP_FACE(0x8CD3),
-    GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_3D_ZOFFSET(0x8CD4),
-    GL_FRAMEBUFFER_COMPLETE(0x8CD5),
-    GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT(0x8CD6),
-    GL_FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT(0x8CD7),
-    GL_FRAMEBUFFER_INCOMPLETE_DIMENSIONS(0x8CD9),
-    GL_FRAMEBUFFER_INCOMPLETE_FORMATS(0x8CDA),
-    GL_FRAMEBUFFER_UNSUPPORTED(0x8CDD),
-    GL_COLOR_ATTACHMENT0(0x8CE0),
-    GL_DEPTH_ATTACHMENT(0x8D00),
-    GL_STENCIL_ATTACHMENT(0x8D20),
-    GL_FRAMEBUFFER(0x8D40),
-    GL_RENDERBUFFER(0x8D41),
-    GL_RENDERBUFFER_WIDTH(0x8D42),
-    GL_RENDERBUFFER_HEIGHT(0x8D43),
-    GL_RENDERBUFFER_INTERNAL_FORMAT(0x8D44),
-    GL_STENCIL_INDEX1(0x8D46),
-    GL_STENCIL_INDEX4(0x8D47),
-    GL_STENCIL_INDEX8(0x8D48),
-    GL_RENDERBUFFER_RED_SIZE(0x8D50),
-    GL_RENDERBUFFER_GREEN_SIZE(0x8D51),
-    GL_RENDERBUFFER_BLUE_SIZE(0x8D52),
-    GL_RENDERBUFFER_ALPHA_SIZE(0x8D53),
-    GL_RENDERBUFFER_DEPTH_SIZE(0x8D54),
-    GL_RENDERBUFFER_STENCIL_SIZE(0x8D55),
-    GL_TEXTURE_GEN_STR(0x8D60),
-    GL_HALF_FLOAT(0x8D61),
-    GL_RGB565(0x8D62),
-    GL_ETC1_RGB8(0x8D64),
-    GL_TEXTURE_EXTERNAL(0x8D65),
-    GL_SAMPLER_EXTERNAL(0x8D66),
-    GL_TEXTURE_BINDING_EXTERNAL(0x8D67),
-    GL_REQUIRED_TEXTURE_IMAGE_UNITS(0x8D68),
-    GL_LOW_FLOAT(0x8DF0),
-    GL_MEDIUM_FLOAT(0x8DF1),
-    GL_HIGH_FLOAT(0x8DF2),
-    GL_LOW_INT(0x8DF3),
-    GL_MEDIUM_INT(0x8DF4),
-    GL_HIGH_INT(0x8DF5),
-    GL_UNSIGNED_INT_10_10_10_2(0x8DF6),
-    GL_INT_10_10_10_2(0x8DF7),
-    GL_SHADER_BINARY_FORMATS(0x8DF8),
-    GL_NUM_SHADER_BINARY_FORMATS(0x8DF9),
-    GL_SHADER_COMPILER(0x8DFA),
-    GL_MAX_VERTEX_UNIFORM_VECTORS(0x8DFB),
-    GL_MAX_VARYING_VECTORS(0x8DFC),
-    GL_MAX_FRAGMENT_UNIFORM_VECTORS(0x8DFD),
-    GL_DEPTH_COMPONENT16_NONLINEAR_NV(0x8E2C),
-    GL_COVERAGE_COMPONENT_NV(0x8ED0),
-    GL_COVERAGE_COMPONENT4_NV(0x8ED1),
-    GL_COVERAGE_ATTACHMENT_NV(0x8ED2),
-    GL_COVERAGE_BUFFERS_NV(0x8ED3),
-    GL_COVERAGE_SAMPLES_NV(0x8ED4),
-    GL_COVERAGE_ALL_FRAGMENTS_NV(0x8ED5),
-    GL_COVERAGE_EDGE_FRAGMENTS_NV(0x8ED6),
-    GL_COVERAGE_AUTOMATIC_NV(0x8ED7),
-    GL_PERFMON_GLOBAL_MODE_QCOM(0x8FA0),
-    GL_SGX_PROGRAM_BINARY_IMG(0x9130),
-    GL_RENDERBUFFER_SAMPLES_IMG(0x9133),
-    GL_FRAMEBUFFER_INCOMPLETE_MULTISAMPLE_IMG(0x9134),
-    GL_MAX_SAMPLES_IMG(0x9135),
-    GL_TEXTURE_SAMPLES_IMG(0x9136),
-    ;
-
-    public final int value;
-    GLEnum(final int value) {
-        this.value = value;
-    }
-
-    private static final java.util.HashMap<Integer, GLEnum> reverseMap = new java.util.HashMap<Integer, GLEnum>();
-    static {
-        for (GLEnum e : GLEnum.values())
-        reverseMap.put(e.value, e);
-    }
-
-    public static GLEnum valueOf(final int value) {
-        return reverseMap.get(value);
-    }
-}
\ No newline at end of file
diff --git a/tools/glesv2debugger/src/com/android/glesv2debugger/GLServerShader.java b/tools/glesv2debugger/src/com/android/glesv2debugger/GLServerShader.java
deleted file mode 100644
index f13c465..0000000
--- a/tools/glesv2debugger/src/com/android/glesv2debugger/GLServerShader.java
+++ /dev/null
@@ -1,259 +0,0 @@
-/*
- ** Copyright 2011, The Android Open Source Project
- **
- ** Licensed under the Apache License, Version 2.0 (the "License");
- ** you may not use this file except in compliance with the License.
- ** You may obtain a copy of the License at
- **
- **     http://www.apache.org/licenses/LICENSE-2.0
- **
- ** Unless required by applicable law or agreed to in writing, software
- ** distributed under the License is distributed on an "AS IS" BASIS,
- ** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- ** See the License for the specific language governing permissions and
- ** limitations under the License.
- */
-
-package com.android.glesv2debugger;
-
-import com.android.glesv2debugger.DebuggerMessage.Message;
-import com.android.sdklib.util.SparseArray;
-
-import java.util.ArrayList;
-
-class GLShader implements Cloneable {
-    public final int name;
-    GLServerShader context; // the context this was created in
-    public final GLEnum type;
-    public boolean delete;
-    public ArrayList<Integer> programs = new ArrayList<Integer>();
-    public String source, originalSource;
-
-    GLShader(final int name, final GLServerShader context, final GLEnum type) {
-        this.name = name;
-        this.context = context;
-        this.type = type;
-    }
-
-    /** deep copy */
-    public GLShader clone(final GLServerShader copyContext) {
-        try {
-            GLShader shader = (GLShader) super.clone();
-            shader.programs = (ArrayList<Integer>) programs.clone();
-            shader.context = copyContext;
-            return shader;
-        } catch (CloneNotSupportedException e) {
-            e.printStackTrace();
-            assert false;
-            return null;
-        }
-    }
-}
-
-class GLProgram implements Cloneable {
-    public final int name;
-    GLServerShader context; // the context this was created in
-    public boolean delete;
-    public int vert, frag;
-
-    GLProgram(final int name, final GLServerShader context) {
-        this.name = name;
-        this.context = context;
-    }
-
-    /** deep copy */
-    public GLProgram clone(final GLServerShader copyContext) {
-        try {
-            GLProgram copy = (GLProgram) super.clone();
-            copy.context = copyContext;
-            return copy;
-        } catch (CloneNotSupportedException e) {
-            e.printStackTrace();
-            assert false;
-            return null;
-        }
-    }
-}
-
-public class GLServerShader implements Cloneable {
-    Context context;
-    public SparseArray<GLShader> shaders = new SparseArray<GLShader>();
-    public SparseArray<GLProgram> programs = new SparseArray<GLProgram>();
-    public GLProgram current = null;
-    boolean uiUpdate = false;
-
-    GLServerShader(Context context) {
-        this.context = context;
-    }
-
-    /** deep copy */
-    public GLServerShader clone(final Context copyContext) {
-        try {
-            GLServerShader copy = (GLServerShader) super.clone();
-            copy.context = copyContext;
-
-            copy.shaders = new SparseArray<GLShader>(shaders.size());
-            for (int i = 0; i < shaders.size(); i++)
-                copy.shaders.append(shaders.keyAt(i), shaders.valueAt(i).clone(copy));
-
-            copy.programs = new SparseArray<GLProgram>(programs.size());
-            for (int i = 0; i < programs.size(); i++)
-                copy.programs.append(programs.keyAt(i), programs.valueAt(i).clone(copy));
-
-            if (current != null)
-                copy.current = copy.programs.get(current.name);
-            return copy;
-        } catch (CloneNotSupportedException e) {
-            e.printStackTrace();
-            assert false;
-            return null;
-        }
-    }
-
-    /** returns true if processed */
-    public boolean processMessage(final Message msg) {
-        boolean oldUiUpdate = uiUpdate;
-        uiUpdate = true;
-        switch (msg.getFunction()) {
-            case glAttachShader:
-                glAttachShader(msg);
-                return true;
-            case glCreateProgram:
-                glCreateProgram(msg);
-                return true;
-            case glCreateShader:
-                glCreateShader(msg);
-                return true;
-            case glDeleteProgram:
-                glDeleteProgram(msg);
-                return true;
-            case glDeleteShader:
-                glDeleteShader(msg);
-                return true;
-            case glDetachShader:
-                glDetachShader(msg);
-                return true;
-            case glShaderSource:
-                glShaderSource(msg);
-                return true;
-            case glUseProgram:
-                glUseProgram(msg);
-                return true;
-            default:
-                uiUpdate = oldUiUpdate;
-                return false;
-        }
-    }
-
-    GLShader getShader(int name) {
-        if (name == 0)
-            return null;
-        for (Context ctx : context.shares) {
-            GLShader shader = ctx.serverShader.shaders.get(name);
-            if (shader != null)
-                return shader;
-        }
-        assert false;
-        return null;
-    }
-
-    GLProgram getProgram(int name) {
-        if (name == 0)
-            return null;
-        for (Context ctx : context.shares) {
-            GLProgram program = ctx.serverShader.programs.get(name);
-            if (program != null)
-                return program;
-        }
-        assert false;
-        return null;
-    }
-
-    // void API_ENTRY(glAttachShader)(GLuint program, GLuint shader)
-    void glAttachShader(final Message msg) {
-        GLProgram program = getProgram(msg.getArg0());
-        assert program != null;
-        GLShader shader = getShader(msg.getArg1());
-        assert program != null;
-        if (GLEnum.GL_VERTEX_SHADER == shader.type)
-            program.vert = shader.name;
-        else
-            program.frag = shader.name;
-        shader.programs.add(program.name);
-    }
-
-    // GLuint API_ENTRY(glCreateProgram)(void)
-    void glCreateProgram(final Message msg) {
-        programs.put(msg.getRet(), new GLProgram(msg.getRet(), this));
-    }
-
-    // GLuint API_ENTRY(glCreateShader)(GLenum type)
-    void glCreateShader(final Message msg) {
-        shaders.put(msg.getRet(),
-                new GLShader(msg.getRet(), this, GLEnum.valueOf(msg.getArg0())));
-    }
-
-    // void API_ENTRY(glDeleteProgram)
-    void glDeleteProgram(final Message msg) {
-        if (msg.getArg0() == 0)
-            return;
-        GLProgram program = getProgram(msg.getArg0());
-        program.delete = true;
-        for (Context ctx : context.shares)
-            if (ctx.serverShader.current == program)
-                return;
-        glDetachShader(program, getShader(program.vert));
-        glDetachShader(program, getShader(program.frag));
-        programs.remove(program.name);
-    }
-
-    // void API_ENTRY(glDeleteShader)(GLuint shader)
-    void glDeleteShader(final Message msg) {
-        if (msg.getArg0() == 0)
-            return;
-        GLShader shader = getShader(msg.getArg0());
-        shader.delete = true;
-        if (shader.programs.size() == 0)
-            shaders.remove(shader.name);
-    }
-
-    // void API_ENTRY(glDetachShader)(GLuint program, GLuint shader)
-    void glDetachShader(final Message msg) {
-        glDetachShader(getProgram(msg.getArg0()), getShader(msg.getArg1()));
-    }
-
-    void glDetachShader(final GLProgram program, final GLShader shader) {
-        if (program == null)
-            return;
-        if (program.vert == shader.name)
-            program.vert = 0;
-        else if (program.frag == shader.name)
-            program.frag = 0;
-        else
-            return;
-        shader.programs.remove(new Integer(program.name));
-        if (shader.delete && shader.programs.size() == 0)
-            shaders.remove(shader.name);
-    }
-
-    // void API_ENTRY(glShaderSource)(GLuint shader, GLsizei count, const
-    // GLchar** string, const GLint* length)
-    void glShaderSource(final Message msg) {
-        if (!msg.hasData())
-            return; // TODO: distinguish between generated calls
-        GLShader shader = getShader(msg.getArg0());
-        shader.source = shader.originalSource = msg.getData().toStringUtf8();
-    }
-
-    // void API_ENTRY(glUseProgram)(GLuint program)
-    void glUseProgram(final Message msg) {
-        GLProgram oldCurrent = current;
-        current = getProgram(msg.getArg0());
-        if (null != oldCurrent && oldCurrent.delete && oldCurrent != current) {
-            for (Context ctx : context.shares)
-                if (ctx.serverShader.current == oldCurrent)
-                    return;
-            oldCurrent.context.programs.remove(new Integer(oldCurrent.name));
-        }
-    }
-}
diff --git a/tools/glesv2debugger/src/com/android/glesv2debugger/GLServerState.java b/tools/glesv2debugger/src/com/android/glesv2debugger/GLServerState.java
deleted file mode 100644
index addf277..0000000
--- a/tools/glesv2debugger/src/com/android/glesv2debugger/GLServerState.java
+++ /dev/null
@@ -1,271 +0,0 @@
-/*
- ** Copyright 2011, The Android Open Source Project
- **
- ** Licensed under the Apache License, Version 2.0 (the "License");
- ** you may not use this file except in compliance with the License.
- ** You may obtain a copy of the License at
- **
- **     http://www.apache.org/licenses/LICENSE-2.0
- **
- ** Unless required by applicable law or agreed to in writing, software
- ** distributed under the License is distributed on an "AS IS" BASIS,
- ** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- ** See the License for the specific language governing permissions and
- ** limitations under the License.
- */
-
-package com.android.glesv2debugger;
-
-import com.android.glesv2debugger.DebuggerMessage.Message;
-import com.android.glesv2debugger.DebuggerMessage.Message.Function;
-import com.android.sdklib.util.SparseArray;
-import com.android.sdklib.util.SparseIntArray;
-
-class GLStencilState implements Cloneable {
-    public int ref, mask;
-    public GLEnum func;
-    public GLEnum sf, df, dp; // operation
-
-    @Override
-    public Object clone() {
-        try {
-            return super.clone();
-        } catch (CloneNotSupportedException e) {
-            e.printStackTrace();
-            return null;
-        }
-    }
-}
-
-public class GLServerState implements Cloneable {
-    final Context context;
-    public GLStencilState front = new GLStencilState(), back = new GLStencilState();
-    public SparseIntArray enableDisables;
-
-    /** integer states set via a GL function and GLEnum; keyed by GLEnum.value */
-    public SparseArray<Message> integers;
-
-    /** states set only via a GL function; keyed by Function.getNumber() */
-    public SparseArray<Message> lastSetter;
-
-    GLServerState(final Context context) {
-        this.context = context;
-        enableDisables = new SparseIntArray();
-        enableDisables.put(GLEnum.GL_BLEND.value, 0);
-        enableDisables.put(GLEnum.GL_DITHER.value, 1);
-        enableDisables.put(GLEnum.GL_DEPTH_TEST.value, 0);
-        enableDisables.put(GLEnum.GL_STENCIL_TEST.value, 0);
-        enableDisables.put(GLEnum.GL_SCISSOR_TEST.value, 0);
-        enableDisables.put(GLEnum.GL_SAMPLE_COVERAGE.value, 0);
-        enableDisables.put(GLEnum.GL_SAMPLE_ALPHA_TO_COVERAGE.value, 0);
-        enableDisables.put(GLEnum.GL_POLYGON_OFFSET_FILL.value, 0);
-        enableDisables.put(GLEnum.GL_CULL_FACE.value, 0);
-        // enableDisables.put(GLEnum.GL_TEXTURE_2D.value, 1);
-
-        lastSetter = new SparseArray<Message>();
-        lastSetter.put(Function.glBlendColor.getNumber(), null);
-        // glBlendEquation overwrites glBlendEquationSeparate
-        lastSetter.put(Function.glBlendEquationSeparate.getNumber(), null);
-        // glBlendFunc overwrites glBlendFuncSeparate
-        lastSetter.put(Function.glBlendFuncSeparate.getNumber(), null);
-        lastSetter.put(Function.glClearColor.getNumber(), null);
-        lastSetter.put(Function.glClearDepthf.getNumber(), null);
-        lastSetter.put(Function.glClearStencil.getNumber(), null);
-        lastSetter.put(Function.glColorMask.getNumber(), null);
-        lastSetter.put(Function.glCullFace.getNumber(), null);
-        lastSetter.put(Function.glDepthMask.getNumber(), null);
-        lastSetter.put(Function.glDepthFunc.getNumber(), null);
-        lastSetter.put(Function.glDepthRangef.getNumber(), null);
-        lastSetter.put(Function.glFrontFace.getNumber(), null);
-        lastSetter.put(Function.glLineWidth.getNumber(), null);
-        lastSetter.put(Function.glPolygonOffset.getNumber(), null);
-        lastSetter.put(Function.glSampleCoverage.getNumber(), null);
-        lastSetter.put(Function.glScissor.getNumber(), null);
-        lastSetter.put(Function.glStencilMaskSeparate.getNumber(), null);
-        lastSetter.put(Function.glViewport.getNumber(), null);
-
-        integers = new SparseArray<Message>();
-        integers.put(GLEnum.GL_PACK_ALIGNMENT.value, null);
-        integers.put(GLEnum.GL_UNPACK_ALIGNMENT.value, null);
-    }
-
-    /** returns true if processed */
-    public boolean processMessage(final Message msg) {
-        switch (msg.getFunction()) {
-            case glBlendColor:
-            case glBlendEquation:
-            case glBlendEquationSeparate:
-            case glBlendFunc:
-            case glBlendFuncSeparate:
-            case glClearColor:
-            case glClearDepthf:
-            case glClearStencil:
-            case glColorMask:
-            case glCullFace:
-            case glDepthMask:
-            case glDepthFunc:
-            case glDepthRangef:
-                return setter(msg);
-            case glDisable:
-                return enableDisable(false, msg);
-            case glEnable:
-                return enableDisable(true, msg);
-            case glFrontFace:
-            case glLineWidth:
-                return setter(msg);
-            case glPixelStorei:
-                if (GLEnum.valueOf(msg.getArg0()) == GLEnum.GL_PACK_ALIGNMENT)
-                    integers.put(msg.getArg0(), msg);
-                else if (GLEnum.valueOf(msg.getArg0()) == GLEnum.GL_UNPACK_ALIGNMENT)
-                    integers.put(msg.getArg0(), msg);
-                else
-                    assert false;
-                return true;
-            case glPolygonOffset:
-            case glSampleCoverage:
-            case glScissor:
-                return setter(msg);
-            case glStencilFunc: {
-                Message.Builder builder = msg.toBuilder();
-                builder.setArg2(msg.getArg1());
-                builder.setArg1(msg.getArg0());
-                builder.setArg0(GLEnum.GL_FRONT_AND_BACK.value);
-                return glStencilFuncSeparate(builder.build());
-            }
-            case glStencilFuncSeparate:
-                return glStencilFuncSeparate(msg);
-            case glStencilMask:
-            case glStencilMaskSeparate:
-                return setter(msg);
-            case glStencilOp: {
-                Message.Builder builder = msg.toBuilder();
-                builder.setArg3(msg.getArg2());
-                builder.setArg2(msg.getArg1());
-                builder.setArg1(msg.getArg0());
-                builder.setArg0(GLEnum.GL_FRONT_AND_BACK.value);
-                return glStencilOpSeparate(builder.build());
-            }
-            case glStencilOpSeparate:
-                return glStencilOpSeparate(msg);
-            case glViewport:
-                return setter(msg);
-            default:
-                return false;
-        }
-    }
-
-    boolean setter(final Message msg) {
-        switch (msg.getFunction()) {
-            case glBlendFunc:
-                lastSetter.put(Function.glBlendFuncSeparate.getNumber(), msg);
-                break;
-            case glBlendEquation:
-                lastSetter.put(Function.glBlendEquationSeparate.getNumber(), msg);
-                break;
-            case glStencilMask:
-                lastSetter.put(Function.glStencilMaskSeparate.getNumber(), msg);
-                break;
-            default:
-                lastSetter.put(msg.getFunction().getNumber(), msg);
-                break;
-        }
-        return true;
-    }
-
-    boolean enableDisable(boolean enable, final Message msg) {
-        int index = enableDisables.indexOfKey(msg.getArg0());
-        if (index < 0) {
-            System.out.print("invalid glDisable/Enable: ");
-            System.out.println(MessageFormatter.format(msg, false));
-            return true;
-        }
-        if ((enableDisables.valueAt(index) != 0) == enable)
-            return true; // TODO: redundant
-        enableDisables.put(msg.getArg0(), enable ? 1 : 0);
-        return true;
-    }
-
-    // void StencilFuncSeparate( enum face, enum func, int ref, uint mask )
-    boolean glStencilFuncSeparate(final Message msg) {
-        GLEnum ff = front.func, bf = back.func;
-        int fr = front.ref, br = back.ref;
-        int fm = front.mask, bm = back.mask;
-        final GLEnum face = GLEnum.valueOf(msg.getArg0());
-        if (face == GLEnum.GL_FRONT || face == GLEnum.GL_FRONT_AND_BACK) {
-            ff = GLEnum.valueOf(msg.getArg1());
-            fr = msg.getArg2();
-            fm = msg.getArg3();
-        }
-        if (face == GLEnum.GL_BACK || face == GLEnum.GL_FRONT_AND_BACK) {
-            bf = GLEnum.valueOf(msg.getArg1());
-            br = msg.getArg2();
-            bm = msg.getArg3();
-        }
-        if (ff == front.func && fr == front.ref && fm == front.mask)
-            if (bf == back.func && br == back.ref && bm == back.mask)
-                return true; // TODO: redundant
-        front.func = ff;
-        front.ref = fr;
-        front.mask = fm;
-        back.func = bf;
-        back.ref = br;
-        back.mask = bm;
-        return true;
-    }
-
-    // void StencilOpSeparate( enum face, enum sfail, enum dpfail, enum dppass )
-    boolean glStencilOpSeparate(final Message msg) {
-        GLEnum fsf = front.sf, fdf = front.df, fdp = front.dp;
-        GLEnum bsf = back.sf, bdf = back.df, bdp = back.dp;
-        final GLEnum face = GLEnum.valueOf(msg.getArg0());
-        if (face == GLEnum.GL_FRONT || face == GLEnum.GL_FRONT_AND_BACK) {
-            fsf = GLEnum.valueOf(msg.getArg1());
-            fdf = GLEnum.valueOf(msg.getArg2());
-            fdp = GLEnum.valueOf(msg.getArg3());
-        }
-        if (face == GLEnum.GL_BACK || face == GLEnum.GL_FRONT_AND_BACK) {
-            bsf = GLEnum.valueOf(msg.getArg1());
-            bdf = GLEnum.valueOf(msg.getArg2());
-            bdp = GLEnum.valueOf(msg.getArg3());
-        }
-        if (fsf == front.sf && fdf == front.df && fdp == front.dp)
-            if (bsf == back.sf && bdf == back.df && bdp == back.dp)
-                return true; // TODO: redundant
-        front.sf = fsf;
-        front.df = fdf;
-        front.dp = fdp;
-        back.sf = bsf;
-        back.df = bdf;
-        back.dp = bdp;
-        return true;
-    }
-
-    /** deep copy */
-    @Override
-    public GLServerState clone() {
-        try {
-            GLServerState newState = (GLServerState) super.clone();
-            newState.front = (GLStencilState) front.clone();
-            newState.back = (GLStencilState) back.clone();
-
-            newState.enableDisables = new SparseIntArray(enableDisables.size());
-            for (int i = 0; i < enableDisables.size(); i++)
-                newState.enableDisables.append(enableDisables.keyAt(i),
-                        enableDisables.valueAt(i));
-
-            newState.integers = new SparseArray<Message>(integers.size());
-            for (int i = 0; i < integers.size(); i++)
-                newState.integers.append(integers.keyAt(i), integers.valueAt(i));
-
-            newState.lastSetter = new SparseArray<Message>(lastSetter.size());
-            for (int i = 0; i < lastSetter.size(); i++)
-                newState.lastSetter.append(lastSetter.keyAt(i), lastSetter.valueAt(i));
-
-            return newState;
-        } catch (CloneNotSupportedException e) {
-            e.printStackTrace();
-            assert false;
-            return null;
-        }
-    }
-}
diff --git a/tools/glesv2debugger/src/com/android/glesv2debugger/GLServerTexture.java b/tools/glesv2debugger/src/com/android/glesv2debugger/GLServerTexture.java
deleted file mode 100644
index 27676dd..0000000
--- a/tools/glesv2debugger/src/com/android/glesv2debugger/GLServerTexture.java
+++ /dev/null
@@ -1,235 +0,0 @@
-/*
- ** Copyright 2011, The Android Open Source Project
- **
- ** Licensed under the Apache License, Version 2.0 (the "License");
- ** you may not use this file except in compliance with the License.
- ** You may obtain a copy of the License at
- **
- **     http://www.apache.org/licenses/LICENSE-2.0
- **
- ** Unless required by applicable law or agreed to in writing, software
- ** distributed under the License is distributed on an "AS IS" BASIS,
- ** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- ** See the License for the specific language governing permissions and
- ** limitations under the License.
- */
-
-package com.android.glesv2debugger;
-
-import com.android.glesv2debugger.DebuggerMessage.Message;
-import com.android.sdklib.util.SparseArray;
-
-import java.nio.ByteBuffer;
-import java.util.ArrayList;
-
-class GLTexture implements Cloneable {
-    public final int name;
-    public final GLEnum target;
-    public ArrayList<Message> contentChanges = new ArrayList<Message>();
-    public GLEnum wrapS = GLEnum.GL_REPEAT, wrapT = GLEnum.GL_REPEAT;
-    public GLEnum min = GLEnum.GL_NEAREST_MIPMAP_LINEAR;
-    public GLEnum mag = GLEnum.GL_LINEAR;
-    public GLEnum format;
-    public int width, height;
-
-    GLTexture(final int name, final GLEnum target) {
-        this.name = name;
-        this.target = target;
-    }
-
-    @Override
-    public GLTexture clone() {
-        try {
-            GLTexture copy = (GLTexture) super.clone();
-            copy.contentChanges = (ArrayList<Message>) contentChanges.clone();
-            return copy;
-        } catch (CloneNotSupportedException e) {
-            e.printStackTrace();
-            assert false;
-            return null;
-        }
-    }
-
-    boolean processMessage(final Message msg) {
-        switch (msg.getFunction()) {
-            case glCompressedTexImage2D:
-            case glCopyTexImage2D:
-            case glTexImage2D:
-                if (msg.getArg1() == 0) { // level 0
-                    format = GLEnum.valueOf(msg.getArg2());
-                    width = msg.getArg3();
-                    height = msg.getArg4();
-                }
-                //$FALL-THROUGH$
-            case glCompressedTexSubImage2D:
-            case glCopyTexSubImage2D:
-            case glTexSubImage2D:
-            case glGenerateMipmap:
-                contentChanges.add(msg);
-                break;
-            default:
-                assert false;
-        }
-        return true;
-    }
-
-    @Override
-    public String toString() {
-        return String.format("%s %s %d*%d %d change(s)", target, format, width, height,
-                contentChanges.size());
-    }
-}
-
-public class GLServerTexture implements Cloneable {
-    Context context;
-
-    public GLEnum activeTexture = GLEnum.GL_TEXTURE0;
-    public int[] tmu2D;
-    public int[] tmuCube;
-    public SparseArray<GLTexture> textures = new SparseArray<GLTexture>();
-    public GLTexture tex2D = null, texCube = null;
-
-    GLServerTexture(final Context context, final int MAX_COMBINED_TEXTURE_IMAGE_UNITS) {
-        this.context = context;
-        textures.append(0, null);
-        tmu2D = new int[MAX_COMBINED_TEXTURE_IMAGE_UNITS];
-        tmuCube = new int[MAX_COMBINED_TEXTURE_IMAGE_UNITS];
-    }
-
-    public GLServerTexture clone(final Context copyContext) {
-        try {
-            GLServerTexture copy = (GLServerTexture) super.clone();
-            copy.context = copyContext;
-
-            copy.tmu2D = tmu2D.clone();
-            copy.tmuCube = tmuCube.clone();
-
-            copy.textures = new SparseArray<GLTexture>(textures.size());
-            for (int i = 0; i < textures.size(); i++)
-                if (textures.valueAt(i) != null)
-                    copy.textures.append(textures.keyAt(i), textures.valueAt(i).clone());
-                else
-                    copy.textures.append(textures.keyAt(i), null);
-
-            if (tex2D != null)
-                copy.tex2D = copy.textures.get(tex2D.name);
-            if (texCube != null)
-                copy.texCube = copy.textures.get(texCube.name);
-
-            return copy;
-        } catch (CloneNotSupportedException e) {
-            e.printStackTrace();
-            assert false;
-            return null;
-        }
-    }
-
-    public boolean processMessage(final Message msg) {
-        switch (msg.getFunction()) {
-            case glActiveTexture:
-                activeTexture = GLEnum.valueOf(msg.getArg0());
-                return true;
-            case glBindTexture:
-                return bindTexture(msg.getArg0(), msg.getArg1());
-            case glCompressedTexImage2D:
-            case glCompressedTexSubImage2D:
-            case glCopyTexImage2D:
-            case glCopyTexSubImage2D:
-            case glTexImage2D:
-            case glTexSubImage2D:
-                switch (GLEnum.valueOf(msg.getArg0())) {
-                    case GL_TEXTURE_2D:
-                        if (tex2D != null)
-                            return tex2D.processMessage(msg);
-                        return true;
-                    case GL_TEXTURE_CUBE_MAP_POSITIVE_X:
-                    case GL_TEXTURE_CUBE_MAP_NEGATIVE_X:
-                    case GL_TEXTURE_CUBE_MAP_POSITIVE_Y:
-                    case GL_TEXTURE_CUBE_MAP_NEGATIVE_Y:
-                    case GL_TEXTURE_CUBE_MAP_POSITIVE_Z:
-                    case GL_TEXTURE_CUBE_MAP_NEGATIVE_Z:
-                        if (texCube != null)
-                            return texCube.processMessage(msg);
-                        return true;
-                    default:
-                        return true;
-                }
-            case glDeleteTextures: {
-                final ByteBuffer names = msg.getData().asReadOnlyByteBuffer();
-                names.order(SampleView.targetByteOrder);
-                for (int i = 0; i < msg.getArg0(); i++) {
-                    final int name = names.getInt();
-                    if (tex2D != null && tex2D.name == name)
-                        bindTexture(GLEnum.GL_TEXTURE_2D.value, 0);
-                    if (texCube != null && texCube.name == name)
-                        bindTexture(GLEnum.GL_TEXTURE_CUBE_MAP.value, 0);
-                    if (name != 0)
-                        textures.remove(name);
-                }
-                return true;
-            }
-            case glGenerateMipmap:
-                if (GLEnum.valueOf(msg.getArg0()) == GLEnum.GL_TEXTURE_2D && tex2D != null)
-                    return tex2D.processMessage(msg);
-                else if (GLEnum.valueOf(msg.getArg0()) == GLEnum.GL_TEXTURE_CUBE_MAP
-                        && texCube != null)
-                    return texCube.processMessage(msg);
-                return true;
-            case glTexParameteri:
-                return texParameter(msg.getArg0(), msg.getArg1(), msg.getArg2());
-            case glTexParameterf:
-                return texParameter(msg.getArg0(), msg.getArg1(),
-                        (int) Float.intBitsToFloat(msg.getArg2()));
-            default:
-                return false;
-        }
-    }
-
-    boolean bindTexture(final int target, final int name) {
-        final int index = activeTexture.value - GLEnum.GL_TEXTURE0.value;
-        if (GLEnum.valueOf(target) == GLEnum.GL_TEXTURE_2D) {
-            tex2D = textures.get(name);
-            if (name != 0 && tex2D == null)
-                textures.put(name, tex2D = new GLTexture(name,
-                        GLEnum.GL_TEXTURE_2D));
-            if (index >= 0 && index < tmu2D.length)
-                tmu2D[index] = name;
-        } else if (GLEnum.valueOf(target) == GLEnum.GL_TEXTURE_CUBE_MAP) {
-            texCube = textures.get(name);
-            if (name != 0 && texCube == null)
-                textures.put(name, texCube = new GLTexture(name,
-                        GLEnum.GL_TEXTURE_CUBE_MAP));
-            if (index >= 0 && index < tmu2D.length)
-                tmu2D[index] = name;
-        } else
-            assert false;
-        return true;
-    }
-
-    boolean texParameter(final int target, final int pname, final int param) {
-        GLTexture tex = null;
-        if (GLEnum.valueOf(target) == GLEnum.GL_TEXTURE_2D)
-            tex = tex2D;
-        else if (GLEnum.valueOf(target) == GLEnum.GL_TEXTURE_CUBE_MAP)
-            tex = texCube;
-        if (tex == null)
-            return true;
-        final GLEnum p = GLEnum.valueOf(param);
-        switch (GLEnum.valueOf(pname)) {
-            case GL_TEXTURE_WRAP_S:
-                tex.wrapS = p;
-                return true;
-            case GL_TEXTURE_WRAP_T:
-                tex.wrapT = p;
-                return true;
-            case GL_TEXTURE_MIN_FILTER:
-                tex.min = p;
-                return true;
-            case GL_TEXTURE_MAG_FILTER:
-                tex.mag = p;
-                return true;
-            default:
-                return true;
-        }
-    }
-}
diff --git a/tools/glesv2debugger/src/com/android/glesv2debugger/GLServerVertex.java b/tools/glesv2debugger/src/com/android/glesv2debugger/GLServerVertex.java
deleted file mode 100644
index 5f9d513..0000000
--- a/tools/glesv2debugger/src/com/android/glesv2debugger/GLServerVertex.java
+++ /dev/null
@@ -1,542 +0,0 @@
-/*
- ** Copyright 2011, The Android Open Source Project
- **
- ** Licensed under the Apache License, Version 2.0 (the "License");
- ** you may not use this file except in compliance with the License.
- ** You may obtain a copy of the License at
- **
- **     http://www.apache.org/licenses/LICENSE-2.0
- **
- ** Unless required by applicable law or agreed to in writing, software
- ** distributed under the License is distributed on an "AS IS" BASIS,
- ** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- ** See the License for the specific language governing permissions and
- ** limitations under the License.
- */
-
-package com.android.glesv2debugger;
-
-import com.android.glesv2debugger.DebuggerMessage.Message;
-import com.android.sdklib.util.SparseArray;
-
-import java.nio.ByteBuffer;
-
-class GLBuffer implements Cloneable {
-    public final int name;
-    public GLEnum usage;
-    public GLEnum target;
-    /** in SampleView.targetByteOrder */
-    public ByteBuffer data;
-
-    public GLBuffer(final int name) {
-        this.name = name;
-    }
-
-    /** deep copy */
-    @Override
-    public GLBuffer clone() {
-        try {
-            GLBuffer copy = (GLBuffer) super.clone();
-            if (data != null) {
-                copy.data = ByteBuffer.allocate(data.capacity());
-                copy.data.order(SampleView.targetByteOrder);
-                data.position(0);
-                copy.data.put(data);
-            }
-            return copy;
-        } catch (CloneNotSupportedException e) {
-            e.printStackTrace();
-            assert false;
-            return null;
-        }
-    }
-}
-
-class GLAttribPointer implements Cloneable {
-    public int size; // number of values per vertex
-    public GLEnum type; // data type
-    public int stride; // bytes
-    /**
-     * element stride in bytes, used when fetching from buffer; not for fetching
-     * from user pointer since server already packed elements
-     */
-    int elemStride; // in bytes
-    /** element size in bytes */
-    int elemSize;
-    public int ptr; // pointer in debugger server or byte offset into buffer
-    public GLBuffer buffer;
-    public boolean normalized;
-    public boolean enabled;
-
-    /** deep copy, re-maps buffer into copyBuffers */
-    public GLAttribPointer clone(SparseArray<GLBuffer> copyBuffers) {
-        try {
-            GLAttribPointer copy = (GLAttribPointer) super.clone();
-            if (buffer != null)
-                copy.buffer = copyBuffers.get(buffer.name);
-            return copy;
-        } catch (CloneNotSupportedException e) {
-            e.printStackTrace();
-            assert false;
-            return null;
-        }
-    }
-}
-
-public class GLServerVertex implements Cloneable {
-    public SparseArray<GLBuffer> buffers = new SparseArray<GLBuffer>();
-    public GLBuffer attribBuffer, indexBuffer; // current binding
-    public GLAttribPointer attribPointers[];
-    public float defaultAttribs[][];
-
-    public GLServerVertex(final int MAX_VERTEX_ATTRIBS) {
-        buffers.append(0, null);
-        attribPointers = new GLAttribPointer[MAX_VERTEX_ATTRIBS];
-        for (int i = 0; i < attribPointers.length; i++)
-            attribPointers[i] = new GLAttribPointer();
-        defaultAttribs = new float[MAX_VERTEX_ATTRIBS][4];
-        for (int i = 0; i < defaultAttribs.length; i++) {
-            defaultAttribs[i][0] = 0;
-            defaultAttribs[i][1] = 0;
-            defaultAttribs[i][2] = 0;
-            defaultAttribs[i][3] = 1;
-        }
-    }
-
-    /** deep copy */
-    @Override
-    public GLServerVertex clone() {
-        try {
-            GLServerVertex copy = (GLServerVertex) super.clone();
-
-            copy.buffers = new SparseArray<GLBuffer>(buffers.size());
-            for (int i = 0; i < buffers.size(); i++)
-                if (buffers.valueAt(i) != null)
-                    copy.buffers.append(buffers.keyAt(i), buffers.valueAt(i).clone());
-                else
-                    copy.buffers.append(buffers.keyAt(i), null);
-
-            if (attribBuffer != null)
-                copy.attribBuffer = copy.buffers.get(attribBuffer.name);
-            if (indexBuffer != null)
-                copy.indexBuffer = copy.buffers.get(indexBuffer.name);
-
-            copy.attribPointers = new GLAttribPointer[attribPointers.length];
-            for (int i = 0; i < attribPointers.length; i++)
-                copy.attribPointers[i] = attribPointers[i].clone(copy.buffers);
-
-            copy.defaultAttribs = defaultAttribs.clone();
-
-            return copy;
-        } catch (CloneNotSupportedException e) {
-            e.printStackTrace();
-            assert false;
-            return null;
-        }
-    }
-
-    /** returns true if processed */
-    public boolean process(final Message msg) {
-        switch (msg.getFunction()) {
-            case glBindBuffer:
-                glBindBuffer(msg);
-                return true;
-            case glBufferData:
-                glBufferData(msg);
-                return true;
-            case glBufferSubData:
-                glBufferSubData(msg);
-                return true;
-            case glDeleteBuffers:
-                glDeleteBuffers(msg);
-                return true;
-            case glDrawArrays:
-            case glDrawElements:
-                return true;
-            case glDisableVertexAttribArray:
-                glDisableVertexAttribArray(msg);
-                return true;
-            case glEnableVertexAttribArray:
-                glEnableVertexAttribArray(msg);
-                return true;
-            case glGenBuffers:
-                glGenBuffers(msg);
-                return true;
-            case glVertexAttribPointer:
-                glVertexAttribPointer(msg);
-                return true;
-            case glVertexAttrib1f:
-                glVertexAttrib1f(msg);
-                return true;
-            case glVertexAttrib1fv:
-                glVertexAttrib1fv(msg);
-                return true;
-            case glVertexAttrib2f:
-                glVertexAttrib2f(msg);
-                return true;
-            case glVertexAttrib2fv:
-                glVertexAttrib2fv(msg);
-                return true;
-            case glVertexAttrib3f:
-                glVertexAttrib3f(msg);
-                return true;
-            case glVertexAttrib3fv:
-                glVertexAttrib3fv(msg);
-                return true;
-            case glVertexAttrib4f:
-                glVertexAttrib4f(msg);
-                return true;
-            case glVertexAttrib4fv:
-                glVertexAttrib4fv(msg);
-                return true;
-            default:
-                return false;
-        }
-    }
-
-    // void API_ENTRY(glBindBuffer)(GLenum target, GLuint buffer)
-    public void glBindBuffer(Message msg) {
-        if (GLEnum.valueOf(msg.getArg0()) == GLEnum.GL_ARRAY_BUFFER) {
-            attribBuffer = buffers.get(msg.getArg1());
-            if (null != attribBuffer)
-                attribBuffer.target = GLEnum.GL_ARRAY_BUFFER;
-        } else if (GLEnum.valueOf(msg.getArg0()) == GLEnum.GL_ELEMENT_ARRAY_BUFFER) {
-            indexBuffer = buffers.get(msg.getArg1());
-            if (null != indexBuffer)
-                indexBuffer.target = GLEnum.GL_ELEMENT_ARRAY_BUFFER;
-        } else
-            assert false;
-    }
-
-    // void API_ENTRY(glBufferData)(GLenum target, GLsizeiptr size, const
-    // GLvoid:size:in data, GLenum usage)
-    public void glBufferData(Message msg) {
-        if (GLEnum.valueOf(msg.getArg0()) == GLEnum.GL_ARRAY_BUFFER) {
-            attribBuffer.usage = GLEnum.valueOf(msg.getArg3());
-            attribBuffer.data = msg.getData().asReadOnlyByteBuffer();
-            attribBuffer.data.order(SampleView.targetByteOrder);
-        } else if (GLEnum.valueOf(msg.getArg0()) == GLEnum.GL_ELEMENT_ARRAY_BUFFER) {
-            indexBuffer.usage = GLEnum.valueOf(msg.getArg3());
-            indexBuffer.data = msg.getData().asReadOnlyByteBuffer();
-            indexBuffer.data.order(SampleView.targetByteOrder);
-        } else
-            assert false;
-    }
-
-    // void API_ENTRY(glBufferSubData)(GLenum target, GLintptr offset,
-    // GLsizeiptr size, const GLvoid:size:in data)
-    public void glBufferSubData(Message msg) {
-        if (GLEnum.valueOf(msg.getArg0()) == GLEnum.GL_ARRAY_BUFFER) {
-            if (attribBuffer.data.isReadOnly()) {
-                ByteBuffer buffer = ByteBuffer.allocate(attribBuffer.data.capacity());
-                buffer.order(SampleView.targetByteOrder);
-                buffer.put(attribBuffer.data);
-                attribBuffer.data = buffer;
-            }
-            attribBuffer.data.position(msg.getArg1());
-            attribBuffer.data.put(msg.getData().asReadOnlyByteBuffer());
-        } else if (GLEnum.valueOf(msg.getArg0()) == GLEnum.GL_ELEMENT_ARRAY_BUFFER) {
-            if (indexBuffer.data.isReadOnly()) {
-                ByteBuffer buffer = ByteBuffer.allocate(indexBuffer.data.capacity());
-                buffer.order(SampleView.targetByteOrder);
-                buffer.put(indexBuffer.data);
-                indexBuffer.data = buffer;
-            }
-            indexBuffer.data.position(msg.getArg1());
-            indexBuffer.data.put(msg.getData().asReadOnlyByteBuffer());
-        } else
-            assert false;
-    }
-
-    // void glDeleteBuffers(GLsizei n, const GLuint* buffers)
-    public void glDeleteBuffers(Message msg) {
-        final int n = msg.getArg0();
-        final ByteBuffer names = msg.getData().asReadOnlyByteBuffer();
-        names.order(SampleView.targetByteOrder);
-        for (int i = 0; i < n; i++) {
-            final int name = names.getInt();
-            final GLBuffer buffer = buffers.get(name);
-            for (int j = 0; j < attribPointers.length; j++)
-                if (attribPointers[j].buffer == buffer) {
-                    attribPointers[j].buffer = null;
-                    attribPointers[j].enabled = false;
-                }
-            if (attribBuffer == buffer)
-                attribBuffer = null;
-            if (indexBuffer == buffer)
-                indexBuffer = null;
-            buffers.remove(name);
-        }
-    }
-
-    // void glDisableVertexAttribArray(GLuint index)
-    public void glDisableVertexAttribArray(Message msg) {
-        if (msg.getArg0() >= 0 && msg.getArg0() < attribPointers.length)
-            attribPointers[msg.getArg0()].enabled = false;
-    }
-
-    float fetchConvert(final ByteBuffer src, final GLEnum type, final boolean normalized) {
-        if (GLEnum.GL_FLOAT == type)
-            return Float.intBitsToFloat(src.getInt());
-        else if (GLEnum.GL_UNSIGNED_INT == type)
-            if (normalized)
-                return (src.getInt() & 0xffffffffL) / (2e32f - 1);
-            else
-                return src.getInt() & 0xffffffffL;
-        else if (GLEnum.GL_INT == type)
-            if (normalized)
-                return (src.getInt() * 2 + 1) / (2e32f - 1);
-            else
-                return src.getInt();
-        else if (GLEnum.GL_UNSIGNED_SHORT == type)
-            if (normalized)
-                return (src.getShort() & 0xffff) / (2e16f - 1);
-            else
-                return src.getShort() & 0xffff;
-        else if (GLEnum.GL_SHORT == type)
-            if (normalized)
-                return (src.getShort() * 2 + 1) / (2e16f - 1);
-            else
-                return src.getShort();
-        else if (GLEnum.GL_UNSIGNED_BYTE == type)
-            if (normalized)
-                return (src.get() & 0xff) / (2e8f - 1);
-            else
-                return src.get() & 0xff;
-        else if (GLEnum.GL_BYTE == type)
-            if (normalized)
-                return (src.get() * 2 + 1) / (2e8f - 1);
-            else
-                return src.get();
-        else if (GLEnum.GL_FIXED == type)
-            if (normalized)
-                return (src.getInt() * 2 + 1) / (2e32f - 1);
-            else
-                return src.getInt() / (2e16f);
-        else
-            assert false;
-        return 0;
-    }
-
-    static int typeSize(final GLEnum type) {
-        switch (type) {
-            case GL_FLOAT:
-            case GL_UNSIGNED_INT:
-            case GL_INT:
-            case GL_FIXED:
-                return 4;
-            case GL_UNSIGNED_SHORT:
-            case GL_SHORT:
-                return 2;
-            case GL_UNSIGNED_BYTE:
-            case GL_BYTE:
-                return 1;
-            default:
-                assert false;
-                return 0;
-        }
-    }
-
-    void fetch(final int maxAttrib, final int index, final int dstIdx, final ByteBuffer nonVBO,
-            final float[][] fetchedAttribs) {
-        for (int i = 0; i < maxAttrib; i++) {
-            final GLAttribPointer attrib = attribPointers[i];
-            int size = 0;
-            if (attrib.enabled) {
-                size = attrib.size;
-                if (null != attrib.buffer) {
-                    final ByteBuffer src = attrib.buffer.data;
-                    src.position(attrib.ptr + index * attrib.elemStride);
-                    for (int j = 0; j < size; j++)
-                        fetchedAttribs[i][dstIdx * 4 + j] = fetchConvert(src, attrib.type,
-                                attrib.normalized);
-                } else
-                    for (int j = 0; j < size; j++)
-                        fetchedAttribs[i][dstIdx * 4 + j] = fetchConvert(nonVBO, attrib.type,
-                                attrib.normalized);
-            }
-            if (size < 1)
-                fetchedAttribs[i][dstIdx * 4 + 0] = defaultAttribs[i][0];
-            if (size < 2)
-                fetchedAttribs[i][dstIdx * 4 + 1] = defaultAttribs[i][1];
-            if (size < 3)
-                fetchedAttribs[i][dstIdx * 4 + 2] = defaultAttribs[i][2];
-            if (size < 4)
-                fetchedAttribs[i][dstIdx * 4 + 3] = defaultAttribs[i][3];
-        }
-    }
-
-    /**
-     * fetches and converts vertex data from buffers, defaults and user pointers
-     * into MessageData; mainly for display use
-     */
-    public void glDrawArrays(MessageData msgData) {
-        final Message msg = msgData.msg;
-        if (!msg.hasArg7())
-            return;
-        final int maxAttrib = msg.getArg7();
-        final int first = msg.getArg1(), count = msg.getArg2();
-        msgData.attribs = new float[maxAttrib][count * 4];
-        ByteBuffer arrays = null;
-        if (msg.hasData()) // server sends user pointer attribs
-        {
-            arrays = msg.getData().asReadOnlyByteBuffer();
-            arrays.order(SampleView.targetByteOrder);
-        }
-        for (int i = 0; i < count; i++)
-            fetch(maxAttrib, first + i, i, arrays, msgData.attribs);
-        assert null == arrays || arrays.remaining() == 0;
-    }
-
-    // void glDrawElements(GLenum mode, GLsizei count, GLenum type, const
-    // GLvoid* indices)
-    /**
-     * fetches and converts vertex data from buffers, defaults and user pointers
-     * and indices from buffer/pointer into MessageData; mainly for display use
-     */
-    public void glDrawElements(MessageData msgData) {
-        final Message msg = msgData.msg;
-        if (!msg.hasArg7())
-            return;
-        final int maxAttrib = msg.getArg7();
-        final int count = msg.getArg1();
-        final GLEnum type = GLEnum.valueOf(msg.getArg2());
-        msgData.attribs = new float[maxAttrib][count * 4];
-        msgData.indices = new short[count];
-        ByteBuffer arrays = null, index = null;
-        if (msg.hasData()) // server sends user pointer attribs
-        {
-            arrays = msg.getData().asReadOnlyByteBuffer();
-            arrays.order(SampleView.targetByteOrder);
-        }
-        if (null == indexBuffer)
-            index = arrays; // server also interleaves user pointer indices
-        else {
-            index = indexBuffer.data;
-            index.position(msg.getArg3());
-        }
-        if (GLEnum.GL_UNSIGNED_SHORT == type) {
-            for (int i = 0; i < count; i++) {
-                msgData.indices[i] = index.getShort();
-                fetch(maxAttrib, msgData.indices[i] & 0xffff, i, arrays, msgData.attribs);
-            }
-        } else if (GLEnum.GL_UNSIGNED_BYTE == type) {
-            for (int i = 0; i < count; i++) {
-                msgData.indices[i] = (short) (index.get() & 0xff);
-                fetch(maxAttrib, msgData.indices[i], i, arrays, msgData.attribs);
-            }
-        } else
-            assert false;
-        assert null == arrays || arrays.remaining() == 0;
-    }
-
-    // void glEnableVertexAttribArray(GLuint index)
-    public void glEnableVertexAttribArray(Message msg) {
-        if (msg.getArg0() >= 0 && msg.getArg0() < attribPointers.length)
-            attribPointers[msg.getArg0()].enabled = true;
-    }
-
-    // void API_ENTRY(glGenBuffers)(GLsizei n, GLuint:n:out buffers)
-    public void glGenBuffers(Message msg) {
-        final int n = msg.getArg0();
-        final ByteBuffer buffer = msg.getData().asReadOnlyByteBuffer();
-        buffer.order(SampleView.targetByteOrder);
-        for (int i = 0; i < n; i++) {
-            final int name = buffer.getInt();
-            final int index = buffers.indexOfKey(name);
-            if (index < 0)
-                buffers.append(name, new GLBuffer(name));
-        }
-    }
-
-    // void glVertexAttribPointer(GLuint index, GLint size, GLenum type,
-    // GLboolean normalized, GLsizei stride, const GLvoid* ptr)
-    public void glVertexAttribPointer(Message msg) {
-        GLAttribPointer attrib = attribPointers[msg.getArg0()];
-        attrib.size = msg.getArg1();
-        attrib.type = GLEnum.valueOf(msg.getArg2());
-        attrib.normalized = msg.getArg3() != 0;
-        attrib.stride = msg.getArg4();
-        attrib.elemSize = attrib.size * typeSize(attrib.type);
-        if (attrib.stride == 0)
-            attrib.elemStride = attrib.elemSize;
-        else
-            attrib.elemStride = attrib.stride;
-        attrib.ptr = msg.getArg5();
-        attrib.buffer = attribBuffer;
-    }
-
-    // void glVertexAttrib1f(GLuint indx, GLfloat x)
-    public void glVertexAttrib1f(Message msg) {
-        glVertexAttrib4f(msg.getArg0(), Float.intBitsToFloat(msg.getArg1()),
-                0, 0, 1);
-    }
-
-    // void glVertexAttrib1fv(GLuint indx, const GLfloat* values)
-    public void glVertexAttrib1fv(Message msg) {
-        final ByteBuffer values = msg.getData().asReadOnlyByteBuffer();
-        values.order(SampleView.targetByteOrder);
-        glVertexAttrib4f(msg.getArg0(),
-                Float.intBitsToFloat(values.getInt()),
-                0, 0, 1);
-    }
-
-    // void glVertexAttrib2f(GLuint indx, GLfloat x, GLfloat y)
-    public void glVertexAttrib2f(Message msg) {
-        glVertexAttrib4f(msg.getArg0(), Float.intBitsToFloat(msg.getArg1()),
-                Float.intBitsToFloat(msg.getArg2()), 0, 1);
-    }
-
-    // void glVertexAttrib2fv(GLuint indx, const GLfloat* values)
-    public void glVertexAttrib2fv(Message msg) {
-        final ByteBuffer values = msg.getData().asReadOnlyByteBuffer();
-        values.order(SampleView.targetByteOrder);
-        glVertexAttrib4f(msg.getArg0(),
-                Float.intBitsToFloat(values.getInt()),
-                Float.intBitsToFloat(values.getInt()), 0, 1);
-    }
-
-    // void glVertexAttrib3f(GLuint indx, GLfloat x, GLfloat y, GLfloat z)
-    public void glVertexAttrib3f(Message msg) {
-        glVertexAttrib4f(msg.getArg0(), Float.intBitsToFloat(msg.getArg1()),
-                Float.intBitsToFloat(msg.getArg2()),
-                Float.intBitsToFloat(msg.getArg3()), 1);
-    }
-
-    // void glVertexAttrib3fv(GLuint indx, const GLfloat* values)
-    public void glVertexAttrib3fv(Message msg) {
-        final ByteBuffer values = msg.getData().asReadOnlyByteBuffer();
-        values.order(SampleView.targetByteOrder);
-        glVertexAttrib4f(msg.getArg0(),
-                Float.intBitsToFloat(values.getInt()),
-                Float.intBitsToFloat(values.getInt()),
-                Float.intBitsToFloat(values.getInt()), 1);
-    }
-
-    public void glVertexAttrib4f(Message msg) {
-        glVertexAttrib4f(msg.getArg0(), Float.intBitsToFloat(msg.getArg1()),
-                Float.intBitsToFloat(msg.getArg2()),
-                Float.intBitsToFloat(msg.getArg3()),
-                Float.intBitsToFloat(msg.getArg4()));
-    }
-
-    void glVertexAttrib4f(int indx, float x, float y, float z, float w) {
-        if (indx < 0 || indx >= defaultAttribs.length)
-            return;
-        defaultAttribs[indx][0] = x;
-        defaultAttribs[indx][1] = y;
-        defaultAttribs[indx][2] = z;
-        defaultAttribs[indx][3] = w;
-    }
-
-    // void glVertexAttrib4fv(GLuint indx, const GLfloat* values)
-    public void glVertexAttrib4fv(Message msg) {
-        final ByteBuffer values = msg.getData().asReadOnlyByteBuffer();
-        values.order(SampleView.targetByteOrder);
-        glVertexAttrib4f(msg.getArg0(),
-                Float.intBitsToFloat(values.getInt()),
-                Float.intBitsToFloat(values.getInt()),
-                Float.intBitsToFloat(values.getInt()),
-                Float.intBitsToFloat(values.getInt()));
-    }
-}
diff --git a/tools/glesv2debugger/src/com/android/glesv2debugger/MessageData.java b/tools/glesv2debugger/src/com/android/glesv2debugger/MessageData.java
deleted file mode 100644
index 321c538..0000000
--- a/tools/glesv2debugger/src/com/android/glesv2debugger/MessageData.java
+++ /dev/null
@@ -1,128 +0,0 @@
-/*
- ** Copyright 2011, The Android Open Source Project
- **
- ** Licensed under the Apache License, Version 2.0 (the "License");
- ** you may not use this file except in compliance with the License.
- ** You may obtain a copy of the License at
- **
- **     http://www.apache.org/licenses/LICENSE-2.0
- **
- ** Unless required by applicable law or agreed to in writing, software
- ** distributed under the License is distributed on an "AS IS" BASIS,
- ** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- ** See the License for the specific language governing permissions and
- ** limitations under the License.
- */
-
-package com.android.glesv2debugger;
-
-import com.android.glesv2debugger.DebuggerMessage.Message;
-import com.android.glesv2debugger.DebuggerMessage.Message.Function;
-import com.android.glesv2debugger.DebuggerMessage.Message.Type;
-
-import org.eclipse.swt.graphics.Device;
-import org.eclipse.swt.graphics.Image;
-import org.eclipse.swt.graphics.ImageData;
-import org.eclipse.swt.widgets.Display;
-
-public class MessageData {
-    public final Message msg;
-    private Image image = null; // texture
-    public String shader = null; // shader source
-    public String text;
-    public String[] columns = new String[3];
-
-    float[][] attribs = null;
-    short[] indices;
-
-    public MessageData(final Device device, final Message msg, final Context context) {
-        this.msg = msg;
-        StringBuilder builder = new StringBuilder();
-        final Function function = msg.getFunction();
-        if (function != Message.Function.ACK && msg.getType() != Type.BeforeCall)
-            assert msg.hasTime();
-        builder.append(columns[0] = function.name());
-        while (builder.length() < 30)
-            builder.append(' ');
-        columns[1] = String.format("%.3f", msg.getTime());
-        if (msg.hasClock())
-            columns[1] += String.format(":%.3f", msg.getClock());
-        builder.append(columns[1]);
-
-        builder.append("  ");
-        builder.append(String.format("0x%08X", msg.getContextId()));
-        builder.append("  ");
-        columns[2] = "";
-        if (msg.getType() == Type.BeforeCall) // incomplete call, client SKIPPED
-            columns[2] = "[BeforeCall(AfterCall missing)] ";
-        else if (msg.getType() == Type.AfterGeneratedCall)
-            columns[2] = "[AfterGeneratedCall] ";
-        else
-            assert msg.getType() == Type.CompleteCall;
-        columns[2] += MessageFormatter.format(msg, false);
-        builder.append(columns[2]);
-        switch (function) {
-            case glDrawArrays:
-                if (!msg.hasArg7())
-                    break;
-                context.serverVertex.glDrawArrays(this);
-                break;
-            case glDrawElements:
-                if (!msg.hasArg7())
-                    break;
-                context.serverVertex.glDrawElements(this);
-                break;
-            case glShaderSource:
-                shader = msg.getData().toStringUtf8();
-                break;
-
-        }
-        text = builder.toString();
-    }
-
-    public Image getImage() {
-        if (image != null)
-            return image;
-        ImageData imageData = null;
-        switch (msg.getFunction()) {
-            case glTexImage2D:
-                if (!msg.hasData())
-                    return null;
-                imageData = MessageProcessor.receiveImage(msg.getArg3(), msg
-                        .getArg4(), msg.getArg6(), msg.getArg7(), msg.getData());
-                return image = new Image(Display.getCurrent(), imageData);
-            case glTexSubImage2D:
-                assert msg.hasData();
-                imageData = MessageProcessor.receiveImage(msg.getArg4(), msg
-                        .getArg5(), msg.getArg6(), msg.getArg7(), msg.getData());
-                return image = new Image(Display.getCurrent(), imageData);
-            case glCopyTexImage2D:
-                imageData = MessageProcessor.receiveImage(msg.getArg5(), msg.getArg6(),
-                        msg.getPixelFormat(), msg.getPixelType(), msg.getData());
-                imageData = imageData.scaledTo(imageData.width, -imageData.height);
-                return image = new Image(Display.getCurrent(), imageData);
-            case glCopyTexSubImage2D:
-                imageData = MessageProcessor.receiveImage(msg.getArg6(), msg.getArg7(),
-                        msg.getPixelFormat(), msg.getPixelType(), msg.getData());
-                imageData = imageData.scaledTo(imageData.width, -imageData.height);
-                return image = new Image(Display.getCurrent(), imageData);
-            case glReadPixels:
-                if (!msg.hasData())
-                    return null;
-                imageData = MessageProcessor.receiveImage(msg.getArg2(), msg.getArg3(),
-                        msg.getArg4(), msg.getArg5(), msg.getData());
-                imageData = imageData.scaledTo(imageData.width, -imageData.height);
-                return image = new Image(Display.getCurrent(), imageData);
-            case eglSwapBuffers:
-                if (!msg.hasData())
-                    return null;
-                imageData = MessageProcessor.receiveImage(msg.getImageWidth(),
-                        msg.getImageHeight(), msg.getPixelFormat(), msg.getPixelType(),
-                        msg.getData());
-                imageData = imageData.scaledTo(imageData.width, -imageData.height);
-                return image = new Image(Display.getCurrent(), imageData);
-            default:
-                return null;
-        }
-    }
-}
diff --git a/tools/glesv2debugger/src/com/android/glesv2debugger/MessageFormatter.java b/tools/glesv2debugger/src/com/android/glesv2debugger/MessageFormatter.java
deleted file mode 100644
index b9fa681..0000000
--- a/tools/glesv2debugger/src/com/android/glesv2debugger/MessageFormatter.java
+++ /dev/null
@@ -1,1488 +0,0 @@
-/*
- ** Copyright 2011, The Android Open Source Project
- **
- ** Licensed under the Apache License, Version 2.0 (the "License");
- ** you may not use this file except in compliance with the License.
- ** You may obtain a copy of the License at
- **
- **     http://www.apache.org/licenses/LICENSE-2.0
- **
- ** Unless required by applicable law or agreed to in writing, software
- ** distributed under the License is distributed on an "AS IS" BASIS,
- ** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- ** See the License for the specific language governing permissions and
- ** limitations under the License.
- */
-
-// auto generated by generate_MessageFormatter_java.py"
-
-package com.android.glesv2debugger;
-
-import java.nio.ByteBuffer;
-
-public class MessageFormatter {
-
-    static String formatFloats(int count, final ByteBuffer data) {
-        if (data.remaining() == 0)
-            return "{}";
-        data.order(SampleView.targetByteOrder);
-        String ret = "{";
-        for (int i = 0; i < count; i++) {
-            ret += Float.intBitsToFloat(data.getInt());
-            if (i < count - 1)
-                ret += ", ";
-        }
-        return ret + "}";
-    }
-
-    static String formatInts(int count, final ByteBuffer data) {
-        if (data.remaining() == 0)
-            return "{}";
-        data.order(SampleView.targetByteOrder);
-        String ret = "{";
-        for (int i = 0; i < count; i++) {
-            ret += data.getInt();
-            if (i < count - 1)
-                ret += ", ";
-        }
-        return ret + "}";
-    }
-
-    static String formatUInts(int count, final ByteBuffer data) {
-        if (data.remaining() == 0)
-            return "{}";
-        data.order(SampleView.targetByteOrder);
-        String ret = "{";
-        for (int i = 0; i < count; i++) {
-            long bits = data.getInt() & 0xffffffff;
-            ret += bits;
-            if (i < count - 1)
-                ret += ", ";
-        }
-        return ret + "}";
-    }
-
-    static String formatMatrix(int columns, int count, final ByteBuffer data) {
-        if (data.remaining() == 0)
-            return "{}";
-        data.order(SampleView.targetByteOrder);
-        String ret = "{";
-        for (int i = 0; i < count; i++) {
-            ret += Float.intBitsToFloat(data.getInt());
-            if (i < count - 1)
-                ret += ", ";
-            if (i % columns == columns - 1)
-                ret += "\n                                             ";
-        }
-        return ret + "}";
-    }
-
-    public static String format(final DebuggerMessage.Message msg,
-                                final boolean code) {
-        String str;
-        switch (msg.getFunction()) {
-            case glActiveTexture:
-                str = String.format("%s(%s%s)",
-                    (code ? "glActiveTexture" : "void")
-                    , (code ? "/*texture*/ " : "texture=")
-                    , GLEnum.valueOf(msg.getArg0()));
-                break;
-            case glAttachShader:
-                str = String.format("%s(%s%s, %s%s)",
-                    (code ? "glAttachShader" : "void")
-                    , (code ? "/*program*/ " : "program=")
-                    , (code ? "program_" : "") + msg.getArg0()
-                    , (code ? "/*shader*/ " : "shader=")
-                    , (code ? "shader_" : "") + msg.getArg1());
-                break;
-            case glBindAttribLocation:
-                str = String.format("%s(%s%s, %s%s, %s%s)",
-                    (code ? "glBindAttribLocation" : "void")
-                    , (code ? "/*program*/ " : "program=")
-                    , (code ? "program_" : "") + msg.getArg0()
-                    , (code ? "/*index*/ " : "index=")
-                    , msg.getArg1()
-                    , (code ? "/*name*/ " : "name=")
-                    , (code ? "\"" : "") + msg.getData().toStringUtf8() + (code ? "\"" : ""));
-                break;
-            case glBindBuffer:
-                str = String.format("%s(%s%s, %s%s)",
-                    (code ? "glBindBuffer" : "void")
-                    , (code ? "/*target*/ " : "target=")
-                    , GLEnum.valueOf(msg.getArg0())
-                    , (code ? "/*buffer*/ " : "buffer=")
-                    , (code ? "buffer_" : "") + msg.getArg1());
-                break;
-            case glBindFramebuffer:
-                str = String.format("%s(%s%s, %s%s)",
-                    (code ? "glBindFramebuffer" : "void")
-                    , (code ? "/*target*/ " : "target=")
-                    , GLEnum.valueOf(msg.getArg0())
-                    , (code ? "/*framebuffer*/ " : "framebuffer=")
-                    , (code ? "framebuffer_" : "") + msg.getArg1());
-                break;
-            case glBindRenderbuffer:
-                str = String.format("%s(%s%s, %s%s)",
-                    (code ? "glBindRenderbuffer" : "void")
-                    , (code ? "/*target*/ " : "target=")
-                    , GLEnum.valueOf(msg.getArg0())
-                    , (code ? "/*renderbuffer*/ " : "renderbuffer=")
-                    , (code ? "renderbuffer_" : "") + msg.getArg1());
-                break;
-            case glBindTexture:
-                str = String.format("%s(%s%s, %s%s)",
-                    (code ? "glBindTexture" : "void")
-                    , (code ? "/*target*/ " : "target=")
-                    , GLEnum.valueOf(msg.getArg0())
-                    , (code ? "/*texture*/ " : "texture=")
-                    , (code ? "texture_" : "") + msg.getArg1());
-                break;
-            case glBlendColor:
-                str = String.format("%s(%s%s, %s%s, %s%s, %s%s)",
-                    (code ? "glBlendColor" : "void")
-                    , (code ? "/*red*/ " : "red=")
-                    , Float.intBitsToFloat(msg.getArg0())
-                    , (code ? "/*green*/ " : "green=")
-                    , Float.intBitsToFloat(msg.getArg1())
-                    , (code ? "/*blue*/ " : "blue=")
-                    , Float.intBitsToFloat(msg.getArg2())
-                    , (code ? "/*alpha*/ " : "alpha=")
-                    , Float.intBitsToFloat(msg.getArg3()));
-                break;
-            case glBlendEquation:
-                str = String.format("%s(%s%s)",
-                    (code ? "glBlendEquation" : "void")
-                    , (code ? "/*mode*/ " : "mode=")
-                    , GLEnum.valueOf(msg.getArg0()));
-                break;
-            case glBlendEquationSeparate:
-                str = String.format("%s(%s%s, %s%s)",
-                    (code ? "glBlendEquationSeparate" : "void")
-                    , (code ? "/*modeRGB*/ " : "modeRGB=")
-                    , GLEnum.valueOf(msg.getArg0())
-                    , (code ? "/*modeAlpha*/ " : "modeAlpha=")
-                    , GLEnum.valueOf(msg.getArg1()));
-                break;
-            case glBlendFunc:
-                str = String.format("%s(%s%s, %s%s)",
-                    (code ? "glBlendFunc" : "void")
-                    , (code ? "/*sfactor*/ " : "sfactor=")
-                    , GLEnum.valueOf(msg.getArg0())
-                    , (code ? "/*dfactor*/ " : "dfactor=")
-                    , GLEnum.valueOf(msg.getArg1()));
-                break;
-            case glBlendFuncSeparate:
-                str = String.format("%s(%s%s, %s%s, %s%s, %s%s)",
-                    (code ? "glBlendFuncSeparate" : "void")
-                    , (code ? "/*srcRGB*/ " : "srcRGB=")
-                    , GLEnum.valueOf(msg.getArg0())
-                    , (code ? "/*dstRGB*/ " : "dstRGB=")
-                    , GLEnum.valueOf(msg.getArg1())
-                    , (code ? "/*srcAlpha*/ " : "srcAlpha=")
-                    , GLEnum.valueOf(msg.getArg2())
-                    , (code ? "/*dstAlpha*/ " : "dstAlpha=")
-                    , GLEnum.valueOf(msg.getArg3()));
-                break;
-            case glBufferData:
-                str = String.format("%s(%s%s, %s%s, %s%s, %s%s)",
-                    (code ? "glBufferData" : "void")
-                    , (code ? "/*target*/ " : "target=")
-                    , GLEnum.valueOf(msg.getArg0())
-                    , (code ? "/*size*/ " : "size=")
-                    , msg.getArg1()
-                    , (code ? "/*data*/ " : "data=")
-                    , (code ? "arg2" : "0x" + Integer.toHexString(msg.getArg2()))
-                    , (code ? "/*usage*/ " : "usage=")
-                    , GLEnum.valueOf(msg.getArg3()));
-                break;
-            case glBufferSubData:
-                str = String.format("%s(%s%s, %s%s, %s%s, %s%s)",
-                    (code ? "glBufferSubData" : "void")
-                    , (code ? "/*target*/ " : "target=")
-                    , GLEnum.valueOf(msg.getArg0())
-                    , (code ? "/*offset*/ " : "offset=")
-                    , msg.getArg1()
-                    , (code ? "/*size*/ " : "size=")
-                    , msg.getArg2()
-                    , (code ? "/*data*/ " : "data=")
-                    , (code ? "arg3" : "0x" + Integer.toHexString(msg.getArg3())));
-                break;
-            case glCheckFramebufferStatus:
-                str = String.format("%s(%s%s)",
-                    (code ? "glCheckFramebufferStatus" : GLEnum.valueOf(msg.getRet()))
-                    , (code ? "/*target*/ " : "target=")
-                    , GLEnum.valueOf(msg.getArg0()));
-                break;
-            case glClear:
-                str = String.format("%s(%s%s)",
-                    (code ? "glClear" : "void")
-                    , (code ? "/*mask*/ " : "mask=")
-                    , msg.getArg0());
-                break;
-            case glClearColor:
-                str = String.format("%s(%s%s, %s%s, %s%s, %s%s)",
-                    (code ? "glClearColor" : "void")
-                    , (code ? "/*red*/ " : "red=")
-                    , Float.intBitsToFloat(msg.getArg0())
-                    , (code ? "/*green*/ " : "green=")
-                    , Float.intBitsToFloat(msg.getArg1())
-                    , (code ? "/*blue*/ " : "blue=")
-                    , Float.intBitsToFloat(msg.getArg2())
-                    , (code ? "/*alpha*/ " : "alpha=")
-                    , Float.intBitsToFloat(msg.getArg3()));
-                break;
-            case glClearDepthf:
-                str = String.format("%s(%s%s)",
-                    (code ? "glClearDepthf" : "void")
-                    , (code ? "/*depth*/ " : "depth=")
-                    , Float.intBitsToFloat(msg.getArg0()));
-                break;
-            case glClearStencil:
-                str = String.format("%s(%s%s)",
-                    (code ? "glClearStencil" : "void")
-                    , (code ? "/*s*/ " : "s=")
-                    , msg.getArg0());
-                break;
-            case glColorMask:
-                str = String.format("%s(%s%s, %s%s, %s%s, %s%s)",
-                    (code ? "glColorMask" : "void")
-                    , (code ? "/*red*/ " : "red=")
-                    , msg.getArg0()
-                    , (code ? "/*green*/ " : "green=")
-                    , msg.getArg1()
-                    , (code ? "/*blue*/ " : "blue=")
-                    , msg.getArg2()
-                    , (code ? "/*alpha*/ " : "alpha=")
-                    , msg.getArg3());
-                break;
-            case glCompileShader:
-                str = String.format("%s(%s%s)",
-                    (code ? "glCompileShader" : "void")
-                    , (code ? "/*shader*/ " : "shader=")
-                    , (code ? "shader_" : "") + msg.getArg0());
-                break;
-            case glCompressedTexImage2D:
-                // FIXME: this function uses pointers, debugger may send data in msg.data
-                str = String.format("%s(%s%s, %s%s, %s%s, %s%s, %s%s, %s%s, %s%s, %s%s)",
-                    (code ? "glCompressedTexImage2D" : "void")
-                    , (code ? "/*target*/ " : "target=")
-                    , GLEnum.valueOf(msg.getArg0())
-                    , (code ? "/*level*/ " : "level=")
-                    , msg.getArg1()
-                    , (code ? "/*internalformat*/ " : "internalformat=")
-                    , GLEnum.valueOf(msg.getArg2())
-                    , (code ? "/*width*/ " : "width=")
-                    , msg.getArg3()
-                    , (code ? "/*height*/ " : "height=")
-                    , msg.getArg4()
-                    , (code ? "/*border*/ " : "border=")
-                    , msg.getArg5()
-                    , (code ? "/*imageSize*/ " : "imageSize=")
-                    , msg.getArg6()
-                    , (code ? "/*data*/ " : "data=")
-                    , (code ? "arg7" : "0x" + Integer.toHexString(msg.getArg7())));
-                break;
-            case glCompressedTexSubImage2D:
-                // FIXME: this function uses pointers, debugger may send data in msg.data
-                str = String.format("%s(%s%s, %s%s, %s%s, %s%s, %s%s, %s%s, %s%s, %s%s, %s%s)",
-                    (code ? "glCompressedTexSubImage2D" : "void")
-                    , (code ? "/*target*/ " : "target=")
-                    , GLEnum.valueOf(msg.getArg0())
-                    , (code ? "/*level*/ " : "level=")
-                    , msg.getArg1()
-                    , (code ? "/*xoffset*/ " : "xoffset=")
-                    , msg.getArg2()
-                    , (code ? "/*yoffset*/ " : "yoffset=")
-                    , msg.getArg3()
-                    , (code ? "/*width*/ " : "width=")
-                    , msg.getArg4()
-                    , (code ? "/*height*/ " : "height=")
-                    , msg.getArg5()
-                    , (code ? "/*format*/ " : "format=")
-                    , GLEnum.valueOf(msg.getArg6())
-                    , (code ? "/*imageSize*/ " : "imageSize=")
-                    , msg.getArg7()
-                    , (code ? "/*data*/ " : "data=")
-                    , (code ? "arg8" : "0x" + Integer.toHexString(msg.getArg8())));
-                break;
-            case glCopyTexImage2D:
-                str = String.format("%s(%s%s, %s%s, %s%s, %s%s, %s%s, %s%s, %s%s, %s%s)",
-                    (code ? "glCopyTexImage2D" : "void")
-                    , (code ? "/*target*/ " : "target=")
-                    , GLEnum.valueOf(msg.getArg0())
-                    , (code ? "/*level*/ " : "level=")
-                    , msg.getArg1()
-                    , (code ? "/*internalformat*/ " : "internalformat=")
-                    , GLEnum.valueOf(msg.getArg2())
-                    , (code ? "/*x*/ " : "x=")
-                    , msg.getArg3()
-                    , (code ? "/*y*/ " : "y=")
-                    , msg.getArg4()
-                    , (code ? "/*width*/ " : "width=")
-                    , msg.getArg5()
-                    , (code ? "/*height*/ " : "height=")
-                    , msg.getArg6()
-                    , (code ? "/*border*/ " : "border=")
-                    , msg.getArg7());
-                break;
-            case glCopyTexSubImage2D:
-                str = String.format("%s(%s%s, %s%s, %s%s, %s%s, %s%s, %s%s, %s%s, %s%s)",
-                    (code ? "glCopyTexSubImage2D" : "void")
-                    , (code ? "/*target*/ " : "target=")
-                    , GLEnum.valueOf(msg.getArg0())
-                    , (code ? "/*level*/ " : "level=")
-                    , msg.getArg1()
-                    , (code ? "/*xoffset*/ " : "xoffset=")
-                    , msg.getArg2()
-                    , (code ? "/*yoffset*/ " : "yoffset=")
-                    , msg.getArg3()
-                    , (code ? "/*x*/ " : "x=")
-                    , msg.getArg4()
-                    , (code ? "/*y*/ " : "y=")
-                    , msg.getArg5()
-                    , (code ? "/*width*/ " : "width=")
-                    , msg.getArg6()
-                    , (code ? "/*height*/ " : "height=")
-                    , msg.getArg7());
-                break;
-            case glCreateProgram:
-                str = String.format("%s()",
-                    (code ? "glCreateProgram" : msg.getRet())
-);
-                break;
-            case glCreateShader:
-                str = String.format("%s(%s%s)",
-                    (code ? "glCreateShader" : msg.getRet())
-                    , (code ? "/*type*/ " : "type=")
-                    , GLEnum.valueOf(msg.getArg0()));
-                break;
-            case glCullFace:
-                str = String.format("%s(%s%s)",
-                    (code ? "glCullFace" : "void")
-                    , (code ? "/*mode*/ " : "mode=")
-                    , GLEnum.valueOf(msg.getArg0()));
-                break;
-            case glDeleteBuffers:
-                str = String.format("%s(%s%s, %s%s)",
-                    (code ? "glDeleteBuffers" : "void")
-                    , (code ? "/*n*/ " : "n=")
-                    , msg.getArg0()
-                    , (code ? "/*buffers*/ " : "buffers=")
-                    , (code ? "(GLuint [])" : "") +  formatUInts(1 * msg.getArg0(), msg.getData().asReadOnlyByteBuffer()));
-                break;
-            case glDeleteFramebuffers:
-                str = String.format("%s(%s%s, %s%s)",
-                    (code ? "glDeleteFramebuffers" : "void")
-                    , (code ? "/*n*/ " : "n=")
-                    , msg.getArg0()
-                    , (code ? "/*framebuffers*/ " : "framebuffers=")
-                    , (code ? "(GLuint [])" : "") +  formatUInts(1 * msg.getArg0(), msg.getData().asReadOnlyByteBuffer()));
-                break;
-            case glDeleteProgram:
-                str = String.format("%s(%s%s)",
-                    (code ? "glDeleteProgram" : "void")
-                    , (code ? "/*program*/ " : "program=")
-                    , (code ? "program_" : "") + msg.getArg0());
-                break;
-            case glDeleteRenderbuffers:
-                str = String.format("%s(%s%s, %s%s)",
-                    (code ? "glDeleteRenderbuffers" : "void")
-                    , (code ? "/*n*/ " : "n=")
-                    , msg.getArg0()
-                    , (code ? "/*renderbuffers*/ " : "renderbuffers=")
-                    , (code ? "(GLuint [])" : "") +  formatUInts(1 * msg.getArg0(), msg.getData().asReadOnlyByteBuffer()));
-                break;
-            case glDeleteShader:
-                str = String.format("%s(%s%s)",
-                    (code ? "glDeleteShader" : "void")
-                    , (code ? "/*shader*/ " : "shader=")
-                    , (code ? "shader_" : "") + msg.getArg0());
-                break;
-            case glDeleteTextures:
-                str = String.format("%s(%s%s, %s%s)",
-                    (code ? "glDeleteTextures" : "void")
-                    , (code ? "/*n*/ " : "n=")
-                    , msg.getArg0()
-                    , (code ? "/*textures*/ " : "textures=")
-                    , (code ? "(GLuint [])" : "") +  formatUInts(1 * msg.getArg0(), msg.getData().asReadOnlyByteBuffer()));
-                break;
-            case glDepthFunc:
-                str = String.format("%s(%s%s)",
-                    (code ? "glDepthFunc" : "void")
-                    , (code ? "/*func*/ " : "func=")
-                    , GLEnum.valueOf(msg.getArg0()));
-                break;
-            case glDepthMask:
-                str = String.format("%s(%s%s)",
-                    (code ? "glDepthMask" : "void")
-                    , (code ? "/*flag*/ " : "flag=")
-                    , msg.getArg0());
-                break;
-            case glDepthRangef:
-                str = String.format("%s(%s%s, %s%s)",
-                    (code ? "glDepthRangef" : "void")
-                    , (code ? "/*zNear*/ " : "zNear=")
-                    , Float.intBitsToFloat(msg.getArg0())
-                    , (code ? "/*zFar*/ " : "zFar=")
-                    , Float.intBitsToFloat(msg.getArg1()));
-                break;
-            case glDetachShader:
-                str = String.format("%s(%s%s, %s%s)",
-                    (code ? "glDetachShader" : "void")
-                    , (code ? "/*program*/ " : "program=")
-                    , (code ? "program_" : "") + msg.getArg0()
-                    , (code ? "/*shader*/ " : "shader=")
-                    , (code ? "shader_" : "") + msg.getArg1());
-                break;
-            case glDisable:
-                str = String.format("%s(%s%s)",
-                    (code ? "glDisable" : "void")
-                    , (code ? "/*cap*/ " : "cap=")
-                    , GLEnum.valueOf(msg.getArg0()));
-                break;
-            case glDisableVertexAttribArray:
-                str = String.format("%s(%s%s)",
-                    (code ? "glDisableVertexAttribArray" : "void")
-                    , (code ? "/*index*/ " : "index=")
-                    , msg.getArg0());
-                break;
-            case glDrawArrays:
-                str = String.format("%s(%s%s, %s%s, %s%s)",
-                    (code ? "glDrawArrays" : "void")
-                    , (code ? "/*mode*/ " : "mode=")
-                    , GLEnum.valueOf(msg.getArg0())
-                    , (code ? "/*first*/ " : "first=")
-                    , msg.getArg1()
-                    , (code ? "/*count*/ " : "count=")
-                    , msg.getArg2());
-                break;
-            case glDrawElements:
-                // FIXME: this function uses pointers, debugger may send data in msg.data
-                str = String.format("%s(%s%s, %s%s, %s%s, %s%s)",
-                    (code ? "glDrawElements" : "void")
-                    , (code ? "/*mode*/ " : "mode=")
-                    , GLEnum.valueOf(msg.getArg0())
-                    , (code ? "/*count*/ " : "count=")
-                    , msg.getArg1()
-                    , (code ? "/*type*/ " : "type=")
-                    , GLEnum.valueOf(msg.getArg2())
-                    , (code ? "/*indices*/ " : "indices=")
-                    , (code ? "arg3" : "0x" + Integer.toHexString(msg.getArg3())));
-                break;
-            case glEnable:
-                str = String.format("%s(%s%s)",
-                    (code ? "glEnable" : "void")
-                    , (code ? "/*cap*/ " : "cap=")
-                    , GLEnum.valueOf(msg.getArg0()));
-                break;
-            case glEnableVertexAttribArray:
-                str = String.format("%s(%s%s)",
-                    (code ? "glEnableVertexAttribArray" : "void")
-                    , (code ? "/*index*/ " : "index=")
-                    , msg.getArg0());
-                break;
-            case glFinish:
-                str = String.format("%s()",
-                    (code ? "glFinish" : "void")
-);
-                break;
-            case glFlush:
-                str = String.format("%s()",
-                    (code ? "glFlush" : "void")
-);
-                break;
-            case glFramebufferRenderbuffer:
-                str = String.format("%s(%s%s, %s%s, %s%s, %s%s)",
-                    (code ? "glFramebufferRenderbuffer" : "void")
-                    , (code ? "/*target*/ " : "target=")
-                    , GLEnum.valueOf(msg.getArg0())
-                    , (code ? "/*attachment*/ " : "attachment=")
-                    , GLEnum.valueOf(msg.getArg1())
-                    , (code ? "/*renderbuffertarget*/ " : "renderbuffertarget=")
-                    , GLEnum.valueOf(msg.getArg2())
-                    , (code ? "/*renderbuffer*/ " : "renderbuffer=")
-                    , (code ? "renderbuffer_" : "") + msg.getArg3());
-                break;
-            case glFramebufferTexture2D:
-                str = String.format("%s(%s%s, %s%s, %s%s, %s%s, %s%s)",
-                    (code ? "glFramebufferTexture2D" : "void")
-                    , (code ? "/*target*/ " : "target=")
-                    , GLEnum.valueOf(msg.getArg0())
-                    , (code ? "/*attachment*/ " : "attachment=")
-                    , GLEnum.valueOf(msg.getArg1())
-                    , (code ? "/*textarget*/ " : "textarget=")
-                    , GLEnum.valueOf(msg.getArg2())
-                    , (code ? "/*texture*/ " : "texture=")
-                    , (code ? "texture_" : "") + msg.getArg3()
-                    , (code ? "/*level*/ " : "level=")
-                    , msg.getArg4());
-                break;
-            case glFrontFace:
-                str = String.format("%s(%s%s)",
-                    (code ? "glFrontFace" : "void")
-                    , (code ? "/*mode*/ " : "mode=")
-                    , GLEnum.valueOf(msg.getArg0()));
-                break;
-            case glGenBuffers:
-                str = String.format("%s(%s%s, %s%s)",
-                    (code ? "glGenBuffers" : "void")
-                    , (code ? "/*n*/ " : "n=")
-                    , msg.getArg0()
-                    , (code ? "/*buffers*/ " : "buffers=")
-                    , (code ? "(GLuint [])" : "") +  formatUInts(1 * msg.getArg0(), msg.getData().asReadOnlyByteBuffer()));
-                break;
-            case glGenerateMipmap:
-                str = String.format("%s(%s%s)",
-                    (code ? "glGenerateMipmap" : "void")
-                    , (code ? "/*target*/ " : "target=")
-                    , GLEnum.valueOf(msg.getArg0()));
-                break;
-            case glGenFramebuffers:
-                str = String.format("%s(%s%s, %s%s)",
-                    (code ? "glGenFramebuffers" : "void")
-                    , (code ? "/*n*/ " : "n=")
-                    , msg.getArg0()
-                    , (code ? "/*framebuffers*/ " : "framebuffers=")
-                    , (code ? "(GLuint [])" : "") +  formatUInts(1 * msg.getArg0(), msg.getData().asReadOnlyByteBuffer()));
-                break;
-            case glGenRenderbuffers:
-                str = String.format("%s(%s%s, %s%s)",
-                    (code ? "glGenRenderbuffers" : "void")
-                    , (code ? "/*n*/ " : "n=")
-                    , msg.getArg0()
-                    , (code ? "/*renderbuffers*/ " : "renderbuffers=")
-                    , (code ? "(GLuint [])" : "") +  formatUInts(1 * msg.getArg0(), msg.getData().asReadOnlyByteBuffer()));
-                break;
-            case glGenTextures:
-                str = String.format("%s(%s%s, %s%s)",
-                    (code ? "glGenTextures" : "void")
-                    , (code ? "/*n*/ " : "n=")
-                    , msg.getArg0()
-                    , (code ? "/*textures*/ " : "textures=")
-                    , (code ? "(GLuint [])" : "") +  formatUInts(1 * msg.getArg0(), msg.getData().asReadOnlyByteBuffer()));
-                break;
-            case glGetActiveAttrib:
-                // FIXME: this function uses pointers, debugger may send data in msg.data
-                str = String.format("%s(%s%s, %s%s, %s%s, %s%s, %s%s, %s%s, %s%s)",
-                    (code ? "glGetActiveAttrib" : "void")
-                    , (code ? "/*program*/ " : "program=")
-                    , (code ? "program_" : "") + msg.getArg0()
-                    , (code ? "/*index*/ " : "index=")
-                    , msg.getArg1()
-                    , (code ? "/*bufsize*/ " : "bufsize=")
-                    , msg.getArg2()
-                    , (code ? "/*length*/ " : "length=")
-                    , (code ? "arg3" : "0x" + Integer.toHexString(msg.getArg3()))
-                    , (code ? "/*size*/ " : "size=")
-                    , (code ? "arg4" : "0x" + Integer.toHexString(msg.getArg4()))
-                    , (code ? "/*type*/ " : "type=")
-                    , (code ? "arg5" : "0x" + Integer.toHexString(msg.getArg5()))
-                    , (code ? "/*name*/ " : "name=")
-                    , (code ? "\"" : "") + msg.getData().toStringUtf8() + (code ? "\"" : ""));
-                break;
-            case glGetActiveUniform:
-                // FIXME: this function uses pointers, debugger may send data in msg.data
-                str = String.format("%s(%s%s, %s%s, %s%s, %s%s, %s%s, %s%s, %s%s)",
-                    (code ? "glGetActiveUniform" : "void")
-                    , (code ? "/*program*/ " : "program=")
-                    , (code ? "program_" : "") + msg.getArg0()
-                    , (code ? "/*index*/ " : "index=")
-                    , msg.getArg1()
-                    , (code ? "/*bufsize*/ " : "bufsize=")
-                    , msg.getArg2()
-                    , (code ? "/*length*/ " : "length=")
-                    , (code ? "arg3" : "0x" + Integer.toHexString(msg.getArg3()))
-                    , (code ? "/*size*/ " : "size=")
-                    , (code ? "arg4" : "0x" + Integer.toHexString(msg.getArg4()))
-                    , (code ? "/*type*/ " : "type=")
-                    , (code ? "arg5" : "0x" + Integer.toHexString(msg.getArg5()))
-                    , (code ? "/*name*/ " : "name=")
-                    , (code ? "\"" : "") + msg.getData().toStringUtf8() + (code ? "\"" : ""));
-                break;
-            case glGetAttachedShaders:
-                // FIXME: this function uses pointers, debugger may send data in msg.data
-                str = String.format("%s(%s%s, %s%s, %s%s, %s%s)",
-                    (code ? "glGetAttachedShaders" : "void")
-                    , (code ? "/*program*/ " : "program=")
-                    , (code ? "program_" : "") + msg.getArg0()
-                    , (code ? "/*maxcount*/ " : "maxcount=")
-                    , msg.getArg1()
-                    , (code ? "/*count*/ " : "count=")
-                    , (code ? "arg2" : "0x" + Integer.toHexString(msg.getArg2()))
-                    , (code ? "/*shaders*/ " : "shaders=")
-                    , (code ? "arg3" : "0x" + Integer.toHexString(msg.getArg3())));
-                break;
-            case glGetAttribLocation:
-                str = String.format("%s(%s%s, %s%s)",
-                    (code ? "glGetAttribLocation" : msg.getRet())
-                    , (code ? "/*program*/ " : "program=")
-                    , (code ? "program_" : "") + msg.getArg0()
-                    , (code ? "/*name*/ " : "name=")
-                    , (code ? "\"" : "") + msg.getData().toStringUtf8() + (code ? "\"" : ""));
-                break;
-            case glGetBooleanv:
-                // FIXME: this function uses pointers, debugger may send data in msg.data
-                str = String.format("%s(%s%s, %s%s)",
-                    (code ? "glGetBooleanv" : "void")
-                    , (code ? "/*pname*/ " : "pname=")
-                    , GLEnum.valueOf(msg.getArg0())
-                    , (code ? "/*params*/ " : "params=")
-                    , (code ? "arg1" : "0x" + Integer.toHexString(msg.getArg1())));
-                break;
-            case glGetBufferParameteriv:
-                // FIXME: this function uses pointers, debugger may send data in msg.data
-                str = String.format("%s(%s%s, %s%s, %s%s)",
-                    (code ? "glGetBufferParameteriv" : "void")
-                    , (code ? "/*target*/ " : "target=")
-                    , GLEnum.valueOf(msg.getArg0())
-                    , (code ? "/*pname*/ " : "pname=")
-                    , GLEnum.valueOf(msg.getArg1())
-                    , (code ? "/*params*/ " : "params=")
-                    , (code ? "arg2" : "0x" + Integer.toHexString(msg.getArg2())));
-                break;
-            case glGetError:
-                str = String.format("%s()",
-                    (code ? "glGetError" : GLEnum.valueOf(msg.getRet()))
-);
-                break;
-            case glGetFloatv:
-                // FIXME: this function uses pointers, debugger may send data in msg.data
-                str = String.format("%s(%s%s, %s%s)",
-                    (code ? "glGetFloatv" : "void")
-                    , (code ? "/*pname*/ " : "pname=")
-                    , GLEnum.valueOf(msg.getArg0())
-                    , (code ? "/*params*/ " : "params=")
-                    , (code ? "arg1" : "0x" + Integer.toHexString(msg.getArg1())));
-                break;
-            case glGetFramebufferAttachmentParameteriv:
-                // FIXME: this function uses pointers, debugger may send data in msg.data
-                str = String.format("%s(%s%s, %s%s, %s%s, %s%s)",
-                    (code ? "glGetFramebufferAttachmentParameteriv" : "void")
-                    , (code ? "/*target*/ " : "target=")
-                    , GLEnum.valueOf(msg.getArg0())
-                    , (code ? "/*attachment*/ " : "attachment=")
-                    , GLEnum.valueOf(msg.getArg1())
-                    , (code ? "/*pname*/ " : "pname=")
-                    , GLEnum.valueOf(msg.getArg2())
-                    , (code ? "/*params*/ " : "params=")
-                    , (code ? "arg3" : "0x" + Integer.toHexString(msg.getArg3())));
-                break;
-            case glGetIntegerv:
-                // FIXME: this function uses pointers, debugger may send data in msg.data
-                str = String.format("%s(%s%s, %s%s)",
-                    (code ? "glGetIntegerv" : "void")
-                    , (code ? "/*pname*/ " : "pname=")
-                    , GLEnum.valueOf(msg.getArg0())
-                    , (code ? "/*params*/ " : "params=")
-                    , (code ? "arg1" : "0x" + Integer.toHexString(msg.getArg1())));
-                break;
-            case glGetProgramiv:
-                str = String.format("%s(%s%s, %s%s, %s%s)",
-                    (code ? "glGetProgramiv" : "void")
-                    , (code ? "/*program*/ " : "program=")
-                    , (code ? "program_" : "") + msg.getArg0()
-                    , (code ? "/*pname*/ " : "pname=")
-                    , GLEnum.valueOf(msg.getArg1())
-                    , (code ? "/*params*/ " : "params=")
-                    , (code ? "(GLint [])" : "") + formatInts(1, msg.getData().asReadOnlyByteBuffer()));
-                break;
-            case glGetProgramInfoLog:
-                // FIXME: this function uses pointers, debugger may send data in msg.data
-                str = String.format("%s(%s%s, %s%s, %s%s, %s%s)",
-                    (code ? "glGetProgramInfoLog" : "void")
-                    , (code ? "/*program*/ " : "program=")
-                    , (code ? "program_" : "") + msg.getArg0()
-                    , (code ? "/*bufsize*/ " : "bufsize=")
-                    , msg.getArg1()
-                    , (code ? "/*length*/ " : "length=")
-                    , (code ? "arg2" : "0x" + Integer.toHexString(msg.getArg2()))
-                    , (code ? "/*infolog*/ " : "infolog=")
-                    , (code ? "\"" : "") + msg.getData().toStringUtf8() + (code ? "\"" : ""));
-                break;
-            case glGetRenderbufferParameteriv:
-                // FIXME: this function uses pointers, debugger may send data in msg.data
-                str = String.format("%s(%s%s, %s%s, %s%s)",
-                    (code ? "glGetRenderbufferParameteriv" : "void")
-                    , (code ? "/*target*/ " : "target=")
-                    , GLEnum.valueOf(msg.getArg0())
-                    , (code ? "/*pname*/ " : "pname=")
-                    , GLEnum.valueOf(msg.getArg1())
-                    , (code ? "/*params*/ " : "params=")
-                    , (code ? "arg2" : "0x" + Integer.toHexString(msg.getArg2())));
-                break;
-            case glGetShaderiv:
-                str = String.format("%s(%s%s, %s%s, %s%s)",
-                    (code ? "glGetShaderiv" : "void")
-                    , (code ? "/*shader*/ " : "shader=")
-                    , (code ? "shader_" : "") + msg.getArg0()
-                    , (code ? "/*pname*/ " : "pname=")
-                    , GLEnum.valueOf(msg.getArg1())
-                    , (code ? "/*params*/ " : "params=")
-                    , (code ? "(GLint [])" : "") + formatInts(1, msg.getData().asReadOnlyByteBuffer()));
-                break;
-            case glGetShaderInfoLog:
-                // FIXME: this function uses pointers, debugger may send data in msg.data
-                str = String.format("%s(%s%s, %s%s, %s%s, %s%s)",
-                    (code ? "glGetShaderInfoLog" : "void")
-                    , (code ? "/*shader*/ " : "shader=")
-                    , (code ? "shader_" : "") + msg.getArg0()
-                    , (code ? "/*bufsize*/ " : "bufsize=")
-                    , msg.getArg1()
-                    , (code ? "/*length*/ " : "length=")
-                    , (code ? "arg2" : "0x" + Integer.toHexString(msg.getArg2()))
-                    , (code ? "/*infolog*/ " : "infolog=")
-                    , (code ? "\"" : "") + msg.getData().toStringUtf8() + (code ? "\"" : ""));
-                break;
-            case glGetShaderPrecisionFormat:
-                // FIXME: this function uses pointers, debugger may send data in msg.data
-                str = String.format("%s(%s%s, %s%s, %s%s, %s%s)",
-                    (code ? "glGetShaderPrecisionFormat" : "void")
-                    , (code ? "/*shadertype*/ " : "shadertype=")
-                    , GLEnum.valueOf(msg.getArg0())
-                    , (code ? "/*precisiontype*/ " : "precisiontype=")
-                    , GLEnum.valueOf(msg.getArg1())
-                    , (code ? "/*range*/ " : "range=")
-                    , (code ? "arg2" : "0x" + Integer.toHexString(msg.getArg2()))
-                    , (code ? "/*precision*/ " : "precision=")
-                    , (code ? "arg3" : "0x" + Integer.toHexString(msg.getArg3())));
-                break;
-            case glGetShaderSource:
-                // FIXME: this function uses pointers, debugger may send data in msg.data
-                str = String.format("%s(%s%s, %s%s, %s%s, %s%s)",
-                    (code ? "glGetShaderSource" : "void")
-                    , (code ? "/*shader*/ " : "shader=")
-                    , (code ? "shader_" : "") + msg.getArg0()
-                    , (code ? "/*bufsize*/ " : "bufsize=")
-                    , msg.getArg1()
-                    , (code ? "/*length*/ " : "length=")
-                    , (code ? "arg2" : "0x" + Integer.toHexString(msg.getArg2()))
-                    , (code ? "/*source*/ " : "source=")
-                    , (code ? "\"" : "") + msg.getData().toStringUtf8() + (code ? "\"" : ""));
-                break;
-            case glGetString:
-                // FIXME: this function uses pointers, debugger may send data in msg.data
-                str = String.format("%s(%s%s)",
-                    (code ? "glGetString" : "0x" + Integer.toHexString(msg.getRet()))
-                    , (code ? "/*name*/ " : "name=")
-                    , GLEnum.valueOf(msg.getArg0()));
-                break;
-            case glGetTexParameterfv:
-                // FIXME: this function uses pointers, debugger may send data in msg.data
-                str = String.format("%s(%s%s, %s%s, %s%s)",
-                    (code ? "glGetTexParameterfv" : "void")
-                    , (code ? "/*target*/ " : "target=")
-                    , GLEnum.valueOf(msg.getArg0())
-                    , (code ? "/*pname*/ " : "pname=")
-                    , GLEnum.valueOf(msg.getArg1())
-                    , (code ? "/*params*/ " : "params=")
-                    , (code ? "arg2" : "0x" + Integer.toHexString(msg.getArg2())));
-                break;
-            case glGetTexParameteriv:
-                // FIXME: this function uses pointers, debugger may send data in msg.data
-                str = String.format("%s(%s%s, %s%s, %s%s)",
-                    (code ? "glGetTexParameteriv" : "void")
-                    , (code ? "/*target*/ " : "target=")
-                    , GLEnum.valueOf(msg.getArg0())
-                    , (code ? "/*pname*/ " : "pname=")
-                    , GLEnum.valueOf(msg.getArg1())
-                    , (code ? "/*params*/ " : "params=")
-                    , (code ? "arg2" : "0x" + Integer.toHexString(msg.getArg2())));
-                break;
-            case glGetUniformfv:
-                // FIXME: this function uses pointers, debugger may send data in msg.data
-                str = String.format("%s(%s%s, %s%s, %s%s)",
-                    (code ? "glGetUniformfv" : "void")
-                    , (code ? "/*program*/ " : "program=")
-                    , (code ? "program_" : "") + msg.getArg0()
-                    , (code ? "/*location*/ " : "location=")
-                    , msg.getArg1()
-                    , (code ? "/*params*/ " : "params=")
-                    , (code ? "arg2" : "0x" + Integer.toHexString(msg.getArg2())));
-                break;
-            case glGetUniformiv:
-                // FIXME: this function uses pointers, debugger may send data in msg.data
-                str = String.format("%s(%s%s, %s%s, %s%s)",
-                    (code ? "glGetUniformiv" : "void")
-                    , (code ? "/*program*/ " : "program=")
-                    , (code ? "program_" : "") + msg.getArg0()
-                    , (code ? "/*location*/ " : "location=")
-                    , msg.getArg1()
-                    , (code ? "/*params*/ " : "params=")
-                    , (code ? "arg2" : "0x" + Integer.toHexString(msg.getArg2())));
-                break;
-            case glGetUniformLocation:
-                str = String.format("%s(%s%s, %s%s)",
-                    (code ? "glGetUniformLocation" : msg.getRet())
-                    , (code ? "/*program*/ " : "program=")
-                    , (code ? "program_" : "") + msg.getArg0()
-                    , (code ? "/*name*/ " : "name=")
-                    , (code ? "\"" : "") + msg.getData().toStringUtf8() + (code ? "\"" : ""));
-                break;
-            case glGetVertexAttribfv:
-                // FIXME: this function uses pointers, debugger may send data in msg.data
-                str = String.format("%s(%s%s, %s%s, %s%s)",
-                    (code ? "glGetVertexAttribfv" : "void")
-                    , (code ? "/*index*/ " : "index=")
-                    , msg.getArg0()
-                    , (code ? "/*pname*/ " : "pname=")
-                    , GLEnum.valueOf(msg.getArg1())
-                    , (code ? "/*params*/ " : "params=")
-                    , (code ? "arg2" : "0x" + Integer.toHexString(msg.getArg2())));
-                break;
-            case glGetVertexAttribiv:
-                // FIXME: this function uses pointers, debugger may send data in msg.data
-                str = String.format("%s(%s%s, %s%s, %s%s)",
-                    (code ? "glGetVertexAttribiv" : "void")
-                    , (code ? "/*index*/ " : "index=")
-                    , msg.getArg0()
-                    , (code ? "/*pname*/ " : "pname=")
-                    , GLEnum.valueOf(msg.getArg1())
-                    , (code ? "/*params*/ " : "params=")
-                    , (code ? "arg2" : "0x" + Integer.toHexString(msg.getArg2())));
-                break;
-            case glGetVertexAttribPointerv:
-                // FIXME: this function uses pointers, debugger may send data in msg.data
-                str = String.format("%s(%s%s, %s%s, %s%s)",
-                    (code ? "glGetVertexAttribPointerv" : "void")
-                    , (code ? "/*index*/ " : "index=")
-                    , msg.getArg0()
-                    , (code ? "/*pname*/ " : "pname=")
-                    , GLEnum.valueOf(msg.getArg1())
-                    , (code ? "/*pointer*/ " : "pointer=")
-                    , (code ? "arg2" : "0x" + Integer.toHexString(msg.getArg2())));
-                break;
-            case glHint:
-                str = String.format("%s(%s%s, %s%s)",
-                    (code ? "glHint" : "void")
-                    , (code ? "/*target*/ " : "target=")
-                    , GLEnum.valueOf(msg.getArg0())
-                    , (code ? "/*mode*/ " : "mode=")
-                    , GLEnum.valueOf(msg.getArg1()));
-                break;
-            case glIsBuffer:
-                str = String.format("%s(%s%s)",
-                    (code ? "glIsBuffer" : msg.getRet())
-                    , (code ? "/*buffer*/ " : "buffer=")
-                    , (code ? "buffer_" : "") + msg.getArg0());
-                break;
-            case glIsEnabled:
-                str = String.format("%s(%s%s)",
-                    (code ? "glIsEnabled" : msg.getRet())
-                    , (code ? "/*cap*/ " : "cap=")
-                    , GLEnum.valueOf(msg.getArg0()));
-                break;
-            case glIsFramebuffer:
-                str = String.format("%s(%s%s)",
-                    (code ? "glIsFramebuffer" : msg.getRet())
-                    , (code ? "/*framebuffer*/ " : "framebuffer=")
-                    , (code ? "framebuffer_" : "") + msg.getArg0());
-                break;
-            case glIsProgram:
-                str = String.format("%s(%s%s)",
-                    (code ? "glIsProgram" : msg.getRet())
-                    , (code ? "/*program*/ " : "program=")
-                    , (code ? "program_" : "") + msg.getArg0());
-                break;
-            case glIsRenderbuffer:
-                str = String.format("%s(%s%s)",
-                    (code ? "glIsRenderbuffer" : msg.getRet())
-                    , (code ? "/*renderbuffer*/ " : "renderbuffer=")
-                    , (code ? "renderbuffer_" : "") + msg.getArg0());
-                break;
-            case glIsShader:
-                str = String.format("%s(%s%s)",
-                    (code ? "glIsShader" : msg.getRet())
-                    , (code ? "/*shader*/ " : "shader=")
-                    , (code ? "shader_" : "") + msg.getArg0());
-                break;
-            case glIsTexture:
-                str = String.format("%s(%s%s)",
-                    (code ? "glIsTexture" : msg.getRet())
-                    , (code ? "/*texture*/ " : "texture=")
-                    , (code ? "texture_" : "") + msg.getArg0());
-                break;
-            case glLineWidth:
-                str = String.format("%s(%s%s)",
-                    (code ? "glLineWidth" : "void")
-                    , (code ? "/*width*/ " : "width=")
-                    , Float.intBitsToFloat(msg.getArg0()));
-                break;
-            case glLinkProgram:
-                str = String.format("%s(%s%s)",
-                    (code ? "glLinkProgram" : "void")
-                    , (code ? "/*program*/ " : "program=")
-                    , (code ? "program_" : "") + msg.getArg0());
-                break;
-            case glPixelStorei:
-                str = String.format("%s(%s%s, %s%s)",
-                    (code ? "glPixelStorei" : "void")
-                    , (code ? "/*pname*/ " : "pname=")
-                    , GLEnum.valueOf(msg.getArg0())
-                    , (code ? "/*param*/ " : "param=")
-                    , msg.getArg1());
-                break;
-            case glPolygonOffset:
-                str = String.format("%s(%s%s, %s%s)",
-                    (code ? "glPolygonOffset" : "void")
-                    , (code ? "/*factor*/ " : "factor=")
-                    , Float.intBitsToFloat(msg.getArg0())
-                    , (code ? "/*units*/ " : "units=")
-                    , Float.intBitsToFloat(msg.getArg1()));
-                break;
-            case glReadPixels:
-                // FIXME: this function uses pointers, debugger may send data in msg.data
-                str = String.format("%s(%s%s, %s%s, %s%s, %s%s, %s%s, %s%s, %s%s)",
-                    (code ? "glReadPixels" : "void")
-                    , (code ? "/*x*/ " : "x=")
-                    , msg.getArg0()
-                    , (code ? "/*y*/ " : "y=")
-                    , msg.getArg1()
-                    , (code ? "/*width*/ " : "width=")
-                    , msg.getArg2()
-                    , (code ? "/*height*/ " : "height=")
-                    , msg.getArg3()
-                    , (code ? "/*format*/ " : "format=")
-                    , GLEnum.valueOf(msg.getArg4())
-                    , (code ? "/*type*/ " : "type=")
-                    , GLEnum.valueOf(msg.getArg5())
-                    , (code ? "/*pixels*/ " : "pixels=")
-                    , (code ? "arg6" : "0x" + Integer.toHexString(msg.getArg6())));
-                break;
-            case glReleaseShaderCompiler:
-                str = String.format("%s()",
-                    (code ? "glReleaseShaderCompiler" : "void")
-);
-                break;
-            case glRenderbufferStorage:
-                str = String.format("%s(%s%s, %s%s, %s%s, %s%s)",
-                    (code ? "glRenderbufferStorage" : "void")
-                    , (code ? "/*target*/ " : "target=")
-                    , GLEnum.valueOf(msg.getArg0())
-                    , (code ? "/*internalformat*/ " : "internalformat=")
-                    , GLEnum.valueOf(msg.getArg1())
-                    , (code ? "/*width*/ " : "width=")
-                    , msg.getArg2()
-                    , (code ? "/*height*/ " : "height=")
-                    , msg.getArg3());
-                break;
-            case glSampleCoverage:
-                str = String.format("%s(%s%s, %s%s)",
-                    (code ? "glSampleCoverage" : "void")
-                    , (code ? "/*value*/ " : "value=")
-                    , Float.intBitsToFloat(msg.getArg0())
-                    , (code ? "/*invert*/ " : "invert=")
-                    , msg.getArg1());
-                break;
-            case glScissor:
-                str = String.format("%s(%s%s, %s%s, %s%s, %s%s)",
-                    (code ? "glScissor" : "void")
-                    , (code ? "/*x*/ " : "x=")
-                    , msg.getArg0()
-                    , (code ? "/*y*/ " : "y=")
-                    , msg.getArg1()
-                    , (code ? "/*width*/ " : "width=")
-                    , msg.getArg2()
-                    , (code ? "/*height*/ " : "height=")
-                    , msg.getArg3());
-                break;
-            case glShaderBinary:
-                // FIXME: this function uses pointers, debugger may send data in msg.data
-                str = String.format("%s(%s%s, %s%s, %s%s, %s%s, %s%s)",
-                    (code ? "glShaderBinary" : "void")
-                    , (code ? "/*n*/ " : "n=")
-                    , msg.getArg0()
-                    , (code ? "/*shaders*/ " : "shaders=")
-                    , (code ? "arg1" : "0x" + Integer.toHexString(msg.getArg1()))
-                    , (code ? "/*binaryformat*/ " : "binaryformat=")
-                    , GLEnum.valueOf(msg.getArg2())
-                    , (code ? "/*binary*/ " : "binary=")
-                    , (code ? "arg3" : "0x" + Integer.toHexString(msg.getArg3()))
-                    , (code ? "/*length*/ " : "length=")
-                    , msg.getArg4());
-                break;
-            case glShaderSource:
-                // FIXME: this function uses pointers, debugger may send data in msg.data
-                str = String.format("%s(%s%s, %s%s, %s%s, %s%s)",
-                    (code ? "glShaderSource" : "void")
-                    , (code ? "/*shader*/ " : "shader=")
-                    , (code ? "shader_" : "") + msg.getArg0()
-                    , (code ? "/*count*/ " : "count=")
-                    , msg.getArg1()
-                    , (code ? "/*string*/ " : "string=")
-                    , (code ? "arg2" : "0x" + Integer.toHexString(msg.getArg2()))
-                    , (code ? "/*length*/ " : "length=")
-                    , (code ? "arg3" : "0x" + Integer.toHexString(msg.getArg3())));
-                break;
-            case glStencilFunc:
-                str = String.format("%s(%s%s, %s%s, %s%s)",
-                    (code ? "glStencilFunc" : "void")
-                    , (code ? "/*func*/ " : "func=")
-                    , GLEnum.valueOf(msg.getArg0())
-                    , (code ? "/*ref*/ " : "ref=")
-                    , msg.getArg1()
-                    , (code ? "/*mask*/ " : "mask=")
-                    , msg.getArg2());
-                break;
-            case glStencilFuncSeparate:
-                str = String.format("%s(%s%s, %s%s, %s%s, %s%s)",
-                    (code ? "glStencilFuncSeparate" : "void")
-                    , (code ? "/*face*/ " : "face=")
-                    , GLEnum.valueOf(msg.getArg0())
-                    , (code ? "/*func*/ " : "func=")
-                    , GLEnum.valueOf(msg.getArg1())
-                    , (code ? "/*ref*/ " : "ref=")
-                    , msg.getArg2()
-                    , (code ? "/*mask*/ " : "mask=")
-                    , msg.getArg3());
-                break;
-            case glStencilMask:
-                str = String.format("%s(%s%s)",
-                    (code ? "glStencilMask" : "void")
-                    , (code ? "/*mask*/ " : "mask=")
-                    , msg.getArg0());
-                break;
-            case glStencilMaskSeparate:
-                str = String.format("%s(%s%s, %s%s)",
-                    (code ? "glStencilMaskSeparate" : "void")
-                    , (code ? "/*face*/ " : "face=")
-                    , GLEnum.valueOf(msg.getArg0())
-                    , (code ? "/*mask*/ " : "mask=")
-                    , msg.getArg1());
-                break;
-            case glStencilOp:
-                str = String.format("%s(%s%s, %s%s, %s%s)",
-                    (code ? "glStencilOp" : "void")
-                    , (code ? "/*fail*/ " : "fail=")
-                    , GLEnum.valueOf(msg.getArg0())
-                    , (code ? "/*zfail*/ " : "zfail=")
-                    , GLEnum.valueOf(msg.getArg1())
-                    , (code ? "/*zpass*/ " : "zpass=")
-                    , GLEnum.valueOf(msg.getArg2()));
-                break;
-            case glStencilOpSeparate:
-                str = String.format("%s(%s%s, %s%s, %s%s, %s%s)",
-                    (code ? "glStencilOpSeparate" : "void")
-                    , (code ? "/*face*/ " : "face=")
-                    , GLEnum.valueOf(msg.getArg0())
-                    , (code ? "/*fail*/ " : "fail=")
-                    , GLEnum.valueOf(msg.getArg1())
-                    , (code ? "/*zfail*/ " : "zfail=")
-                    , GLEnum.valueOf(msg.getArg2())
-                    , (code ? "/*zpass*/ " : "zpass=")
-                    , GLEnum.valueOf(msg.getArg3()));
-                break;
-            case glTexImage2D:
-                // FIXME: this function uses pointers, debugger may send data in msg.data
-                str = String.format("%s(%s%s, %s%s, %s%s, %s%s, %s%s, %s%s, %s%s, %s%s, %s%s)",
-                    (code ? "glTexImage2D" : "void")
-                    , (code ? "/*target*/ " : "target=")
-                    , GLEnum.valueOf(msg.getArg0())
-                    , (code ? "/*level*/ " : "level=")
-                    , msg.getArg1()
-                    , (code ? "/*internalformat*/ " : "internalformat=")
-                    , msg.getArg2()
-                    , (code ? "/*width*/ " : "width=")
-                    , msg.getArg3()
-                    , (code ? "/*height*/ " : "height=")
-                    , msg.getArg4()
-                    , (code ? "/*border*/ " : "border=")
-                    , msg.getArg5()
-                    , (code ? "/*format*/ " : "format=")
-                    , GLEnum.valueOf(msg.getArg6())
-                    , (code ? "/*type*/ " : "type=")
-                    , GLEnum.valueOf(msg.getArg7())
-                    , (code ? "/*pixels*/ " : "pixels=")
-                    , (code ? "arg8" : "0x" + Integer.toHexString(msg.getArg8())));
-                break;
-            case glTexParameterf:
-                str = String.format("%s(%s%s, %s%s, %s%s)",
-                    (code ? "glTexParameterf" : "void")
-                    , (code ? "/*target*/ " : "target=")
-                    , GLEnum.valueOf(msg.getArg0())
-                    , (code ? "/*pname*/ " : "pname=")
-                    , GLEnum.valueOf(msg.getArg1())
-                    , (code ? "/*param*/ " : "param=")
-                    , Float.intBitsToFloat(msg.getArg2()));
-                break;
-            case glTexParameterfv:
-                // FIXME: this function uses pointers, debugger may send data in msg.data
-                str = String.format("%s(%s%s, %s%s, %s%s)",
-                    (code ? "glTexParameterfv" : "void")
-                    , (code ? "/*target*/ " : "target=")
-                    , GLEnum.valueOf(msg.getArg0())
-                    , (code ? "/*pname*/ " : "pname=")
-                    , GLEnum.valueOf(msg.getArg1())
-                    , (code ? "/*params*/ " : "params=")
-                    , (code ? "arg2" : "0x" + Integer.toHexString(msg.getArg2())));
-                break;
-            case glTexParameteri:
-                str = String.format("%s(%s%s, %s%s, %s%s)",
-                    (code ? "glTexParameteri" : "void")
-                    , (code ? "/*target*/ " : "target=")
-                    , GLEnum.valueOf(msg.getArg0())
-                    , (code ? "/*pname*/ " : "pname=")
-                    , GLEnum.valueOf(msg.getArg1())
-                    , (code ? "/*param*/ " : "param=")
-                    , msg.getArg2());
-                break;
-            case glTexParameteriv:
-                // FIXME: this function uses pointers, debugger may send data in msg.data
-                str = String.format("%s(%s%s, %s%s, %s%s)",
-                    (code ? "glTexParameteriv" : "void")
-                    , (code ? "/*target*/ " : "target=")
-                    , GLEnum.valueOf(msg.getArg0())
-                    , (code ? "/*pname*/ " : "pname=")
-                    , GLEnum.valueOf(msg.getArg1())
-                    , (code ? "/*params*/ " : "params=")
-                    , (code ? "arg2" : "0x" + Integer.toHexString(msg.getArg2())));
-                break;
-            case glTexSubImage2D:
-                // FIXME: this function uses pointers, debugger may send data in msg.data
-                str = String.format("%s(%s%s, %s%s, %s%s, %s%s, %s%s, %s%s, %s%s, %s%s, %s%s)",
-                    (code ? "glTexSubImage2D" : "void")
-                    , (code ? "/*target*/ " : "target=")
-                    , GLEnum.valueOf(msg.getArg0())
-                    , (code ? "/*level*/ " : "level=")
-                    , msg.getArg1()
-                    , (code ? "/*xoffset*/ " : "xoffset=")
-                    , msg.getArg2()
-                    , (code ? "/*yoffset*/ " : "yoffset=")
-                    , msg.getArg3()
-                    , (code ? "/*width*/ " : "width=")
-                    , msg.getArg4()
-                    , (code ? "/*height*/ " : "height=")
-                    , msg.getArg5()
-                    , (code ? "/*format*/ " : "format=")
-                    , GLEnum.valueOf(msg.getArg6())
-                    , (code ? "/*type*/ " : "type=")
-                    , GLEnum.valueOf(msg.getArg7())
-                    , (code ? "/*pixels*/ " : "pixels=")
-                    , (code ? "arg8" : "0x" + Integer.toHexString(msg.getArg8())));
-                break;
-            case glUniform1f:
-                str = String.format("%s(%s%s, %s%s)",
-                    (code ? "glUniform1f" : "void")
-                    , (code ? "/*location*/ " : "location=")
-                    , msg.getArg0()
-                    , (code ? "/*x*/ " : "x=")
-                    , Float.intBitsToFloat(msg.getArg1()));
-                break;
-            case glUniform1fv:
-                str = String.format("%s(%s%s, %s%s, %s%s)",
-                    (code ? "glUniform1fv" : "void")
-                    , (code ? "/*location*/ " : "location=")
-                    , msg.getArg0()
-                    , (code ? "/*count*/ " : "count=")
-                    , msg.getArg1()
-                    , (code ? "/*v*/ " : "v=")
-                    , (code ? "(GLfloat [])" : "") +  formatFloats(1 * msg.getArg1(), msg.getData().asReadOnlyByteBuffer()));
-                break;
-            case glUniform1i:
-                str = String.format("%s(%s%s, %s%s)",
-                    (code ? "glUniform1i" : "void")
-                    , (code ? "/*location*/ " : "location=")
-                    , msg.getArg0()
-                    , (code ? "/*x*/ " : "x=")
-                    , msg.getArg1());
-                break;
-            case glUniform1iv:
-                str = String.format("%s(%s%s, %s%s, %s%s)",
-                    (code ? "glUniform1iv" : "void")
-                    , (code ? "/*location*/ " : "location=")
-                    , msg.getArg0()
-                    , (code ? "/*count*/ " : "count=")
-                    , msg.getArg1()
-                    , (code ? "/*v*/ " : "v=")
-                    , (code ? "(GLint [])" : "") +  formatInts(1 * msg.getArg1(), msg.getData().asReadOnlyByteBuffer()));
-                break;
-            case glUniform2f:
-                str = String.format("%s(%s%s, %s%s, %s%s)",
-                    (code ? "glUniform2f" : "void")
-                    , (code ? "/*location*/ " : "location=")
-                    , msg.getArg0()
-                    , (code ? "/*x*/ " : "x=")
-                    , Float.intBitsToFloat(msg.getArg1())
-                    , (code ? "/*y*/ " : "y=")
-                    , Float.intBitsToFloat(msg.getArg2()));
-                break;
-            case glUniform2fv:
-                str = String.format("%s(%s%s, %s%s, %s%s)",
-                    (code ? "glUniform2fv" : "void")
-                    , (code ? "/*location*/ " : "location=")
-                    , msg.getArg0()
-                    , (code ? "/*count*/ " : "count=")
-                    , msg.getArg1()
-                    , (code ? "/*v*/ " : "v=")
-                    , (code ? "(GLfloat [])" : "") +  formatFloats(2 * msg.getArg1(), msg.getData().asReadOnlyByteBuffer()));
-                break;
-            case glUniform2i:
-                str = String.format("%s(%s%s, %s%s, %s%s)",
-                    (code ? "glUniform2i" : "void")
-                    , (code ? "/*location*/ " : "location=")
-                    , msg.getArg0()
-                    , (code ? "/*x*/ " : "x=")
-                    , msg.getArg1()
-                    , (code ? "/*y*/ " : "y=")
-                    , msg.getArg2());
-                break;
-            case glUniform2iv:
-                str = String.format("%s(%s%s, %s%s, %s%s)",
-                    (code ? "glUniform2iv" : "void")
-                    , (code ? "/*location*/ " : "location=")
-                    , msg.getArg0()
-                    , (code ? "/*count*/ " : "count=")
-                    , msg.getArg1()
-                    , (code ? "/*v*/ " : "v=")
-                    , (code ? "(GLint [])" : "") +  formatInts(2 * msg.getArg1(), msg.getData().asReadOnlyByteBuffer()));
-                break;
-            case glUniform3f:
-                str = String.format("%s(%s%s, %s%s, %s%s, %s%s)",
-                    (code ? "glUniform3f" : "void")
-                    , (code ? "/*location*/ " : "location=")
-                    , msg.getArg0()
-                    , (code ? "/*x*/ " : "x=")
-                    , Float.intBitsToFloat(msg.getArg1())
-                    , (code ? "/*y*/ " : "y=")
-                    , Float.intBitsToFloat(msg.getArg2())
-                    , (code ? "/*z*/ " : "z=")
-                    , Float.intBitsToFloat(msg.getArg3()));
-                break;
-            case glUniform3fv:
-                str = String.format("%s(%s%s, %s%s, %s%s)",
-                    (code ? "glUniform3fv" : "void")
-                    , (code ? "/*location*/ " : "location=")
-                    , msg.getArg0()
-                    , (code ? "/*count*/ " : "count=")
-                    , msg.getArg1()
-                    , (code ? "/*v*/ " : "v=")
-                    , (code ? "(GLfloat [])" : "") +  formatFloats(3 * msg.getArg1(), msg.getData().asReadOnlyByteBuffer()));
-                break;
-            case glUniform3i:
-                str = String.format("%s(%s%s, %s%s, %s%s, %s%s)",
-                    (code ? "glUniform3i" : "void")
-                    , (code ? "/*location*/ " : "location=")
-                    , msg.getArg0()
-                    , (code ? "/*x*/ " : "x=")
-                    , msg.getArg1()
-                    , (code ? "/*y*/ " : "y=")
-                    , msg.getArg2()
-                    , (code ? "/*z*/ " : "z=")
-                    , msg.getArg3());
-                break;
-            case glUniform3iv:
-                str = String.format("%s(%s%s, %s%s, %s%s)",
-                    (code ? "glUniform3iv" : "void")
-                    , (code ? "/*location*/ " : "location=")
-                    , msg.getArg0()
-                    , (code ? "/*count*/ " : "count=")
-                    , msg.getArg1()
-                    , (code ? "/*v*/ " : "v=")
-                    , (code ? "(GLint [])" : "") +  formatInts(3 * msg.getArg1(), msg.getData().asReadOnlyByteBuffer()));
-                break;
-            case glUniform4f:
-                str = String.format("%s(%s%s, %s%s, %s%s, %s%s, %s%s)",
-                    (code ? "glUniform4f" : "void")
-                    , (code ? "/*location*/ " : "location=")
-                    , msg.getArg0()
-                    , (code ? "/*x*/ " : "x=")
-                    , Float.intBitsToFloat(msg.getArg1())
-                    , (code ? "/*y*/ " : "y=")
-                    , Float.intBitsToFloat(msg.getArg2())
-                    , (code ? "/*z*/ " : "z=")
-                    , Float.intBitsToFloat(msg.getArg3())
-                    , (code ? "/*w*/ " : "w=")
-                    , Float.intBitsToFloat(msg.getArg4()));
-                break;
-            case glUniform4fv:
-                str = String.format("%s(%s%s, %s%s, %s%s)",
-                    (code ? "glUniform4fv" : "void")
-                    , (code ? "/*location*/ " : "location=")
-                    , msg.getArg0()
-                    , (code ? "/*count*/ " : "count=")
-                    , msg.getArg1()
-                    , (code ? "/*v*/ " : "v=")
-                    , (code ? "(GLfloat [])" : "") +  formatFloats(4 * msg.getArg1(), msg.getData().asReadOnlyByteBuffer()));
-                break;
-            case glUniform4i:
-                str = String.format("%s(%s%s, %s%s, %s%s, %s%s, %s%s)",
-                    (code ? "glUniform4i" : "void")
-                    , (code ? "/*location*/ " : "location=")
-                    , msg.getArg0()
-                    , (code ? "/*x*/ " : "x=")
-                    , msg.getArg1()
-                    , (code ? "/*y*/ " : "y=")
-                    , msg.getArg2()
-                    , (code ? "/*z*/ " : "z=")
-                    , msg.getArg3()
-                    , (code ? "/*w*/ " : "w=")
-                    , msg.getArg4());
-                break;
-            case glUniform4iv:
-                str = String.format("%s(%s%s, %s%s, %s%s)",
-                    (code ? "glUniform4iv" : "void")
-                    , (code ? "/*location*/ " : "location=")
-                    , msg.getArg0()
-                    , (code ? "/*count*/ " : "count=")
-                    , msg.getArg1()
-                    , (code ? "/*v*/ " : "v=")
-                    , (code ? "(GLint [])" : "") +  formatInts(4 * msg.getArg1(), msg.getData().asReadOnlyByteBuffer()));
-                break;
-            case glUniformMatrix2fv:
-                str = String.format("%s(%s%s, %s%s, %s%s, %s%s)",
-                    (code ? "glUniformMatrix2fv" : "void")
-                    , (code ? "/*location*/ " : "location=")
-                    , msg.getArg0()
-                    , (code ? "/*count*/ " : "count=")
-                    , msg.getArg1()
-                    , (code ? "/*transpose*/ " : "transpose=")
-                    , msg.getArg2()
-                    , (code ? "/*value*/ " : "value=")
-                    , (code ? "(GLfloat [])" : "") + formatMatrix(2, 4 * msg.getArg1(), msg.getData().asReadOnlyByteBuffer()));
-                break;
-            case glUniformMatrix3fv:
-                str = String.format("%s(%s%s, %s%s, %s%s, %s%s)",
-                    (code ? "glUniformMatrix3fv" : "void")
-                    , (code ? "/*location*/ " : "location=")
-                    , msg.getArg0()
-                    , (code ? "/*count*/ " : "count=")
-                    , msg.getArg1()
-                    , (code ? "/*transpose*/ " : "transpose=")
-                    , msg.getArg2()
-                    , (code ? "/*value*/ " : "value=")
-                    , (code ? "(GLfloat [])" : "") + formatMatrix(3, 9 * msg.getArg1(), msg.getData().asReadOnlyByteBuffer()));
-                break;
-            case glUniformMatrix4fv:
-                str = String.format("%s(%s%s, %s%s, %s%s, %s%s)",
-                    (code ? "glUniformMatrix4fv" : "void")
-                    , (code ? "/*location*/ " : "location=")
-                    , msg.getArg0()
-                    , (code ? "/*count*/ " : "count=")
-                    , msg.getArg1()
-                    , (code ? "/*transpose*/ " : "transpose=")
-                    , msg.getArg2()
-                    , (code ? "/*value*/ " : "value=")
-                    , (code ? "(GLfloat [])" : "") + formatMatrix(4, 16 * msg.getArg1(), msg.getData().asReadOnlyByteBuffer()));
-                break;
-            case glUseProgram:
-                str = String.format("%s(%s%s)",
-                    (code ? "glUseProgram" : "void")
-                    , (code ? "/*program*/ " : "program=")
-                    , (code ? "program_" : "") + msg.getArg0());
-                break;
-            case glValidateProgram:
-                str = String.format("%s(%s%s)",
-                    (code ? "glValidateProgram" : "void")
-                    , (code ? "/*program*/ " : "program=")
-                    , (code ? "program_" : "") + msg.getArg0());
-                break;
-            case glVertexAttrib1f:
-                str = String.format("%s(%s%s, %s%s)",
-                    (code ? "glVertexAttrib1f" : "void")
-                    , (code ? "/*indx*/ " : "indx=")
-                    , msg.getArg0()
-                    , (code ? "/*x*/ " : "x=")
-                    , Float.intBitsToFloat(msg.getArg1()));
-                break;
-            case glVertexAttrib1fv:
-                str = String.format("%s(%s%s, %s%s)",
-                    (code ? "glVertexAttrib1fv" : "void")
-                    , (code ? "/*indx*/ " : "indx=")
-                    , msg.getArg0()
-                    , (code ? "/*values*/ " : "values=")
-                    , (code ? "(GLfloat [])" : "") + formatFloats(1, msg.getData().asReadOnlyByteBuffer()));
-                break;
-            case glVertexAttrib2f:
-                str = String.format("%s(%s%s, %s%s, %s%s)",
-                    (code ? "glVertexAttrib2f" : "void")
-                    , (code ? "/*indx*/ " : "indx=")
-                    , msg.getArg0()
-                    , (code ? "/*x*/ " : "x=")
-                    , Float.intBitsToFloat(msg.getArg1())
-                    , (code ? "/*y*/ " : "y=")
-                    , Float.intBitsToFloat(msg.getArg2()));
-                break;
-            case glVertexAttrib2fv:
-                str = String.format("%s(%s%s, %s%s)",
-                    (code ? "glVertexAttrib2fv" : "void")
-                    , (code ? "/*indx*/ " : "indx=")
-                    , msg.getArg0()
-                    , (code ? "/*values*/ " : "values=")
-                    , (code ? "(GLfloat [])" : "") + formatFloats(2, msg.getData().asReadOnlyByteBuffer()));
-                break;
-            case glVertexAttrib3f:
-                str = String.format("%s(%s%s, %s%s, %s%s, %s%s)",
-                    (code ? "glVertexAttrib3f" : "void")
-                    , (code ? "/*indx*/ " : "indx=")
-                    , msg.getArg0()
-                    , (code ? "/*x*/ " : "x=")
-                    , Float.intBitsToFloat(msg.getArg1())
-                    , (code ? "/*y*/ " : "y=")
-                    , Float.intBitsToFloat(msg.getArg2())
-                    , (code ? "/*z*/ " : "z=")
-                    , Float.intBitsToFloat(msg.getArg3()));
-                break;
-            case glVertexAttrib3fv:
-                str = String.format("%s(%s%s, %s%s)",
-                    (code ? "glVertexAttrib3fv" : "void")
-                    , (code ? "/*indx*/ " : "indx=")
-                    , msg.getArg0()
-                    , (code ? "/*values*/ " : "values=")
-                    , (code ? "(GLfloat [])" : "") + formatFloats(3, msg.getData().asReadOnlyByteBuffer()));
-                break;
-            case glVertexAttrib4f:
-                str = String.format("%s(%s%s, %s%s, %s%s, %s%s, %s%s)",
-                    (code ? "glVertexAttrib4f" : "void")
-                    , (code ? "/*indx*/ " : "indx=")
-                    , msg.getArg0()
-                    , (code ? "/*x*/ " : "x=")
-                    , Float.intBitsToFloat(msg.getArg1())
-                    , (code ? "/*y*/ " : "y=")
-                    , Float.intBitsToFloat(msg.getArg2())
-                    , (code ? "/*z*/ " : "z=")
-                    , Float.intBitsToFloat(msg.getArg3())
-                    , (code ? "/*w*/ " : "w=")
-                    , Float.intBitsToFloat(msg.getArg4()));
-                break;
-            case glVertexAttrib4fv:
-                str = String.format("%s(%s%s, %s%s)",
-                    (code ? "glVertexAttrib4fv" : "void")
-                    , (code ? "/*indx*/ " : "indx=")
-                    , msg.getArg0()
-                    , (code ? "/*values*/ " : "values=")
-                    , (code ? "(GLfloat [])" : "") + formatFloats(4, msg.getData().asReadOnlyByteBuffer()));
-                break;
-            case glVertexAttribPointer:
-                // FIXME: this function uses pointers, debugger may send data in msg.data
-                str = String.format("%s(%s%s, %s%s, %s%s, %s%s, %s%s, %s%s)",
-                    (code ? "glVertexAttribPointer" : "void")
-                    , (code ? "/*indx*/ " : "indx=")
-                    , msg.getArg0()
-                    , (code ? "/*size*/ " : "size=")
-                    , msg.getArg1()
-                    , (code ? "/*type*/ " : "type=")
-                    , GLEnum.valueOf(msg.getArg2())
-                    , (code ? "/*normalized*/ " : "normalized=")
-                    , msg.getArg3()
-                    , (code ? "/*stride*/ " : "stride=")
-                    , msg.getArg4()
-                    , (code ? "/*ptr*/ " : "ptr=")
-                    , (code ? "arg5" : "0x" + Integer.toHexString(msg.getArg5())));
-                break;
-            case glViewport:
-                str = String.format("%s(%s%s, %s%s, %s%s, %s%s)",
-                    (code ? "glViewport" : "void")
-                    , (code ? "/*x*/ " : "x=")
-                    , msg.getArg0()
-                    , (code ? "/*y*/ " : "y=")
-                    , msg.getArg1()
-                    , (code ? "/*width*/ " : "width=")
-                    , msg.getArg2()
-                    , (code ? "/*height*/ " : "height=")
-                    , msg.getArg3());
-                break;
-            default:
-                str = msg.toString();
-        }
-        return str;
-    }
-}
\ No newline at end of file
diff --git a/tools/glesv2debugger/src/com/android/glesv2debugger/MessageParser.java b/tools/glesv2debugger/src/com/android/glesv2debugger/MessageParser.java
deleted file mode 100644
index 8536728..0000000
--- a/tools/glesv2debugger/src/com/android/glesv2debugger/MessageParser.java
+++ /dev/null
@@ -1,747 +0,0 @@
-/*
- ** Copyright 2011, The Android Open Source Project
- **
- ** Licensed under the Apache License, Version 2.0 (the "License");
- ** you may not use this file except in compliance with the License.
- ** You may obtain a copy of the License at
- **
- **     http://www.apache.org/licenses/LICENSE-2.0
- **
- ** Unless required by applicable law or agreed to in writing, software
- ** distributed under the License is distributed on an "AS IS" BASIS,
- ** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- ** See the License for the specific language governing permissions and
- ** limitations under the License.
- */
-
-// auto generated by generate_MessageParser_java.py,
-//  which also prints skeleton code for MessageParserEx.java
-
-package com.android.glesv2debugger;
-
-import com.android.glesv2debugger.DebuggerMessage.Message;
-import com.android.glesv2debugger.DebuggerMessage.Message.Function;
-import com.google.protobuf.ByteString;
-
-import java.nio.ByteBuffer;
-
-public abstract class MessageParser {
-
-    String args;
-
-    String[] getList()
-    {
-        String arg = args;
-        args = args.substring(args.lastIndexOf('}') + 1);
-        final int comma = args.indexOf(',');
-        if (comma >= 0)
-            args = args.substring(comma + 1).trim();
-        else
-            args = null;
-
-        final int comment = arg.indexOf('=');
-        if (comment >= 0)
-            arg = arg.substring(comment + 1);
-        arg = arg.trim();
-        assert arg.charAt(0) == '{';
-        arg = arg.substring(1, arg.lastIndexOf('}')).trim();
-        return arg.split("\\s*,\\s*");
-    }
-
-    ByteString parseFloats(int count) {
-        ByteBuffer buffer = ByteBuffer.allocate(count * 4);
-        buffer.order(SampleView.targetByteOrder);
-        String [] arg = getList();
-        for (int i = 0; i < count; i++)
-            buffer.putFloat(Float.parseFloat(arg[i].trim()));
-        buffer.rewind();
-        return ByteString.copyFrom(buffer);
-    }
-
-    ByteString parseInts(int count) {
-        ByteBuffer buffer = ByteBuffer.allocate(count * 4);
-        buffer.order(SampleView.targetByteOrder);
-        String [] arg = getList();
-        for (int i = 0; i < count; i++)
-            buffer.putInt(Integer.parseInt(arg[i].trim()));
-        buffer.rewind();
-        return ByteString.copyFrom(buffer);
-    }
-
-    ByteString parseUInts(int count) {
-        ByteBuffer buffer = ByteBuffer.allocate(count * 4);
-        buffer.order(SampleView.targetByteOrder);
-        String [] arg = getList();
-        for (int i = 0; i < count; i++)
-            buffer.putInt((int)(Long.parseLong(arg[i].trim()) & 0xffffffff));
-        buffer.rewind();
-        return ByteString.copyFrom(buffer);
-    }
-
-    ByteString parseMatrix(int columns, int count) {
-        return parseFloats(columns * columns * count);
-    }
-
-    ByteString parseString() {
-        // TODO: escape sequence and proper string literal
-        String arg = args.substring(args.indexOf('"') + 1, args.lastIndexOf('"'));
-        args = args.substring(args.lastIndexOf('"'));
-        int comma = args.indexOf(',');
-        if (comma >= 0)
-            args = args.substring(comma + 1).trim();
-        else
-            args = null;
-        return ByteString.copyFromUtf8(arg);
-    }
-
-    String getArgument()
-    {
-        final int comma = args.indexOf(',');
-        String arg = null;
-        if (comma >= 0)
-        {
-            arg = args.substring(0, comma);
-            args = args.substring(comma + 1);
-        }
-        else
-        {
-            arg = args;
-            args = null;
-        }
-        final int comment = arg.indexOf('=');
-        if (comment >= 0)
-            arg = arg.substring(comment + 1);
-        return arg.trim();
-    }
-
-    int parseArgument()
-    {
-        String arg = getArgument();
-        if (arg.startsWith("GL_"))
-            return GLEnum.valueOf(arg).value;
-        else if (arg.toLowerCase().startsWith("0x"))
-            return Integer.parseInt(arg.substring(2), 16);
-        else
-            return Integer.parseInt(arg);
-    }
-
-    int parseFloat()
-    {
-        String arg = getArgument();
-        return Float.floatToRawIntBits(Float.parseFloat(arg));
-    }
-
-    public void parse(final Message.Builder builder, String string) {
-        int lparen = string.indexOf("("), rparen = string.lastIndexOf(")");
-        String s = string.substring(0, lparen).trim();
-        args = string.substring(lparen + 1, rparen);
-        String[] t = s.split(" ");
-        Function function = Function.valueOf(t[t.length - 1]);
-        builder.setFunction(function);
-        switch (function) {
-            case glActiveTexture:
-                builder.setArg0(parseArgument()); // GLenum texture
-                break;
-            case glAttachShader:
-                builder.setArg0(parseArgument()); // GLuint program
-                builder.setArg1(parseArgument()); // GLuint shader
-                break;
-            case glBindAttribLocation:
-                builder.setArg0(parseArgument()); // GLuint program
-                builder.setArg1(parseArgument()); // GLuint index
-                builder.setData(parseString()); // GLchar name
-                break;
-            case glBindBuffer:
-                builder.setArg0(parseArgument()); // GLenum target
-                builder.setArg1(parseArgument()); // GLuint buffer
-                break;
-            case glBindFramebuffer:
-                builder.setArg0(parseArgument()); // GLenum target
-                builder.setArg1(parseArgument()); // GLuint framebuffer
-                break;
-            case glBindRenderbuffer:
-                builder.setArg0(parseArgument()); // GLenum target
-                builder.setArg1(parseArgument()); // GLuint renderbuffer
-                break;
-            case glBindTexture:
-                builder.setArg0(parseArgument()); // GLenum target
-                builder.setArg1(parseArgument()); // GLuint texture
-                break;
-            case glBlendColor:
-                builder.setArg0(parseFloat()); // GLclampf red
-                builder.setArg1(parseFloat()); // GLclampf green
-                builder.setArg2(parseFloat()); // GLclampf blue
-                builder.setArg3(parseFloat()); // GLclampf alpha
-                break;
-            case glBlendEquation:
-                builder.setArg0(parseArgument()); // GLenum mode
-                break;
-            case glBlendEquationSeparate:
-                builder.setArg0(parseArgument()); // GLenum modeRGB
-                builder.setArg1(parseArgument()); // GLenum modeAlpha
-                break;
-            case glBlendFunc:
-                builder.setArg0(parseArgument()); // GLenum sfactor
-                builder.setArg1(parseArgument()); // GLenum dfactor
-                break;
-            case glBlendFuncSeparate:
-                builder.setArg0(parseArgument()); // GLenum srcRGB
-                builder.setArg1(parseArgument()); // GLenum dstRGB
-                builder.setArg2(parseArgument()); // GLenum srcAlpha
-                builder.setArg3(parseArgument()); // GLenum dstAlpha
-                break;
-            case glBufferData:
-                parse_glBufferData(builder);
-                break;
-            case glBufferSubData:
-                parse_glBufferSubData(builder);
-                break;
-            case glCheckFramebufferStatus:
-                builder.setArg0(parseArgument()); // GLenum target
-                break;
-            case glClear:
-                builder.setArg0(parseArgument()); // GLbitfield mask
-                break;
-            case glClearColor:
-                builder.setArg0(parseFloat()); // GLclampf red
-                builder.setArg1(parseFloat()); // GLclampf green
-                builder.setArg2(parseFloat()); // GLclampf blue
-                builder.setArg3(parseFloat()); // GLclampf alpha
-                break;
-            case glClearDepthf:
-                builder.setArg0(parseFloat()); // GLclampf depth
-                break;
-            case glClearStencil:
-                builder.setArg0(parseArgument()); // GLint s
-                break;
-            case glColorMask:
-                builder.setArg0(parseArgument()); // GLboolean red
-                builder.setArg1(parseArgument()); // GLboolean green
-                builder.setArg2(parseArgument()); // GLboolean blue
-                builder.setArg3(parseArgument()); // GLboolean alpha
-                break;
-            case glCompileShader:
-                builder.setArg0(parseArgument()); // GLuint shader
-                break;
-            case glCompressedTexImage2D:
-                parse_glCompressedTexImage2D(builder);
-                break;
-            case glCompressedTexSubImage2D:
-                parse_glCompressedTexSubImage2D(builder);
-                break;
-            case glCopyTexImage2D:
-                builder.setArg0(parseArgument()); // GLenum target
-                builder.setArg1(parseArgument()); // GLint level
-                builder.setArg2(parseArgument()); // GLenum internalformat
-                builder.setArg3(parseArgument()); // GLint x
-                builder.setArg4(parseArgument()); // GLint y
-                builder.setArg5(parseArgument()); // GLsizei width
-                builder.setArg6(parseArgument()); // GLsizei height
-                builder.setArg7(parseArgument()); // GLint border
-                break;
-            case glCopyTexSubImage2D:
-                builder.setArg0(parseArgument()); // GLenum target
-                builder.setArg1(parseArgument()); // GLint level
-                builder.setArg2(parseArgument()); // GLint xoffset
-                builder.setArg3(parseArgument()); // GLint yoffset
-                builder.setArg4(parseArgument()); // GLint x
-                builder.setArg5(parseArgument()); // GLint y
-                builder.setArg6(parseArgument()); // GLsizei width
-                builder.setArg7(parseArgument()); // GLsizei height
-                break;
-            case glCreateProgram:
-                break;
-            case glCreateShader:
-                builder.setArg0(parseArgument()); // GLenum type
-                break;
-            case glCullFace:
-                builder.setArg0(parseArgument()); // GLenum mode
-                break;
-            case glDeleteBuffers:
-                builder.setArg0(parseArgument()); // GLsizei n
-                builder.setData(parseUInts(1 * builder.getArg0())); // GLuint buffers
-                break;
-            case glDeleteFramebuffers:
-                builder.setArg0(parseArgument()); // GLsizei n
-                builder.setData(parseUInts(1 * builder.getArg0())); // GLuint framebuffers
-                break;
-            case glDeleteProgram:
-                builder.setArg0(parseArgument()); // GLuint program
-                break;
-            case glDeleteRenderbuffers:
-                builder.setArg0(parseArgument()); // GLsizei n
-                builder.setData(parseUInts(1 * builder.getArg0())); // GLuint renderbuffers
-                break;
-            case glDeleteShader:
-                builder.setArg0(parseArgument()); // GLuint shader
-                break;
-            case glDeleteTextures:
-                builder.setArg0(parseArgument()); // GLsizei n
-                builder.setData(parseUInts(1 * builder.getArg0())); // GLuint textures
-                break;
-            case glDepthFunc:
-                builder.setArg0(parseArgument()); // GLenum func
-                break;
-            case glDepthMask:
-                builder.setArg0(parseArgument()); // GLboolean flag
-                break;
-            case glDepthRangef:
-                builder.setArg0(parseFloat()); // GLclampf zNear
-                builder.setArg1(parseFloat()); // GLclampf zFar
-                break;
-            case glDetachShader:
-                builder.setArg0(parseArgument()); // GLuint program
-                builder.setArg1(parseArgument()); // GLuint shader
-                break;
-            case glDisable:
-                builder.setArg0(parseArgument()); // GLenum cap
-                break;
-            case glDisableVertexAttribArray:
-                builder.setArg0(parseArgument()); // GLuint index
-                break;
-            case glDrawArrays:
-                builder.setArg0(parseArgument()); // GLenum mode
-                builder.setArg1(parseArgument()); // GLint first
-                builder.setArg2(parseArgument()); // GLsizei count
-                break;
-            case glDrawElements:
-                parse_glDrawElements(builder);
-                break;
-            case glEnable:
-                builder.setArg0(parseArgument()); // GLenum cap
-                break;
-            case glEnableVertexAttribArray:
-                builder.setArg0(parseArgument()); // GLuint index
-                break;
-            case glFinish:
-                break;
-            case glFlush:
-                break;
-            case glFramebufferRenderbuffer:
-                builder.setArg0(parseArgument()); // GLenum target
-                builder.setArg1(parseArgument()); // GLenum attachment
-                builder.setArg2(parseArgument()); // GLenum renderbuffertarget
-                builder.setArg3(parseArgument()); // GLuint renderbuffer
-                break;
-            case glFramebufferTexture2D:
-                builder.setArg0(parseArgument()); // GLenum target
-                builder.setArg1(parseArgument()); // GLenum attachment
-                builder.setArg2(parseArgument()); // GLenum textarget
-                builder.setArg3(parseArgument()); // GLuint texture
-                builder.setArg4(parseArgument()); // GLint level
-                break;
-            case glFrontFace:
-                builder.setArg0(parseArgument()); // GLenum mode
-                break;
-            case glGenBuffers:
-                builder.setArg0(parseArgument()); // GLsizei n
-                builder.setData(parseUInts(1 * builder.getArg0())); // GLuint buffers
-                break;
-            case glGenerateMipmap:
-                builder.setArg0(parseArgument()); // GLenum target
-                break;
-            case glGenFramebuffers:
-                builder.setArg0(parseArgument()); // GLsizei n
-                builder.setData(parseUInts(1 * builder.getArg0())); // GLuint framebuffers
-                break;
-            case glGenRenderbuffers:
-                builder.setArg0(parseArgument()); // GLsizei n
-                builder.setData(parseUInts(1 * builder.getArg0())); // GLuint renderbuffers
-                break;
-            case glGenTextures:
-                builder.setArg0(parseArgument()); // GLsizei n
-                builder.setData(parseUInts(1 * builder.getArg0())); // GLuint textures
-                break;
-            case glGetActiveAttrib:
-                parse_glGetActiveAttrib(builder);
-                break;
-            case glGetActiveUniform:
-                parse_glGetActiveUniform(builder);
-                break;
-            case glGetAttachedShaders:
-                parse_glGetAttachedShaders(builder);
-                break;
-            case glGetAttribLocation:
-                builder.setArg0(parseArgument()); // GLuint program
-                builder.setData(parseString()); // GLchar name
-                break;
-            case glGetBooleanv:
-                parse_glGetBooleanv(builder);
-                break;
-            case glGetBufferParameteriv:
-                parse_glGetBufferParameteriv(builder);
-                break;
-            case glGetError:
-                break;
-            case glGetFloatv:
-                parse_glGetFloatv(builder);
-                break;
-            case glGetFramebufferAttachmentParameteriv:
-                parse_glGetFramebufferAttachmentParameteriv(builder);
-                break;
-            case glGetIntegerv:
-                parse_glGetIntegerv(builder);
-                break;
-            case glGetProgramiv:
-                builder.setArg0(parseArgument()); // GLuint program
-                builder.setArg1(parseArgument()); // GLenum pname
-                builder.setData(parseInts(1)); // GLint params
-                break;
-            case glGetProgramInfoLog:
-                parse_glGetProgramInfoLog(builder);
-                break;
-            case glGetRenderbufferParameteriv:
-                parse_glGetRenderbufferParameteriv(builder);
-                break;
-            case glGetShaderiv:
-                builder.setArg0(parseArgument()); // GLuint shader
-                builder.setArg1(parseArgument()); // GLenum pname
-                builder.setData(parseInts(1)); // GLint params
-                break;
-            case glGetShaderInfoLog:
-                parse_glGetShaderInfoLog(builder);
-                break;
-            case glGetShaderPrecisionFormat:
-                parse_glGetShaderPrecisionFormat(builder);
-                break;
-            case glGetShaderSource:
-                parse_glGetShaderSource(builder);
-                break;
-            case glGetString:
-                builder.setArg0(parseArgument()); // GLenum name
-                break;
-            case glGetTexParameterfv:
-                parse_glGetTexParameterfv(builder);
-                break;
-            case glGetTexParameteriv:
-                parse_glGetTexParameteriv(builder);
-                break;
-            case glGetUniformfv:
-                parse_glGetUniformfv(builder);
-                break;
-            case glGetUniformiv:
-                parse_glGetUniformiv(builder);
-                break;
-            case glGetUniformLocation:
-                builder.setArg0(parseArgument()); // GLuint program
-                builder.setData(parseString()); // GLchar name
-                break;
-            case glGetVertexAttribfv:
-                parse_glGetVertexAttribfv(builder);
-                break;
-            case glGetVertexAttribiv:
-                parse_glGetVertexAttribiv(builder);
-                break;
-            case glGetVertexAttribPointerv:
-                parse_glGetVertexAttribPointerv(builder);
-                break;
-            case glHint:
-                builder.setArg0(parseArgument()); // GLenum target
-                builder.setArg1(parseArgument()); // GLenum mode
-                break;
-            case glIsBuffer:
-                builder.setArg0(parseArgument()); // GLuint buffer
-                break;
-            case glIsEnabled:
-                builder.setArg0(parseArgument()); // GLenum cap
-                break;
-            case glIsFramebuffer:
-                builder.setArg0(parseArgument()); // GLuint framebuffer
-                break;
-            case glIsProgram:
-                builder.setArg0(parseArgument()); // GLuint program
-                break;
-            case glIsRenderbuffer:
-                builder.setArg0(parseArgument()); // GLuint renderbuffer
-                break;
-            case glIsShader:
-                builder.setArg0(parseArgument()); // GLuint shader
-                break;
-            case glIsTexture:
-                builder.setArg0(parseArgument()); // GLuint texture
-                break;
-            case glLineWidth:
-                builder.setArg0(parseFloat()); // GLfloat width
-                break;
-            case glLinkProgram:
-                builder.setArg0(parseArgument()); // GLuint program
-                break;
-            case glPixelStorei:
-                builder.setArg0(parseArgument()); // GLenum pname
-                builder.setArg1(parseArgument()); // GLint param
-                break;
-            case glPolygonOffset:
-                builder.setArg0(parseFloat()); // GLfloat factor
-                builder.setArg1(parseFloat()); // GLfloat units
-                break;
-            case glReadPixels:
-                parse_glReadPixels(builder);
-                break;
-            case glReleaseShaderCompiler:
-                break;
-            case glRenderbufferStorage:
-                builder.setArg0(parseArgument()); // GLenum target
-                builder.setArg1(parseArgument()); // GLenum internalformat
-                builder.setArg2(parseArgument()); // GLsizei width
-                builder.setArg3(parseArgument()); // GLsizei height
-                break;
-            case glSampleCoverage:
-                builder.setArg0(parseFloat()); // GLclampf value
-                builder.setArg1(parseArgument()); // GLboolean invert
-                break;
-            case glScissor:
-                builder.setArg0(parseArgument()); // GLint x
-                builder.setArg1(parseArgument()); // GLint y
-                builder.setArg2(parseArgument()); // GLsizei width
-                builder.setArg3(parseArgument()); // GLsizei height
-                break;
-            case glShaderBinary:
-                parse_glShaderBinary(builder);
-                break;
-            case glShaderSource:
-                parse_glShaderSource(builder);
-                break;
-            case glStencilFunc:
-                builder.setArg0(parseArgument()); // GLenum func
-                builder.setArg1(parseArgument()); // GLint ref
-                builder.setArg2(parseArgument()); // GLuint mask
-                break;
-            case glStencilFuncSeparate:
-                builder.setArg0(parseArgument()); // GLenum face
-                builder.setArg1(parseArgument()); // GLenum func
-                builder.setArg2(parseArgument()); // GLint ref
-                builder.setArg3(parseArgument()); // GLuint mask
-                break;
-            case glStencilMask:
-                builder.setArg0(parseArgument()); // GLuint mask
-                break;
-            case glStencilMaskSeparate:
-                builder.setArg0(parseArgument()); // GLenum face
-                builder.setArg1(parseArgument()); // GLuint mask
-                break;
-            case glStencilOp:
-                builder.setArg0(parseArgument()); // GLenum fail
-                builder.setArg1(parseArgument()); // GLenum zfail
-                builder.setArg2(parseArgument()); // GLenum zpass
-                break;
-            case glStencilOpSeparate:
-                builder.setArg0(parseArgument()); // GLenum face
-                builder.setArg1(parseArgument()); // GLenum fail
-                builder.setArg2(parseArgument()); // GLenum zfail
-                builder.setArg3(parseArgument()); // GLenum zpass
-                break;
-            case glTexImage2D:
-                parse_glTexImage2D(builder);
-                break;
-            case glTexParameterf:
-                builder.setArg0(parseArgument()); // GLenum target
-                builder.setArg1(parseArgument()); // GLenum pname
-                builder.setArg2(parseFloat()); // GLfloat param
-                break;
-            case glTexParameterfv:
-                parse_glTexParameterfv(builder);
-                break;
-            case glTexParameteri:
-                builder.setArg0(parseArgument()); // GLenum target
-                builder.setArg1(parseArgument()); // GLenum pname
-                builder.setArg2(parseArgument()); // GLint param
-                break;
-            case glTexParameteriv:
-                parse_glTexParameteriv(builder);
-                break;
-            case glTexSubImage2D:
-                parse_glTexSubImage2D(builder);
-                break;
-            case glUniform1f:
-                builder.setArg0(parseArgument()); // GLint location
-                builder.setArg1(parseFloat()); // GLfloat x
-                break;
-            case glUniform1fv:
-                builder.setArg0(parseArgument()); // GLint location
-                builder.setArg1(parseArgument()); // GLsizei count
-                builder.setData(parseFloats(1 * builder.getArg1())); // GLfloat v
-                break;
-            case glUniform1i:
-                builder.setArg0(parseArgument()); // GLint location
-                builder.setArg1(parseArgument()); // GLint x
-                break;
-            case glUniform1iv:
-                builder.setArg0(parseArgument()); // GLint location
-                builder.setArg1(parseArgument()); // GLsizei count
-                builder.setData(parseInts(1 * builder.getArg1())); // GLint v
-                break;
-            case glUniform2f:
-                builder.setArg0(parseArgument()); // GLint location
-                builder.setArg1(parseFloat()); // GLfloat x
-                builder.setArg2(parseFloat()); // GLfloat y
-                break;
-            case glUniform2fv:
-                builder.setArg0(parseArgument()); // GLint location
-                builder.setArg1(parseArgument()); // GLsizei count
-                builder.setData(parseFloats(2 * builder.getArg1())); // GLfloat v
-                break;
-            case glUniform2i:
-                builder.setArg0(parseArgument()); // GLint location
-                builder.setArg1(parseArgument()); // GLint x
-                builder.setArg2(parseArgument()); // GLint y
-                break;
-            case glUniform2iv:
-                builder.setArg0(parseArgument()); // GLint location
-                builder.setArg1(parseArgument()); // GLsizei count
-                builder.setData(parseInts(2 * builder.getArg1())); // GLint v
-                break;
-            case glUniform3f:
-                builder.setArg0(parseArgument()); // GLint location
-                builder.setArg1(parseFloat()); // GLfloat x
-                builder.setArg2(parseFloat()); // GLfloat y
-                builder.setArg3(parseFloat()); // GLfloat z
-                break;
-            case glUniform3fv:
-                builder.setArg0(parseArgument()); // GLint location
-                builder.setArg1(parseArgument()); // GLsizei count
-                builder.setData(parseFloats(3 * builder.getArg1())); // GLfloat v
-                break;
-            case glUniform3i:
-                builder.setArg0(parseArgument()); // GLint location
-                builder.setArg1(parseArgument()); // GLint x
-                builder.setArg2(parseArgument()); // GLint y
-                builder.setArg3(parseArgument()); // GLint z
-                break;
-            case glUniform3iv:
-                builder.setArg0(parseArgument()); // GLint location
-                builder.setArg1(parseArgument()); // GLsizei count
-                builder.setData(parseInts(3 * builder.getArg1())); // GLint v
-                break;
-            case glUniform4f:
-                builder.setArg0(parseArgument()); // GLint location
-                builder.setArg1(parseFloat()); // GLfloat x
-                builder.setArg2(parseFloat()); // GLfloat y
-                builder.setArg3(parseFloat()); // GLfloat z
-                builder.setArg4(parseFloat()); // GLfloat w
-                break;
-            case glUniform4fv:
-                builder.setArg0(parseArgument()); // GLint location
-                builder.setArg1(parseArgument()); // GLsizei count
-                builder.setData(parseFloats(4 * builder.getArg1())); // GLfloat v
-                break;
-            case glUniform4i:
-                builder.setArg0(parseArgument()); // GLint location
-                builder.setArg1(parseArgument()); // GLint x
-                builder.setArg2(parseArgument()); // GLint y
-                builder.setArg3(parseArgument()); // GLint z
-                builder.setArg4(parseArgument()); // GLint w
-                break;
-            case glUniform4iv:
-                builder.setArg0(parseArgument()); // GLint location
-                builder.setArg1(parseArgument()); // GLsizei count
-                builder.setData(parseInts(4 * builder.getArg1())); // GLint v
-                break;
-            case glUniformMatrix2fv:
-                builder.setArg0(parseArgument()); // GLint location
-                builder.setArg1(parseArgument()); // GLsizei count
-                builder.setArg2(parseArgument()); // GLboolean transpose
-                builder.setData(parseMatrix(2, builder.getArg1())); // GLfloat value
-                break;
-            case glUniformMatrix3fv:
-                builder.setArg0(parseArgument()); // GLint location
-                builder.setArg1(parseArgument()); // GLsizei count
-                builder.setArg2(parseArgument()); // GLboolean transpose
-                builder.setData(parseMatrix(3, builder.getArg1())); // GLfloat value
-                break;
-            case glUniformMatrix4fv:
-                builder.setArg0(parseArgument()); // GLint location
-                builder.setArg1(parseArgument()); // GLsizei count
-                builder.setArg2(parseArgument()); // GLboolean transpose
-                builder.setData(parseMatrix(4, builder.getArg1())); // GLfloat value
-                break;
-            case glUseProgram:
-                builder.setArg0(parseArgument()); // GLuint program
-                break;
-            case glValidateProgram:
-                builder.setArg0(parseArgument()); // GLuint program
-                break;
-            case glVertexAttrib1f:
-                builder.setArg0(parseArgument()); // GLuint indx
-                builder.setArg1(parseFloat()); // GLfloat x
-                break;
-            case glVertexAttrib1fv:
-                builder.setArg0(parseArgument()); // GLuint indx
-                builder.setData(parseFloats(1)); // GLfloat values
-                break;
-            case glVertexAttrib2f:
-                builder.setArg0(parseArgument()); // GLuint indx
-                builder.setArg1(parseFloat()); // GLfloat x
-                builder.setArg2(parseFloat()); // GLfloat y
-                break;
-            case glVertexAttrib2fv:
-                builder.setArg0(parseArgument()); // GLuint indx
-                builder.setData(parseFloats(2)); // GLfloat values
-                break;
-            case glVertexAttrib3f:
-                builder.setArg0(parseArgument()); // GLuint indx
-                builder.setArg1(parseFloat()); // GLfloat x
-                builder.setArg2(parseFloat()); // GLfloat y
-                builder.setArg3(parseFloat()); // GLfloat z
-                break;
-            case glVertexAttrib3fv:
-                builder.setArg0(parseArgument()); // GLuint indx
-                builder.setData(parseFloats(3)); // GLfloat values
-                break;
-            case glVertexAttrib4f:
-                builder.setArg0(parseArgument()); // GLuint indx
-                builder.setArg1(parseFloat()); // GLfloat x
-                builder.setArg2(parseFloat()); // GLfloat y
-                builder.setArg3(parseFloat()); // GLfloat z
-                builder.setArg4(parseFloat()); // GLfloat w
-                break;
-            case glVertexAttrib4fv:
-                builder.setArg0(parseArgument()); // GLuint indx
-                builder.setData(parseFloats(4)); // GLfloat values
-                break;
-            case glVertexAttribPointer:
-                parse_glVertexAttribPointer(builder);
-                break;
-            case glViewport:
-                builder.setArg0(parseArgument()); // GLint x
-                builder.setArg1(parseArgument()); // GLint y
-                builder.setArg2(parseArgument()); // GLsizei width
-                builder.setArg3(parseArgument()); // GLsizei height
-                break;
-            default:
-                assert false;
-        }
-    }
-    abstract void parse_glBufferData(Message.Builder builder);
-    abstract void parse_glBufferSubData(Message.Builder builder);
-    abstract void parse_glCompressedTexImage2D(Message.Builder builder);
-    abstract void parse_glCompressedTexSubImage2D(Message.Builder builder);
-    abstract void parse_glDrawElements(Message.Builder builder);
-    abstract void parse_glGetActiveAttrib(Message.Builder builder);
-    abstract void parse_glGetActiveUniform(Message.Builder builder);
-    abstract void parse_glGetAttachedShaders(Message.Builder builder);
-    abstract void parse_glGetBooleanv(Message.Builder builder);
-    abstract void parse_glGetBufferParameteriv(Message.Builder builder);
-    abstract void parse_glGetFloatv(Message.Builder builder);
-    abstract void parse_glGetFramebufferAttachmentParameteriv(Message.Builder builder);
-    abstract void parse_glGetIntegerv(Message.Builder builder);
-    abstract void parse_glGetProgramInfoLog(Message.Builder builder);
-    abstract void parse_glGetRenderbufferParameteriv(Message.Builder builder);
-    abstract void parse_glGetShaderInfoLog(Message.Builder builder);
-    abstract void parse_glGetShaderPrecisionFormat(Message.Builder builder);
-    abstract void parse_glGetShaderSource(Message.Builder builder);
-    abstract void parse_glGetTexParameterfv(Message.Builder builder);
-    abstract void parse_glGetTexParameteriv(Message.Builder builder);
-    abstract void parse_glGetUniformfv(Message.Builder builder);
-    abstract void parse_glGetUniformiv(Message.Builder builder);
-    abstract void parse_glGetVertexAttribfv(Message.Builder builder);
-    abstract void parse_glGetVertexAttribiv(Message.Builder builder);
-    abstract void parse_glGetVertexAttribPointerv(Message.Builder builder);
-    abstract void parse_glReadPixels(Message.Builder builder);
-    abstract void parse_glShaderBinary(Message.Builder builder);
-    abstract void parse_glShaderSource(Message.Builder builder);
-    abstract void parse_glTexImage2D(Message.Builder builder);
-    abstract void parse_glTexParameterfv(Message.Builder builder);
-    abstract void parse_glTexParameteriv(Message.Builder builder);
-    abstract void parse_glTexSubImage2D(Message.Builder builder);
-    abstract void parse_glVertexAttribPointer(Message.Builder builder);
-}
\ No newline at end of file
diff --git a/tools/glesv2debugger/src/com/android/glesv2debugger/MessageParserEx.java b/tools/glesv2debugger/src/com/android/glesv2debugger/MessageParserEx.java
deleted file mode 100644
index 5099146..0000000
--- a/tools/glesv2debugger/src/com/android/glesv2debugger/MessageParserEx.java
+++ /dev/null
@@ -1,306 +0,0 @@
-/*
- ** Copyright 2011, The Android Open Source Project
- **
- ** Licensed under the Apache License, Version 2.0 (the "License");
- ** you may not use this file except in compliance with the License.
- ** You may obtain a copy of the License at
- **
- **     http://www.apache.org/licenses/LICENSE-2.0
- **
- ** Unless required by applicable law or agreed to in writing, software
- ** distributed under the License is distributed on an "AS IS" BASIS,
- ** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- ** See the License for the specific language governing permissions and
- ** limitations under the License.
- */
-
-// skeleton from stdout of generate_MessageParser_java.py
-
-package com.android.glesv2debugger;
-
-import com.android.glesv2debugger.DebuggerMessage.Message;
-
-public class MessageParserEx extends MessageParser {
-
-    @Override
-    void parse_glBufferData(Message.Builder builder) {
-        builder.setArg0(parseArgument()); // GLenum target
-        builder.setArg1(parseArgument()); // GLsizeiptr size
-        // TODO // GLvoid data
-        builder.setArg3(parseArgument()); // GLenum usage
-    }
-
-    @Override
-    void parse_glBufferSubData(Message.Builder builder) {
-        builder.setArg0(parseArgument()); // GLenum target
-        builder.setArg1(parseArgument()); // GLintptr offset
-        builder.setArg2(parseArgument()); // GLsizeiptr size
-        // TODO // GLvoid data
-    }
-
-    @Override
-    void parse_glCompressedTexImage2D(Message.Builder builder) {
-        builder.setArg0(parseArgument()); // GLenum target
-        builder.setArg1(parseArgument()); // GLint level
-        builder.setArg2(parseArgument()); // GLenum internalformat
-        builder.setArg3(parseArgument()); // GLsizei width
-        builder.setArg4(parseArgument()); // GLsizei height
-        builder.setArg5(parseArgument()); // GLint border
-        builder.setArg6(parseArgument()); // GLsizei imageSize
-        // TODO: GLvoid* data
-    }
-
-    @Override
-    void parse_glCompressedTexSubImage2D(Message.Builder builder) {
-        builder.setArg0(parseArgument()); // GLenum target
-        builder.setArg1(parseArgument()); // GLint level
-        builder.setArg2(parseArgument()); // GLint xoffset
-        builder.setArg3(parseArgument()); // GLint yoffset
-        builder.setArg4(parseArgument()); // GLsizei width
-        builder.setArg5(parseArgument()); // GLsizei height
-        builder.setArg6(parseArgument()); // GLenum format
-        builder.setArg7(parseArgument()); // GLsizei imageSize
-        // TODO: GLvoid* data
-    }
-
-    @Override
-    void parse_glDrawElements(Message.Builder builder) {
-        builder.setArg0(parseArgument()); // GLenum mode
-        builder.setArg1(parseArgument()); // GLsizei count
-        builder.setArg2(parseArgument()); // GLenum type
-        // TODO: GLvoid* indices
-    }
-
-    @Override
-    void parse_glGetActiveAttrib(Message.Builder builder) {
-        builder.setArg0(parseArgument()); // GLuint program
-        builder.setArg1(parseArgument()); // GLuint index
-        builder.setArg2(parseArgument()); // GLsizei bufsize
-        // TODO: GLsizei* length
-        // TODO: GLint* size
-        // TODO: GLenum* type
-        builder.setData(parseString()); // GLchar name
-    }
-
-    @Override
-    void parse_glGetActiveUniform(Message.Builder builder) {
-        builder.setArg0(parseArgument()); // GLuint program
-        builder.setArg1(parseArgument()); // GLuint index
-        builder.setArg2(parseArgument()); // GLsizei bufsize
-        // TODO: GLsizei* length
-        // TODO: GLint* size
-        // TODO: GLenum* type
-        builder.setData(parseString()); // GLchar name
-    }
-
-    @Override
-    void parse_glGetAttachedShaders(Message.Builder builder) {
-        builder.setArg0(parseArgument()); // GLuint program
-        builder.setArg1(parseArgument()); // GLsizei maxcount
-        // TODO: GLsizei* count
-        // TODO: GLuint* shaders
-    }
-
-    @Override
-    void parse_glGetBooleanv(Message.Builder builder) {
-        builder.setArg0(parseArgument()); // GLenum pname
-        // TODO: GLboolean* params
-    }
-
-    @Override
-    void parse_glGetBufferParameteriv(Message.Builder builder) {
-        builder.setArg0(parseArgument()); // GLenum target
-        builder.setArg1(parseArgument()); // GLenum pname
-        // TODO: GLint* params
-    }
-
-    @Override
-    void parse_glGetFloatv(Message.Builder builder) {
-        builder.setArg0(parseArgument()); // GLenum pname
-        // TODO: GLfloat* params
-    }
-
-    @Override
-    void parse_glGetFramebufferAttachmentParameteriv(Message.Builder builder) {
-        builder.setArg0(parseArgument()); // GLenum target
-        builder.setArg1(parseArgument()); // GLenum attachment
-        builder.setArg2(parseArgument()); // GLenum pname
-        // TODO: GLint* params
-    }
-
-    @Override
-    void parse_glGetIntegerv(Message.Builder builder) {
-        builder.setArg0(parseArgument()); // GLenum pname
-        // TODO: GLint* params
-    }
-
-    @Override
-    void parse_glGetProgramInfoLog(Message.Builder builder) {
-        builder.setArg0(parseArgument()); // GLuint program
-        builder.setArg1(parseArgument()); // GLsizei bufsize
-        // TODO: GLsizei* length
-        builder.setData(parseString()); // GLchar infolog
-    }
-
-    @Override
-    void parse_glGetRenderbufferParameteriv(Message.Builder builder) {
-        builder.setArg0(parseArgument()); // GLenum target
-        builder.setArg1(parseArgument()); // GLenum pname
-        // TODO: GLint* params
-    }
-
-    @Override
-    void parse_glGetShaderInfoLog(Message.Builder builder) {
-        builder.setArg0(parseArgument()); // GLuint shader
-        builder.setArg1(parseArgument()); // GLsizei bufsize
-        // TODO: GLsizei* length
-        builder.setData(parseString()); // GLchar infolog
-    }
-
-    @Override
-    void parse_glGetShaderPrecisionFormat(Message.Builder builder) {
-        builder.setArg0(parseArgument()); // GLenum shadertype
-        builder.setArg1(parseArgument()); // GLenum precisiontype
-        // TODO: GLint* range
-        // TODO: GLint* precision
-    }
-
-    @Override
-    void parse_glGetShaderSource(Message.Builder builder) {
-        builder.setArg0(parseArgument()); // GLuint shader
-        builder.setArg1(parseArgument()); // GLsizei bufsize
-        // TODO: GLsizei* length
-        builder.setData(parseString()); // GLchar source
-    }
-
-    @Override
-    void parse_glGetTexParameterfv(Message.Builder builder) {
-        builder.setArg0(parseArgument()); // GLenum target
-        builder.setArg1(parseArgument()); // GLenum pname
-        // TODO: GLfloat* params
-    }
-
-    @Override
-    void parse_glGetTexParameteriv(Message.Builder builder) {
-        builder.setArg0(parseArgument()); // GLenum target
-        builder.setArg1(parseArgument()); // GLenum pname
-        // TODO: GLint* params
-    }
-
-    @Override
-    void parse_glGetUniformfv(Message.Builder builder) {
-        builder.setArg0(parseArgument()); // GLuint program
-        builder.setArg1(parseArgument()); // GLint location
-        // TODO: GLfloat* params
-    }
-
-    @Override
-    void parse_glGetUniformiv(Message.Builder builder) {
-        builder.setArg0(parseArgument()); // GLuint program
-        builder.setArg1(parseArgument()); // GLint location
-        // TODO: GLint* params
-    }
-
-    @Override
-    void parse_glGetVertexAttribfv(Message.Builder builder) {
-        builder.setArg0(parseArgument()); // GLuint index
-        builder.setArg1(parseArgument()); // GLenum pname
-        // TODO: GLfloat* params
-    }
-
-    @Override
-    void parse_glGetVertexAttribiv(Message.Builder builder) {
-        builder.setArg0(parseArgument()); // GLuint index
-        builder.setArg1(parseArgument()); // GLenum pname
-        // TODO: GLint* params
-    }
-
-    @Override
-    void parse_glGetVertexAttribPointerv(Message.Builder builder) {
-        builder.setArg0(parseArgument()); // GLuint index
-        builder.setArg1(parseArgument()); // GLenum pname
-        // TODO: GLvoid** pointer
-    }
-
-    @Override
-    void parse_glReadPixels(Message.Builder builder) {
-        builder.setArg0(parseArgument()); // GLint x
-        builder.setArg1(parseArgument()); // GLint y
-        builder.setArg2(parseArgument()); // GLsizei width
-        builder.setArg3(parseArgument()); // GLsizei height
-        builder.setArg4(parseArgument()); // GLenum format
-        builder.setArg5(parseArgument()); // GLenum type
-        // TODO: GLvoid* pixels
-    }
-
-    @Override
-    void parse_glShaderBinary(Message.Builder builder) {
-        builder.setArg0(parseArgument()); // GLsizei n
-        // TODO: GLuint* shaders
-        builder.setArg2(parseArgument()); // GLenum binaryformat
-        // TODO: GLvoid* binary
-        builder.setArg4(parseArgument()); // GLsizei length
-    }
-
-    @Override
-    void parse_glShaderSource(Message.Builder builder) {
-        builder.setArg0(parseArgument()); // GLuint shader
-        builder.setArg1(parseArgument()); // GLsizei count
-        assert 1 == builder.getArg1();
-        builder.setData(parseString()); // GLchar** string
-        builder.setArg3(parseArgument());// not used, always 1 null terminated
-                                         // string; GLint* length
-    }
-
-    @Override
-    void parse_glTexImage2D(Message.Builder builder) {
-        builder.setArg0(parseArgument()); // GLenum target
-        builder.setArg1(parseArgument()); // GLint level
-        builder.setArg2(parseArgument()); // GLint internalformat
-        builder.setArg3(parseArgument()); // GLsizei width
-        builder.setArg4(parseArgument()); // GLsizei height
-        builder.setArg5(parseArgument()); // GLint border
-        builder.setArg6(parseArgument()); // GLenum format
-        builder.setArg7(parseArgument()); // GLenum type
-        // TODO: GLvoid* pixels
-    }
-
-    @Override
-    void parse_glTexParameterfv(Message.Builder builder) {
-        builder.setArg0(parseArgument()); // GLenum target
-        builder.setArg1(parseArgument()); // GLenum pname
-        // TODO: GLfloat* params
-    }
-
-    @Override
-    void parse_glTexParameteriv(Message.Builder builder) {
-        builder.setArg0(parseArgument()); // GLenum target
-        builder.setArg1(parseArgument()); // GLenum pname
-        // TODO: GLint* params
-    }
-
-    @Override
-    void parse_glTexSubImage2D(Message.Builder builder) {
-        builder.setArg0(parseArgument()); // GLenum target
-        builder.setArg1(parseArgument()); // GLint level
-        builder.setArg2(parseArgument()); // GLint xoffset
-        builder.setArg3(parseArgument()); // GLint yoffset
-        builder.setArg4(parseArgument()); // GLsizei width
-        builder.setArg5(parseArgument()); // GLsizei height
-        builder.setArg6(parseArgument()); // GLenum format
-        builder.setArg7(parseArgument()); // GLenum type
-        // TODO: GLvoid* pixels
-    }
-
-    @Override
-    void parse_glVertexAttribPointer(Message.Builder builder) {
-        builder.setArg0(parseArgument()); // GLuint indx
-        builder.setArg1(parseArgument()); // GLint size
-        builder.setArg2(parseArgument()); // GLenum type
-        builder.setArg3(parseArgument()); // GLboolean normalized
-        builder.setArg4(parseArgument()); // GLsizei stride
-        // TODO: GLvoid* ptr
-    }
-
-    public final static MessageParserEx instance = new MessageParserEx();
-}
diff --git a/tools/glesv2debugger/src/com/android/glesv2debugger/MessageProcessor.java b/tools/glesv2debugger/src/com/android/glesv2debugger/MessageProcessor.java
deleted file mode 100644
index bdd53d118..0000000
--- a/tools/glesv2debugger/src/com/android/glesv2debugger/MessageProcessor.java
+++ /dev/null
@@ -1,173 +0,0 @@
-/*
- ** Copyright 2011, The Android Open Source Project
- **
- ** Licensed under the Apache License, Version 2.0 (the "License");
- ** you may not use this file except in compliance with the License.
- ** You may obtain a copy of the License at
- **
- **     http://www.apache.org/licenses/LICENSE-2.0
- **
- ** Unless required by applicable law or agreed to in writing, software
- ** distributed under the License is distributed on an "AS IS" BASIS,
- ** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- ** See the License for the specific language governing permissions and
- ** limitations under the License.
- */
-
-package com.android.glesv2debugger;
-
-import com.google.protobuf.ByteString;
-
-import org.eclipse.jface.dialogs.MessageDialog;
-import org.eclipse.swt.graphics.ImageData;
-import org.eclipse.swt.graphics.PaletteData;
-
-import java.nio.ByteBuffer;
-import java.util.Arrays;
-
-public class MessageProcessor {
-    static void showError(final String message) {
-        // need to call SWT from UI thread
-        MessageDialog.openError(null, "MessageProcessor", message);
-    }
-
-    /**
-     * data layout: uint32 total decompressed length, (chunks: uint32 chunk
-     * decompressed size, uint32 chunk compressed size, chunk data)+. 0 chunk
-     * compressed size means chunk is not compressed
-     */
-    public static byte[] lzfDecompressChunks(final ByteString data) {
-        ByteBuffer in = data.asReadOnlyByteBuffer();
-        in.order(SampleView.targetByteOrder);
-        ByteBuffer out = ByteBuffer.allocate(in.getInt());
-        byte[] inChunk = new byte[0];
-        byte[] outChunk = new byte[0];
-        while (in.remaining() > 0) {
-            int decompressed = in.getInt();
-            int compressed = in.getInt();
-            if (decompressed > outChunk.length)
-                outChunk = new byte[decompressed];
-            if (compressed == 0) {
-                in.get(outChunk, 0, decompressed);
-                out.put(outChunk, 0, decompressed);
-            } else {
-                if (compressed > inChunk.length)
-                    inChunk = new byte[compressed];
-                in.get(inChunk, 0, compressed);
-                int size = org.liblzf.CLZF
-                        .lzf_decompress(inChunk, compressed, outChunk, outChunk.length);
-                assert size == decompressed;
-                out.put(outChunk, 0, size);
-            }
-        }
-        assert !out.hasRemaining();
-        return out.array();
-    }
-
-    /** same data layout as LZFDecompressChunks */
-    public static byte[] lzfCompressChunks(final byte[] in, final int inSize) {
-        byte[] chunk = new byte[256 * 1024]; // chunk size is arbitrary
-        final ByteBuffer out = ByteBuffer.allocate(4 + (inSize + chunk.length - 1)
-                / chunk.length * (chunk.length + 4 * 2));
-        out.order(SampleView.targetByteOrder);
-        out.putInt(inSize);
-        for (int i = 0; i < inSize; i += chunk.length) {
-            int chunkIn = chunk.length;
-            if (i + chunkIn > inSize)
-                chunkIn = inSize - i;
-            final byte[] inChunk = java.util.Arrays.copyOfRange(in, i, i + chunkIn);
-            final int chunkOut = org.liblzf.CLZF
-                    .lzf_compress(inChunk, chunkIn, chunk, chunk.length);
-            out.putInt(chunkIn);
-            out.putInt(chunkOut);
-            if (chunkOut == 0) // compressed bigger than chunk (uncompressed)
-                out.put(inChunk);
-            else
-                out.put(chunk, 0, chunkOut);
-        }
-        return Arrays.copyOf(out.array(), out.position());
-    }
-
-    /**
-     * returns new ref, which is also the decoded image; ref could be bigger
-     * than pixels, in which case the first pixels.length bytes form the image
-     */
-    public static byte[] decodeReferencedImage(byte[] ref, byte[] pixels) {
-        if (ref.length < pixels.length)
-            ref = new byte[pixels.length];
-        for (int i = 0; i < pixels.length; i++)
-            ref[i] ^= pixels[i];
-        for (int i = pixels.length; i < ref.length; i++)
-            ref[i] = 0; // clear unused ref to maintain consistency
-        return ref;
-    }
-
-    public static ImageData receiveImage(int width, int height, int format,
-            int type, final ByteString data) {
-        assert width > 0 && height > 0;
-        int bpp = 0;
-        int redMask = 0, blueMask = 0, greenMask = 0;
-        switch (GLEnum.valueOf(type)) {
-            case GL_UNSIGNED_SHORT_5_6_5:
-            case GL_UNSIGNED_SHORT_4_4_4_4:
-            case GL_UNSIGNED_SHORT_5_5_5_1:
-                format = type;
-                break;
-            case GL_UNSIGNED_BYTE:
-                break;
-            default:
-                showError("unsupported texture type " + type);
-                return null;
-        }
-
-        switch (GLEnum.valueOf(format)) {
-            case GL_ALPHA:
-            case GL_LUMINANCE:
-                redMask = blueMask = greenMask = 0xff;
-                bpp = 8;
-                break;
-            case GL_LUMINANCE_ALPHA:
-                blueMask = 0xff;
-                redMask = 0xff00;
-                bpp = 16;
-                break;
-            case GL_RGB:
-                blueMask = 0xff;
-                greenMask = 0xff00;
-                redMask = 0xff0000;
-                bpp = 24;
-                break;
-            case GL_RGBA:
-                blueMask = 0xff00;
-                greenMask = 0xff0000;
-                redMask = 0xff000000;
-                bpp = 32;
-                break;
-            case GL_UNSIGNED_SHORT_5_6_5:
-                blueMask = ((1 << 5) - 1) << 0;
-                greenMask = ((1 << 6) - 1) << 5;
-                redMask = ((1 << 5) - 1) << 11;
-                bpp = 16;
-                break;
-            case GL_UNSIGNED_SHORT_4_4_4_4:
-                blueMask = ((1 << 4) - 1) << 4;
-                greenMask = ((1 << 4) - 1) << 8;
-                redMask = ((1 << 4) - 1) << 12;
-                bpp = 16;
-                break;
-            case GL_UNSIGNED_SHORT_5_5_5_1:
-                blueMask = ((1 << 5) - 1) << 1;
-                greenMask = ((1 << 5) - 1) << 6;
-                redMask = ((1 << 5) - 1) << 11;
-                bpp = 16;
-                break;
-            default:
-                showError("unsupported texture format: " + format);
-                return null;
-        }
-        byte[] pixels = lzfDecompressChunks(data);
-        assert pixels.length == width * height * (bpp / 8);
-        PaletteData palette = new PaletteData(redMask, greenMask, blueMask);
-        return new ImageData(width, height, bpp, palette, 1, pixels);
-    }
-}
diff --git a/tools/glesv2debugger/src/com/android/glesv2debugger/MessageQueue.java b/tools/glesv2debugger/src/com/android/glesv2debugger/MessageQueue.java
deleted file mode 100644
index c633d06..0000000
--- a/tools/glesv2debugger/src/com/android/glesv2debugger/MessageQueue.java
+++ /dev/null
@@ -1,322 +0,0 @@
-/*
- ** Copyright 2011, The Android Open Source Project
- **
- ** Licensed under the Apache License, Version 2.0 (the "License");
- ** you may not use this file except in compliance with the License.
- ** You may obtain a copy of the License at
- **
- **     http://www.apache.org/licenses/LICENSE-2.0
- **
- ** Unless required by applicable law or agreed to in writing, software
- ** distributed under the License is distributed on an "AS IS" BASIS,
- ** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- ** See the License for the specific language governing permissions and
- ** limitations under the License.
- */
-
-package com.android.glesv2debugger;
-
-import com.android.glesv2debugger.DebuggerMessage.Message;
-import com.android.glesv2debugger.DebuggerMessage.Message.Function;
-import com.android.glesv2debugger.DebuggerMessage.Message.Type;
-import com.android.sdklib.util.SparseArray;
-
-import java.io.DataInputStream;
-import java.io.DataOutputStream;
-import java.io.EOFException;
-import java.io.FileInputStream;
-import java.io.IOException;
-import java.net.Socket;
-import java.nio.ByteOrder;
-import java.util.ArrayList;
-
-abstract interface ProcessMessage {
-    abstract boolean processMessage(final MessageQueue queue, final Message msg)
-            throws IOException;
-}
-
-public class MessageQueue implements Runnable {
-
-    private boolean running = false;
-    private ByteOrder byteOrder;
-    private FileInputStream file; // if null, create and use socket
-    Thread thread = null;
-    private final ProcessMessage[] processes;
-    private ArrayList<Message> complete = new ArrayList<Message>(); // synchronized
-    private ArrayList<Message> commands = new ArrayList<Message>(); // synchronized
-    private SampleView sampleView;
-
-    public MessageQueue(SampleView sampleView, final ProcessMessage[] processes) {
-        this.sampleView = sampleView;
-        this.processes = processes;
-    }
-
-    public void start(final ByteOrder byteOrder, final FileInputStream file) {
-        if (running)
-            return;
-        running = true;
-        this.byteOrder = byteOrder;
-        this.file = file;
-        thread = new Thread(this);
-        thread.start();
-    }
-
-    public void stop() {
-        if (!running)
-            return;
-        running = false;
-    }
-
-    public boolean isRunning() {
-        return running;
-    }
-
-    private void sendCommands(final int contextId) throws IOException {
-        synchronized (commands) {
-            for (int i = 0; i < commands.size(); i++) {
-                Message command = commands.get(i);
-                if (command.getContextId() == contextId || command.getContextId() == 0) {
-                    sendMessage(commands.remove(i));
-                    i--;
-                }
-            }
-        }
-    }
-
-    public void addCommand(Message command) {
-        synchronized (commands) {
-            commands.add(command);
-        }
-    }
-
-    // these should only be accessed from the network thread;
-    // access call chain starts with run()
-    private DataInputStream dis = null;
-    private DataOutputStream dos = null;
-    private SparseArray<ArrayList<Message>> incoming = new SparseArray<ArrayList<Message>>();
-
-    @Override
-    public void run() {
-        Socket socket = null;
-        if (file == null)
-            try {
-                socket = new Socket();
-                socket.connect(new java.net.InetSocketAddress("127.0.0.1", Integer
-                        .parseInt(sampleView.actionPort.getText())));
-                dis = new DataInputStream(socket.getInputStream());
-                dos = new DataOutputStream(socket.getOutputStream());
-            } catch (Exception e) {
-                running = false;
-                Error(e);
-            }
-        else
-            dis = new DataInputStream(file);
-
-        while (running) {
-            try {
-                if (file != null && file.available() == 0) {
-                    running = false;
-                    break;
-                }
-            } catch (IOException e1) {
-                e1.printStackTrace();
-                assert false;
-            }
-
-            Message msg = null;
-            if (incoming.size() > 0) { // find queued incoming
-                for (int i = 0; i < incoming.size(); i++) {
-                    final ArrayList<Message> messages = incoming.valueAt(i);
-                    if (messages.size() > 0) {
-                        msg = messages.remove(0);
-                        break;
-                    }
-                }
-            }
-            try {
-                if (null == msg) // get incoming from network
-                    msg = receiveMessage(dis);
-                processMessage(dos, msg);
-            } catch (IOException e) {
-                Error(e);
-                running = false;
-                break;
-            }
-        }
-
-        try {
-            if (socket != null)
-                socket.close();
-            else
-                file.close();
-        } catch (IOException e) {
-            Error(e);
-            running = false;
-        }
-
-    }
-
-    private void putMessage(final Message msg) {
-        ArrayList<Message> existing = incoming.get(msg.getContextId());
-        if (existing == null)
-            incoming.put(msg.getContextId(), existing = new ArrayList<Message>());
-        existing.add(msg);
-    }
-
-    Message receiveMessage(final int contextId) throws IOException {
-        Message msg = receiveMessage(dis);
-        while (msg.getContextId() != contextId) {
-            putMessage(msg);
-            msg = receiveMessage(dis);
-        }
-        return msg;
-    }
-
-    void sendMessage(final Message msg) throws IOException {
-        sendMessage(dos, msg);
-    }
-
-    // should only be used by DefaultProcessMessage
-    private SparseArray<Message> partials = new SparseArray<Message>();
-
-    Message getPartialMessage(final int contextId) {
-        return partials.get(contextId);
-    }
-
-    // used to add BeforeCall to complete if it was skipped
-    void completePartialMessage(final int contextId) {
-        final Message msg = partials.get(contextId);
-        partials.remove(contextId);
-        assert msg != null;
-        assert msg.getType() == Type.BeforeCall;
-        if (msg != null)
-            synchronized (complete) {
-                complete.add(msg);
-            }
-    }
-
-    // can be used by other message processor as default processor
-    void defaultProcessMessage(final Message msg, boolean expectResponse,
-            boolean sendResponse) throws IOException {
-        final int contextId = msg.getContextId();
-        if (msg.getType() == Type.BeforeCall) {
-            if (sendResponse) {
-                final Message.Builder builder = Message.newBuilder();
-                builder.setContextId(contextId);
-                builder.setType(Type.Response);
-                builder.setExpectResponse(expectResponse);
-                builder.setFunction(Function.CONTINUE);
-                sendMessage(dos, builder.build());
-            }
-            assert partials.indexOfKey(contextId) < 0;
-            partials.put(contextId, msg);
-        } else if (msg.getType() == Type.AfterCall) {
-            if (sendResponse) {
-                final Message.Builder builder = Message.newBuilder();
-                builder.setContextId(contextId);
-                builder.setType(Type.Response);
-                builder.setExpectResponse(expectResponse);
-                builder.setFunction(Function.SKIP);
-                sendMessage(dos, builder.build());
-            }
-            assert partials.indexOfKey(contextId) >= 0;
-            final Message before = partials.get(contextId);
-            partials.remove(contextId);
-            assert before.getFunction() == msg.getFunction();
-            final Message completed = before.toBuilder().mergeFrom(msg)
-                    .setType(Type.CompleteCall).build();
-            synchronized (complete) {
-                complete.add(completed);
-            }
-        } else if (msg.getType() == Type.CompleteCall) {
-            // this type should only be encountered on client after processing
-            assert file != null;
-            assert !msg.getExpectResponse();
-            assert !sendResponse;
-            assert partials.indexOfKey(contextId) < 0;
-            synchronized (complete) {
-                complete.add(msg);
-            }
-        } else if (msg.getType() == Type.Response && msg.getFunction() == Function.SETPROP) {
-            synchronized (complete) {
-                complete.add(msg);
-            }
-        } else
-            assert false;
-    }
-
-    public Message removeCompleteMessage(int contextId) {
-        synchronized (complete) {
-            if (complete.size() == 0)
-                return null;
-            if (0 == contextId) // get a message for any context
-                return complete.remove(0);
-            for (int i = 0; i < complete.size(); i++) {
-                Message msg = complete.get(i);
-                if (msg.getContextId() == contextId) {
-                    complete.remove(i);
-                    return msg;
-                }
-            }
-        }
-        return null;
-    }
-
-    private Message receiveMessage(final DataInputStream dis)
-            throws IOException {
-        int len = 0;
-        try {
-            len = dis.readInt();
-            if (byteOrder == ByteOrder.LITTLE_ENDIAN)
-                len = Integer.reverseBytes(len); // readInt reads BIT_ENDIAN
-        } catch (EOFException e) {
-            Error(new Exception("EOF"));
-        }
-        byte[] buffer = new byte[len];
-        int readLen = 0;
-        while (readLen < len) {
-            int read = -1;
-            try {
-                read = dis.read(buffer, readLen, len - readLen);
-            } catch (EOFException e) {
-                Error(new Exception("EOF"));
-            }
-            if (read < 0) {
-                Error(new Exception("read length = " + read));
-                return null;
-            } else
-                readLen += read;
-        }
-        Message msg = Message.parseFrom(buffer);
-        sendCommands(msg.getContextId());
-        return msg;
-    }
-
-    private void sendMessage(final DataOutputStream dos, final Message message)
-            throws IOException {
-        if (dos == null)
-            return;
-        assert message.getFunction() != Function.NEG;
-        final byte[] data = message.toByteArray();
-        if (byteOrder == ByteOrder.BIG_ENDIAN)
-            dos.writeInt(data.length);
-        else
-            dos.writeInt(Integer.reverseBytes(data.length));
-        dos.write(data);
-    }
-
-    private void processMessage(final DataOutputStream dos, final Message msg) throws IOException {
-        if (msg.getExpectResponse()) {
-            assert dos != null; // readonly source cannot expectResponse
-            for (ProcessMessage process : processes)
-                if (process.processMessage(this, msg))
-                    return;
-            defaultProcessMessage(msg, msg.getExpectResponse(), msg.getExpectResponse());
-        } else
-            defaultProcessMessage(msg, msg.getExpectResponse(), msg.getExpectResponse());
-    }
-
-    void Error(Exception e) {
-        sampleView.showError(e);
-    }
-}
diff --git a/tools/glesv2debugger/src/com/android/glesv2debugger/SampleView.java b/tools/glesv2debugger/src/com/android/glesv2debugger/SampleView.java
deleted file mode 100644
index 4a8cdc9..0000000
--- a/tools/glesv2debugger/src/com/android/glesv2debugger/SampleView.java
+++ /dev/null
@@ -1,835 +0,0 @@
-/*
- ** Copyright 2011, The Android Open Source Project
- **
- ** Licensed under the Apache License, Version 2.0 (the "License");
- ** you may not use this file except in compliance with the License.
- ** You may obtain a copy of the License at
- **
- **     http://www.apache.org/licenses/LICENSE-2.0
- **
- ** Unless required by applicable law or agreed to in writing, software
- ** distributed under the License is distributed on an "AS IS" BASIS,
- ** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- ** See the License for the specific language governing permissions and
- ** limitations under the License.
- */
-
-package com.android.glesv2debugger;
-
-import com.android.glesv2debugger.DebuggerMessage.Message;
-import com.android.glesv2debugger.DebuggerMessage.Message.Function;
-import com.android.glesv2debugger.DebuggerMessage.Message.Prop;
-import com.android.glesv2debugger.DebuggerMessage.Message.Type;
-import com.android.sdklib.util.SparseArray;
-
-import org.eclipse.jface.action.Action;
-import org.eclipse.jface.action.IMenuListener;
-import org.eclipse.jface.action.IMenuManager;
-import org.eclipse.jface.action.IToolBarManager;
-import org.eclipse.jface.action.MenuManager;
-import org.eclipse.jface.action.Separator;
-import org.eclipse.jface.dialogs.InputDialog;
-import org.eclipse.jface.dialogs.MessageDialog;
-import org.eclipse.jface.viewers.ISelectionChangedListener;
-import org.eclipse.jface.viewers.IStructuredContentProvider;
-import org.eclipse.jface.viewers.ITableLabelProvider;
-import org.eclipse.jface.viewers.LabelProvider;
-import org.eclipse.jface.viewers.ListViewer;
-import org.eclipse.jface.viewers.SelectionChangedEvent;
-import org.eclipse.jface.viewers.StructuredSelection;
-import org.eclipse.jface.viewers.TreeViewer;
-import org.eclipse.jface.viewers.Viewer;
-import org.eclipse.jface.viewers.ViewerFilter;
-import org.eclipse.jface.viewers.ViewerSorter;
-import org.eclipse.jface.window.Window;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.events.SelectionEvent;
-import org.eclipse.swt.events.SelectionListener;
-import org.eclipse.swt.graphics.Font;
-import org.eclipse.swt.graphics.GC;
-import org.eclipse.swt.graphics.Image;
-import org.eclipse.swt.graphics.Point;
-import org.eclipse.swt.graphics.Rectangle;
-import org.eclipse.swt.layout.GridData;
-import org.eclipse.swt.layout.GridLayout;
-import org.eclipse.swt.widgets.Canvas;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Event;
-import org.eclipse.swt.widgets.FileDialog;
-import org.eclipse.swt.widgets.Listener;
-import org.eclipse.swt.widgets.Menu;
-import org.eclipse.swt.widgets.ScrollBar;
-import org.eclipse.swt.widgets.Shell;
-import org.eclipse.swt.widgets.Slider;
-import org.eclipse.swt.widgets.TabFolder;
-import org.eclipse.swt.widgets.TabItem;
-import org.eclipse.swt.widgets.Text;
-import org.eclipse.ui.IActionBars;
-import org.eclipse.ui.IWorkbenchActionConstants;
-import org.eclipse.ui.PlatformUI;
-import org.eclipse.ui.part.ViewPart;
-
-import java.io.FileInputStream;
-import java.io.FileNotFoundException;
-import java.nio.ByteOrder;
-
-/**
- * This sample class demonstrates how to plug-in a new workbench view. The view
- * shows data obtained from the model. The sample creates a dummy model on the
- * fly, but a real implementation would connect to the model available either in
- * this or another plug-in (e.g. the workspace). The view is connected to the
- * model using a content provider.
- * <p>
- * The view uses a label provider to define how model objects should be
- * presented in the view. Each view can present the same model objects using
- * different labels and icons, if needed. Alternatively, a single label provider
- * can be shared between views in order to ensure that objects of the same type
- * are presented in the same way everywhere.
- * <p>
- */
-
-public class SampleView extends ViewPart implements Runnable, SelectionListener {
-    public static final ByteOrder targetByteOrder = ByteOrder.LITTLE_ENDIAN;
-
-    boolean running = false;
-    Thread thread;
-    MessageQueue messageQueue;
-    SparseArray<DebugContext> debugContexts = new SparseArray<DebugContext>();
-
-    /** The ID of the view as specified by the extension. */
-    public static final String ID = "glesv2debuggerclient.views.SampleView";
-
-    TabFolder tabFolder;
-    TabItem tabItemText, tabItemImage, tabItemBreakpointOption;
-    TabItem tabItemShaderEditor, tabContextViewer;
-    ListViewer viewer; // ListViewer / TableViewer
-    Slider frameNum; // scale max cannot overlap min, so max is array size
-    TreeViewer contextViewer;
-    BreakpointOption breakpointOption;
-    ShaderEditor shaderEditor;
-    Canvas canvas;
-    Text text;
-    Action actionConnect; // connect / disconnect
-
-    Action actionAutoScroll;
-    Action actionFilter;
-    Action actionPort;
-
-    Action actContext; // for toggling contexts
-    DebugContext current = null;
-
-    Point origin = new Point(0, 0); // for smooth scrolling canvas
-    String[] filters = null;
-
-    class ViewContentProvider extends LabelProvider implements IStructuredContentProvider,
-            ITableLabelProvider {
-        Frame frame = null;
-
-        @Override
-        public void inputChanged(Viewer v, Object oldInput, Object newInput) {
-            frame = (Frame) newInput;
-        }
-
-        @Override
-        public void dispose() {
-        }
-
-        @Override
-        public Object[] getElements(Object parent) {
-            return frame.get().toArray();
-        }
-
-        @Override
-        public String getText(Object obj) {
-            MessageData msgData = (MessageData) obj;
-            return msgData.text;
-        }
-
-        @Override
-        public Image getImage(Object obj) {
-            MessageData msgData = (MessageData) obj;
-            return msgData.getImage();
-        }
-
-        @Override
-        public String getColumnText(Object obj, int index) {
-            MessageData msgData = (MessageData) obj;
-            if (index >= msgData.columns.length)
-                return null;
-            return msgData.columns[index];
-        }
-
-        @Override
-        public Image getColumnImage(Object obj, int index) {
-            if (index > -1)
-                return null;
-            MessageData msgData = (MessageData) obj;
-            return msgData.getImage();
-        }
-    }
-
-    class NameSorter extends ViewerSorter {
-        @Override
-        public int compare(Viewer viewer, Object e1, Object e2) {
-            MessageData m1 = (MessageData) e1;
-            MessageData m2 = (MessageData) e2;
-            return (int) ((m1.msg.getTime() - m2.msg.getTime()) * 100);
-        }
-    }
-
-    class Filter extends ViewerFilter {
-        @Override
-        public boolean select(Viewer viewer, Object parentElement,
-                Object element) {
-            MessageData msgData = (MessageData) element;
-            if (null == filters)
-                return true;
-            for (int i = 0; i < filters.length; i++)
-                if (msgData.text.contains(filters[i]))
-                    return true;
-            return false;
-        }
-    }
-
-    public SampleView() {
-
-    }
-
-    public void createLeftPane(Composite parent) {
-        Composite composite = new Composite(parent, 0);
-
-        GridLayout gridLayout = new GridLayout();
-        gridLayout.numColumns = 1;
-        composite.setLayout(gridLayout);
-
-        frameNum = new Slider(composite, SWT.BORDER | SWT.HORIZONTAL);
-        frameNum.setMinimum(0);
-        frameNum.setMaximum(1);
-        frameNum.setSelection(0);
-        frameNum.addSelectionListener(this);
-
-        GridData gridData = new GridData();
-        gridData.horizontalAlignment = SWT.FILL;
-        gridData.grabExcessHorizontalSpace = true;
-        gridData.verticalAlignment = SWT.FILL;
-        frameNum.setLayoutData(gridData);
-
-        // Table table = new Table(composite, SWT.H_SCROLL | SWT.V_SCROLL |
-        // SWT.MULTI
-        // | SWT.FULL_SELECTION);
-        // TableLayout layout = new TableLayout();
-        // table.setLayout(layout);
-        // table.setLinesVisible(true);
-        // table.setHeaderVisible(true);
-        // String[] headings = {
-        // "Name", "Elapsed (ms)", "Detail"
-        // };
-        // int[] weights = {
-        // 50, 16, 60
-        // };
-        // int[] widths = {
-        // 180, 90, 200
-        // };
-        // for (int i = 0; i < headings.length; i++) {
-        // layout.addColumnData(new ColumnWeightData(weights[i], widths[i],
-        // true));
-        // TableColumn nameCol = new TableColumn(table, SWT.NONE, i);
-        // nameCol.setText(headings[i]);
-        // }
-
-        // viewer = new TableViewer(table);
-        viewer = new ListViewer(composite, SWT.DEFAULT);
-        viewer.getList().setFont(new Font(viewer.getList().getDisplay(),
-                "Courier", 10, SWT.BOLD));
-        ViewContentProvider contentProvider = new ViewContentProvider();
-        viewer.setContentProvider(contentProvider);
-        viewer.setLabelProvider(contentProvider);
-        // viewer.setSorter(new NameSorter());
-        viewer.setFilters(new ViewerFilter[] {
-                new Filter()
-        });
-
-        gridData = new GridData();
-        gridData.horizontalAlignment = SWT.FILL;
-        gridData.grabExcessHorizontalSpace = true;
-        gridData.verticalAlignment = SWT.FILL;
-        gridData.grabExcessVerticalSpace = true;
-        viewer.getControl().setLayoutData(gridData);
-    }
-
-    /**
-     * This is a callback that will allow us to create the viewer and initialize
-     * it.
-     */
-    @Override
-    public void createPartControl(Composite parent) {
-        createLeftPane(parent);
-
-        // Create the help context id for the viewer's control
-        PlatformUI.getWorkbench().getHelpSystem()
-                .setHelp(viewer.getControl(), "GLESv2DebuggerClient.viewer");
-
-        tabFolder = new TabFolder(parent, SWT.BORDER);
-
-        text = new Text(tabFolder, SWT.NO_BACKGROUND | SWT.READ_ONLY
-                | SWT.V_SCROLL | SWT.H_SCROLL);
-
-        tabItemText = new TabItem(tabFolder, SWT.NONE);
-        tabItemText.setText("Text");
-        tabItemText.setControl(text);
-
-        canvas = new Canvas(tabFolder, SWT.NO_BACKGROUND | SWT.NO_REDRAW_RESIZE
-                | SWT.V_SCROLL | SWT.H_SCROLL);
-        tabItemImage = new TabItem(tabFolder, SWT.NONE);
-        tabItemImage.setText("Image");
-        tabItemImage.setControl(canvas);
-
-        breakpointOption = new BreakpointOption(this, tabFolder);
-        tabItemBreakpointOption = new TabItem(tabFolder, SWT.NONE);
-        tabItemBreakpointOption.setText("Breakpoint Option");
-        tabItemBreakpointOption.setControl(breakpointOption);
-
-        shaderEditor = new ShaderEditor(this, tabFolder);
-        tabItemShaderEditor = new TabItem(tabFolder, SWT.NONE);
-        tabItemShaderEditor.setText("Shader Editor");
-        tabItemShaderEditor.setControl(shaderEditor);
-
-        contextViewer = new TreeViewer(tabFolder);
-        ContextViewProvider contextViewProvider = new ContextViewProvider(this);
-        contextViewer.addSelectionChangedListener(contextViewProvider);
-        contextViewer.setContentProvider(contextViewProvider);
-        contextViewer.setLabelProvider(contextViewProvider);
-        tabContextViewer = new TabItem(tabFolder, SWT.NONE);
-        tabContextViewer.setText("Context Viewer");
-        tabContextViewer.setControl(contextViewer.getTree());
-
-        final ScrollBar hBar = canvas.getHorizontalBar();
-        hBar.addListener(SWT.Selection, new Listener() {
-            @Override
-            public void handleEvent(Event e) {
-                if (null == canvas.getBackgroundImage())
-                    return;
-                Image image = canvas.getBackgroundImage();
-                int hSelection = hBar.getSelection();
-                int destX = -hSelection - origin.x;
-                Rectangle rect = image.getBounds();
-                canvas.scroll(destX, 0, 0, 0, rect.width, rect.height, false);
-                origin.x = -hSelection;
-            }
-        });
-        final ScrollBar vBar = canvas.getVerticalBar();
-        vBar.addListener(SWT.Selection, new Listener() {
-            @Override
-            public void handleEvent(Event e) {
-                if (null == canvas.getBackgroundImage())
-                    return;
-                Image image = canvas.getBackgroundImage();
-                int vSelection = vBar.getSelection();
-                int destY = -vSelection - origin.y;
-                Rectangle rect = image.getBounds();
-                canvas.scroll(0, destY, 0, 0, rect.width, rect.height, false);
-                origin.y = -vSelection;
-            }
-        });
-        canvas.addListener(SWT.Resize, new Listener() {
-            @Override
-            public void handleEvent(Event e) {
-                if (null == canvas.getBackgroundImage())
-                    return;
-                Image image = canvas.getBackgroundImage();
-                Rectangle rect = image.getBounds();
-                Rectangle client = canvas.getClientArea();
-                hBar.setMaximum(rect.width);
-                vBar.setMaximum(rect.height);
-                hBar.setThumb(Math.min(rect.width, client.width));
-                vBar.setThumb(Math.min(rect.height, client.height));
-                int hPage = rect.width - client.width;
-                int vPage = rect.height - client.height;
-                int hSelection = hBar.getSelection();
-                int vSelection = vBar.getSelection();
-                if (hSelection >= hPage) {
-                    if (hPage <= 0)
-                        hSelection = 0;
-                    origin.x = -hSelection;
-                }
-                if (vSelection >= vPage) {
-                    if (vPage <= 0)
-                        vSelection = 0;
-                    origin.y = -vSelection;
-                }
-                canvas.redraw();
-            }
-        });
-        canvas.addListener(SWT.Paint, new Listener() {
-            @Override
-            public void handleEvent(Event e) {
-                if (null == canvas.getBackgroundImage())
-                    return;
-                Image image = canvas.getBackgroundImage();
-                GC gc = e.gc;
-                gc.drawImage(image, origin.x, origin.y);
-                Rectangle rect = image.getBounds();
-                Rectangle client = canvas.getClientArea();
-                int marginWidth = client.width - rect.width;
-                if (marginWidth > 0) {
-                    gc.fillRectangle(rect.width, 0, marginWidth, client.height);
-                }
-                int marginHeight = client.height - rect.height;
-                if (marginHeight > 0) {
-                    gc.fillRectangle(0, rect.height, client.width, marginHeight);
-                }
-            }
-        });
-
-        hookContextMenu();
-        hookSelectionChanged();
-        contributeToActionBars();
-
-        messageQueue = new MessageQueue(this, new ProcessMessage[] {
-                breakpointOption, shaderEditor
-        });
-    }
-
-    private void hookContextMenu() {
-        MenuManager menuMgr = new MenuManager("#PopupMenu");
-        menuMgr.setRemoveAllWhenShown(true);
-        menuMgr.addMenuListener(new IMenuListener() {
-            @Override
-            public void menuAboutToShow(IMenuManager manager) {
-                SampleView.this.fillContextMenu(manager);
-            }
-        });
-        Menu menu = menuMgr.createContextMenu(viewer.getControl());
-        viewer.getControl().setMenu(menu);
-        getSite().registerContextMenu(menuMgr, viewer);
-    }
-
-    private void contributeToActionBars() {
-        IActionBars bars = getViewSite().getActionBars();
-        fillLocalPullDown(bars.getMenuManager());
-        fillLocalToolBar(bars.getToolBarManager());
-    }
-
-    private void fillLocalPullDown(IMenuManager manager) {
-        // manager.add(actionConnect);
-        // manager.add(new Separator());
-        // manager.add(actionDisconnect);
-    }
-
-    private void fillContextMenu(IMenuManager manager) {
-        // manager.add(actionConnect);
-        // manager.add(actionDisconnect);
-        // Other plug-ins can contribute there actions here
-        manager.add(new Separator(IWorkbenchActionConstants.MB_ADDITIONS));
-    }
-
-    private void fillLocalToolBar(final IToolBarManager manager) {
-        actionConnect = new Action("Connect", Action.AS_PUSH_BUTTON) {
-            @Override
-            public void run() {
-                if (!running)
-                    changeContext(null); // viewer will switch to newest context
-                connectDisconnect();
-            }
-        };
-        manager.add(actionConnect);
-
-        manager.add(new Action("Open File", Action.AS_PUSH_BUTTON)
-        {
-            @Override
-            public void run()
-            {
-                if (!running)
-                {
-                    changeContext(null); // viewer will switch to newest context
-                    openFile();
-                }
-            }
-        });
-
-        final Shell shell = this.getViewSite().getShell();
-        actionAutoScroll = new Action("Auto Scroll", Action.AS_CHECK_BOX) {
-            @Override
-            public void run() {
-            }
-        };
-        actionAutoScroll.setChecked(true);
-        manager.add(actionAutoScroll);
-
-        actionFilter = new Action("*", Action.AS_DROP_DOWN_MENU) {
-            @Override
-            public void run() {
-                org.eclipse.jface.dialogs.InputDialog dialog = new org.eclipse.jface.dialogs.InputDialog(
-                        shell, "Contains Filter",
-                        "case sensitive substring or *",
-                        actionFilter.getText(), null);
-                if (Window.OK == dialog.open()) {
-                    actionFilter.setText(dialog.getValue());
-                    manager.update(true);
-                    filters = dialog.getValue().split("\\|");
-                    if (filters.length == 1 && filters[0].equals("*"))
-                        filters = null;
-                    viewer.refresh();
-                }
-
-            }
-        };
-        manager.add(actionFilter);
-
-        manager.add(new Action("CaptureDraw", Action.AS_DROP_DOWN_MENU)
-        {
-            @Override
-            public void run()
-            {
-                int contextId = 0;
-                if (current != null)
-                    contextId = current.contextId;
-                InputDialog inputDialog = new InputDialog(shell,
-                        "Capture glDrawArrays/Elements",
-                        "Enter number of glDrawArrays/Elements to glReadPixels for "
-                                + "context 0x" + Integer.toHexString(contextId) +
-                                "\n(0x0 is any context)", "9001", null);
-                if (inputDialog.open() != Window.OK)
-                    return;
-                Message.Builder builder = Message.newBuilder();
-                builder.setContextId(contextId);
-                builder.setType(Type.Response);
-                builder.setExpectResponse(false);
-                builder.setFunction(Function.SETPROP);
-                builder.setProp(Prop.CaptureDraw);
-                builder.setArg0(Integer.parseInt(inputDialog.getValue()));
-                messageQueue.addCommand(builder.build());
-            }
-        });
-
-        manager.add(new Action("CaptureSwap", Action.AS_DROP_DOWN_MENU)
-        {
-            @Override
-            public void run()
-            {
-                int contextId = 0;
-                if (current != null)
-                    contextId = current.contextId;
-                InputDialog inputDialog = new InputDialog(shell,
-                        "Capture eglSwapBuffers",
-                        "Enter number of eglSwapBuffers to glReadPixels for "
-                                + "context 0x" + Integer.toHexString(contextId) +
-                                "\n(0x0 is any context)", "9001", null);
-                if (inputDialog.open() != Window.OK)
-                    return;
-                Message.Builder builder = Message.newBuilder();
-                builder.setContextId(contextId);
-                builder.setType(Type.Response);
-                builder.setExpectResponse(false);
-                builder.setFunction(Function.SETPROP);
-                builder.setProp(Prop.CaptureSwap);
-                builder.setArg0(Integer.parseInt(inputDialog.getValue()));
-                messageQueue.addCommand(builder.build());
-            }
-        });
-
-        manager.add(new Action("SYSTEM_TIME_THREAD", Action.AS_DROP_DOWN_MENU)
-        {
-            @Override
-            public void run()
-            {
-                final String[] timeModes = {
-                        "SYSTEM_TIME_REALTIME", "SYSTEM_TIME_MONOTONIC", "SYSTEM_TIME_PROCESS",
-                        "SYSTEM_TIME_THREAD"
-                };
-                int i = java.util.Arrays.asList(timeModes).indexOf(this.getText());
-                i = (i + 1) % timeModes.length;
-                Message.Builder builder = Message.newBuilder();
-                builder.setContextId(0); // FIXME: proper context id
-                builder.setType(Type.Response);
-                builder.setExpectResponse(false);
-                builder.setFunction(Message.Function.SETPROP);
-                builder.setProp(Prop.TimeMode);
-                builder.setArg0(i);
-                messageQueue.addCommand(builder.build());
-                this.setText(timeModes[i]);
-                manager.update(true);
-            }
-        });
-
-        actContext = new Action("Context: 0x", Action.AS_DROP_DOWN_MENU) {
-            @Override
-            public void run() {
-                if (debugContexts.size() < 2)
-                    return;
-                final String idStr = this.getText().substring(
-                                          "Context: 0x".length());
-                if (idStr.length() == 0)
-                    return;
-                final int contextId = Integer.parseInt(idStr, 16);
-                int index = debugContexts.indexOfKey(contextId);
-                index = (index + 1) % debugContexts.size();
-                changeContext(debugContexts.valueAt(index));
-            }
-        };
-        manager.add(actContext);
-
-        actionPort = new Action("5039", Action.AS_DROP_DOWN_MENU)
-        {
-            @Override
-            public void run() {
-                InputDialog dialog = new InputDialog(shell, "Port", "Debugger port",
-                        actionPort.getText(), null);
-                if (Window.OK == dialog.open()) {
-                    actionPort.setText(dialog.getValue());
-                    manager.update(true);
-                }
-            }
-        };
-        manager.add(actionPort);
-
-        manager.add(new Action("CodeGen Frame", Action.AS_PUSH_BUTTON)
-        {
-            @Override
-            public void run()
-            {
-                if (current != null)
-                {
-                    new CodeGen().codeGenFrame((Frame) viewer.getInput());
-                    // need to reload current frame
-                    viewer.setInput(current.getFrame(frameNum.getSelection()));
-                }
-            }
-        });
-
-        manager.add(new Action("CodeGen Frames", Action.AS_PUSH_BUTTON)
-        {
-            @Override
-            public void run()
-            {
-                if (current != null)
-                {
-                    new CodeGen().codeGenFrames(current, frameNum.getSelection() + 1,
-                            getSite().getShell());
-                    // need to reload current frame
-                    viewer.setInput(current.getFrame(frameNum.getSelection()));
-                }
-            }
-        });
-    }
-
-    private void openFile() {
-        FileDialog dialog = new FileDialog(getSite().getShell(), SWT.OPEN);
-        dialog.setText("Open");
-        dialog.setFilterExtensions(new String[] {
-                "*.gles2dbg"
-        });
-        String filePath = dialog.open();
-        if (filePath == null)
-            return;
-        FileInputStream file = null;
-        try {
-            file = new FileInputStream(filePath);
-        } catch (FileNotFoundException e) {
-            e.printStackTrace();
-            return;
-        }
-        running = true;
-        messageQueue.start(targetByteOrder, file);
-        thread = new Thread(this);
-        thread.start();
-        actionConnect.setText("Disconnect");
-        getViewSite().getActionBars().getToolBarManager().update(true);
-    }
-
-    private void connectDisconnect() {
-        if (!running) {
-            running = true;
-            messageQueue.start(targetByteOrder, null);
-            thread = new Thread(this);
-            thread.start();
-            actionConnect.setText("Disconnect");
-        } else {
-            running = false;
-            messageQueue.stop();
-            actionConnect.setText("Connect");
-        }
-        this.getSite().getShell().getDisplay().syncExec(new Runnable() {
-            @Override
-            public void run() {
-                getViewSite().getActionBars().getToolBarManager().update(true);
-            }
-        });
-    }
-
-    void messageDataSelected(final MessageData msgData) {
-        if (null == msgData)
-            return;
-        if (frameNum.getSelection() == frameNum.getMaximum())
-            return; // scale max cannot overlap min, so max is array size
-        final Frame frame = current.getFrame(frameNum.getSelection());
-        final Context context = frame.computeContext(msgData);
-        contextViewer.setInput(context);
-        if (msgData.getImage() != null) {
-            canvas.setBackgroundImage(msgData.getImage());
-            tabFolder.setSelection(tabItemImage);
-            canvas.redraw();
-        } else if (null != msgData.shader) {
-            text.setText(msgData.shader);
-            tabFolder.setSelection(tabItemText);
-        } else if (null != msgData.attribs) {
-            StringBuilder builder = new StringBuilder();
-            final int maxAttrib = msgData.msg.getArg7();
-            for (int i = 0; i < msgData.attribs[0].length / 4; i++) {
-                if (msgData.indices != null) {
-                    builder.append(msgData.indices[i] & 0xffff);
-                    builder.append(": ");
-                }
-                for (int j = 0; j < maxAttrib; j++) {
-                    for (int k = 0; k < 4; k++)
-                        builder.append(String.format("%.3g ", msgData.attribs[j][i * 4 + k]));
-                    if (j < maxAttrib - 1)
-                        builder.append("|| ");
-                }
-                builder.append('\n');
-            }
-            text.setText(builder.toString());
-            tabFolder.setSelection(tabItemText);
-        }
-    }
-
-    private void hookSelectionChanged() {
-        viewer.addSelectionChangedListener(new ISelectionChangedListener() {
-            @Override
-            public void selectionChanged(SelectionChangedEvent event) {
-                StructuredSelection selection = (StructuredSelection) event
-                        .getSelection();
-                if (null == selection)
-                    return;
-                MessageData msgData = (MessageData) selection.getFirstElement();
-                messageDataSelected(msgData);
-            }
-        });
-    }
-
-    public void showError(final Exception e) {
-        viewer.getControl().getDisplay().syncExec(new Runnable() {
-            @Override
-            public void run() {
-                MessageDialog.openError(viewer.getControl().getShell(),
-                        "GL ES 2.0 Debugger Client", e.getMessage());
-            }
-        });
-    }
-
-    /**
-     * Passing the focus request to the viewer's control.
-     */
-    @Override
-    public void setFocus() {
-        viewer.getControl().setFocus();
-    }
-
-    @Override
-    public void run() {
-        int newMessages = 0;
-
-        boolean shaderEditorUpdate = false;
-        while (running) {
-            final Message oriMsg = messageQueue.removeCompleteMessage(0);
-            if (oriMsg == null && !messageQueue.isRunning())
-                break;
-            if (newMessages > 60 || (newMessages > 0 && null == oriMsg)) {
-                newMessages = 0;
-                if (current != null && current.uiUpdate)
-                    getSite().getShell().getDisplay().syncExec(new Runnable() {
-                        @Override
-                        public void run() {
-                            if (frameNum.getSelection() == current.frameCount() - 1 ||
-                                    frameNum.getSelection() == current.frameCount() - 2)
-                            {
-                                viewer.refresh(false);
-                                if (actionAutoScroll.isChecked())
-                                    viewer.getList().setSelection(
-                                            viewer.getList().getItemCount() - 1);
-                            }
-                            frameNum.setMaximum(current.frameCount());
-                        }
-                    });
-                current.uiUpdate = false;
-
-                if (shaderEditorUpdate)
-                    this.getSite().getShell().getDisplay().syncExec(new Runnable() {
-                        @Override
-                        public void run() {
-                            shaderEditor.updateUI();
-                        }
-                    });
-                shaderEditorUpdate = false;
-            }
-            if (null == oriMsg) {
-                try {
-                    Thread.sleep(1);
-                    continue;
-                } catch (InterruptedException e) {
-                    showError(e);
-                }
-            }
-            DebugContext debugContext = debugContexts.get(oriMsg.getContextId());
-            if (debugContext == null) {
-                debugContext = new DebugContext(oriMsg.getContextId());
-                debugContexts.put(oriMsg.getContextId(), debugContext);
-            }
-            debugContext.processMessage(oriMsg);
-            shaderEditorUpdate |= debugContext.currentContext.serverShader.uiUpdate;
-            debugContext.currentContext.serverShader.uiUpdate = false;
-            if (current == null && debugContext.frameCount() > 0)
-                changeContext(debugContext);
-            newMessages++;
-        }
-        if (running)
-            connectDisconnect(); // error occurred, disconnect
-    }
-
-    /** can be called from non-UI thread */
-    void changeContext(final DebugContext newContext) {
-        getSite().getShell().getDisplay().syncExec(new Runnable() {
-            @Override
-            public void run() {
-                current = newContext;
-                if (current != null)
-                {
-                    frameNum.setMaximum(current.frameCount());
-                    if (frameNum.getSelection() >= current.frameCount())
-                        if (current.frameCount() > 0)
-                            frameNum.setSelection(current.frameCount() - 1);
-                        else
-                            frameNum.setSelection(0);
-                    viewer.setInput(current.getFrame(frameNum.getSelection()));
-                    actContext.setText("Context: 0x" + Integer.toHexString(current.contextId));
-                }
-                else
-                {
-                    frameNum.setMaximum(1); // cannot overlap min
-                    frameNum.setSelection(0);
-                    viewer.setInput(null);
-                    actContext.setText("Context: 0x");
-                }
-                shaderEditor.updateUI();
-                getViewSite().getActionBars().getToolBarManager().update(true);
-            }
-        });
-    }
-
-    @Override
-    public void widgetSelected(SelectionEvent e) {
-        if (e.widget != frameNum)
-            assert false;
-        if (current == null)
-            return;
-        if (frameNum.getSelection() == current.frameCount())
-            return; // scale maximum cannot overlap minimum
-        Frame frame = current.getFrame(frameNum.getSelection());
-        viewer.setInput(frame);
-    }
-
-    @Override
-    public void widgetDefaultSelected(SelectionEvent e) {
-        widgetSelected(e);
-    }
-}
diff --git a/tools/glesv2debugger/src/com/android/glesv2debugger/ShaderEditor.java b/tools/glesv2debugger/src/com/android/glesv2debugger/ShaderEditor.java
deleted file mode 100644
index c125143..0000000
--- a/tools/glesv2debugger/src/com/android/glesv2debugger/ShaderEditor.java
+++ /dev/null
@@ -1,407 +0,0 @@
-/*
- ** Copyright 2011, The Android Open Source Project
- **
- ** Licensed under the Apache License, Version 2.0 (the "License");
- ** you may not use this file except in compliance with the License.
- ** You may obtain a copy of the License at
- **
- **     http://www.apache.org/licenses/LICENSE-2.0
- **
- ** Unless required by applicable law or agreed to in writing, software
- ** distributed under the License is distributed on an "AS IS" BASIS,
- ** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- ** See the License for the specific language governing permissions and
- ** limitations under the License.
- */
-
-package com.android.glesv2debugger;
-
-import com.android.glesv2debugger.DebuggerMessage.Message;
-import com.android.glesv2debugger.DebuggerMessage.Message.Function;
-import com.android.glesv2debugger.DebuggerMessage.Message.Type;
-
-import org.eclipse.jface.dialogs.MessageDialog;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.custom.ExtendedModifyEvent;
-import org.eclipse.swt.custom.ExtendedModifyListener;
-import org.eclipse.swt.custom.StyleRange;
-import org.eclipse.swt.custom.StyledText;
-import org.eclipse.swt.events.SelectionEvent;
-import org.eclipse.swt.events.SelectionListener;
-import org.eclipse.swt.graphics.Color;
-import org.eclipse.swt.graphics.Font;
-import org.eclipse.swt.layout.GridData;
-import org.eclipse.swt.layout.GridLayout;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Display;
-import org.eclipse.swt.widgets.List;
-import org.eclipse.swt.widgets.ToolBar;
-import org.eclipse.swt.widgets.ToolItem;
-
-import java.io.BufferedReader;
-import java.io.File;
-import java.io.FileWriter;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.InputStreamReader;
-import java.util.ArrayList;
-
-public class ShaderEditor extends Composite implements SelectionListener, ExtendedModifyListener,
-        ProcessMessage {
-    SampleView sampleView;
-
-    ToolBar toolbar;
-    ToolItem uploadShader, restoreShader, currentPrograms;
-    List list;
-    StyledText styledText;
-
-    GLShader current;
-
-    ArrayList<GLShader> shadersToUpload = new ArrayList<GLShader>();
-
-    ShaderEditor(SampleView sampleView, Composite parent) {
-        super(parent, 0);
-        this.sampleView = sampleView;
-
-        GridLayout gridLayout = new GridLayout();
-        gridLayout.numColumns = 1;
-        this.setLayout(gridLayout);
-
-        toolbar = new ToolBar(this, SWT.BORDER);
-
-        uploadShader = new ToolItem(toolbar, SWT.PUSH);
-        uploadShader.setText("Upload Shader");
-        uploadShader.addSelectionListener(this);
-
-        restoreShader = new ToolItem(toolbar, SWT.PUSH);
-        restoreShader.setText("Original Shader");
-        restoreShader.addSelectionListener(this);
-
-        currentPrograms = new ToolItem(toolbar, SWT.PUSH);
-        currentPrograms.setText("Current Programs: ");
-
-        list = new List(this, SWT.V_SCROLL);
-        list.setFont(new Font(parent.getDisplay(), "Courier", 10, 0));
-        list.addSelectionListener(this);
-        GridData gridData = new GridData();
-        gridData.horizontalAlignment = SWT.FILL;
-        gridData.grabExcessHorizontalSpace = true;
-        gridData.verticalAlignment = SWT.FILL;
-        gridData.grabExcessVerticalSpace = true;
-        list.setLayoutData(gridData);
-
-        styledText = new StyledText(this, SWT.V_SCROLL | SWT.H_SCROLL | SWT.MULTI);
-        gridData = new GridData();
-        gridData.horizontalAlignment = SWT.FILL;
-        gridData.grabExcessHorizontalSpace = true;
-        gridData.verticalAlignment = SWT.FILL;
-        gridData.grabExcessVerticalSpace = true;
-        gridData.verticalSpan = 2;
-        styledText.setLayoutData(gridData);
-        styledText.addExtendedModifyListener(this);
-    }
-
-    public void updateUI() {
-        list.removeAll();
-        String progs = "Current Programs: ";
-        for (int j = 0; j < sampleView.debugContexts.size(); j++) {
-            final Context context = sampleView.debugContexts.valueAt(j).currentContext;
-
-            if (context.serverShader.current != null) {
-                progs += context.serverShader.current.name + "(0x";
-                progs += Integer.toHexString(context.contextId) + ") ";
-            }
-            for (int i = 0; i < context.serverShader.shaders.size(); i++) {
-                GLShader shader = context.serverShader.shaders.valueAt(i);
-                StringBuilder builder = new StringBuilder();
-                builder.append(String.format("%08X", context.contextId));
-                builder.append(' ');
-                builder.append(shader.type);
-                while (builder.length() < 30)
-                    builder.append(" ");
-                builder.append(shader.name);
-                while (builder.length() < 40)
-                    builder.append(" ");
-                builder.append(" : ");
-                for (Context ctx : context.shares) {
-                    builder.append(String.format("%08X", ctx.contextId));
-                    builder.append(' ');
-                }
-                builder.append(": ");
-                for (int program : shader.programs) {
-                    builder.append(program);
-                    builder.append(" ");
-                }
-                list.add(builder.toString());
-            }
-
-        }
-
-        currentPrograms.setText(progs);
-        toolbar.redraw();
-        toolbar.pack(true);
-        toolbar.update();
-    }
-
-    void uploadShader() {
-        current.source = styledText.getText();
-
-        // optional syntax check by glsl_compiler, built from external/mesa3d
-        if (new File("./glsl_compiler").exists())
-            try {
-                File file = File.createTempFile("shader",
-                        current.type == GLEnum.GL_VERTEX_SHADER ? ".vert" : ".frag");
-                FileWriter fileWriter = new FileWriter(file, false);
-                fileWriter.write(current.source);
-                fileWriter.close();
-
-                ProcessBuilder processBuilder = new ProcessBuilder(
-                        "./glsl_compiler", "--glsl-es", file.getAbsolutePath());
-                final Process process = processBuilder.start();
-                InputStream is = process.getInputStream();
-                InputStreamReader isr = new InputStreamReader(is);
-                BufferedReader br = new BufferedReader(isr);
-                String line;
-                String infolog = "";
-
-                styledText.setLineBackground(0, styledText.getLineCount(), null);
-
-                while ((line = br.readLine()) != null) {
-                    infolog += line;
-                    if (!line.startsWith("0:"))
-                        continue;
-                    String[] details = line.split(":|\\(|\\)");
-                    final int ln = Integer.parseInt(details[1]);
-                    if (ln > 0) // usually line 0 means errors other than syntax
-                        styledText.setLineBackground(ln - 1, 1,
-                                new Color(Display.getCurrent(), 255, 230, 230));
-                }
-                file.delete();
-                if (infolog.length() > 0) {
-                    if (!MessageDialog.openConfirm(getShell(),
-                            "Shader Syntax Error, Continue?", infolog))
-                        return;
-                }
-            } catch (IOException e) {
-                sampleView.showError(e);
-            }
-
-        // add the initial command, which when read by server will set
-        // expectResponse for the message loop and go into message exchange
-        synchronized (shadersToUpload) {
-            for (GLShader shader : shadersToUpload) {
-                if (shader.context.context.contextId != current.context.context.contextId)
-                    continue;
-                MessageDialog.openWarning(this.getShell(), "Context 0x" +
-                        Integer.toHexString(current.context.context.contextId),
-                        "Previous shader upload not complete, try again");
-                return;
-            }
-            shadersToUpload.add(current);
-            final int contextId = current.context.context.contextId;
-            Message.Builder builder = getBuilder(contextId);
-            MessageParserEx.instance.parse(builder,
-                    String.format("glShaderSource(%d,1,\"%s\",0)", current.name, current.source));
-            sampleView.messageQueue.addCommand(builder.build());
-        }
-    }
-
-    Message.Builder getBuilder(int contextId) {
-        Message.Builder builder = Message.newBuilder();
-        builder.setContextId(contextId);
-        builder.setType(Type.Response);
-        builder.setExpectResponse(true);
-        return builder;
-    }
-
-    Message exchangeMessage(final int contextId, final MessageQueue queue,
-            String format, Object... args) throws IOException {
-        Message.Builder builder = getBuilder(contextId);
-        MessageParserEx.instance.parse(builder, String.format(format, args));
-        final Function function = builder.getFunction();
-        queue.sendMessage(builder.build());
-        final Message msg = queue.receiveMessage(contextId);
-        assert msg.getContextId() == contextId;
-        assert msg.getType() == Type.AfterGeneratedCall;
-        assert msg.getFunction() == function;
-        return msg;
-    }
-
-    // this is called from network thread
-    public boolean processMessage(final MessageQueue queue, final Message msg)
-            throws IOException {
-        GLShader shader = null;
-        final int contextId = msg.getContextId();
-        synchronized (shadersToUpload) {
-            if (shadersToUpload.size() == 0)
-                return false;
-            boolean matchingContext = false;
-            for (int i = 0; i < shadersToUpload.size(); i++) {
-                shader = shadersToUpload.get(i);
-                for (Context ctx : shader.context.context.shares)
-                    if (ctx.contextId == contextId) {
-                        matchingContext = true;
-                        break;
-                    }
-                if (matchingContext) {
-                    shadersToUpload.remove(i);
-                    break;
-                }
-            }
-            if (!matchingContext)
-                return false;
-        }
-
-        // glShaderSource was already sent to trigger set expectResponse
-        assert msg.getType() == Type.AfterGeneratedCall;
-        assert msg.getFunction() == Function.glShaderSource;
-
-        exchangeMessage(contextId, queue, "glCompileShader(%d)", shader.name);
-
-        // the 0, "" and {0} are dummies for the parser
-        Message rcv = exchangeMessage(contextId, queue,
-                "glGetShaderiv(%d, GL_COMPILE_STATUS, {0})", shader.name);
-        assert rcv.hasData();
-        if (rcv.getData().asReadOnlyByteBuffer().getInt() == 0) {
-            // compile failed
-            rcv = exchangeMessage(contextId, queue,
-                    "glGetShaderInfoLog(%d, 0, 0, \"\")", shader.name);
-            final String title = String.format("Shader %d in 0x%s failed to compile",
-                    shader.name, Integer.toHexString(shader.context.context.contextId));
-            final String message = rcv.getData().toStringUtf8();
-            sampleView.getSite().getShell().getDisplay().syncExec(new Runnable() {
-                @Override
-                public void run()
-                {
-                    MessageDialog.openWarning(getShell(), title, message);
-                }
-            });
-        } else
-            for (int programName : shader.programs) {
-                GLProgram program = shader.context.getProgram(programName);
-                exchangeMessage(contextId, queue, "glLinkProgram(%d)", program.name);
-                rcv = exchangeMessage(contextId, queue,
-                        "glGetProgramiv(%d, GL_LINK_STATUS, {0})", program.name);
-                assert rcv.hasData();
-                if (rcv.getData().asReadOnlyByteBuffer().getInt() != 0)
-                    continue;
-                // link failed
-                rcv = exchangeMessage(contextId, queue,
-                            "glGetProgramInfoLog(%d, 0, 0, \"\")", program.name);
-                final String title = String.format("Program %d in 0x%s failed to link",
-                        program.name, Integer.toHexString(program.context.context.contextId));
-                final String message = rcv.getData().toStringUtf8();
-                sampleView.getSite().getShell().getDisplay().syncExec(new Runnable() {
-                    @Override
-                    public void run()
-                    {
-                        MessageDialog.openWarning(getShell(), title, message);
-                    }
-                });
-                // break;
-            }
-
-        // TODO: add to upload results if failed
-
-        Message.Builder builder = getBuilder(contextId);
-        builder.setExpectResponse(false);
-        if (queue.getPartialMessage(contextId) != null)
-            // the glShaderSource interrupted a BeforeCall, so continue
-            builder.setFunction(Function.CONTINUE);
-        else
-            builder.setFunction(Function.SKIP);
-        queue.sendMessage(builder.build());
-
-        return true;
-    }
-
-    @Override
-    public void widgetSelected(SelectionEvent e) {
-        if (e.getSource() == uploadShader && null != current) {
-            uploadShader();
-            return;
-        } else if (e.getSource() == restoreShader && null != current) {
-            current.source = styledText.getText();
-            styledText.setText(current.originalSource);
-            return;
-        }
-
-        if (list.getSelectionCount() < 1)
-            return;
-        if (null != current && !current.source.equals(styledText.getText())) {
-            String[] btns = {
-                    "&Upload", "&Save", "&Discard"
-            };
-            MessageDialog dialog = new MessageDialog(this.getShell(), "Shader Edited",
-                    null, "Shader source has been edited", MessageDialog.QUESTION, btns, 0);
-            int rc = dialog.open();
-            if (rc == SWT.DEFAULT || rc == 0)
-                uploadShader();
-            else if (rc == 1)
-                current.source = styledText.getText();
-            // else if (rc == 2) do nothing; selection is changing
-        }
-        String[] details = list.getSelection()[0].split("\\s+");
-        final int contextId = Integer.parseInt(details[0], 16);
-        int name = Integer.parseInt(details[2]);
-        current = sampleView.debugContexts.get(contextId).currentContext.serverShader.shaders
-                .get(name);
-        styledText.setText(current.source);
-    }
-
-    @Override
-    public void widgetDefaultSelected(SelectionEvent e) {
-        widgetSelected(e);
-    }
-
-    @Override
-    public void modifyText(ExtendedModifyEvent event) {
-        final String[] keywords = {
-                "gl_Position", "gl_FragColor"
-        };
-        // FIXME: proper scanner for syntax highlighting
-        String text = styledText.getText();
-        int start = event.start;
-        int end = event.start + event.length;
-        start -= 20; // deleting chars from keyword causes rescan
-        end += 20;
-        if (start < 0)
-            start = 0;
-        if (end > text.length())
-            end = text.length();
-        if (null != styledText.getStyleRangeAtOffset(event.start)) {
-            StyleRange clearStyleRange = new StyleRange();
-            clearStyleRange.start = start;
-            clearStyleRange.length = end - start;
-            clearStyleRange.foreground = event.display.getSystemColor(SWT.COLOR_BLACK);
-            styledText.setStyleRange(clearStyleRange);
-        }
-
-        while (start < end) {
-            for (final String keyword : keywords) {
-                if (!text.substring(start).startsWith(keyword))
-                    continue;
-                if (start > 0) {
-                    final char before = text.charAt(start - 1);
-                    if (Character.isLetterOrDigit(before))
-                        continue;
-                    else if (before == '_')
-                        continue;
-                }
-                if (start + keyword.length() < text.length()) {
-                    final char after = text.charAt(start + keyword.length());
-                    if (Character.isLetterOrDigit(after))
-                        continue;
-                    else if (after == '_')
-                        continue;
-                }
-                StyleRange style1 = new StyleRange();
-                style1.start = start;
-                style1.length = keyword.length();
-                style1.foreground = event.display.getSystemColor(SWT.COLOR_BLUE);
-                styledText.setStyleRange(style1);
-            }
-            start++;
-        }
-    }
-}
diff --git a/tools/glesv2debugger/test/com/android/glesv2debugger/MessageParserExTest.java b/tools/glesv2debugger/test/com/android/glesv2debugger/MessageParserExTest.java
deleted file mode 100644
index d2a9a7e..0000000
--- a/tools/glesv2debugger/test/com/android/glesv2debugger/MessageParserExTest.java
+++ /dev/null
@@ -1,115 +0,0 @@
-/*
- ** Copyright 2011, The Android Open Source Project
- **
- ** Licensed under the Apache License, Version 2.0 (the "License");
- ** you may not use this file except in compliance with the License.
- ** You may obtain a copy of the License at
- **
- **     http://www.apache.org/licenses/LICENSE-2.0
- **
- ** Unless required by applicable law or agreed to in writing, software
- ** distributed under the License is distributed on an "AS IS" BASIS,
- ** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- ** See the License for the specific language governing permissions and
- ** limitations under the License.
- */
-
-package com.android.glesv2debugger;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-
-import com.android.glesv2debugger.DebuggerMessage.Message;
-import com.android.glesv2debugger.DebuggerMessage.Message.Function;
-import com.android.glesv2debugger.DebuggerMessage.Message.Type;
-import com.google.protobuf.ByteString;
-
-import org.junit.Before;
-import org.junit.Test;
-
-import java.nio.ByteBuffer;
-
-public class MessageParserExTest {
-    /**
-     * @throws java.lang.Exception
-     */
-    @Before
-    public void setUp() throws Exception {
-    }
-
-    @Test
-    public void testParseFloats() {
-        final MessageParserEx parser = new MessageParserEx();
-        final String args = "{0, 1    ,2,3  }";
-        parser.args = args;
-        final ByteBuffer data = parser.parseFloats(4).asReadOnlyByteBuffer();
-        data.order(SampleView.targetByteOrder);
-        for (int i = 0; i < 4; i++)
-            assertEquals(i, data.getFloat(), 0);
-    }
-
-    @Test
-    public void testParseArgument() {
-        final MessageParserEx parser = new MessageParserEx();
-        final String args = "sdfa   =  GL_VERTEX_SHADER , -5421 ,0x443=0x54f";
-        parser.args = args;
-        assertEquals(GLEnum.GL_VERTEX_SHADER.value, parser.parseArgument());
-        assertEquals(-5421, parser.parseArgument());
-        assertEquals(0x54f, parser.parseArgument());
-    }
-
-    /**
-     * Test method for
-     * {@link com.android.glesv2debugger.MessageParserEx#parse_glShaderSource(com.android.glesv2debugger.DebuggerMessage.Message.Builder)}
-     * .
-     */
-    @Test
-    public void testParse_glShaderSource() {
-        final Message.Builder builder = Message.newBuilder();
-        final MessageParserEx messageParserEx = new MessageParserEx();
-        final String source = "dks \n jafhskjaho { urehg ; } hskjg";
-        messageParserEx.parse(builder, "void glShaderSource ( shader=4, count= 1, "
-                                + "string =\"" + source + "\"  , 0x0)");
-        assertEquals(Function.glShaderSource, builder.getFunction());
-        assertEquals(4, builder.getArg0());
-        assertEquals(1, builder.getArg1());
-        assertEquals(source, builder.getData().toStringUtf8());
-        assertEquals(0, builder.getArg3());
-    }
-
-    @Test
-    public void testParse_glBlendEquation() {
-        assertNotNull(MessageParserEx.instance);
-        final Message.Builder builder = Message.newBuilder();
-        MessageParserEx.instance.parse(builder, "void glBlendEquation ( mode= GL_ADD ) ; ");
-        assertEquals(Function.glBlendEquation, builder.getFunction());
-        assertEquals(GLEnum.GL_ADD.value, builder.getArg0());
-    }
-
-    /** loopback testing of typical generated MessageFormatter and MessageParser */
-    @Test
-    public void testParseFormatterMessage() {
-        final ByteBuffer srcData = ByteBuffer.allocate(4 * 2 * 4);
-        srcData.order(SampleView.targetByteOrder);
-        for (int i = 0; i < 4 * 2; i++)
-            srcData.putFloat(i);
-        srcData.rewind();
-        Message.Builder builder = Message.newBuilder();
-        builder.setContextId(3752).setExpectResponse(false).setType(Type.CompleteCall);
-        builder.setFunction(Function.glUniformMatrix2fv);
-        builder.setArg0(54).setArg1(2).setArg2(0).setData(ByteString.copyFrom(srcData));
-        Message msg = builder.build();
-        builder = msg.toBuilder();
-        String formatted = MessageFormatter.format(msg, false);
-        formatted = formatted.substring(0, formatted.indexOf('(')) + ' ' + builder.getFunction() +
-                formatted.substring(formatted.indexOf('('));
-        Message.Builder parsed = Message.newBuilder();
-        MessageParserEx.instance.parse(parsed, formatted);
-        assertEquals(builder.getFunction(), parsed.getFunction());
-        assertEquals(builder.getArg0(), parsed.getArg0());
-        assertEquals(builder.getArg1(), parsed.getArg1());
-        assertEquals(builder.getArg2(), parsed.getArg2());
-        assertEquals(builder.getData().toStringUtf8(), parsed.getData().toStringUtf8());
-    }
-
-}
diff --git a/tools/glesv2debugger/test/com/android/glesv2debugger/MessageQueueTest.java b/tools/glesv2debugger/test/com/android/glesv2debugger/MessageQueueTest.java
deleted file mode 100644
index 5f8e93d..0000000
--- a/tools/glesv2debugger/test/com/android/glesv2debugger/MessageQueueTest.java
+++ /dev/null
@@ -1,183 +0,0 @@
-/*
- ** Copyright 2011, The Android Open Source Project
- **
- ** Licensed under the Apache License, Version 2.0 (the "License");
- ** you may not use this file except in compliance with the License.
- ** You may obtain a copy of the License at
- **
- **     http://www.apache.org/licenses/LICENSE-2.0
- **
- ** Unless required by applicable law or agreed to in writing, software
- ** distributed under the License is distributed on an "AS IS" BASIS,
- ** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- ** See the License for the specific language governing permissions and
- ** limitations under the License.
- */
-
-package com.android.glesv2debugger;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertNull;
-
-import com.android.glesv2debugger.DebuggerMessage.Message;
-import com.android.glesv2debugger.DebuggerMessage.Message.Function;
-import com.android.glesv2debugger.DebuggerMessage.Message.Type;
-
-import org.junit.Before;
-import org.junit.Test;
-
-import java.io.DataOutputStream;
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.FileNotFoundException;
-import java.io.FileOutputStream;
-import java.io.IOException;
-import java.nio.ByteOrder;
-
-public class MessageQueueTest {
-    private MessageQueue queue;
-
-    /**
-     * @throws java.lang.Exception
-     */
-    @Before
-    public void setUp() throws Exception {
-        queue = new MessageQueue(null, new ProcessMessage[0]);
-    }
-
-    /**
-     * Test method for
-     * {@link com.android.glesv2debugger.MessageQueue#defaultProcessMessage(com.android.glesv2debugger.DebuggerMessage.Message, boolean, boolean)}
-     * .
-     * 
-     * @throws IOException
-     */
-    @Test
-    public void testDefaultProcessMessage() throws IOException {
-        final int contextId = 8784;
-        assertNull(queue.getPartialMessage(contextId));
-        Message.Builder builder = Message.newBuilder();
-        builder.setContextId(contextId);
-        builder.setExpectResponse(false);
-        builder.setFunction(Function.glFinish);
-        builder.setType(Type.BeforeCall);
-        Message msg = builder.build();
-        queue.defaultProcessMessage(msg, false, false);
-        assertNotNull(queue.getPartialMessage(contextId));
-
-        builder = msg.toBuilder();
-        builder.setType(Type.AfterCall);
-        builder.setTime(5);
-        msg = builder.build();
-        queue.defaultProcessMessage(msg, false, false);
-        assertNull(queue.getPartialMessage(contextId));
-        Message complete = queue.removeCompleteMessage(contextId);
-        assertNotNull(complete);
-        assertEquals(contextId, complete.getContextId());
-        assertEquals(msg.getFunction(), complete.getFunction());
-        assertEquals(msg.getTime(), complete.getTime(), 0);
-        assertEquals(Type.CompleteCall, complete.getType());
-
-        // an already complete message should just be added to complete queue
-        queue.defaultProcessMessage(complete, false, false);
-        assertNull(queue.getPartialMessage(contextId));
-        complete = queue.removeCompleteMessage(contextId);
-        assertNotNull(complete);
-        assertEquals(contextId, complete.getContextId());
-        assertEquals(msg.getFunction(), complete.getFunction());
-        assertEquals(msg.getTime(), complete.getTime(), 0);
-        assertEquals(Type.CompleteCall, complete.getType());
-    }
-
-    @Test
-    public void testCompletePartialMessage() throws IOException {
-        final int contextId = 8784;
-        assertNull(queue.getPartialMessage(contextId));
-        Message.Builder builder = Message.newBuilder();
-        builder.setContextId(contextId);
-        builder.setExpectResponse(false);
-        builder.setFunction(Function.glFinish);
-        builder.setType(Type.BeforeCall);
-        Message msg = builder.build();
-        queue.defaultProcessMessage(msg, false, false);
-        assertNotNull(queue.getPartialMessage(contextId));
-        queue.completePartialMessage(contextId);
-
-        final Message complete = queue.removeCompleteMessage(contextId);
-        assertNotNull(complete);
-        assertEquals(contextId, complete.getContextId());
-        assertEquals(msg.getFunction(), complete.getFunction());
-        assertEquals(msg.getTime(), complete.getTime(), 0);
-        assertEquals(Type.BeforeCall, complete.getType());
-    }
-
-    /** Write two messages from two contexts to file and test handling them */
-    @Test
-    public void testRunWithFile() throws FileNotFoundException, IOException, InterruptedException {
-        final File filePath = File.createTempFile("test", ".gles2dbg");
-        DataOutputStream file = new DataOutputStream(new FileOutputStream(filePath));
-        Message.Builder builder = Message.newBuilder();
-        final int contextId0 = 521643, contextId1 = 87634;
-        assertNull(queue.removeCompleteMessage(contextId0));
-        assertNull(queue.removeCompleteMessage(contextId1));
-
-        builder.setContextId(contextId0).setExpectResponse(false).setType(Type.BeforeCall);
-        builder.setFunction(Function.glClear).setArg0(contextId0);
-        Message msg0 = builder.build();
-        byte[] data = msg0.toByteArray();
-        file.writeInt(data.length);
-        file.write(data);
-
-        builder = Message.newBuilder();
-        builder.setContextId(contextId1).setExpectResponse(false).setType(Type.BeforeCall);
-        builder.setFunction(Function.glDisable).setArg0(contextId1);
-        Message msg1 = builder.build();
-        data = msg1.toByteArray();
-        file.writeInt(data.length);
-        file.write(data);
-
-        builder = Message.newBuilder();
-        msg0 = builder.setContextId(msg0.getContextId()).setExpectResponse(false)
-                .setType(Type.AfterCall).setFunction(msg0.getFunction()).setTime(2).build();
-        data = msg0.toByteArray();
-        file.writeInt(data.length);
-        file.write(data);
-
-        builder = Message.newBuilder();
-        msg1 = builder.setContextId(msg1.getContextId()).setExpectResponse(false)
-                .setType(Type.AfterCall).setFunction(msg1.getFunction()).setTime(465).build();
-        data = msg1.toByteArray();
-        file.writeInt(data.length);
-        file.write(data);
-
-        file.close();
-
-        FileInputStream fis = new FileInputStream(filePath);
-        // Java VM uses big endian, so the file was written in big endian
-        queue.start(ByteOrder.BIG_ENDIAN, fis);
-        queue.thread.join();
-
-        Message complete0 = queue.removeCompleteMessage(msg0.getContextId());
-        assertNotNull(complete0);
-        assertNull(queue.removeCompleteMessage(contextId0));
-        assertEquals(contextId0, complete0.getContextId());
-        assertEquals(false, complete0.getExpectResponse());
-        assertEquals(Type.CompleteCall, complete0.getType());
-        assertEquals(msg0.getFunction(), complete0.getFunction());
-        assertEquals(contextId0, complete0.getArg0());
-        assertEquals(msg0.getTime(), complete0.getTime(), 0);
-
-        Message complete1 = queue.removeCompleteMessage(msg1.getContextId());
-        assertNotNull(complete1);
-        assertNull(queue.removeCompleteMessage(contextId1));
-        assertEquals(contextId1, complete1.getContextId());
-        assertEquals(false, complete1.getExpectResponse());
-        assertEquals(Type.CompleteCall, complete1.getType());
-        assertEquals(msg1.getFunction(), complete1.getFunction());
-        assertEquals(contextId1, complete1.getArg0());
-        assertEquals(msg1.getTime(), complete1.getTime(), 0);
-
-        filePath.delete();
-    }
-}
diff --git a/tools/mkstubs/.classpath b/tools/mkstubs/.classpath
index 49a6d6c..1b7d34b 100644
--- a/tools/mkstubs/.classpath
+++ b/tools/mkstubs/.classpath
@@ -1,9 +1,9 @@
-<?xml version="1.0" encoding="UTF-8"?>

-<classpath>

-	<classpathentry kind="src" path="src"/>

-	<classpathentry kind="src" path="tests"/>

-	<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/J2SE-1.5"/>

-	<classpathentry kind="con" path="org.eclipse.jdt.junit.JUNIT_CONTAINER/4"/>

-	<classpathentry kind="var" path="ANDROID_SRC/prebuilt/common/asm/asm-3.1.jar"/>

-	<classpathentry kind="output" path="bin"/>

-</classpath>

+<?xml version="1.0" encoding="UTF-8"?>
+<classpath>
+	<classpathentry kind="src" path="src"/>
+	<classpathentry kind="src" path="tests"/>
+	<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/J2SE-1.5"/>
+	<classpathentry kind="con" path="org.eclipse.jdt.junit.JUNIT_CONTAINER/4"/>
+	<classpathentry kind="var" path="ANDROID_SRC/prebuilt/common/asm/asm-4.0.jar"/>
+	<classpathentry kind="output" path="bin"/>
+</classpath>
diff --git a/tools/mkstubs/Android.mk b/tools/mkstubs/Android.mk
index a12bf18..3e46a1d 100644
--- a/tools/mkstubs/Android.mk
+++ b/tools/mkstubs/Android.mk
@@ -20,7 +20,7 @@
 
 LOCAL_JAR_MANIFEST := manifest.txt
 LOCAL_STATIC_JAVA_LIBRARIES := \
-	asm-3.1
+	asm-4.0
 
 LOCAL_MODULE := mkstubs
 
diff --git a/tools/mkstubs/src/com/android/mkstubs/FilterClassAdapter.java b/tools/mkstubs/src/com/android/mkstubs/FilterClassAdapter.java
index 6f570c7..e875f10 100644
--- a/tools/mkstubs/src/com/android/mkstubs/FilterClassAdapter.java
+++ b/tools/mkstubs/src/com/android/mkstubs/FilterClassAdapter.java
@@ -20,7 +20,6 @@
 
 import org.objectweb.asm.AnnotationVisitor;
 import org.objectweb.asm.Attribute;
-import org.objectweb.asm.ClassAdapter;
 import org.objectweb.asm.ClassVisitor;
 import org.objectweb.asm.FieldVisitor;
 import org.objectweb.asm.MethodVisitor;
@@ -30,14 +29,14 @@
  * A class visitor that filters out all members (fields, methods and inner classes) that are
  * either private, default-access or rejected by the {@link Filter}.
  */
-class FilterClassAdapter extends ClassAdapter {
+class FilterClassAdapter extends ClassVisitor {
 
     private final Logger mLog;
     private final Filter mFilter;
     private String mClassName;
 
     public FilterClassAdapter(ClassVisitor writer, Filter filter, Logger log) {
-        super(writer);
+        super(Opcodes.ASM4, writer);
         mFilter = filter;
         mLog = log;
     }
diff --git a/tools/mkstubs/src/com/android/mkstubs/sourcer/AnnotationSourcer.java b/tools/mkstubs/src/com/android/mkstubs/sourcer/AnnotationSourcer.java
index d2843a8..ea3ca67 100644
--- a/tools/mkstubs/src/com/android/mkstubs/sourcer/AnnotationSourcer.java
+++ b/tools/mkstubs/src/com/android/mkstubs/sourcer/AnnotationSourcer.java
@@ -17,11 +17,12 @@
 package com.android.mkstubs.sourcer;
 
 import org.objectweb.asm.AnnotationVisitor;
+import org.objectweb.asm.Opcodes;
 
 /**
  * An annotation visitor that generates Java source for an annotation.
  */
-class AnnotationSourcer implements AnnotationVisitor {
+class AnnotationSourcer extends AnnotationVisitor {
 
     private final String mOpenChar;
     private final String mCloseChar;
@@ -33,11 +34,13 @@
     }
 
     public AnnotationSourcer(Output output, boolean isArray) {
+        super(Opcodes.ASM4);
         mOutput = output;
         mOpenChar = isArray ? "[" : "(";
         mCloseChar = isArray ? "]" : ")";
     }
 
+    @Override
     public void visit(String name, Object value) {
         startOpen();
 
@@ -56,6 +59,7 @@
         }
     }
 
+    @Override
     public void visitEnd() {
         if (mNeedClose) {
             mOutput.write(mCloseChar);
@@ -63,18 +67,21 @@
         mOutput.write("\n");
     }
 
+    @Override
     public AnnotationVisitor visitAnnotation(String name, String desc) {
         startOpen();
-        
+
         mOutput.write("@%s", name);
         return this;
     }
 
+    @Override
     public AnnotationVisitor visitArray(String name) {
         startOpen();
         return new AnnotationSourcer(mOutput, true /*isArray*/);
     }
 
+    @Override
     public void visitEnum(String name, String desc, String value) {
         mOutput.write("/* annotation enum not supported: %s */\n", name);
     }
diff --git a/tools/mkstubs/src/com/android/mkstubs/sourcer/ClassSourcer.java b/tools/mkstubs/src/com/android/mkstubs/sourcer/ClassSourcer.java
index 3d95039..c005b0c 100644
--- a/tools/mkstubs/src/com/android/mkstubs/sourcer/ClassSourcer.java
+++ b/tools/mkstubs/src/com/android/mkstubs/sourcer/ClassSourcer.java
@@ -27,23 +27,25 @@
 /**
  * A class visitor that writes a java source.
  */
-public class ClassSourcer implements ClassVisitor {
+public class ClassSourcer extends ClassVisitor {
 
     private final Output mOutput;
     private final AccessSourcer mAccessSourcer;
     private String mClassName;
 
     public ClassSourcer(Output output) {
+        super(Opcodes.ASM4);
         mOutput = output;
         mAccessSourcer = new AccessSourcer(mOutput);
     }
-    
+
     /* Examples:
      * name = com/foo/MyClass
      * signature = null (if not generic)
      * superName = java/lang/Object
      * interfaces = [ java/lang/Runnable ... ]
      */
+    @Override
     public void visit(int version, int access, String name, String signature,
             String superName, String[] interfaces) {
 
@@ -63,13 +65,13 @@
             SignatureReader sigReader = new SignatureReader(signature);
             SignatureSourcer sigSourcer = new SignatureSourcer();
             sigReader.accept(sigSourcer);
-            
+
             if (sigSourcer.hasFormalsContent()) {
                 mOutput.write(sigSourcer.formalsToString());
             }
 
             mOutput.write(" extends %s", sigSourcer.getSuperClass().toString());
-            
+
         } else {
             // write non-generic super type
             mOutput.write(" extends %s", superName.replace('/', '.'));
@@ -87,35 +89,40 @@
                 need_sep = true;
             }
         }
-        
+
         // open class body
         mOutput.write(" {\n");
     }
 
+    @Override
     public void visitEnd() {
         mOutput.write("}\n");
     }
 
+    @Override
     public AnnotationVisitor visitAnnotation(String desc, boolean visible) {
         mOutput.write("@%s", desc);
         return new AnnotationSourcer(mOutput);
     }
 
+    @Override
     public void visitAttribute(Attribute attr) {
         mOutput.write("%s /* non-standard class attribute */ ", attr.type);
     }
 
 
+    @Override
     public FieldVisitor visitField(int access, String name, String desc, String signature,
             Object value) {
         // skip synthetic fields
         if ((access & Opcodes.ACC_SYNTHETIC) != 0) {
             return null;
         }
-        
+
         return new FieldSourcer(mOutput, access, name, desc, signature);
     }
 
+    @Override
     public MethodVisitor visitMethod(int access, String name, String desc, String signature,
             String[] exceptions) {
 
@@ -123,15 +130,18 @@
         return new MethodSourcer(mOutput, mClassName, access, name, desc, signature, exceptions);
     }
 
+    @Override
     public void visitInnerClass(String name, String outerName, String innerName, int access) {
         // Skip inner classes. This just indicates there's an inner class definition but
         // they are visited at the top level as separate classes.
     }
 
+    @Override
     public void visitOuterClass(String owner, String name, String desc) {
         // Skip outer classes.
     }
 
+    @Override
     public void visitSource(String source, String debug) {
         // Skip source information.
     }
diff --git a/tools/mkstubs/src/com/android/mkstubs/sourcer/FieldSourcer.java b/tools/mkstubs/src/com/android/mkstubs/sourcer/FieldSourcer.java
index 7f30a24..68eae71 100644
--- a/tools/mkstubs/src/com/android/mkstubs/sourcer/FieldSourcer.java
+++ b/tools/mkstubs/src/com/android/mkstubs/sourcer/FieldSourcer.java
@@ -19,13 +19,14 @@
 import org.objectweb.asm.AnnotationVisitor;
 import org.objectweb.asm.Attribute;
 import org.objectweb.asm.FieldVisitor;
+import org.objectweb.asm.Opcodes;
 import org.objectweb.asm.Type;
 import org.objectweb.asm.signature.SignatureReader;
 
 /**
- * A field visitor that generates Java source defining a field. 
+ * A field visitor that generates Java source defining a field.
  */
-class FieldSourcer implements FieldVisitor {
+class FieldSourcer extends FieldVisitor {
 
     private final Output mOutput;
     private final int mAccess;
@@ -34,6 +35,7 @@
     private final String mSignature;
 
     public FieldSourcer(Output output, int access, String name, String desc, String signature) {
+        super(Opcodes.ASM4);
         mOutput = output;
         mAccess = access;
         mName = name;
@@ -41,21 +43,24 @@
         mSignature = signature;
     }
 
+    @Override
     public AnnotationVisitor visitAnnotation(String desc, boolean visible) {
         mOutput.write("@%s", desc);
         return new AnnotationSourcer(mOutput);
     }
 
+    @Override
     public void visitAttribute(Attribute attr) {
         mOutput.write("%s /* non-standard attribute */ ", attr.type);
     }
 
+    @Override
     public void visitEnd() {
         // Need to write type and field name after the annotations and attributes.
 
         AccessSourcer as = new AccessSourcer(mOutput);
         as.write(mAccess, AccessSourcer.IS_FIELD);
-        
+
         if (mSignature == null) {
             mOutput.write(" %s", Type.getType(mDesc).getClassName());
         } else {
diff --git a/tools/mkstubs/src/com/android/mkstubs/sourcer/MethodSourcer.java b/tools/mkstubs/src/com/android/mkstubs/sourcer/MethodSourcer.java
index f58de32..26e8870 100644
--- a/tools/mkstubs/src/com/android/mkstubs/sourcer/MethodSourcer.java
+++ b/tools/mkstubs/src/com/android/mkstubs/sourcer/MethodSourcer.java
@@ -20,15 +20,16 @@
 import org.objectweb.asm.Attribute;
 import org.objectweb.asm.Label;
 import org.objectweb.asm.MethodVisitor;
+import org.objectweb.asm.Opcodes;
 import org.objectweb.asm.Type;
 import org.objectweb.asm.signature.SignatureReader;
 
 import java.util.ArrayList;
 
 /**
- * A method visitor that generates the Java source for a whole method. 
+ * A method visitor that generates the Java source for a whole method.
  */
-class MethodSourcer implements MethodVisitor {
+class MethodSourcer extends MethodVisitor {
 
     private final Output mOutput;
     private final int mAccess;
@@ -42,6 +43,7 @@
 
     public MethodSourcer(Output output, String className, int access, String name,
             String desc, String signature, String[] exceptions) {
+        super(Opcodes.ASM4);
         mOutput = output;
         mClassName = className;
         mAccess = access;
@@ -49,16 +51,16 @@
         mDesc = desc;
         mSignature = signature;
         mExceptions = exceptions;
-        
+
         mNeedDeclaration = true;
         mIsConstructor = "<init>".equals(name);
     }
-    
-    private void writeHeader() {        
+
+    private void writeHeader() {
         if (!mNeedDeclaration) {
             return;
         }
-        
+
         AccessSourcer as = new AccessSourcer(mOutput);
         as.write(mAccess, AccessSourcer.IS_METHOD);
 
@@ -68,19 +70,19 @@
             SignatureReader sigReader = new SignatureReader(mSignature);
             sigSourcer = new SignatureSourcer();
             sigReader.accept(sigSourcer);
-            
+
             if (sigSourcer.hasFormalsContent()) {
                 // dump formal template parameter definitions
                 mOutput.write(" %s", sigSourcer.formalsToString());
             }
         }
-        
+
         // output return type (constructor have no return type)
         if (!mIsConstructor) {
             // The signature overrides desc, if present
             if (sigSourcer == null || sigSourcer.getReturnType() == null) {
                 mOutput.write(" %s", Type.getReturnType(mDesc).getClassName());
-                
+
             } else {
                 mOutput.write(" %s", sigSourcer.getReturnType().toString());
             }
@@ -88,11 +90,11 @@
 
         // output name
         mOutput.write(" %s(", mIsConstructor ? mClassName : mName);
-            
+
         // output arguments. The signature overrides desc, if present
         if (mSignature == null) {
             Type[] types = Type.getArgumentTypes(mDesc);
-            
+
             for(int i = 0; i < types.length; i++) {
                 if (i > 0) {
                     mOutput.write(", ");
@@ -101,7 +103,7 @@
             }
         } else {
             ArrayList<SignatureSourcer> params = sigSourcer.getParameters();
-            
+
             for(int i = 0; i < params.size(); i++) {
                 if (i > 0) {
                     mOutput.write(", ");
@@ -114,7 +116,7 @@
         // output throwable exceptions
         if (mExceptions != null && mExceptions.length > 0) {
             mOutput.write(" throws ");
-            
+
             for (int i = 0; i < mExceptions.length; i++) {
                 if (i > 0) {
                     mOutput.write(", ");
@@ -128,106 +130,130 @@
         mNeedDeclaration = false;
     }
 
+    @Override
     public void visitCode() {
         writeHeader();
-        
+
         // write the stub itself
         mOutput.write("throw new RuntimeException(\"Stub\");");
     }
 
+    @Override
     public void visitEnd() {
         writeHeader();
         mOutput.write("\n}\n");
     }
 
+    @Override
     public AnnotationVisitor visitAnnotation(String desc, boolean visible) {
         mOutput.write("@%s", desc);
         return new AnnotationSourcer(mOutput);
     }
 
+    @Override
     public AnnotationVisitor visitAnnotationDefault() {
         // pass
         return null;
     }
 
+    @Override
     public void visitAttribute(Attribute attr) {
         mOutput.write("%s /* non-standard method attribute */ ", attr.type);
     }
 
+    @Override
     public void visitFieldInsn(int opcode, String owner, String name, String desc) {
         // pass
     }
 
+    @Override
     public void visitFrame(int type, int local, Object[] local2, int stack, Object[] stack2) {
         // pass
     }
 
+    @Override
     public void visitIincInsn(int var, int increment) {
         // pass
     }
 
+    @Override
     public void visitInsn(int opcode) {
         // pass
     }
 
+    @Override
     public void visitIntInsn(int opcode, int operand) {
         // pass
     }
 
+    @Override
     public void visitJumpInsn(int opcode, Label label) {
         // pass
     }
 
+    @Override
     public void visitLabel(Label label) {
         // pass
     }
 
+    @Override
     public void visitLdcInsn(Object cst) {
         // pass
     }
 
+    @Override
     public void visitLineNumber(int line, Label start) {
         // pass
     }
 
+    @Override
     public void visitLocalVariable(String name, String desc, String signature,
             Label start, Label end, int index) {
         // pass
     }
 
+    @Override
     public void visitLookupSwitchInsn(Label dflt, int[] keys, Label[] labels) {
         // pass
     }
 
+    @Override
     public void visitMaxs(int maxStack, int maxLocals) {
         // pass
     }
 
+    @Override
     public void visitMethodInsn(int opcode, String owner, String name, String desc) {
         // pass
     }
 
+    @Override
     public void visitMultiANewArrayInsn(String desc, int dims) {
         // pass
     }
 
+    @Override
     public AnnotationVisitor visitParameterAnnotation(int parameter, String desc, boolean visible) {
         // pass
         return null;
     }
 
+    @Override
     public void visitTableSwitchInsn(int min, int max, Label dflt, Label[] labels) {
         // pass
     }
 
+    @Override
     public void visitTryCatchBlock(Label start, Label end, Label handler, String type) {
         // pass
     }
 
+    @Override
     public void visitTypeInsn(int opcode, String type) {
         // pass
     }
 
+    @Override
     public void visitVarInsn(int opcode, int var) {
         // pass
     }
diff --git a/tools/mkstubs/src/com/android/mkstubs/sourcer/SignatureSourcer.java b/tools/mkstubs/src/com/android/mkstubs/sourcer/SignatureSourcer.java
index 7805d7d..ab90945 100644
--- a/tools/mkstubs/src/com/android/mkstubs/sourcer/SignatureSourcer.java
+++ b/tools/mkstubs/src/com/android/mkstubs/sourcer/SignatureSourcer.java
@@ -16,6 +16,7 @@
 
 package com.android.mkstubs.sourcer;
 
+import org.objectweb.asm.Opcodes;
 import org.objectweb.asm.Type;
 import org.objectweb.asm.signature.SignatureReader;
 import org.objectweb.asm.signature.SignatureVisitor;
@@ -36,12 +37,12 @@
  * <p/>
  * Note: When processing a method's signature, the signature order is the reverse of the source
  * order, e.g. the signature is written as "(parameters)return-type" where we want to generate
- * "return-type method-name (parameters)". To hanlde this case, the return-type and parameters
+ * "return-type method-name (parameters)". To handle this case, the return-type and parameters
  * are <em>not</em> output directly but are instead accumulated in internal variables that you can
  * get later using {@link #getReturnType()}, {@link #getParameters()}, {@link #getSuperClass()}
  * and {@link #formalsToString()}.
  */
-class SignatureSourcer implements SignatureVisitor {
+class SignatureSourcer extends SignatureVisitor {
 
     /**
      * Buffer used to construct the signature.
@@ -85,13 +86,14 @@
     private ArrayList<SignatureSourcer> mParameters = new ArrayList<SignatureSourcer>();
 
 
-    
+
     /**
      * Constructs a new {@link SignatureWriter} object.
      */
     public SignatureSourcer() {
+        super(Opcodes.ASM4);
     }
-    
+
     private StringBuilder getBuf() {
         if (mWritingFormals) {
             return mFormalsBuf;
@@ -117,7 +119,7 @@
     public SignatureSourcer getReturnType() {
         return mReturnType;
     }
-    
+
     /**
      * Will be non-empty if a parameters were processed
      * by {@link SignatureReader#accept(SignatureVisitor)}
@@ -125,19 +127,19 @@
     public ArrayList<SignatureSourcer> getParameters() {
         return mParameters;
     }
-    
+
     /**
-     * True if the signature contains formal type parameters, which are available 
+     * True if the signature contains formal type parameters, which are available
      * via {@link #formalsToString()} after calling {@link SignatureReader#accept(SignatureVisitor)}
      */
     public boolean hasFormalsContent() {
         return mFormalsBuf.length() > 0;
     }
-    
+
     public String formalsToString() {
         return mFormalsBuf.toString();
     }
-    
+
     /**
      * Will be non-null if a super class was processed
      * by {@link SignatureReader#accept(SignatureVisitor)}
@@ -150,6 +152,7 @@
     // Implementation of the SignatureVisitor interface
     // ------------------------------------------------------------------------
 
+    @Override
     public void visitFormalTypeParameter(final String name) {
         if (!mWritingFormals) {
             mWritingFormals = true;
@@ -161,16 +164,19 @@
         getBuf().append(" extends ");
     }
 
+    @Override
     public SignatureVisitor visitClassBound() {
-        // we don't differentiate between visiting a sub class or interface type 
+        // we don't differentiate between visiting a sub class or interface type
         return this;
     }
 
+    @Override
     public SignatureVisitor visitInterfaceBound() {
-        // we don't differentiate between visiting a sub class or interface type 
+        // we don't differentiate between visiting a sub class or interface type
         return this;
     }
 
+    @Override
     public SignatureVisitor visitSuperclass() {
         endFormals();
         SignatureSourcer sourcer = new SignatureSourcer();
@@ -179,10 +185,12 @@
         return sourcer;
     }
 
+    @Override
     public SignatureVisitor visitInterface() {
         return this;
     }
 
+    @Override
     public SignatureVisitor visitParameterType() {
         endFormals();
         SignatureSourcer sourcer = new SignatureSourcer();
@@ -190,6 +198,7 @@
         return sourcer;
     }
 
+    @Override
     public SignatureVisitor visitReturnType() {
         endFormals();
         SignatureSourcer sourcer = new SignatureSourcer();
@@ -198,29 +207,35 @@
         return sourcer;
     }
 
+    @Override
     public SignatureVisitor visitExceptionType() {
         getBuf().append('^');
         return this;
     }
 
+    @Override
     public void visitBaseType(final char descriptor) {
         getBuf().append(Type.getType(Character.toString(descriptor)).getClassName());
     }
 
+    @Override
     public void visitTypeVariable(final String name) {
         getBuf().append(name.replace('/', '.'));
     }
 
+    @Override
     public SignatureVisitor visitArrayType() {
         getBuf().append('[');
         return this;
     }
 
+    @Override
     public void visitClassType(final String name) {
         getBuf().append(name.replace('/', '.'));
         mArgumentStack *= 2;
     }
 
+    @Override
     public void visitInnerClassType(final String name) {
         endArguments();
         getBuf().append('.');
@@ -228,6 +243,7 @@
         mArgumentStack *= 2;
     }
 
+    @Override
     public void visitTypeArgument() {
         if (mArgumentStack % 2 == 0) {
             ++mArgumentStack;
@@ -238,6 +254,7 @@
         getBuf().append('*');
     }
 
+    @Override
     public SignatureVisitor visitTypeArgument(final char wildcard) {
         if (mArgumentStack % 2 == 0) {
             ++mArgumentStack;
@@ -258,6 +275,7 @@
         return this;
     }
 
+    @Override
     public void visitEnd() {
         endArguments();
     }
diff --git a/tools/mkstubs/src/com/android/mkstubs/stubber/ClassStubber.java b/tools/mkstubs/src/com/android/mkstubs/stubber/ClassStubber.java
index 8f9ae11..f66c7a7 100644
--- a/tools/mkstubs/src/com/android/mkstubs/stubber/ClassStubber.java
+++ b/tools/mkstubs/src/com/android/mkstubs/stubber/ClassStubber.java
@@ -18,19 +18,19 @@
 
 import org.objectweb.asm.AnnotationVisitor;
 import org.objectweb.asm.Attribute;
-import org.objectweb.asm.ClassAdapter;
 import org.objectweb.asm.ClassVisitor;
 import org.objectweb.asm.FieldVisitor;
 import org.objectweb.asm.MethodVisitor;
+import org.objectweb.asm.Opcodes;
 
 /**
  * A class visitor that generates stubs for all methods of the visited class.
  * Everything else is passed as-is.
  */
-public class ClassStubber extends ClassAdapter {
+public class ClassStubber extends ClassVisitor {
 
     public ClassStubber(ClassVisitor cv) {
-        super(cv);
+        super(Opcodes.ASM4, cv);
     }
 
     @Override
@@ -41,45 +41,45 @@
             String[] interfaces) {
         super.visit(version, access, name, signature, superName, interfaces);
     }
-    
+
     @Override
     public void visitEnd() {
         super.visitEnd();
     }
-    
+
     @Override
     public AnnotationVisitor visitAnnotation(String desc, boolean visible) {
         return super.visitAnnotation(desc, visible);
     }
-    
+
     @Override
     public void visitAttribute(Attribute attr) {
         super.visitAttribute(attr);
     }
-    
+
     @Override
     public MethodVisitor visitMethod(int access, String name, String desc, String signature,
             String[] exceptions) {
         MethodVisitor mw = super.visitMethod(access, name, desc, signature, exceptions);
         return new MethodStubber(mw, access, name, desc, signature, exceptions);
     }
-    
+
     @Override
     public FieldVisitor visitField(int access, String name, String desc, String signature,
             Object value) {
         return super.visitField(access, name, desc, signature, value);
     }
-    
+
     @Override
     public void visitInnerClass(String name, String outerName, String innerName, int access) {
         super.visitInnerClass(name, outerName, innerName, access);
     }
-    
+
     @Override
     public void visitOuterClass(String owner, String name, String desc) {
         super.visitOuterClass(owner, name, desc);
     }
-    
+
     @Override
     public void visitSource(String source, String debug) {
         super.visitSource(source, debug);
diff --git a/tools/mkstubs/src/com/android/mkstubs/stubber/MethodStubber.java b/tools/mkstubs/src/com/android/mkstubs/stubber/MethodStubber.java
index 1617809..89aa221 100644
--- a/tools/mkstubs/src/com/android/mkstubs/stubber/MethodStubber.java
+++ b/tools/mkstubs/src/com/android/mkstubs/stubber/MethodStubber.java
@@ -19,7 +19,6 @@
 import org.objectweb.asm.AnnotationVisitor;
 import org.objectweb.asm.Attribute;
 import org.objectweb.asm.Label;
-import org.objectweb.asm.MethodAdapter;
 import org.objectweb.asm.MethodVisitor;
 import org.objectweb.asm.Opcodes;
 
@@ -32,13 +31,13 @@
  * Note that constructors rewritten this way will probably fail with the runtime bytecode
  * verifier since no call to <code>super</code> is generated.
  */
-public class MethodStubber extends MethodAdapter {
+public class MethodStubber extends MethodVisitor {
 
     public MethodStubber(MethodVisitor mw,
             int access, String name, String desc, String signature, String[] exceptions) {
-        super(mw);
+        super(Opcodes.ASM4, mw);
     }
-    
+
     @Override
     public void visitCode() {
         Label l0 = new Label();
@@ -64,7 +63,7 @@
                 0);                                             // index
         mv.visitMaxs(3, 1); // maxStack, maxLocals
     }
-    
+
     @Override
     public void visitEnd() {
         super.visitEnd();
@@ -74,110 +73,110 @@
     public AnnotationVisitor visitAnnotation(String desc, boolean visible) {
         return super.visitAnnotation(desc, visible);
     }
-    
+
     @Override
     public AnnotationVisitor visitAnnotationDefault() {
         return super.visitAnnotationDefault();
     }
- 
+
     @Override
     public void visitAttribute(Attribute attr) {
         super.visitAttribute(attr);
     }
-    
+
     @Override
     public AnnotationVisitor visitParameterAnnotation(int parameter, String desc, boolean visible) {
         return super.visitParameterAnnotation(parameter, desc, visible);
     }
 
     // -- stuff that gets skipped
-    
+
     @Override
     public void visitFieldInsn(int opcode, String owner, String name, String desc) {
         // skip
     }
-    
+
     @Override
     public void visitFrame(int type, int local, Object[] local2, int stack, Object[] stack2) {
         // skip
     }
-    
+
     @Override
     public void visitIincInsn(int var, int increment) {
         // skip
     }
-    
+
     @Override
     public void visitInsn(int opcode) {
         // skip
     }
-    
+
     @Override
     public void visitIntInsn(int opcode, int operand) {
         // skip
     }
-    
+
     @Override
     public void visitJumpInsn(int opcode, Label label) {
         // skip
     }
-    
+
     @Override
     public void visitLabel(Label label) {
         // skip
     }
-    
+
     @Override
     public void visitLdcInsn(Object cst) {
         // skip
     }
-    
+
     @Override
     public void visitLineNumber(int line, Label start) {
         // skip
     }
-    
+
     @Override
     public void visitLocalVariable(String name, String desc, String signature,
             Label start, Label end, int index) {
         // skip
     }
-    
+
     @Override
     public void visitLookupSwitchInsn(Label dflt, int[] keys, Label[] labels) {
         // skip
     }
-    
+
     @Override
     public void visitMaxs(int maxStack, int maxLocals) {
         // skip
     }
-    
+
     @Override
     public void visitMethodInsn(int opcode, String owner, String name, String desc) {
         // skip
     }
-    
+
     @Override
     public void visitMultiANewArrayInsn(String desc, int dims) {
         // skip
     }
-    
+
     @Override
     public void visitTableSwitchInsn(int min, int max, Label dflt, Label[] labels) {
         // skip
     }
-    
+
     @Override
     public void visitTryCatchBlock(Label start, Label end, Label handler, String type) {
         // skip
     }
-    
+
     @Override
     public void visitTypeInsn(int opcode, String type) {
         // skip
     }
-    
+
     @Override
     public void visitVarInsn(int opcode, int var) {
         // skip
diff --git a/tools/templates/ic_launcher_hdpi.png b/tools/templates/ic_launcher_hdpi.png
index 8074c4c..96a442e 100644
--- a/tools/templates/ic_launcher_hdpi.png
+++ b/tools/templates/ic_launcher_hdpi.png
Binary files differ
diff --git a/tools/templates/ic_launcher_ldpi.png b/tools/templates/ic_launcher_ldpi.png
index 1095584..9923872 100644
--- a/tools/templates/ic_launcher_ldpi.png
+++ b/tools/templates/ic_launcher_ldpi.png
Binary files differ
diff --git a/tools/templates/ic_launcher_mdpi.png b/tools/templates/ic_launcher_mdpi.png
index a07c69f..359047d 100644
--- a/tools/templates/ic_launcher_mdpi.png
+++ b/tools/templates/ic_launcher_mdpi.png
Binary files differ
diff --git a/tools/templates/ic_launcher_xhdpi.png b/tools/templates/ic_launcher_xhdpi.png
new file mode 100644
index 0000000..71c6d76
--- /dev/null
+++ b/tools/templates/ic_launcher_xhdpi.png
Binary files differ