Merge "Enforce background fallback to be non-translucent" into nyc-dev
diff --git a/core/java/android/app/ActivityTransitionState.java b/core/java/android/app/ActivityTransitionState.java
index 4a1aff7..02eb4d3 100644
--- a/core/java/android/app/ActivityTransitionState.java
+++ b/core/java/android/app/ActivityTransitionState.java
@@ -284,7 +284,7 @@
     }
 
     public boolean startExitBackTransition(final Activity activity) {
-        if (mEnteringNames == null) {
+        if (mEnteringNames == null || mCalledExitCoordinator != null) {
             return false;
         } else {
             if (!mHasExited) {
diff --git a/core/java/android/app/EnterTransitionCoordinator.java b/core/java/android/app/EnterTransitionCoordinator.java
index a599584..8bf1e9a 100644
--- a/core/java/android/app/EnterTransitionCoordinator.java
+++ b/core/java/android/app/EnterTransitionCoordinator.java
@@ -150,6 +150,7 @@
                 }
             };
             decor.getViewTreeObserver().addOnPreDrawListener(mViewsReadyListener);
+            decor.invalidate();
         }
     }
 
diff --git a/packages/DocumentsUI/src/com/android/documentsui/FilesActivity.java b/packages/DocumentsUI/src/com/android/documentsui/FilesActivity.java
index 57c14e9..b82f8dd 100644
--- a/packages/DocumentsUI/src/com/android/documentsui/FilesActivity.java
+++ b/packages/DocumentsUI/src/com/android/documentsui/FilesActivity.java
@@ -86,17 +86,26 @@
         if (mState.restored) {
             if (DEBUG) Log.d(TAG, "Stack already resolved for uri: " + intent.getData());
         } else if (!mState.stack.isEmpty()) {
-            // If a non-empty stack is present in our state it was read (presumably)
+            // If a non-empty stack is present in our state, it was read (presumably)
             // from EXTRA_STACK intent extra. In this case, we'll skip other means of
-            // loading or restoring the stack.
+            // loading or restoring the stack (like URI).
             //
-            // When restoring from a stack, if a URI is present, it should only ever
-            // be a launch URI, or a fake Uri from notifications.
-            // Launch URIs support sensible activity management, but don't specify a real
-            // content target.
-            if (DEBUG) Log.d(TAG, "Launching with non-empty stack.");
-            assert(uri == null || uri.getAuthority() == null ||
-                    LauncherActivity.isLaunchUri(uri));
+            // When restoring from a stack, if a URI is present, it should only ever be:
+            // -- a launch URI: Launch URIs support sensible activity management,
+            //    but don't specify a real content target)
+            // -- a fake Uri from notifications. These URIs have no authority (TODO: details).
+            //
+            // Any other URI is *sorta* unexpected...except when browsing an archive
+            // in downloads.
+            if(uri != null
+                    && uri.getAuthority() != null
+                    && !uri.equals(mState.stack.peek())
+                    && !LauncherActivity.isLaunchUri(uri)) {
+                if (DEBUG) Log.w(TAG,
+                        "Launching with non-empty stack. Ignoring unexpected uri: " + uri);
+            } else {
+                if (DEBUG) Log.d(TAG, "Launching with non-empty stack.");
+            }
             refreshCurrentRootAndDirectory(AnimationView.ANIM_NONE);
         } else if (Intent.ACTION_VIEW.equals(intent.getAction())) {
             assert(uri != null);
diff --git a/packages/SystemUI/src/com/android/systemui/stackdivider/DividerView.java b/packages/SystemUI/src/com/android/systemui/stackdivider/DividerView.java
index d09587b..998f50f 100644
--- a/packages/SystemUI/src/com/android/systemui/stackdivider/DividerView.java
+++ b/packages/SystemUI/src/com/android/systemui/stackdivider/DividerView.java
@@ -1064,6 +1064,14 @@
         int position = DockedDividerUtils.calculatePositionForBounds(event.initialRect,
                 mDockSide, mDividerSize);
         mEntranceAnimationRunning = true;
+
+        // Insets might not have been fetched yet, so fetch manually if needed.
+        if (mStableInsets.isEmpty()) {
+            SystemServicesProxy.getInstance(mContext).getStableInsets(mStableInsets);
+            mSnapAlgorithm = null;
+            initializeSnapAlgorithm();
+        }
+
         resizeStack(position, mSnapAlgorithm.getMiddleTarget().position,
                 mSnapAlgorithm.getMiddleTarget());
     }
