Merge "LayoutLib: render system/title/action bars." into honeycomb
diff --git a/core/java/android/app/INotificationManager.aidl b/core/java/android/app/INotificationManager.aidl
index 4d5238c..2420b84 100644
--- a/core/java/android/app/INotificationManager.aidl
+++ b/core/java/android/app/INotificationManager.aidl
@@ -33,6 +33,7 @@
     void enqueueToast(String pkg, ITransientNotification callback, int duration);
     void cancelToast(String pkg, ITransientNotification callback);
     void enqueueNotificationWithTag(String pkg, String tag, int id, in Notification notification, inout int[] idReceived);
+    void enqueueNotificationWithTagPriority(String pkg, String tag, int id, int priority, in Notification notification, inout int[] idReceived);
     void cancelNotificationWithTag(String pkg, String tag, int id);
 }
 
diff --git a/core/java/android/preference/SeekBarPreference.java b/core/java/android/preference/SeekBarPreference.java
index 658c2a7..037fb41 100644
--- a/core/java/android/preference/SeekBarPreference.java
+++ b/core/java/android/preference/SeekBarPreference.java
@@ -29,25 +29,30 @@
  */
 public class SeekBarPreference extends DialogPreference {
     private static final String TAG = "SeekBarPreference";
-    
+
     private Drawable mMyIcon;
 
     public SeekBarPreference(Context context, AttributeSet attrs) {
         super(context, attrs);
 
         setDialogLayoutResource(com.android.internal.R.layout.seekbar_dialog);
-        setPositiveButtonText(android.R.string.ok);
-        setNegativeButtonText(android.R.string.cancel);
-        
+        createActionButtons();
+
         // Steal the XML dialogIcon attribute's value
         mMyIcon = getDialogIcon();
         setDialogIcon(null);
     }
 
+    // Allow subclasses to override the action buttons
+    public void createActionButtons() {
+        setPositiveButtonText(android.R.string.ok);
+        setNegativeButtonText(android.R.string.cancel);
+    }
+
     @Override
     protected void onBindDialogView(View view) {
         super.onBindDialogView(view);
-        
+
         final ImageView iconView = (ImageView) view.findViewById(android.R.id.icon);
         if (mMyIcon != null) {
             iconView.setImageDrawable(mMyIcon);
diff --git a/core/java/android/preference/VolumePreference.java b/core/java/android/preference/VolumePreference.java
index 50ca71e..3b12780 100644
--- a/core/java/android/preference/VolumePreference.java
+++ b/core/java/android/preference/VolumePreference.java
@@ -236,14 +236,11 @@
             @Override
             public void onChange(boolean selfChange) {
                 super.onChange(selfChange);
-                if (mSeekBar != null) {
-                    int volume = System.getInt(mContext.getContentResolver(),
-                            System.VOLUME_SETTINGS[mStreamType], -1);
-                    // Works around an atomicity problem with volume updates
-                    // TODO: Fix the actual issue, probably in AudioService
-                    if (volume >= 0) {
-                        mSeekBar.setProgress(volume);
-                    }
+                if (mSeekBar != null && mAudioManager != null) {
+                    int volume = mAudioManager.isStreamMute(mStreamType) ?
+                            mAudioManager.getLastAudibleStreamVolume(mStreamType)
+                            : mAudioManager.getStreamVolume(mStreamType);
+                    mSeekBar.setProgress(volume);
                 }
             }
         };
diff --git a/core/java/android/view/ViewGroup.java b/core/java/android/view/ViewGroup.java
index 6981b9c..26f8627 100644
--- a/core/java/android/view/ViewGroup.java
+++ b/core/java/android/view/ViewGroup.java
@@ -2224,10 +2224,12 @@
         final View[] children = mChildren;
         for (int i = 0; i < count; i++) {
             final View child = children[i];
-            child.mRecreateDisplayList = (child.mPrivateFlags & INVALIDATED) == INVALIDATED;
-            child.mPrivateFlags &= ~INVALIDATED;
-            child.getDisplayList();
-            child.mRecreateDisplayList = false;
+            if ((child.mViewFlags & VISIBILITY_MASK) == VISIBLE || child.getAnimation() != null) {
+                child.mRecreateDisplayList = (child.mPrivateFlags & INVALIDATED) == INVALIDATED;
+                child.mPrivateFlags &= ~INVALIDATED;
+                child.getDisplayList();
+                child.mRecreateDisplayList = false;
+            }
         }
     }
 
diff --git a/core/java/android/view/VolumePanel.java b/core/java/android/view/VolumePanel.java
index e447dbb..2aa94dc 100644
--- a/core/java/android/view/VolumePanel.java
+++ b/core/java/android/view/VolumePanel.java
@@ -16,10 +16,17 @@
 
 package android.view;
 
-import android.bluetooth.HeadsetBase;
+import com.android.internal.R;
+
+import android.app.Dialog;
+import android.content.DialogInterface.OnDismissListener;
+import android.content.BroadcastReceiver;
 import android.content.Context;
+import android.content.DialogInterface;
 import android.content.Intent;
+import android.content.IntentFilter;
 import android.content.res.Resources;
+import android.graphics.drawable.Drawable;
 import android.media.AudioManager;
 import android.media.AudioService;
 import android.media.AudioSystem;
@@ -29,12 +36,16 @@
 import android.os.Handler;
 import android.os.Message;
 import android.os.Vibrator;
-import android.util.Config;
+import android.telephony.TelephonyManager;
 import android.util.Log;
 import android.widget.ImageView;
 import android.widget.ProgressBar;
+import android.widget.SeekBar;
 import android.widget.TextView;
 import android.widget.Toast;
+import android.widget.SeekBar.OnSeekBarChangeListener;
+
+import java.util.HashMap;
 
 /**
  * Handle the volume up and down keys.
@@ -43,7 +54,7 @@
  *
  * @hide
  */
-public class VolumePanel extends Handler
+public class VolumePanel extends Handler implements OnSeekBarChangeListener, View.OnClickListener
 {
     private static final String TAG = "VolumePanel";
     private static boolean LOGD = false;
@@ -68,62 +79,255 @@
     private static final int BEEP_DURATION = 150;
     private static final int MAX_VOLUME = 100;
     private static final int FREE_DELAY = 10000;
+    private static final int TIMEOUT_DELAY = 3000;
 
     private static final int MSG_VOLUME_CHANGED = 0;
     private static final int MSG_FREE_RESOURCES = 1;
     private static final int MSG_PLAY_SOUND = 2;
     private static final int MSG_STOP_SOUNDS = 3;
     private static final int MSG_VIBRATE = 4;
+    private static final int MSG_TIMEOUT = 5;
+    private static final int MSG_RINGER_MODE_CHANGED = 6;
 
-    private static final int RINGTONE_VOLUME_TEXT = com.android.internal.R.string.volume_ringtone;
-    private static final int MUSIC_VOLUME_TEXT = com.android.internal.R.string.volume_music;
-    private static final int INCALL_VOLUME_TEXT = com.android.internal.R.string.volume_call;
-    private static final int ALARM_VOLUME_TEXT = com.android.internal.R.string.volume_alarm;
-    private static final int UNKNOWN_VOLUME_TEXT = com.android.internal.R.string.volume_unknown;
-    private static final int NOTIFICATION_VOLUME_TEXT =
-            com.android.internal.R.string.volume_notification;
-    private static final int BLUETOOTH_INCALL_VOLUME_TEXT =
-            com.android.internal.R.string.volume_bluetooth_call;
+//    private static final int RINGTONE_VOLUME_TEXT = com.android.internal.R.string.volume_ringtone;
+//    private static final int MUSIC_VOLUME_TEXT = com.android.internal.R.string.volume_music;
+//    private static final int INCALL_VOLUME_TEXT = com.android.internal.R.string.volume_call;
+//    private static final int ALARM_VOLUME_TEXT = com.android.internal.R.string.volume_alarm;
+//    private static final int UNKNOWN_VOLUME_TEXT = com.android.internal.R.string.volume_unknown;
+//    private static final int NOTIFICATION_VOLUME_TEXT =
+//            com.android.internal.R.string.volume_notification;
+//    private static final int BLUETOOTH_INCALL_VOLUME_TEXT =
+//            com.android.internal.R.string.volume_bluetooth_call;
 
     protected Context mContext;
     private AudioManager mAudioManager;
     protected AudioService mAudioService;
     private boolean mRingIsSilent;
 
-    private final Toast mToast;
+    /** Dialog containing all the sliders */
+    private final Dialog mDialog;
+    /** Dialog's content view */
     private final View mView;
-    private final TextView mMessage;
-    private final TextView mAdditionalMessage;
-    private final ImageView mSmallStreamIcon;
-    private final ImageView mLargeStreamIcon;
-    private final ProgressBar mLevel;
+//    private final TextView mMessage;
+//    private final TextView mAdditionalMessage;
+//    private final ImageView mSmallStreamIcon;
+//    private final ImageView mLargeStreamIcon;
+//    private final ProgressBar mLevel;
+
+    /** Contains the sliders and their touchable icons */
+    private final ViewGroup mSliderGroup;
+    /** The button that expands the dialog to show all sliders */
+    private final View mMoreButton;
+    /** Dummy divider icon that needs to vanish with the more button */
+    private final View mDivider;
+
+    /** Currently active stream that shows up at the top of the list of sliders */
+    private int mActiveStreamType = -1;
+    /** All the slider controls mapped by stream type */
+    private HashMap<Integer,StreamControl> mStreamControls;
+
+    // List of stream types and their order
+    // RING and VOICE_CALL are hidden unless explicitly requested
+    private static final int [] STREAM_TYPES = {
+        AudioManager.STREAM_RING,
+        AudioManager.STREAM_VOICE_CALL,
+        AudioManager.STREAM_MUSIC,
+        AudioManager.STREAM_NOTIFICATION
+    };
+
+    // These icons need to correspond to the ones above.
+    private static final int [] STREAM_ICONS_NORMAL = {
+        R.drawable.ic_audio_phone,
+        R.drawable.ic_audio_phone,
+        R.drawable.ic_audio_vol,
+        R.drawable.ic_audio_notification,
+    };
+
+    // These icons need to correspond to the ones above.
+    private static final int [] STREAM_ICONS_MUTED = {
+        R.drawable.ic_audio_phone,
+        R.drawable.ic_audio_phone,
+        R.drawable.ic_audio_vol_mute,
+        R.drawable.ic_audio_notification_mute,
+    };
+
+    /** Object that contains data for each slider */
+    private class StreamControl {
+        int streamType;
+        ViewGroup group;
+        ImageView icon;
+        SeekBar seekbarView;
+        int iconRes;
+        int iconMuteRes;
+    }
 
     // Synchronize when accessing this
     private ToneGenerator mToneGenerators[];
     private Vibrator mVibrator;
 
-    public VolumePanel(Context context, AudioService volumeService) {
+    public VolumePanel(final Context context, AudioService volumeService) {
         mContext = context;
         mAudioManager = (AudioManager) context.getSystemService(Context.AUDIO_SERVICE);
         mAudioService = volumeService;
-        mToast = new Toast(context);
 
         LayoutInflater inflater = (LayoutInflater) context
                 .getSystemService(Context.LAYOUT_INFLATER_SERVICE);
-        View view = mView = inflater.inflate(com.android.internal.R.layout.volume_adjust, null);
-        mMessage = (TextView) view.findViewById(com.android.internal.R.id.message);
-        mAdditionalMessage =
-                (TextView) view.findViewById(com.android.internal.R.id.additional_message);
-        mSmallStreamIcon = (ImageView) view.findViewById(com.android.internal.R.id.other_stream_icon);
-        mLargeStreamIcon = (ImageView) view.findViewById(com.android.internal.R.id.ringer_stream_icon);
-        mLevel = (ProgressBar) view.findViewById(com.android.internal.R.id.level);
+        View view = mView = inflater.inflate(R.layout.volume_adjust, null);
+        mView.setOnTouchListener(new View.OnTouchListener() {
+            public boolean onTouch(View v, MotionEvent event) {
+                resetTimeout();
+                return true;
+            }
+        });
+        mSliderGroup = (ViewGroup) mView.findViewById(R.id.slider_group);
+        mMoreButton = (ImageView) mView.findViewById(R.id.expand_button);
+        mMoreButton.setOnClickListener(this);
+        mDivider = (ImageView) mView.findViewById(R.id.expand_button_divider);
+
+        mDialog = new Dialog(context, R.style.Theme_Panel_Volume);
+        mDialog.setTitle("Volume control"); // No need to localize
+        mDialog.setContentView(mView);
+        mDialog.setOnDismissListener(new OnDismissListener() {
+            public void onDismiss(DialogInterface dialog) {
+                mActiveStreamType = -1;
+            }
+        });
+        // Change some window properties
+        Window window = mDialog.getWindow();
+        window.setGravity(Gravity.TOP);
+        WindowManager.LayoutParams lp = window.getAttributes();
+        lp.token = null;
+        lp.type = WindowManager.LayoutParams.TYPE_SYSTEM_ALERT;
+        window.setAttributes(lp);
+        window.addFlags(WindowManager.LayoutParams.FLAG_ALT_FOCUSABLE_IM);
+
+//        mMessage = (TextView) view.findViewById(com.android.internal.R.id.message);
+//        mAdditionalMessage =
+//                (TextView) view.findViewById(com.android.internal.R.id.additional_message);
+//        mSmallStreamIcon = (ImageView) view.findViewById(com.android.internal.R.id.other_stream_icon);
+//        mLargeStreamIcon = (ImageView) view.findViewById(com.android.internal.R.id.ringer_stream_icon);
+//        mLevel = (ProgressBar) view.findViewById(com.android.internal.R.id.level);
 
         mToneGenerators = new ToneGenerator[AudioSystem.getNumStreamTypes()];
         mVibrator = new Vibrator();
+
+        listenToRingerMode();
+    }
+
+    private void listenToRingerMode() {
+        final IntentFilter filter = new IntentFilter();
+        filter.addAction(AudioManager.RINGER_MODE_CHANGED_ACTION);
+        mContext.registerReceiver(new BroadcastReceiver() {
+
+            public void onReceive(Context context, Intent intent) {
+                final String action = intent.getAction();
+
+                if (AudioManager.RINGER_MODE_CHANGED_ACTION.equals(action)) {
+                    removeMessages(MSG_RINGER_MODE_CHANGED);
+                    sendMessage(obtainMessage(MSG_RINGER_MODE_CHANGED));
+                }
+            }
+        }, filter);
+    }
+
+    private boolean isMuted(int streamType) {
+        return mAudioManager.isStreamMute(streamType);
+    }
+
+    private void createSliders() {
+        LayoutInflater inflater = (LayoutInflater) mContext
+                .getSystemService(Context.LAYOUT_INFLATER_SERVICE);
+        mStreamControls = new HashMap<Integer,StreamControl>(STREAM_TYPES.length);
+        for (int i = 0; i < STREAM_TYPES.length; i++) {
+            StreamControl sc = new StreamControl();
+            sc.streamType = STREAM_TYPES[i];
+            sc.group = (ViewGroup) inflater.inflate(R.layout.volume_adjust_item, null);
+            sc.group.setTag(sc);
+            sc.icon = (ImageView) sc.group.findViewById(R.id.stream_icon);
+            sc.icon.setOnClickListener(this);
+            sc.icon.setTag(sc);
+            sc.iconRes = STREAM_ICONS_NORMAL[i];
+            sc.iconMuteRes = STREAM_ICONS_MUTED[i];
+            sc.icon.setImageResource(sc.iconRes);
+            sc.seekbarView = (SeekBar) sc.group.findViewById(R.id.seekbar);
+            sc.seekbarView.setMax(mAudioManager.getStreamMaxVolume(STREAM_TYPES[i]));
+            sc.seekbarView.setOnSeekBarChangeListener(this);
+            sc.seekbarView.setTag(sc);
+            mStreamControls.put(STREAM_TYPES[i], sc);
+        }
+    }
+
+    private void reorderSliders(int activeStreamType) {
+        mSliderGroup.removeAllViews();
+
+        StreamControl active = mStreamControls.get(activeStreamType);
+        if (active == null) {
+            Log.e("VolumePanel", "Missing stream type! - " + activeStreamType);
+            mActiveStreamType = -1;
+        } else {
+            mSliderGroup.addView(active.group);
+            mActiveStreamType = activeStreamType;
+            active.group.setVisibility(View.VISIBLE);
+            updateSlider(active);
+        }
+
+        for (int i = 0; i < STREAM_TYPES.length; i++) {
+            // Skip the phone specific ones and the active one
+            final int streamType = STREAM_TYPES[i];
+            if (streamType == AudioManager.STREAM_RING
+                    || streamType == AudioManager.STREAM_VOICE_CALL
+                    || streamType == activeStreamType) {
+                continue;
+            }
+            StreamControl sc = mStreamControls.get(streamType);
+            mSliderGroup.addView(sc.group);
+            updateSlider(sc);
+        }
+    }
+
+    /** Update the mute and progress state of a slider */
+    private void updateSlider(StreamControl sc) {
+        sc.seekbarView.setProgress(mAudioManager.getLastAudibleStreamVolume(sc.streamType));
+        final boolean muted = isMuted(sc.streamType);
+        sc.icon.setImageResource(muted ? sc.iconMuteRes : sc.iconRes);
+        sc.seekbarView.setEnabled(!muted);
+    }
+
+    private boolean isExpanded() {
+        return mMoreButton.getVisibility() != View.VISIBLE;
+    }
+
+    private void expand() {
+        final int count = mSliderGroup.getChildCount();
+        for (int i = 0; i < count; i++) {
+            mSliderGroup.getChildAt(i).setVisibility(View.VISIBLE);
+        }
+        mMoreButton.setVisibility(View.INVISIBLE);
+        mDivider.setVisibility(View.INVISIBLE);
+    }
+
+    private void collapse() {
+        mMoreButton.setVisibility(View.VISIBLE);
+        mDivider.setVisibility(View.VISIBLE);
+        final int count = mSliderGroup.getChildCount();
+        for (int i = 1; i < count; i++) {
+            mSliderGroup.getChildAt(i).setVisibility(View.GONE);
+        }
+    }
+
+    private void updateStates() {
+        final int count = mSliderGroup.getChildCount();
+        for (int i = 0; i < count; i++) {
+            StreamControl sc = (StreamControl) mSliderGroup.getChildAt(i).getTag();
+            updateSlider(sc);
+        }
     }
 
     public void postVolumeChanged(int streamType, int flags) {
         if (hasMessages(MSG_VOLUME_CHANGED)) return;
+        if (mStreamControls == null) {
+            createSliders();
+        }
         removeMessages(MSG_FREE_RESOURCES);
         obtainMessage(MSG_VOLUME_CHANGED, streamType, flags).sendToTarget();
     }
@@ -137,6 +341,10 @@
 
         if (LOGD) Log.d(TAG, "onVolumeChanged(streamType: " + streamType + ", flags: " + flags + ")");
 
+        if (mActiveStreamType == -1) {
+            reorderSliders(streamType);
+        }
+
         if ((flags & AudioManager.FLAG_SHOW_UI) != 0) {
             onShowVolumeChanged(streamType, flags);
         }
@@ -154,12 +362,17 @@
 
         removeMessages(MSG_FREE_RESOURCES);
         sendMessageDelayed(obtainMessage(MSG_FREE_RESOURCES), FREE_DELAY);
+
+        resetTimeout();
     }
 
     protected void onShowVolumeChanged(int streamType, int flags) {
-        int index = mAudioService.getStreamVolume(streamType);
-        int message = UNKNOWN_VOLUME_TEXT;
-        int additionalMessage = 0;
+        int index = mAudioService.isStreamMute(streamType) ?
+                mAudioService.getLastAudibleStreamVolume(streamType)
+                : mAudioService.getStreamVolume(streamType);
+
+//        int message = UNKNOWN_VOLUME_TEXT;
+//        int additionalMessage = 0;
         mRingIsSilent = false;
 
         if (LOGD) {
@@ -168,31 +381,35 @@
         }
 
         // get max volume for progress bar
+
         int max = mAudioService.getStreamMaxVolume(streamType);
 
         switch (streamType) {
 
             case AudioManager.STREAM_RING: {
-                setRingerIcon();
-                message = RINGTONE_VOLUME_TEXT;
+//                setRingerIcon();
+//                message = RINGTONE_VOLUME_TEXT;
                 Uri ringuri = RingtoneManager.getActualDefaultRingtoneUri(
                         mContext, RingtoneManager.TYPE_RINGTONE);
                 if (ringuri == null) {
-                    additionalMessage =
-                        com.android.internal.R.string.volume_music_hint_silent_ringtone_selected;
+//                    additionalMessage =
+//                        com.android.internal.R.string.volume_music_hint_silent_ringtone_selected;
                     mRingIsSilent = true;
                 }
                 break;
             }
 
             case AudioManager.STREAM_MUSIC: {
-                message = MUSIC_VOLUME_TEXT;
+//                message = MUSIC_VOLUME_TEXT;
+                // Special case for when Bluetooth is active for music
                 if (mAudioManager.isBluetoothA2dpOn()) {
-                    additionalMessage =
-                        com.android.internal.R.string.volume_music_hint_playing_through_bluetooth;
-                    setLargeIcon(com.android.internal.R.drawable.ic_volume_bluetooth_ad2p);
+//                    additionalMessage =
+//                        com.android.internal.R.string.volume_music_hint_playing_through_bluetooth;
+//                    setLargeIcon(com.android.internal.R.drawable.ic_volume_bluetooth_ad2p);
+                    setMusicIcon(R.drawable.ic_audio_bt, R.drawable.ic_audio_bt_mute);
                 } else {
-                    setSmallIcon(index);
+                    setMusicIcon(R.drawable.ic_audio_vol, R.drawable.ic_audio_vol_mute);
+//                    setSmallIcon(index);
                 }
                 break;
             }
@@ -205,25 +422,25 @@
                  */
                 index++;
                 max++;
-                message = INCALL_VOLUME_TEXT;
-                setSmallIcon(index);
+//                message = INCALL_VOLUME_TEXT;
+//                setSmallIcon(index);
                 break;
             }
 
             case AudioManager.STREAM_ALARM: {
-                message = ALARM_VOLUME_TEXT;
-                setSmallIcon(index);
+//                message = ALARM_VOLUME_TEXT;
+//                setSmallIcon(index);
                 break;
             }
 
             case AudioManager.STREAM_NOTIFICATION: {
-                message = NOTIFICATION_VOLUME_TEXT;
-                setSmallIcon(index);
+//                message = NOTIFICATION_VOLUME_TEXT;
+//                setSmallIcon(index);
                 Uri ringuri = RingtoneManager.getActualDefaultRingtoneUri(
                         mContext, RingtoneManager.TYPE_NOTIFICATION);
                 if (ringuri == null) {
-                    additionalMessage =
-                        com.android.internal.R.string.volume_music_hint_silent_ringtone_selected;
+//                    additionalMessage =
+//                        com.android.internal.R.string.volume_music_hint_silent_ringtone_selected;
                     mRingIsSilent = true;
                 }
                 break;
@@ -237,34 +454,41 @@
                  */
                 index++;
                 max++;
-                message = BLUETOOTH_INCALL_VOLUME_TEXT;
-                setLargeIcon(com.android.internal.R.drawable.ic_volume_bluetooth_in_call);
+//                message = BLUETOOTH_INCALL_VOLUME_TEXT;
+//                setLargeIcon(com.android.internal.R.drawable.ic_volume_bluetooth_in_call);
                 break;
             }
         }
 
-        String messageString = Resources.getSystem().getString(message);
-        if (!mMessage.getText().equals(messageString)) {
-            mMessage.setText(messageString);
+//        String messageString = Resources.getSystem().getString(message);
+//        if (!mMessage.getText().equals(messageString)) {
+//            mMessage.setText(messageString);
+//        }
+//
+//        if (additionalMessage == 0) {
+//            mAdditionalMessage.setVisibility(View.GONE);
+//        } else {
+//            mAdditionalMessage.setVisibility(View.VISIBLE);
+//            mAdditionalMessage.setText(Resources.getSystem().getString(additionalMessage));
+//        }
+
+//        if (max != mLevel.getMax()) {
+//            mLevel.setMax(max);
+//        }
+//        mLevel.setProgress(index);
+
+        StreamControl sc = mStreamControls.get(streamType);
+        if (sc != null) {
+            sc.seekbarView.setProgress(index);
         }
 
-        if (additionalMessage == 0) {
-            mAdditionalMessage.setVisibility(View.GONE);
-        } else {
-            mAdditionalMessage.setVisibility(View.VISIBLE);
-            mAdditionalMessage.setText(Resources.getSystem().getString(additionalMessage));
+        if (!mDialog.isShowing()) {
+            mDialog.setContentView(mView);
+            // Showing dialog - use collapsed state
+            collapse();
+            mDialog.show();
         }
 
-        if (max != mLevel.getMax()) {
-            mLevel.setMax(max);
-        }
-        mLevel.setProgress(index);
-
-        mToast.setView(mView);
-        mToast.setDuration(Toast.LENGTH_SHORT);
-        mToast.setGravity(Gravity.TOP, 0, 0);
-        mToast.show();
-
         // Do a little vibrate if applicable (only when going into vibrate mode)
         if ((flags & AudioManager.FLAG_VIBRATE) != 0 &&
                 mAudioService.isStreamAffectedByRingerMode(streamType) &&
@@ -333,59 +557,72 @@
         }
     }
 
-    /**
-     * Makes the small icon visible, and hides the large icon.
-     *
-     * @param index The volume index, where 0 means muted.
-     */
-    private void setSmallIcon(int index) {
-        mLargeStreamIcon.setVisibility(View.GONE);
-        mSmallStreamIcon.setVisibility(View.VISIBLE);
-
-        mSmallStreamIcon.setImageResource(index == 0
-                ? com.android.internal.R.drawable.ic_volume_off_small
-                : com.android.internal.R.drawable.ic_volume_small);
-    }
+//    /**
+//     * Makes the small icon visible, and hides the large icon.
+//     *
+//     * @param index The volume index, where 0 means muted.
+//     */
+//    private void setSmallIcon(int index) {
+//        mLargeStreamIcon.setVisibility(View.GONE);
+//        mSmallStreamIcon.setVisibility(View.VISIBLE);
+//
+//        mSmallStreamIcon.setImageResource(index == 0
+//                ? com.android.internal.R.drawable.ic_volume_off_small
+//                : com.android.internal.R.drawable.ic_volume_small);
+//    }
+//
+//    /**
+//     * Makes the large image view visible with the given icon.
+//     *
+//     * @param resId The icon to display.
+//     */
+//    private void setLargeIcon(int resId) {
+//        mSmallStreamIcon.setVisibility(View.GONE);
+//        mLargeStreamIcon.setVisibility(View.VISIBLE);
+//        mLargeStreamIcon.setImageResource(resId);
+//    }
+//
+//    /**
+//     * Makes the ringer icon visible with an icon that is chosen
+//     * based on the current ringer mode.
+//     */
+//    private void setRingerIcon() {
+//        mSmallStreamIcon.setVisibility(View.GONE);
+//        mLargeStreamIcon.setVisibility(View.VISIBLE);
+//
+//        int ringerMode = mAudioService.getRingerMode();
+//        int icon;
+//
+//        if (LOGD) Log.d(TAG, "setRingerIcon(), ringerMode: " + ringerMode);
+//
+//        if (ringerMode == AudioManager.RINGER_MODE_SILENT) {
+//            icon = com.android.internal.R.drawable.ic_volume_off;
+//        } else if (ringerMode == AudioManager.RINGER_MODE_VIBRATE) {
+//            icon = com.android.internal.R.drawable.ic_vibrate;
+//        } else {
+//            icon = com.android.internal.R.drawable.ic_volume;
+//        }
+//        mLargeStreamIcon.setImageResource(icon);
+//    }
 
     /**
-     * Makes the large image view visible with the given icon.
-     *
-     * @param resId The icon to display.
+     * Switch between icons because Bluetooth music is same as music volume, but with
+     * different icons.
      */
-    private void setLargeIcon(int resId) {
-        mSmallStreamIcon.setVisibility(View.GONE);
-        mLargeStreamIcon.setVisibility(View.VISIBLE);
-        mLargeStreamIcon.setImageResource(resId);
-    }
-
-    /**
-     * Makes the ringer icon visible with an icon that is chosen
-     * based on the current ringer mode.
-     */
-    private void setRingerIcon() {
-        mSmallStreamIcon.setVisibility(View.GONE);
-        mLargeStreamIcon.setVisibility(View.VISIBLE);
-
-        int ringerMode = mAudioService.getRingerMode();
-        int icon;
-
-        if (LOGD) Log.d(TAG, "setRingerIcon(), ringerMode: " + ringerMode);
-
-        if (ringerMode == AudioManager.RINGER_MODE_SILENT) {
-            icon = com.android.internal.R.drawable.ic_volume_off;
-        } else if (ringerMode == AudioManager.RINGER_MODE_VIBRATE) {
-            icon = com.android.internal.R.drawable.ic_vibrate;
-        } else {
-            icon = com.android.internal.R.drawable.ic_volume;
+    private void setMusicIcon(int resId, int resMuteId) {
+        StreamControl sc = mStreamControls.get(AudioManager.STREAM_MUSIC);
+        if (sc != null) {
+            sc.iconRes = resId;
+            sc.iconMuteRes = resMuteId;
+            sc.icon.setImageResource(isMuted(sc.streamType) ? sc.iconMuteRes : sc.iconRes);
         }
-        mLargeStreamIcon.setImageResource(icon);
     }
 
     protected void onFreeResources() {
         // We'll keep the views, just ditch the cached drawable and hence
         // bitmaps
-        mSmallStreamIcon.setImageDrawable(null);
-        mLargeStreamIcon.setImageDrawable(null);
+//        mSmallStreamIcon.setImageDrawable(null);
+//        mLargeStreamIcon.setImageDrawable(null);
 
         synchronized (this) {
             for (int i = mToneGenerators.length - 1; i >= 0; i--) {
@@ -426,7 +663,55 @@
                 break;
             }
 
+            case MSG_TIMEOUT: {
+                if (mDialog.isShowing()) {
+                    mDialog.dismiss();
+                    mActiveStreamType = -1;
+                }
+                break;
+            }
+            case MSG_RINGER_MODE_CHANGED: {
+                if (mDialog.isShowing()) {
+                    updateStates();
+                }
+                break;
+            }
         }
     }
 
+    private void resetTimeout() {
+        removeMessages(MSG_TIMEOUT);
+        sendMessageDelayed(obtainMessage(MSG_TIMEOUT), TIMEOUT_DELAY);
+    }
+
+    public void onProgressChanged(SeekBar seekBar, int progress,
+            boolean fromUser) {
+        final Object tag = seekBar.getTag();
+        if (fromUser && tag instanceof StreamControl) {
+            StreamControl sc = (StreamControl) tag;
+            if (mAudioManager.getStreamVolume(sc.streamType) != progress) {
+                mAudioManager.setStreamVolume(sc.streamType, progress, 0);
+            }
+        }
+        resetTimeout();
+    }
+
+    public void onStartTrackingTouch(SeekBar seekBar) {
+    }
+
+    public void onStopTrackingTouch(SeekBar seekBar) {
+    }
+
+    public void onClick(View v) {
+        if (v == mMoreButton) {
+            expand();
+        } else if (v.getTag() instanceof StreamControl) {
+            StreamControl sc = (StreamControl) v.getTag();
+            mAudioManager.setRingerMode(mAudioManager.isSilentMode()
+                    ? AudioManager.RINGER_MODE_NORMAL : AudioManager.RINGER_MODE_SILENT);
+            // Expand the dialog if it hasn't been expanded yet.
+            if (!isExpanded()) expand();
+        }
+        resetTimeout();
+    }
 }
diff --git a/core/java/android/webkit/CookieManager.java b/core/java/android/webkit/CookieManager.java
index 1fea65a..9b0d4e0 100644
--- a/core/java/android/webkit/CookieManager.java
+++ b/core/java/android/webkit/CookieManager.java
@@ -519,11 +519,17 @@
         }
     }
 
-    synchronized void waitForCookieOperationsToComplete() {
-        while (pendingCookieOperations > 0) {
-            try {
-                wait();
-            } catch (InterruptedException e) { }
+    /**
+     * Waits for pending operations to completed.
+     * {@hide}  Too late to release publically.
+     */
+    public void waitForCookieOperationsToComplete() {
+        synchronized (this) {
+            while (pendingCookieOperations > 0) {
+                try {
+                    wait();
+                } catch (InterruptedException e) { }
+            }
         }
     }
 
diff --git a/core/java/com/android/internal/service/wallpaper/ImageWallpaper.java b/core/java/com/android/internal/service/wallpaper/ImageWallpaper.java
index 8fde247..38ec9c8 100644
--- a/core/java/com/android/internal/service/wallpaper/ImageWallpaper.java
+++ b/core/java/com/android/internal/service/wallpaper/ImageWallpaper.java
@@ -114,14 +114,11 @@
             mReceiver = new WallpaperObserver();
             registerReceiver(mReceiver, filter);
 
+            updateSurfaceSize(surfaceHolder);
+
             synchronized (mLock) {
                 updateWallpaperLocked();
             }
-            surfaceHolder.setFixedSize(getDesiredMinimumWidth(), getDesiredMinimumHeight());
-            // Used a fixed size surface, because we are special.  We can do
-            // this because we know the current design of window animations doesn't
-            // cause this to break.
-            //surfaceHolder.setSizeFromLayout();
         }
 
         @Override
@@ -131,6 +128,23 @@
         }
 
         @Override
+        public void onDesiredSizeChanged(int desiredWidth, int desiredHeight) {
+            onDesiredSizeChanged(desiredWidth, desiredHeight);
+            SurfaceHolder surfaceHolder = getSurfaceHolder();
+            if (surfaceHolder != null) {
+                updateSurfaceSize(surfaceHolder);
+            }
+        }
+
+        void updateSurfaceSize(SurfaceHolder surfaceHolder) {
+            surfaceHolder.setFixedSize(getDesiredMinimumWidth(), getDesiredMinimumHeight());
+            // Used a fixed size surface, because we are special.  We can do
+            // this because we know the current design of window animations doesn't
+            // cause this to break.
+            //surfaceHolder.setSizeFromLayout();
+        }
+
+        @Override
         public void onVisibilityChanged(boolean visible) {
             if (DEBUG) {
                 Log.d(TAG, "onVisibilityChanged: visible=" + visible);
diff --git a/core/java/com/android/internal/statusbar/StatusBarNotification.java b/core/java/com/android/internal/statusbar/StatusBarNotification.java
index cb791be..c03ff1a 100644
--- a/core/java/com/android/internal/statusbar/StatusBarNotification.java
+++ b/core/java/com/android/internal/statusbar/StatusBarNotification.java
@@ -63,8 +63,7 @@
         this.initialPid = initialPid;
         this.notification = notification;
 
-        this.priority = ((notification.flags & Notification.FLAG_ONGOING_EVENT) != 0)
-            ? PRIORITY_ONGOING : PRIORITY_NORMAL;
+        this.priority = PRIORITY_NORMAL;
     }
 
     public StatusBarNotification(Parcel in) {
diff --git a/core/res/res/drawable-hdpi/dialog_bottom_holo_dark.9.png b/core/res/res/drawable-hdpi/dialog_bottom_holo_dark.9.png
index 065cc9c..6c6252e 100644
--- a/core/res/res/drawable-hdpi/dialog_bottom_holo_dark.9.png
+++ b/core/res/res/drawable-hdpi/dialog_bottom_holo_dark.9.png
Binary files differ
diff --git a/core/res/res/drawable-hdpi/dialog_bottom_holo_light.9.png b/core/res/res/drawable-hdpi/dialog_bottom_holo_light.9.png
index 94decee..175c750 100644
--- a/core/res/res/drawable-hdpi/dialog_bottom_holo_light.9.png
+++ b/core/res/res/drawable-hdpi/dialog_bottom_holo_light.9.png
Binary files differ
diff --git a/core/res/res/drawable-hdpi/dialog_full_holo_dark.9.png b/core/res/res/drawable-hdpi/dialog_full_holo_dark.9.png
index 3b9e0cf..6e9abe65 100644
--- a/core/res/res/drawable-hdpi/dialog_full_holo_dark.9.png
+++ b/core/res/res/drawable-hdpi/dialog_full_holo_dark.9.png
Binary files differ
diff --git a/core/res/res/drawable-hdpi/dialog_full_holo_light.9.png b/core/res/res/drawable-hdpi/dialog_full_holo_light.9.png
index 0665b08..f96d09e 100644
--- a/core/res/res/drawable-hdpi/dialog_full_holo_light.9.png
+++ b/core/res/res/drawable-hdpi/dialog_full_holo_light.9.png
Binary files differ
diff --git a/core/res/res/drawable-hdpi/dialog_middle_holo_dark.9.png b/core/res/res/drawable-hdpi/dialog_middle_holo_dark.9.png
index dc62ab2..1f11f44 100644
--- a/core/res/res/drawable-hdpi/dialog_middle_holo_dark.9.png
+++ b/core/res/res/drawable-hdpi/dialog_middle_holo_dark.9.png
Binary files differ
diff --git a/core/res/res/drawable-hdpi/dialog_middle_holo_light.9.png b/core/res/res/drawable-hdpi/dialog_middle_holo_light.9.png
index e78e134..2e376cd 100644
--- a/core/res/res/drawable-hdpi/dialog_middle_holo_light.9.png
+++ b/core/res/res/drawable-hdpi/dialog_middle_holo_light.9.png
Binary files differ
diff --git a/core/res/res/drawable-hdpi/dialog_top_holo_dark.9.png b/core/res/res/drawable-hdpi/dialog_top_holo_dark.9.png
index ae223c8..73d56b7 100644
--- a/core/res/res/drawable-hdpi/dialog_top_holo_dark.9.png
+++ b/core/res/res/drawable-hdpi/dialog_top_holo_dark.9.png
Binary files differ
diff --git a/core/res/res/drawable-hdpi/dialog_top_holo_light.9.png b/core/res/res/drawable-hdpi/dialog_top_holo_light.9.png
index 7baced0..869decf 100644
--- a/core/res/res/drawable-hdpi/dialog_top_holo_light.9.png
+++ b/core/res/res/drawable-hdpi/dialog_top_holo_light.9.png
Binary files differ
diff --git a/core/res/res/drawable-hdpi/ic_audio_vol.png b/core/res/res/drawable-hdpi/ic_audio_vol.png
index cf3f3f5..6ea2693 100644
--- a/core/res/res/drawable-hdpi/ic_audio_vol.png
+++ b/core/res/res/drawable-hdpi/ic_audio_vol.png
Binary files differ
diff --git a/core/res/res/drawable-hdpi/ic_audio_vol_mute.png b/core/res/res/drawable-hdpi/ic_audio_vol_mute.png
index c4ac4ef..f7428c7 100644
--- a/core/res/res/drawable-hdpi/ic_audio_vol_mute.png
+++ b/core/res/res/drawable-hdpi/ic_audio_vol_mute.png
Binary files differ
diff --git a/core/res/res/drawable-hdpi/ic_sysbar_quicksettings.png b/core/res/res/drawable-hdpi/ic_sysbar_quicksettings.png
new file mode 100644
index 0000000..47b4ba2
--- /dev/null
+++ b/core/res/res/drawable-hdpi/ic_sysbar_quicksettings.png
Binary files differ
diff --git a/core/res/res/drawable-hdpi/scrubber_control_disabled_holo.png b/core/res/res/drawable-hdpi/scrubber_control_disabled_holo.png
index 401e904..d428e5a 100644
--- a/core/res/res/drawable-hdpi/scrubber_control_disabled_holo.png
+++ b/core/res/res/drawable-hdpi/scrubber_control_disabled_holo.png
Binary files differ
diff --git a/core/res/res/drawable-hdpi/scrubber_control_holo.png b/core/res/res/drawable-hdpi/scrubber_control_holo.png
index 175917e..a5fb73c 100644
--- a/core/res/res/drawable-hdpi/scrubber_control_holo.png
+++ b/core/res/res/drawable-hdpi/scrubber_control_holo.png
Binary files differ
diff --git a/core/res/res/drawable-hdpi/toast_frame.9.png b/core/res/res/drawable-hdpi/toast_frame.9.png
index 8f5d811..736683e 100644
--- a/core/res/res/drawable-hdpi/toast_frame.9.png
+++ b/core/res/res/drawable-hdpi/toast_frame.9.png
Binary files differ
diff --git a/core/res/res/drawable-mdpi/dialog_bottom_holo_dark.9.png b/core/res/res/drawable-mdpi/dialog_bottom_holo_dark.9.png
index 43e6528..9471615 100644
--- a/core/res/res/drawable-mdpi/dialog_bottom_holo_dark.9.png
+++ b/core/res/res/drawable-mdpi/dialog_bottom_holo_dark.9.png
Binary files differ
diff --git a/core/res/res/drawable-mdpi/dialog_bottom_holo_light.9.png b/core/res/res/drawable-mdpi/dialog_bottom_holo_light.9.png
index 09a1cd8..0502b93 100644
--- a/core/res/res/drawable-mdpi/dialog_bottom_holo_light.9.png
+++ b/core/res/res/drawable-mdpi/dialog_bottom_holo_light.9.png
Binary files differ
diff --git a/core/res/res/drawable-mdpi/dialog_full_holo_dark.9.png b/core/res/res/drawable-mdpi/dialog_full_holo_dark.9.png
index bd5f9e0..f364b2e 100644
--- a/core/res/res/drawable-mdpi/dialog_full_holo_dark.9.png
+++ b/core/res/res/drawable-mdpi/dialog_full_holo_dark.9.png
Binary files differ
diff --git a/core/res/res/drawable-mdpi/dialog_full_holo_light.9.png b/core/res/res/drawable-mdpi/dialog_full_holo_light.9.png
index 45e9712..91c2076 100644
--- a/core/res/res/drawable-mdpi/dialog_full_holo_light.9.png
+++ b/core/res/res/drawable-mdpi/dialog_full_holo_light.9.png
Binary files differ
diff --git a/core/res/res/drawable-mdpi/dialog_middle_holo_dark.9.png b/core/res/res/drawable-mdpi/dialog_middle_holo_dark.9.png
index 8082ddd9..92788c9 100644
--- a/core/res/res/drawable-mdpi/dialog_middle_holo_dark.9.png
+++ b/core/res/res/drawable-mdpi/dialog_middle_holo_dark.9.png
Binary files differ
diff --git a/core/res/res/drawable-mdpi/dialog_middle_holo_light.9.png b/core/res/res/drawable-mdpi/dialog_middle_holo_light.9.png
index ccdcd1d..74b66f8 100644
--- a/core/res/res/drawable-mdpi/dialog_middle_holo_light.9.png
+++ b/core/res/res/drawable-mdpi/dialog_middle_holo_light.9.png
Binary files differ
diff --git a/core/res/res/drawable-mdpi/dialog_top_holo_dark.9.png b/core/res/res/drawable-mdpi/dialog_top_holo_dark.9.png
index 79aaffb..f25cfb6 100644
--- a/core/res/res/drawable-mdpi/dialog_top_holo_dark.9.png
+++ b/core/res/res/drawable-mdpi/dialog_top_holo_dark.9.png
Binary files differ
diff --git a/core/res/res/drawable-mdpi/dialog_top_holo_light.9.png b/core/res/res/drawable-mdpi/dialog_top_holo_light.9.png
index 0740051..ff3ff06 100644
--- a/core/res/res/drawable-mdpi/dialog_top_holo_light.9.png
+++ b/core/res/res/drawable-mdpi/dialog_top_holo_light.9.png
Binary files differ
diff --git a/core/res/res/drawable-mdpi/ic_audio_vol.png b/core/res/res/drawable-mdpi/ic_audio_vol.png
index 049e92a..c32fdbc0d 100644
--- a/core/res/res/drawable-mdpi/ic_audio_vol.png
+++ b/core/res/res/drawable-mdpi/ic_audio_vol.png
Binary files differ
diff --git a/core/res/res/drawable-mdpi/ic_audio_vol_mute.png b/core/res/res/drawable-mdpi/ic_audio_vol_mute.png
index be71492..52611b6 100644
--- a/core/res/res/drawable-mdpi/ic_audio_vol_mute.png
+++ b/core/res/res/drawable-mdpi/ic_audio_vol_mute.png
Binary files differ
diff --git a/core/res/res/drawable-mdpi/ic_sysbar_quicksettings.png b/core/res/res/drawable-mdpi/ic_sysbar_quicksettings.png
new file mode 100644
index 0000000..7928104
--- /dev/null
+++ b/core/res/res/drawable-mdpi/ic_sysbar_quicksettings.png
Binary files differ
diff --git a/core/res/res/drawable-mdpi/scrubber_control_disabled_holo.png b/core/res/res/drawable-mdpi/scrubber_control_disabled_holo.png
index 26f018f..66dc001 100644
--- a/core/res/res/drawable-mdpi/scrubber_control_disabled_holo.png
+++ b/core/res/res/drawable-mdpi/scrubber_control_disabled_holo.png
Binary files differ
diff --git a/core/res/res/drawable-mdpi/scrubber_control_holo.png b/core/res/res/drawable-mdpi/scrubber_control_holo.png
index 242c16d..6e0e85a 100644
--- a/core/res/res/drawable-mdpi/scrubber_control_holo.png
+++ b/core/res/res/drawable-mdpi/scrubber_control_holo.png
Binary files differ
diff --git a/core/res/res/drawable-mdpi/toast_frame.9.png b/core/res/res/drawable-mdpi/toast_frame.9.png
index 08c4f86..1b06b7c8 100755
--- a/core/res/res/drawable-mdpi/toast_frame.9.png
+++ b/core/res/res/drawable-mdpi/toast_frame.9.png
Binary files differ
diff --git a/core/res/res/drawable-xlarge-nodpi/default_wallpaper.jpg b/core/res/res/drawable-xlarge-nodpi/default_wallpaper.jpg
index 8729fe1..7d7cdbb 100644
--- a/core/res/res/drawable-xlarge-nodpi/default_wallpaper.jpg
+++ b/core/res/res/drawable-xlarge-nodpi/default_wallpaper.jpg
Binary files differ
diff --git a/core/res/res/layout/volume_adjust.xml b/core/res/res/layout/volume_adjust.xml
index 18da85f..b0ca3e8 100644
--- a/core/res/res/layout/volume_adjust.xml
+++ b/core/res/res/layout/volume_adjust.xml
@@ -17,56 +17,48 @@
 <FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
     android:layout_width="wrap_content"
     android:layout_height="wrap_content"
-    android:background="@android:drawable/dialog_full_holo_dark"
     android:gravity="left">
 
     <LinearLayout
-        android:layout_width="416dip"
-        android:layout_height="wrap_content"
-        android:paddingLeft="16dip"
-        android:paddingTop="16dip"
-        android:paddingRight="16dip"
-        android:paddingBottom="8dip"
-        android:orientation="vertical">
-
-    <LinearLayout
         android:layout_width="wrap_content"
         android:layout_height="wrap_content"
-        android:layout_marginBottom="8dip"
-        android:gravity="left">
-    
+        android:layout_marginTop="80dip"
+        android:background="@android:drawable/dialog_full_holo_dark"
+        android:orientation="horizontal"
+        >
+
+        <LinearLayout
+            android:id="@+id/slider_group"
+            android:layout_width="wrap_content"
+            android:layout_height="wrap_content"
+            android:orientation="vertical"
+            >
+            <!-- Sliders go here -->
+        </LinearLayout>
+
         <ImageView
-            android:id="@+id/other_stream_icon"
+            android:id="@+id/expand_button_divider"
+            android:src="?attr/dividerVertical"
+            android:layout_width="wrap_content"
+            android:layout_height="32dip"
+            android:scaleType="fitXY"
+            android:layout_gravity="top"
+            android:layout_marginTop="16dip"
+            android:layout_marginBottom="16dip"
+            />
+
+        <ImageView
+            android:id="@+id/expand_button"
             android:layout_width="wrap_content"
             android:layout_height="wrap_content"
-            android:layout_marginRight="16dip" />
-
-        <TextView
-            android:layout_width="wrap_content"
-            android:layout_height="wrap_content"
-            android:id="@+id/message"
-            android:textAppearance="?android:attr/textAppearanceMedium" />
-
+            android:layout_gravity="top"
+            android:padding="16dip"
+            android:background="?attr/selectableItemBackground"
+            android:src="@drawable/ic_sysbar_quicksettings"
+            />
+        
     </LinearLayout>
 
-    <TextView
-        android:layout_width="wrap_content"
-        android:layout_height="wrap_content"
-        android:id="@+id/additional_message"
-        android:textAppearance="?android:attr/textAppearanceSmall" />
-
-    <ImageView
-        android:id="@+id/ringer_stream_icon"
-        android:layout_width="wrap_content"
-        android:layout_height="wrap_content"
-        android:layout_marginTop="14dip" />
-
-    <ProgressBar
-        style="?android:attr/progressBarStyleHorizontal"
-        android:id="@+id/level"
-        android:layout_width="match_parent"
-        android:layout_height="wrap_content" />
-    </LinearLayout>
 </FrameLayout>
 
 
diff --git a/core/res/res/layout/volume_adjust_item.xml b/core/res/res/layout/volume_adjust_item.xml
new file mode 100644
index 0000000..e841d87
--- /dev/null
+++ b/core/res/res/layout/volume_adjust_item.xml
@@ -0,0 +1,45 @@
+<?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="80dip"
+    android:orientation="horizontal"
+    android:layout_marginTop="8dip"
+    android:layout_marginBottom="8dip"
+    android:gravity="left|center_vertical">
+
+    <ImageView
+        android:id="@+id/stream_icon"
+        android:layout_width="wrap_content"
+        android:layout_height="wrap_content"
+        android:padding="16dip"
+        android:layout_marginLeft="8dip"
+        android:background="?attr/selectableItemBackground"
+        />
+
+    <SeekBar
+        style="?android:attr/seekBarStyle"
+        android:id="@+id/seekbar"
+        android:layout_width="300dip"
+        android:layout_height="wrap_content"
+        android:padding="16dip"
+        android:layout_marginLeft="8dip"
+        android:layout_marginRight="8dip" />
+
+</LinearLayout>
+
+
diff --git a/core/res/res/values/styles.xml b/core/res/res/values/styles.xml
index e2751bd..5700641 100644
--- a/core/res/res/values/styles.xml
+++ b/core/res/res/values/styles.xml
@@ -208,6 +208,11 @@
         <item name="windowExitAnimation">@anim/fade_out</item>
     </style>
 
+    <!-- Window animations used for volume panel. -->
+    <style name="Animation.VolumePanel">
+        <item name="windowEnterAnimation">@null</item>
+        <item name="windowExitAnimation">@anim/fade_out</item>
+    </style>
     <!-- Status Bar Styles -->
 
     <style name="TextAppearance.StatusBar">
diff --git a/core/res/res/values/themes.xml b/core/res/res/values/themes.xml
index 38b068e..6d5b482 100644
--- a/core/res/res/values/themes.xml
+++ b/core/res/res/values/themes.xml
@@ -730,6 +730,11 @@
         <item name="android:windowCloseOnTouchOutside">false</item>
     </style>
 
+    <style name="Theme.Panel.Volume">
+        <item name="android:windowAnimationStyle">@android:style/Animation.VolumePanel</item>
+        <item name="android:windowCloseOnTouchOutside">true</item>
+    </style>
+
     <!-- Default theme with an Action Bar. -->
     <style name="Theme.WithActionBar">
         <item name="android:windowActionBar">true</item>
diff --git a/data/sounds/effects/ogg/Effect_Tick.ogg b/data/sounds/effects/ogg/Effect_Tick.ogg
index b379019..a997fe1 100644
--- a/data/sounds/effects/ogg/Effect_Tick.ogg
+++ b/data/sounds/effects/ogg/Effect_Tick.ogg
Binary files differ
diff --git a/docs/html/guide/topics/fundamentals/index.jd b/docs/html/guide/topics/fundamentals/index.jd
new file mode 100644
index 0000000..de2e312
--- /dev/null
+++ b/docs/html/guide/topics/fundamentals/index.jd
@@ -0,0 +1,496 @@
+page.title=Application Fundamentals
+@jd:body
+
+<div id="qv-wrapper">
+<div id="qv">
+
+<h2>Quickview</h2>
+<ul>
+  <li>Android applications are composed of one or more application components (activities,
+services, content providers, and broadcast receivers)</li>
+  <li>Each component performs a different role in the overall application behavior, and each
+one can be activated individually (even by other applications)</li>
+  <li>The manifest file must declare all components in the application and should also declare
+all application requirements, such as the minimum version of Android required and any hardware
+configurations required</li>
+  <li>Non-code application resources (images, strings, layout files, etc.) should include
+alternatives for different device configurations (such as different strings for different
+languages and different layouts for different screen sizes)</li>
+</ul>
+
+
+<h2>In this document</h2>
+<ol>
+<li><a href="#Components">Application Components</a>
+  <ol>
+    <li><a href="#ActivatingComponents">Activating components</a></li>
+  </ol>
+</li>
+<li><a href="#Manifest">The Manifest File</a>
+  <ol>
+    <li><a href="#DeclaringComponents">Declaring components</a></li>
+    <li><a href="#DeclaringRequirements">Declaring application requirements</a></li>
+  </ol>
+</li>
+<li><a href="#Resources">Application Resources</a></li>
+</ol>
+</div>
+</div>
+
+<p>Android applications are written in the Java programming language. The Android SDK tools compile
+the code&mdash;along with any data and resource files&mdash;into an <i>Android package</i>, an
+archive file with an {@code .apk} suffix. All the code in a single {@code .apk} file is considered
+to be one application and is the file that Android-powered devices use to install the
+application.</p>
+
+<p>Once installed on a device, each Android application lives in its own security sandbox: </p>
+
+<ul>
+ <li>The Android operating system is a multi-user Linux system in which each application is a
+different user.</li>
+
+<li>By default, the system assigns each application a unique Linux user ID (the ID is used only by
+the system and is unknown to the application). The system sets permissions for all the files in an
+application so that only the user ID assigned to that application can access them. </li>
+
+<li>Each process has its own virtual machine (VM), so an application's code runs in isolation from
+other applications.</li>
+
+<li>By default, every application runs in its own Linux process. Android starts the process when any
+of the application's components need to be executed, then shuts down the process when it's no longer
+needed or when the system must recover memory for other applications.</li>
+</ul>
+
+<p>In this way, the Android system implements the <em>principle of least privilege</em>. That is,
+each application, by default, has access only to the components that it requires to do its work and
+no more. This creates a very secure environment in which an application cannot access parts of
+the system for which it is not given permission.</p>
+
+<p>However, there are ways for an application to share data with other applications and for an
+application to access system services:</p>
+
+<ul>
+  <li>It's possible to arrange for two applications to share the same Linux user ID, in which case
+they are able to access each other's files.  To conserve system resources, applications with the
+same user ID can also arrange to run in the same Linux process and share the same VM (the
+applications must also be signed with the same certificate).</li>
+  <li>An application can request permission to access device data such as the user's
+contacts, SMS messages, the mountable storage (SD card), camera, Bluetooth, and more. All
+application permissions must be granted by the user at install time.</li>
+</ul>
+
+<p>That covers the basics regarding how an Android application exists within the system. The rest of
+this document introduces you to:</p>
+<ul>
+  <li>The core framework components that define your application.</li>
+  <li>The manifest file in which you declare components and required device features for your
+application.</li>
+  <li>Resources that are separate from the application code and allow your application to
+gracefully optimize its behavior for a variety of device configurations.</li>
+</ul>
+
+<p class="note"><strong>Tip:</strong> If you're new to Android development, we suggest that you
+follow the Beginner's Path link at the bottom of this page. For each document in the Application
+Fundamentals, the Beginner's Path points you to the document we suggest you read next, in order
+to get up to speed on the core Android concepts.</p>
+
+
+
+<h2 id="Components">Application Components</h2>
+
+<p>Application components are the essential building blocks of an Android application. Each
+component is a different point through which the system can enter your application. Not all
+components are actual entry points for the user and some depend on each other, but each one exists
+as its own entity and plays a specific role&mdash;each one is a unique building block that
+helps define your application's overall behavior.</p>
+
+<p>There are four different types of application components. Each type serves a distinct purpose
+and has a distinct lifecycle that defines how the component is created and destroyed.</p>
+
+<p>Here are the four types of application components:</p>
+
+<dl>
+
+<dt><b>Activities</b></dt>
+
+<dd>An <i>activity</i> represents a single screen with a user interface. For example,
+an email application might have one activity that shows a list of new
+emails, another activity to compose an email, and another activity for reading emails. Although
+the activities work together to form a cohesive user experience in the email application, each one
+is independent of the others. As such, a different application can start any one of these
+activities (if the email application allows it). For example, a camera application can start the
+activity in the email application that composes new mail, in order for the user to share a picture.
+
+<p>An activity is implemented as a subclass of {@link android.app.Activity} and you can learn more
+about it in the <a href="{@docRoot}guide/topics/fundamentals/activities.html">Activities</a>
+developer guide.</p>
+</dd>
+
+
+<dt><b>Services</b></dt>
+
+<dd>A <i>service</i> is a component that runs in the background to perform long-running
+operations or to perform work for remote processes. A service
+does not provide a user interface. For example, a service might play music in the background while
+the user is in a different application, or it might fetch data over the network without
+blocking user interaction with an activity. Another component, such as an activity, can start the
+service and let it run or bind to it in order to interact with it.
+
+<p>A service is implemented as a subclass of {@link android.app.Service} and you can learn more
+about it in the <a href="{@docRoot}guide/topics/fundamentals/services.html">Services</a> developer
+guide.</p>
+</dd>
+
+
+<dt><b>Content providers</b></dt>
+
+<dd>A <i>content provider</i> manages a shared set of application data. You can store the data in
+the file system, an SQLite database, on the web, or any other persistent storage location your
+application can access. Through the content provider, other applications can query or even modify
+the data (if the content provider allows it). For example, the Android system provides a content
+provider that manages the user's contact information. As such, any application with the proper
+permissions can query part of the content provider (such as {@link
+android.provider.ContactsContract.Data}) to read and write information about a particular person.
+
+<p>Content providers are also useful for reading and writing data that is private to your
+application and not shared. For example, the <a
+href="{@docRoot}resources/samples/NotePad/index.html">Note Pad</a> sample application uses a
+content provider to save notes.</p>
+
+<p>A content provider is implemented as a subclass of {@link android.content.ContentProvider}
+and must implement a standard set of APIs that enable other applications to perform
+transactions. For more information, see the <a
+href="{@docRoot}guide/topics/providers/content-providers.html">Content Providers</a> developer
+guide.</p>
+</dd>
+
+
+<dt><b>Broadcast receivers</b></dt>
+
+<dd>A <i>broadcast receiver</i> is a component that responds to system-wide broadcast
+announcements.  Many broadcasts originate from the system&mdash;for example, a broadcast announcing
+that the screen has turned off, the battery is low, or a picture was captured.
+Applications can also initiate broadcasts&mdash;for example, to let other applications know that
+some data has been downloaded to the device and is available for them to use. Although broadcast
+receivers don't display a user interface, they may <a
+href="{@docRoot}guide/topics/ui/notifiers/notifications.html">create a status bar notification</a>
+to alert the user when a broadcast event occurs. More commonly, though, a broadcast receiver is
+just a "gateway" to other components and is intended to do a very minimal amount of work. For
+instance, it might initiate a service to perform some work based on the event.
+
+<p>A broadcast receiver is implemented as a subclass of {@link android.content.BroadcastReceiver}
+and each broadcast is delivered as an {@link android.content.Intent} object. For more information,
+see the <a
+href="{@docRoot}guide/topics/intents/intents-filters.html">Intents and Intent Filters</a>
+developer guide.</p>
+</dd>
+
+</dl>
+
+
+
+<p>A unique aspect of the Android system design is that any application can start another
+application’s component. For example, if you want the user to capture a
+photo with the device camera, there's probably another application that does that and your
+application can use it, instead of developing an activity to capture a photo yourself. You don't
+need to incorporate or even link to the code from the camera application.
+Instead, you can simply start the activity in the camera application that captures a
+photo. When complete, the photo is even returned to your application so you can use it. To the user,
+it seems as if the camera is actually a part of your application.</p>
+
+<p>When the system starts a component, it starts the process for that application (if it's not
+already running) and instantiates the classes needed for the component. For example, if your
+application starts the activity in the camera application that captures a photo, that activity
+runs in the process that belongs to the camera application, not in your application's process.
+Therefore, unlike applications on most other systems, Android applications don't have a single entry
+point (there's no {@code main()} function, for example).</p>
+
+<p>Because the system runs each application in a separate process with file permissions that
+restrict access to other applications, your application cannot directly activate a component from
+another application. The Android system, however, can. So, to activate a component in
+another application, you must deliver a message to the system that specifies your <em>intent</em> to
+start a particular component. The system then activates the component for you.</p>
+
+
+<h3 id="ActivatingComponents">Activating Components</h3>
+
+<p>Three of the four component types&mdash;activities, services, and
+broadcast receivers&mdash;are activated by an asynchronous message called an <em>intent</em>.
+Intents bind individual components to each other at runtime (you can think of them
+as the messengers that request an action from other components), whether the component belongs
+to your application or another.</p>
+
+<p>An intent is defined by an {@link android.content.Intent} object, which defines a message to
+activate either a specific component or a specific <em>type</em> of component&mdash;an intent
+can be either explicit or implicit, respectively.</p>
+
+<p>For activities and services, an intent defines the action to perform (for example, to "view" or
+"send" something) and may specify the URI of the data to act on (among other things that the
+component being started might need to know). For example, an intent might convey a request for an
+activity to present an image to the user or to open a web page. In some cases, you can start a
+component in order to receive a result, in which case, the component that is started also returns
+the result in an {@link android.content.Intent} object (for example, you can issue an intent to let
+the user pick a personal contact and have it returned to you&mdash;the return intent includes a
+URI pointing to the chosen contact). For broadcast receivers, the intent simply defines the
+announcement being broadcast (for example, a broadcast to indicate the device battery is low
+includes only a known action string that indicates "battery is low").</p>
+
+<p>The remaining type of component, content provider, is not activated by intents. Rather, it is
+activated when targeted by a request from a {@link android.content.ContentResolver}. The content
+resolver handles all direct transactions with the content provider so that the component that's
+performing transactions with the provider doesn't need to and instead calls methods on the {@link
+android.content.ContentResolver} object. This leaves a layer of abstraction between the content
+provider and the component requesting information (for security).</p>
+
+<p>For more information about using intents, see the <a
+href="{@docRoot}guide/topics/intents/intents-filters.html">Intents and
+Intent Filters</a> document. More information about activating specific components is also provided
+in the <a href="{@docRoot}guide/topics/fundamentals/activities.html">Activities</a>, <a
+href="{@docRoot}guide/topics/fundamentals/services.html">Services</a>, and <a
+href="{@docRoot}guide/topics/providers/content-providers.html">Content Providers</a> developer
+guides.</p>
+
+
+<h2 id="Manifest">The Manifest File</h2>
+
+<p>Before the Android system can start an application component, the system must know that the
+component exists by reading the application's {@code AndroidManifest.xml} file (the "manifest"
+file). Your application must declare all its components in this file, which must be at the root of
+the application project directory.</p>
+
+<p>The manifest does a number of things in addition to declaring the application's components,
+such as:</p>
+<ul>
+  <li>Identify any user permissions the application requires, such as Internet access or
+read-access to the user's contacts.</li>
+  <li>Declare the minimum <a href="{@docRoot}guide/appendix/api-levels.html">API Level</a>
+required by the application, based on which APIs the application uses.</li>
+  <li>Declare hardware and software features used or required by the application, such as a camera,
+bluetooth services, or a multitouch screen.</li>
+  <li>API libraries the application needs to be linked against (other than the Android framework
+APIs), such as the <a
+href="http://code.google.com/android/add-ons/google-apis/maps-overview.html">Google Maps
+library</a>.</li>
+  <li>And more</li>
+</ul>
+
+
+<h3 id="DeclaringComponents">Declaring components</h3>
+
+<p>The primary task of the manifest is to inform the system about the application's components. For
+example, a manifest file can declare an activity as follows: </p>
+
+<pre>
+&lt;?xml version="1.0" encoding="utf-8"?&gt;
+&lt;manifest ... &gt;
+    &lt;application android:icon="@drawable/app_icon.png" ... &gt;
+        &lt;activity android:name="com.example.project.ExampleActivity"
+                  android:label="@string/example_label" ... &gt;
+        &lt;/activity&gt;
+        ...
+    &lt;/application&gt;
+&lt;/manifest&gt;</pre>
+
+<p>In the <code><a
+href="{@docRoot}guide/topics/manifest/application-element.html">&lt;application&gt;</a></code>
+element, the {@code android:icon} attribute points to resources for an icon that identifies the
+application.</p>
+
+<p>In the <code><a
+href="{@docRoot}guide/topics/manifest/activity-element.html">&lt;activity&gt;</a></code> element,
+the {@code android:name} attribute specifies the fully qualified class name of the {@link
+android.app.Activity} subclass and the {@code android:label} attributes specifies a string
+to use as the user-visible label for the activity.</p>
+
+<p>You must declare all application components this way:</p>
+<ul>
+  <li><code><a
+href="{@docRoot}guide/topics/manifest/activity-element.html">&lt;activity&gt;</a></code> elements
+for activities</li>
+  <li><code><a
+href="{@docRoot}guide/topics/manifest/service-element.html">&lt;service&gt;</a></code> elements for
+services</li>
+  <li><code><a
+href="{@docRoot}guide/topics/manifest/receiver-element.html">&lt;receiver&gt;</a></code> elements
+for broadcast receivers</li>
+  <li><code><a
+href="{@docRoot}guide/topics/manifest/provider-element.html">&lt;provider&gt;</a></code> elements
+for content providers</li>
+</ul>
+
+<p>Activities, services, and content providers that you include in your source but do not declare
+in the manifest are not visible to the system and, consequently, can never run.  However,
+broadcast
+receivers can be either declared in the manifest or created dynamically in code (as
+{@link android.content.BroadcastReceiver} objects) and registered with the system by calling
+{@link android.content.Context#registerReceiver registerReceiver()}.</p>
+
+<p>For more about how to structure the manifest file for your application, see the <a
+href="{@docRoot}guide/topics/manifest/manifest-intro.html">The AndroidManifest.xml File</a>
+documentation. </p>
+
+
+
+<h3 id="DeclaringComponentCapabilities">Declaring component capabilities</h3>
+
+<p>As discussed above, in <a href="#ActivatingComponents">Activating Components</a>, you can use an
+{@link android.content.Intent} to start activities, services, and broadcast receivers. You can do so
+by explicitly naming the target component (using the component class name) in the intent. However,
+the real power of intents lies in the concept of intent actions. With intent actions, you simply
+describe the type of action you want to perform (and optionally, the data upon which you’d like to
+perform the action) and allow the system to find a component on the device that can perform the
+action and start it. If there are multiple components that can perform the action described by the
+intent, then the user selects which one to use.</p>
+
+<p>The way the system identifies the components that can respond to an intent is by comparing the
+intent received to the <i>intent filters</i> provided in the manifest file of other applications on
+the device.</p>
+
+<p>When you declare a component in your application's manifest, you can optionally include
+intent filters that declare the capabilities of the component so it can respond to intents
+from other applications. You can declare an intent filter for your component by
+adding an <a href="{@docRoot}guide/topics/manifest/intent-filter-element.html">{@code
+&lt;intent-filter&gt;}</a> element as a child of the component's declaration element.</p>
+
+<p>For example, an email application with an activity for composing a new email might declare an
+intent filter in its manifest entry to respond to "send" intents (in order to send email). An
+activity in your application can then create an intent with the “send” action ({@link
+android.content.Intent#ACTION_SEND}), which the system matches to the email application’s “send”
+activity and launches it when you invoke the intent with {@link android.app.Activity#startActivity
+startActivity()}.</p>
+
+<p>For more about creating intent filters, see the <a
+href="{@docRoot}guide/topics/intents/intents-filters.html">Intents and Intent Filters</a> document.
+</p>
+
+
+
+<h3 id="DeclaringRequirements">Declaring application requirements</h3>
+
+<p>There are a variety of devices powered by Android and not all of them provide the
+same features and capabilities. In order to prevent your application from being installed on devices
+that lack features needed by your application, it's important that you clearly define a profile for
+the types of devices your application supports by declaring device and software requirements in your
+manifest file. Most of these declarations are informational only and the system does not read
+them, but external services such as Android Market do read them in order to provide filtering
+for users when they search for applications from their device.</p>
+
+<p>For example, if your application requires a camera and uses APIs introduced in Android 2.1 (<a
+href="{@docRoot}guide/appendix/api-levels.html">API Level</a> 7), you should declare these as
+requirements in your manifest file. That way, devices that do <em>not</em> have a camera and have an
+Android version <em>lower</em> than 2.1 cannot install your application from Android Market.</p>
+
+<p>However, you can also declare that your applicaiton uses the camera, but does not
+<em>require</em> it. In that case, your application must perform a check at runtime to determine
+if the device has a camera and disable any features that use the camera if one is not available.</p>
+
+<p>Here are some of the important device characteristics that you should consider as you design and
+develop your application:</p>
+
+<dl>
+  <dt>Screen size and density</dt>
+  <dd>In order to categorize devices by their screen type, Android defines two characteristics for
+each device: screen size (the physical dimensions of the screen) and screen density (the physical
+density of the pixels on the screen, or dpi&mdash;dots per inch). To simplify all the different
+types of screen configurations, the Android system generalizes them into select groups that make
+them easier to target.
+<p>The screen sizes are: small, normal, large, and extra large.<br/>
+The screen densities are: low density, medium density, high density, and extra high density.</p>
+
+<p>By default, your application is compatible with all screen sizes and densities,
+because the Android system makes the appropriate adjustments to your UI layout and image
+resources. However, you should create specialized layouts for certain screen sizes and provide
+specialized images for certain densities, using alternative layout resources, and by declaring in
+your manifest exactly which screen sizes your application supports with the <a
+href="{@docRoot}guide/topics/manifest/supports-screens.html">{@code
+&lt;supports-screens&gt;}</a> element.</p>
+<p>For more information, see the <a
+href="{@docRoot}guide/practices/screens_support.html">Supporting Multiple Screens</a>
+document.</p></dd>
+
+  <dt>Input configurations</dt>
+  <dd>Many devices provide a different type of user input mechanism, such as a hardware keyboard, a
+trackball, or a five-way navigation pad. If your application requires a particular kind of input
+hardware, then you should declare it in your manifest with the <a
+href="{@docRoot}guide/topics/manifest/uses-configuration-element.html">{@code
+&lt;uses-configuration&gt;}</a> element. However, it is rare that an application should require
+a certain input configuration.</dd>
+
+  <dt>Device features</dt>
+  <dd>There are many hardware and software features that may or may not exist on a given
+Android-powered device, such as a camera, a light sensor, bluetooth, a certain
+version of OpenGL, or the fidelity of the touchscreen. You should never assume that a certain
+feature is available on all Android-powered devices (other than the availability of the standard
+Android library), so you should declare any features used by your application with the <a
+href="{@docRoot}guide/topics/manifest/uses-feature-element.html">{@code &lt;uses-feature&gt;}</a>
+element.</dd>
+
+  <dt>Platform Version</dt>
+  <dd>Different Android-powered devices often run different versions of the Android platform,
+such as Android 1.6 or Android 2.3. Each successive version often includes additional APIs not
+available in the previous version. In order to indicate which set of APIs are available, each
+platform version specifies an <a
+href="{@docRoot}guide/appendix/api-levels.html">API Level</a> (for example, Android 1.0 is API Level
+1 and Android 2.3 is API Level 9). If you use any APIs that were added to the platform after
+version 1.0, you should declare the minimum API Level in which those APIs were introduced using the
+<a href="{@docRoot}guide/topics/manifest/uses-sdk.html">{@code &lt;uses-sdk&gt;}</a> element.</dd>
+</dl>
+
+<p>It's important that you declare all such requirements for your application, because, when you
+distribute your application on Android Market, Market uses these declarations to filter which
+applications are available on each device. As such, your application should be available only to
+devices that meet all your application requirements.</p>
+
+<p>For more information about how Android Market filters applications based on these (and other)
+requirements, see the <a href="{@docRoot}guide/appendix/market-filters.html">Market Filters</a>
+document.</p>
+
+
+
+<h2 id="Resources">Application Resources</h2>
+
+<p>An Android application is composed of more than just code&mdash;it requires resources that are
+separate from the source code, such as images, audio files, and anything relating to the visual
+presentation of the application. For example, you should define animations, menus, styles, colors,
+and the layout of activity user interfaces with XML files. Using application resources makes it easy
+to update various characteristics of your application without modifying code and&mdash;by providing
+sets of alternative resources&mdash;enables you to optimize your application for a  variety of
+device configurations (such as different languages and screen sizes).</p>
+
+<p>For every resource that you include in your Android project, the SDK build tools define a unique
+integer ID, which you can use to reference the resource from your application code or from
+other resources defined in XML. For example, if your application contains an image file named {@code
+logo.png} (saved in the {@code res/drawable/} directory), the SDK tools generate a resource ID
+named {@code R.drawable.logo}, which you can use to reference the image and insert it in your
+user interface.</p>
+
+<p>One of the most important aspects of providing resources separate from your source code
+is the ability for you to provide alternative resources for different device
+configurations. For example, by defining UI strings in XML, you can translate the strings into other
+languages and save those strings in separate files. Then, based on a language <em>qualifier</em>
+that you append to the resource directory's name (such as {@code res/values-fr/} for French string
+values) and the user's language setting, the Android system applies the appropriate language strings
+to your UI.</p>
+
+<p>Android supports many different <em>qualifiers</em> for your alternative resources. The
+qualifier is a short string that you include in the name of your resource directories in order to
+define the device configuration for which those resources should be used. As another
+example, you should often create different layouts for your activities, depending on the
+device's screen orientation and size. For example, when the device screen is in portrait
+orientation (tall), you might want a layout with buttons to be vertical, but when the screen is in
+landscape orientation (wide), the buttons should be aligned horizontally. To change the layout
+depending on the orientation, you can define two different layouts and apply the appropriate
+qualifier to each layout's directory name. Then, the system automatically applies the appropriate
+layout depending on the current device orientation.</p>
+
+<p>For more about the different kinds of resources you can include in your application and how
+to create alternative resources for various device configurations, see the <a
+href="{@docRoot}guide/topics/resources/index.html">Application Resources</a> developer guide.</p>
+
+
+<h2>Beginner's Path</h2>
+
+<p>For a close look at implementing activities&mdash;the components your users use to
+interact with your application&mdash;continue with the <b><a
+href="{@docRoot}guide/topics/fundamentals/activities.html">Activities</a></b> document.</p>
+
diff --git a/docs/html/guide/topics/fundamentals/processes-and-threads.jd b/docs/html/guide/topics/fundamentals/processes-and-threads.jd
new file mode 100644
index 0000000..c35108e
--- /dev/null
+++ b/docs/html/guide/topics/fundamentals/processes-and-threads.jd
@@ -0,0 +1,425 @@
+page.title=Processes and Threads
+parent.title=Application Fundamentals
+parent.link=index.html
+@jd:body
+
+<div id="qv-wrapper">
+<div id="qv">
+<h2>Quickview</h2>
+<ul>
+  <li>Every application runs in its own process and all components of the application run in that
+process, by default</li>
+  <li>Any slow, blocking operations in an activity should be done in a new thread, to avoid slowing
+down the user interface</li>
+</ul>
+
+<h2>In this document</h2>
+<ol>
+<li><a href="#Processes">Processes</a>
+  <ol>
+    <li><a href="#Lifecycle">Process lifecycle</a></li>
+  </ol>
+</li>
+<li><a href="#Threads">Threads</a>
+  <ol>
+    <li><a href="#WorkerThreads">Worker threads</a></li>
+    <li><a href="#ThreadSafe">Thread-safe methods</a></li>
+  </ol>
+</li>
+<li><a href="#IPC">Interprocess Communication</a></li>
+</ol>
+
+</div>
+</div>
+
+<p>When an application component starts and the application does not have any other components
+running, the Android system starts a new Linux process for the application with a single thread of
+execution. By default, all components of the same application run in the same process and thread
+(called the "main" thread). If an application component starts and there already exists a process
+for that application (because another component from the application exists), then the component is
+started within that process and uses the same thread of execution. However, you can arrange for
+different components in your application to run in separate processes, and you can create additional
+threads for any process.</p>
+
+<p>This document discusses how processes and threads work in an Android application.</p>
+
+
+<h2 id="Processes">Processes</h2>
+
+<p>By default, all components of the same application run in the same process and most applications
+should not change this. However, if you find that you need to control which process a certain
+component belongs to, you can do so in the manifest file.</p>
+
+<p>The manifest entry for each type of component element&mdash;<a
+href="{@docRoot}guide/topics/manifest/activity-element.html">{@code
+&lt;activity&gt;}</a>, <a href="{@docRoot}guide/topics/manifest/service-element.html">{@code
+&lt;service&gt;}</a>, <a href="{@docRoot}guide/topics/manifest/receiver-element.html">{@code
+&lt;receiver&gt;}</a>, and <a href="{@docRoot}guide/topics/manifest/provider-element.html">{@code
+&lt;provider&gt;}</a>&mdash;supports an {@code android:process} attribute that can specify a
+process in which that component should run. You can set this attribute so that each component runs
+in its own process or so that some components share a process while others do not.  You can also set
+{@code android:process} so that components of different applications run in the same
+process&mdash;provided that the applications share the same Linux user ID and are signed with the
+same certificates.</p>
+
+<p>The <a href="{@docRoot}guide/topics/manifest/application-element.html">{@code
+&lt;application&gt;}</a> element also supports an {@code android:process} attribute, to set a
+default value that applies to all components.</p>
+
+<p>Android might decide to shut down a process at some point, when memory is low and required by
+other processes that are more immediately serving the user. Application
+components running in the process that's killed are consequently destroyed.  A process is started
+again for those components when there's again work for them to do.</p>
+
+<p>When deciding which processes to kill, the Android system weighs their relative importance to
+the user.  For example, it more readily shuts down a process hosting activities that are no longer
+visible on screen, compared to a process hosting visible activities. The decision whether to
+terminate a process, therefore, depends on the state of the components running in that process. The
+rules used to decide which processes to terminate is discussed below. </p>
+
+
+<h3 id="Lifecycle">Process lifecycle</h3>
+
+<p>The Android system tries to maintain an application process for as long as possible, but
+eventually needs to remove old processes to reclaim memory for new or more important processes.  To
+determine which processes to keep
+and which to kill, the system places each process into an "importance hierarchy" based on the
+components running in the process and the state of those components.  Processes with the lowest
+importance are eliminated first, then those with the next lowest importance, and so on, as necessary
+to recover system resources.</p>
+
+<p>There are five levels in the importance hierarchy. The following list presents the different
+types of processes in order of importance (the first process is <em>most important</em> and is
+<em>killed last</em>):</p>
+
+<ol>
+  <li><b>Foreground process</b>
+    <p>A process that is required for what the user is currently doing.  A
+      process is considered to be in the foreground if any of the following conditions are true:</p>
+
+      <ul>
+        <li>It hosts an {@link android.app.Activity} that the user is interacting with (the {@link
+android.app.Activity}'s {@link android.app.Activity#onResume onResume()} method has been
+called).</li>
+
+        <li>It hosts a {@link android.app.Service} that's bound to the activity that the user is
+interacting with.</li>
+
+        <li>It hosts a {@link android.app.Service} that's running "in the foreground"&mdash;the
+service has called {@link android.app.Service#startForeground startForeground()}.
+
+        <li>It hosts a {@link android.app.Service} that's executing one of its lifecycle
+callbacks ({@link android.app.Service#onCreate onCreate()}, {@link android.app.Service#onStart
+onStart()}, or {@link android.app.Service#onDestroy onDestroy()}).</li>
+
+        <li>It hosts a {@link android.content.BroadcastReceiver} that's executing its {@link
+        android.content.BroadcastReceiver#onReceive onReceive()} method.</li>
+    </ul>
+
+    <p>Generally, only a few foreground processes exist at any given time.  They are killed only as
+a last resort&mdash;if memory is so low that they cannot all continue to run.  Generally, at that
+point, the device has reached a memory paging state, so killing some foreground processes is
+required to keep the user interface responsive.</p></li>
+
+  <li><b>Visible process</b>
+    <p>A process that doesn't have any foreground components, but still can
+      affect what the user sees on screen. A process is considered to be visible if either of the
+      following conditions are true:</p>
+
+      <ul>
+        <li>It hosts an {@link android.app.Activity} that is not in the foreground, but is still
+visible to the user (its {@link android.app.Activity#onPause onPause()} method has been called). 
+This might occur, for example, if the foreground activity started a dialog, which allows the
+previous activity to be seen behind it.</li>
+
+        <li>It hosts a {@link android.app.Service} that's bound to a visible (or foreground)
+activity.</li>
+      </ul>
+
+      <p>A visible process is considered extremely important and will not be killed unless doing so
+is required to keep all foreground processes running. </p>
+    </li>
+
+  <li><b>Service process</b>
+    <p>A process that is running a service that has been started with the {@link
+android.content.Context#startService startService()} method and does not fall into either of the two
+higher categories. Although service processes are not directly tied to anything the user sees, they
+are generally doing things that the user cares about (such as playing music in the background or
+downloading  data on the network), so the system keeps them running unless there's not enough memory
+to retain them along with all foreground and visible processes. </p>
+  </li>
+
+  <li><b>Background process</b>
+    <p>A process holding an activity that's not currently visible to the user  (the activity's
+{@link android.app.Activity#onStop onStop()} method has been called). These processes have no direct
+impact on the user experience, and the system can kill them at any time to reclaim memory for a
+foreground,
+visible, or service process. Usually there are many background processes running, so they are kept
+in an LRU (least recently used) list to ensure that the process with the activity that was most
+recently seen by the user is the last to be killed. If an activity implements its lifecycle methods
+correctly, and saves its current state, killing its process will not have a visible effect on
+the user experience, because when the user navigates back to the activity, the activity restores
+all of its visible state. See the <a
+href="{@docRoot}guide/topics/fundamentals/activities.html#SavingActivityState">Activities</a>
+document for information about saving and restoring state.</p>
+  </li>
+
+  <li><b>Empty process</b>
+    <p>A process that doesn't hold any active application components.  The only reason to keep this
+kind of process alive is for caching purposes, to improve startup time the next time a component
+needs to run in it.  The system often kills these processes in order to balance overall system
+resources between process caches and the underlying kernel caches.</p>
+  </li>
+</ol>
+
+
+  <p>Android ranks a process at the highest level it can, based upon the importance of the
+components currently active in the process.  For example, if a process hosts a service and a visible
+activity, the process is ranked as a visible process, not a service process.</p>
+
+  <p>In addition, a process's ranking might be increased because other processes are dependent on
+it&mdash;a process that is serving another process can never be ranked lower than the process it is
+serving. For example, if a content provider in process A is serving a client in process B, or if a
+service in process A is bound to a component in process B, process A is always considered at least
+as important as process B.</p>
+
+  <p>Because a process running a service is ranked higher than a process with background activities,
+an activity that initiates a long-running operation might do well to start a <a
+href="{@docRoot}guide/topics/fundamentals/services.html">service</a> for that operation, rather than
+simply create a worker thread&mdash;particularly if the operation will likely outlast the activity.
+For example, an activity that's uploading a picture to a web site should start a service to perform
+the upload so that the upload can continue in the background even if the user leaves the activity.
+Using a service guarantees that the operation will have at least "service process" priority,
+regardless of what happens to the activity. This is the same reason that broadcast receivers should
+employ services rather than simply put time-consuming operations in a thread.</p>
+
+
+
+
+<h2 id="Threads">Threads</h2>
+
+<p>When an application is launched, the system creates a thread of execution for the application,
+called "main." This thread is very important because it is in charge of dispatching events to
+the appropriate user interface widgets, including drawing events. It is also the thread in which
+your application interacts with components from the Android UI toolkit (components from the {@link
+android.widget} and {@link android.view} packages). As such, the main thread is also sometimes
+called the UI thread.</p>
+
+<p>The system does <em>not</em> create a separate thread for each instance of a component. All
+components that run in the same process are instantiated in the UI thread, and system calls to
+each component are dispatched from that thread. Consequently, methods that respond to system
+callbacks (such as {@link android.view.View#onKeyDown onKeyDown()} to report user actions
+or a lifecycle callback method) always run in the UI thread of the process.</p>
+
+<p>For instance, when the user touches a button on the screen, your app's UI thread dispatches the
+touch event to the widget, which in turn sets its pressed state and posts an invalidate request to
+the event queue. The UI thread dequeues the request and notifies the widget that it should redraw
+itself.</p>
+
+<p>When your app performs intensive work in response to user interaction, this single thread model
+can yield poor performance unless you implement your application properly. Specifically, if
+everything is happening in the UI thread, performing long operations such as network access or
+database queries will block the whole UI. When the thread is blocked, no events can be dispatched,
+including drawing events. From the user's perspective, the
+application appears to hang. Even worse, if the UI thread is blocked for more than a few seconds
+(about 5 seconds currently) the user is presented with the infamous "<a
+href="http://developer.android.com/guide/practices/design/responsiveness.html">application not
+responding</a>" (ANR) dialog. The user might then decide to quit your application and uninstall it
+if they are unhappy.</p>
+
+<p>Additionally, the Andoid UI toolkit is <em>not</em> thread-safe. So, you must not manipulate
+your UI from a worker thread&mdash;you must do all manipulation to your user interface from the UI
+thread. Thus, there are simply two rules to Android's single thread model:</p>
+
+<ol>
+<li>Do not block the UI thread
+<li>Do not access the Android UI toolkit from outside the UI thread
+</ol>
+
+<h3 id="WorkerThreads">Worker threads</h3>
+
+<p>Because of the single thread model described above, it's vital to the responsiveness of your
+application's UI that you do not block the UI thread. If you have operations to perform
+that are not instantaneous, you should make sure to do them in separate threads ("background" or
+"worker" threads).</p>
+
+<p>For example, below is some code for a click listener that downloads an image from a separate
+thread and displays it in an {@link android.widget.ImageView}:</p>
+
+<pre>
+public void onClick(View v) {
+    new Thread(new Runnable() {
+        public void run() {
+            Bitmap b = loadImageFromNetwork("http://example.com/image.png");
+            mImageView.setImageBitmap(b);
+        }
+    }).start();
+}
+</pre>
+
+<p>At first, this seems to work fine, because it creates a new thread to handle the network
+operation. However, it violates the second rule of the single-threaded model: <em>do not access the
+Android UI toolkit from outside the UI thread</em>&mdash;this sample modifies the {@link
+android.widget.ImageView} from the worker thread instead of the UI thread. This can result in
+undefined and unexpected behavior, which can be difficult and time-consuming to track down.</p>
+
+<p>To fix this problem, Android offers several ways to access the UI thread from other
+threads. Here is a list of methods that can help:</p>
+
+<ul>
+<li>{@link android.app.Activity#runOnUiThread(java.lang.Runnable)
+Activity.runOnUiThread(Runnable)}</li>
+<li>{@link android.view.View#post(java.lang.Runnable) View.post(Runnable)}</li>
+<li>{@link android.view.View#postDelayed(java.lang.Runnable, long) View.postDelayed(Runnable,
+long)}</li>
+</ul>
+
+<p>For example, you can fix the above code by using the {@link
+android.view.View#post(java.lang.Runnable) View.post(Runnable)} method:</p>
+
+<pre>
+public void onClick(View v) {
+    new Thread(new Runnable() {
+        public void run() {
+            final Bitmap bitmap = loadImageFromNetwork("http://example.com/image.png");
+            mImageView.post(new Runnable() {
+                public void run() {
+                    mImageView.setImageBitmap(bitmap);
+                }
+            });
+        }
+    }).start();
+}
+</pre>
+
+<p>Now this implementation is thread-safe: the network operation is done from a separate thread
+while the {@link android.widget.ImageView} is manipulated from the UI thread.</p>
+
+<p>However, as the complexity of the operation grows, this kind of code can get complicated and
+difficult to maintain. To handle more complex interactions with a worker thread, you might consider
+using a {@link android.os.Handler} in your worker thread, to process messages delivered from the UI
+thread. Perhaps the best solution, though, is to extend the {@link android.os.AsyncTask} class,
+which simplifies the execution of worker thread tasks that need to interact with the UI.</p>
+
+
+<h4 id="AsyncTask">Using AsyncTask</h4>
+
+<p>{@link android.os.AsyncTask} allows you to perform asynchronous work on your user
+interface. It performs the blocking operations in a worker thread and then publishes the results on
+the UI thread, without requiring you to handle threads and/or handlers yourself.</p>
+
+<p>To use it, you must subclass {@link android.os.AsyncTask} and implement the {@link
+android.os.AsyncTask#doInBackground doInBackground()} callback method, which runs in a pool of
+background threads. To update your UI, you should implement {@link
+android.os.AsyncTask#onPostExecute onPostExecute()}, which delivers the result from {@link
+android.os.AsyncTask#doInBackground doInBackground()} and runs in the UI thread, so you can safely
+update your UI. You can then run the task by calling {@link android.os.AsyncTask#execute execute()}
+from the UI thread.</p>
+
+<p>For example, you can implement the previous example using {@link android.os.AsyncTask} this
+way:</p>
+
+<pre>
+public void onClick(View v) {
+    new DownloadImageTask().execute("http://example.com/image.png");
+}
+
+private class DownloadImageTask extends AsyncTask&lt;String, Void, Bitmap&gt; {
+    /** The system calls this to perform work in a worker thread and
+      * delivers it the parameters given to AsyncTask.execute() */
+    protected Bitmap doInBackground(String... urls) {
+        return loadImageFromNetwork(urls[0]);
+    }
+    
+    /** The system calls this to perform work in the UI thread and delivers
+      * the result from doInBackground() */
+    protected void onPostExecute(Bitmap result) {
+        mImageView.setImageBitmap(result);
+    }
+}
+</pre>
+
+<p>Now the UI is safe and the code is simpler, because it separates the work into the
+part that should be done on a worker thread and the part that should be done on the UI thread.</p>
+
+<p>You should read the {@link android.os.AsyncTask} reference for a full understanding on
+how to use this class, but here is a quick overview of how it works:</p>
+
+<ul>
+<li>You can specify the type of the parameters, the progress values, and the final
+value of the task, using generics</li>
+<li>The method {@link android.os.AsyncTask#doInBackground doInBackground()} executes automatically
+on a worker thread</li>
+<li>{@link android.os.AsyncTask#onPreExecute onPreExecute()}, {@link
+android.os.AsyncTask#onPostExecute onPostExecute()}, and {@link
+android.os.AsyncTask#onProgressUpdate onProgressUpdate()} are all invoked on the UI thread</li>
+<li>The value returned by {@link android.os.AsyncTask#doInBackground doInBackground()} is sent to
+{@link android.os.AsyncTask#onPostExecute onPostExecute()}</li>
+<li>You can call {@link android.os.AsyncTask#publishProgress publishProgress()} at anytime in {@link
+android.os.AsyncTask#doInBackground doInBackground()} to execute {@link
+android.os.AsyncTask#onProgressUpdate onProgressUpdate()} on the UI thread</li>
+<li>You can cancel the task at any time, from any thread</li>
+</ul>
+
+<p class="caution"><strong>Caution:</strong> Another problem you might encounter when using a worker
+thread is unexpected restarts in your activity due to a <a
+href="{@docRoot}guide/topics/resources/runtime-changes.html">runtime configuration change</a>
+(such as when the user changes the screen orientation), which may destroy your worker thread. To
+see how you can persist your task during one of these restarts and how to properly cancel the task
+when the activity is destroyed, see the source code for the <a
+href="http://code.google.com/p/shelves/">Shelves</a> sample application.</p>
+
+
+<h3 id="ThreadSafe">Thread-safe methods</h3>
+
+<p> In some situations, the methods you implement might be called from more than one thread, and
+therefore must be written to be thread-safe. </p>
+
+<p>This is primarily true for methods that can be called remotely&mdash;such as methods in a <a
+href="{@docRoot}guide/topics/fundamentals/bound-services.html">bound service</a>. When a call on a
+method implemented in an {@link android.os.IBinder} originates in the same process in which the
+{@link android.os.IBinder IBinder} is running, the method is executed in the caller's thread.
+However, when the call originates in another process, the method is executed in a thread chosen from
+a pool of threads that the system maintains in the same process as the {@link android.os.IBinder
+IBinder} (it's not executed in the UI thread of the process).  For example, whereas a service's
+{@link android.app.Service#onBind onBind()} method would be called from the UI thread of the
+service's process, methods implemented in the object that {@link android.app.Service#onBind
+onBind()} returns (for example, a subclass that implements RPC methods) would be called from threads
+in the pool. Because a service can have more than one client, more than one pool thread can engage
+the same {@link android.os.IBinder IBinder} method at the same time.  {@link android.os.IBinder
+IBinder} methods must, therefore, be implemented to be thread-safe.</p>
+
+<p> Similarly, a content provider can receive data requests that originate in other processes.
+Although the {@link android.content.ContentResolver} and {@link android.content.ContentProvider}
+classes hide the details of how the interprocess communication is managed, {@link
+android.content.ContentProvider} methods that respond to those requests&mdash;the methods {@link
+android.content.ContentProvider#query query()}, {@link android.content.ContentProvider#insert
+insert()}, {@link android.content.ContentProvider#delete delete()}, {@link
+android.content.ContentProvider#update update()}, and {@link android.content.ContentProvider#getType
+getType()}&mdash;are called from a pool of threads in the content provider's process, not the UI
+thread for the process.  Because these methods might be called from any number of threads at the
+same time, they too must be implemented to be thread-safe. </p>
+
+
+<h2 id="IPC">Interprocess Communication</h2>
+
+<p>Android offers a mechanism for interprocess communication (IPC) using remote procedure calls
+(RPCs), in which a method is called by an activity or other application component, but executed
+remotely (in another process), with any result returned back to the
+caller. This entails decomposing a method call and its data to a level the operating system can
+understand, transmitting it from the local process and address space to the remote process and
+address space, then reassembling and reenacting the call there.  Return values are then
+transmitted in the opposite direction.  Android provides all the code to perform these IPC
+transactions, so you can focus on defining and implementing the RPC programming interface. </p>
+
+<p>To perform IPC, your application must bind to a service, using {@link
+android.content.Context#bindService bindService()}. For more information, see the <a
+href="{@docRoot}guide/topics/fundamentals/services.html">Services</a> developer guide.</p>
+
+
+<h2>Beginner's Path</h2>
+
+<p>For information about how to perform work in the background for an indefinite period of time
+(without a user interface), continue with the <b><a
+href="{@docRoot}guide/topics/fundamentals/services.html">Services</a></b> document.</p>
+
diff --git a/docs/html/guide/topics/resources/menu-resource.jd b/docs/html/guide/topics/resources/menu-resource.jd
index 33c782b..d09790b 100644
--- a/docs/html/guide/topics/resources/menu-resource.jd
+++ b/docs/html/guide/topics/resources/menu-resource.jd
@@ -12,9 +12,12 @@
   </div>
 </div>
 
-<p>A menu resource defines an application menu (Options Menu, Context Menu, or Sub Menu) that
+<p>A menu resource defines an application menu (Options Menu, Context Menu, or submenu) that
 can be inflated with {@link android.view.MenuInflater}.</p>
 
+<p>For a guide to using menus, see the <a href="{@docRoot}guide/topics/ui/menus.html">Creating
+Menus</a> document.</p>
+
 <dl class="xml">
 
 <dt>file location:</dt>
@@ -110,12 +113,12 @@
 href="{@docRoot}guide/developing/tools/proguard.html">ProGuard</a> (or a similar tool),
 be sure to exclude the method you specify in this attribute from renaming, because it can break the
 functionality.</p>
-          <p>Introduced in API Level HONEYCOMB.</p></dd>
+          <p>Introduced in API Level 11.</p></dd>
 
         <dt><code>android:showAsAction</code></dt>
           <dd><em>Keyword</em>. When and how this item should appear as an action item in the Action
 Bar. A menu item can appear as an action item only when the activity includes an {@link
-android.app.ActionBar} (introduced in API Level HONEYCOMB). Valid values:
+android.app.ActionBar} (introduced in API Level 11). Valid values:
           <table>
             <tr><th>Value</th><th>Description</th></tr>
             <tr><td><code>ifRoom</code></td><td>Only place this item in the Action Bar if
@@ -131,14 +134,14 @@
           </table>
           <p>See <a href="{@docRoot}guide/topics/ui/actionbar.html">Using the Action Bar</a> for
 more information.</p>
-          <p>Introduced in API Level HONEYCOMB.</p>
+          <p>Introduced in API Level 11.</p>
         </dd>
 
         <dt><code>android:actionViewLayout</code></dt>
           <dd><em>Layout resource</em>. A layout to use as the action view.
           <p>See <a href="{@docRoot}guide/topics/ui/actionbar.html">Using the Action Bar</a> for
 more information.</p>
-          <p>Introduced in API Level HONEYCOMB.</p></dd>
+          <p>Introduced in API Level 11.</p></dd>
 
         <dt><code>android:actionViewClassName</code></dt>
           <dd><em>Class name</em>. A fully-qualified class name for the {@link android.view.View}
@@ -149,7 +152,7 @@
 href="{@docRoot}guide/developing/tools/proguard.html">ProGuard</a> (or a similar tool),
 be sure to exclude the class you specify in this attribute from renaming, because it can break the
 functionality.</p>
-          <p>Introduced in API Level HONEYCOMB.</p></dd>
+          <p>Introduced in API Level 11.</p></dd>
 
 
         <dt><code>android:alphabeticShortcut</code></dt>
@@ -277,7 +280,7 @@
 }
 </pre>
 <p class="note"><strong>Note:</strong> The {@code android:showAsAction} attribute is
-available only on Android X.X (API Level HONEYCOMB) and greater.</p>
+available only on Android 3.0 (API Level 11) and greater.</p>
 </dd> <!-- end example -->
 
 
diff --git a/docs/html/guide/topics/ui/menus.jd b/docs/html/guide/topics/ui/menus.jd
index d1c0ff8..984bf8f 100644
--- a/docs/html/guide/topics/ui/menus.jd
+++ b/docs/html/guide/topics/ui/menus.jd
@@ -7,11 +7,11 @@
 <div id="qv">
   <h2>In this document</h2>
   <ol>
-    <li><a href="#xml">Defining Menus</a></li>
+    <li><a href="#xml">Creating a Menu Resource</a></li>
     <li><a href="#Inflating">Inflating a Menu Resource</a>
     <li><a href="#options-menu">Creating an Options Menu</a>
       <ol>
-        <li><a href="#ChangingTheMenu">Changing the menu when it opens</a></li>
+        <li><a href="#ChangingTheMenu">Changing menu items at runtime</a></li>
       </ol>
     </li>
     <li><a href="#context-menu">Creating a Context Menu</a></li>
@@ -21,7 +21,7 @@
         <li><a href="#groups">Menu groups</a></li>
         <li><a href="#checkable">Checkable menu items</a></li>
         <li><a href="#shortcuts">Shortcut keys</a></li>
-        <li><a href="#intents">Intents for menu items</a></li>
+        <li><a href="#intents">Dynamically adding menu intents</a></li>
       </ol>
     </li>
   </ol>
@@ -42,52 +42,60 @@
 </div>
 </div>
 
-<p>Menus are an important part of an application that provide a familiar interface for the user
-to access application functions and settings. Android offers an easy programming interface
-for you to provide application menus in your application.</p>
+<p>Menus are an important part of an activity's user interface, which provide users a familiar
+way to perform actions. Android offers a simple framework for you to add standard
+menus to your application.</p>
 
-<p>Android provides three types of application menus:</p>
+<p>There are three types of application menus:</p>
 <dl>
   <dt><strong>Options Menu</strong></dt>
-    <dd>The primary collection of menu items for an Activity that is associated with the device MENU
-key. To provide instant access to select menu items, you can place some items in the <a
-href="{@docRoot}guide/topics/ui/actionbar.html">Action Bar</a>, if available.</dd>
+    <dd>The primary collection of menu items for an activity, which appears when the user touches
+the MENU button. When your application is running on Android 3.0 or later, you can provide
+quick access to select menu items by placing them directly in the <a
+href="{@docRoot}guide/topics/ui/actionbar.html">Action Bar</a>, as "action items."</dd>
   <dt><strong>Context Menu</strong></dt>
-    <dd>A floating list of menu items that appears when the user performs a long-press on a View.
+    <dd>A floating list of menu items that appears when the user touches and holds a view
+that's registered to provide a context menu.
 </dd>
   <dt><strong>Submenu</strong></dt>
-    <dd>A floating list of menu items that the user opens by pressing a menu item in the Options
-Menu or a context menu. A submenu item cannot support a nested submenu. </dd>
+    <dd>A floating list of menu items that appears when the user touches a menu item that contains
+a nested menu.</dd>
 </dl>
 
+<p>This document shows you how to create each type of menu, using XML to define the content of
+the menu and callback methods in your activity to respond when the user selects an item.</p>
 
 
-<h2 id="xml">Defining Menus</h2>
+
+<h2 id="xml">Creating a Menu Resource</h2>
 
 <p>Instead of instantiating a {@link android.view.Menu} in your application code, you should
 define a menu and all its items in an XML <a
 href="{@docRoot}guide/topics/resources/menu-resource.html">menu resource</a>, then inflate the menu
-resource (load it as a programmable object) in your application code. Defining your menus in XML is
-a good practice because it separates your interface design from your application code (the same as
-when you <a href="{@docRoot}guide/topics/ui/declaring-layout.html">define your Activity
-layout</a>).</p>
+resource (load it as a programmable object) in your application code. Using a menu resource to
+define your menu is a good practice because it separates the content for the menu from your
+application code. It's also easier to visualize the structure and content of a menu in XML.</p>
 
-<p>To define a menu, create an XML file inside your project's <code>res/menu/</code>
+<p>To create a menu resource, create an XML file inside your project's <code>res/menu/</code>
 directory and build the menu with the following elements:</p>
 <dl>
   <dt><code>&lt;menu></code></dt>
-    <dd>Creates a {@link android.view.Menu}, which is a container for menu items. It must be
-the root node and holds one or more of the following elements. You can also nest this element
-in an {@code &lt;item&gt;} to create a submenu.</dd>
+    <dd>Defines a {@link android.view.Menu}, which is a container for menu items. A
+<code>&lt;menu></code> element must be the root node for the file and can hold one or more
+<code>&lt;item></code> and <code>&lt;group></code> elements.</dd>
+
   <dt><code>&lt;item></code></dt>
-    <dd>Creates a {@link android.view.MenuItem}, which represents a single item in a menu.</dd>
+    <dd>Creates a {@link android.view.MenuItem}, which represents a single item in a menu. This
+element may contain a nested <code>&lt;menu></code> element in order to create a submenu.</dd>
+    
   <dt><code>&lt;group></code></dt>
     <dd>An optional, invisible container for {@code &lt;item&gt;} elements. It allows you to
-categorize menu items so they share properties such as active state and visibility. See <a
-href="#groups">Menu groups</a>.</dd>
+categorize menu items so they share properties such as active state and visibility. See the
+section about <a href="#groups">Menu groups</a>.</dd>
 </dl>
 
-<p>For example, here is a file in <code>res/menu/</code> named <code>game_menu.xml</code>:</p>
+
+<p>Here's an example menu named <code>game_menu.xml</code>:</p>
 <pre>
 &lt;?xml version="1.0" encoding="utf-8"?&gt;
 &lt;menu xmlns:android="http://schemas.android.com/apk/res/android"&gt;
@@ -100,28 +108,33 @@
 &lt;/menu&gt;
 </pre>
 
-<p>This example defines a menu with two menu items. Each item includes the attributes:</p>
+<p>This example defines a menu with two items. Each item includes the attributes:</p>
 <dl>
   <dt>{@code android:id}</dt>
-    <dd>A resource ID that's unique to the item so that the application can recognize the item when
-the user selects it.</dd>
+    <dd>A resource ID that's unique to the item, which allows the application can recognize the item
+when the user selects it.</dd>
   <dt>{@code android:icon}</dt>
-    <dd>A drawable resource that is the icon visible to the user.</dd>
+    <dd>A reference to a drawable to use as the item's icon.</dd>
   <dt>{@code android:title}</dt>
-    <dd>A string resource that is the title visible to the user.</dd>
+    <dd>A reference to a string to use as the item's title.</dd>
 </dl>
 
-<p>For more about the XML syntax and attributes for a menu resource, see the <a
+<p>There are many more attributes you can include in an {@code &lt;item&gt;}, including some that
+ specify how the item may appear in the <a
+href="{@docRoot}guide/topics/ui/actionbar.html">Action Bar</a>. For more information about the XML
+syntax and attributes for a menu resource, see the <a
 href="{@docRoot}guide/topics/resources/menu-resource.html">Menu Resource</a> reference.</p>
 
 
+
 <h2 id="Inflating">Inflating a Menu Resource</h2>
 
-<p>You can inflate your menu resource (convert the XML resource into a programmable object) using
+<p>From your application code, you can inflate a menu resource (convert the XML resource into a
+programmable object) using
 {@link android.view.MenuInflater#inflate(int,Menu) MenuInflater.inflate()}. For
-example, the following code inflates the <code>game_menu.xml</code> file defined above during the
-{@link android.app.Activity#onCreateOptionsMenu(Menu) onCreateOptionsMenu()} callback method, to be
-used for the Options Menu:</p>
+example, the following code inflates the <code>game_menu.xml</code> file defined above, during the
+{@link android.app.Activity#onCreateOptionsMenu(Menu) onCreateOptionsMenu()} callback method, to
+use the menu as the activity's Options Menu:</p>
 
 <pre>
 &#64;Override
@@ -133,59 +146,47 @@
 </pre>
 
 <p>The {@link android.app.Activity#getMenuInflater()} method returns a {@link
-android.view.MenuInflater} for the Activity. With this object, you can call {@link
+android.view.MenuInflater} for the activity. With this object, you can call {@link
 android.view.MenuInflater#inflate(int,Menu) inflate()}, which inflates a menu resource into a
 {@link android.view.Menu} object. In this example, the menu resource defined by
 <code>game_menu.xml</code>
 is inflated into the {@link android.view.Menu} that was passed into {@link
 android.app.Activity#onCreateOptionsMenu(Menu) onCreateOptionsMenu()}. (This callback method for
-creating an option menu is discussed more in the next section.)</p>
+the Options Menu is discussed more in the next section.)</p>
 
 
 
 <h2 id="options-menu">Creating an Options Menu</h2>
 
 <div class="figure" style="width:200px">
-  <img src="{@docRoot}images/options_menu.png" height="300" alt="" />
-  <p class="img-caption"><strong>Figure 1.</strong> Screenshot of an Options Menu.</p>
+  <img src="{@docRoot}images/options_menu.png" height="333" alt="" />
+  <p class="img-caption"><strong>Figure 1.</strong> Screenshot of the Options Menu in the
+Browser.</p>
 </div>
 
-
-<p>The Options Menu is where you should include basic application functions and necessary navigation
+<p>The Options Menu is where you should include basic activity actions and necessary navigation
 items (for example, a button to open the application settings). Items in the Options Menu are
-accessible in two distinct ways: in the Action Bar and in the menu revealed by the MENU
-key.</p>
+accessible in two distinct ways: the MENU button or in the <a
+href="{@docRoot}guide/topics/ui/actionbar.html">Action Bar</a> (on devices running Android 3.0
+or higher).</p>
 
-<p>The Action Bar is an optional widget that appears at the top of the activity in place of the
-title bar. It can display several menu items that you choose from the Options Menu, but items in
-the Action Bar display only an icon (no title text). Users can reveal the other menu items in the
-Options Menu with the MENU key.</p>
+<p>When running on a device with Android 2.3 and lower, the Options Menu appears at the bottom of
+the screen, as shown in figure 1. When opened, the first visible portion of the Options Menu is
+the icon menu. It holds the first six menu items. If you add more than six items to the
+Options Menu, Android places the sixth item and those after it into the overflow menu, which the
+user can open by touching the "More" menu item.</p>
 
-<p>If you include the Action Bar in your activity, the menu items that are not placed in the Action
-Bar can appear in two different styles:</p>
-<dl>
-  <dt>Action Bar Menu</dt>
-    <dd>If the device has an extra-large screen ({@code xlarge}), then all items in the Options Menu
-that are not placed in the Action Bar are placed into a drop-down list at the right side of the
-Action Bar, with icons and title text. The user can reveal the drop-down list by pressing the
-drop-down icon in the Action Bar or the MENU key.</dd>
-  <dt>Standard Options Menu</dt>
-    <dd>If the device <em>does not</em> have an extra-large screen, then all items in the Options
-Menu that are not placed in the Action Bar are placed into the Standard Options Menu at the bottom
-of the activity. The user can reveal the standard Options Menu by pressing the MENU key.
-    <p>The first visible portion of the Standard Options Menu is called the Icon Menu.
-It holds the first six menu items (excluding any added to the Action Bar), with icons and title
-text. If there are more than six items, Android adds a "More" item as the sixth menu item and places
-the remaining items into the Expanded Menu, which the user can open by selecting "More". The
-Expanded Menu displays menu items only by their title text (no icon)</p>
-    </dd>
-</dl>
+<p>On Android 3.0 and higher, items from the Options Menu is placed in the Action Bar, which appears
+at the top of the activity in place of the traditional title bar. By default all items from the
+Options Menu are placed in the overflow menu, which the user can open by touching the menu icon
+on the right side of the Action Bar. However, you can place select menu items directly in the
+Action Bar as "action items," for instant access, as shown in figure 2.</p>
 
-<p>When the user opens the Options Menu for the first time, Android calls your Activity's
-{@link android.app.Activity#onCreateOptionsMenu(Menu)
-onCreateOptionsMenu()} method. Override this method in your Activity
-and populate the {@link android.view.Menu} that is passed into the method. Populate the
-{@link android.view.Menu} by inflating a menu resource as described in <a
+<p>When the Android system creates the Options Menu for the first time, it calls your
+activity's {@link android.app.Activity#onCreateOptionsMenu(Menu)
+onCreateOptionsMenu()} method. Override this method in your activity
+and populate the {@link android.view.Menu} that is passed into the method,
+{@link android.view.Menu} by inflating a menu resource as described above in <a
 href="#Inflating">Inflating a Menu Resource</a>. For example:</p>
 
 <pre>
@@ -197,17 +198,31 @@
 }
 </pre>
 
-<p>(You can also populate the menu in code, using {@link android.view.Menu#add(int,int,int,int)
-add()} to add items to the {@link android.view.Menu}.)</p>
+<div class="figure" style="width:500px">
+<img src="{@docRoot}images/ui/actionbar.png" height="34" alt="" />
+<p class="img-caption"><strong>Figure 2.</strong> Screenshot of the Action Bar in the Email
+application, with two action items from the Options Menu, plus the overflow menu.</p>
+</div>
 
-<p>When the user selects a menu item from the Options Menu (including items selected from the
-Action Bar), the system calls your Activity's
+<p>You can also populate the menu in code, using {@link android.view.Menu#add(int,int,int,int)
+add()} to add items to the {@link android.view.Menu}.</p>
+
+<p class="note"><strong>Note:</strong> On Android 2.3 and lower, the system calls {@link
+android.app.Activity#onCreateOptionsMenu(Menu) onCreateOptionsMenu()} to create the Options Menu
+when the user opens it for the first time, but on Android 3.0 and greater, the system creates it as
+soon as the activity is created, in order to populate the Action Bar.</p>
+
+
+<h3 id="RespondingOptionsMenu">Responding to user action</h3>
+
+<p>When the user selects a menu item from the Options Menu (including action items in the
+Action Bar), the system calls your activity's
 {@link android.app.Activity#onOptionsItemSelected(MenuItem) onOptionsItemSelected()}
 method. This method passes the
 {@link android.view.MenuItem} that the user selected. You can identify the menu item by calling
 {@link android.view.MenuItem#getItemId()}, which returns the unique ID for the menu
-item (defined by the {@code android:id} attribute in the menu resource or with an integer passed
-to the {@link android.view.Menu#add(int,int,int,int) add()} method). You can match this ID
+item (defined by the {@code android:id} attribute in the menu resource or with an integer
+given to the {@link android.view.Menu#add(int,int,int,int) add()} method). You can match this ID
 against known menu items and perform the appropriate action. For example:</p>
 
 <pre>
@@ -229,45 +244,67 @@
 
 <p>In this example, {@link android.view.MenuItem#getItemId()} queries the ID for the selected menu
 item and the switch statement compares the ID against the resource IDs that were assigned to menu
-items in the XML resource. When a switch case successfully handles the item, it
-returns "true" to indicate that the item selection was handled. Otherwise, the default statement
-passes the menu item to the super class in
+items in the XML resource. When a switch case successfully handles the menu item, it
+returns {@code true} to indicate that the item selection was handled. Otherwise, the default
+statement passes the menu item to the super class, in
 case it can handle the item selected. (If you've directly extended the {@link android.app.Activity}
-class, then the super class returns "false", but it's a good practice to
-pass unhandled menu items to the super class instead of directly returning "false".)</p>
+class, then the super class returns {@code false}, but it's a good practice to
+pass unhandled menu items to the super class instead of directly returning {@code false}.)</p>
+
+<p>Additionally, Android 3.0 adds the ability for you to define the on-click behavior for a menu
+item in the <a href="{@docRoot}guide/topics/resources/menu-resource.html">menu resource</a> XML,
+using the {@code android:onClick} attribute. So you don't need to implement {@link
+android.app.Activity#onOptionsItemSelected(MenuItem) onOptionsItemSelected()}. Using the {@code
+android:onClick} attribute, you can specify a method to call when the user selects the menu item.
+Your activity must then implement the method specified in the {@code android:onClick} attribute so 
+that it accepts a single {@link android.view.MenuItem} parameter&mdash;when the system calls this
+method, it passes the menu item selected.</p>
 
 <p class="note"><strong>Tip:</strong> If your application contains multiple activities and
 some of them provide the same Options Menu, consider creating
-an Activity that implements nothing except the {@link android.app.Activity#onCreateOptionsMenu(Menu)
+an activity that implements nothing except the {@link android.app.Activity#onCreateOptionsMenu(Menu)
 onCreateOptionsMenu()} and {@link android.app.Activity#onOptionsItemSelected(MenuItem)
-onOptionsItemSelected()} methods. Then extend this class for each Activity that should share the
+onOptionsItemSelected()} methods. Then extend this class for each activity that should share the
 same Options Menu. This way, you have to manage only one set of code for handling menu
 actions and each descendant class inherits the menu behaviors.<br/><br/>
 If you want to add menu items to one of your descendant activities,
 override {@link android.app.Activity#onCreateOptionsMenu(Menu)
-onCreateOptionsMenu()} in that Activity. Call {@code super.onCreateOptionsMenu(menu)} so the
+onCreateOptionsMenu()} in that activity. Call {@code super.onCreateOptionsMenu(menu)} so the
 original menu items are created, then add new menu items with {@link
 android.view.Menu#add(int,int,int,int) menu.add()}. You can also override the super class's
 behavior for individual menu items.</p>
 
 
-<h3 id="ChangingTheMenu">Changing the menu when it opens</h3>
+<h3 id="ChangingTheMenu">Changing menu items at runtime</h3>
 
-<p>The {@link android.app.Activity#onCreateOptionsMenu(Menu) onCreateOptionsMenu()} method is
-called only the first time the Options Menu is opened. The system keeps and re-uses the {@link
-android.view.Menu} you define in this method until your Activity is destroyed. If you want to change
-the Options Menu each time it opens, you must override the
+<p>Once the activity is created, the {@link android.app.Activity#onCreateOptionsMenu(Menu)
+onCreateOptionsMenu()} method is
+called only once, as described above. The system keeps and re-uses the {@link
+android.view.Menu} you define in this method until your activity is destroyed. If you want to change
+the Options Menu any time after it's first created, you must override the
 {@link android.app.Activity#onPrepareOptionsMenu(Menu) onPrepareOptionsMenu()} method. This passes
 you the {@link android.view.Menu} object as it currently exists. This is useful if you'd like to
 remove, add, disable, or enable menu items depending on the current state of your application.</p>
 
+<p>On Android 2.3 and lower, the system calls {@link android.app.Activity#onPrepareOptionsMenu(Menu)
+onPrepareOptionsMenu()} each time the user opens the Options Menu.</p>
+
+<p>On Android 3.0 and higher, you must call {@link android.app.Activity#invalidateOptionsMenu
+invalidateOptionsMenu()} when you want to update the menu, because the menu is always open. The
+system will then call {@link android.app.Activity#onPrepareOptionsMenu(Menu) onPrepareOptionsMenu()}
+so you can update the menu items.</p>
+
 <p class="note"><strong>Note:</strong> 
 You should never change items in the Options Menu based on the {@link android.view.View} currently
-in focus. When in touch mode (when the user is not using a trackball or d-pad), Views
+in focus. When in touch mode (when the user is not using a trackball or d-pad), views
 cannot take focus, so you should never use focus as the basis for modifying
 items in the Options Menu. If you want to provide menu items that are context-sensitive to a {@link
 android.view.View}, use a <a href="#context-menu">Context Menu</a>.</p>
 
+<p>If you're developing for Android 3.0 or higher, be sure to also read <a
+href="{@docRoot}guide/topics/ui/actionbar.html">Using the Action Bar</a>.</p>
+
+
 
 
 <h2 id="context-menu">Creating a Context Menu</h2>
@@ -287,7 +324,7 @@
 <div class="sidebox-wrapper">
 <div class="sidebox">
 <h3>Register a ListView</h3>
-<p>If your Activity uses a {@link android.widget.ListView} and
+<p>If your activity uses a {@link android.widget.ListView} and
 you want all list items to provide a context menu, register all items for a context
 menu by passing the {@link android.widget.ListView} to {@link
 android.app.Activity#registerForContextMenu(View) registerForContextMenu()}. For
@@ -301,7 +338,7 @@
 pass it the {@link android.view.View} you want to give a context menu. When this View then
 receives a long-press, it displays a context menu.</p>
 
-<p>To define the context menu's appearance and behavior, override your Activity's context menu
+<p>To define the context menu's appearance and behavior, override your activity's context menu
 callback methods, {@link android.app.Activity#onCreateContextMenu(ContextMenu,View,ContextMenuInfo)
 onCreateContextMenu()} and
 {@link android.app.Activity#onContextItemSelected(MenuItem) onContextItemSelected()}.</p>
@@ -325,7 +362,7 @@
 parameters include the {@link android.view.View}
 that the user selected and a {@link android.view.ContextMenu.ContextMenuInfo} object that provides
 additional information about the item selected. You might use these parameters to determine
-which context menu should be created, but in this example, all context menus for the Activity are
+which context menu should be created, but in this example, all context menus for the activity are
 the same.</p>
 
 <p>Then when the user selects an item from the context menu, the system calls {@link
@@ -387,9 +424,9 @@
           android:icon="@drawable/file"
           android:title="@string/file" &gt;
         &lt;!-- "file" submenu --&gt;
-        &lt;menu"&gt;
-            &lt;item android:id="@+id/new"
-                  android:title="@string/new" /&gt;
+        &lt;menu&gt;
+            &lt;item android:id="@+id/create_new"
+                  android:title="@string/create_new" /&gt;
             &lt;item android:id="@+id/open"
                   android:title="@string/open" /&gt;
         &lt;/menu&gt;
@@ -456,8 +493,9 @@
 <h3 id="checkable">Checkable menu items</h3>
 
 <div class="figure" style="width:200px">
-  <img src="{@docRoot}images/radio_buttons.png" height="300" alt="" />
-  <p class="img-caption"><strong>Figure 2.</strong> Screenshot of checkable menu items</p>
+  <img src="{@docRoot}images/radio_buttons.png" height="333" alt="" />
+  <p class="img-caption"><strong>Figure 3.</strong> Screenshot of a submenu with checkable
+items.</p>
 </div>
 
 <p>A menu can be useful as an interface for turning options on and off, using a checkbox for
@@ -525,7 +563,7 @@
 
 <p>If you don't set the checked state this way, then the visible state of the item (the checkbox or
 radio button) will not
-change when the user selects it. When you do set the state, the Activity preserves the checked state
+change when the user selects it. When you do set the state, the activity preserves the checked state
 of the item so that when the user opens the menu later, the checked state that you
 set is visible.</p>
 
@@ -538,7 +576,8 @@
 
 <h3 id="shortcuts">Shortcut keys</h3>
 
-<p>You can add quick-access shortcut keys using letters and/or numbers to menu items with the
+<p>To facilitate quick access to items in the Options Menu when the user's device has a hardware
+keyboard, you can add quick-access shortcut keys using letters and/or numbers, with the
 {@code android:alphabeticShortcut} and {@code android:numericShortcut} attributes in the {@code
 &lt;item&gt;} element. You can also use the methods {@link
 android.view.MenuItem#setAlphabeticShortcut(char)} and {@link
@@ -546,57 +585,46 @@
 case sensitive.</p>
 
 <p>For example, if you apply the "s" character as an alphabetic shortcut to a "save" menu item, then
-when the menu is open (or while the user holds the MENU key) and the user presses the "s" key,
+when the menu is open (or while the user holds the MENU button) and the user presses the "s" key,
 the "save" menu item is selected.</p>
 
 <p>This shortcut key is displayed as a tip in the menu item, below the menu item name
 (except for items in the Icon Menu, which are displayed only if the user holds the MENU
-key).</p>
+button).</p>
 
 <p class="note"><strong>Note:</strong> Shortcut keys for menu items only work on devices with a
 hardware keyboard. Shortcuts cannot be added to items in a Context Menu.</p>
 
 
-<h3 id="intents">Intents for menu items</h3>
 
-<p>Sometimes you'll want a menu item to launch an Activity using an Intent (whether it's an
-Activity in your application or another application). When you know the Intent you want to use and
-have a specific menu item that should initiate the Intent, you can execute the Intent with {@link
-android.app.Activity#startActivity(Intent) startActivity()} during the appropriate on-item-selected
-callback method (such as the {@link android.app.Activity#onOptionsItemSelected(MenuItem)
-onOptionsItemSelected()} callback).</p>
+<h3 id="intents">Dynamically adding menu intents</h3>
+
+<p>Sometimes you'll want a menu item to launch an activity using an {@link android.content.Intent}
+(whether it's an activity in your application or another application). When you know the intent you
+want to use and have a specific menu item that should initiate the intent, you can execute the
+intent with {@link android.app.Activity#startActivity(Intent) startActivity()} during the
+appropriate on-item-selected callback method (such as the {@link
+android.app.Activity#onOptionsItemSelected(MenuItem) onOptionsItemSelected()} callback).</p>
 
 <p>However, if you are not certain that the user's device
-contains an application that handles the Intent, then adding a menu item that executes the
-Intent can result in a non-functioning menu item, because the Intent might not resolve to an
-Activity that accepts it. To solve this, Android lets you dynamically add menu items to your menu
-when Android finds activities on the device that handle your Intent.</p>
+contains an application that handles the intent, then adding a menu item that invokes it can result
+in a non-functioning menu item, because the intent might not resolve to an
+activity. To solve this, Android lets you dynamically add menu items to your menu
+when Android finds activities on the device that handle your intent.</p>
 
-<p>If you're not familiar with creating Intents, read the <a
-href="/guide/topics/intents/intents-filters.html">Intents and Intent Filters</a>.</p>
-
-
-<h4>Dynamically adding Intents</h4>
-
-<p>When you don't know if the user's device has an application that handles a specific Intent,
-you can define the Intent and let Android search the device for activities that accept the Intent.
-When it finds activies that handle the Intent, it adds a menu item for
-each one to your menu and attaches the appropriate Intent to open the Activity when the user
-selects it.</p>
-
-<p>To add menu items based on available activities that accept an Intent:</p>
+<p>To add menu items based on available activities that accept an intent:</p>
 <ol>
   <li>Define an
-Intent with the category {@link android.content.Intent#CATEGORY_ALTERNATIVE} and/or
+intent with the category {@link android.content.Intent#CATEGORY_ALTERNATIVE} and/or
 {@link android.content.Intent#CATEGORY_SELECTED_ALTERNATIVE}, plus any other requirements.</li>
   <li>Call {@link
 android.view.Menu#addIntentOptions(int,int,int,ComponentName,Intent[],Intent,int,MenuItem[])
-Menu.addIntentOptions()}. Android then searches for any applications that can perform the Intent
+Menu.addIntentOptions()}. Android then searches for any applications that can perform the intent
 and adds them to your menu.</li>
 </ol>
 
 <p>If there are no applications installed
-that satisfy the Intent, then no menu items are added.</p>
+that satisfy the intent, then no menu items are added.</p>
 
 <p class="note"><strong>Note:</strong>
 {@link android.content.Intent#CATEGORY_SELECTED_ALTERNATIVE} is used to handle the currently
@@ -621,7 +649,7 @@
          R.id.intent_group,  // Menu group to which new items will be added
          0,      // Unique item ID (none)
          0,      // Order for the items (none)
-         this.getComponentName(),   // The current Activity name
+         this.getComponentName(),   // The current activity name
          null,   // Specific items to place first (none)
          intent, // Intent created above that describes our requirements
          0,      // Additional flags to control items (none)
@@ -630,8 +658,8 @@
     return true;
 }</pre>
 
-<p>For each Activity found that provides an Intent filter matching the Intent defined, a menu
-item is added, using the value in the Intent filter's <code>android:label</code> as the
+<p>For each activity found that provides an intent filter matching the intent defined, a menu
+item is added, using the value in the intent filter's <code>android:label</code> as the
 menu item title and the application icon as the menu item icon. The
 {@link android.view.Menu#addIntentOptions(int,int,int,ComponentName,Intent[],Intent,int,MenuItem[])
 addIntentOptions()} method returns the number of menu items added.</p>
@@ -642,14 +670,14 @@
 argument.</p>
 
 
-<h4>Allowing your Activity to be added to menus</h4>
+<h4>Allowing your activity to be added to other menus</h4>
 
-<p>You can also offer the services of your Activity to other applications, so your
+<p>You can also offer the services of your activity to other applications, so your
 application can be included in the menu of others (reverse the roles described above).</p>
 
-<p>To be included in other application menus, you need to define an Intent
+<p>To be included in other application menus, you need to define an intent
 filter as usual, but be sure to include the {@link android.content.Intent#CATEGORY_ALTERNATIVE}
-and/or {@link android.content.Intent#CATEGORY_SELECTED_ALTERNATIVE} values for the Intent filter
+and/or {@link android.content.Intent#CATEGORY_SELECTED_ALTERNATIVE} values for the intent filter
 category. For example:</p>
 <pre>
 &lt;intent-filter label="Resize Image">
@@ -660,7 +688,7 @@
 &lt;/intent-filter>
 </pre>
 
-<p>Read more about writing Intent filters in the
+<p>Read more about writing intent filters in the
 <a href="/guide/topics/intents/intents-filters.html">Intents and Intent Filters</a> document.</p>
 
 <p>For a sample application using this technique, see the 
diff --git a/docs/html/images/options_menu.png b/docs/html/images/options_menu.png
index ecb9394..6c49906 100755
--- a/docs/html/images/options_menu.png
+++ b/docs/html/images/options_menu.png
Binary files differ
diff --git a/docs/html/images/radio_buttons.png b/docs/html/images/radio_buttons.png
index b755e42..415ccca 100755
--- a/docs/html/images/radio_buttons.png
+++ b/docs/html/images/radio_buttons.png
Binary files differ
diff --git a/graphics/java/android/graphics/Canvas.java b/graphics/java/android/graphics/Canvas.java
index c1deed3..136e9b4 100644
--- a/graphics/java/android/graphics/Canvas.java
+++ b/graphics/java/android/graphics/Canvas.java
@@ -104,7 +104,7 @@
     public Canvas() {
         // 0 means no native bitmap
         mNativeCanvas = initRaster(0);
-        mFinalizer = new CanvasFinalizer(0);
+        mFinalizer = new CanvasFinalizer(mNativeCanvas);
     }
 
     /**
diff --git a/libs/hwui/Caches.cpp b/libs/hwui/Caches.cpp
index ebf7aa0..4f5edd5 100644
--- a/libs/hwui/Caches.cpp
+++ b/libs/hwui/Caches.cpp
@@ -76,8 +76,14 @@
     LOGD("  PathCache            %8d / %8d", pathCache.getSize(), pathCache.getMaxSize());
     LOGD("  CircleShapeCache     %8d / %8d",
             circleShapeCache.getSize(), circleShapeCache.getMaxSize());
+    LOGD("  OvalShapeCache       %8d / %8d",
+            ovalShapeCache.getSize(), ovalShapeCache.getMaxSize());
     LOGD("  RoundRectShapeCache  %8d / %8d",
             roundRectShapeCache.getSize(), roundRectShapeCache.getMaxSize());
+    LOGD("  RectShapeCache       %8d / %8d",
+            rectShapeCache.getSize(), rectShapeCache.getMaxSize());
+    LOGD("  ArcShapeCache        %8d / %8d",
+            arcShapeCache.getSize(), arcShapeCache.getMaxSize());
     LOGD("  TextDropShadowCache  %8d / %8d", dropShadowCache.getSize(),
             dropShadowCache.getMaxSize());
     for (uint32_t i = 0; i < fontRenderer.getFontRendererCount(); i++) {
@@ -94,6 +100,11 @@
     total += gradientCache.getSize();
     total += pathCache.getSize();
     total += dropShadowCache.getSize();
+    total += roundRectShapeCache.getSize();
+    total += circleShapeCache.getSize();
+    total += ovalShapeCache.getSize();
+    total += rectShapeCache.getSize();
+    total += arcShapeCache.getSize();
     for (uint32_t i = 0; i < fontRenderer.getFontRendererCount(); i++) {
         total += fontRenderer.getFontRendererSize(i);
     }
diff --git a/libs/hwui/DisplayListRenderer.cpp b/libs/hwui/DisplayListRenderer.cpp
index cfc853c..2df52ae 100644
--- a/libs/hwui/DisplayListRenderer.cpp
+++ b/libs/hwui/DisplayListRenderer.cpp
@@ -22,62 +22,6 @@
 namespace uirenderer {
 
 ///////////////////////////////////////////////////////////////////////////////
-// Defines
-///////////////////////////////////////////////////////////////////////////////
-
-#define PATH_HEAP_SIZE 64
-
-///////////////////////////////////////////////////////////////////////////////
-// Helpers
-///////////////////////////////////////////////////////////////////////////////
-
-PathHeap::PathHeap(): mHeap(PATH_HEAP_SIZE * sizeof(SkPath)) {
-}
-
-PathHeap::PathHeap(SkFlattenableReadBuffer& buffer): mHeap(PATH_HEAP_SIZE * sizeof(SkPath)) {
-    int count = buffer.readS32();
-
-    mPaths.setCount(count);
-    SkPath** ptr = mPaths.begin();
-    SkPath* p = (SkPath*) mHeap.allocThrow(count * sizeof(SkPath));
-
-    for (int i = 0; i < count; i++) {
-        new (p) SkPath;
-        p->unflatten(buffer);
-        *ptr++ = p;
-        p++;
-    }
-}
-
-PathHeap::~PathHeap() {
-    SkPath** iter = mPaths.begin();
-    SkPath** stop = mPaths.end();
-    while (iter < stop) {
-        (*iter)->~SkPath();
-        iter++;
-    }
-}
-
-int PathHeap::append(const SkPath& path) {
-    SkPath* p = (SkPath*) mHeap.allocThrow(sizeof(SkPath));
-    new (p) SkPath(path);
-    *mPaths.append() = p;
-    return mPaths.count();
-}
-
-void PathHeap::flatten(SkFlattenableWriteBuffer& buffer) const {
-    int count = mPaths.count();
-
-    buffer.write32(count);
-    SkPath** iter = mPaths.begin();
-    SkPath** stop = mPaths.end();
-    while (iter < stop) {
-        (*iter)->flatten(buffer);
-        iter++;
-    }
-}
-
-///////////////////////////////////////////////////////////////////////////////
 // Display list
 ///////////////////////////////////////////////////////////////////////////////
 
@@ -124,6 +68,10 @@
 }
 
 DisplayList::~DisplayList() {
+    clearResources();
+}
+
+void DisplayList::clearResources() {
     sk_free((void*) mReader.base());
 
     Caches& caches = Caches::getInstance();
@@ -143,20 +91,18 @@
     }
     mPaints.clear();
 
+    for (size_t i = 0; i < mPaths.size(); i++) {
+        delete mPaths.itemAt(i);
+    }
+    mPaths.clear();
+
     for (size_t i = 0; i < mMatrices.size(); i++) {
         delete mMatrices.itemAt(i);
     }
     mMatrices.clear();
-
-    if (mPathHeap) {
-        for (int i = 0; i < mPathHeap->count(); i++) {
-            caches.pathCache.removeDeferred(&(*mPathHeap)[i]);
-        }
-        mPathHeap->safeUnref();
-    }
 }
 
-void DisplayList::initFromDisplayListRenderer(const DisplayListRenderer& recorder) {
+void DisplayList::initFromDisplayListRenderer(const DisplayListRenderer& recorder, bool reusing) {
     const SkWriter32& writer = recorder.writeStream();
     init();
 
@@ -164,17 +110,16 @@
         return;
     }
 
+    if (reusing) {
+        // re-using display list - clear out previous allocations
+        clearResources();
+    }
+
     size_t size = writer.size();
     void* buffer = sk_malloc_throw(size);
     writer.flatten(buffer);
     mReader.setMemory(buffer, size);
 
-    mRCPlayback.reset(&recorder.mRCRecorder);
-    mRCPlayback.setupBuffer(mReader);
-
-    mTFPlayback.reset(&recorder.mTFRecorder);
-    mTFPlayback.setupBuffer(mReader);
-
     Caches& caches = Caches::getInstance();
 
     const Vector<SkBitmap*> &bitmapResources = recorder.getBitmapResources();
@@ -196,19 +141,18 @@
         mPaints.add(paints.itemAt(i));
     }
 
+    const Vector<SkPath*> &paths = recorder.getPaths();
+    for (size_t i = 0; i < paths.size(); i++) {
+        mPaths.add(paths.itemAt(i));
+    }
+
     const Vector<SkMatrix*> &matrices = recorder.getMatrices();
     for (size_t i = 0; i < matrices.size(); i++) {
         mMatrices.add(matrices.itemAt(i));
     }
-
-    mPathHeap = recorder.mPathHeap;
-    if (mPathHeap) {
-        mPathHeap->safeRef();
-    }
 }
 
 void DisplayList::init() {
-    mPathHeap = NULL;
 }
 
 bool DisplayList::replay(OpenGLRenderer& renderer, uint32_t level) {
@@ -557,9 +501,7 @@
 // Base structure
 ///////////////////////////////////////////////////////////////////////////////
 
-DisplayListRenderer::DisplayListRenderer():
-        mHeap(HEAP_BLOCK_SIZE), mWriter(MIN_WRITER_SIZE) {
-    mPathHeap = NULL;
+DisplayListRenderer::DisplayListRenderer(): mWriter(MIN_WRITER_SIZE) {
     mDisplayList = NULL;
 }
 
@@ -568,16 +510,7 @@
 }
 
 void DisplayListRenderer::reset() {
-    if (mPathHeap) {
-        mPathHeap->unref();
-        mPathHeap = NULL;
-    }
-
     mWriter.reset();
-    mHeap.reset();
-
-    mRCRecorder.reset();
-    mTFRecorder.reset();
 
     Caches& caches = Caches::getInstance();
     for (size_t i = 0; i < mBitmapResources.size(); i++) {
@@ -594,6 +527,8 @@
 
     mPaints.clear();
     mPaintMap.clear();
+    mPaths.clear();
+    mPathMap.clear();
     mMatrices.clear();
 }
 
@@ -605,7 +540,7 @@
     if (mDisplayList == NULL) {
         mDisplayList = new DisplayList(*this);
     } else {
-        mDisplayList->initFromDisplayListRenderer(*this);
+        mDisplayList->initFromDisplayListRenderer(*this, true);
     }
     return mDisplayList;
 }
diff --git a/libs/hwui/DisplayListRenderer.h b/libs/hwui/DisplayListRenderer.h
index a6d2bfe..2d0e30a 100644
--- a/libs/hwui/DisplayListRenderer.h
+++ b/libs/hwui/DisplayListRenderer.h
@@ -38,7 +38,6 @@
 ///////////////////////////////////////////////////////////////////////////////
 
 #define MIN_WRITER_SIZE 16384
-#define HEAP_BLOCK_SIZE 4096
 
 // Debug
 #if DEBUG_DISPLAY_LIST
@@ -48,31 +47,6 @@
 #endif
 
 ///////////////////////////////////////////////////////////////////////////////
-// Helpers
-///////////////////////////////////////////////////////////////////////////////
-
-class PathHeap: public SkRefCnt {
-public:
-    PathHeap();
-    PathHeap(SkFlattenableReadBuffer& buffer);
-    ~PathHeap();
-
-    int append(const SkPath& path);
-
-    int count() const { return mPaths.count(); }
-
-    SkPath& operator[](int index) const {
-        return *mPaths[index];
-    }
-
-    void flatten(SkFlattenableWriteBuffer& buffer) const;
-
-private:
-    SkChunkAlloc mHeap;
-    SkTDArray<SkPath*> mPaths;
-};
-
-///////////////////////////////////////////////////////////////////////////////
 // Display list
 ///////////////////////////////////////////////////////////////////////////////
 
@@ -128,13 +102,15 @@
 
     static const char* OP_NAMES[];
 
-    void initFromDisplayListRenderer(const DisplayListRenderer& recorder);
+    void initFromDisplayListRenderer(const DisplayListRenderer& recorder, bool reusing = false);
 
     bool replay(OpenGLRenderer& renderer, uint32_t level = 0);
 
 private:
     void init();
 
+    void clearResources();
+
     class TextContainer {
     public:
         size_t length() const {
@@ -174,7 +150,7 @@
     }
 
     SkPath* getPath() {
-        return &(*mPathHeap)[getInt() - 1];
+        return (SkPath*) getInt();
     }
 
     SkPaint* getPaint() {
@@ -209,19 +185,15 @@
         text->mText = (const char*) mReader.skip(length);
     }
 
-    PathHeap* mPathHeap;
-
     Vector<SkBitmap*> mBitmapResources;
     Vector<SkiaColorFilter*> mFilterResources;
 
     Vector<SkPaint*> mPaints;
+    Vector<SkPath*> mPaths;
     Vector<SkMatrix*> mMatrices;
     Vector<SkiaShader*> mShaders;
 
     mutable SkFlattenableReadBuffer mReader;
-
-    SkRefCntPlayback mRCPlayback;
-    SkTypefacePlayback mTFPlayback;
 };
 
 ///////////////////////////////////////////////////////////////////////////////
@@ -317,6 +289,10 @@
         return mPaints;
     }
 
+    const Vector<SkPath*>& getPaths() const {
+        return mPaths;
+    }
+
     const Vector<SkMatrix*>& getMatrices() const {
         return mMatrices;
     }
@@ -385,11 +361,24 @@
         mWriter.writePad(text, byteLength);
     }
 
-    inline void addPath(const SkPath* path) {
-        if (mPathHeap == NULL) {
-            mPathHeap = new PathHeap();
+    inline void addPath(SkPath* path) {
+        if (!path) {
+            addInt((int) NULL);
+            return;
         }
-        addInt(mPathHeap->append(*path));
+
+        SkPath* pathCopy = mPathMap.valueFor(path);
+        if (pathCopy == NULL || pathCopy->getGenerationID() != path->getGenerationID()) {
+            if (pathCopy == NULL) {
+                pathCopy = path;
+            } else {
+                pathCopy = new SkPath(*path);
+                mPaths.add(pathCopy);
+            }
+            mPathMap.add(path, pathCopy);
+        }
+
+        addInt((int) pathCopy);
     }
 
     inline void addPaint(SkPaint* paint) {
@@ -457,25 +446,22 @@
         caches.resourceCache.incrementRefcount(colorFilter);
     }
 
-    SkChunkAlloc mHeap;
-
     Vector<SkBitmap*> mBitmapResources;
     Vector<SkiaColorFilter*> mFilterResources;
 
     Vector<SkPaint*> mPaints;
     DefaultKeyedVector<SkPaint*, SkPaint*> mPaintMap;
 
+    Vector<SkPath*> mPaths;
+    DefaultKeyedVector<SkPath*, SkPath*> mPathMap;
+
     Vector<SkiaShader*> mShaders;
     DefaultKeyedVector<SkiaShader*, SkiaShader*> mShaderMap;
 
     Vector<SkMatrix*> mMatrices;
 
-    PathHeap* mPathHeap;
     SkWriter32 mWriter;
 
-    SkRefCntRecorder mRCRecorder;
-    SkRefCntRecorder mTFRecorder;
-
     DisplayList *mDisplayList;
 
     int mRestoreSaveCount;
diff --git a/libs/hwui/PathCache.cpp b/libs/hwui/PathCache.cpp
index 28c302e..0f22bea 100644
--- a/libs/hwui/PathCache.cpp
+++ b/libs/hwui/PathCache.cpp
@@ -65,7 +65,6 @@
 
 PathTexture* PathCache::get(SkPath* path, SkPaint* paint) {
     PathCacheEntry entry(path, paint);
-
     PathTexture* texture = mCache.get(entry);
 
     if (!texture) {
diff --git a/libs/hwui/Snapshot.h b/libs/hwui/Snapshot.h
index 595ad4e..bd70319 100644
--- a/libs/hwui/Snapshot.h
+++ b/libs/hwui/Snapshot.h
@@ -150,6 +150,10 @@
                 break;
             case SkRegion::kIntersect_Op:
                 clipped = clipRect->intersect(r);
+                if (!clipped) {
+                    clipRect->setEmpty();
+                    clipped = true;
+                }
                 break;
             case SkRegion::kUnion_Op:
                 clipped = clipRect->unionWith(r);
diff --git a/libs/hwui/TextDropShadowCache.h b/libs/hwui/TextDropShadowCache.h
index 8cefc8c..ffccfa2 100644
--- a/libs/hwui/TextDropShadowCache.h
+++ b/libs/hwui/TextDropShadowCache.h
@@ -32,7 +32,7 @@
 namespace uirenderer {
 
 struct ShadowText {
-    ShadowText(): radius(0), len(0), hash(0), textSize(0.0f), typeface(NULL) {
+    ShadowText(): radius(0), len(0), textSize(0.0f), typeface(NULL) {
     }
 
     ShadowText(SkPaint* paint, uint32_t radius, uint32_t len, const char* srcText):
@@ -42,20 +42,11 @@
 
         textSize = paint->getTextSize();
         typeface = paint->getTypeface();
-
-        hash = 0;
-        uint32_t multiplier = 1;
-        const char* text = str.string();
-        for (uint32_t i = 0; i < len; i++) {
-            hash += text[i] * multiplier;
-            uint32_t shifted = multiplier << 5;
-            multiplier = shifted - multiplier;
-        }
     }
 
     ShadowText(const ShadowText& shadow):
-            radius(shadow.radius), len(shadow.len), hash(shadow.hash),
-            textSize(shadow.textSize), typeface(shadow.typeface), str(shadow.str) {
+            radius(shadow.radius), len(shadow.len), textSize(shadow.textSize),
+            typeface(shadow.typeface), str(shadow.str) {
     }
 
     ~ShadowText() {
@@ -63,20 +54,17 @@
 
     uint32_t radius;
     uint32_t len;
-    uint32_t hash;
     float textSize;
     SkTypeface* typeface;
     String8 str;
 
     bool operator<(const ShadowText& rhs) const {
-        LTE_INT(hash) {
-            LTE_INT(len) {
-                LTE_INT(radius) {
-                    LTE_FLOAT(textSize) {
-                        if (typeface < rhs.typeface) return true;
-                        else if (typeface == rhs.typeface) {
-                            return str.compare(rhs.str) < 0;
-                        }
+        LTE_INT(len) {
+            LTE_INT(radius) {
+                LTE_FLOAT(textSize) {
+                    if (typeface < rhs.typeface) return true;
+                    else if (typeface == rhs.typeface) {
+                        return str.compare(rhs.str) < 0;
                     }
                 }
             }
diff --git a/media/java/android/media/videoeditor/MediaArtistNativeHelper.java b/media/java/android/media/videoeditor/MediaArtistNativeHelper.java
index 297c4df..6b3f223 100644
--- a/media/java/android/media/videoeditor/MediaArtistNativeHelper.java
+++ b/media/java/android/media/videoeditor/MediaArtistNativeHelper.java
@@ -23,7 +23,6 @@
 import java.util.Iterator;
 import java.util.List;
 import java.util.concurrent.Semaphore;
-import java.util.concurrent.TimeUnit;
 
 import android.graphics.Bitmap;
 import android.graphics.BitmapFactory;
@@ -58,6 +57,10 @@
     private static final Paint sResizePaint = new Paint(Paint.FILTER_BITMAP_FLAG);
 
     private final VideoEditor mVideoEditor;
+    /*
+     *  Semaphore to control preview calls
+     */
+    private final Semaphore mLock;
 
     private EditSettings mStoryBoardSettings;
 
@@ -79,11 +82,6 @@
 
     private int mProgressToApp;
 
-    /*
-     *  Semaphore to control preview calls
-     */
-    private final Semaphore mLock = new Semaphore(1, true);
-
     private String mRenderPreviewOverlayFile;
     private int mRenderPreviewRenderingMode;
 
@@ -1775,9 +1773,10 @@
      *
      * @param projectPath The path where the VideoEditor stores all files
      *        related to the project
+     * @param lock The semaphore
      * @param veObj The video editor reference
      */
-    public MediaArtistNativeHelper(String projectPath, VideoEditor veObj) {
+    public MediaArtistNativeHelper(String projectPath, Semaphore lock, VideoEditor veObj) {
         mProjectPath = projectPath;
         if (veObj != null) {
             mVideoEditor = veObj;
@@ -1785,8 +1784,11 @@
             mVideoEditor = null;
             throw new IllegalArgumentException("video editor object is null");
         }
-        if (mStoryBoardSettings == null)
+        if (mStoryBoardSettings == null) {
             mStoryBoardSettings = new EditSettings();
+        }
+
+        mLock = lock;
 
         _init(mProjectPath, "null");
         mAudioTrackPCMFilePath = null;
@@ -1932,16 +1934,8 @@
     /**
      * Release the native helper object
      */
-    void releaseNativeHelper() {
-        try {
-            release();
-        } catch (IllegalStateException ex) {
-            Log.e(TAG, "Illegal State exeption caught in releaseNativeHelper");
-            throw ex;
-        } catch (RuntimeException ex) {
-            Log.e(TAG, "Runtime exeption caught in releaseNativeHelper");
-            throw ex;
-        }
+    void releaseNativeHelper() throws InterruptedException {
+        release();
     }
 
     /**
@@ -3735,18 +3729,15 @@
      */
     Bitmap getPixels(String inputFile, int width, int height, long timeMS) {
         if (inputFile == null) {
-            throw new IllegalArgumentException();
+            throw new IllegalArgumentException("Invalid input file");
         }
 
-        int newWidth = 0;
-        int newHeight = 0;
-        Bitmap tempBitmap = null;
-
         /* Make width and height as even */
-        newWidth = (width + 1) & 0xFFFFFFFE;
-        newHeight = (height + 1) & 0xFFFFFFFE;
+        final int newWidth = (width + 1) & 0xFFFFFFFE;
+        final int newHeight = (height + 1) & 0xFFFFFFFE;
 
         /* Create a temp bitmap for resized thumbnails */
+        Bitmap tempBitmap = null;
         if ((newWidth != width) || (newHeight != height)) {
              tempBitmap = Bitmap.createBitmap(newWidth, newHeight, Bitmap.Config.ARGB_8888);
         }
@@ -3770,6 +3761,7 @@
         if (tempBitmap != null) {
             tempBitmap.recycle();
         }
+
         return bitmap;
     }
 
@@ -3787,17 +3779,15 @@
      *
      * @return The frames as bitmaps in bitmap array
      **/
-    public Bitmap[] getPixelsList(String filename, int width, int height, long startMs, long endMs,
+    Bitmap[] getPixelsList(String filename, int width, int height, long startMs, long endMs,
             int thumbnailCount) {
         int[] rgb888 = null;
         int thumbnailSize = 0;
-        int newWidth = 0;
-        int newHeight = 0;
         Bitmap tempBitmap = null;
 
         /* Make width and height as even */
-        newWidth = (width + 1) & 0xFFFFFFFE;
-        newHeight = (height + 1) & 0xFFFFFFFE;
+        final int newWidth = (width + 1) & 0xFFFFFFFE;
+        final int newHeight = (height + 1) & 0xFFFFFFFE;
         thumbnailSize = newWidth * newHeight * 4;
 
         /* Create a temp bitmap for resized thumbnails */
@@ -3820,7 +3810,8 @@
                 bitmaps = new Bitmap[MAX_THUMBNAIL_PERMITTED];
                 thumbnailCount = MAX_THUMBNAIL_PERMITTED;
             } catch (Throwable ex) {
-                throw new RuntimeException("Memory allocation fails, thumbnail count too large: "+thumbnailCount);
+                throw new RuntimeException("Memory allocation fails, thumbnail count too large: "
+                        + thumbnailCount);
             }
         }
         IntBuffer tmpBuffer = IntBuffer.allocate(thumbnailSize);
@@ -3848,6 +3839,7 @@
         if (tempBitmap != null) {
             tempBitmap.recycle();
         }
+
         return bitmaps;
     }
 
@@ -3908,7 +3900,7 @@
      *
      * @throws InterruptedException
      */
-    void lock() throws InterruptedException {
+    private void lock() throws InterruptedException {
         if (Log.isLoggable(TAG, Log.DEBUG)) {
             Log.d(TAG, "lock: grabbing semaphore", new Throwable());
         }
@@ -3919,30 +3911,9 @@
     }
 
     /**
-     * Tries to grab the semaphore with a specified time out which arbitrates access to the editor
-     *
-     * @param timeoutMs time out in ms.
-     *
-     * @return true if the semaphore is acquired, false otherwise
-     * @throws InterruptedException
-     */
-    boolean lock(long timeoutMs) throws InterruptedException {
-        if (Log.isLoggable(TAG, Log.DEBUG)) {
-            Log.d(TAG, "lock: grabbing semaphore with timeout " + timeoutMs, new Throwable());
-        }
-
-        boolean acquireSem = mLock.tryAcquire(timeoutMs, TimeUnit.MILLISECONDS);
-        if (Log.isLoggable(TAG, Log.DEBUG)) {
-            Log.d(TAG, "lock: grabbed semaphore status " + acquireSem);
-        }
-
-        return acquireSem;
-    }
-
-    /**
      * Release the semaphore which arbitrates access to the editor
      */
-    void unlock() {
+    private void unlock() {
         if (Log.isLoggable(TAG, Log.DEBUG)) {
             Log.d(TAG, "unlock: releasing semaphore");
         }
diff --git a/media/java/android/media/videoeditor/VideoEditorImpl.java b/media/java/android/media/videoeditor/VideoEditorImpl.java
index 33a8654..3019057 100755
--- a/media/java/android/media/videoeditor/VideoEditorImpl.java
+++ b/media/java/android/media/videoeditor/VideoEditorImpl.java
@@ -27,6 +27,9 @@
 import java.util.Iterator;
 import java.util.List;
 import java.util.Map;
+import java.util.concurrent.Semaphore;
+import java.util.concurrent.TimeUnit;
+
 import org.xmlpull.v1.XmlPullParser;
 import org.xmlpull.v1.XmlPullParserException;
 import org.xmlpull.v1.XmlSerializer;
@@ -118,11 +121,12 @@
     /*
      *  Instance variables
      */
-    private long mDurationMs;
+    private final Semaphore mLock;
     private final String mProjectPath;
     private final List<MediaItem> mMediaItems = new ArrayList<MediaItem>();
     private final List<AudioTrack> mAudioTracks = new ArrayList<AudioTrack>();
     private final List<Transition> mTransitions = new ArrayList<Transition>();
+    private long mDurationMs;
     private int mAspectRatio;
 
     /*
@@ -138,7 +142,8 @@
      *        related to the project
      */
     public VideoEditorImpl(String projectPath) throws IOException {
-        mMANativeHelper = new MediaArtistNativeHelper(projectPath, this);
+        mLock = new Semaphore(1, true);
+        mMANativeHelper = new MediaArtistNativeHelper(projectPath, mLock, this);
         mProjectPath = projectPath;
         final File projectXml = new File(projectPath, PROJECT_FILENAME);
         if (projectXml.exists()) {
@@ -417,15 +422,20 @@
 
         boolean semAcquireDone = false;
         try {
-            mMANativeHelper.lock();
+            lock();
             semAcquireDone = true;
+
+            if (mMANativeHelper == null) {
+                throw new IllegalStateException("The video editor is not initialized");
+            }
+
             mMANativeHelper.export(filename, mProjectPath, height,bitrate,
                                mMediaItems, mTransitions, mAudioTracks, listener);
         } catch (InterruptedException  ex) {
             Log.e(TAG, "Sem acquire NOT successful in export");
         } finally {
             if (semAcquireDone) {
-                mMANativeHelper.unlock();
+                unlock();
             }
         }
     }
@@ -436,9 +446,13 @@
     public void generatePreview(MediaProcessingProgressListener listener) {
         boolean semAcquireDone = false;
         try {
-            mMANativeHelper.lock();
+            lock();
             semAcquireDone = true;
 
+            if (mMANativeHelper == null) {
+                throw new IllegalStateException("The video editor is not initialized");
+            }
+
             if ((mMediaItems.size() > 0) || (mAudioTracks.size() > 0)) {
                 mMANativeHelper.previewStoryBoard(mMediaItems, mTransitions, mAudioTracks,
                         listener);
@@ -447,7 +461,7 @@
             Log.e(TAG, "Sem acquire NOT successful in previewStoryBoard");
         } finally {
             if (semAcquireDone) {
-                mMANativeHelper.unlock();
+                unlock();
             }
         }
     }
@@ -675,11 +689,26 @@
      */
     public void release() {
         stopPreview();
-        mMediaItems.clear();
-        mAudioTracks.clear();
-        mTransitions.clear();
-        mMANativeHelper.releaseNativeHelper();
-        mMANativeHelper = null;
+
+        boolean semAcquireDone = false;
+        try {
+            lock();
+            semAcquireDone = true;
+
+            if (mMANativeHelper != null) {
+                mMediaItems.clear();
+                mAudioTracks.clear();
+                mTransitions.clear();
+                mMANativeHelper.releaseNativeHelper();
+                mMANativeHelper = null;
+            }
+        } catch (Exception  ex) {
+            Log.e(TAG, "Sem acquire NOT successful in export", ex);
+        } finally {
+            if (semAcquireDone) {
+                unlock();
+            }
+        }
     }
 
     /*
@@ -854,11 +883,15 @@
 
         boolean semAcquireDone = false;
         try {
-            semAcquireDone = mMANativeHelper.lock(ENGINE_ACCESS_MAX_TIMEOUT_MS);
+            semAcquireDone = lock(ENGINE_ACCESS_MAX_TIMEOUT_MS);
             if (semAcquireDone == false) {
                 throw new IllegalStateException("Timeout waiting for semaphore");
             }
 
+            if (mMANativeHelper == null) {
+                throw new IllegalStateException("The video editor is not initialized");
+            }
+
             if (mMediaItems.size() > 0) {
                 final Rect frame = surfaceHolder.getSurfaceFrame();
                 result = mMANativeHelper.renderPreviewFrame(surface,
@@ -871,7 +904,7 @@
             throw new IllegalStateException("The thread was interrupted");
         } finally {
             if (semAcquireDone) {
-                mMANativeHelper.unlock();
+                unlock();
             }
         }
         return result;
@@ -1568,11 +1601,15 @@
         boolean semAcquireDone = false;
         if (!mPreviewInProgress) {
             try{
-                semAcquireDone = mMANativeHelper.lock(ENGINE_ACCESS_MAX_TIMEOUT_MS);
+                semAcquireDone = lock(ENGINE_ACCESS_MAX_TIMEOUT_MS);
                 if (semAcquireDone == false) {
                     throw new IllegalStateException("Timeout waiting for semaphore");
                 }
 
+                if (mMANativeHelper == null) {
+                    throw new IllegalStateException("The video editor is not initialized");
+                }
+
                 if (mMediaItems.size() > 0) {
                     mPreviewInProgress = true;
                     mMANativeHelper.previewStoryBoard(mMediaItems, mTransitions,
@@ -1581,7 +1618,7 @@
                                      callbackAfterFrameCount, listener);
                 }
                 /**
-                 *  release on complete by calling stopPreview
+                 *  Release The lock on complete by calling stopPreview
                  */
             } catch (InterruptedException ex) {
                 Log.w(TAG, "The thread was interrupted", new Throwable());
@@ -1605,7 +1642,7 @@
                  */
                 } finally {
                     mPreviewInProgress = false;
-                    mMANativeHelper.unlock();
+                    unlock();
                 }
             return result;
         }
@@ -1791,4 +1828,50 @@
             Log.w(TAG, "Native helper was not ready!");
         }
     }
+
+    /**
+     * Grab the semaphore which arbitrates access to the editor
+     *
+     * @throws InterruptedException
+     */
+    private void lock() throws InterruptedException {
+        if (Log.isLoggable(TAG, Log.DEBUG)) {
+            Log.d(TAG, "lock: grabbing semaphore", new Throwable());
+        }
+        mLock.acquire();
+        if (Log.isLoggable(TAG, Log.DEBUG)) {
+            Log.d(TAG, "lock: grabbed semaphore");
+        }
+    }
+
+    /**
+     * Tries to grab the semaphore with a specified time out which arbitrates access to the editor
+     *
+     * @param timeoutMs time out in ms.
+     *
+     * @return true if the semaphore is acquired, false otherwise
+     * @throws InterruptedException
+     */
+    private boolean lock(long timeoutMs) throws InterruptedException {
+        if (Log.isLoggable(TAG, Log.DEBUG)) {
+            Log.d(TAG, "lock: grabbing semaphore with timeout " + timeoutMs, new Throwable());
+        }
+
+        boolean acquireSem = mLock.tryAcquire(timeoutMs, TimeUnit.MILLISECONDS);
+        if (Log.isLoggable(TAG, Log.DEBUG)) {
+            Log.d(TAG, "lock: grabbed semaphore status " + acquireSem);
+        }
+
+        return acquireSem;
+    }
+
+    /**
+     * Release the semaphore which arbitrates access to the editor
+     */
+    private void unlock() {
+        if (Log.isLoggable(TAG, Log.DEBUG)) {
+            Log.d(TAG, "unlock: releasing semaphore");
+        }
+        mLock.release();
+    }
 }
diff --git a/media/jni/mediaeditor/VideoBrowserMain.c b/media/jni/mediaeditor/VideoBrowserMain.c
index f54a16e..bb13fba 100755
--- a/media/jni/mediaeditor/VideoBrowserMain.c
+++ b/media/jni/mediaeditor/VideoBrowserMain.c
@@ -246,9 +246,13 @@
                     pContext->m_pCodecLoaderContext = M4OSA_NULL;
                     decoderType = M4DECODER_kVideoTypeMPEG4;
 
-                    err = VideoEditorVideoDecoder_getInterface_MPEG4(
-                        &decoderType, &pContext->m_pDecoder);
-
+#ifdef USE_SOFTWARE_DECODER
+                        err = VideoEditorVideoDecoder_getSoftwareInterface_MPEG4(
+                            &decoderType, &pContext->m_pDecoder);
+#else
+                        err = VideoEditorVideoDecoder_getInterface_MPEG4(
+                            &decoderType, &pContext->m_pDecoder);
+#endif
                     CHECK_ERR(videoBrowserCreate, err) ;
 
                     err = pContext->m_pDecoder->m_pFctCreate(
@@ -267,8 +271,14 @@
                     pContext->m_pCodecLoaderContext = M4OSA_NULL;
 
                     decoderType = M4DECODER_kVideoTypeAVC;
-                    err = VideoEditorVideoDecoder_getInterface_H264(
-                        &decoderType, &pContext->m_pDecoder);
+
+#ifdef USE_SOFTWARE_DECODER
+                        err = VideoEditorVideoDecoder_getSoftwareInterface_H264(
+                            &decoderType, &pContext->m_pDecoder);
+#else
+                        err = VideoEditorVideoDecoder_getInterface_H264(
+                            &decoderType, &pContext->m_pDecoder);
+#endif
                    CHECK_ERR(videoBrowserCreate, err) ;
 
                     err = pContext->m_pDecoder->m_pFctCreate(
diff --git a/packages/SystemUI/res/drawable-hdpi/stat_sys_data_bluetooth.png b/packages/SystemUI/res/drawable-hdpi/stat_sys_data_bluetooth.png
index fe9be2c..c9704fc 100644
--- a/packages/SystemUI/res/drawable-hdpi/stat_sys_data_bluetooth.png
+++ b/packages/SystemUI/res/drawable-hdpi/stat_sys_data_bluetooth.png
Binary files differ
diff --git a/packages/SystemUI/res/drawable-hdpi/stat_sys_data_bluetooth_connected.png b/packages/SystemUI/res/drawable-hdpi/stat_sys_data_bluetooth_connected.png
index f9b3966..b37dd9f 100644
--- a/packages/SystemUI/res/drawable-hdpi/stat_sys_data_bluetooth_connected.png
+++ b/packages/SystemUI/res/drawable-hdpi/stat_sys_data_bluetooth_connected.png
Binary files differ
diff --git a/packages/SystemUI/res/drawable-mdpi/stat_sys_data_bluetooth.png b/packages/SystemUI/res/drawable-mdpi/stat_sys_data_bluetooth.png
index 45a97fd..f615835 100644
--- a/packages/SystemUI/res/drawable-mdpi/stat_sys_data_bluetooth.png
+++ b/packages/SystemUI/res/drawable-mdpi/stat_sys_data_bluetooth.png
Binary files differ
diff --git a/packages/SystemUI/res/drawable-mdpi/stat_sys_data_bluetooth_connected.png b/packages/SystemUI/res/drawable-mdpi/stat_sys_data_bluetooth_connected.png
index 306afd0..f784e7e 100644
--- a/packages/SystemUI/res/drawable-mdpi/stat_sys_data_bluetooth_connected.png
+++ b/packages/SystemUI/res/drawable-mdpi/stat_sys_data_bluetooth_connected.png
Binary files differ
diff --git a/packages/SystemUI/res/layout-xlarge/status_bar_notification_area.xml b/packages/SystemUI/res/layout-xlarge/status_bar_notification_area.xml
index a892cd9..6e3b0d7 100644
--- a/packages/SystemUI/res/layout-xlarge/status_bar_notification_area.xml
+++ b/packages/SystemUI/res/layout-xlarge/status_bar_notification_area.xml
@@ -75,7 +75,7 @@
             android:id="@+id/clock"
             android:layout_width="wrap_content"
             android:layout_height="wrap_content"
-            android:layout_marginBottom="2dip"
+            android:layout_marginBottom="3dip"
             android:layout_marginLeft="4dip"
             android:layout_marginRight="4dip"
             >
diff --git a/packages/SystemUI/res/values-es-rUS-xlarge/strings.xml b/packages/SystemUI/res/values-es-rUS-xlarge/strings.xml
index 00b951e..7ba493d 100644
--- a/packages/SystemUI/res/values-es-rUS-xlarge/strings.xml
+++ b/packages/SystemUI/res/values-es-rUS-xlarge/strings.xml
@@ -22,4 +22,10 @@
     <string name="status_bar_clear_all_button" msgid="4722520806446512408">"Eliminar todos"</string>
     <string name="status_bar_settings_signal_meter_disconnected" msgid="4684094636492991496">"Sin conexión a Int."</string>
     <string name="status_bar_settings_signal_meter_wifi_nossid" msgid="1456658018593445677">"WiFi conectado"</string>
+
+    <!-- manually translated -->
+    <string name="gps_notification_searching_text">Buscando señal de GPS</string>
+
+    <!-- manually translated -->
+    <string name="gps_notification_found_text">Ubicación establecida por el GPS</string>
 </resources>
diff --git a/packages/SystemUI/res/values-xlarge/colors.xml b/packages/SystemUI/res/values-xlarge/colors.xml
index 1fd396d..a7a70c3 100644
--- a/packages/SystemUI/res/values-xlarge/colors.xml
+++ b/packages/SystemUI/res/values-xlarge/colors.xml
@@ -1,6 +1,6 @@
 <?xml version="1.0" encoding="utf-8"?>
 <resources>
     <drawable name="status_bar_background">#000000</drawable>
-    <drawable name="notification_icon_area_smoke">#CC000000</drawable>
+    <drawable name="notification_icon_area_smoke">#aa000000</drawable>
 </resources>
 
diff --git a/packages/SystemUI/res/values-xlarge/strings.xml b/packages/SystemUI/res/values-xlarge/strings.xml
index f7b642d..dfd5851 100644
--- a/packages/SystemUI/res/values-xlarge/strings.xml
+++ b/packages/SystemUI/res/values-xlarge/strings.xml
@@ -38,4 +38,9 @@
     <!-- Separator for PLMN and SPN in network name. -->
     <string name="status_bar_network_name_separator" translatable="false">" – "</string>
 
+    <!-- Notification text: when GPS is getting a fix [CHAR LIMIT=50] -->
+    <string name="gps_notification_searching_text">Searching for GPS</string>
+
+    <!-- Notification text: when GPS has found a fix [CHAR LIMIT=50] -->
+    <string name="gps_notification_found_text">Location set by GPS</string>
 </resources>
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/policy/LocationController.java b/packages/SystemUI/src/com/android/systemui/statusbar/policy/LocationController.java
new file mode 100644
index 0000000..bb326fe
--- /dev/null
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/policy/LocationController.java
@@ -0,0 +1,121 @@
+/*
+ * Copyright (C) 2008 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.android.systemui.statusbar.policy;
+
+import java.util.ArrayList;
+
+import android.app.Notification;
+import android.app.NotificationManager;
+import android.app.PendingIntent;
+import android.content.BroadcastReceiver;
+import android.content.Context;
+import android.content.Intent;
+import android.content.IntentFilter;
+import android.location.LocationManager;
+import android.provider.Settings;
+import android.util.Slog;
+import android.view.View;
+import android.widget.ImageView;
+
+// private NM API
+import android.app.INotificationManager;
+import com.android.internal.statusbar.StatusBarNotification;
+
+import com.android.systemui.R;
+
+public class LocationController extends BroadcastReceiver {
+    private static final String TAG = "StatusBar.LocationController";
+
+    private static final int GPS_NOTIFICATION_ID = 374203-122084;
+
+    private Context mContext;
+
+    private INotificationManager mNotificationService;
+
+    public LocationController(Context context) {
+        mContext = context;
+
+        IntentFilter filter = new IntentFilter();
+        filter.addAction(LocationManager.GPS_ENABLED_CHANGE_ACTION);
+        filter.addAction(LocationManager.GPS_FIX_CHANGE_ACTION);
+        context.registerReceiver(this, filter);
+
+        NotificationManager nm = (NotificationManager)context.getSystemService(
+                Context.NOTIFICATION_SERVICE);
+        mNotificationService = nm.getService();
+    }
+
+    @Override
+    public void onReceive(Context context, Intent intent) {
+        final String action = intent.getAction();
+        final boolean enabled = intent.getBooleanExtra(LocationManager.EXTRA_GPS_ENABLED, false);
+
+        boolean visible;
+        int iconId, textResId;
+
+        if (action.equals(LocationManager.GPS_FIX_CHANGE_ACTION) && enabled) {
+            // GPS is getting fixes
+            iconId = com.android.internal.R.drawable.stat_sys_gps_on;
+            textResId = R.string.gps_notification_found_text;
+            visible = true;
+        } else if (action.equals(LocationManager.GPS_ENABLED_CHANGE_ACTION) && !enabled) {
+            // GPS is off
+            visible = false;
+            iconId = textResId = 0;
+        } else {
+            // GPS is on, but not receiving fixes
+            iconId = R.drawable.stat_sys_gps_acquiring_anim;
+            textResId = R.string.gps_notification_searching_text;
+            visible = true;
+        }
+        
+        try {
+            if (visible) {
+                Intent gpsIntent = new Intent(Settings.ACTION_LOCATION_SOURCE_SETTINGS);
+                gpsIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
+                PendingIntent pendingIntent = PendingIntent.getActivity(context, 0, gpsIntent, 0);
+
+                Notification n = new Notification.Builder(mContext)
+                    .setSmallIcon(iconId)
+                    .setContentTitle(mContext.getText(textResId))
+                    .setOngoing(true)
+                    .setContentIntent(pendingIntent)
+                    .getNotification();
+
+                // Notification.Builder will helpfully fill these out for you no matter what you do
+                n.tickerView = null;
+                n.tickerText = null;
+
+                int[] idOut = new int[1];
+                mNotificationService.enqueueNotificationWithTagPriority(
+                        mContext.getPackageName(),
+                        null, 
+                        GPS_NOTIFICATION_ID, 
+                        StatusBarNotification.PRIORITY_SYSTEM, // !!!1!one!!!
+                        n,
+                        idOut);
+            } else {
+                mNotificationService.cancelNotification(
+                        mContext.getPackageName(),
+                        GPS_NOTIFICATION_ID);
+            }
+        } catch (android.os.RemoteException ex) {
+            // well, it was worth a shot
+        }
+    }
+}
+
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/tablet/TabletStatusBar.java b/packages/SystemUI/src/com/android/systemui/statusbar/tablet/TabletStatusBar.java
index 4bac07f..7a13fde 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/tablet/TabletStatusBar.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/tablet/TabletStatusBar.java
@@ -65,6 +65,7 @@
 import com.android.systemui.statusbar.*;
 import com.android.systemui.statusbar.policy.BatteryController;
 import com.android.systemui.statusbar.policy.BluetoothController;
+import com.android.systemui.statusbar.policy.LocationController;
 import com.android.systemui.statusbar.policy.NetworkController;
 import com.android.systemui.recent.RecentApplicationsActivity;
 
@@ -135,6 +136,7 @@
     HeightReceiver mHeightReceiver;
     BatteryController mBatteryController;
     BluetoothController mBluetoothController;
+    LocationController mLocationController;
     NetworkController mNetworkController;
 
     View mBarContents;
@@ -359,6 +361,8 @@
         mTicker = new TabletTicker(this);
 
         // The icons
+        mLocationController = new LocationController(mContext); // will post a notification
+
         mBatteryController = new BatteryController(mContext);
         mBatteryController.addIconView((ImageView)sb.findViewById(R.id.battery));
         mBluetoothController = new BluetoothController(mContext);
diff --git a/services/java/com/android/server/NotificationManagerService.java b/services/java/com/android/server/NotificationManagerService.java
index 0490190..47dce41 100755
--- a/services/java/com/android/server/NotificationManagerService.java
+++ b/services/java/com/android/server/NotificationManagerService.java
@@ -156,10 +156,11 @@
         final int id;
         final int uid;
         final int initialPid;
+        final int priority;
         final Notification notification;
         IBinder statusBarKey;
 
-        NotificationRecord(String pkg, String tag, int id, int uid, int initialPid,
+        NotificationRecord(String pkg, String tag, int id, int uid, int initialPid, int priority,
                 Notification notification)
         {
             this.pkg = pkg;
@@ -167,6 +168,7 @@
             this.id = id;
             this.uid = uid;
             this.initialPid = initialPid;
+            this.priority = priority;
             this.notification = notification;
         }
 
@@ -194,7 +196,9 @@
                 + Integer.toHexString(System.identityHashCode(this))
                 + " pkg=" + pkg
                 + " id=" + Integer.toHexString(id)
-                + " tag=" + tag + "}";
+                + " tag=" + tag 
+                + " pri=" + priority 
+                + "}";
         }
     }
 
@@ -649,11 +653,27 @@
                 tag, id, notification, idOut);
     }
 
+    public void enqueueNotificationWithTagPriority(String pkg, String tag, int id, int priority,
+            Notification notification, int[] idOut)
+    {
+        enqueueNotificationInternal(pkg, Binder.getCallingUid(), Binder.getCallingPid(),
+                tag, id, priority, notification, idOut);
+    }
+
     // Not exposed via Binder; for system use only (otherwise malicious apps could spoof the
     // uid/pid of another application)
     public void enqueueNotificationInternal(String pkg, int callingUid, int callingPid,
             String tag, int id, Notification notification, int[] idOut)
     {
+        enqueueNotificationInternal(pkg, callingUid, callingPid, tag, id, 
+                ((notification.flags & Notification.FLAG_ONGOING_EVENT) != 0)
+                    ? StatusBarNotification.PRIORITY_ONGOING
+                    : StatusBarNotification.PRIORITY_NORMAL,
+                notification, idOut);
+    }
+    public void enqueueNotificationInternal(String pkg, int callingUid, int callingPid,
+            String tag, int id, int priority, Notification notification, int[] idOut)
+    {
         checkIncomingCall(pkg);
 
         // Limit the number of notifications that any given package except the android
@@ -695,8 +715,10 @@
         }
 
         synchronized (mNotificationList) {
-            NotificationRecord r = new NotificationRecord(pkg, tag, id,
-                    callingUid, callingPid, notification);
+            NotificationRecord r = new NotificationRecord(pkg, tag, id, 
+                    callingUid, callingPid, 
+                    priority,
+                    notification);
             NotificationRecord old = null;
 
             int index = indexOfNotificationLocked(pkg, tag, id);
@@ -722,6 +744,8 @@
             if (notification.icon != 0) {
                 StatusBarNotification n = new StatusBarNotification(pkg, id, tag,
                         r.uid, r.initialPid, notification);
+                n.priority = r.priority;
+
                 if (old != null && old.statusBarKey != null) {
                     r.statusBarKey = old.statusBarKey;
                     long identity = Binder.clearCallingIdentity();
@@ -743,6 +767,7 @@
                 }
                 sendAccessibilityEvent(notification, pkg);
             } else {
+                Slog.e(TAG, "Ignoring notification with icon==0: " + notification);
                 if (old != null && old.statusBarKey != null) {
                     long identity = Binder.clearCallingIdentity();
                     try {
diff --git a/services/java/com/android/server/SystemServer.java b/services/java/com/android/server/SystemServer.java
index 92ec1da..33e9908 100644
--- a/services/java/com/android/server/SystemServer.java
+++ b/services/java/com/android/server/SystemServer.java
@@ -629,6 +629,9 @@
             }, SNAPSHOT_INTERVAL, SNAPSHOT_INTERVAL);
         }
 
+        // Mmmmmm... more memory!
+        dalvik.system.VMRuntime.getRuntime().clearGrowthLimit();
+
         // The system server has to run all of the time, so it needs to be
         // as efficient as possible with its memory usage.
         VMRuntime.getRuntime().setTargetHeapUtilization(0.8f);
diff --git a/services/java/com/android/server/WindowManagerService.java b/services/java/com/android/server/WindowManagerService.java
index a98c3e3..d144dba 100644
--- a/services/java/com/android/server/WindowManagerService.java
+++ b/services/java/com/android/server/WindowManagerService.java
@@ -704,6 +704,9 @@
             Surface.openTransaction();
             try {
                 mSurface.setPosition((int)(x - mThumbOffsetX), (int)(y - mThumbOffsetY));
+                if (SHOW_TRANSACTIONS) Slog.i(TAG, "  DRAG "
+                        + mSurface + ": pos=(" +
+                        (int)(x - mThumbOffsetX) + "," + (int)(y - mThumbOffsetY) + ")");
             } finally {
                 Surface.closeTransaction();
                 if (SHOW_TRANSACTIONS) Slog.i(TAG, "<<< CLOSE TRANSACTION notifyMoveLw");
@@ -911,7 +914,7 @@
     Rect mCompatibleScreenFrame = new Rect();
     // The surface used to fill the outer rim of the app running in compatibility mode.
     Surface mBackgroundFillerSurface = null;
-    boolean mBackgroundFillerShown = false;
+    WindowState mBackgroundFillerTarget = null;
 
     public static WindowManagerService main(Context context,
             PowerManagerService pm, boolean haveInputMethods) {
@@ -5876,6 +5879,8 @@
                     if (mDragState == null) {
                         Surface surface = new Surface(session, callerPid, "drag surface", 0,
                                 width, height, PixelFormat.TRANSLUCENT, Surface.HIDDEN);
+                        if (SHOW_TRANSACTIONS) Slog.i(TAG, "  DRAG "
+                                + surface + ": CREATE");
                         outSurface.copyFrom(surface);
                         final IBinder winBinder = window.asBinder();
                         token = new Binder();
@@ -8099,9 +8104,7 @@
                  mFrame.left <= mCompatibleScreenFrame.left &&
                  mFrame.top <= mCompatibleScreenFrame.top &&
                  mFrame.right >= mCompatibleScreenFrame.right &&
-                 mFrame.bottom >= mCompatibleScreenFrame.bottom &&
-                 // and starting window do not need background filler
-                 mAttrs.type != mAttrs.TYPE_APPLICATION_STARTING;
+                 mFrame.bottom >= mCompatibleScreenFrame.bottom;
         }
 
         boolean isFullscreen(int screenWidth, int screenHeight) {
@@ -10432,7 +10435,8 @@
             boolean dimming = false;
             boolean covered = false;
             boolean syswin = false;
-            boolean backgroundFillerShown = false;
+            boolean backgroundFillerWasShown = mBackgroundFillerTarget != null;
+            mBackgroundFillerTarget = null;
 
             final int N = mWindows.size();
 
@@ -10734,6 +10738,16 @@
 
                 final boolean obscuredChanged = w.mObscured != obscured;
 
+                if (mBackgroundFillerTarget != null) {
+                    if (w.isAnimating()) {
+                        // Background filler is below all other windows that
+                        // are animating.
+                        mBackgroundFillerTarget = w;
+                    } else if (w.mIsWallpaper) {
+                        mBackgroundFillerTarget = w;
+                    }
+                }
+
                 // Update effect.
                 if (!(w.mObscured=obscured)) {
                     if (w.mSurface != null) {
@@ -10762,33 +10776,10 @@
                         // so we want to leave all of them as unblurred (for
                         // performance reasons).
                         obscured = true;
-                    } else if (opaqueDrawn && w.needsBackgroundFiller(dw, dh)) {
-                        if (SHOW_TRANSACTIONS) Slog.d(TAG, "showing background filler");
+                    } else if (w.needsBackgroundFiller(dw, dh) && (canBeSeen || w.isAnimating())) {
                         // This window is in compatibility mode, and needs background filler.
                         obscured = true;
-                        if (mBackgroundFillerSurface == null) {
-                            try {
-                                mBackgroundFillerSurface = new Surface(mFxSession, 0,
-                                        "BackGroundFiller",
-                                        0, dw, dh,
-                                        PixelFormat.OPAQUE,
-                                        Surface.FX_SURFACE_NORMAL);
-                            } catch (Exception e) {
-                                Slog.e(TAG, "Exception creating filler surface", e);
-                            }
-                        }
-                        try {
-                            mBackgroundFillerSurface.setPosition(0, 0);
-                            mBackgroundFillerSurface.setSize(dw, dh);
-                            // Using the same layer as Dim because they will never be shown at the
-                            // same time.
-                            mBackgroundFillerSurface.setLayer(w.mAnimLayer - 1);
-                            mBackgroundFillerSurface.show();
-                        } catch (RuntimeException e) {
-                            Slog.e(TAG, "Exception showing filler surface");
-                        }
-                        backgroundFillerShown = true;
-                        mBackgroundFillerShown = true;
+                        mBackgroundFillerTarget = w;
                     } else if (canBeSeen && !obscured &&
                             (attrFlags&FLAG_BLUR_BEHIND|FLAG_DIM_BEHIND) != 0) {
                         if (localLOGV) Slog.v(TAG, "Win " + w
@@ -10812,8 +10803,6 @@
                                 //Slog.i(TAG, "BLUR BEHIND: " + w);
                                 blurring = true;
                                 if (mBlurSurface == null) {
-                                    if (SHOW_TRANSACTIONS) Slog.i(TAG, "  BLUR "
-                                            + mBlurSurface + ": CREATE");
                                     try {
                                         mBlurSurface = new Surface(mFxSession, 0,
                                                 "BlurSurface",
@@ -10823,6 +10812,8 @@
                                     } catch (Exception e) {
                                         Slog.e(TAG, "Exception creating Blur surface", e);
                                     }
+                                    if (SHOW_TRANSACTIONS) Slog.i(TAG, "  BLUR "
+                                            + mBlurSurface + ": CREATE");
                                 }
                                 if (mBlurSurface != null) {
                                     if (SHOW_TRANSACTIONS) Slog.i(TAG, "  BLUR "
@@ -10855,9 +10846,39 @@
                 }
             }
 
-            if (backgroundFillerShown == false && mBackgroundFillerShown) {
-                mBackgroundFillerShown = false;
-                if (SHOW_TRANSACTIONS) Slog.d(TAG, "hiding background filler");
+            if (mBackgroundFillerTarget != null) {
+                if (mBackgroundFillerSurface == null) {
+                    try {
+                        mBackgroundFillerSurface = new Surface(mFxSession, 0,
+                                "BackGroundFiller",
+                                0, dw, dh,
+                                PixelFormat.OPAQUE,
+                                Surface.FX_SURFACE_NORMAL);
+                    } catch (Exception e) {
+                        Slog.e(TAG, "Exception creating filler surface", e);
+                    }
+                    if (SHOW_TRANSACTIONS) Slog.i(TAG, "  BG FILLER "
+                            + mBackgroundFillerSurface + ": CREATE");
+                }
+                try {
+                    if (SHOW_TRANSACTIONS) Slog.i(TAG, "  BG FILLER "
+                            + mBackgroundFillerSurface + " SHOW: pos=(0,0) ("
+                            + dw + "x" + dh + ") layer="
+                            + (mBackgroundFillerTarget.mLayer - 1));
+                    mBackgroundFillerSurface.setPosition(0, 0);
+                    mBackgroundFillerSurface.setSize(dw, dh);
+                    // Using the same layer as Dim because they will never be shown at the
+                    // same time.  NOTE: we do NOT use mAnimLayer, because we don't
+                    // want this surface dragged up in front of stuff that is animating.
+                    mBackgroundFillerSurface.setLayer(mBackgroundFillerTarget.mLayer - 1);
+                    mBackgroundFillerSurface.show();
+                } catch (RuntimeException e) {
+                    Slog.e(TAG, "Exception showing filler surface");
+                }
+            } else if (backgroundFillerWasShown) {
+                mBackgroundFillerTarget = null;
+                if (SHOW_TRANSACTIONS) Slog.i(TAG, "  BG FILLER "
+                        + mBackgroundFillerSurface + " HIDE");
                 try {
                     mBackgroundFillerSurface.hide();
                 } catch (RuntimeException e) {
@@ -12040,7 +12061,6 @@
      * This is used for opening/closing transition for apps in compatible mode.
      */
     private static class FadeInOutAnimation extends Animation {
-        int mWidth;
         boolean mFadeIn;
 
         public FadeInOutAnimation(boolean fadeIn) {
@@ -12055,24 +12075,7 @@
             if (!mFadeIn) {
                 x = 1.0f - x; // reverse the interpolation for fade out
             }
-            if (x < 0.5) {
-                // move the window out of the screen.
-                t.getMatrix().setTranslate(mWidth, 0);
-            } else {
-                t.getMatrix().setTranslate(0, 0);// show
-                t.setAlpha((x - 0.5f) * 2);
-            }
-        }
-
-        @Override
-        public void initialize(int width, int height, int parentWidth, int parentHeight) {
-            // width is the screen width {@see AppWindowToken#stepAnimatinoLocked}
-            mWidth = width;
-        }
-
-        @Override
-        public int getZAdjustment() {
-            return Animation.ZORDER_TOP;
+            t.setAlpha(x);
         }
     }
 
diff --git a/services/sensorservice/SensorService.cpp b/services/sensorservice/SensorService.cpp
index ea5e5cc..697e879 100644
--- a/services/sensorservice/SensorService.cpp
+++ b/services/sensorservice/SensorService.cpp
@@ -293,18 +293,21 @@
     return result;
 }
 
-void SensorService::cleanupConnection(const wp<SensorEventConnection>& connection)
+void SensorService::cleanupConnection(SensorEventConnection* c)
 {
     Mutex::Autolock _l(mLock);
+    const wp<SensorEventConnection> connection(c);
     size_t size = mActiveSensors.size();
     for (size_t i=0 ; i<size ; ) {
-        SensorRecord* rec = mActiveSensors.valueAt(i);
-        if (rec && rec->removeConnection(connection)) {
-            int handle = mActiveSensors.keyAt(i);
+        int handle = mActiveSensors.keyAt(i);
+        if (c->hasSensor(handle)) {
             SensorInterface* sensor = mSensorMap.valueFor( handle );
             if (sensor) {
-                sensor->activate(connection.unsafe_get(), false);
+                sensor->activate(c, false);
             }
+        }
+        SensorRecord* rec = mActiveSensors.valueAt(i);
+        if (rec && rec->removeConnection(connection)) {
             mActiveSensors.removeItemsAt(i, 1);
             mActiveVirtualSensors.removeItem(handle);
             delete rec;
diff --git a/services/sensorservice/SensorService.h b/services/sensorservice/SensorService.h
index 540c7e2..21f12bd 100644
--- a/services/sensorservice/SensorService.h
+++ b/services/sensorservice/SensorService.h
@@ -129,7 +129,7 @@
 public:
     static char const* getServiceName() { return "sensorservice"; }
 
-    void cleanupConnection(const wp<SensorEventConnection>& connection);
+    void cleanupConnection(SensorEventConnection* connection);
     status_t enable(const sp<SensorEventConnection>& connection, int handle);
     status_t disable(const sp<SensorEventConnection>& connection, int handle);
     status_t setEventRate(const sp<SensorEventConnection>& connection, int handle, nsecs_t ns);
diff --git a/tests/HwAccelerationTest/AndroidManifest.xml b/tests/HwAccelerationTest/AndroidManifest.xml
index 3535809..f72de127 100644
--- a/tests/HwAccelerationTest/AndroidManifest.xml
+++ b/tests/HwAccelerationTest/AndroidManifest.xml
@@ -32,6 +32,15 @@
                 <category android:name="android.intent.category.LAUNCHER" />
             </intent-filter>
         </activity>
+        
+        <activity
+                android:name="MarqueeActivity"
+                android:label="_Marquee">
+            <intent-filter>
+                <action android:name="android.intent.action.MAIN" />
+                <category android:name="android.intent.category.LAUNCHER" />
+            </intent-filter>
+        </activity>
 
         <activity
                 android:name="ShapesActivity"
diff --git a/tests/HwAccelerationTest/res/anim/accelerate_interpolator_2.xml b/tests/HwAccelerationTest/res/anim/accelerate_interpolator_2.xml
new file mode 100644
index 0000000..e4a8d48
--- /dev/null
+++ b/tests/HwAccelerationTest/res/anim/accelerate_interpolator_2.xml
@@ -0,0 +1,21 @@
+<?xml version="1.0" encoding="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.
+*/
+-->
+
+<accelerateInterpolator xmlns:android="http://schemas.android.com/apk/res/android"
+    android:factor="2.0"/>
diff --git a/tests/HwAccelerationTest/res/anim/slide_off_left.xml b/tests/HwAccelerationTest/res/anim/slide_off_left.xml
new file mode 100644
index 0000000..f05de39
--- /dev/null
+++ b/tests/HwAccelerationTest/res/anim/slide_off_left.xml
@@ -0,0 +1,20 @@
+<?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.
+-->
+<translate xmlns:android="http://schemas.android.com/apk/res/android"
+    android:fromXDelta="0%"
+    android:toXDelta="-100%"
+    android:interpolator="@anim/accelerate_interpolator_2"
+    android:duration="600"/>
\ No newline at end of file
diff --git a/tests/HwAccelerationTest/src/com/android/test/hwui/MarqueeActivity.java b/tests/HwAccelerationTest/src/com/android/test/hwui/MarqueeActivity.java
new file mode 100644
index 0000000..715cdbb
--- /dev/null
+++ b/tests/HwAccelerationTest/src/com/android/test/hwui/MarqueeActivity.java
@@ -0,0 +1,68 @@
+/*
+ * 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.android.test.hwui;
+
+import android.app.Activity;
+import android.os.Bundle;
+import android.text.TextUtils;
+import android.view.View;
+import android.view.animation.Animation;
+import android.view.animation.AnimationUtils;
+import android.widget.LinearLayout;
+import android.widget.TextView;
+
+@SuppressWarnings({"UnusedDeclaration"})
+public class MarqueeActivity extends Activity {
+    @Override
+    protected void onCreate(Bundle savedInstanceState) {
+        super.onCreate(savedInstanceState);
+
+        final LinearLayout linearLayout = new LinearLayout(this);
+        linearLayout.setOrientation(LinearLayout.VERTICAL);
+        
+        final TextView text1 = new TextView(this);
+        text1.setText("This is a marquee inside a TextView");
+        text1.setSingleLine(true);
+        text1.setHorizontalFadingEdgeEnabled(true);
+        text1.setEllipsize(TextUtils.TruncateAt.MARQUEE);
+        linearLayout.addView(text1, new LinearLayout.LayoutParams(
+                100, LinearLayout.LayoutParams.WRAP_CONTENT));
+
+        final TextView text2 = new TextView(this);
+        text2.setText("This is a marquee inside a TextView");
+        text2.setSingleLine(true);
+        text2.setHorizontalFadingEdgeEnabled(true);
+        text2.setEllipsize(TextUtils.TruncateAt.MARQUEE);
+        LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(
+                100, LinearLayout.LayoutParams.WRAP_CONTENT);
+        linearLayout.addView(text2, params);
+
+        setContentView(linearLayout);
+        
+        getWindow().getDecorView().postDelayed(new Runnable() {
+            @Override
+            public void run() {
+                text2.setVisibility(View.INVISIBLE);
+                Animation animation = AnimationUtils.loadAnimation(text2.getContext(),
+                        R.anim.slide_off_left);
+                animation.setFillEnabled(true);
+                animation.setFillAfter(true);
+                text2.startAnimation(animation);
+            }
+        }, 1000);
+    }
+}
diff --git a/tests/StatusBar/src/com/android/statusbartest/NotificationTestList.java b/tests/StatusBar/src/com/android/statusbartest/NotificationTestList.java
index 90c2a1a..f463a19 100644
--- a/tests/StatusBar/src/com/android/statusbartest/NotificationTestList.java
+++ b/tests/StatusBar/src/com/android/statusbartest/NotificationTestList.java
@@ -35,6 +35,10 @@
 import android.widget.ProgressBar;
 import android.os.PowerManager;
 
+// private NM API
+import android.app.INotificationManager;
+import com.android.internal.statusbar.StatusBarNotification;
+
 public class NotificationTestList extends TestActivity
 {
     private final static String TAG = "NotificationTestList";
@@ -205,6 +209,15 @@
             }
         },
 
+        new Test("Null Icon #1 (when=now)") {
+            public void run() {
+                Notification n = new Notification(0, null, System.currentTimeMillis());
+                n.setLatestEventInfo(NotificationTestList.this, "Persistent #1",
+                            "This is the same notification!!!", makeIntent());
+                mNM.notify(1, n);
+            }
+        },
+
         new Test("Bad resource #1 (when=create)") {
             public void run() {
                 Notification n = new Notification(R.drawable.icon2,
@@ -752,6 +765,30 @@
             }
         },
 
+        new Test("System priority notification") {
+            public void run() {
+                Notification n = new Notification.Builder(NotificationTestList.this)
+                    .setSmallIcon(R.drawable.notification1)
+                    .setContentTitle("System priority")
+                    .setContentText("This should appear before all others")
+                    .getNotification();
+
+                int[] idOut = new int[1];
+                try {
+                    INotificationManager directLine = mNM.getService();
+                    directLine.enqueueNotificationWithTagPriority(
+                            getPackageName(),
+                            null, 
+                            1, 
+                            StatusBarNotification.PRIORITY_SYSTEM,
+                            n,
+                            idOut);
+                } catch (android.os.RemoteException ex) {
+                    // oh well
+                }
+            }
+        },
+
         new Test("Crash") {
             public void run()
             {