Merge "Import translations. DO NOT MERGE" into lmp-mr1-dev
diff --git a/core/java/android/app/ApplicationErrorReport.java b/core/java/android/app/ApplicationErrorReport.java
index 8b132e0..be4e80e 100644
--- a/core/java/android/app/ApplicationErrorReport.java
+++ b/core/java/android/app/ApplicationErrorReport.java
@@ -27,6 +27,7 @@
 import android.os.SystemProperties;
 import android.provider.Settings;
 import android.util.Printer;
+import android.util.Slog;
 import com.android.internal.util.FastPrintWriter;
 
 import java.io.PrintWriter;
@@ -378,6 +379,7 @@
          * Save a CrashInfo instance to a parcel.
          */
         public void writeToParcel(Parcel dest, int flags) {
+            int start = dest.dataPosition();
             dest.writeString(exceptionClassName);
             dest.writeString(exceptionMessage);
             dest.writeString(throwFileName);
@@ -385,6 +387,16 @@
             dest.writeString(throwMethodName);
             dest.writeInt(throwLineNumber);
             dest.writeString(stackTrace);
+            int total = dest.dataPosition()-start;
+            if (total > 100*1024) {
+                Slog.d("Error", "ERR: exClass=" + exceptionClassName);
+                Slog.d("Error", "ERR: exMsg=" + exceptionMessage);
+                Slog.d("Error", "ERR: file=" + throwFileName);
+                Slog.d("Error", "ERR: class=" + throwClassName);
+                Slog.d("Error", "ERR: method=" + throwMethodName + " line=" + throwLineNumber);
+                Slog.d("Error", "ERR: stack=" + stackTrace);
+                Slog.d("Error", "ERR: TOTAL BYTES WRITTEN: " + (dest.dataPosition()-start));
+            }
         }
 
         /**
diff --git a/core/java/android/os/Binder.java b/core/java/android/os/Binder.java
index cb5a31c..f5fc0d7 100644
--- a/core/java/android/os/Binder.java
+++ b/core/java/android/os/Binder.java
@@ -49,6 +49,7 @@
      * of classes can potentially create leaks.
      */
     private static final boolean FIND_POTENTIAL_LEAKS = false;
+    private static final boolean CHECK_PARCEL_SIZE = false;
     static final String TAG = "Binder";
 
     /**
@@ -388,7 +389,7 @@
     }
 
     static void checkParcel(IBinder obj, int code, Parcel parcel, String msg) {
-        if (parcel.dataSize() >= 800*1024) {
+        if (CHECK_PARCEL_SIZE && parcel.dataSize() >= 800*1024) {
             // Trying to send > 800k, this is way too much
             StringBuilder sb = new StringBuilder();
             sb.append(msg);
diff --git a/core/java/android/os/StrictMode.java b/core/java/android/os/StrictMode.java
index ea71ad8..4e9d1f0 100644
--- a/core/java/android/os/StrictMode.java
+++ b/core/java/android/os/StrictMode.java
@@ -28,6 +28,7 @@
 import android.util.Log;
 import android.util.Printer;
 import android.util.Singleton;
+import android.util.Slog;
 import android.view.IWindowManager;
 
 import com.android.internal.os.RuntimeInit;
@@ -40,6 +41,7 @@
 import java.io.PrintWriter;
 import java.io.StringWriter;
 import java.util.ArrayList;
+import java.util.Arrays;
 import java.util.HashMap;
 import java.util.Map;
 import java.util.concurrent.atomic.AtomicInteger;
@@ -1688,7 +1690,13 @@
         } else {
             p.writeInt(violations.size());
             for (int i = 0; i < violations.size(); ++i) {
+                int start = p.dataPosition();
                 violations.get(i).writeToParcel(p, 0 /* unused flags? */);
+                int size = p.dataPosition()-start;
+                if (size > 100*1024) {
+                    Slog.d(TAG, "Wrote violation #" + i + " of " + violations.size() + ": "
+                            + (p.dataPosition()-start) + " bytes");
+                }
             }
             if (LOG_V) Log.d(TAG, "wrote violations to response parcel; num=" + violations.size());
             violations.clear(); // somewhat redundant, as we're about to null the threadlocal
@@ -2176,6 +2184,7 @@
          */
         public void writeToParcel(Parcel dest, int flags) {
             crashInfo.writeToParcel(dest, flags);
+            int start = dest.dataPosition();
             dest.writeInt(policy);
             dest.writeInt(durationMillis);
             dest.writeInt(violationNumThisLoop);
@@ -2184,6 +2193,17 @@
             dest.writeLong(numInstances);
             dest.writeString(broadcastIntentAction);
             dest.writeStringArray(tags);
+            int total = dest.dataPosition()-start;
+            if (total > 100*1024) {
+                Slog.d(TAG, "VIO: policy=" + policy + " dur=" + durationMillis
+                        + " numLoop=" + violationNumThisLoop
+                        + " anim=" + numAnimationsRunning
+                        + " uptime=" + violationUptimeMillis
+                        + " numInst=" + numInstances);
+                Slog.d(TAG, "VIO: action=" + broadcastIntentAction);
+                Slog.d(TAG, "VIO: tags=" + Arrays.toString(tags));
+                Slog.d(TAG, "VIO: TOTAL BYTES WRITTEN: " + (dest.dataPosition()-start));
+            }
         }
 
 
