Loading services/java/com/android/server/ViewServer.java +29 −4 Original line number Original line Diff line number Diff line Loading @@ -216,8 +216,11 @@ class ViewServer implements Runnable { class ViewServerWorker implements Runnable, WindowManagerService.WindowChangeListener { class ViewServerWorker implements Runnable, WindowManagerService.WindowChangeListener { private Socket mClient; private Socket mClient; private boolean mNeedWindowListUpdate; private boolean mNeedWindowListUpdate; private boolean mNeedFocusedWindowUpdate; public ViewServerWorker(Socket client) { public ViewServerWorker(Socket client) { mClient = client; mClient = client; mNeedWindowListUpdate = false; mNeedFocusedWindowUpdate = false; } } public void run() { public void run() { Loading Loading @@ -285,21 +288,43 @@ class ViewServer implements Runnable { } } } } public void focusChanged() { synchronized(this) { mNeedFocusedWindowUpdate = true; notifyAll(); } } private boolean windowManagerAutolistLoop() { private boolean windowManagerAutolistLoop() { mWindowManager.addWindowChangeListener(this); mWindowManager.addWindowChangeListener(this); BufferedWriter out = null; BufferedWriter out = null; try { try { out = new BufferedWriter(new OutputStreamWriter(mClient.getOutputStream())); out = new BufferedWriter(new OutputStreamWriter(mClient.getOutputStream())); while (!Thread.interrupted()) { while (!Thread.interrupted()) { boolean needWindowListUpdate = false; boolean needFocusedWindowUpdate = false; synchronized (this) { synchronized (this) { while (!mNeedWindowListUpdate) { while (!mNeedWindowListUpdate && !mNeedFocusedWindowUpdate) { wait(); wait(); } } if (mNeedWindowListUpdate) { mNeedWindowListUpdate = false; mNeedWindowListUpdate = false; needWindowListUpdate = true; } } out.write("UPDATE\n"); if (mNeedFocusedWindowUpdate) { mNeedFocusedWindowUpdate = false; needFocusedWindowUpdate = true; } } if(needWindowListUpdate) { out.write("LIST UPDATE\n"); out.flush(); out.flush(); } } if(needFocusedWindowUpdate) { out.write("FOCUS UPDATE\n"); out.flush(); } } } catch (Exception e) { } catch (Exception e) { Slog.w(LOG_TAG, "Connection error: ", e); Slog.w(LOG_TAG, "Connection error: ", e); } finally { } finally { Loading services/java/com/android/server/WindowManagerService.java +21 −4 Original line number Original line Diff line number Diff line Loading @@ -495,6 +495,7 @@ public class WindowManagerService extends IWindowManager.Stub public interface WindowChangeListener { public interface WindowChangeListener { public void windowsChanged(); public void windowsChanged(); public void focusChanged(); } } final Configuration mTempConfiguration = new Configuration(); final Configuration mTempConfiguration = new Configuration(); Loading Loading @@ -4831,6 +4832,21 @@ public class WindowManagerService extends IWindowManager.Stub } } } } private void notifyFocusChanged() { WindowChangeListener[] windowChangeListeners; synchronized(mWindowMap) { if(mWindowChangeListeners.isEmpty()) { return; } windowChangeListeners = new WindowChangeListener[mWindowChangeListeners.size()]; windowChangeListeners = mWindowChangeListeners.toArray(windowChangeListeners); } int N = windowChangeListeners.length; for(int i = 0; i < N; i++) { windowChangeListeners[i].focusChanged(); } } private WindowState findWindow(int hashCode) { private WindowState findWindow(int hashCode) { if (hashCode == -1) { if (hashCode == -1) { return getFocusedWindow(); return getFocusedWindow(); Loading Loading @@ -7720,7 +7736,7 @@ public class WindowManagerService extends IWindowManager.Stub public static final int ENABLE_SCREEN = 16; public static final int ENABLE_SCREEN = 16; public static final int APP_FREEZE_TIMEOUT = 17; public static final int APP_FREEZE_TIMEOUT = 17; public static final int SEND_NEW_CONFIGURATION = 18; public static final int SEND_NEW_CONFIGURATION = 18; public static final int WINDOWS_CHANGED = 19; public static final int REPORT_WINDOWS_CHANGE = 19; private Session mLastReportedHold; private Session mLastReportedHold; Loading Loading @@ -7772,6 +7788,7 @@ public class WindowManagerService extends IWindowManager.Stub // Ignore if process has died. // Ignore if process has died. } } } } notifyFocusChanged(); } } } break; } break; Loading Loading @@ -8052,7 +8069,7 @@ public class WindowManagerService extends IWindowManager.Stub break; break; } } case WINDOWS_CHANGED: { case REPORT_WINDOWS_CHANGE: { if (mWindowsChanged) { if (mWindowsChanged) { synchronized (mWindowMap) { synchronized (mWindowMap) { mWindowsChanged = false; mWindowsChanged = false; Loading Loading @@ -8283,8 +8300,8 @@ public class WindowManagerService extends IWindowManager.Stub } } } } if (mWindowsChanged && !mWindowChangeListeners.isEmpty()) { if (mWindowsChanged && !mWindowChangeListeners.isEmpty()) { mH.removeMessages(H.WINDOWS_CHANGED); mH.removeMessages(H.REPORT_WINDOWS_CHANGE); mH.sendMessage(mH.obtainMessage(H.WINDOWS_CHANGED)); mH.sendMessage(mH.obtainMessage(H.REPORT_WINDOWS_CHANGE)); } } } catch (RuntimeException e) { } catch (RuntimeException e) { mInLayout = false; mInLayout = false; Loading Loading
services/java/com/android/server/ViewServer.java +29 −4 Original line number Original line Diff line number Diff line Loading @@ -216,8 +216,11 @@ class ViewServer implements Runnable { class ViewServerWorker implements Runnable, WindowManagerService.WindowChangeListener { class ViewServerWorker implements Runnable, WindowManagerService.WindowChangeListener { private Socket mClient; private Socket mClient; private boolean mNeedWindowListUpdate; private boolean mNeedWindowListUpdate; private boolean mNeedFocusedWindowUpdate; public ViewServerWorker(Socket client) { public ViewServerWorker(Socket client) { mClient = client; mClient = client; mNeedWindowListUpdate = false; mNeedFocusedWindowUpdate = false; } } public void run() { public void run() { Loading Loading @@ -285,21 +288,43 @@ class ViewServer implements Runnable { } } } } public void focusChanged() { synchronized(this) { mNeedFocusedWindowUpdate = true; notifyAll(); } } private boolean windowManagerAutolistLoop() { private boolean windowManagerAutolistLoop() { mWindowManager.addWindowChangeListener(this); mWindowManager.addWindowChangeListener(this); BufferedWriter out = null; BufferedWriter out = null; try { try { out = new BufferedWriter(new OutputStreamWriter(mClient.getOutputStream())); out = new BufferedWriter(new OutputStreamWriter(mClient.getOutputStream())); while (!Thread.interrupted()) { while (!Thread.interrupted()) { boolean needWindowListUpdate = false; boolean needFocusedWindowUpdate = false; synchronized (this) { synchronized (this) { while (!mNeedWindowListUpdate) { while (!mNeedWindowListUpdate && !mNeedFocusedWindowUpdate) { wait(); wait(); } } if (mNeedWindowListUpdate) { mNeedWindowListUpdate = false; mNeedWindowListUpdate = false; needWindowListUpdate = true; } } out.write("UPDATE\n"); if (mNeedFocusedWindowUpdate) { mNeedFocusedWindowUpdate = false; needFocusedWindowUpdate = true; } } if(needWindowListUpdate) { out.write("LIST UPDATE\n"); out.flush(); out.flush(); } } if(needFocusedWindowUpdate) { out.write("FOCUS UPDATE\n"); out.flush(); } } } catch (Exception e) { } catch (Exception e) { Slog.w(LOG_TAG, "Connection error: ", e); Slog.w(LOG_TAG, "Connection error: ", e); } finally { } finally { Loading
services/java/com/android/server/WindowManagerService.java +21 −4 Original line number Original line Diff line number Diff line Loading @@ -495,6 +495,7 @@ public class WindowManagerService extends IWindowManager.Stub public interface WindowChangeListener { public interface WindowChangeListener { public void windowsChanged(); public void windowsChanged(); public void focusChanged(); } } final Configuration mTempConfiguration = new Configuration(); final Configuration mTempConfiguration = new Configuration(); Loading Loading @@ -4831,6 +4832,21 @@ public class WindowManagerService extends IWindowManager.Stub } } } } private void notifyFocusChanged() { WindowChangeListener[] windowChangeListeners; synchronized(mWindowMap) { if(mWindowChangeListeners.isEmpty()) { return; } windowChangeListeners = new WindowChangeListener[mWindowChangeListeners.size()]; windowChangeListeners = mWindowChangeListeners.toArray(windowChangeListeners); } int N = windowChangeListeners.length; for(int i = 0; i < N; i++) { windowChangeListeners[i].focusChanged(); } } private WindowState findWindow(int hashCode) { private WindowState findWindow(int hashCode) { if (hashCode == -1) { if (hashCode == -1) { return getFocusedWindow(); return getFocusedWindow(); Loading Loading @@ -7720,7 +7736,7 @@ public class WindowManagerService extends IWindowManager.Stub public static final int ENABLE_SCREEN = 16; public static final int ENABLE_SCREEN = 16; public static final int APP_FREEZE_TIMEOUT = 17; public static final int APP_FREEZE_TIMEOUT = 17; public static final int SEND_NEW_CONFIGURATION = 18; public static final int SEND_NEW_CONFIGURATION = 18; public static final int WINDOWS_CHANGED = 19; public static final int REPORT_WINDOWS_CHANGE = 19; private Session mLastReportedHold; private Session mLastReportedHold; Loading Loading @@ -7772,6 +7788,7 @@ public class WindowManagerService extends IWindowManager.Stub // Ignore if process has died. // Ignore if process has died. } } } } notifyFocusChanged(); } } } break; } break; Loading Loading @@ -8052,7 +8069,7 @@ public class WindowManagerService extends IWindowManager.Stub break; break; } } case WINDOWS_CHANGED: { case REPORT_WINDOWS_CHANGE: { if (mWindowsChanged) { if (mWindowsChanged) { synchronized (mWindowMap) { synchronized (mWindowMap) { mWindowsChanged = false; mWindowsChanged = false; Loading Loading @@ -8283,8 +8300,8 @@ public class WindowManagerService extends IWindowManager.Stub } } } } if (mWindowsChanged && !mWindowChangeListeners.isEmpty()) { if (mWindowsChanged && !mWindowChangeListeners.isEmpty()) { mH.removeMessages(H.WINDOWS_CHANGED); mH.removeMessages(H.REPORT_WINDOWS_CHANGE); mH.sendMessage(mH.obtainMessage(H.WINDOWS_CHANGED)); mH.sendMessage(mH.obtainMessage(H.REPORT_WINDOWS_CHANGE)); } } } catch (RuntimeException e) { } catch (RuntimeException e) { mInLayout = false; mInLayout = false; Loading