private ScreenWatcherResult executeScreenWatcher(ScreenWatcher.Builder builder, long timeout) {
    if (timeout <= 0) {
      timeout = 1;
    }

    // TODO(andreastt): Unsafe long to int cast
    builder.setTimeOut((int) timeout);

    builder.setWindowID(services.getWindowManager().getActiveWindowId());

    Response response = executeMessage(ExecMessage.SETUP_SCREEN_WATCHER,
                                       builder,
                                       OperaIntervals.RESPONSE_TIMEOUT.getMs() + timeout);

    ScreenWatcherResult.Builder watcherBuilder = ScreenWatcherResult.newBuilder();
    buildPayload(response, watcherBuilder);

    return watcherBuilder.build();
  }
private ScreenWatcherResult executeScreenWatcher ( ScreenWatcher . Builder builder , long timeout ) { if ( timeout <= 0 ) { timeout = 1 ; } builder . setTimeOut ( ( int ) timeout ) ; builder . setWindowID ( services . getWindowManager ( ) . getActiveWindowId ( ) ) ; Response response = executeMessage ( ExecMessage . SETUP_SCREEN_WATCHER , builder , OperaIntervals . RESPONSE_TIMEOUT . getMs ( ) + timeout ) ; ScreenWatcherResult . Builder watcherBuilder = ScreenWatcherResult . newBuilder ( ) ; buildPayload ( response , watcherBuilder ) ; return watcherBuilder . build ( ) ; }
Executes a screenwatcher with the given timeout and returns the result.