diff --git a/core/java/com/android/internal/os/BatteryStatsImpl.java b/core/java/com/android/internal/os/BatteryStatsImpl.java
index 81705be..42fc613 100644
--- a/core/java/com/android/internal/os/BatteryStatsImpl.java
+++ b/core/java/com/android/internal/os/BatteryStatsImpl.java
@@ -6748,6 +6748,9 @@
                     || getLowDischargeAmountSinceCharge() >= 60)
                     || (getHighDischargeAmountSinceCharge() >= 60
                             && mHistoryBuffer.dataSize() >= MAX_HISTORY_BUFFER)) {
+                Slog.i(TAG, "Resetting battery stats: level=" + level + " status=" + oldStatus
+                        + " lowAmount=" + getLowDischargeAmountSinceCharge()
+                        + " highAmount=" + getHighDischargeAmountSinceCharge());
                 // Before we write, collect a snapshot of the final aggregated
                 // stats to be reported in the next checkin.  Only do this if we have
                 // a sufficient amount of data to make it interesting.
diff --git a/core/jni/android/graphics/BitmapFactory.cpp b/core/jni/android/graphics/BitmapFactory.cpp
index 8ea28ec..e0abc24 100644
--- a/core/jni/android/graphics/BitmapFactory.cpp
+++ b/core/jni/android/graphics/BitmapFactory.cpp
@@ -478,7 +478,7 @@
 
     NPE_CHECK_RETURN_ZERO(env, fileDescriptor);
 
-    jint descriptor = jniGetFDFromFileDescriptor(env, fileDescriptor);
+    int descriptor = jniGetFDFromFileDescriptor(env, fileDescriptor);
 
     struct stat fdStat;
     if (fstat(descriptor, &fdStat) == -1) {
@@ -486,16 +486,27 @@
         return nullObjectReturn("fstat return -1");
     }
 
-    // Restore the descriptor's offset on exiting this function.
+    // Restore the descriptor's offset on exiting this function. Even though
+    // we dup the descriptor, both the original and dup refer to the same open
+    // file description and changes to the file offset in one impact the other.
     AutoFDSeek autoRestore(descriptor);
 
-    FILE* file = fdopen(descriptor, "r");
+    // Duplicate the descriptor here to prevent leaking memory. A leak occurs
+    // if we only close the file descriptor and not the file object it is used to
+    // create.  If we don't explicitly clean up the file (which in turn closes the
+    // descriptor) the buffers allocated internally by fseek will be leaked.
+    int dupDescriptor = dup(descriptor);
+
+    FILE* file = fdopen(dupDescriptor, "r");
     if (file == NULL) {
+        // cleanup the duplicated descriptor since it will not be closed when the
+        // file is cleaned up (fclose).
+        close(dupDescriptor);
         return nullObjectReturn("Could not open file");
     }
 
     SkAutoTUnref<SkFILEStream> fileStream(new SkFILEStream(file,
-                         SkFILEStream::kCallerRetains_Ownership));
+                         SkFILEStream::kCallerPasses_Ownership));
 
     // Use a buffered stream. Although an SkFILEStream can be rewound, this
     // ensures that SkImageDecoder::Factory never rewinds beyond the
diff --git a/core/res/res/layout/breadcrumbs_in_fragment_material.xml b/core/res/res/layout/breadcrumbs_in_fragment_material.xml
new file mode 100644
index 0000000..96c0144
--- /dev/null
+++ b/core/res/res/layout/breadcrumbs_in_fragment_material.xml
@@ -0,0 +1,22 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Copyright (C) 2014 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.
+-->
+
+<!-- This layout disables breadcrumbs in the fragment area and causes PreferenceActivity to
+    put the breadcrumbs in the action bar. -->
+<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
+    android:layout_width="0dip"
+    android:layout_height="0dip"
+    android:visibility="gone" />
diff --git a/core/res/res/values/dimens.xml b/core/res/res/values/dimens.xml
index 7a2bbc1..824ed9e 100644
--- a/core/res/res/values/dimens.xml
+++ b/core/res/res/values/dimens.xml
@@ -380,7 +380,7 @@
     <dimen name="datepicker_month_day_label_text_size">12sp</dimen>
     <dimen name="datepicker_month_list_item_header_height">48dp</dimen>
     <dimen name="datepicker_day_number_select_circle_radius">16dp</dimen>
-    <dimen name="datepicker_view_animator_height">250dp</dimen>
+    <dimen name="datepicker_view_animator_height">244dp</dimen>
 
     <dimen name="datepicker_year_picker_padding_top">8dp</dimen>
     <dimen name="datepicker_year_label_height">64dp</dimen>
diff --git a/docs/html/google/play/billing/billing_overview.jd b/docs/html/google/play/billing/billing_overview.jd
index 12f8c9a..1c20d78 100644
--- a/docs/html/google/play/billing/billing_overview.jd
+++ b/docs/html/google/play/billing/billing_overview.jd
@@ -7,11 +7,11 @@
 <div id="qv">
   <h2>Quickview</h2>
   <ul>
-    <li>Use In-app Billing to sell digital goods, including one-time items and 
+    <li>Use In-app Billing to sell digital goods, including one-time items and
 recurring subscriptions.</li>