diff --git a/services/core/java/com/android/server/am/ActiveServices.java b/services/core/java/com/android/server/am/ActiveServices.java
index 6a8c8b0..dcd9b0c 100755
--- a/services/core/java/com/android/server/am/ActiveServices.java
+++ b/services/core/java/com/android/server/am/ActiveServices.java
@@ -2201,11 +2201,11 @@
                     // If the app is null, then it was probably removed because the process died,
                     // otherwise wtf
                     if (r.app != null) {
-                        Slog.wtfStack(TAG, "Service done with onDestroy, but not inDestroying: "
+                        Slog.w(TAG, "Service done with onDestroy, but not inDestroying: "
                                 + r + ", app=" + r.app);
                     }
                 } else if (r.executeNesting != 1) {
-                    Slog.wtfStack(TAG, "Service done with onDestroy, but executeNesting="
+                    Slog.w(TAG, "Service done with onDestroy, but executeNesting="
                             + r.executeNesting + ": " + r);
                     // Fake it to keep from ANR due to orphaned entry.
                     r.executeNesting = 1;
diff --git a/services/core/java/com/android/server/notification/NotificationManagerService.java b/services/core/java/com/android/server/notification/NotificationManagerService.java
index b5a8bf3..a8b1a4a 100644
--- a/services/core/java/com/android/server/notification/NotificationManagerService.java
+++ b/services/core/java/com/android/server/notification/NotificationManagerService.java
@@ -2582,6 +2582,9 @@
         }
         if (notification.actions != null) {
             for (Notification.Action action: notification.actions) {
+                if (action.actionIntent == null) {
+                    continue;
+                }
                 am.setPendingIntentWhitelistDuration(action.actionIntent.getTarget(), duration);
                 setPendingIntentWhitelistDuration(am, duration, action.getExtras());
                 final RemoteInput[] remoteInputs = action.getRemoteInputs();
diff --git a/services/core/java/com/android/server/pm/PackageManagerService.java b/services/core/java/com/android/server/pm/PackageManagerService.java
index a2bdde4..eb4d755 100644
--- a/services/core/java/com/android/server/pm/PackageManagerService.java
+++ b/services/core/java/com/android/server/pm/PackageManagerService.java
@@ -2395,6 +2395,10 @@
             mPromoteSystemApps =
                     mIsUpgrade && ver.sdkVersion <= Build.VERSION_CODES.LOLLIPOP_MR1;
 
+            // When upgrading from pre-N, we need to handle package extraction like first boot,
+            // as there is no profiling data available.
+            mIsPreNUpgrade = mIsUpgrade && ver.sdkVersion < Build.VERSION_CODES.N;
+
             // save off the names of pre-existing system packages prior to scanning; we don't
             // want to automatically grant runtime permissions for new system apps
             if (mPromoteSystemApps) {
@@ -2407,11 +2411,6 @@
                 }
             }
 
-            // When upgrading from pre-N, we need to handle package extraction like first boot,
-            // as there is no profiling data available.
-            mIsPreNUpgrade = !mSettings.isNWorkDone();
-            mSettings.setNWorkDone();
-
             // Collect vendor overlay packages.
             // (Do this before scanning any apps.)
             // For security and version matching reason, only consider
diff --git a/services/core/java/com/android/server/pm/Settings.java b/services/core/java/com/android/server/pm/Settings.java
index 75bd35c..dfd6dfe 100644
--- a/services/core/java/com/android/server/pm/Settings.java
+++ b/services/core/java/com/android/server/pm/Settings.java
@@ -191,7 +191,6 @@
     private static final String TAG_DEFAULT_BROWSER = "default-browser";
     private static final String TAG_DEFAULT_DIALER = "default-dialer";
     private static final String TAG_VERSION = "version";
-    private static final String TAG_N_WORK = "n-work";
 
     private static final String ATTR_NAME = "name";
     private static final String ATTR_USER = "user";
@@ -398,17 +397,6 @@
 
     public final KeySetManagerService mKeySetManagerService = new KeySetManagerService(mPackages);
 
-    /**
-     * Used to track whether N+ work has been done. This is similar to the file-system level
-     * and denotes that first-boot or upgrade-to-N work has been done.
-     *
-     * Note: the flag has been added to a) allow tracking while an API level check is impossible
-     *       and b) to merge upgrade as well as first boot (because the flag is false, by default).
-     *
-     * STOPSHIP: b/27872764
-     */
-    private boolean mIsNWorkDone = false;
-
     Settings(Object lock) {
         this(Environment.getDataDirectory(), lock);
     }
@@ -2396,10 +2384,6 @@
 
             mKeySetManagerService.writeKeySetManagerServiceLPr(serializer);
 
-            serializer.startTag(null, TAG_N_WORK);
-            serializer.attribute(null, ATTR_DONE, Boolean.toString(mIsNWorkDone));
-            serializer.endTag(null, TAG_N_WORK);
-
             serializer.endTag(null, "packages");
 
             serializer.endDocument();
@@ -2937,8 +2921,6 @@
                     ver.sdkVersion = XmlUtils.readIntAttribute(parser, ATTR_SDK_VERSION);
                     ver.databaseVersion = XmlUtils.readIntAttribute(parser, ATTR_SDK_VERSION);
                     ver.fingerprint = XmlUtils.readStringAttribute(parser, ATTR_FINGERPRINT);
-                } else if (TAG_N_WORK.equals(tagName)) {
-                    mIsNWorkDone = XmlUtils.readBooleanAttribute(parser, ATTR_DONE, false);
                 } else {
                     Slog.w(PackageManagerService.TAG, "Unknown element under <packages>: "
                             + parser.getName());
@@ -4233,14 +4215,6 @@
         return res;
     }
 
-    public boolean isNWorkDone() {
-        return mIsNWorkDone;
-    }
-
-    void setNWorkDone() {
-        mIsNWorkDone = true;
-    }
-
     static void printFlags(PrintWriter pw, int val, Object[] spec) {
         pw.print("[ ");
         for (int i=0; i<spec.length; i+=2) {