1 /* 2 * Copyright (C) 2008 The Android Open Source Project 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 17 package com.android.cts; 18 19 import java.io.PrintStream; 20 21 /** 22 * CTS UI output stream. Handle all output of CTS UI 23 */ 24 final class CUIOutputStream { 25 26 private static PrintStream sOutput = System.out; 27 public static final String CTS_PROMPT_SIGN = "cts_host > "; 28 29 /** 30 * Print a line of message onto the CTS host console. 31 * 32 * @param msg The message to be print. 33 */ print(final String msg)34 static public void print(final String msg) { 35 sOutput.print(msg); 36 37 Log.log(msg); 38 } 39 40 /** 41 * Print a line of message onto the CTS host console with a carriage return. 42 * 43 * @param msg The message to be print. 44 */ println(final String msg)45 static public void println(final String msg) { 46 sOutput.println(msg); 47 48 Log.log(msg); 49 } 50 51 /** 52 * Write the buffer with given offset and length. 53 * 54 * @param buf The buffer. 55 * @param off The offset to start writing. 56 * @param len The length in byte to write. 57 */ write(byte[] buf, int off, int len)58 static public void write(byte[] buf, int off, int len) { 59 sOutput.write(buf, off, len); 60 } 61 62 /** 63 * Write a byte. 64 * 65 * @param c The byte to write. 66 */ write(int c)67 static public void write(int c) { 68 sOutput.write(c); 69 } 70 71 /** 72 * Flush the write buffer. 73 */ flush()74 static public void flush() { 75 sOutput.flush(); 76 } 77 78 /** 79 * Print prompt. 80 */ printPrompt()81 static public void printPrompt() { 82 print(CTS_PROMPT_SIGN); 83 84 Log.log(CTS_PROMPT_SIGN); 85 } 86 } 87