-    <li>Supported for any app published on Google Play. You only need a Google 
+    <li>Supported for any app published on Google Play. You only need a Google
 Play Developer Console account and a Google Wallet merchant account.</li>
-    <li>Checkout processing is automatically handled by Google Play, with the 
+    <li>Checkout processing is automatically handled by Google Play, with the
 same look-and-feel as for app purchases.</li>
   </ul>
   <h2>In this document</h2>
@@ -24,18 +24,18 @@
     </li>
     <li><a href="#console">Google Play Developer Console</a></li>
     <li><a href="#checkout">Google Play Purchase Flow</a></li>
-    <li><a href="#samples">Sample App</a></li> 
+    <li><a href="#samples">Sample App</a></li>
     <li><a href="#migration">Migration Considerations</a></li>
   </ol>
    <h2>Related Samples</h2>
   <ol>
     <li><a href="{@docRoot}training/in-app-billing/preparing-iab-app.html#GetSample">Sample Application (V3)</a></li>
-  </ol> 
+  </ol>
 </div>
 </div>
 
-<p>This documentation describes the fundamental In-app Billing components and 
-features that you need to understand in order to add In-app 
+<p>This documentation describes the fundamental In-app Billing components and
+features that you need to understand in order to add In-app
 Billing features into your application.</p>
 
 <p class="note"><b>Note</b>: Ensure that you comply with applicable laws in the countries where you
@@ -49,130 +49,132 @@
 </p>
 
 <h2 id="api">In-app Billing API</h2>
-<p>Your application accesses the In-app Billing service using an API that is 
-exposed by the Google Play app that is installed on the device. The Google Play 
-app then conveys billing requests and responses between your 
-application and the Google Play server. In practice, your application never 
-directly communicates with the Google Play server. Instead, your application 
-sends billing requests to the Google Play application over interprocess 
-communication (IPC) and receives responses from the Google Play app. 
-Your application does not manage any network connections between itself and 
+<p>Your application accesses the In-app Billing service using an API that is
+exposed by the Google Play app that is installed on the device. The Google Play
+app then conveys billing requests and responses between your
+application and the Google Play server. In practice, your application never
+directly communicates with the Google Play server. Instead, your application
+sends billing requests to the Google Play application over interprocess
+communication (IPC) and receives responses from the Google Play app.
+Your application does not manage any network connections between itself and
 the Google Play server.</p>
-<p>In-app Billing can be implemented only in applications that you publish 
-through Google Play. To complete in-app purchase requests, the Google Play app 
+<p>In-app Billing can be implemented only in applications that you publish
+through Google Play. To complete in-app purchase requests, the Google Play app
 must be able to access the Google Play server over the network.</p>
 
-<p>In-app billing Version 3 is the latest version, and maintains very broad 
-compatibility across the range of Android devices. In-app Billing Version 3 is 
-supported on devices running Android 2.2 or higher that have the latest version 
+<p>In-app billing Version 3 is the latest version, and maintains very broad
+compatibility across the range of Android devices. In-app Billing Version 3 is
+supported on devices running Android 2.2 or higher that have the latest version
 of the Google Play store installed (<a href="{@docRoot}about/dashboards/index.html">a vast majority</a> of active devices).</p>
 
 <h4>Version 3 features</h4>
 <ul>
-<li>Requests are sent through a streamlined API that allows you to easily request 
-product details from Google Play, order in-app products, and quickly restore 
+<li>Requests are sent through a streamlined API that allows you to easily request
+product details from Google Play, order in-app products, and quickly restore
 items based on users' product ownership</li>
-<li>Order information is synchronously propagated to the device on purchase 
+<li>Order information is synchronously propagated to the device on purchase
 completion</li>
-<li>All purchases are “managed” (that is, Google Play keeps track of the user's 
-ownership of in-app products). The user cannot own multiple copies of an in-app 
+<li>All purchases are “managed” (that is, Google Play keeps track of the user's
+ownership of in-app products). The user cannot own multiple copies of an in-app
 item; only one copy can be owned at any point in time</li>
-<li>Purchased items can be consumed. When consumed, the item reverts to the 
+<li>Purchased items can be consumed. When consumed, the item reverts to the
 "unowned" state and can be purchased again from Google Play</li>
 <li>Provides support for <a
   href="{@docRoot}google/play/billing/billing_subscriptions.html">subscriptions</a></li>
 </ul>
-<p>For details about other versions of In-app Billing, see the 
+<p>For details about other versions of In-app Billing, see the
 <a href="{@docRoot}google/play/billing/versions.html">Version Notes</a>.</p>
 
 <h2 id="products">In-app Products</h2>
-<p>In-app products are the digital goods that you offer for sale from inside your 
-application to users. Examples of digital goods includes in-game currency, 
-application feature upgrades that enhance the user experience, and new content 
+<p>In-app products are the digital goods that you offer for sale from inside your
+application to users. Examples of digital goods includes in-game currency,
+application feature upgrades that enhance the user experience, and new content
 for your application.</p>
-<p>You can use In-app Billing to sell only digital content. 
-You cannot use In-app Billing to sell physical goods, personal services, or 
-anything that requires physical delivery. Unlike with priced applications, once 
+<p>You can use In-app Billing to sell only digital content.
+You cannot use In-app Billing to sell physical goods, personal services, or
+anything that requires physical delivery. Unlike with priced applications, once
 the user has purchased an in-app product there is no refund window.</p>
