Merge "No QS hotspot unless supported" into nyc-dev
diff --git a/api/current.txt b/api/current.txt
index 5df8750..78b8501 100644
--- a/api/current.txt
+++ b/api/current.txt
@@ -46665,6 +46665,7 @@
     ctor public FrameLayout.LayoutParams(android.view.ViewGroup.LayoutParams);
     ctor public FrameLayout.LayoutParams(android.view.ViewGroup.MarginLayoutParams);
     ctor public FrameLayout.LayoutParams(android.widget.FrameLayout.LayoutParams);
+    field public static final int UNSPECIFIED_GRAVITY = -1; // 0xffffffff
     field public int gravity;
   }
 
diff --git a/api/system-current.txt b/api/system-current.txt
index 5ea800c..14391a3 100644
--- a/api/system-current.txt
+++ b/api/system-current.txt
@@ -49966,6 +49966,7 @@
     ctor public FrameLayout.LayoutParams(android.view.ViewGroup.LayoutParams);
     ctor public FrameLayout.LayoutParams(android.view.ViewGroup.MarginLayoutParams);
     ctor public FrameLayout.LayoutParams(android.widget.FrameLayout.LayoutParams);
+    field public static final int UNSPECIFIED_GRAVITY = -1; // 0xffffffff
     field public int gravity;
   }
 
diff --git a/api/test-current.txt b/api/test-current.txt
index e4b11bd..4e83278 100644
--- a/api/test-current.txt
+++ b/api/test-current.txt
@@ -46742,6 +46742,7 @@
     ctor public FrameLayout.LayoutParams(android.view.ViewGroup.LayoutParams);
     ctor public FrameLayout.LayoutParams(android.view.ViewGroup.MarginLayoutParams);
     ctor public FrameLayout.LayoutParams(android.widget.FrameLayout.LayoutParams);
+    field public static final int UNSPECIFIED_GRAVITY = -1; // 0xffffffff
     field public int gravity;
   }
 
diff --git a/core/java/android/view/ThreadedRenderer.java b/core/java/android/view/ThreadedRenderer.java
index 206ba16..34110df 100644
--- a/core/java/android/view/ThreadedRenderer.java
+++ b/core/java/android/view/ThreadedRenderer.java
@@ -307,6 +307,12 @@
     private static final int SYNC_INVALIDATE_REQUIRED = 1 << 0;
     // Spoiler: the reward is GPU-accelerated drawing, better find that Surface!
     private static final int SYNC_LOST_SURFACE_REWARD_IF_FOUND = 1 << 1;
