@@ -6569,6 +6569,36 @@ private void handleNotifyRotationChanged(int displayId, int rotation) {
65696569 }
65706570 }
65716571
6572+ private void scheduleNotifyWindowLayersChangedIfNeededLocked (DisplayContent displayContent ) {
6573+ if (displayContent .mDisplayContentChangeListeners != null
6574+ && displayContent .mDisplayContentChangeListeners .getRegisteredCallbackCount () > 0 ) {
6575+ mH .obtainMessage (H .NOTIFY_WINDOW_LAYERS_CHANGED , displayContent ) .sendToTarget ();
6576+ }
6577+ }
6578+
6579+ private void handleNotifyWindowLayersChanged (DisplayContent displayContent ) {
6580+ RemoteCallbackList <IDisplayContentChangeListener > callbacks = null ;
6581+ synchronized (mWindowMap ) {
6582+ callbacks = displayContent .mDisplayContentChangeListeners ;
6583+ if (callbacks == null ) {
6584+ return ;
6585+ }
6586+ }
6587+ try {
6588+ final int watcherCount = callbacks .beginBroadcast ();
6589+ for (int i = 0 ; i < watcherCount ; i ++) {
6590+ try {
6591+ callbacks .getBroadcastItem (i ).onWindowLayersChanged (
6592+ displayContent .getDisplayId ());
6593+ } catch (RemoteException re ) {
6594+ /* ignore */
6595+ }
6596+ }
6597+ } finally {
6598+ callbacks .finishBroadcast ();
6599+ }
6600+ }
6601+
65726602 public void addWindowChangeListener (WindowChangeListener listener ) {
65736603 synchronized (mWindowMap ) {
65746604 mWindowChangeListeners .add (listener );
@@ -7215,12 +7245,13 @@ final class H extends Handler {
72157245 public static final int NOTIFY_ROTATION_CHANGED = 28 ;
72167246 public static final int NOTIFY_WINDOW_TRANSITION = 29 ;
72177247 public static final int NOTIFY_RECTANGLE_ON_SCREEN_REQUESTED = 30 ;
7248+ public static final int NOTIFY_WINDOW_LAYERS_CHANGED = 31 ;
72187249
7219- public static final int DO_DISPLAY_ADDED = 31 ;
7220- public static final int DO_DISPLAY_REMOVED = 32 ;
7221- public static final int DO_DISPLAY_CHANGED = 33 ;
7250+ public static final int DO_DISPLAY_ADDED = 32 ;
7251+ public static final int DO_DISPLAY_REMOVED = 33 ;
7252+ public static final int DO_DISPLAY_CHANGED = 34 ;
72227253
7223- public static final int CLIENT_FREEZE_TIMEOUT = 34 ;
7254+ public static final int CLIENT_FREEZE_TIMEOUT = 35 ;
72247255
72257256 public static final int ANIMATOR_WHAT_OFFSET = 100000 ;
72267257 public static final int SET_TRANSPARENT_REGION = ANIMATOR_WHAT_OFFSET + 1 ;
@@ -7692,6 +7723,12 @@ public void handleMessage(Message msg) {
76927723 break ;
76937724 }
76947725
7726+ case NOTIFY_WINDOW_LAYERS_CHANGED : {
7727+ DisplayContent displayContent = (DisplayContent ) msg .obj ;
7728+ handleNotifyWindowLayersChanged (displayContent );
7729+ break ;
7730+ }
7731+
76957732 case DO_DISPLAY_ADDED :
76967733 synchronized (mWindowMap ) {
76977734 handleDisplayAddedLocked (msg .arg1 );
@@ -8068,6 +8105,8 @@ private final void assignLayersLocked(WindowList windows) {
80688105 Slog .v (TAG , "Assigning layers" , here );
80698106 }
80708107
8108+ boolean anyLayerChanged = false ;
8109+
80718110 for (i =0 ; i <N ; i ++) {
80728111 final WindowState w = windows .get (i );
80738112 final WindowStateAnimator winAnimator = w .mWinAnimator ;
@@ -8083,6 +8122,7 @@ private final void assignLayersLocked(WindowList windows) {
80838122 }
80848123 if (w .mLayer != oldLayer ) {
80858124 layerChanged = true ;
8125+ anyLayerChanged = true ;
80868126 }
80878127 oldLayer = winAnimator .mAnimLayer ;
80888128 if (w .mTargetAppToken != null ) {
@@ -8101,6 +8141,7 @@ private final void assignLayersLocked(WindowList windows) {
81018141 }
81028142 if (winAnimator .mAnimLayer != oldLayer ) {
81038143 layerChanged = true ;
8144+ anyLayerChanged = true ;
81048145 }
81058146 if (layerChanged && mAnimator .isDimmingLocked (winAnimator )) {
81068147 // Force an animation pass just to update the mDimAnimator layer.
@@ -8115,6 +8156,10 @@ private final void assignLayersLocked(WindowList windows) {
81158156 //System.out.println(
81168157 // "Assigned layer " + curLayer + " to " + w.mClient.asBinder());
81178158 }
8159+
8160+ if (anyLayerChanged ) {
8161+ scheduleNotifyWindowLayersChangedIfNeededLocked (getDefaultDisplayContentLocked ());
8162+ }
81188163 }
81198164
81208165 private final void performLayoutAndPlaceSurfacesLocked () {
0 commit comments