-<p>Google Play does not provide any form of content delivery. You are 
-responsible for delivering the digital content that you sell in your 
-applications. In-app products are always explicitly associated with one and 
-only one app. That is, one application cannot purchase an in-app product 
+<p>Google Play does not provide any form of content delivery. You are
+responsible for delivering the digital content that you sell in your
+applications. In-app products are always explicitly associated with one and
+only one app. That is, one application cannot purchase an in-app product
 published for another app, even if they are from the same developer.</p>
 
 <h3 id="prodtypes">Product types</h3>
-<p>In-app Billing supports different product types to give you flexibility in 
-how you monetize your application. In all cases, you define your products using 
+<p>In-app Billing supports different product types to give you flexibility in
+how you monetize your application. In all cases, you define your products using
 the Google Play Developer Console.</p>
-<p>You can specify these types of products for your In-app Billing application  
-— <em>managed in-app products</em> and <em>subscriptions</em>. Google Play 
-handles and tracks ownership for in-app products and subscriptions on your 
+<p>You can specify these types of products for your In-app Billing application
+— <em>managed in-app products</em> and <em>subscriptions</em>. Google Play
+handles and tracks ownership for in-app products and subscriptions on your
 application on a per user account basis. <a href="{@docRoot}google/play/billing/api.html#producttypes">Learn more about the product types supported by In-app Billing Version 3</a>.</p>
 
 <h2 id="console">Google Play Developer Console</h2>
-<p>The Developer Console is where you can publish your 
-In-app Billing application, and manage the various in-app products that are 
+<p>The Developer Console is where you can publish your
+In-app Billing application, and manage the various in-app products that are
 available for purchase from your application.</p>
-<p>You can create a product list of 
-digital goods that are associated with your application, including items for 
-one-time purchase and recurring subscriptions. For each item, you can define 
-information such as the item’s unique product ID (also called its SKU), product 
-type, pricing, description, and how Google Play should handle and track 
+<p>You can create a product list of
+digital goods that are associated with your application, including items for
+one-time purchase and recurring subscriptions. For each item, you can define
+information such as the item’s unique product ID (also called its SKU), product
+type, pricing, description, and how Google Play should handle and track
 purchases for that product.</p>
-<p>You can also create test accounts to authorize 
+<p>You can also create test accounts to authorize
 access for testing applications that are unpublished.</p>
-<p>To learn how to use the Developer Console to configure your in-app 
-products and product list, see 
-<a href="{@docRoot}google/play/billing/billing_admin.html">Administering 
+<p>To learn how to use the Developer Console to configure your in-app
+products and product list, see
+<a href="{@docRoot}google/play/billing/billing_admin.html">Administering
 In-app Billing</a>.</p>
 
 <h2 id="checkout">Google Play Purchase Flow</h2>
-<p>Google Play uses the same checkout backend service as is used for application 
+<p>Google Play uses the same checkout backend service as is used for application
 purchases, so your users experience a consistent and familiar purchase flow.</p>
 <p class="note"><strong>Important:</strong> You must have a Google Wallet
 merchant account to use the In-app Billing service on Google Play.</p>
-<p>To initiate a purchase, your application sends a billing request for a 
-specific in-app product. Google Play then handles all of the checkout details for 
-the transaction, including requesting and validating the form of payment and 
-processing the financial transaction.</p> 
-<p>When the checkout process is complete, 
-Google Play sends your application the purchase details, such as the order 
-number, the order date and time, and the price paid. At no point does your 
-application have to handle any financial transactions; that role is provided by 
+<p>To initiate a purchase, your application sends a billing request for a
+specific in-app product. Google Play then handles all of the checkout details for
+the transaction, including requesting and validating the form of payment and
+processing the financial transaction.</p>
+<p>When the checkout process is complete,
+Google Play sends your application the purchase details, such as the order
+number, the order date and time, and the price paid. At no point does your
+application have to handle any financial transactions; that role is provided by
 Google Play.</p>
 
 <h2 id="samples">Sample Application</h2>
-<p>To help you integrate In-app Billing into your application, the Android SDK 
-provides a sample application that demonstrates how to sell in-app products and subscriptions 
+<p>To help you integrate In-app Billing into your application, the Android SDK
+provides a sample application that demonstrates how to sell in-app products and subscriptions
 from inside an app.</p>
 
-<p>The <a href="{@docRoot}training/in-app-billing/preparing-iab-app.html#GetSample">TrivialDrive sample for the Version 3 API</a> sample shows how to use the In-app Billing Version 3 API 
-to implement in-app product and subscription purchases for a driving game. The 
-application demonstrates how to send In-app Billing requests, and handle 
-synchronous responses from Google Play. The application also shows how to record 
-item consumption with the API. The Version 3 sample includes convenience classes 
-for processing In-app Billing operations as well as perform automatic signature 
+<p>The <a href="{@docRoot}training/in-app-billing/preparing-iab-app.html#GetSample">TrivialDrive sample for the Version 3 API</a> sample shows how to use the In-app Billing Version 3 API
+to implement in-app product and subscription purchases for a driving game. The
+application demonstrates how to send In-app Billing requests, and handle
+synchronous responses from Google Play. The application also shows how to record
+item consumption with the API. The Version 3 sample includes convenience classes
+for processing In-app Billing operations as well as perform automatic signature
 verification.</p>
 
