Merge "Doc change: fix broken links to logcat info." into jb-dev
diff --git a/core/java/android/app/Notification.java b/core/java/android/app/Notification.java
index 8220fd9..ceb8cde 100644
--- a/core/java/android/app/Notification.java
+++ b/core/java/android/app/Notification.java
@@ -1367,7 +1367,9 @@
         public Builder setStyle(Style style) {
             if (mStyle != style) {
                 mStyle = style;
-                mStyle.setBuilder(this);
+                if (mStyle != null) {
+                    mStyle.setBuilder(this);
+                }
             }
             return this;
         }
@@ -1637,7 +1639,9 @@
         public void setBuilder(Builder builder) {
             if (mBuilder != builder) {
                 mBuilder = builder;
-                mBuilder.setStyle(this);
+                if (mBuilder != null) {
+                    mBuilder.setStyle(this);
+                }
             }
         }
 
diff --git a/core/res/res/values-da/strings.xml b/core/res/res/values-da/strings.xml
index 8c6dd5c..443f828 100644
--- a/core/res/res/values-da/strings.xml
+++ b/core/res/res/values-da/strings.xml
@@ -1282,10 +1282,8 @@
     <string name="SetupCallDefault" msgid="5834948469253758575">"Vil du besvare opkaldet?"</string>
     <string name="activity_resolver_use_always" msgid="8017770747801494933">"Altid"</string>
     <string name="activity_resolver_use_once" msgid="2404644797149173758">"Kun én gang"</string>
-    <!-- no translation found for default_audio_route_name (4617053898167127471) -->
-    <skip />
-    <!-- no translation found for default_audio_route_name (4239291273420140123) -->
-    <skip />
+    <string name="default_audio_route_name" product="tablet" msgid="4617053898167127471">"Tablet"</string>
+    <string name="default_audio_route_name" product="default" msgid="4239291273420140123">"Telefon"</string>
     <string name="default_audio_route_name_headphones" msgid="8119971843803439110">"Hovedtelefoner"</string>
     <string name="default_audio_route_name_dock_speakers" msgid="6240602982276591864">"Dockstationens højttalere"</string>
     <string name="default_audio_route_name_hdmi" msgid="7986404173839007682">"HDMI-lyd"</string>
diff --git a/docs/html/about/versions/jelly-bean.jd b/docs/html/about/versions/jelly-bean.jd
index 32b2310..18b3ff6 100644
--- a/docs/html/about/versions/jelly-bean.jd
+++ b/docs/html/about/versions/jelly-bean.jd
@@ -121,7 +121,7 @@
 <div style="float:right;margin:22px 0px 0px 24px;width:280px;">
 <div>
 <!-- <img src="{@docRoot}images/jd-notif-cd.png" style="width:200px"> -->
-<img src="{@docRoot}images/jb-notif-ex.png" width="280" height="548">
+<img src="{@docRoot}images/jb-notif-ex1.png" width="280" height="548">
 </div>
 <p class="image-caption" style="padding:.5em">Developers can create custom notification styles
 like those shown in the examples above to display rich content and actions.</p>
@@ -147,8 +147,6 @@
 
 <p>With expandable notifications, apps can give more information to the user, effortlessly and on demand. Users remain in control and can long-press any notification to get information about the sender and optionally  disable further notifications from the app.</p>
 
-</div>
-
 <div style="float:left;margin:66px 30px 0px 0px;width:280px;">
 <div>
 <img src="{@docRoot}images/jb-appwidgets.png" width="280" height="548">
diff --git a/docs/html/guide/google/play/services.jd b/docs/html/guide/google/play/services.jd
index e88d31f..519d78b 100644
--- a/docs/html/guide/google/play/services.jd
+++ b/docs/html/guide/google/play/services.jd
@@ -15,9 +15,8 @@
     tedious authentication flows. A few clicks from the user and you're set!
     <br /> <a href="https://developers.google.com/android/google-play-services">Learn more &raquo;</a>
  </li>
-    <li style="border-top: 1px solid #F80;"><h5>Google+ Integration</h5>Google Play Services lets you
-    	read from and write to your user's Google+ activity stream, giving your
-    	app an easy way to integrate with Google+.
+    <li style="border-top: 1px solid #F80;"><h5>Google+ Integration</h5> Google Play services makes it
+        easy for your app to integrate with Sign in with Google+, +1 button, and Google+ history.
     <br /> <a href="https://developers.google.com/android/google-play-services">Learn more &raquo;</a>
     </li>
   </ul>
