/**
   * Takes a screenshot sequence and saves the images with the name prefix in the {@link Config}
   * objects save path.
   *
   * <p>The name prefix is appended with "_" + sequence_number for each image in the sequence, where
   * numbering starts at 0.
   *
   * <p>Requires write permission (android.permission.WRITE_EXTERNAL_STORAGE) in the
   * AndroidManifest.xml of the application under test.
   *
   * <p>Taking a screenshot will take on the order of 40-100 milliseconds of time on the main UI
   * thread. Therefore it is possible to mess up the timing of tests if the frameDelay value is set
   * too small.
   *
   * <p>At present multiple simultaneous screenshot sequences are not supported. This method will
   * throw an exception if stopScreenshotSequence() has not been called to finish any prior
   * sequences.
   *
   * @param name the name prefix to give the screenshot
   * @param quality the compression rate. From 0 (compress for lowest size) to 100 (compress for
   *     maximum quality)
   * @param frameDelay the time in milliseconds to wait between each frame
   * @param maxFrames the maximum number of frames that will comprise this sequence
   */
  public void startScreenshotSequence(
      final String name, final int quality, final int frameDelay, final int maxFrames) {
    initScreenShotSaver();

    if (screenshotSequenceThread != null) {
      throw new RuntimeException("only one screenshot sequence is supported at a time");
    }

    screenshotSequenceThread = new ScreenshotSequenceThread(name, quality, frameDelay, maxFrames);

    screenshotSequenceThread.start();
  }
 /**
  * Causes a screenshot sequence to end.
  *
  * <p>If this method is not called to end a sequence and a prior sequence is still in progress,
  * startScreenshotSequence() will throw an exception.
  */
 public void stopScreenshotSequence() {
   if (screenshotSequenceThread != null) {
     screenshotSequenceThread.interrupt();
     screenshotSequenceThread = null;
   }
 }