-<p class="caution"><strong>Recommendation</strong>: Make sure to obfuscate the 
+<p class="caution"><strong>Recommendation</strong>: Make sure to obfuscate the
 code in your application before you publish it. For more information, see
-<a href="{@docRoot}google/play/billing/billing_best_practices.html">Security 
+<a href="{@docRoot}google/play/billing/billing_best_practices.html">Security
 and Design</a>.</p>
 
 <h2 id="migration">Migration Considerations</h2>
-<p>If you have an existing In-app Billing implementation that uses Version 2 or
-earlier, it is strongly recommended that you migrate to <a href="{@docRoot}google/play/billing/api.html">In-app Billing Version 3</a> at your earliest convenience.</p>
+<p>The In-app Billing Version 2 API is deprecated and will be discontinued in January 2015.
+If you have an existing In-app Billing implementation that uses API Version 2 or
+earlier, you must migrate to <a href="{@docRoot}google/play/billing/api.html">In-app Billing Version
+3</a>.</p>
 
 <p>If you have published apps selling in-app products, note that:</p>
 <ul>
-<li>Managed items and subscriptions that you have previously defined in the Developer Console will 
+<li>Managed items and subscriptions that you have previously defined in the Developer Console will
 work with Version 3 as before.</li>
-<li>Unmanaged items that you have defined for existing applications will be 
-treated as managed products if you make a purchase request for these items using 
-the Version 3 API. You do not need to create a new product entry in Developer 
-Console for these items, and you can use the same product IDs to purchase these 
-items. They will still continue to be treated as unmanaged items if you make a 
-purchase request for them using the Version 2 or earlier API. 
+<li>Unmanaged items that you have defined for existing applications will be
+treated as managed products if you make a purchase request for these items using
+the Version 3 API. You do not need to create a new product entry in Developer
+Console for these items, and you can use the same product IDs to purchase these
+items. They will still continue to be treated as unmanaged items if you make a
+purchase request for them using the Version 2 or earlier API.
 </ul>
 
 
diff --git a/docs/html/sdk/installing/studio-build.jd b/docs/html/sdk/installing/studio-build.jd
index 29ba12d..bff3bc0 100644
--- a/docs/html/sdk/installing/studio-build.jd
+++ b/docs/html/sdk/installing/studio-build.jd
@@ -454,8 +454,8 @@
 for debugging purposes.</p>
 
 <p>After you build the project, the output APK for the app module is located in
-<code>app/build/apk/</code>, and the output AAR for the lib module is located in
-<code>lib/build/libs/</code>.</p>
+<code>app/build/outputs/apk/</code>, and the output AAR for the lib module is located in
+<code>lib/build/outputs/libs/</code>.</p>
 
 <p>To see a list of all available build tasks for your project, type this command:</p>
 
diff --git a/graphics/java/android/graphics/drawable/ColorDrawable.java b/graphics/java/android/graphics/drawable/ColorDrawable.java
index 33225ce..0608065 100644
--- a/graphics/java/android/graphics/drawable/ColorDrawable.java
+++ b/graphics/java/android/graphics/drawable/ColorDrawable.java
@@ -16,6 +16,7 @@
 
 package android.graphics.drawable;
 
+import android.annotation.NonNull;
 import android.graphics.*;
 import android.graphics.PorterDuff.Mode;
 import android.content.res.ColorStateList;
@@ -211,6 +212,12 @@
     }
 
     @Override
