Merge "Making ViewRootImpl drop input events when the Activity is in ambient mode." into cw-e-dev am: cbef517d02 am: 898e330aae am: 94794af6be
am: 3f66df086a

* commit '3f66df086a210bc0dec7a0bd86081f6f79b3a712':
  Making ViewRootImpl drop input events when the Activity is in ambient mode.
diff --git a/core/java/android/view/ViewRootImpl.java b/core/java/android/view/ViewRootImpl.java
index faf2640..0ed007d 100644
--- a/core/java/android/view/ViewRootImpl.java
+++ b/core/java/android/view/ViewRootImpl.java
@@ -197,6 +197,10 @@
     // so the window should no longer be active.
     boolean mStopped = false;
 
+    // Set to true if the owner of this window is in ambient mode,
+    // which means it won't receive input events.
+    boolean mIsAmbientMode = false;
+
     // Set to true to stop input during an Activity Transition.
     boolean mPausedForTransition = false;
 
@@ -1032,6 +1036,10 @@
         }
     }
 
+    public void setIsAmbientMode(boolean ambient) {
+        mIsAmbientMode = ambient;
+    }
+
     void setWindowStopped(boolean stopped) {
         if (mStopped != stopped) {
             mStopped = stopped;
@@ -3685,7 +3693,7 @@
                 return true;
             } else if ((!mAttachInfo.mHasWindowFocus
                     && !q.mEvent.isFromSource(InputDevice.SOURCE_CLASS_POINTER)) || mStopped
-                    || (mPausedForTransition && !isBack(q.mEvent))) {
+                    || mIsAmbientMode || (mPausedForTransition && !isBack(q.mEvent))) {
                 // This is a focus event and the window doesn't currently have input focus or
                 // has stopped. This could be an event that came back from the previous stage
                 // but the window has lost focus or stopped in the meantime.
@@ -5511,6 +5519,8 @@
                 writer.println(mProcessInputEventsScheduled);
         writer.print(innerPrefix); writer.print("mTraversalScheduled=");
                 writer.print(mTraversalScheduled);
+        writer.print(innerPrefix); writer.print("mIsAmbientMode=");
+                writer.print(mIsAmbientMode);
         if (mTraversalScheduled) {
             writer.print(" (barrier="); writer.print(mTraversalBarrier); writer.println(")");
         } else {