Merge "Fix hasSurfaceInsets check when creating hardware renderer" into lmp-mr1-dev
diff --git a/core/java/android/view/AccessibilityInteractionController.java b/core/java/android/view/AccessibilityInteractionController.java
index 1cadf69..5e05683 100644
--- a/core/java/android/view/AccessibilityInteractionController.java
+++ b/core/java/android/view/AccessibilityInteractionController.java
@@ -1109,15 +1109,17 @@
                         || accessibilityViewId == providerHost.getAccessibilityViewId()) {
                     final AccessibilityNodeInfo parent;
                     if (virtualDescendantId != AccessibilityNodeInfo.UNDEFINED_ITEM_ID) {
-                        parent = provider.createAccessibilityNodeInfo(
-                                virtualDescendantId);
+                        parent = provider.createAccessibilityNodeInfo(virtualDescendantId);
                     } else {
-                        parent= provider.createAccessibilityNodeInfo(
+                        parent = provider.createAccessibilityNodeInfo(
                                 AccessibilityNodeProvider.HOST_VIEW_ID);
                     }
-                    if (parent != null) {
-                        outInfos.add(parent);
+                    if (parent == null) {
+                        // Couldn't obtain the parent, which means we have a
+                        // disconnected sub-tree. Abort prefetch immediately.
+                        return;
                     }
+                    outInfos.add(parent);
                     parentNodeId = parent.getParentNodeId();
                     accessibilityViewId = AccessibilityNodeInfo.getAccessibilityViewId(
                             parentNodeId);
diff --git a/policy/src/com/android/internal/policy/impl/PhoneWindowManager.java b/policy/src/com/android/internal/policy/impl/PhoneWindowManager.java
index 792712f..b516f00 100644
--- a/policy/src/com/android/internal/policy/impl/PhoneWindowManager.java
+++ b/policy/src/com/android/internal/policy/impl/PhoneWindowManager.java
@@ -116,6 +116,7 @@
 import java.io.IOException;
 import java.io.PrintWriter;
 import java.util.HashSet;
+import java.util.List;
 
 import static android.view.WindowManager.LayoutParams.*;
 import static android.view.WindowManagerPolicy.WindowManagerFuncs.LID_ABSENT;
@@ -2299,24 +2300,19 @@
             boolean goingToNotificationShade) {
         if (goingToNotificationShade) {
             return AnimationUtils.loadAnimation(mContext, R.anim.lock_screen_behind_enter_fade_in);
-        } else if (onWallpaper) {
-            Animation a = AnimationUtils.loadAnimation(mContext,
-                    R.anim.lock_screen_behind_enter_wallpaper);
-            AnimationSet set = (AnimationSet) a;
-
-            // TODO: Use XML interpolators when we have log interpolators available in XML.
-            set.getAnimations().get(0).setInterpolator(mLogDecelerateInterpolator);
-            set.getAnimations().get(1).setInterpolator(mLogDecelerateInterpolator);
-            return set;
-        } else {
-            Animation a = AnimationUtils.loadAnimation(mContext,
-                    R.anim.lock_screen_behind_enter);
-            AnimationSet set = (AnimationSet) a;
-
-            // TODO: Use XML interpolators when we have log interpolators available in XML.
-            set.getAnimations().get(0).setInterpolator(mLogDecelerateInterpolator);
-            return set;
         }
+
+        AnimationSet set = (AnimationSet) AnimationUtils.loadAnimation(mContext, onWallpaper ?
+                    R.anim.lock_screen_behind_enter_wallpaper :
+                    R.anim.lock_screen_behind_enter);
+
+        // TODO: Use XML interpolators when we have log interpolators available in XML.
+        final List<Animation> animations = set.getAnimations();
+        for (int i = animations.size() - 1; i >= 0; --i) {
+            animations.get(i).setInterpolator(mLogDecelerateInterpolator);
+        }
+
+        return set;
     }
 
 
diff --git a/services/core/java/com/android/server/am/ActivityStack.java b/services/core/java/com/android/server/am/ActivityStack.java
index e1b8278..b61bd8a 100755
--- a/services/core/java/com/android/server/am/ActivityStack.java
+++ b/services/core/java/com/android/server/am/ActivityStack.java
@@ -835,7 +835,7 @@
         prev.task.touchActiveTime();
         clearLaunchTime(prev);
         final ActivityRecord next = mStackSupervisor.topRunningActivityLocked();
-        if (mService.mHasRecents && (next == null || next.noDisplay || next.task != prev.task)) {
+        if (mService.mHasRecents && (next == null || next.noDisplay || next.task != prev.task || uiSleeping)) {
             prev.updateThumbnail(screenshotActivities(prev), null);
         }
         stopFullyDrawnTraceIfNeeded();
diff --git a/services/core/java/com/android/server/am/ProcessList.java b/services/core/java/com/android/server/am/ProcessList.java
index 5b22255..843a0cb 100644
--- a/services/core/java/com/android/server/am/ProcessList.java
+++ b/services/core/java/com/android/server/am/ProcessList.java
@@ -235,22 +235,16 @@
             Slog.i("XXXXXX", "minfree_adj=" + minfree_adj + " minfree_abs=" + minfree_abs);
         }
 
-        // We've now baked in the increase to the basic oom values above, since
-        // they seem to be useful more generally for devices that are tight on
-        // memory than just for 64 bit.  This should probably have some more
-        // tuning done, so not deleting it quite yet...
-        final boolean is64bit = false; //Build.SUPPORTED_64_BIT_ABIS.length > 0;
+        if (Build.SUPPORTED_64_BIT_ABIS.length > 0) {
+            // Increase the high min-free levels for cached processes for 64-bit
+            mOomMinFreeHigh[4] = 225000;
+            mOomMinFreeHigh[5] = 325000;
+        }
 
         for (int i=0; i<mOomAdj.length; i++) {
             int low = mOomMinFreeLow[i];
             int high = mOomMinFreeHigh[i];
             mOomMinFree[i] = (int)(low + ((high-low)*scale));
-            if (is64bit) {
-                // On 64 bit devices, we consume more baseline RAM, because 64 bit is cool!
-                // To avoid being all pagey and stuff, scale up the memory levels to
-                // give us some breathing room.
-                mOomMinFree[i] = (3*mOomMinFree[i])/2;
-            }
         }
 
         if (minfree_abs >= 0) {
diff --git a/services/core/java/com/android/server/wm/WindowAnimator.java b/services/core/java/com/android/server/wm/WindowAnimator.java
index 61ea1e8..8d93141 100644
--- a/services/core/java/com/android/server/wm/WindowAnimator.java
+++ b/services/core/java/com/android/server/wm/WindowAnimator.java
@@ -91,6 +91,9 @@
     boolean mKeyguardGoingAwayToNotificationShade;
     boolean mKeyguardGoingAwayDisableWindowAnimations;
 
+    /** Use one animation for all entering activities after keyguard is dismissed. */
+    Animation mPostKeyguardExitAnimation;
+
     // forceHiding states.
     static final int KEYGUARD_NOT_SHOWN     = 0;
     static final int KEYGUARD_ANIMATING_IN  = 1;
@@ -220,9 +223,6 @@
         ++mAnimTransactionSequence;
 
         final WindowList windows = mService.getWindowListLocked(displayId);
-        ArrayList<WindowStateAnimator> unForceHiding = null;
-        boolean wallpaperInUnForceHiding = false;
-        WindowState wallpaper = null;
 
         if (mKeyguardGoingAway) {
             for (int i = windows.size() - 1; i >= 0; i--) {
@@ -261,6 +261,9 @@
         final AppWindowToken appShowWhenLocked = winShowWhenLocked == null ?
                 null : winShowWhenLocked.mAppToken;
 
+        boolean wallpaperInUnForceHiding = false;
+        ArrayList<WindowStateAnimator> unForceHiding = null;
+        WindowState wallpaper = null;
         for (int i = windows.size() - 1; i >= 0; i--) {
             WindowState win = windows.get(i);
             WindowStateAnimator winAnimator = win.mWinAnimator;
@@ -327,40 +330,53 @@
                 } else if (mPolicy.canBeForceHidden(win, win.mAttrs)) {
                     final boolean hideWhenLocked = !((win.mIsImWindow && showImeOverKeyguard) ||
                             (appShowWhenLocked != null && appShowWhenLocked == win.mAppToken));
-                    final boolean changed;
                     if (((mForceHiding == KEYGUARD_ANIMATING_IN)
                                 && (!winAnimator.isAnimating() || hideWhenLocked))
                             || ((mForceHiding == KEYGUARD_SHOWN) && hideWhenLocked)) {
-                        changed = win.hideLw(false, false);
-                        if ((DEBUG_KEYGUARD || WindowManagerService.DEBUG_VISIBILITY)
-                                && changed) Slog.v(TAG, "Now policy hidden: " + win);
+                        if (!win.hideLw(false, false)) {
+                            // Was already hidden
+                            continue;
+                        }
+                        if (DEBUG_KEYGUARD || WindowManagerService.DEBUG_VISIBILITY) Slog.v(TAG,
+                                "Now policy hidden: " + win);
                     } else {
-                        changed = win.showLw(false, false);
-                        if ((DEBUG_KEYGUARD || WindowManagerService.DEBUG_VISIBILITY)
-                                && changed) Slog.v(TAG, "Now policy shown: " + win);
-                        if (changed) {
-                            if ((mBulkUpdateParams & SET_FORCE_HIDING_CHANGED) != 0
-                                    && win.isVisibleNow() /*w.isReadyForDisplay()*/) {
-                                if (unForceHiding == null) {
-                                    unForceHiding = new ArrayList<WindowStateAnimator>();
-                                }
-                                unForceHiding.add(winAnimator);
-                                if ((flags & FLAG_SHOW_WALLPAPER) != 0) {
-                                    wallpaperInUnForceHiding = true;
-                                }
+                        if (!win.showLw(false, false)) {
+                            // Was already showing.
+                            continue;
+                        }
+                        final boolean visibleNow = win.isVisibleNow();
+                        if (!visibleNow) {
+                            // Couldn't really show, must showLw() again when win becomes visible.
+                            win.hideLw(false, false);
+                            continue;
+                        }
+                        if (DEBUG_KEYGUARD || WindowManagerService.DEBUG_VISIBILITY) Slog.v(TAG,
+                                "Now policy shown: " + win);
+                        if ((mBulkUpdateParams & SET_FORCE_HIDING_CHANGED) != 0) {
+                            if (unForceHiding == null) {
+                                unForceHiding = new ArrayList<>();
                             }
-                            final WindowState currentFocus = mService.mCurrentFocus;
-                            if (currentFocus == null || currentFocus.mLayer < win.mLayer) {
-                                // We are showing on to of the current
-                                // focus, so re-evaluate focus to make
-                                // sure it is correct.
-                                if (WindowManagerService.DEBUG_FOCUS_LIGHT) Slog.v(TAG,
-                                        "updateWindowsLocked: setting mFocusMayChange true");
-                                mService.mFocusMayChange = true;
+                            unForceHiding.add(winAnimator);
+                            if ((flags & FLAG_SHOW_WALLPAPER) != 0) {
+                                wallpaperInUnForceHiding = true;
                             }
+                        } else if (mPostKeyguardExitAnimation != null) {
+                            // We're already in the middle of an animation. Use the existing
+                            // animation to bring in this window.
+                            winAnimator.setAnimation(mPostKeyguardExitAnimation);
+                            winAnimator.keyguardGoingAwayAnimation = true;
+                        }
+                        final WindowState currentFocus = mService.mCurrentFocus;
+                        if (currentFocus == null || currentFocus.mLayer < win.mLayer) {
+                            // We are showing on top of the current
+                            // focus, so re-evaluate focus to make
+                            // sure it is correct.
+                            if (WindowManagerService.DEBUG_FOCUS_LIGHT) Slog.v(TAG,
+                                    "updateWindowsLocked: setting mFocusMayChange true");
+                            mService.mFocusMayChange = true;
                         }
                     }
-                    if (changed && (flags & FLAG_SHOW_WALLPAPER) != 0) {
+                    if ((flags & FLAG_SHOW_WALLPAPER) != 0) {
                         mBulkUpdateParams |= SET_WALLPAPER_MAY_CHANGE;
                         setPendingLayoutChanges(Display.DEFAULT_DISPLAY,
                                 WindowManagerPolicy.FINISH_LAYOUT_REDO_WALLPAPER);
@@ -403,42 +419,44 @@
         // If we have windows that are being show due to them no longer
         // being force-hidden, apply the appropriate animation to them.
         if (unForceHiding != null) {
-            boolean startKeyguardExit = true;
-            for (int i=unForceHiding.size()-1; i>=0; i--) {
-                Animation a = null;
-                if (!mKeyguardGoingAwayDisableWindowAnimations) {
-                    a = mPolicy.createForceHideEnterAnimation(wallpaperInUnForceHiding,
-                            mKeyguardGoingAwayToNotificationShade);
-                    if (DEBUG_KEYGUARD) Slog.d(TAG, "updateWindowsLocked: created anim=" + a
-                            + " for win=" + unForceHiding.get(i));
-                } else {
-                    if (DEBUG_KEYGUARD) Slog.d(TAG, "updateWindowsLocked: skipping anim for win="
-                            + unForceHiding.get(i));
-                }
-                if (a != null) {
+            // This only happens the first time that we detect the keyguard is animating out.
+            if (mKeyguardGoingAwayDisableWindowAnimations) {
+                if (DEBUG_KEYGUARD) Slog.d(TAG, "updateWindowsLocked: skipping anim for windows");
+            } else {
+                if (DEBUG_KEYGUARD) Slog.d(TAG, "updateWindowsLocked: created anim for windows");
+                mPostKeyguardExitAnimation = mPolicy.createForceHideEnterAnimation(
+                        wallpaperInUnForceHiding, mKeyguardGoingAwayToNotificationShade);
+            }
+            if (mPostKeyguardExitAnimation != null) {
+                for (int i=unForceHiding.size()-1; i>=0; i--) {
                     final WindowStateAnimator winAnimator = unForceHiding.get(i);
-                    winAnimator.setAnimation(a);
+                    winAnimator.setAnimation(mPostKeyguardExitAnimation);
                     winAnimator.keyguardGoingAwayAnimation = true;
-                    if (startKeyguardExit && mKeyguardGoingAway) {
-                        // Do one time only.
-                        mPolicy.startKeyguardExitAnimation(mCurrentTime + a.getStartOffset(),
-                                a.getDuration());
-                        mKeyguardGoingAway = false;
-                        startKeyguardExit = false;
-                    }
                 }
             }
+        }
 
-            // Wallpaper is going away in un-force-hide motion, animate it as well.
-            if (!wallpaperInUnForceHiding && wallpaper != null
-                    && !mKeyguardGoingAwayDisableWindowAnimations) {
-                if (DEBUG_KEYGUARD) Slog.d(TAG, "updateWindowsLocked: wallpaper animating away");
-                Animation a = mPolicy.createForceHideWallpaperExitAnimation(
-                        mKeyguardGoingAwayToNotificationShade);
-                if (a != null) {
-                    WindowStateAnimator animator = wallpaper.mWinAnimator;
-                    animator.setAnimation(a);
-                }
+        if (mPostKeyguardExitAnimation != null) {
+            // We're in the midst of a keyguard exit animation.
+            if (mKeyguardGoingAway) {
+                mPolicy.startKeyguardExitAnimation(mCurrentTime +
+                        mPostKeyguardExitAnimation.getStartOffset(),
+                        mPostKeyguardExitAnimation.getDuration());
+                mKeyguardGoingAway = false;
+            } else if (mPostKeyguardExitAnimation.hasEnded()) {
+                // Done with the animation, reset.
+                mPostKeyguardExitAnimation = null;
+            }
+        }
+
+        // Wallpaper is going away in un-force-hide motion, animate it as well.
+        if (!wallpaperInUnForceHiding && wallpaper != null
+                && !mKeyguardGoingAwayDisableWindowAnimations) {
+            if (DEBUG_KEYGUARD) Slog.d(TAG, "updateWindowsLocked: wallpaper animating away");
+            Animation a = mPolicy.createForceHideWallpaperExitAnimation(
+                    mKeyguardGoingAwayToNotificationShade);
+            if (a != null) {
+                wallpaper.mWinAnimator.setAnimation(a);
             }
         }
     }
diff --git a/telephony/java/android/telephony/SubInfoRecord.java b/telephony/java/android/telephony/SubInfoRecord.java
index 0966ddb..e08f255 100644
--- a/telephony/java/android/telephony/SubInfoRecord.java
+++ b/telephony/java/android/telephony/SubInfoRecord.java
@@ -222,7 +222,7 @@
             int id = source.readInt();
             String iccId = source.readString();
             int simSlotIndex = source.readInt();
-            String displayName = source.readString();
+            CharSequence displayName = source.readCharSequence();
             int nameSource = source.readInt();
             int color = source.readInt();
             String number = source.readString();
@@ -247,7 +247,7 @@
         dest.writeInt(mId);
         dest.writeString(mIccId);
         dest.writeInt(mSimSlotIndex);
-        dest.writeString(mDisplayName.toString());
+        dest.writeCharSequence(mDisplayName);
         dest.writeInt(mNameSource);
         dest.writeInt(mColor);
         dest.writeString(mNumber.toString());