+    // setStopped is true, drawing is false
+    // TODO: Remove this and SYNC_LOST_SURFACE_REWARD_IF_FOUND?
+    // This flag isn't really used as there's nothing that we care to do
+    // in response, so it really just exists to differentiate from LOST_SURFACE
+    // but possibly both can just be deleted.
+    private static final int SYNC_CONTEXT_IS_STOPPED = 1 << 2;
 
     private static final String[] VISUALIZERS = {
         PROFILE_PROPERTY_VISUALIZE_BARS,
diff --git a/core/java/android/widget/FrameLayout.java b/core/java/android/widget/FrameLayout.java
index 9ac4917..029313c 100644
--- a/core/java/android/widget/FrameLayout.java
+++ b/core/java/android/widget/FrameLayout.java
@@ -417,22 +417,28 @@
      */
     public static class LayoutParams extends MarginLayoutParams {
         /**
+         * Value for {@link #gravity} indicating that a gravity has not been
+         * explicitly specified.
+         */
+        public static final int UNSPECIFIED_GRAVITY = -1;
+
+        /**
          * The gravity to apply with the View to which these layout parameters
          * are associated.
          * <p>
-         * The default value is {@code Gravity.TOP | Gravity.START}
+         * The default value is {@link #UNSPECIFIED_GRAVITY}, which is treated
+         * by FrameLayout as {@code Gravity.TOP | Gravity.START}.
          *
          * @see android.view.Gravity
          * @attr ref android.R.styleable#FrameLayout_Layout_layout_gravity
          */
-        public int gravity = DEFAULT_CHILD_GRAVITY;
+        public int gravity = UNSPECIFIED_GRAVITY;
 
         public LayoutParams(@NonNull Context c, @Nullable AttributeSet attrs) {
             super(c, attrs);
 
             final TypedArray a = c.obtainStyledAttributes(attrs, R.styleable.FrameLayout_Layout);
-            gravity = a.getInt(R.styleable.FrameLayout_Layout_layout_gravity,
-                    DEFAULT_CHILD_GRAVITY);
+            gravity = a.getInt(R.styleable.FrameLayout_Layout_layout_gravity, UNSPECIFIED_GRAVITY);
             a.recycle();
         }
 
diff --git a/libs/hwui/renderthread/DrawFrameTask.cpp b/libs/hwui/renderthread/DrawFrameTask.cpp
index ed472ac..c9c07b3 100644
--- a/libs/hwui/renderthread/DrawFrameTask.cpp
+++ b/libs/hwui/renderthread/DrawFrameTask.cpp
@@ -32,7 +32,7 @@
 DrawFrameTask::DrawFrameTask()
         : mRenderThread(nullptr)
         , mContext(nullptr)
-        , mSyncResult(kSync_OK) {
+        , mSyncResult(SyncResult::OK) {
 }
 
 DrawFrameTask::~DrawFrameTask() {
@@ -68,7 +68,7 @@
 int DrawFrameTask::drawFrame(TreeObserver* observer) {
     LOG_ALWAYS_FATAL_IF(!mContext, "Cannot drawFrame with no CanvasContext!");
 
-    mSyncResult = kSync_OK;
+    mSyncResult = SyncResult::OK;
     mSyncQueued = systemTime(CLOCK_MONOTONIC);
     mObserver = observer;
     postAndWait();
@@ -127,13 +127,18 @@
     // This is after the prepareTree so that any pending operations
     // (RenderNode tree state, prefetched layers, etc...) will be flushed.
     if (CC_UNLIKELY(!mContext->hasSurface() || !canDraw)) {
-        mSyncResult |= kSync_LostSurfaceRewardIfFound;
+        if (!mContext->hasSurface()) {
+            mSyncResult |= SyncResult::LostSurfaceRewardIfFound;
+        } else {
+            // If we have a surface but can't draw we must be stopped
+            mSyncResult |= SyncResult::ContextIsStopped;
+        }
         info.out.canDrawThisFrame = false;
     }
 
     if (info.out.hasAnimations) {
         if (info.out.requiresUiRedraw) {
-            mSyncResult |= kSync_UIRedrawRequired;
+            mSyncResult |= SyncResult::UIRedrawRequired;
         }
     }
     // If prepareTextures is false, we ran out of texture cache space
diff --git a/libs/hwui/renderthread/DrawFrameTask.h b/libs/hwui/renderthread/DrawFrameTask.h
index 9bba065..c02d376 100644
--- a/libs/hwui/renderthread/DrawFrameTask.h
+++ b/libs/hwui/renderthread/DrawFrameTask.h
@@ -40,11 +40,14 @@
 class CanvasContext;
 class RenderThread;
 
-enum SyncResult {
-    kSync_OK = 0,
-    kSync_UIRedrawRequired = 1 << 0,
-    kSync_LostSurfaceRewardIfFound = 1 << 1,
+namespace SyncResult {
+enum {
+    OK = 0,
+    UIRedrawRequired = 1 << 0,
+    LostSurfaceRewardIfFound = 1 << 1,
+    ContextIsStopped = 1 << 2,
 };
+}
 
 /*
  * This is a special Super Task. It is re-used multiple times by RenderProxy,
diff --git a/opengl/java/android/opengl/GLSurfaceView.java b/opengl/java/android/opengl/GLSurfaceView.java
index f37ec58..38ed932 100644
--- a/opengl/java/android/opengl/GLSurfaceView.java
+++ b/opengl/java/android/opengl/GLSurfaceView.java
@@ -547,7 +547,9 @@
      */
     @Override
     public void surfaceRedrawNeeded(SurfaceHolder holder) {
-        mGLThread.requestRenderAndWait();
+        if (mGLThread != null) {
+            mGLThread.requestRenderAndWait();
+        }
     }
 
 
diff --git a/packages/SettingsLib/res/values/strings.xml b/packages/SettingsLib/res/values/strings.xml
index 699f827..74c98e4 100644
--- a/packages/SettingsLib/res/values/strings.xml
+++ b/packages/SettingsLib/res/values/strings.xml
@@ -215,7 +215,7 @@
     <string name="tether_settings_title_all">Tethering &amp; portable hotspot</string>
 
     <!-- Title for a work profile. [CHAR LIMIT=25] -->
-    <string name="managed_user_title">Work profile</string>
+    <string name="managed_user_title">All work apps</string>
 
     <!-- Title for Guest user [CHAR LIMIT=35] -->
     <string name="user_guest">Guest</string>
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBar.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBar.java
index b75c2916..d3f3b2d 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBar.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBar.java
@@ -34,6 +34,7 @@
 import android.content.IntentFilter;
 import android.content.pm.IPackageManager;
 import android.content.pm.PackageManager;
+import android.content.pm.UserInfo;
 import android.content.res.Configuration;
 import android.content.res.Resources;
 import android.database.ContentObserver;
@@ -3950,9 +3951,17 @@
     }
 
     private void updatePublicMode() {
-        setLockscreenPublicMode(
-                mStatusBarKeyguardViewManager.isShowing() && mStatusBarKeyguardViewManager
-                        .isSecure(mCurrentUserId));
+        boolean isPublic = false;
+        if (mStatusBarKeyguardViewManager.isShowing()) {
+            for (int i = mCurrentProfiles.size() - 1; i >= 0; i--) {
+                UserInfo userInfo = mCurrentProfiles.valueAt(i);
+                if (mStatusBarKeyguardViewManager.isSecure(userInfo.id)) {
+                    isPublic = true;
+                    break;
+                }
+            }
+        }
+        setLockscreenPublicMode(isPublic);
     }
 
     protected void updateKeyguardState(boolean goingToFullShade, boolean fromShadeLocked) {