+    public void getOutline(@NonNull Outline outline) {
+        outline.setRect(getBounds());
+        outline.setAlpha(getAlpha() / 255.0f);
+    }
+
+    @Override
     public void inflate(Resources r, XmlPullParser parser, AttributeSet attrs, Theme theme)
             throws XmlPullParserException, IOException {
         super.inflate(r, parser, attrs, theme);
diff --git a/graphics/java/android/graphics/drawable/Drawable.java b/graphics/java/android/graphics/drawable/Drawable.java
index 43a9eaa..9ae788c 100644
--- a/graphics/java/android/graphics/drawable/Drawable.java
+++ b/graphics/java/android/graphics/drawable/Drawable.java
@@ -895,7 +895,7 @@
      */
     public void getOutline(@NonNull Outline outline) {
         outline.setRect(getBounds());
-        outline.setAlpha(getAlpha() / 255.0f);
+        outline.setAlpha(0);
     }
 
     /**
diff --git a/graphics/java/android/graphics/drawable/DrawableContainer.java b/graphics/java/android/graphics/drawable/DrawableContainer.java
index 0b052f4..4a719fe 100644
--- a/graphics/java/android/graphics/drawable/DrawableContainer.java
+++ b/graphics/java/android/graphics/drawable/DrawableContainer.java
@@ -177,11 +177,10 @@
 
     @Override
     public void setTintList(ColorStateList tint) {
-        mDrawableContainerState.mHasTint = tint != null
-                && mDrawableContainerState.mTintMode != null;
+        mDrawableContainerState.mHasTintList = true;
 
-        if (mDrawableContainerState.mTint != tint) {
-            mDrawableContainerState.mTint = tint;
+        if (mDrawableContainerState.mTintList != tint) {
+            mDrawableContainerState.mTintList = tint;
 
             if (mCurrDrawable != null) {
                 mCurrDrawable.mutate().setTintList(tint);
@@ -191,8 +190,7 @@
 
     @Override
     public void setTintMode(Mode tintMode) {
-        mDrawableContainerState.mHasTint = mDrawableContainerState.mTint != null
-                && tintMode != null;
+        mDrawableContainerState.mHasTintMode = true;
 
         if (mDrawableContainerState.mTintMode != tintMode) {
             mDrawableContainerState.mTintMode = tintMode;
@@ -449,10 +447,15 @@
                     d.setAlpha(mAlpha);
                 }
                 if (mDrawableContainerState.mHasColorFilter) {
+                    // Color filter always overrides tint.
                     d.setColorFilter(mDrawableContainerState.mColorFilter);
-                } else if (mDrawableContainerState.mHasTint) {
-                    d.setTintList(mDrawableContainerState.mTint);
-                    d.setTintMode(mDrawableContainerState.mTintMode);
+                } else {
+                    if (mDrawableContainerState.mHasTintList) {
+                        d.setTintList(mDrawableContainerState.mTintList);
+                    }
+                    if (mDrawableContainerState.mHasTintMode) {
+                        d.setTintMode(mDrawableContainerState.mTintMode);
+                    }
                 }
                 d.setVisible(isVisible(), true);
                 d.setDither(mDrawableContainerState.mDither);
@@ -623,9 +626,10 @@
         ColorFilter mColorFilter;
         boolean mHasColorFilter;
 
-        ColorStateList mTint;
+        ColorStateList mTintList;
         Mode mTintMode;
-        boolean mHasTint;
+        boolean mHasTintList;
+        boolean mHasTintMode;
 
         DrawableContainerState(DrawableContainerState orig, DrawableContainer owner,
                 Resources res) {
@@ -649,9 +653,10 @@
                 mAutoMirrored = orig.mAutoMirrored;
                 mColorFilter = orig.mColorFilter;
                 mHasColorFilter = orig.mHasColorFilter;
-                mTint = orig.mTint;
+                mTintList = orig.mTintList;
                 mTintMode = orig.mTintMode;
-                mHasTint = orig.mHasTint;
+                mHasTintList = orig.mHasTintList;
+                mHasTintMode = orig.mHasTintMode;
 
                 // Cloning the following values may require creating futures.
                 mConstantPadding = orig.getConstantPadding();
diff --git a/libs/hwui/OpenGLRenderer.cpp b/libs/hwui/OpenGLRenderer.cpp
index ce1d09f..eac06cb 100755
--- a/libs/hwui/OpenGLRenderer.cpp
+++ b/libs/hwui/OpenGLRenderer.cpp
@@ -51,6 +51,21 @@
     #define EVENT_LOGD(...)
 #endif
 
+static void atraceFormatBegin(const char* fmt, ...) {
+    const int BUFFER_SIZE = 256;
+    va_list ap;
+    char buf[BUFFER_SIZE];
+
+    va_start(ap, fmt);
+    vsnprintf(buf, BUFFER_SIZE, fmt, ap);
+    va_end(ap);
+
+    ATRACE_BEGIN(buf);
+}
+
+#define ATRACE_FORMAT_BEGIN(fmt, ...) \
+    if (CC_UNLIKELY(ATRACE_ENABLED())) atraceFormatBegin(fmt, ##__VA_ARGS__)
+
 namespace android {
 namespace uirenderer {
 
@@ -537,17 +552,18 @@
 
         // Note: it is very important to update the layers in order
         for (int i = 0; i < count; i++) {
+            Layer* layer = mLayerUpdates.itemAt(i);
+
             sprintf(layerName, "Layer #%d", i);
             startMark(layerName);
+            ATRACE_FORMAT_BEGIN("flushLayer %ux%u", layer->getWidth(), layer->getHeight());
 
-            ATRACE_BEGIN("flushLayer");
-            Layer* layer = mLayerUpdates.itemAt(i);
             layer->flush();
+
             ATRACE_END();
+            endMark();
 
             mCaches.resourceCache.decrementRefcount(layer);
-
-            endMark();
         }
 
         mLayerUpdates.clear();
@@ -631,6 +647,7 @@
 
     if (restoreLayer) {
         endMark(); // Savelayer
+        ATRACE_END(); // SaveLayer
         startMark("ComposeLayer");
         composeLayer(removed, restored);
         endMark();
@@ -814,6 +831,9 @@
     mSnapshot->flags |= Snapshot::kFlagIsLayer;
     mSnapshot->layer = layer;
 
+    ATRACE_FORMAT_BEGIN("%ssaveLayer %ux%u",
+            fboLayer ? "" : "unclipped ",
+            layer->getWidth(), layer->getHeight());
     startMark("SaveLayer");
     if (fboLayer) {
         return createFboLayer(layer, bounds, clip);
diff --git a/services/core/java/com/android/server/ConnectivityService.java b/services/core/java/com/android/server/ConnectivityService.java
index 0b1a627..85ab249 100644
--- a/services/core/java/com/android/server/ConnectivityService.java
+++ b/services/core/java/com/android/server/ConnectivityService.java
@@ -516,11 +516,13 @@
                 return;
             }
 
-            if (list.isEmpty() || isDefaultNetwork(nai)) {
+            list.add(nai);
+
+            // Send a broadcast if this is the first network of its type or if it's the default.
+            if (list.size() == 1 || isDefaultNetwork(nai)) {
                 maybeLogBroadcast(nai, true, type);
                 sendLegacyNetworkBroadcast(nai, true, type);
             }
-            list.add(nai);
         }
 
         /** Removes the given network from the specified legacy type list. */
diff --git a/services/core/java/com/android/server/TelephonyRegistry.java b/services/core/java/com/android/server/TelephonyRegistry.java
index b3337bb..e3e0228 100644
--- a/services/core/java/com/android/server/TelephonyRegistry.java
+++ b/services/core/java/com/android/server/TelephonyRegistry.java
@@ -212,11 +212,12 @@
                     //defaultSubId comes before new defaultSubId update) we need to recall all
                     //possible missed notify callback
                     synchronized (mRecords) {
-                      for (Record r : mRecords) {
-                          if(r.subId == SubscriptionManager.DEFAULT_SUB_ID) {
-                              checkPossibleMissNotify(r, newDefaultPhoneId);
-                          }
-                      }
+                        for (Record r : mRecords) {
+                            if(r.subId == SubscriptionManager.DEFAULT_SUB_ID) {
+                                checkPossibleMissNotify(r, newDefaultPhoneId);
+                            }
+                        }
+                        handleRemoveListLocked();
                     }
                     mDefaultSubId = newDefaultSubId;
                     mDefaultPhoneId = newDefaultPhoneId;
@@ -1445,7 +1446,7 @@
                 r.callback.onServiceStateChanged(
                         new ServiceState(mServiceState[phoneId]));
             } catch (RemoteException ex) {
-                remove(r.binder);
+                mRemoveList.add(r.binder);
             }
         }
 