diff --git a/docs/html/images/jb-notif-ex.png b/docs/html/images/jb-notif-ex.png
index 477cc45..c1470fe 100644
--- a/docs/html/images/jb-notif-ex.png
+++ b/docs/html/images/jb-notif-ex.png
Binary files differ
diff --git a/docs/html/images/jb-notif-ex1.png b/docs/html/images/jb-notif-ex1.png
new file mode 100644
index 0000000..a960ab9
--- /dev/null
+++ b/docs/html/images/jb-notif-ex1.png
Binary files differ
diff --git a/docs/html/sdk/index.jd b/docs/html/sdk/index.jd
index 02f8d6e..0038fac 100644
--- a/docs/html/sdk/index.jd
+++ b/docs/html/sdk/index.jd
@@ -50,8 +50,8 @@
 
 <!-- this appears when viewing the online docs -->
 <div class="online">
-<a class="big button disabled" id="download-button" href="" >Sorry, the SDK does not support
-your OS</a>
+<a class="big button" id="download-button" href="" style="display:none" ></a>
+<p id="not-supported">Choose the SDK package for your OS from the table below.</p>
 
 <p style="margin-top:20px;font-size:12px"><a href='' onclick="
   if ($('.pax').is(':visible')) {
diff --git a/docs/html/tools/adk/adk2.jd b/docs/html/tools/adk/adk2.jd
index 6ee4a46..d0d8831 100644
--- a/docs/html/tools/adk/adk2.jd
+++ b/docs/html/tools/adk/adk2.jd
@@ -257,28 +257,34 @@
 
 <h3 id="dev-setup">Setting Up the Development Environment</h3>
 
-<p>The ADK 2012 source code repository includes an integrated development environment (IDE) that you
-can use to develop software for and program the ADK 2012 accessory. The following instructions
-explain how to build and run the ADK 2012 IDE.</p>
+<p>The ADK 2012 comes with an integrated development environment (IDE) that you use to develop
+software and program the ADK 2012 accessory. The following instructions explain how to setup and run
+the ADK 2012 IDE.</p>
 
-<p>To set up, build and run the ADK 2012 IDE:</p>
+<p>To set up and run the ADK 2012 IDE:</p>
 
 <ol>
-  <li><a href="#src-download">Download</a> the ADK 2012 source code files.</li>
   <li>Download and install the Java Development Kit 6 or higher from <a
-href="http://java.oracle.com">java.oracle.com</a>.</li>
-  <li>Download and install <a href="http://ant.apache.org/">Apache Ant</a>.</li>
-  <li>In a terminal window, navigate to {@code &lt;adk-source-download&gt;/external/ide/build}
-and execute the following command to build the ADK 2012 IDE:
-<pre>$> ant</pre>
+    href="http://java.oracle.com">java.oracle.com</a>.</li>
+  <li>Download the ADK 2012 IDE for your development platform:
+    <ul>
+      <li><a href="https://dl-ssl.google.com/android/adk/adk2012_ide-win32-20120626.zip">
+          Windows</a></li>
+      <li><a href="https://dl-ssl.google.com/android/adk/adk2012_ide-macosx-20120626.zip">
+          Mac</a></li>
+      <li>Linux
+        <a href="https://dl-ssl.google.com/android/adk/adk2012_ide-linux32-20120626.tgz">32bit</a>,
+        <a href="https://dl-ssl.google.com/android/adk/adk2012_ide-linux64-20120626.tgz">64bit</a>
+      </li>
+    </ul>
   </li>
-  <li>After the build successfully completes, execute the following command to run the ADK 2012
-IDE:
-<pre>$> ant run</pre></li>
+  <li>Unpack the downloaded archive.</li>
+  <li>Run the application by navigating to the unpacked {@code ADK2012_IDE/} folder and execute
+    the {@code arduino} file.</li>
 </ol>
 
-<p>After you have successfully built and run the ADK 2012 IDE, you must configure it to use the 
-ADK 2012 library.</p>
+<p>After you have successfully installed and run the ADK 2012 IDE, you must configure it to use
+the ADK 2012 library.</p>
 
 <p>To configure the ADK 2012 IDE for use with the ADK libraries:</p>
 
diff --git a/media/java/android/media/MediaCodec.java b/media/java/android/media/MediaCodec.java
index fcb676d..560c549 100644
--- a/media/java/android/media/MediaCodec.java
+++ b/media/java/android/media/MediaCodec.java
@@ -33,7 +33,7 @@
  * codec.start();
  * ByteBuffer[] inputBuffers = codec.getInputBuffers();
  * ByteBuffer[] outputBuffers = codec.getOutputBuffers();
- * Map<String, Object> format = codec.getOutputFormat();
+ * MediaFormat format = codec.getOutputFormat();
  * for (;;) {
  *   int inputBufferIndex = codec.dequeueInputBuffer(timeoutUs);
  *   if (inputBufferIndex &gt;= 0) {
diff --git a/media/java/android/media/MediaExtractor.java b/media/java/android/media/MediaExtractor.java
index d3a00c2..9f10cb0 100644
--- a/media/java/android/media/MediaExtractor.java
+++ b/media/java/android/media/MediaExtractor.java
@@ -36,8 +36,8 @@
  * extractor.setDataSource(...);
  * int numTracks = extractor.getTrackCount();
  * for (int i = 0; i &lt; numTracks; ++i) {
- *   Map%lt;String, Object&gt; format = extractor.getTrackFormat(i);
- *   String mime = (String)format.get("mime");
+ *   MediaFormat format = extractor.getTrackFormat(i);
+ *   String mime = format.getString(MediaFormat.KEY_MIME);
  *   if (weAreInterestedInThisTrack) {
  *     extractor.selectTrack(i);
  *   }
diff --git a/packages/SystemUI/src/com/android/systemui/SwipeHelper.java b/packages/SystemUI/src/com/android/systemui/SwipeHelper.java
index 2d65dd6..ceb8654 100644
--- a/packages/SystemUI/src/com/android/systemui/SwipeHelper.java
+++ b/packages/SystemUI/src/com/android/systemui/SwipeHelper.java
@@ -322,6 +322,9 @@
         }
 
         if (!mDragging) {
+            // We are not doing anything, make sure the long press callback
+            // is not still ticking like a bomb waiting to go off.
+            removeLongPressCallback();
             return false;
         }
 
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/BaseStatusBar.java b/packages/SystemUI/src/com/android/systemui/statusbar/BaseStatusBar.java
index 0866d18..ec99513 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/BaseStatusBar.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/BaseStatusBar.java
@@ -907,8 +907,14 @@
             if (DEBUG) Slog.d(TAG, "contents was " + (contentsUnchanged ? "unchanged" : "changed"));
             if (DEBUG) Slog.d(TAG, "order was " + (orderUnchanged ? "unchanged" : "changed"));
             if (DEBUG) Slog.d(TAG, "notification is " + (isTopAnyway ? "top" : "not top"));
+            final boolean wasExpanded = oldEntry.userExpanded();
             removeNotificationViews(key);
             addNotificationViews(key, notification);
+            if (wasExpanded) {
+                final NotificationData.Entry newEntry = mNotificationData.findByKey(key);
+                expandView(newEntry, true);
+                newEntry.setUserExpanded(true);
+            }
         }
 
         // Update the veto button accordingly (and as a result, whether this row is
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/NotificationData.java b/packages/SystemUI/src/com/android/systemui/statusbar/NotificationData.java
index 1a07ed3..dfd8cf8 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/NotificationData.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/NotificationData.java
@@ -65,6 +65,12 @@
         public boolean userExpanded() {
             return NotificationData.getUserExpanded(row);
         }
+        /**
+         * Set the flag indicating that this was manually expanded by the user.
+         */
+        public boolean setUserExpanded(boolean userExpanded) {
+            return NotificationData.setUserExpanded(row, userExpanded);
+        }
     }
     private final ArrayList<Entry> mEntries = new ArrayList<Entry>();
     private final Comparator<Entry> mEntryCmp = new Comparator<Entry>() {
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/tablet/TabletStatusBar.java b/packages/SystemUI/src/com/android/systemui/statusbar/tablet/TabletStatusBar.java
index 5cab636..f947369 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/tablet/TabletStatusBar.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/tablet/TabletStatusBar.java
@@ -1658,6 +1658,7 @@
 
     @Override
     protected boolean isTopNotification(ViewGroup parent, NotificationData.Entry entry) {
+        if (parent == null || entry == null) return false;
         return parent.indexOfChild(entry.row) == parent.getChildCount()-1;
     }
 
diff --git a/services/java/com/android/server/PowerManagerService.java b/services/java/com/android/server/PowerManagerService.java
index c32f1da..24c59a5 100644
--- a/services/java/com/android/server/PowerManagerService.java
+++ b/services/java/com/android/server/PowerManagerService.java
@@ -1238,7 +1238,7 @@
                     + " mLightSensorKeyboardBrightness=" + mLightSensorKeyboardBrightness);
             pw.println("  mUseSoftwareAutoBrightness=" + mUseSoftwareAutoBrightness);
             pw.println("  mAutoBrightessEnabled=" + mAutoBrightessEnabled);
-            mScreenBrightnessAnimator.dump(pw, "  mScreenBrightnessAnimator: ");
+            mScreenBrightnessAnimator.dump(pw, "mScreenBrightnessAnimator: ");
 
             int N = mLocks.size();
             pw.println();
@@ -2303,8 +2303,9 @@
                     + ", duration:" + duration + ", current:" + currentValue);
             pw.println("  startSensorValue:" + startSensorValue
                     + " endSensorValue:" + endSensorValue);
