private static void ensureAtLeastTwoTrailingNewlines(Editable text) {
      appendNewlineIfNoTrailingNewline(text);
      int len = text.length();
      if (len == 1) {
        // "text" is just a newline character (ensured by appendNewlineIfNoTrailingNewline above).
        text.append('\n');
        return;
      }

      // "text" now has at least two characters and ends with newline character
      if (text.charAt(len - 2) != '\n') {
        text.append('\n');
      }
    }
Ensures that the text ends with two newline characters, appending newline characters only
when necessary.
java/com/google/android/apps/authenticator/util/Utilities.java