@@ -1472,7 +1473,7 @@
                 r.callback.onSignalStrengthChanged((gsmSignalStrength == 99 ? -1
                         : gsmSignalStrength));
             } catch (RemoteException ex) {
-                remove(r.binder);
+                mRemoveList.add(r.binder);
             }
         }
 
@@ -1484,7 +1485,7 @@
                 }
                 r.callback.onCellInfoChanged(mCellInfo.get(phoneId));
             } catch (RemoteException ex) {
-                remove(r.binder);
+                mRemoveList.add(r.binder);
             }
         }
 
@@ -1497,7 +1498,7 @@
                 r.callback.onMessageWaitingIndicatorChanged(
                         mMessageWaiting[phoneId]);
             } catch (RemoteException ex) {
-                remove(r.binder);
+                mRemoveList.add(r.binder);
             }
         }
 
@@ -1510,7 +1511,7 @@
                 r.callback.onCallForwardingIndicatorChanged(
                         mCallForwarding[phoneId]);
             } catch (RemoteException ex) {
-                remove(r.binder);
+                mRemoveList.add(r.binder);
             }
         }
 
@@ -1535,7 +1536,7 @@
                 r.callback.onDataConnectionStateChanged(mDataConnectionState[phoneId],
                         mDataConnectionNetworkType[phoneId]);
             } catch (RemoteException ex) {
-                remove(r.binder);
+                mRemoveList.add(r.binder);
             }
         }
     }
diff --git a/services/core/java/com/android/server/content/SyncManager.java b/services/core/java/com/android/server/content/SyncManager.java
index 9292d45..adc96f7 100644
--- a/services/core/java/com/android/server/content/SyncManager.java
+++ b/services/core/java/com/android/server/content/SyncManager.java
@@ -311,7 +311,9 @@
                     if (Log.isLoggable(TAG, Log.VERBOSE)) {
                         Log.v(TAG, "Reconnection detected: clearing all backoffs");
                     }
-                    mSyncStorageEngine.clearAllBackoffs(mSyncQueue);
+                    synchronized (mSyncQueue) {
+                        mSyncStorageEngine.clearAllBackoffsLocked(mSyncQueue);
+                    }
                 }
                 sendCheckAlarmsMessage();
             }
diff --git a/services/core/java/com/android/server/content/SyncStorageEngine.java b/services/core/java/com/android/server/content/SyncStorageEngine.java
index 9499370..0d5f240 100644
--- a/services/core/java/com/android/server/content/SyncStorageEngine.java
+++ b/services/core/java/com/android/server/content/SyncStorageEngine.java
@@ -834,17 +834,16 @@
         return changed;
     }
 