-            pw.println("  startSensorValue:" + startSensorValue
-                    + " endSensorValue:" + endSensorValue);
+            pw.println("  startTimeMillis:" + startTimeMillis
+                    + " now:" + SystemClock.elapsedRealtime());
+            pw.println("  currentMask:" + dumpPowerState(currentMask));
         }
 
         public void animateTo(int target, int mask, int animationDuration) {
diff --git a/services/java/com/android/server/am/ActivityManagerService.java b/services/java/com/android/server/am/ActivityManagerService.java
index f482552..95d3c41 100644
--- a/services/java/com/android/server/am/ActivityManagerService.java
+++ b/services/java/com/android/server/am/ActivityManagerService.java
@@ -5704,12 +5704,19 @@
 
         if (killProcesses) {
             // Find any running processes associated with this app.
+            final String pkg = component.getPackageName();
             ArrayList<ProcessRecord> procs = new ArrayList<ProcessRecord>();
-            SparseArray<ProcessRecord> appProcs
-                    = mProcessNames.getMap().get(component.getPackageName());
-            if (appProcs != null) {
-                for (int i=0; i<appProcs.size(); i++) {
-                    procs.add(appProcs.valueAt(i));
+            HashMap<String, SparseArray<ProcessRecord>> pmap = mProcessNames.getMap();
+            for (SparseArray<ProcessRecord> uids : pmap.values()) {
+                for (int i=0; i<uids.size(); i++) {
+                    ProcessRecord proc = uids.valueAt(i);
+                    if (proc.userId != tr.userId) {
+                        continue;
+                    }
+                    if (!proc.pkgList.contains(pkg)) {
+                        continue;
+                    }
+                    procs.add(proc);
                 }
             }
 
@@ -5720,6 +5727,7 @@
                     Slog.i(TAG, "Killing " + pr.toShortString() + ": remove task");
                     EventLog.writeEvent(EventLogTags.AM_KILL, pr.pid,
                             pr.processName, pr.setAdj, "remove task");
+                    pr.killedBackground = true;
                     Process.killProcessQuiet(pr.pid);
                 } else {
                     pr.waitingToKill = "remove task";
@@ -14634,6 +14642,7 @@
                 Slog.i(TAG, "Killing " + app.toShortString() + ": " + app.waitingToKill);
                 EventLog.writeEvent(EventLogTags.AM_KILL, app.pid,
                         app.processName, app.setAdj, app.waitingToKill);
+                app.killedBackground = true;
                 Process.killProcessQuiet(app.pid);
                 success = false;
             } else {
diff --git a/services/java/com/android/server/am/ActivityStack.java b/services/java/com/android/server/am/ActivityStack.java
index b276494..9171e47 100755
--- a/services/java/com/android/server/am/ActivityStack.java
+++ b/services/java/com/android/server/am/ActivityStack.java
@@ -2347,6 +2347,9 @@
         while (i > 0) {
             i--;
             ActivityRecord candidate = mHistory.get(i);
+            if (candidate.finishing) {
+                continue;
+            }
             if (candidate.task.taskId != task) {
                 break;
             }
@@ -4057,7 +4060,7 @@
                 int index = indexOfActivityLocked(r);
                 if (index >= 0) {
                     if (r.state == ActivityState.DESTROYING) {
-                        cleanUpActivityLocked(r, true, true);
+                        cleanUpActivityLocked(r, true, false);
                         removeActivityFromHistoryLocked(r);
                     }
                 }