Merge "Update ShortcutManager javadoc" into nyc-mr1-dev
diff --git a/core/java/android/animation/ObjectAnimator.java b/core/java/android/animation/ObjectAnimator.java
index 5c4b979..9a2aa30 100644
--- a/core/java/android/animation/ObjectAnimator.java
+++ b/core/java/android/animation/ObjectAnimator.java
@@ -977,7 +977,7 @@
     @Override
     void animateValue(float fraction) {
         final Object target = getTarget();
-        if (mTarget != null && target == null) {
+        if (target == null) {
             // We lost the target reference, cancel and clean up.
             cancel();
             return;
diff --git a/core/java/android/animation/ValueAnimator.java b/core/java/android/animation/ValueAnimator.java
index 0c7ee2c..e3f8fa4 100644
--- a/core/java/android/animation/ValueAnimator.java
+++ b/core/java/android/animation/ValueAnimator.java
@@ -982,6 +982,7 @@
         mStarted = true;
         mPaused = false;
         mRunning = false;
+        mAnimationEndRequested = false;
         // Resets mLastFrameTime when start() is called, so that if the animation was running,
         // calling start() would put the animation in the
         // started-but-not-yet-reached-the-first-frame phase.
diff --git a/core/java/android/text/SpannableStringInternal.java b/core/java/android/text/SpannableStringInternal.java
index 47e71be..4b02df86 100644
--- a/core/java/android/text/SpannableStringInternal.java
+++ b/core/java/android/text/SpannableStringInternal.java
@@ -33,6 +33,7 @@
             mText = source.toString().substring(start, end);
 
         mSpans = EmptyArray.OBJECT;
+        // Invariant: mSpanData.length = mSpans.length * COLUMNS
         mSpanData = EmptyArray.INT;
 
         if (source instanceof Spanned) {
@@ -99,7 +100,7 @@
             Object[] srcSpans = src.mSpans;
             mSpanCount = count;
             mSpans = ArrayUtils.newUnpaddedObjectArray(mSpanCount);
-            mSpanData = new int[mSpanCount * COLUMNS];
+            mSpanData = new int[mSpans.length * COLUMNS];
             for (int i = 0, j = 0; i < limit; i++) {
                 int spanStart = srcData[i * COLUMNS + START];
                 int spanEnd = srcData[i * COLUMNS + END];
diff --git a/core/java/android/view/RoundScrollbarRenderer.java b/core/java/android/view/RoundScrollbarRenderer.java
index f258458..b77be8c 100644
--- a/core/java/android/view/RoundScrollbarRenderer.java
+++ b/core/java/android/view/RoundScrollbarRenderer.java
@@ -20,6 +20,7 @@
 import android.graphics.Color;
 import android.graphics.Paint;
 import android.graphics.RectF;
+import android.graphics.Rect;
 
 /**
  * Helper class for drawing round scroll bars on round Wear devices.
@@ -53,7 +54,7 @@
         mParent = parent;
     }
 
-    public void drawRoundScrollbars(Canvas canvas, float alpha) {
+    public void drawRoundScrollbars(Canvas canvas, float alpha, Rect bounds) {
         if (alpha == 0) {
             return;
         }
@@ -83,10 +84,11 @@
 
         // Draw the track and the scroll bar.
         mRect.set(
-                0 + thumbWidth / 2,
-                0 + thumbWidth / 2,
-                mParent.getWidth() - thumbWidth / 2,
-                mParent.getHeight() - thumbWidth / 2);
+                bounds.left - thumbWidth / 2,
+                bounds.top,
+                bounds.right - thumbWidth / 2,
+                bounds.bottom);
+
         canvas.drawArc(mRect, -SCROLLBAR_ANGLE_RANGE / 2, SCROLLBAR_ANGLE_RANGE, false,
                 mTrackPaint);
         canvas.drawArc(mRect, startAngle, sweepAngle, false, mThumbPaint);
diff --git a/core/java/android/view/TextureView.java b/core/java/android/view/TextureView.java
index 1a712c3..b2e2505 100644
--- a/core/java/android/view/TextureView.java
+++ b/core/java/android/view/TextureView.java
@@ -355,17 +355,6 @@
         }
     }
 
-    /**
-     * @hide
-     */
-    @Override
-    protected void destroyHardwareResources() {
-        super.destroyHardwareResources();
-        destroySurface();
-        invalidateParentCaches();
-        invalidate(true);
-    }
-
     HardwareLayer getHardwareLayer() {
         if (mLayer == null) {
             if (mAttachInfo == null || mAttachInfo.mHardwareRenderer == null) {
diff --git a/core/java/android/view/View.java b/core/java/android/view/View.java
index 1fa1820..d93f8af 100644
--- a/core/java/android/view/View.java
+++ b/core/java/android/view/View.java
@@ -14770,6 +14770,37 @@
     }
 
     private void getVerticalScrollBarBounds(Rect bounds) {
+        if (mRoundScrollbarRenderer == null) {
+            getStraightVerticalScrollBarBounds(bounds);
+        } else {
+            getRoundVerticalScrollBarBounds(bounds);
+        }
+    }
+
+    private void getRoundVerticalScrollBarBounds(Rect bounds) {
+        final int inside = (mViewFlags & SCROLLBARS_OUTSIDE_MASK) == 0 ? ~0 : 0;
+        int verticalScrollbarPosition = mVerticalScrollbarPosition;
+        if (verticalScrollbarPosition == SCROLLBAR_POSITION_DEFAULT) {
+            verticalScrollbarPosition = isLayoutRtl() ?
+                    SCROLLBAR_POSITION_LEFT : SCROLLBAR_POSITION_RIGHT;
+        }
+        final int width = mRight - mLeft;
+        final int height = mBottom - mTop;
+        switch (verticalScrollbarPosition) {
+            default:
+            case SCROLLBAR_POSITION_RIGHT:
+                bounds.left = mScrollX - (mUserPaddingRight & inside);
+                break;
+            case SCROLLBAR_POSITION_LEFT:
+                bounds.left = mScrollX + (mUserPaddingLeft & inside);
+                break;
+        }
+        bounds.top = mScrollY + (mPaddingTop & inside);
+        bounds.right = bounds.left + width;
+        bounds.bottom = mScrollY + height - (mUserPaddingBottom & inside);
+    }
+
+    private void getStraightVerticalScrollBarBounds(Rect bounds) {
         final int inside = (mViewFlags & SCROLLBARS_OUTSIDE_MASK) == 0 ? ~0 : 0;
         final int size = getVerticalScrollbarWidth();
         int verticalScrollbarPosition = mVerticalScrollbarPosition;
@@ -14848,8 +14879,10 @@
             // Fork out the scroll bar drawing for round wearable devices.
             if (mRoundScrollbarRenderer != null) {
                 if (drawVerticalScrollBar) {
+                    final Rect bounds = cache.mScrollBarBounds;
+                    getVerticalScrollBarBounds(bounds);
                     mRoundScrollbarRenderer.drawRoundScrollbars(
-                            canvas, (float) cache.scrollBar.getAlpha() / 255f);
+                            canvas, (float) cache.scrollBar.getAlpha() / 255f, bounds);
                     if (invalidate) {
                         invalidate();
                     }
diff --git a/core/java/com/android/internal/app/AlertController.java b/core/java/com/android/internal/app/AlertController.java
index 2b25b3f..5aeb7f9 100644
--- a/core/java/com/android/internal/app/AlertController.java
+++ b/core/java/com/android/internal/app/AlertController.java
@@ -178,11 +178,6 @@
         return outValue.data != 0;
     }
 
-    private static boolean isWatch(Context context) {
-        return (context.getResources().getConfiguration().uiMode & Configuration.UI_MODE_TYPE_WATCH)
-                == Configuration.UI_MODE_TYPE_WATCH;
-    }
-
     public static final AlertController create(Context context, DialogInterface di, Window window) {
         final TypedArray a = context.obtainStyledAttributes(
                 null, R.styleable.AlertDialog, R.attr.alertDialogStyle, 0);
@@ -892,14 +887,8 @@
             listView.setAdapter(mAdapter);
             final int checkedItem = mCheckedItem;
             if (checkedItem > -1) {
-                // TODO: Remove temp watch specific code
-                if (isWatch(mContext)) {
-                    listView.setItemChecked(checkedItem + listView.getHeaderViewsCount(), true);
-                    listView.setSelection(checkedItem + listView.getHeaderViewsCount());
-                } else {
-                    listView.setItemChecked(checkedItem, true);
-                    listView.setSelection(checkedItem);
-                }
+                listView.setItemChecked(checkedItem, true);
+                listView.setSelection(checkedItem);
             }
         }
     }
@@ -1078,13 +1067,7 @@
                             if (mCheckedItems != null) {
                                 boolean isItemChecked = mCheckedItems[position];
                                 if (isItemChecked) {
-                                    // TODO: Remove temp watch specific code
-                                    if (isWatch(mContext)) {
-                                        listView.setItemChecked(
-                                                position + listView.getHeaderViewsCount(), true);
-                                    } else {
-                                        listView.setItemChecked(position, true);
-                                    }
+                                    listView.setItemChecked(position, true);
                                 }
                             }
                             return view;
@@ -1105,16 +1088,9 @@
                         public void bindView(View view, Context context, Cursor cursor) {
                             CheckedTextView text = (CheckedTextView) view.findViewById(R.id.text1);
                             text.setText(cursor.getString(mLabelIndex));
-                            // TODO: Remove temp watch specific code
-                            if (isWatch(mContext)) {
-                                listView.setItemChecked(
-                                        cursor.getPosition() + listView.getHeaderViewsCount(),
-                                        cursor.getInt(mIsCheckedIndex) == 1);
-                            } else {
-                                listView.setItemChecked(
-                                        cursor.getPosition(),
-                                        cursor.getInt(mIsCheckedIndex) == 1);
-                            }
+                            listView.setItemChecked(
+                                    cursor.getPosition(),
+                                    cursor.getInt(mIsCheckedIndex) == 1);
                         }
 
                         @Override
@@ -1157,10 +1133,6 @@
                 listView.setOnItemClickListener(new OnItemClickListener() {
                     @Override
                     public void onItemClick(AdapterView<?> parent, View v, int position, long id) {
-                        // TODO: Remove temp watch specific code
-                        if (isWatch(mContext)) {
-                            position -= listView.getHeaderViewsCount();
-                        }
                         mOnClickListener.onClick(dialog.mDialogInterface, position);
                         if (!mIsSingleChoice) {
                             dialog.mDialogInterface.dismiss();
@@ -1171,10 +1143,6 @@
                 listView.setOnItemClickListener(new OnItemClickListener() {
                     @Override
                     public void onItemClick(AdapterView<?> parent, View v, int position, long id) {
-                        // TODO: Remove temp watch specific code
-                        if (isWatch(mContext)) {
-                            position -= listView.getHeaderViewsCount();
-                        }
                         if (mCheckedItems != null) {
                             mCheckedItems[position] = listView.isItemChecked(position);
                         }
diff --git a/core/java/com/android/internal/app/MicroAlertController.java b/core/java/com/android/internal/app/MicroAlertController.java
index 00fcd6f..4431f3c 100644
--- a/core/java/com/android/internal/app/MicroAlertController.java
+++ b/core/java/com/android/internal/app/MicroAlertController.java
@@ -18,12 +18,15 @@
 
 import android.content.Context;
 import android.content.DialogInterface;
+import android.text.TextUtils;
+import android.view.Gravity;
 import android.view.View;
 import android.view.ViewGroup;
 import android.view.Window;
+import android.widget.FrameLayout;
+import android.widget.ImageView;
 import android.widget.ScrollView;
 import android.widget.TextView;
-import android.widget.AbsListView;
 
 import com.android.internal.app.AlertController;
 import com.android.internal.R;
@@ -52,30 +55,38 @@
             contentPanel.removeView(mMessageView);
 
             if (mListView != null) {
-                // has ListView, swap ScrollView with ListView
+                // has ListView, swap scrollView with ListView
 
-                // move topPanel into header of ListView
+                // move topPanel into top of scrollParent
                 View topPanel = mScrollView.findViewById(R.id.topPanel);
                 ((ViewGroup) topPanel.getParent()).removeView(topPanel);
-                topPanel.setLayoutParams(
-                        new AbsListView.LayoutParams(topPanel.getLayoutParams()));
-                mListView.addHeaderView(topPanel, null, false);
+                FrameLayout.LayoutParams topParams =
+                        new FrameLayout.LayoutParams(topPanel.getLayoutParams());
+                topParams.gravity = Gravity.TOP;
+                topPanel.setLayoutParams(topParams);
 
-                // move buttonPanel into footer of ListView
+                // move buttonPanel into bottom of scrollParent
                 View buttonPanel = mScrollView.findViewById(R.id.buttonPanel);
                 ((ViewGroup) buttonPanel.getParent()).removeView(buttonPanel);
-                buttonPanel.setLayoutParams(
-                        new AbsListView.LayoutParams(buttonPanel.getLayoutParams()));
-                mListView.addFooterView(buttonPanel, null, false);
+                FrameLayout.LayoutParams buttonParams =
+                        new FrameLayout.LayoutParams(buttonPanel.getLayoutParams());
+                buttonParams.gravity = Gravity.BOTTOM;
+                buttonPanel.setLayoutParams(buttonParams);
 
-                // swap ScrollView w/ ListView
+                // remove scrollview
                 final ViewGroup scrollParent = (ViewGroup) mScrollView.getParent();
                 final int childIndex = scrollParent.indexOfChild(mScrollView);
                 scrollParent.removeViewAt(childIndex);
-                scrollParent.addView(mListView, childIndex,
+
+                // add list view
+                scrollParent.addView(mListView,
                         new ViewGroup.LayoutParams(
                                 ViewGroup.LayoutParams.MATCH_PARENT,
                                 ViewGroup.LayoutParams.MATCH_PARENT));
+
+                // add top and button panel
+                scrollParent.addView(topPanel);
+                scrollParent.addView(buttonPanel);
             } else {
                 // no content, just hide everything
                 contentPanel.setVisibility(View.GONE);
diff --git a/core/java/com/android/internal/widget/WatchListDecorLayout.java b/core/java/com/android/internal/widget/WatchListDecorLayout.java
new file mode 100644
index 0000000..538ceca
--- /dev/null
+++ b/core/java/com/android/internal/widget/WatchListDecorLayout.java
@@ -0,0 +1,327 @@
+/*
+ * Copyright (C) 2016 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.internal.widget;
+
+import android.content.Context;
+import android.graphics.drawable.Drawable;
+import android.graphics.Rect;
+import android.util.AttributeSet;
+import android.view.Gravity;
+import android.view.View;
+import android.view.ViewTreeObserver;
+import android.widget.ListView;
+import android.widget.FrameLayout;
+
+import java.util.ArrayList;
+
+
+/**
+ * Layout for the decor for ListViews on watch-type devices with small screens.
+ * <p>
+ * Supports one panel with the gravity set to top, and one panel with gravity set to bottom.
+ * <p>
+ * Use with one ListView child. The top and bottom panels will track the ListView's scrolling.
+ * If there is no ListView child, it will act like a normal FrameLayout.
+ */
+public class WatchListDecorLayout extends FrameLayout
+        implements ViewTreeObserver.OnScrollChangedListener {
+
+    private int mForegroundPaddingLeft = 0;
+    private int mForegroundPaddingTop = 0;
+    private int mForegroundPaddingRight = 0;
+    private int mForegroundPaddingBottom = 0;
+
+    private final ArrayList<View> mMatchParentChildren = new ArrayList<>(1);
+
+    /** Track the amount the ListView has to scroll up to account for padding change difference. */
+    private int mPendingScroll;
+    private View mBottomPanel;
+    private View mTopPanel;
+    private ListView mListView;
+    private ViewTreeObserver mObserver;
+
+
+    public WatchListDecorLayout(Context context, AttributeSet attrs) {
+        super(context, attrs);
+    }
+
+    public WatchListDecorLayout(Context context, AttributeSet attrs, int defStyleAttr) {
+        super(context, attrs, defStyleAttr);
+    }
+
+    public WatchListDecorLayout(
+            Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes) {
+        super(context, attrs, defStyleAttr, defStyleRes);
+    }
+
+    @Override
+    protected void onAttachedToWindow() {
+        super.onAttachedToWindow();
+
+        mPendingScroll = 0;
+
+        for (int i = 0; i < getChildCount(); ++i) {
+            View child = getChildAt(i);
+            if (child instanceof ListView) {
+                if (mListView != null) {
+                    throw new IllegalArgumentException("only one ListView child allowed");
+                }
+                mListView = (ListView) child;
+
+                mListView.setNestedScrollingEnabled(true);
+                mObserver = mListView.getViewTreeObserver();
+                mObserver.addOnScrollChangedListener(this);
+            } else {
+                int gravity = (((LayoutParams) child.getLayoutParams()).gravity
+                        & Gravity.VERTICAL_GRAVITY_MASK);
+                if (gravity == Gravity.TOP && mTopPanel == null) {
+                    mTopPanel = child;
+                } else if (gravity == Gravity.BOTTOM && mBottomPanel == null) {
+                    mBottomPanel = child;
+                }
+            }
+        }
+    }
+
+    @Override
+    public void onDetachedFromWindow() {
+        mListView = null;
+        mBottomPanel = null;
+        mTopPanel = null;
+        if (mObserver != null) {
+            if (mObserver.isAlive()) {
+                mObserver.removeOnScrollChangedListener(this);
+            }
+            mObserver = null;
+        }
+    }
+
+    private void applyMeasureToChild(View child, int widthMeasureSpec, int heightMeasureSpec) {
+        final MarginLayoutParams lp = (MarginLayoutParams) child.getLayoutParams();
+
+        final int childWidthMeasureSpec;
+        if (lp.width == LayoutParams.MATCH_PARENT) {
+            final int width = Math.max(0, getMeasuredWidth()
+                    - getPaddingLeftWithForeground() - getPaddingRightWithForeground()
+                    - lp.leftMargin - lp.rightMargin);
+            childWidthMeasureSpec = MeasureSpec.makeMeasureSpec(
+                    width, MeasureSpec.EXACTLY);
+        } else {
+            childWidthMeasureSpec = getChildMeasureSpec(widthMeasureSpec,
+                    getPaddingLeftWithForeground() + getPaddingRightWithForeground() +
+                    lp.leftMargin + lp.rightMargin,
+                    lp.width);
+        }
+
+        final int childHeightMeasureSpec;
+        if (lp.height == LayoutParams.MATCH_PARENT) {
+            final int height = Math.max(0, getMeasuredHeight()
+                    - getPaddingTopWithForeground() - getPaddingBottomWithForeground()
+                    - lp.topMargin - lp.bottomMargin);
+            childHeightMeasureSpec = MeasureSpec.makeMeasureSpec(
+                    height, MeasureSpec.EXACTLY);
+        } else {
+            childHeightMeasureSpec = getChildMeasureSpec(heightMeasureSpec,
+                    getPaddingTopWithForeground() + getPaddingBottomWithForeground() +
+                    lp.topMargin + lp.bottomMargin,
+                    lp.height);
+        }
+
+        child.measure(childWidthMeasureSpec, childHeightMeasureSpec);
+    }
+
+    private int measureAndGetHeight(View child, int widthMeasureSpec, int heightMeasureSpec) {
+        if (child != null) {
+            if (child.getVisibility() != GONE) {
+                applyMeasureToChild(mBottomPanel, widthMeasureSpec, heightMeasureSpec);
+                return child.getMeasuredHeight();
+            } else if (getMeasureAllChildren()) {
+                applyMeasureToChild(mBottomPanel, widthMeasureSpec, heightMeasureSpec);
+            }
+        }
+        return 0;
+    }
+
+    @Override
+    protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
+        int count = getChildCount();
+
+        final boolean measureMatchParentChildren =
+                MeasureSpec.getMode(widthMeasureSpec) != MeasureSpec.EXACTLY ||
+                MeasureSpec.getMode(heightMeasureSpec) != MeasureSpec.EXACTLY;
+        mMatchParentChildren.clear();
+
+        int maxHeight = 0;
+        int maxWidth = 0;
+        int childState = 0;
+
+        for (int i = 0; i < count; i++) {
+            final View child = getChildAt(i);
+            if (getMeasureAllChildren() || child.getVisibility() != GONE) {
+                measureChildWithMargins(child, widthMeasureSpec, 0, heightMeasureSpec, 0);
+                final LayoutParams lp = (LayoutParams) child.getLayoutParams();
+                maxWidth = Math.max(maxWidth,
+                        child.getMeasuredWidth() + lp.leftMargin + lp.rightMargin);
+                maxHeight = Math.max(maxHeight,
+                        child.getMeasuredHeight() + lp.topMargin + lp.bottomMargin);
+                childState = combineMeasuredStates(childState, child.getMeasuredState());
+                if (measureMatchParentChildren) {
+                    if (lp.width == LayoutParams.MATCH_PARENT ||
+                            lp.height == LayoutParams.MATCH_PARENT) {
+                        mMatchParentChildren.add(child);
+                    }
+                }
+            }
+        }
+
+        // Account for padding too
+        maxWidth += getPaddingLeftWithForeground() + getPaddingRightWithForeground();
+        maxHeight += getPaddingTopWithForeground() + getPaddingBottomWithForeground();
+
+        // Check against our minimum height and width
+        maxHeight = Math.max(maxHeight, getSuggestedMinimumHeight());
+        maxWidth = Math.max(maxWidth, getSuggestedMinimumWidth());
+
+        // Check against our foreground's minimum height and width
+        final Drawable drawable = getForeground();
+        if (drawable != null) {
+            maxHeight = Math.max(maxHeight, drawable.getMinimumHeight());
+            maxWidth = Math.max(maxWidth, drawable.getMinimumWidth());
+        }
+
+        setMeasuredDimension(resolveSizeAndState(maxWidth, widthMeasureSpec, childState),
+                resolveSizeAndState(maxHeight, heightMeasureSpec,
+                        childState << MEASURED_HEIGHT_STATE_SHIFT));
+
+        if (mListView != null) {
+            if (mPendingScroll != 0) {
+                mListView.scrollListBy(mPendingScroll);
+                mPendingScroll = 0;
+            }
+
+            int paddingTop = Math.max(mListView.getPaddingTop(),
+                    measureAndGetHeight(mTopPanel, widthMeasureSpec, heightMeasureSpec));
+            int paddingBottom = Math.max(mListView.getPaddingBottom(),
+                    measureAndGetHeight(mBottomPanel, widthMeasureSpec, heightMeasureSpec));
+
+            if (paddingTop != mListView.getPaddingTop()
+                    || paddingBottom != mListView.getPaddingBottom()) {
+                mPendingScroll += mListView.getPaddingTop() - paddingTop;
+                mListView.setPadding(
+                        mListView.getPaddingLeft(), paddingTop,
+                        mListView.getPaddingRight(), paddingBottom);
+            }
+        }
+
+        count = mMatchParentChildren.size();
+        if (count > 1) {
+            for (int i = 0; i < count; i++) {
+                final View child = mMatchParentChildren.get(i);
+                if (mListView == null || (child != mTopPanel && child != mBottomPanel)) {
+                    applyMeasureToChild(child, widthMeasureSpec, heightMeasureSpec);
+                }
+            }
+        }
+    }
+
+    @Override
+    public void setForegroundGravity(int foregroundGravity) {
+        if (getForegroundGravity() != foregroundGravity) {
+            super.setForegroundGravity(foregroundGravity);
+
+            // calling get* again here because the set above may apply default constraints
+            final Drawable foreground = getForeground();
+            if (getForegroundGravity() == Gravity.FILL && foreground != null) {
+                Rect padding = new Rect();
+                if (foreground.getPadding(padding)) {
+                    mForegroundPaddingLeft = padding.left;
+                    mForegroundPaddingTop = padding.top;
+                    mForegroundPaddingRight = padding.right;
+                    mForegroundPaddingBottom = padding.bottom;
+                }
+            } else {
+                mForegroundPaddingLeft = 0;
+                mForegroundPaddingTop = 0;
+                mForegroundPaddingRight = 0;
+                mForegroundPaddingBottom = 0;
+            }
+        }
+    }
+
+    private int getPaddingLeftWithForeground() {
+        return isForegroundInsidePadding() ? Math.max(mPaddingLeft, mForegroundPaddingLeft) :
+            mPaddingLeft + mForegroundPaddingLeft;
+    }
+
+    private int getPaddingRightWithForeground() {
+        return isForegroundInsidePadding() ? Math.max(mPaddingRight, mForegroundPaddingRight) :
+            mPaddingRight + mForegroundPaddingRight;
+    }
+
+    private int getPaddingTopWithForeground() {
+        return isForegroundInsidePadding() ? Math.max(mPaddingTop, mForegroundPaddingTop) :
+            mPaddingTop + mForegroundPaddingTop;
+    }
+
+    private int getPaddingBottomWithForeground() {
+        return isForegroundInsidePadding() ? Math.max(mPaddingBottom, mForegroundPaddingBottom) :
+            mPaddingBottom + mForegroundPaddingBottom;
+    }
+
+    @Override
+    public void onScrollChanged() {
+        if (mListView == null) {
+            return;
+        }
+
+        if (mTopPanel != null) {
+            if (mListView.getChildCount() > 0) {
+                if (mListView.getFirstVisiblePosition() == 0) {
+                    View firstChild = mListView.getChildAt(0);
+                    setScrolling(mTopPanel,
+                            firstChild.getY() - mTopPanel.getHeight() - mTopPanel.getTop());
+                } else {
+                    // shift to hide the frame, last child is not the last position
+                    setScrolling(mTopPanel, -mTopPanel.getHeight());
+                }
+            } else {
+                setScrolling(mTopPanel, 0); // no visible child, fallback to default behaviour
+            }
+        }
+
+        if (mBottomPanel != null) {
+            if (mListView.getChildCount() > 0) {
+                if (mListView.getLastVisiblePosition() >= mListView.getCount() - 1) {
+                    View lastChild = mListView.getChildAt(mListView.getChildCount() - 1);
+                    setScrolling(mBottomPanel,
+                            lastChild.getY() + lastChild.getHeight() - mBottomPanel.getTop());
+                } else {
+                    // shift to hide the frame, last child is not the last position
+                    setScrolling(mBottomPanel, mBottomPanel.getHeight());
+                }
+            } else {
+                setScrolling(mBottomPanel, 0); // no visible child, fallback to default behaviour
+            }
+        }
+    }
+
+    /** Only set scrolling for the panel if there is a change in its translationY. */
+    private void setScrolling(View panel, float translationY) {
+        if (panel.getTranslationY() != translationY) {
+            panel.setTranslationY(translationY);
+        }
+    }
+}
diff --git a/core/res/AndroidManifest.xml b/core/res/AndroidManifest.xml
index 48dfdff..ed71fc2 100644
--- a/core/res/AndroidManifest.xml
+++ b/core/res/AndroidManifest.xml
@@ -1262,6 +1262,11 @@
     <permission android:name="android.permission.CONNECTIVITY_INTERNAL"
         android:protectionLevel="signature|privileged" />
 
+    <!-- Allows an internal user to use restricted Networks.
+         @hide -->
+    <permission android:name="android.permission.CONNECTIVITY_USE_RESTRICTED_NETWORKS"
+        android:protectionLevel="signature|privileged" />
+
     <!-- Allows a system application to access hardware packet offload capabilities.
          @hide -->
     <permission android:name="android.permission.PACKET_KEEPALIVE_OFFLOAD"
diff --git a/core/res/res/layout-watch/alert_dialog_material.xml b/core/res/res/layout-watch/alert_dialog_material.xml
index a8bb204..ce8e20a 100644
--- a/core/res/res/layout-watch/alert_dialog_material.xml
+++ b/core/res/res/layout-watch/alert_dialog_material.xml
@@ -14,7 +14,7 @@
   ~ See the License for the specific language governing permissions and
   ~ limitations under the License
   -->
-<FrameLayout
+<com.android.internal.widget.WatchListDecorLayout
         xmlns:android="http://schemas.android.com/apk/res/android"
         android:id="@+id/parentPanel"
         android:layout_width="match_parent"
@@ -104,4 +104,4 @@
             </FrameLayout>
         </LinearLayout>
     </ScrollView>
-</FrameLayout>
+</com.android.internal.widget.WatchListDecorLayout>
diff --git a/docs/html/_redirects.yaml b/docs/html/_redirects.yaml
index 4cfe808..2b94718 100644
--- a/docs/html/_redirects.yaml
+++ b/docs/html/_redirects.yaml
@@ -1201,3 +1201,10 @@
   to: /studio/intro/index.html?utm_medium=android-studio
 - from: /r/studio-ui/menu-start.html
   to: /training/index.html?utm_medium=android-studio
+
+# N Preview redirects
+
+- from: /preview/features/key-attestation.html
+  to: /training/articles/security-key-attestation.html
+- from: /preview/features/security-config.html
+  to: /training/articles/security-config.html
\ No newline at end of file
diff --git a/docs/html/about/versions/android-1.6.jd b/docs/html/about/versions/android-1.6.jd
index ffca6b6..970c343 100755
--- a/docs/html/about/versions/android-1.6.jd
+++ b/docs/html/about/versions/android-1.6.jd
@@ -289,7 +289,7 @@
 
     <ul>
       <li>New <a href="{@docRoot}guide/topics/manifest/supports-screens-element.html">{@code
-      &lt;supports-screens>}</a> element lets you specify the device screen sizes that your
+      <supports-screens>}</a> element lets you specify the device screen sizes that your
       application is designed and tested to support, where "size" is a combination
       of resolution and density. If your application is run on a device whose screen
       size is not specified in the <code>&lt;supports-screen&gt;</code> element, the system
@@ -324,7 +324,7 @@
     </p>
     </li>
 
-      <li>New <a href="{@docRoot}guide/topics/manifest/uses-feature-element.html">{@code &lt;uses-feature>}</a>
+      <li>New <a href="{@docRoot}guide/topics/manifest/uses-feature-element.html">{@code <uses-feature>}</a>
         element lets an application specify hardware (or other)
         features that it requires to function normally. When an application
         specifies such features, the system allows the application to be installed only
@@ -338,7 +338,7 @@
         </ul>
       </li>
       <li>New attributes for the
-      <a href="{@docRoot}guide/topics/manifest/uses-sdk-element.html">{@code &lt;uses-sdk>}</a> element:
+      <a href="{@docRoot}guide/topics/manifest/uses-sdk-element.html">{@code <uses-sdk>}</a> element:
         <ul>
           <li><code>targetSdkVersion</code>: Indicates the API Level that the application is targeting.
           It is able to run on older versions (down to minSdkVersion), but was explicitly tested to
diff --git a/docs/html/about/versions/android-4.0.3.jd b/docs/html/about/versions/android-4.0.3.jd
index bcfa35c..c4b503c 100644
--- a/docs/html/about/versions/android-4.0.3.jd
+++ b/docs/html/about/versions/android-4.0.3.jd
@@ -217,7 +217,7 @@
 
 <ul>
 <li>Adds the new method {@link
-android.speech.tts.TextToSpeech.Engine#getFeatures(java.util.Locale)
+android.speech.tts.TextToSpeech#getFeatures(java.util.Locale)
 getFeatures()}for querying and enabling network TTS support.
 <li>Adds a new listener class, {@link
 android.speech.tts.UtteranceProgressListener}, that engines can register to
diff --git a/docs/html/about/versions/android-4.0.jd b/docs/html/about/versions/android-4.0.jd
index 48afcd4..bf68584 100644
--- a/docs/html/about/versions/android-4.0.jd
+++ b/docs/html/about/versions/android-4.0.jd
@@ -631,8 +631,8 @@
 <p>A new package, {@link android.net.wifi.p2p}, contains all the APIs for performing peer-to-peer
 connections with Wi-Fi. The primary class you need to work with is {@link
 android.net.wifi.p2p.WifiP2pManager}, which you can acquire by calling {@link
-android.app.Activity#getSystemService getSystemService(WIFI_P2P_SERVICE)}. The {@link
-android.net.wifi.p2p.WifiP2pManager} includes APIs that allow you to:</p>
+android.app.Activity#getSystemService(java.lang.String) getSystemService(WIFI_P2P_SERVICE)}.
+The {@link android.net.wifi.p2p.WifiP2pManager} includes APIs that allow you to:</p>
 <ul>
 <li>Initialize your application for P2P connections by calling {@link
 android.net.wifi.p2p.WifiP2pManager#initialize initialize()}</li>
@@ -798,7 +798,7 @@
 android.R.attr#contentDescription android:contentDescription} text is missing or
 insufficient. To add more text description to the
 {@link android.view.accessibility.AccessibilityEvent}, call {@link
-android.view.accessibility.AccessibilityEvent#getText()}.{@link java.util.List#add add()}.</p>
+android.view.accessibility.AccessibilityRecord#getText()}.{@link java.util.List#add add()}.</p>
 </li>
   <li>At this point, the {@link android.view.View} passes the event up the view hierarchy by calling
 {@link android.view.ViewGroup#requestSendAccessibilityEvent requestSendAccessibilityEvent()} on the
diff --git a/docs/html/about/versions/android-4.2.jd b/docs/html/about/versions/android-4.2.jd
index 34fa1d4..ac84d0f 100755
--- a/docs/html/about/versions/android-4.2.jd
+++ b/docs/html/about/versions/android-4.2.jd
@@ -213,9 +213,9 @@
 <p>Android now allows your app to display unique content on additional screens that are connected
 to the user’s device over either a wired connection or Wi-Fi.
  To create unique content for a secondary display, extend the {@link android.app.Presentation}
-class and implement the {@link android.app.Presentation#onCreate onCreate()} callback. Within
-{@link android.app.Presentation#onCreate onCreate()}, specify your UI for the secondary display
-by calling {@link android.app.Presentation#setContentView setContentView()}.
+class and implement the {@link android.app.Dialog#onCreate onCreate()} callback. Within
+{@link android.app.Dialog#onCreate onCreate()}, specify your UI for the secondary display
+by calling {@link android.app.Dialog#setContentView setContentView()}.
 As an extension of the {@link android.app.Dialog} class, the {@link
 android.app.Presentation} class provides the region in which your app can display a unique UI on the
 secondary display.</p>
@@ -241,13 +241,13 @@
 
 <p>To detect at runtime when a new display has been connected, create an instance of {@link
 android.media.MediaRouter.SimpleCallback} in which you implement the {@link
-android.media.MediaRouter.SimpleCallback#onRoutePresentationDisplayChanged
+android.media.MediaRouter.Callback#onRoutePresentationDisplayChanged
 onRoutePresentationDisplayChanged()} callback method, which the system will call when a new
 presentation display is connected. Then register the {@link
 android.media.MediaRouter.SimpleCallback} by passing it to {@link
 android.media.MediaRouter#addCallback MediaRouter.addCallback()} along with the {@link
 android.media.MediaRouter#ROUTE_TYPE_LIVE_VIDEO} route type. When you receive a call to
-{@link android.media.MediaRouter.SimpleCallback#onRoutePresentationDisplayChanged
+{@link android.media.MediaRouter.Callback#onRoutePresentationDisplayChanged
 onRoutePresentationDisplayChanged()}, simply call {@link
 android.media.MediaRouter#getSelectedRoute MediaRouter.getSelectedRoute()} as mentioned above.</p>
 
@@ -262,7 +262,7 @@
 likely a different screen density. Because the screen characteristics may different, you should
 provide resources that are optimized specifically for such larger displays. If you need
 to request additional resources from your {@link
-android.app.Presentation}, call {@link android.app.Presentation#getContext()}{@link
+android.app.Presentation}, call {@link android.app.Dialog#getContext()}{@link
 android.content.Context#getResources .getResources()} to get the {@link
 android.content.res.Resources} object corresponding to the display. This provides
 the appropriate resources from your app that are best suited for the
@@ -510,7 +510,7 @@
   <p>To use a script intrinsic, call the static <code>create()</code> method of each instrinsic
   to create an instance of the script. You then call the available <code>set()</code>
   methods of each script intrinsic to set any necessary inputs and options.
-  Finally, call the {@link android.renderscript.ScriptC#forEach forEach()}</code>
+  Finally, call the {@link android.renderscript.Script#forEach forEach()}</code>
   method to execute the script.</p>
   </dd>
 
diff --git a/docs/html/about/versions/android-4.3.jd b/docs/html/about/versions/android-4.3.jd
index 547b2f8..34a701b 100644
--- a/docs/html/about/versions/android-4.3.jd
+++ b/docs/html/about/versions/android-4.3.jd
@@ -907,7 +907,7 @@
 
 <p>To track changes to inserts and updates, you can now include the {@link android.provider.ContactsContract.ContactsColumns#CONTACT_LAST_UPDATED_TIMESTAMP} parameter with your selection to query only the contacts that have changed since the last time you queried the provider.</p>
 
-<p>To track which contacts have been deleted, the new table {@link android.provider.ContactsContract.DeletedContacts} provides a log of contacts that have been deleted (but each contact deleted is held in this table for a limited time). Similar to {@link android.provider.ContactsContract.ContactsColumns#CONTACT_LAST_UPDATED_TIMESTAMP}, you can use the new selection parameter, {@link android.provider.ContactsContract.DeletedContacts#CONTACT_DELETED_TIMESTAMP} to check which contacts have been deleted since the last time you queried the provider. The table also contains the constant {@link android.provider.ContactsContract.DeletedContacts#DAYS_KEPT_MILLISECONDS} containing the number of days (in milliseconds) that the log will be kept.</p>
+<p>To track which contacts have been deleted, the new table {@link android.provider.ContactsContract.DeletedContacts} provides a log of contacts that have been deleted (but each contact deleted is held in this table for a limited time). Similar to {@link android.provider.ContactsContract.ContactsColumns#CONTACT_LAST_UPDATED_TIMESTAMP}, you can use the new selection parameter, {@link android.provider.ContactsContract.DeletedContactsColumns#CONTACT_DELETED_TIMESTAMP} to check which contacts have been deleted since the last time you queried the provider. The table also contains the constant {@link android.provider.ContactsContract.DeletedContacts#DAYS_KEPT_MILLISECONDS} containing the number of days (in milliseconds) that the log will be kept.</p>
 
 <p>Additionally, the Contacts Provider now broadcasts the {@link
 android.provider.ContactsContract.Intents#CONTACTS_DATABASE_CREATED} action when the user
diff --git a/docs/html/about/versions/marshmallow/android-6.0-changes.jd b/docs/html/about/versions/marshmallow/android-6.0-changes.jd
index b44142e..65c976b 100644
--- a/docs/html/about/versions/marshmallow/android-6.0-changes.jd
+++ b/docs/html/about/versions/marshmallow/android-6.0-changes.jd
@@ -280,7 +280,7 @@
 If your app uses the
 {@link java.lang.reflect.Constructor#newInstance(java.lang.Object...) newInstance()} method and you
 want to override access checks, call the
-{@link java.lang.reflect.Constructor#setAccessible(boolean) setAccessible()} method with the input
+{@link java.lang.reflect.AccessibleObject#setAccessible(boolean) setAccessible()} method with the input
 parameter set to {@code true}. If your app uses the
 <a href="{@docRoot}tools/support-library/features.html#v7-appcompat">v7 appcompat library</a> or the
 <a href="{@docRoot}tools/support-library/features.html#v7-recyclerview">v7 recyclerview library</a>,
diff --git a/docs/html/about/versions/marshmallow/android-6.0.jd b/docs/html/about/versions/marshmallow/android-6.0.jd
index 240b080..247c6d1c 100644
--- a/docs/html/about/versions/marshmallow/android-6.0.jd
+++ b/docs/html/about/versions/marshmallow/android-6.0.jd
@@ -129,8 +129,8 @@
 <pre class="no-prettyprint">
 adb -e emu finger touch &lt;finger_id&gt;
 </pre>
-<p>On Windows, you may have to run {@code telnet 127.0.0.1 &lt;emulator-id&gt;} followed by
-  {@code finger touch &lt;finger_id&gt;}.
+<p>On Windows, you may have to run {@code telnet 127.0.0.1 <emulator-id>} followed by
+  {@code finger touch <finger_id>}.
 </p>
 </li>
 </ol>
@@ -204,7 +204,7 @@
 
 <p>For each activity that you want to expose to
 {@link android.service.chooser.ChooserTargetService}, add a
-{@code &lt;meta-data&gt;} element with the name
+{@code <meta-data>} element with the name
 {@code "android.service.chooser.chooser_target_service"} in your app manifest.
 </p>
 
diff --git a/docs/html/google/play/billing/billing_integrate.jd b/docs/html/google/play/billing/billing_integrate.jd
index e666bc6..5d6b3a8 100755
--- a/docs/html/google/play/billing/billing_integrate.jd
+++ b/docs/html/google/play/billing/billing_integrate.jd
@@ -90,7 +90,7 @@
 <li>Select <strong>Google Play Billing Library</strong>.</li>
 <li>Click <strong>Install packages</strong> to complete the download.</li>
 </ol>
-<p>The {@code IInAppBillingService.aidl} file will be installed to {@code &lt;sdk&gt;/extras/google/play_billing/}.</p>
+<p>The {@code IInAppBillingService.aidl} file will be installed to {@code <sdk>/extras/google/play_billing/}.</p>
 
 <p>To add the AIDL to your project:</p>
 
@@ -116,7 +116,7 @@
           <strong>OK</strong>.</li>
 
           <li>Using your operating system file explorer, navigate to
-          {@code &lt;sdk&gt;/extras/google/play_billing/}, copy the
+          {@code <sdk>/extras/google/play_billing/}, copy the
           {@code IInAppBillingService.aidl} file, and paste it into the
           {@code com.android.vending.billing} package in your project.
           </li>
diff --git a/docs/html/google/play/expansion-files.jd b/docs/html/google/play/expansion-files.jd
index 3c01684..cb8f277 100755
--- a/docs/html/google/play/expansion-files.jd
+++ b/docs/html/google/play/expansion-files.jd
@@ -131,7 +131,7 @@
   <dt>{@code main} or {@code patch}</dt>
     <dd>Specifies whether the file is the main or patch expansion file. There can be
 only one main file and one patch file for each APK.</dd>
-  <dt>{@code &lt;expansion-version&gt;}</dt>
+  <dt>{@code <expansion-version>}</dt>
     <dd>This is an integer that matches the version code of the APK with which the expansion is
 <em>first</em> associated (it matches the application's <a
 href="{@docRoot}guide/topics/manifest/manifest-element.html#vcode">{@code android:versionCode}</a>
@@ -139,7 +139,7 @@
     <p>"First" is emphasized because although the Developer Console allows you to
 re-use an uploaded expansion file with a new APK, the expansion file's name does not change&mdash;it
 retains the version applied to it when you first uploaded the file.</p></dd>
-  <dt>{@code &lt;package-name&gt;}</dt>
+  <dt>{@code <package-name>}</dt>
     <dd>Your application's Java-style package name.</dd>
 </dl>
 
@@ -162,9 +162,9 @@
 </pre>
 
 <ul>
-  <li>{@code &lt;shared-storage&gt;} is the path to the shared storage space, available from
+  <li>{@code <shared-storage>} is the path to the shared storage space, available from
 {@link android.os.Environment#getExternalStorageDirectory()}.</li>
-  <li>{@code &lt;package-name&gt;} is your application's Java-style package name, available
+  <li>{@code <package-name>} is your application's Java-style package name, available
 from {@link android.content.Context#getPackageName()}.</li>
 </ul>
 
@@ -470,7 +470,7 @@
 <strong>Finish</strong>.</li>
   <li>Select <strong>File > Project Structure</strong>.</li>
   <li>Select the <em>Properties</em> tab and in <em>Library
-Repository</em>, enter the library from the {@code &lt;sdk&gt;/extras/google/} directory
+Repository</em>, enter the library from the {@code <sdk>/extras/google/} directory
 ({@code play_licensing/} for the License Verification Library or {@code
 play_apk_expansion/downloader_library/} for the Downloader Library).</li>
   <li>Select <strong>OK</strong> to create the new module.</li>
@@ -716,7 +716,7 @@
   </li>
   <li>Start the download by calling the static method {@code
 DownloaderClientMarshaller.startDownloadServiceIfRequired(Context c, PendingIntent
-notificationClient, Class&lt;?> serviceClass)}.
+notificationClient, Class<?> serviceClass)}.
     <p>The method takes the following parameters:</p>
     <ul>
       <li><code>context</code>: Your application's {@link android.content.Context}.</li>
@@ -780,7 +780,7 @@
   </li>
   <li>When the {@code startDownloadServiceIfRequired()} method returns anything <em>other
 than</em> {@code NO_DOWNLOAD_REQUIRED}, create an instance of {@code IStub} by
-calling {@code DownloaderClientMarshaller.CreateStub(IDownloaderClient client, Class&lt;?>
+calling {@code DownloaderClientMarshaller.CreateStub(IDownloaderClient client, Class<?>
 downloaderService)}. The {@code IStub} provides a binding between your activity to the downloader
 service such that your activity receives callbacks about the download progress.
     <p>In order to instantiate your {@code IStub} by calling {@code CreateStub()}, you must pass it
@@ -956,7 +956,7 @@
 depends on the type of file you've used. As discussed in the <a href="#Overview">overview</a>, your
 expansion files can be any kind of file you
 want, but are renamed using a particular <a href="#Filename">file name format</a> and are saved to
-{@code &lt;shared-storage&gt;/Android/obb/&lt;package-name&gt;/}.</p>
+{@code <shared-storage>/Android/obb/<package-name>/}.</p>
 
 <p>Regardless of how you read your files, you should always first check that the external
 storage is available for reading. There's a chance that the user has the storage mounted to a
@@ -1059,7 +1059,7 @@
 
 <p>The Google Market Apk Expansion package includes a library called the APK
 Expansion Zip Library (located in {@code
-&lt;sdk>/extras/google/google_market_apk_expansion/zip_file/}). This is an optional library that
+<sdk>/extras/google/google_market_apk_expansion/zip_file/}). This is an optional library that
 helps you read your expansion
 files when they're saved as ZIP files. Using this library allows you to easily read resources from
 your ZIP expansion files as a virtual file system.</p>
diff --git a/docs/html/google/play/licensing/setting-up.jd b/docs/html/google/play/licensing/setting-up.jd
index 352b79b..11ca4d7 100755
--- a/docs/html/google/play/licensing/setting-up.jd
+++ b/docs/html/google/play/licensing/setting-up.jd
@@ -181,12 +181,12 @@
 <ol>
   <li>Launch the Android SDK Manager, available under the Android Studio Tools menu
 (<strong>Tools > Android > SDK Manager</strong>) or by executing
-{@code &lt;sdk>/tools/android sdk}.</li>
+{@code <sdk>/tools/android sdk}.</li>
   <li>Select and download <strong>Google APIs</strong> for the Android version you'd like to target
 (must be Android 2.2 or higher).</li>
   <li>When the download is complete, open the AVD Manager, available under the Android Studio
 Tools menu (<strong>Tools > Android > AVD Manager</strong>) or by executing
-{@code &lt;sdk>/tools/android avd}.</li>
+{@code <sdk>/tools/android avd}.</li>
   <li>In the <em>Android Virtual Device Manager</em> window, select
 <strong>+ Create Virtual Device</strong> to set the configuration details for the new AVD. </li>
   <li>In the <em>Virtual Device Configuration</em> window, select device hardware, then
@@ -317,7 +317,7 @@
 <strong>File > New > Import Module</strong>.</li>
 <li>In the <em>New Module</em> window, in <em>Source directory</em>, enter the LVL's
 <code>library</code> directory (the directory containing the library's AndroidManifest.xml file)
-as the project root ({@code &lt;sdk>/extras/google/play_licensing/library/AndroidManifest.xml}),
+as the project root ({@code <sdk>/extras/google/play_licensing/library/AndroidManifest.xml}),
 then select <strong>Next</strong>.</li>
 <li>Select <strong>Finish</strong> to import the library module.</li>
 </ol>
diff --git a/docs/html/guide/components/activities.jd b/docs/html/guide/components/activities.jd
index e757288..9443924 100644
--- a/docs/html/guide/components/activities.jd
+++ b/docs/html/guide/components/activities.jd
@@ -624,8 +624,8 @@
 before making the activity vulnerable to destruction. The system passes this method
 a {@link android.os.Bundle} in which you can save
 state information about the activity as name-value pairs, using methods such as {@link
-android.os.Bundle#putString putString()} and {@link
-android.os.Bundle#putInt putInt()}. Then, if the system kills your application
+android.os.BaseBundle#putString putString()} and {@link
+android.os.BaseBundle#putInt putInt()}. Then, if the system kills your application
 process and the user navigates back to your activity, the system recreates the activity and passes
 the {@link android.os.Bundle} to both {@link android.app.Activity#onCreate onCreate()} and {@link
 android.app.Activity#onRestoreInstanceState onRestoreInstanceState()}. Using either of these
diff --git a/docs/html/guide/practices/compatibility.jd b/docs/html/guide/practices/compatibility.jd
index 83e841c..fb3db84 100644
--- a/docs/html/guide/practices/compatibility.jd
+++ b/docs/html/guide/practices/compatibility.jd
@@ -114,7 +114,7 @@
 
 <p>If necessary, you can prevent users from installing your app when their devices don't provide a
 given feature by declaring it with a <a href=
-"{@docRoot}guide/topics/manifest/uses-feature-element.html">{@code &lt;uses-feature&gt;}</a>
+"{@docRoot}guide/topics/manifest/uses-feature-element.html">{@code <uses-feature>}</a>
 element in your app's <a href="{@docRoot}guide/topics/manifest/manifest-intro.html">manifest
 file</a>.</p>
 
@@ -164,7 +164,7 @@
 on this feature and make your app available to devices without Bluetooth by setting the <a href=
 "{@docRoot}guide/topics/manifest/uses-feature-element.html#required">{@code required}</a> attribute
 to {@code "false"} in the <a href=
-"{@docRoot}guide/topics/manifest/uses-feature-element.html">{@code &lt;uses-feature&gt;}</a> tag.
+"{@docRoot}guide/topics/manifest/uses-feature-element.html">{@code <uses-feature>}</a> tag.
 For more information about implicitly required device features, read <a href=
 "{@docRoot}guide/topics/manifest/uses-feature-element.html#permissions">Permissions that Imply
 Feature Requirements</a>.</p>
@@ -180,7 +180,7 @@
 
 <p>The API level allows you to declare the minimum version with which your app is
 compatible, using the <a href="{@docRoot}guide/topics/manifest/uses-sdk-element.html">{@code
-&lt;uses-sdk>}</a> manifest tag and its
+<uses-sdk>}</a> manifest tag and its
 <a href="{@docRoot}guide/topics/manifest/uses-sdk-element.html#min">{@code minSdkVersion}</a>
 attribute.</p>
 
diff --git a/docs/html/guide/topics/connectivity/bluetooth.jd b/docs/html/guide/topics/connectivity/bluetooth.jd
index 07fcd09..42229fd 100644
--- a/docs/html/guide/topics/connectivity/bluetooth.jd
+++ b/docs/html/guide/topics/connectivity/bluetooth.jd
@@ -1056,7 +1056,7 @@
 object. <p>Similar to regular headset and A2DP profile devices, you must call
 {@link android.bluetooth.BluetoothAdapter#getProfileProxy getProfileProxy()}
 with a {@link android.bluetooth.BluetoothProfile.ServiceListener} and the {@link
-android.bluetooth.BluetoothProfile.ServiceListener#HEALTH} profile type to
+android.bluetooth.BluetoothProfile#HEALTH} profile type to
 establish a connection with the profile proxy object.</p> </li>
 
   <li>Create a {@link android.bluetooth.BluetoothHealthCallback} and register an
diff --git a/docs/html/guide/topics/connectivity/wifip2p.jd b/docs/html/guide/topics/connectivity/wifip2p.jd
index b8eb40e..2bcdf54 100644
--- a/docs/html/guide/topics/connectivity/wifip2p.jd
+++ b/docs/html/guide/topics/connectivity/wifip2p.jd
@@ -117,7 +117,7 @@
 	</tr>
 
 	<tr>
-	  <td>{@link android.net.wifi.p2p.WifiP2pManager.PeerListListener#discoverPeers discoverPeers()}</td>
+	  <td>{@link android.net.wifi.p2p.WifiP2pManager#discoverPeers discoverPeers()}</td>
 	  <td>Initiates peer discovery </td>
 	</tr>
 
@@ -147,7 +147,7 @@
     android.net.wifi.p2p.WifiP2pManager#cancelConnect cancelConnect()}, {@link
     android.net.wifi.p2p.WifiP2pManager#createGroup createGroup()}, {@link
     android.net.wifi.p2p.WifiP2pManager#removeGroup removeGroup()}, and {@link
-    android.net.wifi.p2p.WifiP2pManager.PeerListListener#discoverPeers discoverPeers()}</td>
+    android.net.wifi.p2p.WifiP2pManager#discoverPeers discoverPeers()}</td>
     </tr>
 
     <tr>
@@ -190,8 +190,8 @@
       <tr>
         <td>{@link android.net.wifi.p2p.WifiP2pManager#WIFI_P2P_PEERS_CHANGED_ACTION}</td>
         <td>Broadcast when you call {@link
-    android.net.wifi.p2p.WifiP2pManager.PeerListListener#discoverPeers discoverPeers()}. You
-    usually want to call {@link android.net.wifi.p2p.WifiP2pManager.PeerListListener#requestPeers
+    android.net.wifi.p2p.WifiP2pManager#discoverPeers discoverPeers()}. You
+    usually want to call {@link android.net.wifi.p2p.WifiP2pManager#requestPeers
     requestPeers()} to get an updated list of peers if you handle this intent in your
     application.</td>
       </tr>
diff --git a/docs/html/guide/topics/manifest/meta-data-element.jd b/docs/html/guide/topics/manifest/meta-data-element.jd
index 2d1bdfe..945b116 100644
--- a/docs/html/guide/topics/manifest/meta-data-element.jd
+++ b/docs/html/guide/topics/manifest/meta-data-element.jd
@@ -60,7 +60,7 @@
 <dt><a name="rsrc"></a>{@code android:resource}</dt>
 <dd>A reference to a resource.  The ID of the resource is the value assigned
 to the item.  The ID can be retrieved from the meta-data Bundle by the
-{@link android.os.Bundle#getInt Bundle.getInt()} method.</dd>
+{@link android.os.BaseBundle#getInt Bundle.getInt()} method.</dd>
 
 <dt><a name="val"></a>{@code android:value}</dt>
 <dd>The value assigned to the item.  The data types that can be assigned as values and the Bundle methods that  components use to retrieve those values are listed in the following table:
@@ -72,17 +72,17 @@
 </tr><tr>
   <td>String value, using double backslashes ({@code \\}) to escape characters
       &mdash; such as "{@code \\n}" and "{@code \\uxxxxx}" for a Unicode character.</td>
-  <td>{@link android.os.Bundle#getString(String) getString()}</td>
+  <td>{@link android.os.BaseBundle#getString(String) getString()}</td>
 </tr><tr>
   <td>Integer value, such as "{@code 100}"</td>
-  <td>{@link android.os.Bundle#getInt(String) getInt()}</td>
+  <td>{@link android.os.BaseBundle#getInt(String) getInt()}</td>
 </tr><tr>
   <td>Boolean value, either "{@code true}" or "{@code false}"</td>
-  <td>{@link android.os.Bundle#getBoolean(String) getBoolean()}</td>
+  <td>{@link android.os.BaseBundle#getBoolean(String) getBoolean()}</td>
 </tr><tr>
   <td>Color value, in the form "{@code #rgb}", "{@code #argb}",
       "{@code #rrggbb}", or "{@code #aarrggbb}"</td>
-  <td>{@link android.os.Bundle#getInt(String) getInt()}</td>
+  <td>{@link android.os.BaseBundle#getInt(String) getInt()}</td>
 </tr><tr>
   <td>Float value, such as "{@code 1.23}"</td>
   <td>{@link android.os.Bundle#getFloat(String) getFloat()}</td>
diff --git a/docs/html/guide/topics/manifest/uses-feature-element.jd b/docs/html/guide/topics/manifest/uses-feature-element.jd
index 0670348..10841d6 100755
--- a/docs/html/guide/topics/manifest/uses-feature-element.jd
+++ b/docs/html/guide/topics/manifest/uses-feature-element.jd
@@ -1149,12 +1149,12 @@
 
     <p>
       As a best practice, you should still declare your requirement for this
-      orientation using a {@code &lt;uses-feature&gt;} element. If you declare
+      orientation using a {@code <uses-feature>} element. If you declare
       an orientation for your activity using <a href=
       "{@docRoot}guide/topics/manifest/activity-element.html#screen">{@code
       android:screenOrientation}</a>, but don't actually require it, you can
       disable the requirement by declaring the orientation with a {@code
-      &lt;uses-feature&gt;} element and include {@code
+      <uses-feature>} element and include {@code
       android:required="false"}.
     </p>
 
diff --git a/docs/html/guide/topics/providers/calendar-provider.jd b/docs/html/guide/topics/providers/calendar-provider.jd
index 485f3c1..01a1bfc 100644
--- a/docs/html/guide/topics/providers/calendar-provider.jd
+++ b/docs/html/guide/topics/providers/calendar-provider.jd
@@ -278,9 +278,9 @@
 
 <div class="sidebox-wrapper"> <div class="sidebox"> <h3>Why must you include
 ACCOUNT_TYPE?</h3> <p>If you query on a {@link
-android.provider.CalendarContract.Calendars#ACCOUNT_NAME
+android.provider.CalendarContract.SyncColumns#ACCOUNT_NAME
 Calendars.ACCOUNT_NAME}, you must also include
-{@link android.provider.CalendarContract.Calendars#ACCOUNT_TYPE Calendars.ACCOUNT_TYPE}
+{@link android.provider.CalendarContract.SyncColumns#ACCOUNT_TYPE Calendars.ACCOUNT_TYPE}
 in the selection. That is because a given account is
 only considered unique given both its <code>ACCOUNT_NAME</code> and its
 <code>ACCOUNT_TYPE</code>. The <code>ACCOUNT_TYPE</code> is the string corresponding to the
diff --git a/docs/html/guide/topics/providers/contacts-provider.jd b/docs/html/guide/topics/providers/contacts-provider.jd
index 2b14558..ac855aa 100644
--- a/docs/html/guide/topics/providers/contacts-provider.jd
+++ b/docs/html/guide/topics/providers/contacts-provider.jd
@@ -329,13 +329,13 @@
 </p>
 <dl>
     <dt>
-        {@link android.provider.ContactsContract.Data#RAW_CONTACT_ID}
+        {@link android.provider.ContactsContract.DataColumns#RAW_CONTACT_ID}
     </dt>
     <dd>
         The value of the <code>_ID</code> column of the raw contact for this data.
     </dd>
     <dt>
-        {@link android.provider.ContactsContract.Data#MIMETYPE}
+        {@link android.provider.ContactsContract.DataColumns#MIMETYPE}
     </dt>
     <dd>
         The type of data stored in this row, expressed as a custom MIME type. The Contacts Provider
@@ -2351,7 +2351,7 @@
     {@link android.provider.ContactsContract.Data} table, selecting on the raw contact's
     {@link android.provider.BaseColumns#_ID}, the
     {@link android.provider.ContactsContract.CommonDataKinds.Photo#CONTENT_ITEM_TYPE
-    Photo.CONTENT_ITEM_TYPE}, and the {@link android.provider.ContactsContract.Data#IS_PRIMARY}
+    Photo.CONTENT_ITEM_TYPE}, and the {@link android.provider.ContactsContract.DataColumns#IS_PRIMARY}
     column to find the raw contact's primary photo row.
 </p>
 <p>
diff --git a/docs/html/guide/topics/renderscript/compute.jd b/docs/html/guide/topics/renderscript/compute.jd
index 861c925..fe68654 100755
--- a/docs/html/guide/topics/renderscript/compute.jd
+++ b/docs/html/guide/topics/renderscript/compute.jd
@@ -294,7 +294,7 @@
 </ul></li>
 
 <li><strong>Populate Allocations with data.</strong> Except for Allocations created with {@link
-android.renderscript#createFromBitmap}, an Allocation will be populated with empty data when it is
+android.renderscript.Allocation#createFromBitmap}, an Allocation will be populated with empty data when it is
 first created. To populate an Allocation, use one of the <code>copy</code> methods in {@link
 android.renderscript.Allocation}.</li>
 
diff --git a/docs/html/guide/topics/search/search-dialog.jd b/docs/html/guide/topics/search/search-dialog.jd
index 4d6b400..8278ab1 100644
--- a/docs/html/guide/topics/search/search-dialog.jd
+++ b/docs/html/guide/topics/search/search-dialog.jd
@@ -699,7 +699,7 @@
     inflater.inflate(R.menu.options_menu, menu);
 
     // Get the SearchView and set the searchable configuration
-    SearchManager searchManager = (SearchManager) {@link android.app.Activity#getSystemService getSystemService}(Context.SEARCH_SERVICE);
+    SearchManager searchManager = (SearchManager) {@link android.app.Activity#getSystemService(java.lang.String) getSystemService()}(Context.SEARCH_SERVICE);
     SearchView searchView = (SearchView) menu.findItem(R.id.menu_search).getActionView();
     // Assumes current activity is the searchable activity
     searchView.setSearchableInfo(searchManager.getSearchableInfo({@link android.app.Activity#getComponentName()}));
diff --git a/docs/html/guide/topics/ui/accessibility/apps.jd b/docs/html/guide/topics/ui/accessibility/apps.jd
index ab8c792..c415762 100644
--- a/docs/html/guide/topics/ui/accessibility/apps.jd
+++ b/docs/html/guide/topics/ui/accessibility/apps.jd
@@ -298,7 +298,7 @@
 dispatchPopulateAccessibilityEvent()} method for each child of this view. In order to support
 accessibility services on revisions of Android <em>prior</em> to 4.0 (API Level 14) you
 <em>must</em> override this method and populate {@link
-android.view.accessibility.AccessibilityEvent#getText} with descriptive text for your custom
+android.view.accessibility.AccessibilityRecord#getText} with descriptive text for your custom
 view, which is spoken by accessibility services, such as TalkBack.</dd>
 
   <dt>{@link android.view.View#onPopulateAccessibilityEvent onPopulateAccessibilityEvent()}</dt>
diff --git a/docs/html/guide/topics/ui/accessibility/services.jd b/docs/html/guide/topics/ui/accessibility/services.jd
index c6db855..d08022e 100644
--- a/docs/html/guide/topics/ui/accessibility/services.jd
+++ b/docs/html/guide/topics/ui/accessibility/services.jd
@@ -205,7 +205,7 @@
 while it is running ({@link android.accessibilityservice.AccessibilityService#onAccessibilityEvent
 onAccessibilityEvent()},
 {@link android.accessibilityservice.AccessibilityService#onInterrupt onInterrupt()}) to when it is
-shut down ({@link android.accessibilityservice.AccessibilityService#onUnbind onUnbind()}).</p>
+shut down ({@link android.app.Service#onUnbind onUnbind()}).</p>
 
 <ul>
   <li>{@link android.accessibilityservice.AccessibilityService#onServiceConnected
@@ -231,7 +231,7 @@
 providing, usually in response to a user action such as moving focus to a different control. This
 method may be called many times over the lifecycle of your service.</li>
 
-  <li>{@link android.accessibilityservice.AccessibilityService#onUnbind onUnbind()} - (optional)
+  <li>{@link android.app.Service#onUnbind onUnbind()} - (optional)
 This method is called when the system is about to shutdown the accessibility service. Use this
 method to do any one-time shutdown procedures, including de-allocating user feedback system
 services, such as the audio manager or device vibrator.</li>
@@ -283,7 +283,7 @@
 to the {@link android.view.accessibility.AccessibilityEvent} passed to you by the system. This level
 of detail provides more context for the event that triggered your accessibility service.</li>
 
-  <li>{@link android.view.accessibility.AccessibilityEvent#getSource
+  <li>{@link android.view.accessibility.AccessibilityRecord#getSource
 AccessibilityEvent.getSource()} - This method returns an {@link
 android.view.accessibility.AccessibilityNodeInfo} object. This object allows you to request view
 layout hierarchy (parents and children) of the component that originated the accessibility event.
@@ -296,10 +296,10 @@
 level of access through the accessibility <a href="#service-config">service configuration XML</a>
 file, by including the {@code canRetrieveWindowContent} attribute and setting it to {@code true}. If
 you do not include this setting in your service configuration xml file, calls to {@link
-android.view.accessibility.AccessibilityEvent#getSource getSource()} fail.</p>
+android.view.accessibility.AccessibilityRecord#getSource getSource()} fail.</p>
 
 <p class="note"><strong>Note:</strong> In Android 4.1 (API Level 16) and higher, the
-{@link android.view.accessibility.AccessibilityEvent#getSource getSource()} method,
+{@link android.view.accessibility.AccessibilityRecord#getSource getSource()} method,
 as well as {@link android.view.accessibility.AccessibilityNodeInfo#getChild
 AccessibilityNodeInfo.getChild()} and
 {@link android.view.accessibility.AccessibilityNodeInfo#getParent getParent()}, return only
@@ -372,7 +372,7 @@
   <a href="#service-config">service configuration file</a>. When events are received by your
   service, it can then retrieve the
   {@link android.view.accessibility.AccessibilityNodeInfo} object from the event using
-  {@link android.view.accessibility.AccessibilityEvent#getSource getSource()}.
+  {@link android.view.accessibility.AccessibilityRecord#getSource getSource()}.
   With the {@link android.view.accessibility.AccessibilityNodeInfo} object, your service can then
   explore the view hierarchy to determine what action to take and then act for the user using
   {@link android.view.accessibility.AccessibilityNodeInfo#performAction performAction()}.</p>
diff --git a/docs/html/guide/topics/ui/declaring-layout.jd b/docs/html/guide/topics/ui/declaring-layout.jd
index bf0db57..ecdcfdc 100755
--- a/docs/html/guide/topics/ui/declaring-layout.jd
+++ b/docs/html/guide/topics/ui/declaring-layout.jd
@@ -423,7 +423,7 @@
   <li>The string array</li>
 </ul>
 <p>Then simply call
-{@link android.widget.ListView#setAdapter setAdapter()} on your {@link android.widget.ListView}:</p>
+{@link android.widget.AdapterView#setAdapter setAdapter()} on your {@link android.widget.ListView}:</p>
 <pre>
 ListView listView = (ListView) findViewById(R.id.listview);
 listView.setAdapter(adapter);
diff --git a/docs/html/guide/topics/ui/dialogs.jd b/docs/html/guide/topics/ui/dialogs.jd
index 7ab4ca5..52cd1a0 100644
--- a/docs/html/guide/topics/ui/dialogs.jd
+++ b/docs/html/guide/topics/ui/dialogs.jd
@@ -643,7 +643,7 @@
 or other {@link android.app.Dialog} objects to build the dialog in this case. If
 you want the {@link android.support.v4.app.DialogFragment} to be
 embeddable, you must define the dialog's UI in a layout, then load the layout in the
-{@link android.support.v4.app.DialogFragment#onCreateView
+{@link android.support.v4.app.Fragment#onCreateView
 onCreateView()} callback.</p>
 
 <p>Here's an example {@link android.support.v4.app.DialogFragment} that can appear as either a
diff --git a/docs/html/guide/topics/ui/layout/gridview.jd b/docs/html/guide/topics/ui/layout/gridview.jd
index 13467ae..4ed6ff5 100644
--- a/docs/html/guide/topics/ui/layout/gridview.jd
+++ b/docs/html/guide/topics/ui/layout/gridview.jd
@@ -81,7 +81,7 @@
   <p>After the {@code main.xml} layout is set for the content view, the
 {@link android.widget.GridView} is captured from the layout with {@link
 android.app.Activity#findViewById(int)}. The {@link
-android.widget.GridView#setAdapter(T) setAdapter()} method then sets a custom adapter ({@code
+android.widget.AdapterView#setAdapter(T) setAdapter()} method then sets a custom adapter ({@code
 ImageAdapter}) as the source for all items to be displayed in the grid. The {@code ImageAdapter} is
 created in the next step.</p>
 <p>To do something when an item in the grid is clicked, the {@link
@@ -170,7 +170,7 @@
 image is resized and cropped to fit in these dimensions, as appropriate.</li>
   <li>{@link android.widget.ImageView#setScaleType(ImageView.ScaleType)} declares that images should
 be cropped toward the center (if necessary).</li>
-  <li>{@link android.widget.ImageView#setPadding(int,int,int,int)} defines the padding for all
+  <li>{@link android.view.View#setPadding(int,int,int,int)} defines the padding for all
 sides. (Note that, if the images have different aspect-ratios, then less
 padding will cause more cropping of the image if it does not match
 the dimensions given to the ImageView.)</li>
diff --git a/docs/html/guide/topics/ui/menus.jd b/docs/html/guide/topics/ui/menus.jd
index 73dec20..38f6e21 100644
--- a/docs/html/guide/topics/ui/menus.jd
+++ b/docs/html/guide/topics/ui/menus.jd
@@ -132,7 +132,7 @@
 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
+    <dd>An optional, invisible container for {@code <item>} elements. It allows you to
 categorize menu items so they share properties such as active state and visibility. For more
 information, see the section about <a href="#groups">Creating Menu Groups</a>.</dd>
 </dl>
@@ -172,8 +172,8 @@
 For information about all the supported attributes, see the <a
 href="{@docRoot}guide/topics/resources/menu-resource.html">Menu Resource</a> document.</p>
 
-<p>You can add a submenu to an item in any menu (except a submenu) by adding a {@code &lt;menu&gt;}
-element as the child of an {@code &lt;item&gt;}. Submenus are useful when your application has a lot
+<p>You can add a submenu to an item in any menu (except a submenu) by adding a {@code <menu>}
+element as the child of an {@code <item>}. Submenus are useful when your application has a lot
 of functions that can be organized into topics, like items in a PC application's menu bar (File,
 Edit, View, etc.). For example:</p>
 
@@ -230,7 +230,7 @@
 the right side of the app bar (or by pressing the device <em>Menu</em> button, if available). To
 enable
 quick access to important actions, you can promote a few items to appear in the app bar by adding
-{@code android:showAsAction="ifRoom"} to the corresponding {@code &lt;item&gt;} elements (see figure
+{@code android:showAsAction="ifRoom"} to the corresponding {@code <item>} elements (see figure
 2). <p>For more information about action items and other app bar behaviors, see the <a
 href="{@docRoot}training/appbar/index.html">Adding the App Bar</a> training class. </p>
 </li>
@@ -246,7 +246,7 @@
 declare items for the options menu, they are combined in the UI. The activity's items appear
 first, followed by those of each fragment in the order in which each fragment is added to the
 activity. If necessary, you can re-order the menu items with the {@code android:orderInCategory}
-attribute in each {@code &lt;item&gt;} you need to move.</p>
+attribute in each {@code <item>} you need to move.</p>
 
 <p>To specify the options menu for an activity, override {@link
 android.app.Activity#onCreateOptionsMenu(Menu) onCreateOptionsMenu()} (fragments provide their
@@ -682,7 +682,7 @@
 </pre>
 
 <p>That's it. Now when the user selects an item with a long-click, the system calls the {@link
-android.widget.AbsListView.MultiChoiceModeListener#onCreateActionMode onCreateActionMode()}
+android.view.ActionMode.Callback#onCreateActionMode onCreateActionMode()}
 method and displays the contextual action bar with the specified actions. While the contextual
 action bar is visible, users can select additional items.</p>
 
@@ -814,7 +814,7 @@
 android.view.Menu#setGroupCheckable(int,boolean,boolean) setGroupCheckable()}</li>
 </ul>
 
-<p>You can create a group by nesting {@code &lt;item&gt;} elements inside a {@code &lt;group&gt;}
+<p>You can create a group by nesting {@code <item>} elements inside a {@code <group>}
 element in your menu resource or by specifying a group ID with the {@link
 android.view.Menu#add(int,int,int,int) add()} method.</p>
 
@@ -863,8 +863,8 @@
 each time the state changes.</p>
 
 <p>You can define the checkable behavior for individual menu items using the {@code
-android:checkable} attribute in the {@code &lt;item&gt;} element, or for an entire group with
-the {@code android:checkableBehavior} attribute in the {@code &lt;group&gt;} element. For
+android:checkable} attribute in the {@code <item>} element, or for an entire group with
+the {@code android:checkableBehavior} attribute in the {@code <group>} element. For
 example, all items in this menu group are checkable with a radio button:</p>
 
 <pre>
@@ -890,7 +890,7 @@
 </dl>
 
 <p>You can apply a default checked state to an item using the {@code android:checked} attribute in
-the {@code &lt;item&gt;} element and change it in code with the {@link
+the {@code <item>} element and change it in code with the {@link
 android.view.MenuItem#setChecked(boolean) setChecked()} method.</p>
 
 <p>When a checkable item is selected, the system calls your respective item-selected callback method
diff --git a/docs/html/preview/features/background-optimization.jd b/docs/html/preview/features/background-optimization.jd
index 3e4c041..326513b 100644
--- a/docs/html/preview/features/background-optimization.jd
+++ b/docs/html/preview/features/background-optimization.jd
@@ -379,7 +379,7 @@
 
   <li style="list-style: none; display: inline">
 <pre class="no-pretty-print">
-{@code $ adb shell cmd appops set &lt;package_name&gt; RUN_IN_BACKGROUND ignore}
+{@code $ adb shell cmd appops set <package_name> RUN_IN_BACKGROUND ignore}
 </pre>
   </li>
 
@@ -389,7 +389,7 @@
 
   <li style="list-style: none; display: inline">
 <pre class="no-pretty-print">
-{@code $ adb shell cmd appops set &lt;package_name&gt; RUN_IN_BACKGROUND allow}
+{@code $ adb shell cmd appops set <package_name> RUN_IN_BACKGROUND allow}
 </pre>
   </li>
 </ul>
diff --git a/docs/html/topic/libraries/support-library/revisions.jd b/docs/html/topic/libraries/support-library/revisions.jd
index ef73d1d..3b25fb0 100644
--- a/docs/html/topic/libraries/support-library/revisions.jd
+++ b/docs/html/topic/libraries/support-library/revisions.jd
@@ -960,7 +960,7 @@
           <li style="list-style: none; display: inline">
             <ul>
               <li>Day and night themes can be found here: {@code
-              &lt;sdk&gt;/extras/android/support/v7/appcompat/res/values/themes_daynight.xml}
+              <sdk>/extras/android/support/v7/appcompat/res/values/themes_daynight.xml}
               </li>
 
               <li>{@code AppCompatDelegate.setDefaultNightMode()}: sets the
@@ -2806,7 +2806,7 @@
 <a href="{@docRoot}design/index.html">Android Design</a> guidelines for navigation. These
 additions include a way to implement the action bar's <em>Up</em> button across versions.
 For an example implementation of this pattern, see the AppNavigation sample in
-({@code <em>&lt;sdk&gt;</em>/samples/<em>&lt;platform&gt;</em>/AppNavigation}).</li>
+({@code <em><sdk></em>/samples/<em><platform></em>/AppNavigation}).</li>
           <li>Added {@link android.support.v4.app.NotificationCompat.Builder} to provide a
 compatibility implementation of Android 3.0's {@link android.app.Notification.Builder} helper class
 for creating standardized system notifications.</li>
diff --git a/docs/html/topic/libraries/support-library/setup.jd b/docs/html/topic/libraries/support-library/setup.jd
index 62f7148..5e33851 100755
--- a/docs/html/topic/libraries/support-library/setup.jd
+++ b/docs/html/topic/libraries/support-library/setup.jd
@@ -72,7 +72,7 @@
 
 <p>After downloading, the tool installs the Support Library files to your existing Android SDK
   directory. The library files are located in the following subdirectory of your SDK:
-  {@code &lt;sdk&gt;/extras/android/support/} directory.</p>
+  {@code <sdk>/extras/android/support/} directory.</p>
 
 
 <h2 id="choosing">Choosing Support Libraries</h2>
@@ -233,9 +233,9 @@
 SDK installation directory, as listed below:</p>
 
 <ul>
-  <li>4v Samples: {@code &lt;sdk&gt;/extras/android/support/samples/Support4Demos/}</li>
-  <li>7v Samples: {@code &lt;sdk&gt;/extras/android/support/samples/Support7Demos/}</li>
-  <li>13v Samples: {@code &lt;sdk&gt;/extras/android/support/samples/Support13Demos/}</li>
-  <li>App Navigation: {@code &lt;sdk&gt;/extras/android/support/samples/SupportAppNavigation/}</li>
+  <li>4v Samples: {@code <sdk>/extras/android/support/samples/Support4Demos/}</li>
+  <li>7v Samples: {@code <sdk>/extras/android/support/samples/Support7Demos/}</li>
+  <li>13v Samples: {@code <sdk>/extras/android/support/samples/Support13Demos/}</li>
+  <li>App Navigation: {@code <sdk>/extras/android/support/samples/SupportAppNavigation/}</li>
 </ul>
 
diff --git a/docs/html/training/_book.yaml b/docs/html/training/_book.yaml
index 00f9295..0e2083a 100644
--- a/docs/html/training/_book.yaml
+++ b/docs/html/training/_book.yaml
@@ -1363,6 +1363,11 @@
     path_attributes:
     - name: description
       value: How to ensure that your app is secure when performing network transactions.
+  - title: Network Security Configuration
+    path: /training/articles/security-config.html
+    path_attributes:
+    - name: description
+      value: Customize the behavior of your app's secure network connections safely.
   - title: Updating Your Security Provider to Protect Against SSL Exploits
     path: /training/articles/security-gms-provider.html
     path_attributes:
@@ -1373,6 +1378,11 @@
     path_attributes:
     - name: description
       value: How to use the SafetyNet service to analyze a device where your app is running and get information about its compatibility with your app.
+  - title: Verifying Hardware-backed Key Pairs with Key Attestation
+    path: /training/articles/security-key-attestation.html
+    path_attributes:
+    - name: description
+      value: How to retrieve and verify the properties of a device's hardware-backed key pair.
   - title: Enhancing Security with Device Management Policies
     path: /work/device-management-policy.html
     path_attributes:
diff --git a/docs/html/training/accessibility/service.jd b/docs/html/training/accessibility/service.jd
index 9935c97..de00db7 100755
--- a/docs/html/training/accessibility/service.jd
+++ b/docs/html/training/accessibility/service.jd
@@ -174,7 +174,7 @@
 In that method, use {@link
 android.view.accessibility.AccessibilityEvent#getEventType} to determine the
 type of event, and {@link
-android.view.accessibility.AccessibilityEvent#getContentDescription} to extract
+android.view.accessibility.AccessibilityRecord#getContentDescription} to extract
 any label text associated with the view that fired the event.</pre>
 
 <pre>
@@ -211,7 +211,7 @@
 </pre>
 <p>Once that's done, get an {@link
 android.view.accessibility.AccessibilityNodeInfo} object using {@link
-android.view.accessibility.AccessibilityEvent#getSource}.  This call only
+android.view.accessibility.AccessibilityRecord#getSource}.  This call only
 returns an object if the window where the event originated is still the active
 window.  If not, it will return null, so <em>behave accordingly</em>.  The
 following example is a snippet of code that, when it receives an event, does
diff --git a/docs/html/training/articles/perf-anr.jd b/docs/html/training/articles/perf-anr.jd
index 2eda4fa..8848354 100644
--- a/docs/html/training/articles/perf-anr.jd
+++ b/docs/html/training/articles/perf-anr.jd
@@ -146,7 +146,7 @@
 
 <p>If you implement {@link java.lang.Thread} or {@link android.os.HandlerThread},
 be sure that your UI thread does not block while waiting for the worker thread to
-complete&mdash;do not call {@link java.lang.Thread#wait Thread.wait()} or
+complete&mdash;do not call {@link java.lang.Object#wait Thread.wait()} or
 {@link java.lang.Thread#sleep Thread.sleep()}. Instead of blocking while waiting for a worker
 thread to complete, your main thread should provide a {@link
 android.os.Handler} for the other threads to post back to upon completion.
diff --git a/docs/html/preview/features/security-config.jd b/docs/html/training/articles/security-config.jd
similarity index 77%
rename from docs/html/preview/features/security-config.jd
rename to docs/html/training/articles/security-config.jd
index 2706ced..90a93fa 100644
--- a/docs/html/preview/features/security-config.jd
+++ b/docs/html/training/articles/security-config.jd
@@ -1,11 +1,12 @@
 page.title=Network Security Configuration
-page.keywords=androidn,security,network
+page.keywords=security,network,config
+page.metaDescription=Feature that allows app developers to customize network security settings in a safe configuration file.
 page.image=images/cards/card-nyc_2x.jpg
 
 @jd:body
 
-<div id="qv-wrapper">
-<div id="qv">
+<div id="tb-wrapper">
+<div id="tb">
 
 <h2>In this document</h2>
 <ol>
@@ -28,11 +29,10 @@
 
 
 <p>
-  Android N includes a Network Security Configuration
-  feature that lets apps customize their network security settings in a safe,
-  declarative configuration file without modifying app code. These settings can
-  be configured for specific domains and for a specific app. The key
-  capabilities of this feature are as follows:
+  The Network Security Configuration feature lets apps customize their network
+  security settings in a safe, declarative configuration file without modifying
+  app code. These settings can be configured for specific domains and for a
+  specific app. The key capabilities of this feature are as follows:
 </p>
 
 <ul>
@@ -49,7 +49,7 @@
   </li>
 
   <li>
-    <b>Cleartext traffic opt-out:</b> Protect apps from from
+    <b>Cleartext traffic opt-out:</b> Protect apps from
     accidental usage of cleartext traffic.
   </li>
 
@@ -72,10 +72,10 @@
 <pre>
 &lt;?xml version="1.0" encoding="utf-8"?&gt;
 &lt;manifest ... &gt;
-  &lt;application android:networkSecurityConfig="@xml/network_security_config"
-               ... &gt;
-    ...
-  &lt;/application&gt;
+    &lt;application android:networkSecurityConfig="@xml/network_security_config"
+                    ... &gt;
+        ...
+    &lt;/application&gt;
 &lt;/manifest&gt;
 </pre>
 
@@ -87,12 +87,12 @@
 </p>
 
 <ul>
-  <li>Connecting to a host with a custom certificate authority(self-signed,
-  issued by an internal corporate CA, etc).
+  <li>Connecting to a host with a custom certificate authority, such as a
+  CA that is self-signed or is issued internally within a company.
   </li>
 
   <li>Limiting the set of CAs to only the CAs you trust instead of every
-  preinstalled CA.
+  pre-installed CA.
   </li>
 
   <li>Trusting additional CAs not included in the system.
@@ -100,12 +100,11 @@
 </ul>
 
 <p>
-  By default secure (e.g. TLS, HTTPS) connections from all apps trust
-  the pre-installed system CAs, and apps targeting API level 23
-  (Android M) and below also trust the user-added CA store by default. An
-  app can customize its own connections using {@code base-config} (for
-  app-wide customization) or {@code domain-config} (for per-domain
-  customization).
+  By default, secure connections (using protocols like TLS and HTTPS) from all
+  apps trust the pre-installed system CAs, and apps targeting Android 6.0 (API
+  level 23) and lower also trust the user-added CA store by default. An app can
+  customize its own connections using {@code base-config} (for app-wide
+  customization) or {@code domain-config} (for per-domain customization).
 </p>
 
 
@@ -147,8 +146,8 @@
 </p>
 
 <p>
-  The config to limit the set of trusted CAs is similar to <a href=
-  "#TrustingACustomCa">trusting a custom CA</a> for a specific domain except
+  The configuration to limit the set of trusted CAs is similar to <a href=
+  "#ConfigCustom">trusting a custom CA</a> for a specific domain except
   that multiple CAs are provided in the resource.
 </p>
 
@@ -207,14 +206,14 @@
 <h2 id="TrustingDebugCa">Configuring CAs for Debugging</h2>
 
 <p>
-  When debugging an app that connects over HTTPS you may want to
+  When debugging an app that connects over HTTPS, you may want to
   connect to a local development server, which does not have the SSL
   certificate for your production server. In order to support this without any
-  modification to your app's code you can specify debug-only CAs that
-  are <i>only</i> trusted when <a href=
+  modification to your app's code, you can specify debug-only CAs, which
+  are trusted <i>only</i> when <a href=
   "{@docRoot}guide/topics/manifest/application-element.html#debug">
 android:debuggable</a>
-  is {@code true} by using {@code debug-overrides}. Normally IDEs and build
+  is {@code true}, by using {@code debug-overrides}. Normally, IDEs and build
   tools set this flag automatically for non-release builds.
 </p>
 
@@ -243,7 +242,7 @@
 
 <p>
   Applications intending to connect to destinations using only secure
-  connections can opt-out of supporting cleartext (using unencrypted HTTP
+  connections can opt-out of supporting cleartext (using the unencrypted HTTP
   protocol instead of HTTPS) to those destinations. This option helps prevent
   accidental regressions in apps due to changes in URLs provided by external
   sources such as backend servers.
@@ -273,29 +272,30 @@
 <h2 id="CertificatePinning">Pinning Certificates</h2>
 
 <p>
-  Normally an app trusts all preinstalled CAs. If any of these CAs were
-  to issue a fradulent certificate the app would be at risk from a MiTM
-  attack. Some apps choose to limit the set of certificates they accept
-  by either limiting the set of CAs they trust or by certificate pinning.
+  Normally, an app trusts all pre-installed CAs. If any of these CAs were to
+  issue a fradulent certificate, the app would be at risk from a
+  man-in-the-middle attack. Some apps choose to limit the set of certificates
+  they accept by either limiting the set of CAs they trust or by certificate
+  pinning.
 </p>
 
 <p>
   Certificate pinning is done by providing a set of certificates by hash of the
-  public key (SubjectPublicKeyInfo of the X.509 certificate). A certificate
-  chain is then only valid if the certificate chain contains at least one of
-  the pinned public keys.
+  public key (<code>SubjectPublicKeyInfo</code> of the X.509 certificate). A
+  certificate chain is then valid only if the certificate chain contains at
+  least one of the pinned public keys.
 </p>
 
 <p>
-  Note that when using certificate pinning you should always include a backup
-  key so that if you are forced to switch to new keys, or change CAs (when
+  Note that, when using certificate pinning, you should always include a backup
+  key so that if you are forced to switch to new keys or change CAs (when
   pinning to a CA certificate or an intermediate of that CA), your
-  app's connectivity is unaffected. Otherwise you must to push out
+  app's connectivity is unaffected. Otherwise, you must push out
   an update to the app to restore connectivity.
 </p>
 
 <p>
-  Additionally it is possible to set an expiration time for pins after which
+  Additionally, it is possible to set an expiration time for pins after which
   pinning is not performed. This helps prevent connectivity issues in
   apps which have not been updated. However, setting an expiration time
   on pins may enable pinning bypass.
@@ -322,24 +322,24 @@
 <h2 id="ConfigInheritance">Configuration Inheritance Behavior</h2>
 
 <p>
-  Values not set in a specific config are inherited. This behavior allows more
-  complex configurations while keeping the configuration file readable.
+  Values not set in a specific configuration are inherited. This behavior allows
+  more complex configurations while keeping the configuration file readable.
 </p>
 
 <p>
-  If a value is not set in a specific entry then value from the next more
-  general entry is used. Values not set in a {@code domain-config} is
-  taken from the parent {@code domain-config}, if nested, or from the {@code
-  base-config} if not. Values not set in the {@code base-config} uses the
+  If a value is not set in a specific entry, then the value from the more
+  general entry is used. For example, values not set in a {@code domain-config}
+  are taken from the parent {@code domain-config}, if nested, or from the {@code
+  base-config} if not. Values not set in the {@code base-config} use the
   platform default values.
 </p>
 
 <p>
-  For example consider, where all connections to subdomains of {@code
-  example.com} must use a custom set of CAs. Additonally cleartext traffic to
+  For example, consider where all connections to subdomains of {@code
+  example.com} must use a custom set of CAs. Additonally, cleartext traffic to
   these domains is permitted <em>except</em> when connecting to {@code
   secure.example.com}. By nesting the configuration for {@code
-  secure.example.com} inside the configuration for {@code example.com} the
+  secure.example.com} inside the configuration for {@code example.com}, the
   {@code trust-anchors} does not need to be duplicated.
 </p>
 
@@ -458,7 +458,8 @@
 
 <p>
   Any values that are not set use the platform default values. The default
-  configuration for apps targeting above API level 24 and above:
+  configuration for apps targeting Android 7.0 (API level 24) and higher is as
+  follows:
 </p>
 
 <pre>
@@ -468,7 +469,8 @@
     &lt;/trust-anchors&gt;
 &lt;/base-config&gt;
 </pre>
-The default configuration for apps targeting API level 23 and below is:
+The default configuration for apps targeting Android 6.0 (API level 23) and
+lower is as follows:
 <pre>
 &lt;base-config cleartextTrafficPermitted="true"&gt;
     &lt;trust-anchors&gt;
@@ -499,13 +501,14 @@
 <br/>Any number of nested <code>&lt;domain-config&gt;</code></dd>
 
 <dt>Description</dt>
-<dd>Configuration used for connections to specific destinations as the defined by {@code domain} elements.
+<dd>Configuration used for connections to specific destinations, as defined by
+the {@code domain} elements.
 
-<p>Note that if multiple {@code domain-config} elements cover a destination the config with the most specific (longest)
-matching domain rule is used.</p></dd>
+<p>Note that if multiple {@code domain-config} elements cover a destination, the
+configuration with the most specific (longest) matching domain rule is
+used.</p></dd>
 </dl>
 
-
 <h3 id="domain">&lt;domain&gt;</h3>
 
 <dl class="xml">
@@ -530,8 +533,8 @@
       </dt>
 
       <dd>
-        If {@code "true"} then this domain rule matches the domain and all
-        subdomains, including subdomains of subdomains, otherwise the rule only
+        If {@code "true"}, then this domain rule matches the domain and all
+        subdomains, including subdomains of subdomains. Otherwise, the rule only
         applies to exact matches.
       </dd>
     </dl>
@@ -572,13 +575,13 @@
   <dd>
     Overrides to be applied when <a href=
     "{@docRoot}guide/topics/manifest/application-element.html#debug">android:debuggable</a>
-    is {@code "true"} which is normally the case for non-release builds
+    is {@code "true"}, which is normally the case for non-release builds
     generated by IDEs and build tools. Trust anchors specified in {@code
-    debug-overrides} are added to all other configurations and certificate
+    debug-overrides} are added to all other configurations, and certificate
     pinning is not performed when the server's certificate chain uses one of
     these debug-only trust anchors. If <a href=
     "{@docRoot}guide/topics/manifest/application-element.html#debug">android:debuggable</a>
-    is {@code "false"} then this section is completely ignored.
+    is {@code "false"}, then this section is completely ignored.
   </dd>
 </dl>
 
@@ -627,11 +630,11 @@
 <dd><dl class="attr">
 <dt>{@code src}</dt>
 <dd>
-The source of CA certificates, can be one of
+The source of CA certificates. Each certificate can be one of the following:
 <ul>
-  <li>a raw resource id pointing to a file containing X.509 certificates.
+  <li>a raw resource ID pointing to a file containing X.509 certificates.
   Certificates must be encoded in DER or PEM format. In the case of PEM
-  certificates the file <em>must not</em> contain extra non-PEM data such as
+  certificates, the file <em>must not</em> contain extra non-PEM data such as
   comments.
   </li>
 
@@ -647,9 +650,9 @@
 <dd>
   <p>
     Specifies if the CAs from this source bypass certificate pinning. If {@code
-    "true"} then certificate chains which chain through one of the CAs from this
-    source then pinning is not be performed. This can be useful for debug CAs
-    or to support letting the user MiTM your app's secure traffic.
+    "true"}, then pinning is not performed on certificate chains which are
+    signed by one of the CAs from this source. This can be useful for debugging
+    CAs or for testing man-in-the-middle attacks on your app's secure traffic.
   </p>
 
   <p>
@@ -705,13 +708,12 @@
       </dt>
 
       <dd>
-        The date, in {@code yyyy-MM-dd} format, at and after which the pins
-        expire, thus disabling pinning. If the attribute is not set then the
-        pins do not expire.
+        The date, in {@code yyyy-MM-dd} format, on which the pins expire, thus
+        disabling pinning. If the attribute is not set, then the pins do not
+        expire.
         <p>
-          Expiration helps prevent connectivity issues in apps which do
-          not get updates to their pin set, for example because the user
-          disabled app updates.
+          Expiration helps prevent connectivity issues in apps which do not get
+          updates to their pin set, such as when the user disables app updates.
         </p>
       </dd>
     </dl>
@@ -742,7 +744,7 @@
       </dt>
 
       <dd>
-        The digest algorithm used to generate the pin. Currently only
+        The digest algorithm used to generate the pin. Currently, only
         {@code "SHA-256"} is supported.
       </dd>
     </dl>
diff --git a/docs/html/preview/features/key-attestation.jd b/docs/html/training/articles/security-key-attestation.jd
similarity index 92%
rename from docs/html/preview/features/key-attestation.jd
rename to docs/html/training/articles/security-key-attestation.jd
index 5be6dfa..9145d30 100644
--- a/docs/html/preview/features/key-attestation.jd
+++ b/docs/html/training/articles/security-key-attestation.jd
@@ -1,11 +1,11 @@
 page.title=Key Attestation
-page.metaDescription=New support in Android N for verifying security properties of hardware-backed keys.
-page.keywords="android N", "security", "TEE", "hardware-backed", "keystore", "certificate", "key attestation"
+page.metaDescription=A tool for verifying security properties of hardware-backed key pairs.
+page.keywords="security", "TEE", "hardware-backed", "keystore", "certificate", "key attestation"
 
 @jd:body
 
-<div id="qv-wrapper">
-  <div id="qv">
+<div id="tb-wrapper">
+  <div id="tb">
     <h2>In this document</h2>
       <ol>
         <li><a href="#verifying">Retrieving and Verifying a Hardware-backed Key Pair</a></li>
@@ -22,14 +22,14 @@
 </p>
 
 <p class="note">
-  <strong>Note: </strong>Only a small number of devices running Android N
-  support hardware-level key attestation; all other devices running Android N
-  use software-level key attestation instead. Before you verify the properties
-  of a device's hardware-backed keys in a production-level environment, you
-  should make sure that the device supports hardware-level key attestation. To
-  do so, you should check that the attestation certificate chain contains a root
-  certificate that is signed by the Google attestation root key and that the
-  <code>attestationSecurityLevel</code> element within the <a
+  <strong>Note: </strong>Only a small number of devices running Android 7.0 (API
+  level 24) support hardware-level key attestation; all other devices running
+  Android 7.0 use software-level key attestation instead. Before you verify the
+  properties of a device's hardware-backed keys in a production-level
+  environment, you should make sure that the device supports hardware-level key
+  attestation. To do so, you should check that the attestation certificate chain
+  contains a root certificate that is signed by the Google attestation root key
+  and that the <code>attestationSecurityLevel</code> element within the <a
   href="#certificate_schema_keydescription">key description</a> data structure
   is set to the TrustedEnvironment security level.
 </p>
@@ -45,15 +45,17 @@
 </p>
 
 <p>
-  The root certificate within this chain is signed using an attestation key,
-  which the device manufacturer injects into the device’s hardware-backed
-  keystore at the factory.
+  If the device supports hardware-level key attestation, the root certificate
+  within this chain is signed using an attestation root key, which the device
+  manufacturer injects into the device’s hardware-backed keystore at the
+  factory.
 </p>
 
 <p class="note">
-  <strong>Note:</strong> On devices that ship with Android N and Google Play
-  services, the root certificate is issued by Google. You should verify that
-  this root certificate appears within Google’s list of root certificates.
+  <strong>Note:</strong> On devices that ship with hardware-level key
+  attestation, Android 7.0 (API level 24), and Google Play services, the root
+  certificate is signed by the Google attestation root key. You should verify
+  that this root certificate appears within Google’s list of root certificates.
 </p>
 
 <p>
@@ -231,7 +233,7 @@
   </dd>
 
   <dt>
-    <code>attestationSecurity</code>
+    <code>attestationSecurityLevel</code>
   </dt>
 
   <dd>
@@ -242,8 +244,8 @@
 
     <p class="caution">
       <strong>Warning:</strong> Although it is possible to attest keys that are
-      stored in the Android system&mdash;that is, if the
-      <code>attestationSecurity</code> value is set to Software&mdash;you
+      stored in the Android system&mdash;that is, if the value of
+      <code>attestationSecurityLevel</code> is set to Software&mdash;you
       cannot trust these attestations if the Android system becomes compromised.
     </p>
   </dd>
@@ -259,7 +261,7 @@
   </dd>
 
   <dt>
-    <code>keymasterSecurity</code>
+    <code>keymasterSecurityLevel</code>
   </dt>
 
   <dd>
@@ -357,7 +359,8 @@
 <p>
   Each field name corresponds to a similarly-named Keymaster tag. For example,
   the <code>keySize</code> field in an authorization list corresponds to the
-  <code>KM_TAG_KEY_SIZE</code> Keymaster tag.
+  <a href="https://source.android.com/security/keystore/implementer-ref.html#km_tag_key_size">
+  <code>KM_TAG_KEY_SIZE</code></a> Keymaster tag.
 </p>
 
 <p>
@@ -780,7 +783,7 @@
   <dd>
     The month and year associated with the security patch that is currently
     installed on the device, specified as a six-digit integer. For example, the
-    June 2016 patch is represented as 201606.
+    August 2016 patch is represented as 201608.
   </dd>
 </dl>
 
diff --git a/docs/html/training/auto/testing/index.jd b/docs/html/training/auto/testing/index.jd
index c93012f..e3e2d86 100644
--- a/docs/html/training/auto/testing/index.jd
+++ b/docs/html/training/auto/testing/index.jd
@@ -523,7 +523,7 @@
 
 <ol>
 <li>Install the Android Media Browser simulator
-({@code &lt;sdk&gt;/extras/google/simulators/media-browser-simulator.apk}) on
+({@code <sdk>/extras/google/simulators/media-browser-simulator.apk}) on
 the test device. You can do this using
 the <a href="{@docRoot}tools/help/adb.html#move">adb</a> command line tool.</li>
 <li>Enable <a href="{@docRoot}tools/device.html#developer-device-options">
@@ -540,7 +540,7 @@
 
 <ol>
 <li>Install the Android Messaging simulator
-  ({@code &lt;sdk&gt;/extras/google/simulators/messaging-simulator.apk})
+  ({@code <sdk>/extras/google/simulators/messaging-simulator.apk})
 on the test device. You can do this using the
 <a href="{@docRoot}tools/help/adb.html#move">adb</a> command line tool.</li>
 <li>Enable the simulator to read notifications posted on the system:
diff --git a/docs/html/training/backup/autosyncapi.jd b/docs/html/training/backup/autosyncapi.jd
index 0e2a9a9..e0df7bb 100644
--- a/docs/html/training/backup/autosyncapi.jd
+++ b/docs/html/training/backup/autosyncapi.jd
@@ -257,7 +257,7 @@
 <a href="{@docRoot}guide/topics/manifest/application-element.html">app manifest</a>. If your app
 used this legacy approach, you can transition to full-data backups by adding the
 {@code android:fullBackupOnly="true"} attribute to the
-<a href="{@docRoot}guide/topics/manifest/application-element.html">{@code &lt;application/&gt;}</a>
+<a href="{@docRoot}guide/topics/manifest/application-element.html">{@code <application/>}</a>
 element in the manifest. When running on a device with Android 5.1
 (API level 22) or lower, your app ignores this value in the manifest, and continues performing
 backups in the previous manner.</p>
@@ -349,7 +349,7 @@
 <pre>$ adb shell bmgr wipe &lt;TRANSPORT&gt; &lt;PACKAGE&gt;</pre>
 
 <p>
-  You must prepend <code>com.google.android.gms</code> to the {@code &lt;TRANSPORT&gt;} value.
+  You must prepend <code>com.google.android.gms</code> to the {@code <TRANSPORT>} value.
   To get the list of <a href="{@docRoot}google/backup/index.html">transports</a>, execute the
   following command:
 </p>
diff --git a/docs/html/training/basics/firstapp/building-ui.jd b/docs/html/training/basics/firstapp/building-ui.jd
index 275500c..a680c73 100644
--- a/docs/html/training/basics/firstapp/building-ui.jd
+++ b/docs/html/training/basics/firstapp/building-ui.jd
@@ -71,38 +71,31 @@
 <h2 id="LinearLayout">Create a Linear Layout</h2>
 
 <ol>
-<li>In Android Studio, from the <code>res/layout</code> directory, open the {@code content_my.xml}
-file.
-<p>The BlankActivity template you chose when you created this project includes the
-<code>content_my.xml</code> file with a {@link android.widget.RelativeLayout} root view and a
-{@link android.widget.TextView} child view.</p>
-</li>
-<li>In the <strong>Preview</strong> pane, click the Hide icon <img src="{@docRoot}images/tools/as-hide-side.png"
-  style="vertical-align:baseline;margin:0; max-height:1.5em" /> to close the Preview pane.
-  <p> In Android Studio, when you open a layout file, you’re first shown
-    the Preview pane. Clicking elements in this pane opens the WYSIWYG tools in the Design pane. For
-    this lesson, you’re going to work directly with the XML.</p></li>
-<li>Delete the {@link android.widget.TextView &lt;TextView>} element.</li>
-<li>Change the {@link android.widget.RelativeLayout &lt;RelativeLayout>} element to
-{@link android.widget.LinearLayout &lt;LinearLayout>}.</li>
-<li>Add the <a href="{@docRoot}reference/android/widget/LinearLayout.html#attr_android:orientation">
-{@code android:orientation}</a> attribute and set it to <code>"horizontal"</code>.</li>
-<li>Remove the {@code android:padding} attributes and the {@code tools:context} attribute.
-</ol>
-
-<p>The result looks like this:</p>
-
-<pre>
-&lt;LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
-    xmlns:app="http://schemas.android.com/apk/res-auto"
+  <li>From the <code>res/layout/</code> directory, open the
+    <code>activity_main.xml</code> file.
+    <p>This XML file defines the layout of your activity. It contains the
+      default "Hello World" text view.</p>
+  </li>
+  <li>When you open a layout file, you’re first shown the design editor in the
+    <a href="/studio/write/layout-editor.html">Layout Editor</a>. For this lesson,
+    you work directly with the XML, so click the <b>Text</b> tab to switch to
+    the text editor.
+  </li>
+  <li>Replace the contents of the file with the following XML:
+    <pre>&lt;?xml version="1.0" encoding="utf-8"?&gt;
+&lt;LinearLayout
+    xmlns:android="http://schemas.android.com/apk/res/android"
     xmlns:tools="http://schemas.android.com/tools"
-    android:orientation="horizontal"
     android:layout_width="match_parent"
     android:layout_height="match_parent"
-    app:layout_behavior="@string/appbar_scrolling_view_behavior"
-    tools:showIn="@layout/activity_my"&gt;
+    android:orientation="horizontal"&gt;
+&lt;/LinearLayout&gt;
 </pre>
 
+  </li>
+
+</ol>
+
 <p>{@link android.widget.LinearLayout} is a view group (a subclass of {@link
 android.view.ViewGroup}) that lays out child views in either a vertical or horizontal orientation,
 as specified by the <a
@@ -128,29 +121,25 @@
 
 <h2 id="TextInput">Add a Text Field</h2>
 
-<p>As with every {@link android.view.View} object, you must define certain XML attributes to specify
-the {@link android.widget.EditText} object's properties.</p>
+<p>In the <code>activity_main.xml</code> file, within the
+{@link android.widget.LinearLayout &lt;LinearLayout>} element, add the following
+{@link android.widget.EditText &lt;EditText>} element:</p>
 
-<ol>
-<li>In the <code>content_my.xml</code> file, within the
-{@link android.widget.LinearLayout &lt;LinearLayout>} element, define an
-{@link android.widget.EditText &lt;EditText>} element with the <code>id</code> attribute
-set to <code>@+id/edit_message</code>.</li>
-<li>Define the <code>layout_width</code> and <code>layout_height</code> attributes as
-<code>wrap_content</code>.</li>
-<li>Define a <code>hint</code> attribute as a string object named <code>edit_message</code>.</li>
-</ol>
-
-<p>The {@link android.widget.EditText &lt;EditText>} element should read as follows:</p>
-
-<pre>
-&lt;EditText android:id="@+id/edit_message"
-    android:layout_width="wrap_content"
-    android:layout_height="wrap_content"
-    android:hint="@string/edit_message" />
+<pre>&lt;LinearLayout
+    xmlns:android="http://schemas.android.com/apk/res/android"
+    xmlns:tools="http://schemas.android.com/tools"
+    android:layout_width="match_parent"
+    android:layout_height="match_parent"
+    android:orientation="horizontal"&gt;
+    <b>&lt;EditText android:id="@+id/edit_message"
+        android:layout_width="wrap_content"
+        android:layout_height="wrap_content"
+        android:hint="@string/edit_message" /></b>
+&lt;/LinearLayout&gt;
 </pre>
 
-<p>Here are the {@link android.widget.EditText &lt;EditText>} attributes you added:</p>
+<p>Here is a description of the attributes in the
+  {@link android.widget.EditText &lt;EditText>} you added:</p>
 
 <dl>
 <dt><a href="{@docRoot}reference/android/view/View.html#attr_android:id">{@code android:id}</a></dt>
@@ -222,29 +211,20 @@
 <h2 id="Strings">Add String Resources</h2>
 
 <p>By default, your Android project includes a string resource file at
-<code>res/values/strings.xml</code>. Here, you'll add a new string named
-<code>"edit_message"</code> and set the value to "Enter a message."</p>
+<code>res/values/strings.xml</code>. Here, you'll add two new strings.</p>
 
 <ol>
-<li>In Android Studio, from the <code>res/values</code> directory, open <code>strings.xml</code>.</li>
-<li>Add a line for a string named <code>"edit_message"</code> with the value, "Enter a message".
-</li>
-<li>Add a line for a string named <code>"button_send"</code> with the value, "Send".
-<p>You'll create the button that uses this string in the next section.</p>
-</li>
-</ol>
-
-<p>The result for <code>strings.xml</code> looks like this:</p>
-
-<pre>
-&lt;?xml version="1.0" encoding="utf-8"?>
+<li>From the <code>res/values/</code> directory, open <code>strings.xml</code>.</li>
+<li>Add two strings so that your file looks like this:
+<pre>&lt;?xml version="1.0" encoding="utf-8"?>
 &lt;resources>
     &lt;string name="app_name">My First App&lt;/string>
-    &lt;string name="edit_message">Enter a message&lt;/string>
-    &lt;string name="button_send">Send&lt;/string>
-    &lt;string name="action_settings">Settings&lt;/string>
+    <b>&lt;string name="edit_message">Enter a message&lt;/string>
+    &lt;string name="button_send">Send&lt;/string></b>
 &lt;/resources>
 </pre>
+</li>
+</ol>
 
 <p>For text in the user interface, always specify each string as
 a resource. String resources allow you to manage all UI text in a single location,
@@ -260,40 +240,22 @@
 
 <h2 id="Button">Add a Button</h2>
 
-<ol>
-<li>In Android Studio, from the <code>res/layout</code> directory, edit the <code>content_my.xml</code>
-file.</li>
-<li>Within the
-{@link android.widget.LinearLayout &lt;LinearLayout>} element, define a
-{@link android.widget.Button &lt;Button>} element immediately following the
-{@link android.widget.EditText &lt;EditText>} element.</li>
-<li>Set the button's width and height attributes to <code>"wrap_content"</code> so
-the button is only as big as necessary to fit the button's text label.</li>
-<li>Define the button's text label with the <a
-href="{@docRoot}reference/android/widget/TextView.html#attr_android:text">{@code
-android:text}</a> attribute; set its value to the <code>button_send</code> string
-resource you defined in the previous section.</li>
-</ol>
-
-<p>Your {@link android.widget.LinearLayout &lt;LinearLayout>} should look like this:</p>
-
-<pre>
-&lt;LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
-    xmlns:app="http://schemas.android.com/apk/res-auto"
+<p>Go back to the <code>activity_main.xml</code> file and add a button after the
+  {@link android.widget.EditText &lt;EditText>}. Your file should look like this:</p>
+<pre>&lt;LinearLayout
+    xmlns:android="http://schemas.android.com/apk/res/android"
     xmlns:tools="http://schemas.android.com/tools"
     android:orientation="horizontal"
     android:layout_width="match_parent"
-    android:layout_height="match_parent"
-    app:layout_behavior="@string/appbar_scrolling_view_behavior"
-    tools:showIn="@layout/activity_my"&gt;
+    android:layout_height="match_parent"&gt;
         &lt;EditText android:id="@+id/edit_message"
           android:layout_width="wrap_content"
           android:layout_height="wrap_content"
           android:hint="@string/edit_message" /&gt;
-        &lt;Button
+        <b>&lt;Button
           android:layout_width="wrap_content"
           android:layout_height="wrap_content"
-          android:text="@string/button_send" /&gt;
+          android:text="@string/button_send" /&gt;</b>
 &lt;/LinearLayout&gt;
 </pre>
 
@@ -302,7 +264,7 @@
 attribute, because it won't be referenced from the activity code.</p>
 
 <p>The layout is currently designed so that both the {@link android.widget.EditText} and {@link
-android.widget.Button} widgets are only as big as necessary to fit their content, as Figure 2 shows.
+android.widget.Button} widgets are only as big as necessary to fit their content, as figure 2 shows.
 </p>
 
 <img src="{@docRoot}images/training/firstapp/edittext_wrap.png" />
@@ -334,53 +296,36 @@
 
 <h2 id="Weight">Make the Input Box Fill in the Screen Width</h2>
 
-<p>To fill the remaining space in your layout with the {@link android.widget.EditText} element, do
-the following:</p>
-
-<ol>
-<li>In the <code>content_my.xml</code> file, assign the
-{@link android.widget.EditText &lt;EditText>} element's <code>layout_weight</code> attribute a value
-of <code>1</code>.</li>
-<li>Also, assign {@link android.widget.EditText &lt;EditText>} element's <code>layout_width</code>
-attribute a value of <code>0dp</code>.
+<p>In <code>activity_main.xml</code>, modify the
+  {@link android.widget.EditText &lt;EditText>} so that the attributes look like
+  this:</p>
 
 <pre>
-&lt;EditText
-    android:layout_weight="1"
-    android:layout_width="0dp"
-    ... /&gt;
+&lt;EditText android:id="@+id/edit_message"
+    <b>android:layout_weight="1"
+    android:layout_width="0dp"</b>
+    android:layout_height="wrap_content"
+    android:hint="@string/edit_message" /&gt;
 </pre>
 
-<p>To improve the layout efficiency when you specify the weight, you should change the
-width of the {@link android.widget.EditText} to be
-zero (0dp). Setting the width to zero improves layout performance because using
+<p>Setting the width to zero (0dp) improves layout performance because using
 <code>"wrap_content"</code> as the width requires the system to calculate a width that is
 ultimately irrelevant because the weight value requires another width calculation to fill the
 remaining space.</p>
 
-<p>Figure 3
-shows the result when you assign all weight to the {@link android.widget.EditText} element.</p>
-
 <img src="{@docRoot}images/training/firstapp/edittext_gravity.png" />
 <p class="img-caption"><strong>Figure 3.</strong> The {@link android.widget.EditText} widget is
 given all the layout weight, so it fills the remaining space in the {@link
 android.widget.LinearLayout}.</p>
 
-</li>
-</ol>
+<p>Here’s how your complete <code>activity_main.xml</code>layout file should now look:</p>
 
-<p>Here’s how your complete <code>content_my.xml</code>layout file should now look:</p>
-
-<pre>
-&lt;?xml version="1.0" encoding="utf-8"?>
+<pre>&lt;?xml version="1.0" encoding="utf-8"?&gt;
 &lt;LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
-   xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:orientation="horizontal"
    android:layout_width="match_parent"
-   android:layout_height="match_parent"
-   app:layout_behavior="@string/appbar_scrolling_view_behavior"
-   tools:showIn="@layout/activity_my"&gt;
+   android:layout_height="match_parent"&gt;
     &lt;EditText android:id="@+id/edit_message"
         android:layout_weight="1"
         android:layout_width="0dp"
@@ -406,7 +351,4 @@
 
 <p>Continue to the <a href="starting-activity.html">next
 lesson</a> to learn how to respond to button presses, read content
-from the text field, start another activity, and more.</p>
-
-
-
+from the text field, start another activity, and more.</p>
\ No newline at end of file
diff --git a/docs/html/training/basics/firstapp/creating-project.jd b/docs/html/training/basics/firstapp/creating-project.jd
index 4c2155b..cad32bf 100644
--- a/docs/html/training/basics/firstapp/creating-project.jd
+++ b/docs/html/training/basics/firstapp/creating-project.jd
@@ -14,36 +14,19 @@
 <div id="tb-wrapper">
 <div id="tb">
 
-<h2>This lesson teaches you to</h2>
-
-<ol>
-  <li><a href="#Studio">Create a Project with Android Studio</a></li>
-</ol>
-
 <h2>You should also read</h2>
 
 <ul>
-  <li><a href="{@docRoot}tools/projects/index.html">Managing Projects</a></li>
+  <li><a href="{@docRoot}studio/projects/index.html">Projects Overview</a></li>
 </ul>
 
 
 </div>
 </div>
 
-<p>An Android project contains all the files that comprise the source code for your Android
-app.</p>
-
-<p>This lesson
-shows how to create a new project either using Android Studio or using the
-SDK tools from a command line.</p>
-
-<p class="note"><strong>Note:</strong> You should already have Android Studio or the Android SDK
-command-line tools installed. If not, <a
-href="{@docRoot}studio/index.html">download them</a> before you start this
-lesson.</p>
-
-
-<h2 id="Studio">Create a Project with Android Studio</h2>
+<p>This lesson shows you how to create a new Android project with
+  <a href="{@docRoot}studio/index.html">Android Studio</a> and describes some
+  of the files in the project.</p>
 
 <ol>
   <li>In Android Studio, create a new project:
@@ -54,11 +37,12 @@
         Project</strong>. The <em>Create New Project</em> screen appears.</li>
     </ul>
   </li>
-  <li>Fill out the fields on the screen, and click <strong>Next</strong>.
-    <p>It is easier to follow these lessons if you use the same values as shown.</p>
+  <li>Fill out the fields on the screen. For <strong>Application Name</strong>
+    use "My First App". For <strong>Company Domain</strong>, use "example.com".
+    For the other fields, use the default values and click <strong>Next</strong>
+    <p>Here's a brief explanation of each field:</p>
     <ul>
-      <li><strong>Application Name</strong> is the app name that appears to users.
-          For this project, use "My First App."</li>
+      <li><strong>Application Name</strong> is the app name that appears to users.</li>
       <li><strong>Company domain</strong> provides a qualifier that will be appended to the package
         name; Android Studio will remember this qualifier for each new project you create.</li>
       <li><strong>Package name</strong> is the fully qualified name for the project (following the
@@ -70,9 +54,8 @@
         files.</li>
     </ul>
   </li>
-  <li>Under <strong>Select the form factors your app will run on</strong>, check the box for <strong>
-    Phone and Tablet</strong>.</li>
-  <li>For <strong>Minimum SDK</strong>, select <strong>API 8: Android 2.2 (Froyo)</strong>.
+  <li>Under <strong>Target Android Devices</strong>, accept the default values
+    and click <strong>Next</strong>.
     <p>The Minimum Required SDK is the earliest version of Android that your app supports,
       indicated using the <a href="{@docRoot}guide/topics/manifest/uses-sdk-element.html#ApiLevels">
       API level</a>. To support as many devices as possible, you should set this to the lowest
@@ -80,8 +63,13 @@
       app is possible only on newer versions of Android and it's not critical to the app's core
       feature set, you can enable the feature only when running on the versions that support it (as
       discussed in <a href="{@docRoot}training/basics/supporting-devices/platforms.html">
-      Supporting Different Platform Versions</a>).</p></li>
-  <li>Leave all of the other options (TV, Wear, and Glass) unchecked and click <strong>Next.</strong></li>
+      Supporting Different Platform Versions</a>).</p>
+    </li>
+
+  <li>Under <strong>Add an Activity to Mobile</strong>, select <strong>Empty
+    Activity</strong> and click <strong>Next</strong>.
+  </li>
+
   <div class="sidebox-wrapper">
     <div class="sidebox">
       <h3>Activities</h3>
@@ -93,43 +81,25 @@
         Activities</a> for more information.</p>
     </div>
   </div>
-  <li>Under <strong>Add an activity to &lt;<em>template</em>&gt;</strong>,
-  select <strong>Basic Activity</strong> and click <strong>Next</strong>.
-  </li>
 
-  <li>Under <strong>Customize the Activity</strong>, change the
-  <strong>Activity Name</strong> to <em>MyActivity</em>. The <strong>Layout
-  Name</strong> changes to <em>activity_my</em>, and the <strong>Title</strong>
-  to <em>MyActivity</em>. The <strong>Menu Resource Name</strong> is
-  <em>menu_my</em>.
-  </li>
-
-  <li>Click the <strong>Finish</strong> button to create the project.
-  </li>
+  <li>Under <strong>Customize the Activity</strong>, accept the default values
+    and click <strong>Finish</strong>.
 </ol>
 
 <p>Your Android project is now a basic "Hello World" app that contains some default files. Take a
 moment to review the most important of these:</p>
 
 <dl>
-  <dt><code>app/src/main/res/layout/activity_my.xml</code></dt>
-  <dd>This XML layout file is for the activity you added when you created the project
-  with Android Studio. Following the New Project workflow, Android Studio presents this file
-  with both a text
-    view and a preview of the screen UI. The file contains some default interface elements
-    from the material design library, including the
-    <a href="{@docRoot}training/appbar/index.html">app bar</a> and a floating action button.
-    It also includes a separate layout file with the main content.</dd>
+  <dt><code>app/src/main/java/com.example.myfirstapp/MainActivity.java</code></dt>
+  <dd>This file appears in Android Studio after the New Project wizard finishes.
+    It contains the class definition for the activity you created earlier. When you build
+    and run the app, the {@link android.app.Activity} starts and loads the
+    layout file that says "Hello World!"</dd>
 
-  <dt><code>app/src/main/res/layout/content_my.xml</code></dt>
-  <dd>This XML layout file resides in {@code activity_my.xml}, and contains some settings and
-  a {@code TextView} element that displays the message, "Hello world!".</dd>
+  <dt><code>app/src/main/res/layout/activity_main.xml</code></dt>
+  <dd>This XML file defines the layout of the activity. It contains a {@code TextView}
+    element with the text "Hello world!".</dd>
 
-  <dt><code>app/src/main/java/com.mycompany.myfirstapp/MyActivity.java</code></dt>
-  <dd>A tab for this file appears in Android Studio when the New Project workflow finishes. When you
-    select the file you see the class definition for the activity you created. When you build and
-    run the app, the {@link android.app.Activity} class starts the activity and loads the layout file
-    that says "Hello World!"</dd>
   <dt><code>app/src/main/AndroidManifest.xml</code></dt>
   <dd>The <a href="{@docRoot}guide/topics/manifest/manifest-intro.html">manifest file</a> describes
     the fundamental characteristics of the app and defines each of its components. You'll revisit
@@ -143,15 +113,15 @@
     <ul>
       <li><code>compiledSdkVersion</code> is the platform version against which you will compile
         your app. By default, this is set to the latest version of Android available in your SDK.
-        (It should be Android 4.1 or greater; if you don't have such a version available, you must
-        install one using the <a href="{@docRoot}studio/intro/update.html">SDK Manager</a>.)
+        By default, this is set to the latest version of Android SDK installed on your
+        development machine.
         You can still build your app to support older versions, but setting this to the latest
         version allows you to enable new features and optimize your app for a great user experience
         on the latest devices.</li>
       <li><code>applicationId</code> is the fully qualified package name for your application that
-        you specified during the New Project workflow.</li>
+        you specified in the New Project wizard.</li>
       <li><code>minSdkVersion</code> is the Minimum SDK version you specified during the New Project
-        workflow. This is the earliest version of the Android SDK that your app supports.</li>
+        wizard. This is the earliest version of the Android SDK that your app supports.</li>
       <li><code>targetSdkVersion</code> indicates the highest version of Android with which you have
         tested your application. As new versions of Android become available, you should
         test your app on the new version and update this value to match the latest API level and
@@ -172,8 +142,8 @@
     for various <a href="{@docRoot}training/multiscreen/screendensities.html">densities</a>.
 </dd>
   <dt><code>layout/</code></dt>
-    <dd>Directory for files that define your app's user interface like {@code activity_my.xml},
-      discussed above, which describes a basic layout for the {@code MyActivity}
+    <dd>Directory for files that define your app's user interface like {@code activity_main.xml},
+      discussed above, which describes a basic layout for the {@code MainActivity}
       class.</dd>
   <dt><code>menu/</code></dt>
     <dd>Directory for files that define your app's menu items.</dd>
diff --git a/docs/html/training/basics/firstapp/index.jd b/docs/html/training/basics/firstapp/index.jd
index cb5073f..48b7190 100644
--- a/docs/html/training/basics/firstapp/index.jd
+++ b/docs/html/training/basics/firstapp/index.jd
@@ -23,25 +23,10 @@
 
 <p>Welcome to Android application development!</p>
 
-<p>This class teaches you how to build your first Android app. You’ll learn how to create an Android
-project and run a debuggable version of the app. You'll also learn some fundamentals of Android app
-design, including how to build a simple user interface and handle user input.</p>
+<p>This class teaches you how to build your first Android app. You’ll learn how
+  to create an Android project with Android Studio and run a debuggable version
+  of the app. You'll also learn some fundamentals of Android app design,
+  including how to build a simple user interface and handle user input.</p>
 
-<h2>Set Up Your Environment</h2>
-
-<p>Before you start this class, be sure you have your development environment set up. You need
-to:</p>
-<ol>
-  <li>Download <a href="{@docRoot}studio/index.html">Android Studio</a>.</li>
-  <li>Download the latest SDK tools and platforms using the
-  <a href="{@docRoot}tools/help/sdk-manager.html">SDK Manager</a>.</li>
-</ol>
-
-<p class="note"><strong>Note:</strong> Although most of this training class
-expects that you're using Android Studio, some procedures include alternative
-instructions for using
-the SDK tools from the command line instead.</p>
-
-<p>This class uses a tutorial format to create a small Android app that teaches
-you some fundamental concepts about Android development, so it's important that you follow each
-step.</p>
+<p>Before you start this class, download and install
+  <a href="{@docRoot}studio/index.html">Android Studio</a>.</p>
\ No newline at end of file
diff --git a/docs/html/training/basics/firstapp/running-app.jd b/docs/html/training/basics/firstapp/running-app.jd
index 21fb64d..e809871 100755
--- a/docs/html/training/basics/firstapp/running-app.jd
+++ b/docs/html/training/basics/firstapp/running-app.jd
@@ -26,7 +26,6 @@
 <ul>
   <li><a href="{@docRoot}tools/device.html">Using Hardware Devices</a></li>
   <li><a href="{@docRoot}tools/devices/managing-avds.html">Managing AVDs with AVD Manager</a></li>
-  <li><a href="{@docRoot}tools/projects/index.html">Managing Projects</a></li>
 </ul>
 
 
@@ -34,27 +33,20 @@
 </div>
 
 
-<p>If you followed the <a href="creating-project.html">previous lesson</a> to create an
-Android project, it includes a default set of "Hello World" source files that allow you to
-immediately run the app.</p>
-
-<p>How you run your app depends on two things: whether you have a real device running Android and
-whether you're using Android Studio. This lesson shows you how to install and run your app on a
-real device and on the Android emulator, and in both cases with either Android Studio or the command
-line tools.</p>
+<p>In the <a href="creating-project.html">previous lesson</a>, you created an
+  Android project. The project contains a default app that displays
+  "Hello World". In this lesson, you will run the app on a device or emulator.</p>
 
 <h2 id="RealDevice">Run on a Real Device</h2>
 
-<p>If you have a device running Android, here's how to install and run your app.</p>
-
-<h3>Set up your device</h3>
+<p>Set up your device as follows:</p>
 
 <ol>
-  <li>Plug in your device to your development machine with a USB cable.
+  <li>Connect your device to your development machine with a USB cable.
     If you're developing on Windows, you might need to install the appropriate USB driver for your
-    device. For help installing drivers, see the <a href="{@docRoot}tools/extras/oem-usb.html">OEM
+    device. For help installing drivers, see the <a href="{@docRoot}studio/run/oem-usb.html">OEM
     USB Drivers</a> document.</li>
-  <li>Enable <strong>USB debugging</strong> on your device. On Android 4.0 and newer, go to
+  <li>Enable <strong>USB debugging</strong> on your device by going to
     <strong>Settings > Developer options</strong>.
         <p class="note"><strong>Note:</strong> On Android 4.2 and newer, <strong>Developer
         options</strong> is hidden by default. To make it available, go
@@ -63,73 +55,61 @@
   </li>
 </ol>
 
-<h3>Run the app from Android Studio</h3>
+<p>Run the app from Android Studio as follows:</p>
+
 <ol>
-  <li>Select one of your project's files and click
-<strong>Run</strong> <img
-src="{@docRoot}images/tools/as-run.png" style="vertical-align:baseline;margin:0; max-height:1em" />
-from the toolbar.</li>
-  <li>In the <strong>Choose Device</strong> window that appears, select the
-  <strong>Choose a running device</strong> radio button, select your device, and click <strong>OK
-  </strong>.</li>
+  <li>In Android Studio, select your project and click
+    <strong>Run</strong> <img src="{@docRoot}images/tools/as-run.png"
+    style="vertical-align:baseline;margin:0; max-height:1em" />
+    from the toolbar.</li>
+  <li>In the <strong>Select Deployment Target</strong> window,
+    select your device, and click <strong>OK</strong>.</li>
 </ol>
 <p>Android Studio installs the app on your connected device and starts it.</p>
 
 
 <h2 id="Emulator">Run on the Emulator</h2>
 
-<p>Whether you're using Android Studio or the command line, to run your app on the emulator you need
-to first create an <a href="{@docRoot}tools/devices/index.html">Android Virtual Device</a> (AVD). An
-AVD is a device configuration for the Android emulator that allows you to model a specific
-device.</p>
+<p>Before you run your app on an emulator, you need to create an
+  <a href="{@docRoot}tools/devices/index.html">Android Virtual Device</a> (AVD)
+  definition. An AVD definition defines the characteristics of an Android phone,
+  tablet, Android Wear, or Android TV device that you want to simulate in the
+  Android Emulator.</p>
 
-
-<h3>Create an AVD</h3>
+<p>Create an AVD Definition as follows:</p>
 <ol>
-  <li>Launch the Android Virtual Device Manager:
-    <ul>
-      <li>In Android Studio, select <strong>Tools &gt; Android &gt; AVD Manager</strong>, or click
-  the AVD Manager icon <img src="{@docRoot}images/tools/avd-manager-studio.png"
-  style="vertical-align:bottom;margin:0;height:19px"> in the toolbar. The
-  <em>AVD Manager</em> screen appears.</li>
-      <li>Or, from the command line, change directories to
-      <code>sdk/</code> and execute:
-        <pre class="no-pretty-print">tools/android avd</pre>
-        <p class="note"><strong>Note:</strong> The AVD Manager that appears
-        when launched from the command line is different from the version in
-        Android Studio, so the following instructions may not all apply.</p>
-        </li>
-    </ul>
-
-  </li>
+  <li>Launch the Android Virtual Device Manager by selecting
+    <strong>Tools &gt; Android &gt; AVD Manager</strong>, or by clicking
+    the AVD Manager icon <img src="{@docRoot}images/tools/avd-manager-studio.png"
+    style="vertical-align:bottom;margin:0;height:19px"> in the toolbar.</li>
   <li>On the AVD Manager main screen, click <strong>Create Virtual Device</strong>.</li>
-  <li>In the Select Hardware window, select a device configuration, such as Nexus 6,
-  then click <strong>Next</strong>.
+  <li>In the Select Hardware page, select a phone device, such as Nexus 6,
+    then click <strong>Next</strong>.
   </li>
-  <li>Select the desired system version for the AVD and click <strong>Next</strong>.
+  <li>In the Select Image page, choose the desired system image for the AVD and
+    click <strong>Next</strong>.
   </li>
-  <li>Verify the configuration settings, then click <strong>Finish</strong>.
+  <li>Verify the configuration settings (for your first AVD, leave all the
+    settings as they are), and then click <strong>Finish</strong>.
   </li>
 </ol>
 
 <p>For more information about using AVDs, see
-<a href="{@docRoot}tools/devices/managing-avds.html">Managing AVDs with AVD Manager</a>.</p>
+<a href="{@docRoot}studio/run/managing-avds.html">Create and Manage Virtual Devices</a>.</p>
 
-<h3>Run the app from Android Studio</h3>
+<p>Run the app from Android Studio as follows:</p>
 <ol>
-  <li>In <strong>Android Studio</strong>, select your project and click <strong>Run</strong>
-    <img src="{@docRoot}images/tools/as-run.png" style="vertical-align:baseline;margin:0; max-height:1em" /> from the toolbar.</li>
-  <li>In the <strong>Choose Device</strong> window, click the <strong>Launch emulator</strong> radio
-    button.</li>
-  <li>From the <strong>Android virtual device</strong> pull-down menu, select the emulator
-    you created, and click <strong>OK</strong>.</li>
+  <li>In <strong>Android Studio</strong>, select your project and click
+    <strong>Run</strong> <img src="{@docRoot}images/tools/as-run.png"
+    style="vertical-align:baseline;margin:0; max-height:1em" />
+    from the toolbar.</li>
+  <li>In the <strong>Select Deployment Target</strong> window,
+    select your emulator and click <strong>OK</strong>.</li>
 </ol>
-<p>It can take a few minutes for the emulator to load itself. You may have to unlock the screen.
+<p>It can take a few minutes for the emulator to start. You may have to unlock the screen.
 When you do, <em>My First App</em> appears on the emulator screen.</p>
 
 
 <p>That's how you build and run your Android app on the emulator!
 To start developing, continue to the <a href="building-ui.html">next
-lesson</a>.</p>
-
-
+lesson</a>.</p>
\ No newline at end of file
diff --git a/docs/html/training/basics/firstapp/starting-activity.jd b/docs/html/training/basics/firstapp/starting-activity.jd
index e84e17e..ebf42cb 100644
--- a/docs/html/training/basics/firstapp/starting-activity.jd
+++ b/docs/html/training/basics/firstapp/starting-activity.jd
@@ -19,9 +19,7 @@
 <ol>
   <li><a href="#RespondToButton">Respond to the Send Button</a></li>
   <li><a href="#BuildIntent">Build an Intent</a></li>
-  <!-- <li><a href="#StartActivity">Start the Second Activity</a></li> -->
   <li><a href="#CreateActivity">Create the Second Activity</a></li>
-  <li><a href="#ReceiveIntent">Receive the Intent</a></li>
   <li><a href="#DisplayMessage">Display the Message</a></li>
 </ol>
 
@@ -33,55 +31,53 @@
 
 <p>After completing the <a href="building-ui.html">previous lesson</a>, you have an app that
 shows an activity (a single screen) with a text field and a button. In this lesson, you’ll add some
-code to <code>MyActivity</code> that
+code to <code>MainActivity</code> that
 starts a new activity when the user clicks the Send button.</p>
 
 
 <h2 id="RespondToButton">Respond to the Send Button</h2>
 
 <ol>
-<li>In Android Studio, from the <code>res/layout</code> directory, edit the <code>content_my.xml</code>
-file.</li>
-<li>Add the <a
-href="{@docRoot}reference/android/view/View.html#attr_android:onClick">{@code android:onClick}</a>
-attribute to the {@link android.widget.Button &lt;Button&gt;} element.
+  <li>In the file <code>res/layout/activity_main.xml</code>, add the
+    <a href="{@docRoot}reference/android/view/View.html#attr_android:onClick">{@code android:onClick}</a>
+    attribute to the {@link android.widget.Button &lt;Button&gt;} element as
+    shown below:
+    <pre>&lt;Button
+      android:layout_width="wrap_content"
+      android:layout_height="wrap_content"
+      android:text="@string/button_send"
+      <b>android:onClick="sendMessage"</b> />
+    </pre>
+    <p>This attribute tells the system to call the <code>sendMessage()</code>
+      method in your activity whenever a user clicks on the button.</p>
+  </li>
 
-<p class="code-caption">res/layout/content_my.xml</p>
-<pre>
-&lt;Button
-    android:layout_width="wrap_content"
-    android:layout_height="wrap_content"
-    android:text="@string/button_send"
-    android:onClick="sendMessage" />
-</pre>
+  <li>In the file <code>java/com.example.myfirstapp/MainActivity.java</code>,
+    add the <code>sendMessage()</code> method stub as shown below:
 
-<p>The <a
-href="{@docRoot}reference/android/view/View.html#attr_android:onClick">{@code
-android:onClick}</a> attribute’s value, <code>"sendMessage"</code>, is the name of a method in your
-activity that the system calls when the user clicks the button.</p>
-</li>
-<li>In the <code>java/com.mycompany.myfirstapp</code> directory, open the <code>MyActivity.java</code> file.</li>
-<li>Within the <code>MyActivity</code> class, add the {@code sendMessage()} method stub shown
-below.
+    <pre>public class MainActivity extends AppCompatActivity {
+    &#64;Override
+    protected void onCreate(Bundle savedInstanceState) {
+        super.onCreate(savedInstanceState);
+        setContentView(R.layout.activity_main);
+    }
 
-<p class="code-caption">java/com.mycompany.myfirstapp/MyActivity.java</p>
-<pre>
-/** Called when the user clicks the Send button */
-public void sendMessage(View view) {
-    // Do something in response to button
-}
-</pre>
+    <b>/** Called when the user clicks the Send button */
+    public void sendMessage(View view) {
+        // Do something in response to button
+    }</b>
+}</pre>
 
-<p>In order for the system to match this method to the method name given to <a
-href="{@docRoot}reference/android/view/View.html#attr_android:onClick">{@code android:onClick}</a>,
-the signature must be exactly as shown. Specifically, the method must:</p>
+    <p>In order for the system to match this method to the method name given to <a
+      href="{@docRoot}reference/android/view/View.html#attr_android:onClick">{@code android:onClick}</a>,
+      the signature must be exactly as shown. Specifically, the method must:</p>
 
-<ul>
-<li>Be public</li>
-<li>Have a void return value</li>
-<li>Have a {@link android.view.View} as the only parameter (this will be the {@link
-android.view.View} that was clicked)</li>
-</ul>
+    <ul>
+    <li>Be public</li>
+    <li>Have a void return value</li>
+    <li>Have a {@link android.view.View} as the only parameter (this will be the {@link
+    android.view.View} that was clicked)</li>
+    </ul>
 
 </li>
 </ol>
@@ -90,422 +86,147 @@
 another activity.</p>
 
 <h2 id="BuildIntent">Build an Intent</h2>
+<p>An {@link android.content.Intent} is an object that provides runtime binding
+  between separate components (such as two activities). The
+  {@link android.content.Intent} represents an app’s "intent to do something."
+  You can use intents for a wide variety of tasks, but in this lesson, your intent
+  starts another activity.</p>
 
-<ol>
-<li>In <code>MyActivity.java</code>, inside the {@code sendMessage()} method, create an
-{@link android.content.Intent} to start an activity called {@code DisplayMessageActivity} with the
-following code:
+<p>In <code>MainActivity.java</code>, add the code shown below to
+  <code>sendMessage()</code>:</p>
 
-<p class="code-caption">java/com.mycompany.myfirstapp/MyActivity.java</p>
-<pre>
-public void sendMessage(View view) {
-  Intent intent = new Intent(this, DisplayMessageActivity.class);
-}
-</pre>
-
-<div class="sidebox-wrapper">
-<div class="sidebox">
-<h3>Intents</h3>
-<p>An {@link android.content.Intent} is an object that provides runtime binding between separate
-components (such as two activities). The {@link android.content.Intent} represents an
-app’s "intent to do something." You can use intents for a wide
-variety of tasks, but most often they’re used to start another activity. For more information, see
-<a href="{@docRoot}guide/components/intents-filters.html ">Intents and Intent Filters</a>.</p>
-</div>
-</div>
-
-<p class="note"><strong>Note:</strong> The reference to {@code DisplayMessageActivity}
-will raise an error if you’re using an IDE such as Android Studio because the class doesn’t exist yet.
-Ignore the error for now; you’ll create the class soon.</p>
-
-<p>The constructor used here takes two parameters:</p>
-<ul>
-  <li>A {@link
-android.content.Context} as its first parameter ({@code this} is used because the {@link
-android.app.Activity} class is a subclass of {@link android.content.Context})
-  <li>The {@link java.lang.Class} of the app component to which the system should deliver
-the {@link android.content.Intent} (in this case, the activity that should be started)
-</ul>
-
-<p>Android Studio indicates that you must import the {@link android.content.Intent} class.</p>
-
-</li>
-<li>At the top of the file, import the {@link android.content.Intent} class:
-<p class="code-caption">java/com.mycompany.myfirstapp/MyActivity.java</p>
-<pre>
-import android.content.Intent;
-</pre>
-<p class="note"><strong>Tip:</strong> In Android Studio, press Alt + Enter (option + return on Mac)
-  to import missing classes.</p>
-</li>
-
-<!-- I didn't think this was necessary
-<div class="sidebox-wrapper">
-<div class="sidebox">
-  <h3>Sending an intent to other apps</h3>
-  <p>The intent created in this lesson is what's considered an <em>explicit intent</em>, because the
-{@link android.content.Intent}
-specifies the exact app component to which the intent should be given. However, intents
-can also be <em>implicit</em>, in which case the {@link android.content.Intent} does not specify
-the desired component, but allows any app installed on the device to respond to the intent
-as long as it satisfies the meta-data specifications for the action that's specified in various
-{@link android.content.Intent} parameters. For more information, see the class about <a
-href="{@docRoot}training/basics/intents/index.html">Interacting with Other Apps</a>.</p>
-</div>
-</div>
--->
-
-<li>Inside the {@code sendMessage()} method,
-use {@link android.app.Activity#findViewById findViewById()} to get the
-{@link android.widget.EditText} element.
-<p class="code-caption">java/com.mycompany.myfirstapp/MyActivity.java</p>
-<pre>
-public void sendMessage(View view) {
-  Intent intent = new Intent(this, DisplayMessageActivity.class);
-  EditText editText = (EditText) findViewById(R.id.edit_message);
-}
-</pre>
-</li>
-
-<li>At the top of the file, import the {@link android.widget.EditText} class.
-  <p>In Android Studio, press Alt + Enter (option + return on Mac) to import missing classes.</p>
-</li>
-
-<li>Assign the text to a local <code>message</code> variable, and use the
-{@link android.content.Intent#putExtra putExtra()} method to add its text value to the intent.
-<p class="code-caption">java/com.mycompany.myfirstapp/MyActivity.java</p>
-<pre>
-public void sendMessage(View view) {
-  Intent intent = new Intent(this, DisplayMessageActivity.class);
-  EditText editText = (EditText) findViewById(R.id.edit_message);
-  String message = editText.getText().toString();
-  intent.putExtra(EXTRA_MESSAGE, message);
-}
-</pre>
-
-<p>An {@link android.content.Intent} can carry data types as key-value
-pairs called <em>extras</em>. The {@link android.content.Intent#putExtra putExtra()} method takes the
-key name in the first parameter and the value in the second parameter.</p>
-
-</li>
-<li>At the top of the {@code MyActivity} class, add the {@code EXTRA_MESSAGE} definition as
-follows:
-<p class="code-caption">java/com.mycompany.myfirstapp/MyActivity.java</p>
-<pre>
-public class MyActivity extends AppCompatActivity {
-    public final static String EXTRA_MESSAGE = "com.mycompany.myfirstapp.MESSAGE";
-    ...
-}
-</pre>
-
-<p>For the next activity to query the extra data, you should define the key
-for your intent's extra using a public constant. It's generally a good practice to define keys for
-intent extras using your app's package name as a prefix. This ensures the keys are unique, in case
-your app interacts with other apps.</p>
-
-</li>
-
-<!-- <h2 id="StartActivity">Start the Second Activity</h2> -->
-
-<li>In the {@code sendMessage()} method, to finish the intent, call the
-{@link android.app.Activity#startActivity startActivity()} method, passing it the
-{@link android.content.Intent} object created in step 1.
-
-</ol>
-
-<p>With this new code, the complete {@code sendMessage()} method that's invoked by the Send
-button now looks like this:</p>
-<p class="code-caption">java/com.mycompany.myfirstapp/MyActivity.java</p>
-<pre>
-/** Called when the user clicks the Send button */
-public void sendMessage(View view) {
-    Intent intent = new Intent(this, DisplayMessageActivity.class);
-    EditText editText = (EditText) findViewById(R.id.edit_message);
-    String message = editText.getText().toString();
-    intent.putExtra(EXTRA_MESSAGE, message);
-    startActivity(intent);
-}
-</pre>
-
-<p>The system receives this call and starts an instance of the {@link android.app.Activity}
-specified by the {@link android.content.Intent}. Now you need to create the
-{@code DisplayMessageActivity} class in order for this to work.</p>
-
-</li>
-</ol>
-
-
-<h2 id="CreateActivity">Create the Second Activity</h2>
-
-<p>All subclasses of {@link android.app.Activity} must implement the
-{@link android.app.Activity#onCreate onCreate()} method. This method is where the activity receives
-the intent with the message, then renders the message. Also, the
-{@link android.app.Activity#onCreate onCreate()} method must define the activity
-layout with the {@link android.app.Activity#setContentView setContentView()} method. This is where
-the activity performs the initial setup of the activity components.</p>
-
-<h3>Create a new activity using Android Studio</h3>
-
-<p>Android Studio includes a stub for the
-{@link android.app.Activity#onCreate onCreate()} method when you create a new activity. The
-<em>New Android Activity</em> window appears.</p>
-
-<ol>
-  <li>In Android Studio, in the <code>java</code> directory, select the package,
-    <strong>com.mycompany.myfirstapp</strong>, right-click, and select
-    <strong>New > Activity > Blank Activity</strong>.</li>
-  <li>In the <strong>Choose options</strong> window, fill in the activity details:
-    <ul>
-      <li><strong>Activity Name</strong>: DisplayMessageActivity</li>
-      <li><strong>Layout Name</strong>: activity_display_message</li>
-      <li><strong>Title</strong>: My Message</li>
-      <li><strong>Hierarchical Parent</strong>: com.mycompany.myfirstapp.MyActivity</li>
-      <li><strong>Package name</strong>: com.mycompany.myfirstapp</li>
-    </ul>
-    <p>Click <strong>Finish</strong>.</p>
-  </li>
-
-<li>Open the {@code DisplayMessageActivity.java} file.
-
-<p>The class already includes an implementation of the required
-{@link android.app.Activity#onCreate onCreate()} method. You update the implementation of this
-method later.</p>
-
-<!-- Android Studio does not create a Fragment placeholder
-<p>Also, the file includes a <code>PlaceholderFragment</code> class that extends
-{@link android.app.Fragment}. This activity does not implement fragments, but you might use this
-later in the training. Fragments decompose application functionality and UI into reusable modules.
-For more information on fragments, see the
-<a href="{@docRoot}guide/components/fragments.html">Fragments API Guide</a> and follow the training,
-<a href="{@docRoot}training/basics/fragments/index.html">Building A Dynamic UI with Fragments</a>.
-</p>
--->
-</li>
-</ol>
-
-<!-- Not needed for Android Studio
-<p class="note"><strong>Note:</strong> Your activity may look different if you did not use
-the latest version of the ADT plugin. Make sure you install the latest version of the
-<a href="{@docRoot}tools/sdk/eclipse-adt.html">ADT plugin</a> to complete this tutorial.</p>
--->
-
-<p>If you're developing with Android Studio, you can run the app now, but not much happens.
-Clicking the Send button starts the second activity, but it uses
-a default "Hello world" layout provided by the template. You'll soon update the
-activity to instead display a custom text view.</p>
-
-
-<h3>Create the activity without Android Studio</h3>
-
-<p>If you're using a different IDE or the command line tools, do the following:</p>
-
-<ol>
-<li>Create a new file named {@code DisplayMessageActivity.java} in the project's <code>src/</code>
-directory, next to the original {@code MyActivity.java} file.</li>
-<li>Add the following code to the file:
-
-<pre>
-public class DisplayMessageActivity extends AppCompatActivity {
-
+<pre>public class MainActivity extends AppCompatActivity {
+    <b>public final static String EXTRA_MESSAGE = "com.example.myfirstapp.MESSAGE";</b>
     &#64;Override
     protected void onCreate(Bundle savedInstanceState) {
         super.onCreate(savedInstanceState);
-        setContentView(R.layout.activity_display_message);
-
-        if (savedInstanceState == null) {
-            getSupportFragmentManager().beginTransaction()
-                .add(R.id.container, new PlaceholderFragment()).commit();
-        }
+        setContentView(R.layout.activity_main);
     }
 
-    &#64;Override
-    public boolean onOptionsItemSelected(MenuItem item) {
-        // Handle app bar item clicks here. The app bar
-        // automatically handles clicks on the Home/Up button, so long
-        // as you specify a parent activity in AndroidManifest.xml.
-        int id = item.getItemId();
-        if (id == R.id.action_settings) {
-            return true;
-        }
-        return super.onOptionsItemSelected(item);
+    /** Called when the user clicks the Send button */
+    public void sendMessage(View view) {
+        <b>Intent intent = new Intent(this, DisplayMessageActivity.class);
+        EditText editText = (EditText) findViewById(R.id.edit_message);
+        String message = editText.getText().toString();
+        intent.putExtra(EXTRA_MESSAGE, message);
+        startActivity(intent);</b>
     }
+}</pre>
 
-    /**
-     * A placeholder fragment containing a simple view.
-     */
-    public static class PlaceholderFragment extends Fragment {
+<p class="note"><strong>Note: </strong>Android Studio will display
+  <code>Cannot resolve symbol</code> errors because the code references classes
+  like {@link android.content.Intent} and {@link android.widget.EditText}
+  that have not been imported. To import these classes, you can either 1)
+  use Android Studio's "import class" functionality by pressing Alt + Enter
+  (Option + Return on Mac) or 2) manually add import statements at the top of
+  the file.</p>
 
-        public PlaceholderFragment() { }
+<p>There’s a lot going on in <code>sendMessage()</code>, so let’s explain
+  what's going on.</p>
 
-        &#64;Override
-        public View onCreateView(LayoutInflater inflater, ViewGroup container,
-                  Bundle savedInstanceState) {
-              View rootView = inflater.inflate(R.layout.fragment_display_message,
-                      container, false);
-              return rootView;
-        }
-    }
-}
-</pre>
+<p>The {@link android.content.Intent} constructor takes two parameters:</p>
+<ul>
+  <li>A {@link android.content.Context} as its first parameter ({@code this}
+    is used because the {@link android.app.Activity} class is a subclass of
+    {@link android.content.Context})
+  <li>The {@link java.lang.Class} of the app component to which the system
+    should deliver the {@link android.content.Intent} (in this case, the
+    activity that should be started).
+    <p class="note"><strong>Note:</strong> The reference to
+      <code>DisplayMessageActivity</code> will raise an error in Android Studio
+      because the class doesn’t exist yet. Ignore the error for now; you’ll
+      create the class soon.</p>
+</ul>
 
-<p class="note"><strong>Note:</strong> If you are using an IDE other than Android Studio, your project
-does not contain the {@code activity_display_message} layout that's requested by
-{@link android.app.Activity#setContentView setContentView()}. That's OK because
-you will update this method later and won't be using that layout.</p>
+<p>The {@link android.content.Intent#putExtra(String, String) putExtra()}
+  method adds the <code>EditText</code>'s value to the intent. An <code>Intent</code>
+  can carry data types as key-value pairs called <em>extras</em>. Your key is a
+  public constant <code>EXTRA_MESSAGE</code> because the next
+  activity uses the key to retrive the text value. It's a good practice to
+  define keys for intent extras using your app's package name as a prefix. This
+  ensures the keys are unique, in case your app interacts with other apps.</p>
 
-</li>
+<p>The {@link android.app.Activity#startActivity(Intent) startActivity()}
+  method starts an instance of the <code>DisplayMessageActivity</code> specified
+  by the {@link android.content.Intent}. Now you need to create the class.</p>
 
-<li>To your {@code strings.xml} file, add the new activity's title as follows:
-<pre>
-&lt;resources>
-    ...
-    &lt;string name="title_activity_display_message">My Message&lt;/string>
-&lt;/resources>
-</pre>
-</li>
-
-<li>In your manifest file, <code>AndroidManifest.xml</code>, within the <code>Application</code>
-element, add the
-<a href="{@docRoot}guide/topics/manifest/activity-element.html">{@code <activity>}</a> element
-for your {@code DisplayMessageActivity} class, as follows:
-
-<pre>
-&lt;application ... >
-    ...
-    &lt;activity
-        android:name="com.mycompany.myfirstapp.DisplayMessageActivity"
-        android:label="@string/title_activity_display_message"
-        android:parentActivityName="com.mycompany.myfirstapp.MyActivity" >
-        &lt;meta-data
-            android:name="android.support.PARENT_ACTIVITY"
-            android:value="com.mycompany.myfirstapp.MyActivity" />
-    &lt;/activity>
-&lt;/application>
-</pre>
-
-</li>
-</ol>
-
-<p>The <a href="{@docRoot}guide/topics/manifest/activity-element.html#parent">{@code
-android:parentActivityName}</a> attribute declares the name of this activity's parent activity
-within the app's logical hierarchy. The system uses this value
-to implement default navigation behaviors, such as <a
-href="{@docRoot}design/patterns/navigation.html">Up navigation</a> on
-Android 4.1 (API level 16) and higher. You can provide the same navigation behaviors for
-older versions of Android by using the
-<a href="{@docRoot}tools/support-library/index.html">Support Library</a> and adding
-the <a href="{@docRoot}guide/topics/manifest/meta-data-element.html">{@code
-<meta-data>}</a> element as shown here.</p>
-
-<p class="note"><strong>Note:</strong> Your Android SDK should already include
-the latest Android Support Library, which you installed during the
-<a href="{@docRoot}studio/intro/update.html">Adding SDK Packages</a> step.
-When using the templates in Android Studio, the Support Library is automatically added to your app project
-(you can see the library's JAR file listed under <em>Android Dependencies</em>). If you're not using
-Android Studio, you need to manually add the library to your project&mdash;follow the guide for <a
-href="{@docRoot}tools/support-library/setup.html">setting up the Support Library</a>
-then return here.</p>
-
-<p>If you're using a different IDE than Android Studio, don't worry that the app won't yet compile.
-You'll soon update the activity to display a custom text view.</p>
-
-
-<h2 id="ReceiveIntent">Receive the Intent</h2>
-
-<p>Every {@link android.app.Activity} is invoked by an {@link android.content.Intent}, regardless of
-how the user navigated there. You can get the {@link android.content.Intent} that started your
-activity by calling {@link android.app.Activity#getIntent()} and retrieve the data contained
-within the intent.</p>
+<h2 id="CreateActivity">Create the Second Activity</h2>
 
 <ol>
-<li>In the <code>java/com.mycompany.myfirstapp</code> directory, edit the
-  {@code DisplayMessageActivity.java} file.</li>
-<li>Get the intent and assign it to a local variable.
-<pre>
-Intent intent = getIntent();
-</pre>
-</li>
-<li>At the top of the file, import the {@link android.content.Intent} class.
-  <p>In Android Studio, press Alt + Enter (option + return on Mac) to import missing classes.</p>
-</li>
-<li>Extract the message delivered by {@code MyActivity} with the
-{@link android.content.Intent#getStringExtra getStringExtra()} method.
-<pre>
-String message = intent.getStringExtra(MyActivity.EXTRA_MESSAGE);
-</pre>
-</li>
+  <li>In the <b>Project</b> window, right-click the <b>app</b> folder and select
+    <strong>New > Activity > Empty Activity</strong>.</li>
+  <li>In the <strong>Configure Activity</strong> window, enter
+    "DisplayMessageActivity" for <strong>Activity Name</strong> and click
+    <strong>Finish</strong>
+  </li>
 </ol>
 
+<p>Android Studio automatically does three things:</p>
+<ul>
+  <li>Creates the class <code>DisplayMessageActivity.java</code> with an
+   implementation of the required {@link android.app.Activity#onCreate(Bundle) onCreate()}
+    method.</li>
+  <li>Creates the corresponding layout file <code>activity_display_message.xml</code>
+    </li>
+  <li>Adds the required
+    <a href="{@docRoot}guide/topics/manifest/activity-element.html">&lt;activity&gt;</a>
+    element in <code>AndroidManifest.xml</code>.
+</ul>
+
+<p>If you run the app and click the Send button on the first activity, the
+  second activity starts but is empty. This is because the second activity uses
+  the default empty layout provided by the template.</p>
+
 <h2 id="DisplayMessage">Display the Message</h2>
+<p>Now you will modify the second activity to display the message that was passed
+by the first activity.</p>
 
 <ol>
-<li>In the res/layout directory, edit the {@code content_display_message.xml} file.</li>
-<li>Add an {@code android:id} attribute to the {@code RelativeLayout}.
-You need this attribute to reference the object from your app code.</li>
-
-<pre>
-&lt; RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
-...
-android:id="@+id/content"&gt;
-&lt;/RelativeLayout&gt;
-</pre>
-<li>Switch back to editing {@code DisplayMessageActivity.java}.</li>
-
-
-<li>In the {@link android.app.Activity#onCreate onCreate()} method, create a {@link android.widget.TextView} object.
-<pre>
-TextView textView = new TextView(this);
-</pre>
-</li>
-<li>Set the text size and message with {@link android.widget.TextView#setText setText()}.
-<pre>
-textView.setTextSize(40);
-textView.setText(message);
-</pre>
-</li>
-<li>Add the {@link android.widget.TextView} to the {@link android.widget.RelativeLayout}
-identified by {@code R.id.content}.
-<pre>
-RelativeLayout layout = (RelativeLayout) findViewById(R.id.content);
-layout.addView(textView);
-</pre>
-</li>
-<li>At the top of the file, import the {@link android.widget.TextView} class.
-  <p>In Android Studio, press Alt + Enter (option + return on Mac) to import missing classes.</p>
-</li>
-</ol>
-
-<p>The complete {@link android.app.Activity#onCreate onCreate()} method for {@code
-DisplayMessageActivity} now looks like this:</p>
-
-<pre>
-&#64;Override
+  <li>In {@code DisplayMessageActivity.java}, add the following code to the
+    <code>onCreate()</code> method:
+    <pre>&#64;Override
 protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_display_message);
-   Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
-   setSupportActionBar(toolbar);
-
-   FloatingActionButton fab = (FloatingActionButton) findViewById(R.id.fab);
-   fab.setOnClickListener(new View.OnClickListener() {
-       &#64;Override
-       public void onClick(View view) {
-           Snackbar.make(view, "Replace with your own action", Snackbar.LENGTH_LONG)
-                   .setAction("Action", null)
-                   .show();
-       }
-   });
-   getSupportActionBar().setDisplayHomeAsUpEnabled(true);
 
    Intent intent = getIntent();
-   String message = intent.getStringExtra(MyActivity.EXTRA_MESSAGE);
+   String message = intent.getStringExtra(MainActivity.EXTRA_MESSAGE);
    TextView textView = new TextView(this);
    textView.setTextSize(40);
    textView.setText(message);
 
-   RelativeLayout layout = (RelativeLayout) findViewById(R.id.content);
+   ViewGroup layout = (ViewGroup) findViewById(R.id.activity_display_message);
    layout.addView(textView);
-</pre>
+}</pre>
+  </li>
+  <li>Press Alt + Enter (option + return on Mac) to import missing classes.</li>
+</ol>
+
+<p>There’s a lot going on here, so let’s explain:</p>
+
+<ol>
+  <li>The call {@link android.app.Activity#getIntent()} grabs the intent
+    that started the activity. Every {@link android.app.Activity} is invoked by an
+    {@link android.content.Intent}, regardless of how the user navigated there.
+    The call {@link android.content.Intent#getStringExtra(String) getStringExtra()}
+    retrieves the data from the first activity.</li>
+  <li>You programmatically create a {@link android.widget.TextView} and set
+    its size and message.
+  </li>
+  <li>You add the <code>TextView</code> to the layout identified by
+    {@code R.id.activity_display_message}. You cast the layout to
+    {@link android.view.ViewGroup} because it is the superclass of all layouts and
+    contains the {@link android.view.ViewGroup#addView(View) addView()}
+    method.</li>
+</ol>
+
+<p class="note"><strong>Note: </strong>The XML layout generated by previous
+  versions of Android Studio might not include the <code>android:id</code>
+  attribute. The call <code>findViewById()</code> will fail if the layout
+  does not have the <code>android:id</code> attribute. If this is the case,
+  open <code>activity_display_message.xml</code> and add the attribute
+  <code>android:id="@+id/activity_display_message"</code> to the layout element.
+</p>
 
 <p>You can now run the app. When it opens, type a message in the text field, and click
 <strong>Send</strong>. The second activity replaces the first one on the screen, showing
@@ -513,8 +234,4 @@
 
 <p>That's it, you've built your first Android app!</p>
 
-<p>To learn more, follow the link below to the next class.</p>
-
-
-
-
+<p>To learn more, follow the link below to the next class.</p>
\ No newline at end of file
diff --git a/docs/html/training/contacts-provider/display-contact-badge.jd b/docs/html/training/contacts-provider/display-contact-badge.jd
index 6c9616b..d286440 100644
--- a/docs/html/training/contacts-provider/display-contact-badge.jd
+++ b/docs/html/training/contacts-provider/display-contact-badge.jd
@@ -113,10 +113,10 @@
 <p>
     For Android 3.0 (API level 11) and later, include the following columns in your projection:</p>
 <ul>
-    <li>{@link android.provider.ContactsContract.Contacts#_ID Contacts._ID}</li>
-    <li>{@link android.provider.ContactsContract.Contacts#LOOKUP_KEY Contacts.LOOKUP_KEY}</li>
+    <li>{@link android.provider.BaseColumns#_ID Contacts._ID}</li>
+    <li>{@link android.provider.ContactsContract.ContactsColumns#LOOKUP_KEY Contacts.LOOKUP_KEY}</li>
     <li>
-        {@link android.provider.ContactsContract.Contacts#PHOTO_THUMBNAIL_URI
+        {@link android.provider.ContactsContract.ContactsColumns#PHOTO_THUMBNAIL_URI
         Contacts.PHOTO_THUMBNAIL_URI}
     </li>
 </ul>
@@ -124,8 +124,8 @@
     For Android 2.3.3 (API level 10) and earlier, use the following columns:
 </p>
 <ul>
-    <li>{@link android.provider.ContactsContract.Contacts#_ID Contacts._ID}</li>
-    <li>{@link android.provider.ContactsContract.Contacts#LOOKUP_KEY Contacts.LOOKUP_KEY}</li>
+    <li>{@link android.provider.BaseColumns#_ID Contacts._ID}</li>
+    <li>{@link android.provider.ContactsContract.ContactsColumns#LOOKUP_KEY Contacts.LOOKUP_KEY}</li>
 </ul>
 <p>
     The remainder of this lesson assumes that you've already loaded a
@@ -187,14 +187,14 @@
 </p>
 <p class="note">
     <strong>Note:</strong> The
-    {@link android.provider.ContactsContract.Contacts#PHOTO_THUMBNAIL_URI} column isn't available
+    {@link android.provider.ContactsContract.ContactsColumns#PHOTO_THUMBNAIL_URI} column isn't available
     in platform versions prior to 3.0. For those versions, you must retrieve the URI
     from the {@link android.provider.ContactsContract.Contacts.Photo Contacts.Photo} subtable.
 </p>
 <p>
     First, set up variables for accessing the {@link android.database.Cursor} containing the
-    {@link android.provider.ContactsContract.Contacts#_ID Contacts._ID} and
-    {@link android.provider.ContactsContract.Contacts#LOOKUP_KEY Contacts.LOOKUP_KEY} columns, as
+    {@link android.provider.BaseColumns#_ID Contacts._ID} and
+    {@link android.provider.ContactsContract.ContactsColumns#LOOKUP_KEY Contacts.LOOKUP_KEY} columns, as
     described previously:
 </p>
 <pre>
diff --git a/docs/html/training/contacts-provider/modify-data.jd b/docs/html/training/contacts-provider/modify-data.jd
index 64853ef..e993c56 100644
--- a/docs/html/training/contacts-provider/modify-data.jd
+++ b/docs/html/training/contacts-provider/modify-data.jd
@@ -196,8 +196,8 @@
     Contacts.CONTENT_LOOKUP_URI}, call
     {@link android.provider.ContactsContract.Contacts#getLookupUri
     Contacts.getLookupUri(id, lookupkey)} with the contact's
-    {@link android.provider.ContactsContract.Contacts#_ID Contacts._ID} and
-    {@link android.provider.ContactsContract.Contacts#LOOKUP_KEY Contacts.LOOKUP_KEY} values as
+    {@link android.provider.BaseColumns#_ID Contacts._ID} and
+    {@link android.provider.ContactsContract.ContactsColumns#LOOKUP_KEY Contacts.LOOKUP_KEY} values as
     arguments.
 </p>
 <p>
diff --git a/docs/html/training/contacts-provider/retrieve-details.jd b/docs/html/training/contacts-provider/retrieve-details.jd
index 0de3b67..a463b75 100644
--- a/docs/html/training/contacts-provider/retrieve-details.jd
+++ b/docs/html/training/contacts-provider/retrieve-details.jd
@@ -55,11 +55,11 @@
 <p>
     To retrieve all the details for a contact, search the
     {@link android.provider.ContactsContract.Data} table for any rows that contain the contact's
-    {@link android.provider.ContactsContract.Data#LOOKUP_KEY}. This column is available in
+    {@link android.provider.ContactsContract.ContactsColumns#LOOKUP_KEY}. This column is available in
     the {@link android.provider.ContactsContract.Data} table, because the Contacts
     Provider makes an implicit join between the {@link android.provider.ContactsContract.Contacts}
     table and the {@link android.provider.ContactsContract.Data} table. The
-    {@link android.provider.ContactsContract.Contacts#LOOKUP_KEY} column is described
+    {@link android.provider.ContactsContract.ContactsColumns#LOOKUP_KEY} column is described
     in more detail in the <a href="retrieve-names.html">Retrieving Contact Names</a> lesson.
 </p>
 <p class="note">
@@ -85,9 +85,9 @@
     the data is in different columns depending on the data type.
     To ensure you get all the possible columns for all possible data types, you need to add all the
     column names to your projection. Always retrieve
-    {@link android.provider.ContactsContract.Data#_ID Data._ID} if you're binding the result
+    {@link android.provider.BaseColumns#_ID Data._ID} if you're binding the result
     {@link android.database.Cursor} to a {@link android.widget.ListView}; otherwise, the binding
-    won't work. Also retrieve {@link android.provider.ContactsContract.Data#MIMETYPE Data.MIMETYPE}
+    won't work. Also retrieve {@link android.provider.ContactsContract.DataColumns#MIMETYPE Data.MIMETYPE}
     so you can identify the data type of each row you retrieve. For example:
 </p>
 <pre>
@@ -128,7 +128,7 @@
 <p>
     Define a constant for your selection clause, an array to hold selection arguments, and a
     variable to hold the selection value. Use
-    the {@link android.provider.ContactsContract.Contacts#LOOKUP_KEY Contacts.LOOKUP_KEY} column to
+    the {@link android.provider.ContactsContract.ContactsColumns#LOOKUP_KEY Contacts.LOOKUP_KEY} column to
     find the contact. For example:
 </p>
 <pre>
@@ -153,7 +153,7 @@
 <p>
     Define the sort order you want in the resulting {@link android.database.Cursor}. To
     keep all rows for a particular data type together, sort by
-    {@link android.provider.ContactsContract.Data#MIMETYPE Data.MIMETYPE}. This query argument
+    {@link android.provider.ContactsContract.DataColumns#MIMETYPE Data.MIMETYPE}. This query argument
     groups all email rows together, all phone rows together, and so forth. For example:
 </p>
 <pre>
@@ -299,7 +299,7 @@
     </dt>
     <dd>
         Modify the selection text to search for the
-        {@link android.provider.ContactsContract.Data#MIMETYPE MIMETYPE} value that's specific to
+        {@link android.provider.ContactsContract.DataColumns#MIMETYPE MIMETYPE} value that's specific to
         your data type.
     </dd>
     <dt>
@@ -307,7 +307,7 @@
     </dt>
     <dd>
         Since you're only selecting a single detail type, don't group the returned
-        {@link android.database.Cursor} by {@link android.provider.ContactsContract.Data#MIMETYPE
+        {@link android.database.Cursor} by {@link android.provider.ContactsContract.DataColumns#MIMETYPE
         Data.MIMETYPE}.
     </dd>
 </dl>
@@ -344,9 +344,9 @@
 <h3>Define selection criteria</h3>
 <p>
     Define a search text expression that retrieves rows for a specific contact's
-    {@link android.provider.ContactsContract.Data#LOOKUP_KEY} and the
-    {@link android.provider.ContactsContract.Data#MIMETYPE Data.MIMETYPE} of the details you
-    want. Enclose the {@link android.provider.ContactsContract.Data#MIMETYPE MIMETYPE} value in
+    {@link android.provider.ContactsContract.ContactsColumns#LOOKUP_KEY} and the
+    {@link android.provider.ContactsContract.DataColumns#MIMETYPE Data.MIMETYPE} of the details you
+    want. Enclose the {@link android.provider.ContactsContract.DataColumns#MIMETYPE MIMETYPE} value in
     single quotes by concatenating a "<code>'</code>" (single-quote) character to the start and end
     of the constant; otherwise, the provider interprets the constant as a variable name rather
     than as a string value. You don't need to use a placeholder for this value, because you're
@@ -368,10 +368,10 @@
 <h3>Define a sort order</h3>
 <p>
     Define a sort order for the returned {@link android.database.Cursor}. Since you're retrieving a
-    specific data type, omit the sort on {@link android.provider.ContactsContract.Data#MIMETYPE}.
+    specific data type, omit the sort on {@link android.provider.ContactsContract.DataColumns#MIMETYPE}.
     Instead, if the type of detail data you're searching includes a subtype, sort on it.
     For example, for email data you can sort on
-    {@link android.provider.ContactsContract.CommonDataKinds.Email#TYPE Email.TYPE}:
+    {@link android.provider.ContactsContract.CommonDataKinds.CommonColumns#TYPE Email.TYPE}:
 </p>
 <pre>
     private static final String SORT_ORDER = Email.TYPE + " ASC ";
diff --git a/docs/html/training/contacts-provider/retrieve-names.jd b/docs/html/training/contacts-provider/retrieve-names.jd
index 49d6e95..7d70ceb 100755
--- a/docs/html/training/contacts-provider/retrieve-names.jd
+++ b/docs/html/training/contacts-provider/retrieve-names.jd
@@ -227,7 +227,7 @@
 </pre>
 <p class="note">
     <strong>Note:</strong> Since
-    {@link android.provider.ContactsContract.Contacts#DISPLAY_NAME_PRIMARY
+    {@link android.provider.ContactsContract.ContactNameColumns#DISPLAY_NAME_PRIMARY
     Contacts.DISPLAY_NAME_PRIMARY} requires Android 3.0 (API version 11) or later, setting your
     app's <code>minSdkVersion</code> to 10 or below generates an Android Lint warning in
     Android Studio. To turn off this warning, add the annotation
@@ -261,7 +261,7 @@
     that displays the contacts, you need to call {@link android.app.Activity#findViewById
     Activity.findViewById()} using the parent activity of the
     {@link android.support.v4.app.Fragment}. Use the {@link android.content.Context} of the
-    parent activity when you call {@link android.widget.ListView#setAdapter setAdapter()}.
+    parent activity when you call {@link android.widget.AdapterView#setAdapter setAdapter()}.
     For example:
 </p>
 <pre>
@@ -293,7 +293,7 @@
 </p>
 <p>
     To continue setting up the listener, bind it to the {@link android.widget.ListView} by
-    calling the method {@link android.widget.ListView#setOnItemClickListener
+    calling the method {@link android.widget.AdapterView#setOnItemClickListener
     setOnItemClickListener()} in {@link android.support.v4.app.Fragment#onActivityCreated
     onActivityCreated()}. For example:
 </p>
@@ -318,15 +318,15 @@
     the {@link android.widget.ListView} displays the contact's display name,
     which contains the main form of the contact's name. In Android 3.0 (API version 11) and later,
     the name of this column is
-    {@link android.provider.ContactsContract.Contacts#DISPLAY_NAME_PRIMARY
+    {@link android.provider.ContactsContract.ContactNameColumns#DISPLAY_NAME_PRIMARY
     Contacts.DISPLAY_NAME_PRIMARY}; in versions previous to that, its name is
-    {@link android.provider.ContactsContract.Contacts#DISPLAY_NAME Contacts.DISPLAY_NAME}.
+    {@link android.provider.ContactsContract.ContactsColumns#DISPLAY_NAME Contacts.DISPLAY_NAME}.
 </p>
 <p>
-    The column {@link android.provider.ContactsContract.Contacts#_ID Contacts._ID} is used by the
+    The column {@link android.provider.BaseColumns#_ID Contacts._ID} is used by the
     {@link android.support.v4.widget.SimpleCursorAdapter} binding process.
-    {@link android.provider.ContactsContract.Contacts#_ID Contacts._ID} and
-    {@link android.provider.ContactsContract.Contacts#LOOKUP_KEY} are used together to
+    {@link android.provider.BaseColumns#_ID Contacts._ID} and
+    {@link android.provider.ContactsContract.ContactsColumns#LOOKUP_KEY} are used together to
     construct a content URI for the contact the user selects.
 </p>
 <pre>
@@ -635,7 +635,7 @@
     </li>
     <li>
         The name of the column that contains the custom MIME type value. This name is always
-        {@link android.provider.ContactsContract.Data#MIMETYPE Data.MIMETYPE}.
+        {@link android.provider.ContactsContract.DataColumns#MIMETYPE Data.MIMETYPE}.
     </li>
     <li>
         The custom MIME type value for the data type. As described previously, this is the constant
diff --git a/docs/html/training/graphics/opengl/touch.jd b/docs/html/training/graphics/opengl/touch.jd
index 089ede7..6a961da 100644
--- a/docs/html/training/graphics/opengl/touch.jd
+++ b/docs/html/training/graphics/opengl/touch.jd
@@ -36,7 +36,7 @@
 getting some attention, but what if you want to have users interact with your OpenGL ES graphics?
 The key to making your OpenGL ES application touch interactive is expanding your implementation of
 {@link android.opengl.GLSurfaceView} to override the {@link
-android.opengl.GLSurfaceView#onTouchEvent onTouchEvent()} to listen for touch events.</p>
+android.view.View#onTouchEvent onTouchEvent()} to listen for touch events.</p>
 
 <p>This lesson shows you how to listen for touch events to let users rotate an OpenGL ES object.</p>
 
@@ -44,7 +44,7 @@
 <h2 id="listener">Setup a Touch Listener</h2>
 
 <p>In order to make your OpenGL ES application respond to touch events, you must implement the
-{@link android.opengl.GLSurfaceView#onTouchEvent onTouchEvent()} method in your
+{@link android.view.View#onTouchEvent onTouchEvent()} method in your
 {@link android.opengl.GLSurfaceView} class. The example implementation below shows how to listen for
 {@link android.view.MotionEvent#ACTION_MOVE MotionEvent.ACTION_MOVE} events and translate them to
 an angle of rotation for a shape.</p>
diff --git a/docs/html/training/implementing-navigation/nav-drawer.jd b/docs/html/training/implementing-navigation/nav-drawer.jd
index 679c240..d359a47 100644
--- a/docs/html/training/implementing-navigation/nav-drawer.jd
+++ b/docs/html/training/implementing-navigation/nav-drawer.jd
@@ -148,7 +148,7 @@
 }
 </pre>
 
-<p>This code also calls {@link android.widget.ListView#setOnItemClickListener
+<p>This code also calls {@link android.widget.AdapterView#setOnItemClickListener
 setOnItemClickListener()} to receive click events in the navigation drawer's list.
 The next section shows how to implement this interface
 and change the content view when the user selects an item.</p>
@@ -160,7 +160,7 @@
 <p>When the user selects an item in the drawer's list, the system calls {@link
 android.widget.AdapterView.OnItemClickListener#onItemClick onItemClick()} on the
 {@link android.widget.AdapterView.OnItemClickListener OnItemClickListener} given to
-{@link android.widget.ListView#setOnItemClickListener setOnItemClickListener()}.</p>
+{@link android.widget.AdapterView#setOnItemClickListener setOnItemClickListener()}.</p>
 
 <p>What you do in the {@link
 android.widget.AdapterView.OnItemClickListener#onItemClick onItemClick()} method
diff --git a/docs/html/training/notify-user/build-notification.jd b/docs/html/training/notify-user/build-notification.jd
index 2f96a20..dcc8685 100644
--- a/docs/html/training/notify-user/build-notification.jd
+++ b/docs/html/training/notify-user/build-notification.jd
@@ -134,8 +134,8 @@
 <ul>
 <li>Get an instance of {@link android.app.NotificationManager}.</li>
 
-<li>Use the {@link android.app.NotificationManager#notify notify()} method to issue the
-notification. When you call {@link android.app.NotificationManager#notify notify()}, specify a notification ID.
+<li>Use the {@link android.app.NotificationManager#notify(String, int, Notification)} method to issue the
+notification. When you call {@link android.app.NotificationManager#notify(String, int, Notification)}, specify a notification ID.
 You can use this ID to update the notification later on. This is described in more detail in
 <a href="managing.html">Managing Notifications</a>.</li>
 
diff --git a/docs/html/training/testing/integration-testing/service-testing.jd b/docs/html/training/testing/integration-testing/service-testing.jd
index 60b95ca..7ba00b0 100644
--- a/docs/html/training/testing/integration-testing/service-testing.jd
+++ b/docs/html/training/testing/integration-testing/service-testing.jd
@@ -81,7 +81,7 @@
 <a href="{@docRoot}training/testing/unit-testing/instrumented-unit-tests.html#build">
 Create an Instrumented Unit Test Class</a>.</p>
 
-<p>To create an integration test for your service, add the {@code &#64;RunWith(AndroidJUnit4.class)}
+<p>To create an integration test for your service, add the {@code @RunWith(AndroidJUnit4.class)}
 annotation at the beginning of your test class definition. You also need to specify the
 <a href="{@docRoot}reference/android/support/test/runner/AndroidJUnitRunner.html">
 {@code AndroidJUnitRunner}</a> class that the Android Testing Support Library provides as your
@@ -91,7 +91,7 @@
 
 <p>Next, create a
 <a href="{@docRoot}reference/android/support/test/rule/ServiceTestRule.html">ServiceTestRule</a>
-instance in your test by using the {@code &#64;Rule} annotation.</p>
+instance in your test by using the {@code @Rule} annotation.</p>
 
 <pre>
 &#64;Rule
diff --git a/docs/html/training/testing/ui-testing/uiautomator-testing.jd b/docs/html/training/testing/ui-testing/uiautomator-testing.jd
index 5d42107..53f497a 100644
--- a/docs/html/training/testing/ui-testing/uiautomator-testing.jd
+++ b/docs/html/training/testing/ui-testing/uiautomator-testing.jd
@@ -172,7 +172,7 @@
 <a href="{@docRoot}training/testing/unit-testing/instrumented-unit-tests.html#build">
 Create an Instrumented Unit Test Class</a>.
 </p>
-<p>Add the {@code &#64;RunWith(AndroidJUnit4.class)} annotation at the beginning of your test class
+<p>Add the {@code @RunWith(AndroidJUnit4.class)} annotation at the beginning of your test class
 definition. You also need to specify the
 <a href="{@docRoot}reference/android/support/test/runner/AndroidJUnitRunner.html">
 {@code AndroidJUnitRunner}</a> class
@@ -279,7 +279,7 @@
 }
 </pre>
 
-<p>In the example, the {@code &#64;SdkSuppress(minSdkVersion = 18)} statement helps to ensure that
+<p>In the example, the {@code @SdkSuppress(minSdkVersion = 18)} statement helps to ensure that
   tests will only run on devices with Android 4.3 (API level 18) or higher, as required by the
   UI Automator framework.</p>
 
diff --git a/docs/html/training/testing/unit-testing/instrumented-unit-tests.jd b/docs/html/training/testing/unit-testing/instrumented-unit-tests.jd
index f65766d..00622ee 100644
--- a/docs/html/training/testing/unit-testing/instrumented-unit-tests.jd
+++ b/docs/html/training/testing/unit-testing/instrumented-unit-tests.jd
@@ -122,7 +122,7 @@
 creating JUnit 4 test classes and using JUnit 4 assertions and annotations, see
 <a href="local-unit-tests.html#build">Create a Local Unit Test Class</a>.
 </p>
-<p>To create an instrumented JUnit 4 test class, add the {@code &#64;RunWith(AndroidJUnit4.class)}
+<p>To create an instrumented JUnit 4 test class, add the {@code @RunWith(AndroidJUnit4.class)}
 annotation at the beginning of your test class definition. You also need to specify the
 <a href="{@docRoot}reference/android/support/test/runner/AndroidJUnitRunner.html">
 {@code AndroidJUnitRunner}</a> class
@@ -200,8 +200,8 @@
 class="external-link">{@code RunWith}</a> and
 <a href="http://junit.sourceforge.net/javadoc/org/junit/runners/Suite.html"
 class="external-link">{@code Suite}</a> classes. In your test suite, add the
-{@code &#64;RunWith(Suite.class)} and the {@code &#64;Suite.SuitClasses()} annotations. In
-the {@code &#64;Suite.SuiteClasses()} annotation, list the individual test classes or test
+{@code @RunWith(Suite.class)} and the {@code @Suite.SuitClasses()} annotations. In
+the {@code @Suite.SuiteClasses()} annotation, list the individual test classes or test
 suites as arguments.
 </p>
 
diff --git a/docs/html/training/testing/unit-testing/local-unit-tests.jd b/docs/html/training/testing/unit-testing/local-unit-tests.jd
index 25b62fa..8b109ee 100644
--- a/docs/html/training/testing/unit-testing/local-unit-tests.jd
+++ b/docs/html/training/testing/unit-testing/local-unit-tests.jd
@@ -80,7 +80,7 @@
 {@code junit.extensions} package.</p>
 
 <p>To create a basic JUnit 4 test class, create a Java class that contains one or more test methods.
-A test method begins with the {@code &#64;Test} annotation and contains the code to exercise
+A test method begins with the {@code @Test} annotation and contains the code to exercise
 and verify a single functionality in the component that you want to test.</p>
 
 <p>The following example shows how you might implement a local unit test class. The test method
@@ -136,11 +136,11 @@
 <a href="#setup">Set Up Your Testing Environment</a>.
 </li>
 <li>At the beginning of your unit test class definition, add the
-{@code &#64;RunWith(MockitoJUnitRunner.class)} annotation. This annotation tells the Mockito test
+{@code @RunWith(MockitoJUnitRunner.class)} annotation. This annotation tells the Mockito test
 runner to validate that your usage of the framework is correct and simplifies the initialization of
 your mock objects.
 </li>
-<li>To create a mock object for an Android dependency, add the {@code &#64;Mock} annotation before
+<li>To create a mock object for an Android dependency, add the {@code @Mock} annotation before
 the field declaration.</li>
 <li>To stub the behavior of the dependency, you can specify a condition and return
 value when the condition is met by using the {@code when()} and {@code thenReturn()} methods.
diff --git a/docs/html/training/wearables/data-layer/events.jd b/docs/html/training/wearables/data-layer/events.jd
index 20f219d..db0ffcf6 100644
--- a/docs/html/training/wearables/data-layer/events.jd
+++ b/docs/html/training/wearables/data-layer/events.jd
@@ -242,7 +242,7 @@
 per manifest, multiple intent filters per service, multiple actions per filter,
 and multiple data stanzas per filter. Filters can match on a wildcard host or on
 a specific one. To match on a wildcard host, use {@code host="*"}. To match
-on a specific host, specify {@code host=&lt;node_id&gt;}.
+on a specific host, specify {@code host=<node_id>}.
 </p>
 
 <p>
diff --git a/docs/html/training/wearables/notifications/creating.jd b/docs/html/training/wearables/notifications/creating.jd
index 5663b58..35bb2bd 100644
--- a/docs/html/training/wearables/notifications/creating.jd
+++ b/docs/html/training/wearables/notifications/creating.jd
@@ -58,7 +58,7 @@
 
 <p>To create a notification with the support library, you create an instance of
 {@link android.support.v4.app.NotificationCompat.Builder} and issue the notification by
-passing it to {@link android.support.v4.app.NotificationManagerCompat#notify notify()}. For example:
+passing it to {@link android.support.v4.app.NotificationManagerCompat#notify(int, android.app.Notification) notify()}. For example:
 </p>
 
 <pre>
diff --git a/docs/html/training/wearables/notifications/stacks.jd b/docs/html/training/wearables/notifications/stacks.jd
index 8056fc8..c3f43a7 100644
--- a/docs/html/training/wearables/notifications/stacks.jd
+++ b/docs/html/training/wearables/notifications/stacks.jd
@@ -37,7 +37,7 @@
 
 <p>To create a stack, call {@link android.support.v4.app.NotificationCompat.Builder#setGroup setGroup()}
 for each notification you want in the stack and specify a
-group key. Then call {@link android.support.v4.app.NotificationManagerCompat#notify notify()}
+group key. Then call {@link android.support.v4.app.NotificationManagerCompat#notify(int, android.app.Notification) notify()}
 to send it to the wearable.</p>
 
 <pre style="clear:right">
@@ -59,7 +59,7 @@
 
 <p>Later on, when you create another notification, specify
 the same group key. When you call
-{@link android.support.v4.app.NotificationManagerCompat#notify notify()},
+{@link android.support.v4.app.NotificationManagerCompat#notify(int, android.app.Notification) notify()},
 this notification appears in the same stack as the previous notification,
 instead of as a new card:</p>
 
diff --git a/docs/html/work/managed-configurations.jd b/docs/html/work/managed-configurations.jd
index 6de4d8b..76ca82f 100644
--- a/docs/html/work/managed-configurations.jd
+++ b/docs/html/work/managed-configurations.jd
@@ -349,7 +349,7 @@
 <p>
   To get a {@link android.content.RestrictionsManager} object, get the current
   activity with {@link android.app.Fragment#getActivity getActivity()}, then
-  call that activity's {@link android.app.Activity#getSystemService
+  call that activity's {@link android.app.Activity#getSystemService(java.lang.String)
   Activity.getSystemService()} method:
 </p>
 
@@ -399,9 +399,9 @@
   <code>String</code>, and <code>String[]</code>. Once you have the
   managed configurations {@link android.os.Bundle}, you can check the current
   configuration settings with the standard {@link android.os.Bundle} methods for
-  those data types, such as {@link android.os.Bundle#getBoolean getBoolean()}
+  those data types, such as {@link android.os.BaseBundle#getBoolean getBoolean()}
   or
-  {@link android.os.Bundle#getString getString()}.
+  {@link android.os.BaseBundle#getString getString()}.
 </p>
 
 <p class="note">
diff --git a/media/java/android/media/MediaRecorder.java b/media/java/android/media/MediaRecorder.java
index 73485af..94e894f 100644
--- a/media/java/android/media/MediaRecorder.java
+++ b/media/java/android/media/MediaRecorder.java
@@ -746,6 +746,27 @@
     }
 
     /**
+     * Sets the video encoding profile for recording. Call this method before prepare().
+     * Prepare() may perform additional checks on the parameter to make sure whether the
+     * specified profile and level are applicable, and sometimes the passed profile or
+     * level will be discarded due to codec capablity or to ensure the video recording
+     * can proceed smoothly based on the capabilities of the platform.
+     * @hide
+     * @param profile declared in {@link MediaCodecInfo.CodecProfileLevel}.
+     * @param level declared in {@link MediaCodecInfo.CodecProfileLevel}.
+     */
+    public void setVideoEncodingProfileLevel(int profile, int level) {
+        if (profile <= 0)  {
+            throw new IllegalArgumentException("Video encoding profile is not positive");
+        }
+        if (level <= 0)  {
+            throw new IllegalArgumentException("Video encoding level is not positive");
+        }
+        setParameter("video-param-encoder-profile=" + profile);
+        setParameter("video-param-encoder-level=" + level);
+    }
+
+    /**
      * Currently not implemented. It does nothing.
      * @deprecated Time lapse mode video recording using camera still image capture
      * is not desirable, and will not be supported.
diff --git a/packages/CaptivePortalLogin/src/com/android/captiveportallogin/CaptivePortalLoginActivity.java b/packages/CaptivePortalLogin/src/com/android/captiveportallogin/CaptivePortalLoginActivity.java
index 6fb8b51..b58c87a 100644
--- a/packages/CaptivePortalLogin/src/com/android/captiveportallogin/CaptivePortalLoginActivity.java
+++ b/packages/CaptivePortalLogin/src/com/android/captiveportallogin/CaptivePortalLoginActivity.java
@@ -96,7 +96,7 @@
         // Exit app if Network disappears.
         final NetworkCapabilities networkCapabilities = mCm.getNetworkCapabilities(mNetwork);
         if (networkCapabilities == null) {
-            finish();
+            finishAndRemoveTask();
             return;
         }
         mNetworkCallback = new NetworkCallback() {
@@ -163,7 +163,7 @@
                 mCaptivePortal.useNetwork();
                 break;
         }
-        finish();
+        finishAndRemoveTask();
     }
 
     @Override
diff --git a/packages/PrintSpooler/src/com/android/printspooler/ui/PrintActivity.java b/packages/PrintSpooler/src/com/android/printspooler/ui/PrintActivity.java
index 3e262d0..3b25edb 100644
--- a/packages/PrintSpooler/src/com/android/printspooler/ui/PrintActivity.java
+++ b/packages/PrintSpooler/src/com/android/printspooler/ui/PrintActivity.java
@@ -244,6 +244,8 @@
     public void onCreate(Bundle savedInstanceState) {
         super.onCreate(savedInstanceState);
 
+        setTitle(R.string.print_dialog);
+
         Bundle extras = getIntent().getExtras();
 
         mPrintJob = extras.getParcelable(PrintManager.EXTRA_PRINT_JOB);
@@ -298,7 +300,6 @@
         // Now that we are bound to the local print spooler service
         // and the printer registry loaded the historical printers
         // we can show the UI without flickering.
-        setTitle(R.string.print_dialog);
         setContentView(R.layout.print_activity);
 
         try {
diff --git a/packages/SystemUI/src/com/android/systemui/qs/PagedTileLayout.java b/packages/SystemUI/src/com/android/systemui/qs/PagedTileLayout.java
index 71bd798..afedbe3 100644
--- a/packages/SystemUI/src/com/android/systemui/qs/PagedTileLayout.java
+++ b/packages/SystemUI/src/com/android/systemui/qs/PagedTileLayout.java
@@ -10,6 +10,7 @@
 import android.view.LayoutInflater;
 import android.view.View;
 import android.view.ViewGroup;
+
 import com.android.systemui.R;
 import com.android.systemui.qs.QSPanel.QSTileLayout;
 import com.android.systemui.qs.QSPanel.TileRecord;
@@ -207,6 +208,7 @@
             }
             if (DEBUG) Log.d(TAG, "Size: " + mNumPages);
             mPageIndicator.setNumPages(mNumPages);
+            mDecorGroup.setVisibility(mNumPages > 1 ? View.VISIBLE : View.GONE);
             setAdapter(mAdapter);
             mAdapter.notifyDataSetChanged();
             setCurrentItem(0, false);
@@ -238,7 +240,8 @@
                 maxHeight = height;
             }
         }
-        setMeasuredDimension(getMeasuredWidth(), maxHeight + mDecorGroup.getMeasuredHeight());
+        setMeasuredDimension(getMeasuredWidth(), maxHeight
+                + (mDecorGroup.getVisibility() != View.GONE ? mDecorGroup.getMeasuredHeight() : 0));
     }
 
     private final Runnable mDistribute = new Runnable() {
diff --git a/packages/SystemUI/src/com/android/systemui/qs/QSAnimator.java b/packages/SystemUI/src/com/android/systemui/qs/QSAnimator.java
index aaa4e51..63444d2 100644
--- a/packages/SystemUI/src/com/android/systemui/qs/QSAnimator.java
+++ b/packages/SystemUI/src/com/android/systemui/qs/QSAnimator.java
@@ -230,7 +230,9 @@
             // Fade in the tiles/labels as we reach the final position.
             mFirstPageDelayedAnimator = new TouchAnimator.Builder()
                     .setStartDelay(EXPANDED_TILE_DELAY)
-                    .addFloat(mQsPanel.getTileLayout(), "alpha", 0, 1).build();
+                    .addFloat(mQsPanel.getTileLayout(), "alpha", 0, 1)
+                    .addFloat(mQsPanel.getFooter().getView(), "alpha", 0, 1).build();
+            mAllViews.add(mQsPanel.getFooter().getView());
             Path path = new Path();
             path.moveTo(0, 0);
             path.cubicTo(0, 0, 0, 1, 1, 1);
diff --git a/packages/SystemUI/src/com/android/systemui/qs/QSDetail.java b/packages/SystemUI/src/com/android/systemui/qs/QSDetail.java
index ee55a80..662b6a7 100644
--- a/packages/SystemUI/src/com/android/systemui/qs/QSDetail.java
+++ b/packages/SystemUI/src/com/android/systemui/qs/QSDetail.java
@@ -67,7 +67,7 @@
     private boolean mTriggeredExpand;
     private int mOpenX;
     private int mOpenY;
-    private boolean mAnimating;
+    private boolean mAnimatingOpen;
     private boolean mSwitchState;
 
     public QSDetail(Context context, @Nullable AttributeSet attrs) {
@@ -160,7 +160,7 @@
                 mQsDetailHeader.setClickable(false);
             } else {
                 mQsDetailHeaderSwitch.setVisibility(VISIBLE);
-                handleToggleStateChanged(toggleState);
+                handleToggleStateChanged(toggleState, adapter.getToggleEnabled());
                 mQsDetailHeader.setClickable(true);
                 mQsDetailHeader.setOnClickListener(new OnClickListener() {
                     @Override
@@ -230,7 +230,7 @@
         }
         sendAccessibilityEvent(AccessibilityEvent.TYPE_WINDOW_STATE_CHANGED);
         if (visibleDiff) {
-            mAnimating = true;
+            mAnimatingOpen = adapter != null;
             if (mFullyExpanded || mDetailAdapter != null) {
                 setAlpha(1);
                 mClipper.animateCircularClip(x, y, mDetailAdapter != null, listener);
@@ -243,13 +243,12 @@
         }
     }
 
-    private void handleToggleStateChanged(boolean state) {
+    private void handleToggleStateChanged(boolean state, boolean toggleEnabled) {
         mSwitchState = state;
-        if (mAnimating) {
+        if (mAnimatingOpen) {
             return;
         }
         mQsDetailHeaderSwitch.setChecked(state);
-        final boolean toggleEnabled = mDetailAdapter != null && mDetailAdapter.getToggleEnabled();
         mQsDetailHeader.setEnabled(toggleEnabled);
         mQsDetailHeaderSwitch.setEnabled(toggleEnabled);
     }
@@ -268,7 +267,8 @@
     }
 
     private void checkPendingAnimations() {
-        handleToggleStateChanged(mSwitchState);
+        handleToggleStateChanged(mSwitchState,
+                            mDetailAdapter != null && mDetailAdapter.getToggleEnabled());
     }
 
     private final QSPanel.Callback mQsPanelCallback = new QSPanel.Callback() {
@@ -277,7 +277,8 @@
             post(new Runnable() {
                 @Override
                 public void run() {
-                    handleToggleStateChanged(state);
+                    handleToggleStateChanged(state,
+                            mDetailAdapter != null && mDetailAdapter.getToggleEnabled());
                 }
             });
         }
@@ -308,7 +309,7 @@
             // If we have been cancelled, remove the listener so that onAnimationEnd doesn't get
             // called, this will avoid accidentally turning off the grid when we don't want to.
             animation.removeListener(this);
-            mAnimating = false;
+            mAnimatingOpen = false;
             checkPendingAnimations();
         };
 
@@ -319,7 +320,7 @@
                 mQsPanel.setGridContentVisibility(false);
                 mHeader.setVisibility(View.INVISIBLE);
             }
-            mAnimating = false;
+            mAnimatingOpen = false;
             checkPendingAnimations();
         }
     };
diff --git a/packages/SystemUI/src/com/android/systemui/qs/QSPanel.java b/packages/SystemUI/src/com/android/systemui/qs/QSPanel.java
index 890279f..ad5c9c0 100644
--- a/packages/SystemUI/src/com/android/systemui/qs/QSPanel.java
+++ b/packages/SystemUI/src/com/android/systemui/qs/QSPanel.java
@@ -23,7 +23,6 @@
 import android.os.Handler;
 import android.os.Message;
 import android.util.AttributeSet;
-import android.util.Log;
 import android.view.LayoutInflater;
 import android.view.View;
 import android.widget.ImageView;
@@ -505,6 +504,10 @@
         return null;
     }
 
+    public QSFooter getFooter() {
+        return mFooter;
+    }
+
     private class H extends Handler {
         private static final int SHOW_DETAIL = 1;
         private static final int SET_TILE_VISIBILITY = 2;
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/PanelView.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/PanelView.java
index e4aa103..af85101 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/PanelView.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/PanelView.java
@@ -209,6 +209,9 @@
 
     public void setTouchDisabled(boolean disabled) {
         mTouchDisabled = disabled;
+        if (mTouchDisabled && mTracking) {
+            onTrackingStopped(true /* expanded */);
+        }
     }
 
     @Override
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBar.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBar.java
index 482c698..34ce6d5 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBar.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBar.java
@@ -17,6 +17,19 @@
 package com.android.systemui.statusbar.phone;
 
 
+import static android.app.StatusBarManager.NAVIGATION_HINT_BACK_ALT;
+import static android.app.StatusBarManager.NAVIGATION_HINT_IME_SHOWN;
+import static android.app.StatusBarManager.WINDOW_STATE_HIDDEN;
+import static android.app.StatusBarManager.WINDOW_STATE_SHOWING;
+import static android.app.StatusBarManager.windowStateToString;
+import static com.android.systemui.statusbar.phone.BarTransitions.MODE_LIGHTS_OUT;
+import static com.android.systemui.statusbar.phone.BarTransitions.MODE_LIGHTS_OUT_TRANSPARENT;
+import static com.android.systemui.statusbar.phone.BarTransitions.MODE_OPAQUE;
+import static com.android.systemui.statusbar.phone.BarTransitions.MODE_SEMI_TRANSPARENT;
+import static com.android.systemui.statusbar.phone.BarTransitions.MODE_TRANSLUCENT;
+import static com.android.systemui.statusbar.phone.BarTransitions.MODE_TRANSPARENT;
+import static com.android.systemui.statusbar.phone.BarTransitions.MODE_WARNING;
+
 import android.animation.Animator;
 import android.animation.AnimatorListenerAdapter;
 import android.annotation.NonNull;
@@ -78,6 +91,7 @@
 import android.service.notification.NotificationListenerService;
 import android.service.notification.NotificationListenerService.RankingMap;
 import android.service.notification.StatusBarNotification;
+import android.telecom.TelecomManager;
 import android.util.ArraySet;
 import android.util.DisplayMetrics;
 import android.util.EventLog;
@@ -99,6 +113,7 @@
 import android.view.animation.Interpolator;
 import android.widget.ImageView;
 import android.widget.TextView;
+
 import com.android.internal.logging.MetricsLogger;
 import com.android.internal.logging.MetricsProto.MetricsEvent;
 import com.android.internal.statusbar.NotificationVisibility;
@@ -117,7 +132,6 @@
 import com.android.systemui.Prefs;
 import com.android.systemui.R;
 import com.android.systemui.SystemUIFactory;
-import com.android.systemui.assist.AssistManager;
 import com.android.systemui.classifier.FalsingLog;
 import com.android.systemui.classifier.FalsingManager;
 import com.android.systemui.doze.DozeHost;
@@ -172,7 +186,8 @@
 import com.android.systemui.statusbar.policy.UserSwitcherController;
 import com.android.systemui.statusbar.policy.ZenModeController;
 import com.android.systemui.statusbar.stack.NotificationStackScrollLayout;
-import com.android.systemui.statusbar.stack.NotificationStackScrollLayout.OnChildLocationsChangedListener;
+import com.android.systemui.statusbar.stack.NotificationStackScrollLayout
+        .OnChildLocationsChangedListener;
 import com.android.systemui.statusbar.stack.StackStateAnimator;
 import com.android.systemui.statusbar.stack.StackViewState;
 import com.android.systemui.volume.VolumeComponent;
@@ -186,19 +201,6 @@
 import java.util.List;
 import java.util.Map;
 
-import static android.app.StatusBarManager.NAVIGATION_HINT_BACK_ALT;
-import static android.app.StatusBarManager.NAVIGATION_HINT_IME_SHOWN;
-import static android.app.StatusBarManager.WINDOW_STATE_HIDDEN;
-import static android.app.StatusBarManager.WINDOW_STATE_SHOWING;
-import static android.app.StatusBarManager.windowStateToString;
-import static com.android.systemui.statusbar.phone.BarTransitions.MODE_LIGHTS_OUT;
-import static com.android.systemui.statusbar.phone.BarTransitions.MODE_LIGHTS_OUT_TRANSPARENT;
-import static com.android.systemui.statusbar.phone.BarTransitions.MODE_OPAQUE;
-import static com.android.systemui.statusbar.phone.BarTransitions.MODE_SEMI_TRANSPARENT;
-import static com.android.systemui.statusbar.phone.BarTransitions.MODE_TRANSLUCENT;
-import static com.android.systemui.statusbar.phone.BarTransitions.MODE_TRANSPARENT;
-import static com.android.systemui.statusbar.phone.BarTransitions.MODE_WARNING;
-
 public class PhoneStatusBar extends BaseStatusBar implements DemoMode,
         DragDownHelper.DragDownCallback, ActivityStarter, OnUnlockMethodChangedListener,
         HeadsUpManager.OnHeadsUpChangedListener, DisplayManager.DisplayListener {
@@ -1304,9 +1306,29 @@
     };
 
     private final View.OnTouchListener mHomeActionListener = new View.OnTouchListener() {
+        public boolean mBlockedThisTouch;
+
         @Override
         public boolean onTouch(View v, MotionEvent event) {
+            if (mBlockedThisTouch && event.getActionMasked() != MotionEvent.ACTION_DOWN) {
+                return true;
+            }
+            // If an incoming call is ringing, HOME is totally disabled.
+            // (The user is already on the InCallUI at this point,
+            // and his ONLY options are to answer or reject the call.)
             switch (event.getAction()) {
+                case MotionEvent.ACTION_DOWN:
+                    mBlockedThisTouch = false;
+                    TelecomManager telecomManager = mContext.getSystemService(TelecomManager.class);
+                    if (telecomManager != null && telecomManager.isRinging()) {
+                        if (mStatusBarKeyguardViewManager.isShowing()) {
+                            Log.i(TAG, "Ignoring HOME; there's a ringing incoming call. " +
+                                    "No heads up");
+                            mBlockedThisTouch = true;
+                            return true;
+                        }
+                    }
+                    break;
                 case MotionEvent.ACTION_UP:
                 case MotionEvent.ACTION_CANCEL:
                     awakenDreams();
@@ -1361,7 +1383,7 @@
 
         prepareNavigationBarView();
 
-        mWindowManager.updateViewLayout(mNavigationBarView, getNavigationBarLayoutParams());
+        mWindowManager.updateViewLayout(mNavigationBarView, mNavigationBarView.getLayoutParams());
     }
 
     private void notifyNavigationBarScreenOn(boolean screenOn) {
@@ -3500,7 +3522,6 @@
 
         repositionNavigationBar();
         updateRowStates();
-        mIconController.defineSlots();
         mScreenPinningRequest.onConfigurationChanged();
         mNetworkController.onConfigurationChanged();
     }
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBarIconController.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBarIconController.java
index 0c9bfab..3326736 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBarIconController.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBarIconController.java
@@ -112,6 +112,8 @@
 
     public StatusBarIconController(Context context, View statusBar, View keyguardStatusBar,
             PhoneStatusBar phoneStatusBar) {
+        super(context.getResources().getStringArray(
+                com.android.internal.R.array.config_statusBarIcons));
         mContext = context;
         mPhoneStatusBar = phoneStatusBar;
         mSystemIconArea = (LinearLayout) statusBar.findViewById(R.id.system_icon_area);
@@ -137,7 +139,6 @@
         mDarkModeIconColorSingleTone = context.getColor(R.color.dark_mode_icon_color_single_tone);
         mLightModeIconColorSingleTone = context.getColor(R.color.light_mode_icon_color_single_tone);
         mHandler = new Handler();
-        defineSlots();
         loadDimens();
 
         TunerService.get(mContext).addTunable(this, ICON_BLACKLIST);
@@ -197,11 +198,6 @@
                 R.dimen.status_bar_icon_padding);
     }
 
-    public void defineSlots() {
-        defineSlots(mContext.getResources().getStringArray(
-                com.android.internal.R.array.config_statusBarIcons));
-    }
-
     private void addSystemIcon(int index, StatusBarIcon icon) {
         String slot = getSlot(index);
         int viewIndex = getViewIndex(index);
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBarIconList.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBarIconList.java
index 6821879..660672d 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBarIconList.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBarIconList.java
@@ -25,14 +25,11 @@
     private ArrayList<String> mSlots = new ArrayList<>();
     private ArrayList<StatusBarIcon> mIcons = new ArrayList<>();
 
-    public void defineSlots(String[] slots) {
-        mSlots.clear();
+    public StatusBarIconList(String[] slots) {
         final int N = slots.length;
         for (int i=0; i < N; i++) {
             mSlots.add(slots[i]);
-            if (mIcons.size() < mSlots.size()) {
-                mIcons.add(null);
-            }
+            mIcons.add(null);
         }
     }
 
diff --git a/services/core/java/com/android/server/ConnectivityService.java b/services/core/java/com/android/server/ConnectivityService.java
index 051cb2d..1106262 100644
--- a/services/core/java/com/android/server/ConnectivityService.java
+++ b/services/core/java/com/android/server/ConnectivityService.java
@@ -1577,6 +1577,16 @@
                 "ConnectivityService");
     }
 
+    private void enforceConnectivityRestrictedNetworksPermission() {
+        try {
+            mContext.enforceCallingOrSelfPermission(
+                    android.Manifest.permission.CONNECTIVITY_USE_RESTRICTED_NETWORKS,
+                    "ConnectivityService");
+            return;
+        } catch (SecurityException e) { /* fallback to ConnectivityInternalPermission */ }
+        enforceConnectivityInternalPermission();
+    }
+
     private void enforceKeepalivePermission() {
         mContext.enforceCallingOrSelfPermission(KeepaliveTracker.PERMISSION, "ConnectivityService");
     }
@@ -4109,7 +4119,7 @@
 
     private void enforceNetworkRequestPermissions(NetworkCapabilities networkCapabilities) {
         if (networkCapabilities.hasCapability(NET_CAPABILITY_NOT_RESTRICTED) == false) {
-            enforceConnectivityInternalPermission();
+            enforceConnectivityRestrictedNetworksPermission();
         } else {
             enforceChangePermission();
         }
diff --git a/services/core/java/com/android/server/am/ActivityManagerService.java b/services/core/java/com/android/server/am/ActivityManagerService.java
index 236f083..8e4af12 100644
--- a/services/core/java/com/android/server/am/ActivityManagerService.java
+++ b/services/core/java/com/android/server/am/ActivityManagerService.java
@@ -8611,7 +8611,8 @@
             if (uri == null) {
                 owner.removeUriPermissionsLocked(mode);
             } else {
-                owner.removeUriPermissionLocked(new GrantUri(userId, uri, false), mode);
+                final boolean prefix = (mode & Intent.FLAG_GRANT_PREFIX_URI_PERMISSION) != 0;
+                owner.removeUriPermissionLocked(new GrantUri(userId, uri, prefix), mode);
             }
         }
     }
diff --git a/services/core/java/com/android/server/connectivity/PermissionMonitor.java b/services/core/java/com/android/server/connectivity/PermissionMonitor.java
index 22cefd1..7cd1b7b 100644
--- a/services/core/java/com/android/server/connectivity/PermissionMonitor.java
+++ b/services/core/java/com/android/server/connectivity/PermissionMonitor.java
@@ -18,6 +18,7 @@
 
 import static android.Manifest.permission.CHANGE_NETWORK_STATE;
 import static android.Manifest.permission.CONNECTIVITY_INTERNAL;
+import static android.Manifest.permission.CONNECTIVITY_USE_RESTRICTED_NETWORKS;
 import static android.content.pm.ApplicationInfo.FLAG_SYSTEM;
 import static android.content.pm.ApplicationInfo.FLAG_UPDATED_SYSTEM_APP;
 import static android.content.pm.PackageManager.GET_PERMISSIONS;
@@ -65,10 +66,10 @@
     private final BroadcastReceiver mIntentReceiver;
 
     // Values are User IDs.
-    private final Set<Integer> mUsers = new HashSet<Integer>();
+    private final Set<Integer> mUsers = new HashSet<>();
 
     // Keys are App IDs. Values are true for SYSTEM permission and false for NETWORK permission.
-    private final Map<Integer, Boolean> mApps = new HashMap<Integer, Boolean>();
+    private final Map<Integer, Boolean> mApps = new HashMap<>();
 
     public PermissionMonitor(Context context, INetworkManagementService netd) {
         mContext = context;
@@ -126,14 +127,14 @@
             }
 
             boolean isNetwork = hasNetworkPermission(app);
-            boolean isSystem = hasSystemPermission(app);
+            boolean hasRestrictedPermission = hasRestrictedNetworkPermission(app);
 
-            if (isNetwork || isSystem) {
+            if (isNetwork || hasRestrictedPermission) {
                 Boolean permission = mApps.get(uid);
                 // If multiple packages share a UID (cf: android:sharedUserId) and ask for different
                 // permissions, don't downgrade (i.e., if it's already SYSTEM, leave it as is).
                 if (permission == null || permission == NETWORK) {
-                    mApps.put(uid, isSystem);
+                    mApps.put(uid, hasRestrictedPermission);
                 }
             }
         }
@@ -164,12 +165,13 @@
         return hasPermission(app, CHANGE_NETWORK_STATE);
     }
 
-    private boolean hasSystemPermission(PackageInfo app) {
+    private boolean hasRestrictedNetworkPermission(PackageInfo app) {
         int flags = app.applicationInfo != null ? app.applicationInfo.flags : 0;
         if ((flags & FLAG_SYSTEM) != 0 || (flags & FLAG_UPDATED_SYSTEM_APP) != 0) {
             return true;
         }
-        return hasPermission(app, CONNECTIVITY_INTERNAL);
+        return hasPermission(app, CONNECTIVITY_INTERNAL)
+                || hasPermission(app, CONNECTIVITY_USE_RESTRICTED_NETWORKS);
     }
 
     private int[] toIntArray(List<Integer> list) {
@@ -181,8 +183,8 @@
     }
 
     private void update(Set<Integer> users, Map<Integer, Boolean> apps, boolean add) {
-        List<Integer> network = new ArrayList<Integer>();
-        List<Integer> system = new ArrayList<Integer>();
+        List<Integer> network = new ArrayList<>();
+        List<Integer> system = new ArrayList<>();
         for (Entry<Integer, Boolean> app : apps.entrySet()) {
             List<Integer> list = app.getValue() ? system : network;
             for (int user : users) {
@@ -209,7 +211,7 @@
         }
         mUsers.add(user);
 
-        Set<Integer> users = new HashSet<Integer>();
+        Set<Integer> users = new HashSet<>();
         users.add(user);
         update(users, mApps, true);
     }
@@ -221,7 +223,7 @@
         }
         mUsers.remove(user);
 
-        Set<Integer> users = new HashSet<Integer>();
+        Set<Integer> users = new HashSet<>();
         users.add(user);
         update(users, mApps, false);
     }
@@ -235,16 +237,16 @@
         try {
             PackageInfo app = mPackageManager.getPackageInfo(appName, GET_PERMISSIONS);
             boolean isNetwork = hasNetworkPermission(app);
-            boolean isSystem = hasSystemPermission(app);
-            if (isNetwork || isSystem) {
+            boolean hasRestrictedPermission = hasRestrictedNetworkPermission(app);
+            if (isNetwork || hasRestrictedPermission) {
                 Boolean permission = mApps.get(appUid);
                 // If multiple packages share a UID (cf: android:sharedUserId) and ask for different
                 // permissions, don't downgrade (i.e., if it's already SYSTEM, leave it as is).
                 if (permission == null || permission == NETWORK) {
-                    mApps.put(appUid, isSystem);
+                    mApps.put(appUid, hasRestrictedPermission);
 
-                    Map<Integer, Boolean> apps = new HashMap<Integer, Boolean>();
-                    apps.put(appUid, isSystem);
+                    Map<Integer, Boolean> apps = new HashMap<>();
+                    apps.put(appUid, hasRestrictedPermission);
                     update(mUsers, apps, true);
                 }
             }
@@ -260,7 +262,7 @@
         }
         mApps.remove(appUid);
 
-        Map<Integer, Boolean> apps = new HashMap<Integer, Boolean>();
+        Map<Integer, Boolean> apps = new HashMap<>();
         apps.put(appUid, NETWORK);  // doesn't matter which permission we pick here
         update(mUsers, apps, false);
     }
diff --git a/services/core/java/com/android/server/policy/PhoneWindowManager.java b/services/core/java/com/android/server/policy/PhoneWindowManager.java
index fbc727d..490ff9e 100644
--- a/services/core/java/com/android/server/policy/PhoneWindowManager.java
+++ b/services/core/java/com/android/server/policy/PhoneWindowManager.java
@@ -3061,15 +3061,6 @@
                     return -1;
                 }
 
-                // If an incoming call is ringing, HOME is totally disabled.
-                // (The user is already on the InCallUI at this point,
-                // and his ONLY options are to answer or reject the call.)
-                TelecomManager telecomManager = getTelecommService();
-                if (telecomManager != null && telecomManager.isRinging()) {
-                    Log.i(TAG, "Ignoring HOME; there's a ringing incoming call.");
-                    return -1;
-                }
-
                 // Delay handling home if a double-tap is possible.
                 if (mDoubleTapOnHomeBehavior != DOUBLE_TAP_HOME_NOTHING) {
                     mHandler.removeCallbacks(mHomeDoubleTapTimeoutRunnable); // just in case
diff --git a/services/core/java/com/android/server/search/SearchManagerService.java b/services/core/java/com/android/server/search/SearchManagerService.java
index 2e5eb3a..f3b9b18 100644
--- a/services/core/java/com/android/server/search/SearchManagerService.java
+++ b/services/core/java/com/android/server/search/SearchManagerService.java
@@ -141,7 +141,12 @@
     }
 
     private void onUnlockUser(int userId) {
-        getSearchables(userId, true);
+        try {
+            getSearchables(userId, true);
+        } catch (IllegalStateException ignored) {
+            // We're just trying to warm a cache, so we don't mind if the user
+            // was stopped or destroyed before we got here.
+        }
     }
 
     private void onCleanupUser(int userId) {
diff --git a/services/net/java/android/net/apf/ApfFilter.java b/services/net/java/android/net/apf/ApfFilter.java
index 0f812ac..4bb0902 100644
--- a/services/net/java/android/net/apf/ApfFilter.java
+++ b/services/net/java/android/net/apf/ApfFilter.java
@@ -192,6 +192,7 @@
 
     private static final int ICMP6_TYPE_OFFSET = ETH_HEADER_LEN + IPV6_HEADER_LEN;
     private static final int ICMP6_NEIGHBOR_ANNOUNCEMENT = 136;
+    private static final int ICMP6_ROUTER_ADVERTISEMENT = 134;
 
     // NOTE: this must be added to the IPv4 header length in IPV4_HEADER_SIZE_MEMORY_SLOT
     private static final int UDP_DESTINATION_PORT_OFFSET = ETH_HEADER_LEN + 2;
@@ -452,6 +453,16 @@
         Ra(byte[] packet, int length) {
             mPacket = ByteBuffer.wrap(Arrays.copyOf(packet, length));
             mLastSeen = curTime();
+
+            // Sanity check packet in case a packet arrives before we attach RA filter
+            // to our packet socket. b/29586253
+            if (getUint16(mPacket, ETH_ETHERTYPE_OFFSET) != ETH_P_IPV6 ||
+                    uint8(mPacket.get(IPV6_NEXT_HEADER_OFFSET)) != IPPROTO_ICMPV6 ||
+                    uint8(mPacket.get(ICMP6_TYPE_OFFSET)) != ICMP6_ROUTER_ADVERTISEMENT) {
+                throw new IllegalArgumentException("Not an ICMP6 router advertisement");
+            }
+
+
             RaEvent.Builder builder = new RaEvent.Builder();
 
             // Ignore the checksum.
diff --git a/services/usb/java/com/android/server/usb/UsbDeviceManager.java b/services/usb/java/com/android/server/usb/UsbDeviceManager.java
index df9242d..1d19637 100644
--- a/services/usb/java/com/android/server/usb/UsbDeviceManager.java
+++ b/services/usb/java/com/android/server/usb/UsbDeviceManager.java
@@ -49,6 +49,7 @@
 import android.util.Slog;
 
 import com.android.internal.annotations.GuardedBy;
+import com.android.internal.os.SomeArgs;
 import com.android.internal.util.IndentingPrintWriter;
 import com.android.server.FgThread;
 
@@ -320,6 +321,7 @@
         private boolean mConnected;
         private boolean mHostConnected;
         private boolean mSourcePower;
+        private boolean mSinkPower;
         private boolean mConfigured;
         private boolean mUsbDataUnlocked;
         private String mCurrentFunctions;
@@ -401,7 +403,19 @@
         public void updateHostState(UsbPort port, UsbPortStatus status) {
             boolean hostConnected = status.getCurrentDataRole() == UsbPort.DATA_ROLE_HOST;
             boolean sourcePower = status.getCurrentPowerRole() == UsbPort.POWER_ROLE_SOURCE;
-            obtainMessage(MSG_UPDATE_HOST_STATE, hostConnected ? 1 :0, sourcePower ? 1 :0).sendToTarget();
+            boolean sinkPower = status.getCurrentPowerRole() == UsbPort.POWER_ROLE_SINK;
+
+            if (DEBUG) {
+                Slog.i(TAG, "updateHostState " + port + ": dataRole=" + status.getCurrentDataRole() +
+                        ", powerRole=" + status.getCurrentPowerRole());
+            }
+
+            SomeArgs args = SomeArgs.obtain();
+            args.argi1 = hostConnected ? 1 :0;
+            args.argi2 = sourcePower ? 1 :0;
+            args.argi3 = sinkPower ? 1 :0;
+
+            obtainMessage(MSG_UPDATE_HOST_STATE, args).sendToTarget();
         }
 
         private boolean waitForState(String state) {
@@ -718,8 +732,11 @@
                     }
                     break;
                 case MSG_UPDATE_HOST_STATE:
-                    mHostConnected = (msg.arg1 == 1);
-                    mSourcePower = (msg.arg2 == 1);
+                    SomeArgs args = (SomeArgs) msg.obj;
+                    mHostConnected = (args.argi1 == 1);
+                    mSourcePower = (args.argi2 == 1);
+                    mSinkPower = (args.argi3 == 1);
+                    args.recycle();
                     updateUsbNotification();
                     if (mBootCompleted) {
                         updateUsbStateBroadcastIfNeeded();
@@ -809,6 +826,8 @@
                 }
             } else if (mSourcePower) {
                 id = com.android.internal.R.string.usb_supplying_notification_title;
+            } else if (mSinkPower) {
+                id = com.android.internal.R.string.usb_charging_notification_title;
             }
             if (id != mUsbNotificationId) {
                 // clear notification if title needs changing
diff --git a/telephony/java/android/telephony/Rlog.java b/telephony/java/android/telephony/Rlog.java
index 2a7f7af..b4f400f 100644
--- a/telephony/java/android/telephony/Rlog.java
+++ b/telephony/java/android/telephony/Rlog.java
@@ -85,5 +85,13 @@
         return Log.isLoggable(tag, level);
     }
 
+    /**
+     * Redact personally identifiable information for production users.
+     * If log tag is loggable in verbose mode, return the original string, otherwise return XXX.
+     */
+    public static String pii(String tag, Object pii) {
+        return (isLoggable(tag, Log.VERBOSE) ? String.valueOf(pii) : "XXX");
+    }
+
 }