Loading services/java/com/android/server/ViewServer.java +4 −0 Original line number Diff line number Diff line Loading @@ -60,6 +60,8 @@ class ViewServer implements Runnable { private static final String COMMAND_WINDOW_MANAGER_LIST = "LIST"; // Keeps a connection open and notifies when the list of windows changes private static final String COMMAND_WINDOW_MANAGER_AUTOLIST = "AUTOLIST"; // Returns the focused window private static final String COMMAND_WINDOW_MANAGER_GET_FOCUS = "GET_FOCUS"; private ServerSocket mServer; private Thread mThread; Loading Loading @@ -250,6 +252,8 @@ class ViewServer implements Runnable { result = writeValue(mClient, VALUE_SERVER_VERSION); } else if (COMMAND_WINDOW_MANAGER_LIST.equalsIgnoreCase(command)) { result = mWindowManager.viewServerListWindows(mClient); } else if (COMMAND_WINDOW_MANAGER_GET_FOCUS.equalsIgnoreCase(command)) { result = mWindowManager.viewServerGetFocusedWindow(mClient); } else if(COMMAND_WINDOW_MANAGER_AUTOLIST.equalsIgnoreCase(command)) { result = windowManagerAutolistLoop(); } else { Loading services/java/com/android/server/WindowManagerService.java +45 −0 Original line number Diff line number Diff line Loading @@ -4729,6 +4729,51 @@ public class WindowManagerService extends IWindowManager.Stub return result; } /** * Returns the focused window in the following format: * windowHashCodeInHexadecimal windowName * * @param client The remote client to send the listing to. * @return False if an error occurred, true otherwise. */ boolean viewServerGetFocusedWindow(Socket client) { if (isSystemSecure()) { return false; } boolean result = true; WindowState focusedWindow = getFocusedWindow(); BufferedWriter out = null; // Any uncaught exception will crash the system process try { OutputStream clientStream = client.getOutputStream(); out = new BufferedWriter(new OutputStreamWriter(clientStream), 8 * 1024); if(focusedWindow != null) { out.write(Integer.toHexString(System.identityHashCode(focusedWindow))); out.write(' '); out.append(focusedWindow.mAttrs.getTitle()); } out.write('\n'); out.flush(); } catch (Exception e) { result = false; } finally { if (out != null) { try { out.close(); } catch (IOException e) { result = false; } } } return result; } /** * Sends a command to a target window. The result of the command, if any, will be * written in the output stream of the specified socket. Loading Loading
services/java/com/android/server/ViewServer.java +4 −0 Original line number Diff line number Diff line Loading @@ -60,6 +60,8 @@ class ViewServer implements Runnable { private static final String COMMAND_WINDOW_MANAGER_LIST = "LIST"; // Keeps a connection open and notifies when the list of windows changes private static final String COMMAND_WINDOW_MANAGER_AUTOLIST = "AUTOLIST"; // Returns the focused window private static final String COMMAND_WINDOW_MANAGER_GET_FOCUS = "GET_FOCUS"; private ServerSocket mServer; private Thread mThread; Loading Loading @@ -250,6 +252,8 @@ class ViewServer implements Runnable { result = writeValue(mClient, VALUE_SERVER_VERSION); } else if (COMMAND_WINDOW_MANAGER_LIST.equalsIgnoreCase(command)) { result = mWindowManager.viewServerListWindows(mClient); } else if (COMMAND_WINDOW_MANAGER_GET_FOCUS.equalsIgnoreCase(command)) { result = mWindowManager.viewServerGetFocusedWindow(mClient); } else if(COMMAND_WINDOW_MANAGER_AUTOLIST.equalsIgnoreCase(command)) { result = windowManagerAutolistLoop(); } else { Loading
services/java/com/android/server/WindowManagerService.java +45 −0 Original line number Diff line number Diff line Loading @@ -4729,6 +4729,51 @@ public class WindowManagerService extends IWindowManager.Stub return result; } /** * Returns the focused window in the following format: * windowHashCodeInHexadecimal windowName * * @param client The remote client to send the listing to. * @return False if an error occurred, true otherwise. */ boolean viewServerGetFocusedWindow(Socket client) { if (isSystemSecure()) { return false; } boolean result = true; WindowState focusedWindow = getFocusedWindow(); BufferedWriter out = null; // Any uncaught exception will crash the system process try { OutputStream clientStream = client.getOutputStream(); out = new BufferedWriter(new OutputStreamWriter(clientStream), 8 * 1024); if(focusedWindow != null) { out.write(Integer.toHexString(System.identityHashCode(focusedWindow))); out.write(' '); out.append(focusedWindow.mAttrs.getTitle()); } out.write('\n'); out.flush(); } catch (Exception e) { result = false; } finally { if (out != null) { try { out.close(); } catch (IOException e) { result = false; } } } return result; } /** * Sends a command to a target window. The result of the command, if any, will be * written in the output stream of the specified socket. Loading