Merge "Remove outdated tests for custom decoder." into lmp-mr1-dev
diff --git a/core/java/com/android/internal/view/menu/MenuBuilder.java b/core/java/com/android/internal/view/menu/MenuBuilder.java
index e8d1ead..e5f9ec9 100644
--- a/core/java/com/android/internal/view/menu/MenuBuilder.java
+++ b/core/java/com/android/internal/view/menu/MenuBuilder.java
@@ -828,7 +828,8 @@
                       || shortcutChar == possibleChars.meta[2]
                       || (qwerty && shortcutChar == '\b' &&
                           keyCode == KeyEvent.KEYCODE_DEL)) &&
-                  item.isEnabled()) {
+                  item.isEnabled() &&
+                  item.isVisible()) {
                 items.add(item);
             }
         }
diff --git a/core/java/com/android/internal/widget/SwipeDismissLayout.java b/core/java/com/android/internal/widget/SwipeDismissLayout.java
index 97b1634..7a4b23a 100644
--- a/core/java/com/android/internal/widget/SwipeDismissLayout.java
+++ b/core/java/com/android/internal/widget/SwipeDismissLayout.java
@@ -17,6 +17,7 @@
 package com.android.internal.widget;
 
 import android.animation.TimeInterpolator;
+import android.app.Activity;
 import android.content.Context;
 import android.util.AttributeSet;
 import android.util.Log;
@@ -102,6 +103,11 @@
                 android.R.integer.config_shortAnimTime);
         mCancelInterpolator = new DecelerateInterpolator(1.5f);
         mDismissInterpolator = new AccelerateInterpolator(1.5f);
+        // SwipeDismissLayout assumes that the host Activity is translucent
+        // and temporarily disables translucency when it is fully visible.
+        // As soon as the user starts swiping, we will re-enable
+        // translucency.
+        ((Activity) context).convertFromTranslucent();
     }
 
     public void setOnDismissedListener(OnDismissedListener listener) {
@@ -197,6 +203,7 @@
                 mLastX = ev.getRawX();
                 updateSwiping(ev);
                 if (mSwiping) {
+                    ((Activity) getContext()).convertToTranslucent(null, null);
                     setProgress(ev.getRawX() - mDownX);
                     break;
                 }
@@ -218,6 +225,7 @@
     }
 
     protected void cancel() {
+        ((Activity) getContext()).convertFromTranslucent();
         if (mProgressListener != null) {
             mProgressListener.onSwipeCancelled(this);
         }
diff --git a/core/jni/android/graphics/BitmapFactory.cpp b/core/jni/android/graphics/BitmapFactory.cpp
index e0abc24..a578b5d 100644
--- a/core/jni/android/graphics/BitmapFactory.cpp
+++ b/core/jni/android/graphics/BitmapFactory.cpp
@@ -315,7 +315,8 @@
     }
 
     SkBitmap decodingBitmap;