-    public void clearAllBackoffs(SyncQueue syncQueue) {
+    public void clearAllBackoffsLocked(SyncQueue syncQueue) {
         boolean changed = false;
         synchronized (mAuthorities) {
-            synchronized (syncQueue) {
                 // Clear backoff for all sync adapters.
                 for (AccountInfo accountInfo : mAccounts.values()) {
                     for (AuthorityInfo authorityInfo : accountInfo.authorities.values()) {
                         if (authorityInfo.backoffTime != NOT_IN_BACKOFF_MODE
                                 || authorityInfo.backoffDelay != NOT_IN_BACKOFF_MODE) {
                             if (Log.isLoggable(TAG, Log.VERBOSE)) {
-                                Log.v(TAG, "clearAllBackoffs:"
+                                Log.v(TAG, "clearAllBackoffsLocked:"
                                         + " authority:" + authorityInfo.target
                                         + " account:" + accountInfo.accountAndUser.account.name
                                         + " user:" + accountInfo.accountAndUser.userId
@@ -868,7 +867,6 @@
                             authorityInfo.backoffDelay = NOT_IN_BACKOFF_MODE;
                         }
                     }
-                }
                 syncQueue.clearBackoffs();
             }
         }
diff --git a/services/core/java/com/android/server/media/MediaSessionRecord.java b/services/core/java/com/android/server/media/MediaSessionRecord.java
index 5097927..a0ec1d5 100644
--- a/services/core/java/com/android/server/media/MediaSessionRecord.java
+++ b/services/core/java/com/android/server/media/MediaSessionRecord.java
@@ -23,6 +23,7 @@
 import android.content.pm.ParceledListSlice;
 import android.media.AudioManager;
 import android.media.AudioManagerInternal;
+import android.media.AudioSystem;
 import android.media.MediaDescription;
 import android.media.MediaMetadata;
 import android.media.Rating;
@@ -237,6 +238,7 @@
      */
     public void adjustVolume(int direction, int flags, String packageName, int uid,
             boolean useSuggested) {
+        int previousFlagPlaySound = flags & AudioManager.FLAG_PLAY_SOUND;
         if (isPlaybackActive(false) || hasFlag(MediaSession.FLAG_EXCLUSIVE_GLOBAL_PRIORITY)) {
             flags &= ~AudioManager.FLAG_PLAY_SOUND;
         }
@@ -248,8 +250,15 @@
         if (mVolumeType == PlaybackInfo.PLAYBACK_TYPE_LOCAL) {
             int stream = AudioAttributes.toLegacyStreamType(mAudioAttrs);
             if (useSuggested) {
-                mAudioManagerInternal.adjustSuggestedStreamVolumeForUid(stream, direction, flags,
-                        packageName, uid);
+                if (AudioSystem.isStreamActive(stream, 0)) {
+                    mAudioManagerInternal.adjustSuggestedStreamVolumeForUid(stream, direction,
+                            flags, packageName, uid);
+                } else {
+                    flags |= previousFlagPlaySound;
+                    mAudioManagerInternal.adjustSuggestedStreamVolumeForUid(
+                            AudioManager.USE_DEFAULT_STREAM_TYPE, direction, flags, packageName,
+                            uid);
+                }
             } else {
                 mAudioManagerInternal.adjustStreamVolumeForUid(stream, direction, flags,
                         packageName, uid);
@@ -615,7 +624,10 @@
     }
 
     private PlaybackState getStateWithUpdatedPosition() {
-        PlaybackState state = mPlaybackState;
+        PlaybackState state;
+        synchronized (mLock) {
+            state = mPlaybackState;
+        }
         long duration = -1;
         if (mMetadata != null && mMetadata.containsKey(MediaMetadata.METADATA_KEY_DURATION)) {
             duration = mMetadata.getLong(MediaMetadata.METADATA_KEY_DURATION);
@@ -674,7 +686,8 @@
 
         @Override
         public void sendEvent(String event, Bundle data) {
-            mHandler.post(MessageHandler.MSG_SEND_EVENT, event, data);
+            mHandler.post(MessageHandler.MSG_SEND_EVENT, event,
+                    data == null ? null : new Bundle(data));
         }
 
         @Override
@@ -712,7 +725,11 @@
 
         @Override
         public void setMetadata(MediaMetadata metadata) {
-            mMetadata = metadata;
+            // Make a copy of the metadata as the underlying bundle may be
+            // modified on this thread.
+            synchronized (mLock) {
+                mMetadata = metadata == null ? null : new MediaMetadata.Builder(metadata).build();
+            }
             mHandler.post(MessageHandler.MSG_UPDATE_METADATA);
         }
 
@@ -723,14 +740,18 @@
             if (MediaSession.isActiveState(oldState) && newState == PlaybackState.STATE_PAUSED) {
                 mLastActiveTime = SystemClock.elapsedRealtime();
             }
-            mPlaybackState = state;
+            synchronized (mLock) {
+                mPlaybackState = state;
+            }
             mService.onSessionPlaystateChange(MediaSessionRecord.this, oldState, newState);
             mHandler.post(MessageHandler.MSG_UPDATE_PLAYBACK_STATE);
         }
 
         @Override
         public void setQueue(ParceledListSlice queue) {
-            mQueue = queue;
+            synchronized (mLock) {
+                mQueue = queue;
+            }
             mHandler.post(MessageHandler.MSG_UPDATE_QUEUE);
         }
 
@@ -742,7 +763,9 @@
 
         @Override
         public void setExtras(Bundle extras) {
-            mExtras = extras;
+            synchronized (mLock) {
+                mExtras = extras == null ? null : new Bundle(extras);
+            }
             mHandler.post(MessageHandler.MSG_UPDATE_EXTRAS);
         }
 
@@ -1118,7 +1141,9 @@
 
         @Override
         public MediaMetadata getMetadata() {
-            return mMetadata;
+            synchronized (mLock) {
+                return mMetadata;
+            }
         }
 
         @Override
@@ -1128,7 +1153,9 @@
 
         @Override
         public ParceledListSlice getQueue() {
-            return mQueue;
+            synchronized (mLock) {
+                return mQueue;
+            }
         }
 
         @Override
@@ -1138,7 +1165,9 @@
 
         @Override
         public Bundle getExtras() {
-            return mExtras;
+            synchronized (mLock) {
+                return mExtras;
+            }
         }
 
         @Override