function parseWindows (lines) {
  let atStatusBar = false;
  let atNavBar = false;
  let statusBar;
  let navigationBar;
  // the window manager output looks like:
  // Window #1 ... WindowID
  //   A bunch of properties
  // Window #2 ... WindowID
  //   A bunch of properties
  lines.split('\n').forEach((line) => {
    // the start of a new window section
    if (line.indexOf('  Window #') !== -1) {
      // determine which section we're in
      // only one will be true
      atStatusBar = (line.indexOf('StatusBar') !== -1);
      atNavBar = (line.indexOf('NavigationBar') !== -1);
      // don't need anything else. move to next line
      return;
    }
    // once we're in a window section, look for the surface data line
    if (line.indexOf('      Surface:') === -1) {
      return;
    }
    if (atStatusBar) {
      statusBar = parseSurfaceLine(line);
      atStatusBar = false;
    } else if (atNavBar) {
      navigationBar = parseSurfaceLine(line);
      atNavBar = false;
    }
  });

  if (!statusBar) {
    log.errorAndThrow('Failed to parse status bar information.');
  }
  if (!navigationBar) {
    log.errorAndThrow('Failed to parse navigation bar information.');
  }

  return {statusBar, navigationBar};
}
/**
 * Extracts status and navigation bar information from the window manager output.
 * @param lines: Output from dumpsys command
 * @return: Visibility and bounds info of status and navigation bar
 */
Extracts status and navigation bar information from the window manager output.
@param lines: Output from dumpsys command
@return: Visibility and bounds info of status and navigation bar
Extracts status and navigation bar information from the window manager output . @param lines : Output from dumpsys command @return : Visibility and bounds info of status and navigation bar
function parseWindows (lines) {
  let atStatusBar = false;
  let atNavBar = false;
  let statusBar;
  let navigationBar;
  lines.split('\n').forEach((line) => {
    if (line.indexOf('  Window #') !== -1) {
      atStatusBar = (line.indexOf('StatusBar') !== -1);
      atNavBar = (line.indexOf('NavigationBar') !== -1);
      return;
    }
    if (line.indexOf('      Surface:') === -1) {
      return;
    }
    if (atStatusBar) {
      statusBar = parseSurfaceLine(line);
      atStatusBar = false;
    } else if (atNavBar) {
      navigationBar = parseSurfaceLine(line);
      atNavBar = false;
    }
  });
  if (!statusBar) {
    log.errorAndThrow('Failed to parse status bar information.');
  }
  if (!navigationBar) {
    log.errorAndThrow('Failed to parse navigation bar information.');
  }
  return {statusBar, navigationBar};
}
function parseWindows ( lines ) { let atStatusBar = false ; let atNavBar = false ; let statusBar ; let navigationBar ; lines . split ( '\n' ) . forEach ( ( line ) => { if ( line . indexOf ( '  Window #' ) !== - 1 ) { atStatusBar = ( line . indexOf ( 'StatusBar' ) !== - 1 ) ; atNavBar = ( line . indexOf ( 'NavigationBar' ) !== - 1 ) ; return ; } if ( line . indexOf ( '      Surface:' ) === - 1 ) { return ; } if ( atStatusBar ) { statusBar = parseSurfaceLine ( line ) ; atStatusBar = false ; } else if ( atNavBar ) { navigationBar = parseSurfaceLine ( line ) ; atNavBar = false ; } } ) ; if ( ! statusBar ) { log . errorAndThrow ( 'Failed to parse status bar information.' ) ; } if ( ! navigationBar ) { log . errorAndThrow ( 'Failed to parse navigation bar information.' ) ; } return { statusBar , navigationBar } ; }
Extracts status and navigation bar information from the window manager output.
Extracts status and navigation bar information from the window manager output .
// the window manager output looks like: // Window #1 ... WindowID //   A bunch of properties // Window #2 ... WindowID //   A bunch of properties // the start of a new window section // determine which section we're in // only one will be true // don't need anything else. move to next line // once we're in a window section, look for the surface data line