-    if (!decoder->decode(stream, &decodingBitmap, prefColorType, decodeMode)) {
+    if (decoder->decode(stream, &decodingBitmap, prefColorType, decodeMode)
+                != SkImageDecoder::kSuccess) {
         return nullObjectReturn("decoder->decode returned false");
     }
 
diff --git a/core/res/res/values/strings.xml b/core/res/res/values/strings.xml
index 3d30792..56cf56d 100644
--- a/core/res/res/values/strings.xml
+++ b/core/res/res/values/strings.xml
@@ -1449,9 +1449,8 @@
     <string name="permlab_bodySensors">body sensors (like heart rate monitors)
     </string>
     <!-- Description of the body sensors permission, listed so the user can decide whether to allow the application to access data from body sensors. [CHAR LIMIT=NONE] -->
-    <string name="permdesc_bodySensors" product="default">Allows the app to
-      access data from sensors you use to measure what’s happening inside your
-      body, such as heart rate.</string>
+    <string name="permdesc_bodySensors" product="default">Allows the app to access data from sensors
+    that monitor your physical condition, such as your heart rate.</string>
 
     <!-- Title of the read social stream permission, listed so the user can decide whether to allow the application to read information from the user's social stream. [CHAR LIMIT=30] -->
     <string name="permlab_readSocialStream" product="default">read your social stream</string>
diff --git a/core/res/res/values/themes_micro.xml b/core/res/res/values/themes_micro.xml
index 7e0467b..f1bc5da 100644
--- a/core/res/res/values/themes_micro.xml
+++ b/core/res/res/values/themes_micro.xml
@@ -24,6 +24,8 @@
         <item name="windowBackground">@color/black</item>
         <item name="windowContentOverlay">@null</item>
         <item name="windowIsFloating">false</item>
+        <!-- We need the windows to be translucent for SwipeToDismiss layout
+             to work properly. -->
         <item name="windowIsTranslucent">true</item>
         <item name="windowSwipeToDismiss">true</item>
     </style>
@@ -38,6 +40,8 @@
         <item name="windowBackground">@color/white</item>
         <item name="windowContentOverlay">@null</item>
         <item name="windowIsFloating">false</item>
+        <!-- We need the windows to be translucent for SwipeToDismiss layout
+             to work properly. -->
         <item name="windowIsTranslucent">true</item>
         <item name="windowSwipeToDismiss">true</item>
     </style>
diff --git a/docs/html/about/versions/android-5.0.jd b/docs/html/about/versions/android-5.0.jd
index f8d8ab6..a438420 100644
--- a/docs/html/about/versions/android-5.0.jd
+++ b/docs/html/about/versions/android-5.0.jd
@@ -23,6 +23,7 @@
 <li><a href="#BehaviorGetRecentTasks">If your app uses getRecentTasks()...</a></li>
 <li><a href="#64BitSupport">If you are using the Android Native Development Kit (NDK)...</a></li>
 <li><a href="#BindService">If your app binds to a Service...</a></li>
+<li><a href="#BehaviorWebView">If your app uses a WebView...</a></li>
     </ol>
   </li>
   <li><a href="#UI">User Interface</a>
@@ -234,8 +235,8 @@
 vibration.</p>
 
 <p>Setting the device to
-{@link android.media.AudioManager#RINGER_MODE_SILENT RINGER_MODE_SILENT} now
-causes the device to enter the new priority mode. The device leaves priority
+{@link android.media.AudioManager#RINGER_MODE_SILENT RINGER_MODE_SILENT} causes
+the device to enter the new priority mode. The device leaves priority
 mode if you set it to
 {@link android.media.AudioManager#RINGER_MODE_NORMAL RINGER_MODE_NORMAL} or
 {@link android.media.AudioManager#RINGER_MODE_NORMAL RINGER_MODE_VIBRATE}.</p>
@@ -366,6 +367,31 @@
 To ensure your app is secure, use an explicit intent when starting or binding
 your {@link android.app.Service}, and do not declare intent filters for the service.</p>
 
+<h3 id="BehaviorWebView">If your app uses WebView...</h3>
+
+<p>Android 5.0 changes the default behavior for your app.</p>
+<ul>
+<li><strong>If your app targets API level 21 or higher:</strong>
+  <ul>
+    <li>The system
+  blocks <a href="https://developer.mozilla.org/en-US/docs/Security/MixedContent"
+  class="external-link">mixed content</a> and third party cookies by default. To allow mixed
+  content and third party cookies, use the
+  {@link android.webkit.WebSettings#setMixedContentMode(int) setMixedContentMode()}
+and {@link android.webkit.CookieManager#setAcceptThirdPartyCookies(android.webkit.WebView, boolean) setAcceptThirdPartyCookies()}
+methods respectively.</li>
+    <li>The system now intelligently chooses portions of the HTML
+      document to draw. This new default behavior helps to reduce memory
+      footprint and increase performance. If you want to
+      render the whole document at once, disable this optimization by calling
+      {@link android.webkit.WebView#enableSlowWholeDocumentDraw()}.</li>
+  </ul>
+</li>
+<li><strong>If your app targets API levels lower than 21:</strong> The system
+  allows mixed content and third party cookies, and always renders the whole
+  document at once.</li>
+</ul>
+
 <h2 id="UI">User Interface</h2>
 
 <h3 id="MaterialDesign">Material design support</h3>
@@ -470,7 +496,7 @@
 method.</p>
 
 <p>For an example of how to use the new APIs, see the {@code MediaProjectionDemo}
-class in the {@code ApiDemos} sample project.</p>
+class in the sample project.</p>
 
 <h2 id="Notifications">Notifications</h2>
 
diff --git a/docs/html/training/wearables/notifications/stacks.jd b/docs/html/training/wearables/notifications/stacks.jd
index e71e74c..9a528a4 100644
--- a/docs/html/training/wearables/notifications/stacks.jd
+++ b/docs/html/training/wearables/notifications/stacks.jd
@@ -45,7 +45,7 @@
 Notification notif = new NotificationCompat.Builder(mContext)
          .setContentTitle("New mail from " + sender1)
          .setContentText(subject1)
-         .setSmallIcon(R.drawable.new_mail);
+         .setSmallIcon(R.drawable.new_mail)
          .setGroup(GROUP_KEY_EMAILS)
          .build();
 
@@ -65,7 +65,7 @@
 Notification notif2 = new NotificationCompat.Builder(mContext)
          .setContentTitle("New mail from " + sender2)
          .setContentText(subject2)
-         .setSmallIcon(R.drawable.new_mail);
+         .setSmallIcon(R.drawable.new_mail)
          .setGroup(GROUP_KEY_EMAILS)
          .build();
 
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/policy/UserSwitcherController.java b/packages/SystemUI/src/com/android/systemui/statusbar/policy/UserSwitcherController.java
index eb808c2..5c7909a 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/policy/UserSwitcherController.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/policy/UserSwitcherController.java
@@ -571,6 +571,9 @@
                 cancel();
             } else {
                 dismiss();
+                if (ActivityManager.isUserAMonkey()) {
+                    return;
+                }
                 UserInfo user = mUserManager.createSecondaryUser(
                         mContext.getString(R.string.user_new_user_name), 0 /* flags */);
                 if (user == null) {
diff --git a/services/core/java/com/android/server/job/JobSchedulerService.java b/services/core/java/com/android/server/job/JobSchedulerService.java
index c6d2db2..83d6986 100644
--- a/services/core/java/com/android/server/job/JobSchedulerService.java
+++ b/services/core/java/com/android/server/job/JobSchedulerService.java
@@ -137,11 +137,15 @@
         public void onReceive(Context context, Intent intent) {
             Slog.d(TAG, "Receieved: " + intent.getAction());
             if (Intent.ACTION_PACKAGE_REMOVED.equals(intent.getAction())) {
-                int uidRemoved = intent.getIntExtra(Intent.EXTRA_UID, -1);
-                if (DEBUG) {
-                    Slog.d(TAG, "Removing jobs for uid: " + uidRemoved);
+                // If this is an outright uninstall rather than the first half of an
+                // app update sequence, cancel the jobs associated with the app.
+                if (!intent.getBooleanExtra(Intent.EXTRA_REPLACING, false)) {
+                    int uidRemoved = intent.getIntExtra(Intent.EXTRA_UID, -1);
+                    if (DEBUG) {
+                        Slog.d(TAG, "Removing jobs for uid: " + uidRemoved);
+                    }
+                    cancelJobsForUid(uidRemoved);
                 }
-                cancelJobsForUid(uidRemoved);
             } else if (Intent.ACTION_USER_REMOVED.equals(intent.getAction())) {
                 final int userId = intent.getIntExtra(Intent.EXTRA_USER_HANDLE, 0);
                 if (DEBUG) {
diff --git a/services/core/java/com/android/server/trust/TrustManagerService.java b/services/core/java/com/android/server/trust/TrustManagerService.java
index fefbe0a..f9b1704 100644
--- a/services/core/java/com/android/server/trust/TrustManagerService.java
+++ b/services/core/java/com/android/server/trust/TrustManagerService.java
@@ -120,8 +120,9 @@
         if (phase == SystemService.PHASE_SYSTEM_SERVICES_READY && !isSafeMode()) {
             mPackageMonitor.register(mContext, mHandler.getLooper(), UserHandle.ALL, true);
             mReceiver.register(mContext);
-            maybeEnableFactoryTrustAgents(mLockPatternUtils, UserHandle.USER_OWNER);
             refreshAgentList(UserHandle.USER_ALL);
+        } else if (phase == SystemService.PHASE_BOOT_COMPLETED && !isSafeMode()) {
+            maybeEnableFactoryTrustAgents(mLockPatternUtils, UserHandle.USER_OWNER);
         }
     }
 
diff --git a/telecomm/java/android/telecom/Connection.java b/telecomm/java/android/telecom/Connection.java
index 795053d..2932721 100644
--- a/telecomm/java/android/telecom/Connection.java
+++ b/telecomm/java/android/telecom/Connection.java
@@ -898,6 +898,13 @@
     }
 
     /**
+     * @hide
+     */
+    public final ConnectionService getConnectionService() {
+        return mConnectionService;
+    }
+
+    /**
      * Sets the conference that this connection is a part of. This will fail if the connection is
      * already part of a conference call. {@link #resetConference} to un-set the conference first.
      *
diff --git a/telephony/java/com/android/internal/telephony/DctConstants.java b/telephony/java/com/android/internal/telephony/DctConstants.java
index defb43b..a4e9486 100644
--- a/telephony/java/com/android/internal/telephony/DctConstants.java
+++ b/telephony/java/com/android/internal/telephony/DctConstants.java
@@ -99,6 +99,7 @@
     public static final int EVENT_PROVISIONING_APN_ALARM = BASE + 39;
     public static final int CMD_NET_STAT_POLL = BASE + 40;
     public static final int EVENT_DATA_RAT_CHANGED = BASE + 41;
+    public static final int CMD_CLEAR_PROVISIONING_SPINNER = BASE + 42;
 
     /***** Constants *****/
 
diff --git a/tools/layoutlib/bridge/src/android/graphics/FontFamily_Delegate.java b/tools/layoutlib/bridge/src/android/graphics/FontFamily_Delegate.java
index bef5181..4993262 100644
--- a/tools/layoutlib/bridge/src/android/graphics/FontFamily_Delegate.java
+++ b/tools/layoutlib/bridge/src/android/graphics/FontFamily_Delegate.java
@@ -213,6 +213,10 @@
         return null;
     }
 
+    @Nullable
+    /*package*/ static String getFontLocation() {
+        return sFontLocation;
+    }
 
     // ---- native methods ----
 
diff --git a/tools/layoutlib/bridge/src/android/graphics/Typeface_Accessor.java b/tools/layoutlib/bridge/src/android/graphics/Typeface_Accessor.java
deleted file mode 100644
index adad2ac..0000000
--- a/tools/layoutlib/bridge/src/android/graphics/Typeface_Accessor.java
+++ /dev/null
@@ -1,27 +0,0 @@
-/*
- * Copyright (C) 2011 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package android.graphics;
-
-/**
- * Class allowing access to package-protected methods/fields.
- */
-public class Typeface_Accessor {
-
-    public static void resetDefaults() {
-        Typeface.sDefaults = null;
-    }
-}
diff --git a/tools/layoutlib/bridge/src/android/graphics/Typeface_Delegate.java b/tools/layoutlib/bridge/src/android/graphics/Typeface_Delegate.java
index 276e134..b9460b4 100644
--- a/tools/layoutlib/bridge/src/android/graphics/Typeface_Delegate.java
+++ b/tools/layoutlib/bridge/src/android/graphics/Typeface_Delegate.java
@@ -27,6 +27,8 @@
 import java.util.ArrayList;
 import java.util.List;
 
+import static android.graphics.FontFamily_Delegate.getFontLocation;
+
 /**
  * Delegate implementing the native methods of android.graphics.Typeface
  *
@@ -48,8 +50,6 @@
     private static final DelegateManager<Typeface_Delegate> sManager =
             new DelegateManager<Typeface_Delegate>(Typeface_Delegate.class);
 
-    // ---- delegate helper data ----
-    private static String sFontLocation;
 
     // ---- delegate data ----
 
@@ -61,11 +61,8 @@
 
     private static long sDefaultTypeface;
 
+
     // ---- Public Helper methods ----
-    public static synchronized void setFontLocation(String fontLocation) {
-        sFontLocation = fontLocation;
-        FontFamily_Delegate.setFontLocation(fontLocation);
-    }
 
     public static Typeface_Delegate getDelegate(long nativeTypeface) {
         return sManager.getDelegate(nativeTypeface);
@@ -131,6 +128,18 @@
         return fonts;
     }
 
+    /**
+     * Clear the default typefaces when disposing bridge.
+     */
+    public static void resetDefaults() {
+        // Sometimes this is called before the Bridge is initialized. In that case, we don't want to
+        // initialize Typeface because the SDK fonts location hasn't been set.
+        if (FontFamily_Delegate.getFontLocation() != null) {
+            Typeface.sDefaults = null;
+        }
+    }
+
+
     // ---- native methods ----
 
     @LayoutlibDelegate
@@ -193,7 +202,7 @@
 
     @LayoutlibDelegate
     /*package*/ static File getSystemFontConfigLocation() {
-        return new File(sFontLocation);
+        return new File(getFontLocation());
     }
 
     // ---- Private delegate/helper methods ----
diff --git a/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/Bridge.java b/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/Bridge.java
index 3d0e1e8..825731b 100644
--- a/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/Bridge.java
+++ b/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/Bridge.java
@@ -38,7 +38,7 @@
 
 import android.content.res.BridgeAssetManager;
 import android.graphics.Bitmap;
-import android.graphics.Typeface_Accessor;
+import android.graphics.FontFamily_Delegate;
 import android.graphics.Typeface_Delegate;
 import android.os.Looper;
 import android.os.Looper_Accessor;
@@ -250,7 +250,7 @@
         }
 
         // load the fonts.
-        Typeface_Delegate.setFontLocation(fontLocation.getAbsolutePath());
+        FontFamily_Delegate.setFontLocation(fontLocation.getAbsolutePath());
 
         // now parse com.android.internal.R (and only this one as android.R is a subset of
         // the internal version), and put the content in the maps.
@@ -303,7 +303,7 @@
         BridgeAssetManager.clearSystem();
 
         // dispose of the default typeface.
-        Typeface_Accessor.resetDefaults();
+        Typeface_Delegate.resetDefaults();
 
         return true;
     }