Skip to content

Commit

Permalink
添加日志写入
Browse files Browse the repository at this point in the history
  • Loading branch information
StArrayJaN committed Nov 13, 2023
1 parent 10fe456 commit e826d5b
Show file tree
Hide file tree
Showing 18 changed files with 70 additions and 97 deletions.
28 changes: 0 additions & 28 deletions emulatorview/build.gradle.bak

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -658,7 +658,7 @@ private void sendText(CharSequence text) {
}
}
} catch (IOException e) {
Log.e(TAG, "error writing ", e);
TLog.e(TAG, "error writing ", e);
}
}

Expand All @@ -674,7 +674,7 @@ private void mapAndSend(int c) throws IOException {

public boolean beginBatchEdit() {
if (LOG_IME) {
Log.w(TAG, "beginBatchEdit");
TLog.w(TAG, "beginBatchEdit");
}
setImeBuffer("");
mCursor = 0;
Expand All @@ -685,28 +685,28 @@ public boolean beginBatchEdit() {

public boolean clearMetaKeyStates(int arg0) {
if (LOG_IME) {
Log.w(TAG, "clearMetaKeyStates " + arg0);
TLog.w(TAG, "clearMetaKeyStates " + arg0);
}
return false;
}

public boolean commitCompletion(CompletionInfo arg0) {
if (LOG_IME) {
Log.w(TAG, "commitCompletion " + arg0);
TLog.w(TAG, "commitCompletion " + arg0);
}
return false;
}

public boolean endBatchEdit() {
if (LOG_IME) {
Log.w(TAG, "endBatchEdit");
TLog.w(TAG, "endBatchEdit");
}
return true;
}

public boolean finishComposingText() {
if (LOG_IME) {
Log.w(TAG, "finishComposingText");
TLog.w(TAG, "finishComposingText");
}
sendText(mImeBuffer);
setImeBuffer("");
Expand All @@ -718,7 +718,7 @@ public boolean finishComposingText() {

public int getCursorCapsMode(int reqModes) {
if (LOG_IME) {
Log.w(TAG, "getCursorCapsMode(" + reqModes + ")");
TLog.w(TAG, "getCursorCapsMode(" + reqModes + ")");
}
int mode = 0;
if ((reqModes & TextUtils.CAP_MODE_CHARACTERS) != 0) {
Expand All @@ -730,14 +730,14 @@ public int getCursorCapsMode(int reqModes) {
public ExtractedText getExtractedText(ExtractedTextRequest arg0,
int arg1) {
if (LOG_IME) {
Log.w(TAG, "getExtractedText" + arg0 + "," + arg1);
TLog.w(TAG, "getExtractedText" + arg0 + "," + arg1);
}
return null;
}

public CharSequence getTextAfterCursor(int n, int flags) {
if (LOG_IME) {
Log.w(TAG, "getTextAfterCursor(" + n + "," + flags + ")");
TLog.w(TAG, "getTextAfterCursor(" + n + "," + flags + ")");
}
int len = Math.min(n, mImeBuffer.length() - mCursor);
if (len <= 0 || mCursor < 0 || mCursor >= mImeBuffer.length()) {
Expand All @@ -748,7 +748,7 @@ public CharSequence getTextAfterCursor(int n, int flags) {

public CharSequence getTextBeforeCursor(int n, int flags) {
if (LOG_IME) {
Log.w(TAG, "getTextBeforeCursor(" + n + "," + flags + ")");
TLog.w(TAG, "getTextBeforeCursor(" + n + "," + flags + ")");
}
int len = Math.min(n, mCursor);
if (len <= 0 || mCursor < 0 || mCursor >= mImeBuffer.length()) {
Expand All @@ -759,35 +759,35 @@ public CharSequence getTextBeforeCursor(int n, int flags) {

public boolean performContextMenuAction(int arg0) {
if (LOG_IME) {
Log.w(TAG, "performContextMenuAction" + arg0);
TLog.w(TAG, "performContextMenuAction" + arg0);
}
return true;
}

public boolean performPrivateCommand(String arg0, Bundle arg1) {
if (LOG_IME) {
Log.w(TAG, "performPrivateCommand" + arg0 + "," + arg1);
TLog.w(TAG, "performPrivateCommand" + arg0 + "," + arg1);
}
return true;
}

public boolean reportFullscreenMode(boolean arg0) {
if (LOG_IME) {
Log.w(TAG, "reportFullscreenMode" + arg0);
TLog.w(TAG, "reportFullscreenMode" + arg0);
}
return true;
}

public boolean commitCorrection (CorrectionInfo correctionInfo) {
if (LOG_IME) {
Log.w(TAG, "commitCorrection");
TLog.w(TAG, "commitCorrection");
}
return true;
}

public boolean commitText(CharSequence text, int newCursorPosition) {
if (LOG_IME) {
Log.w(TAG, "commitText(\"" + text + "\", " + newCursorPosition + ")");
TLog.w(TAG, "commitText(\"" + text + "\", " + newCursorPosition + ")");
}
clearComposingText();
sendText(text);
Expand Down Expand Up @@ -816,7 +816,7 @@ private void clearComposingText() {

public boolean deleteSurroundingText(int leftLength, int rightLength) {
if (LOG_IME) {
Log.w(TAG, "deleteSurroundingText(" + leftLength +
TLog.w(TAG, "deleteSurroundingText(" + leftLength +
"," + rightLength + ")");
}
if (leftLength > 0) {
Expand All @@ -835,7 +835,7 @@ public boolean deleteSurroundingText(int leftLength, int rightLength) {

public boolean performEditorAction(int actionCode) {
if (LOG_IME) {
Log.w(TAG, "performEditorAction(" + actionCode + ")");
TLog.w(TAG, "performEditorAction(" + actionCode + ")");
}
if (actionCode == EditorInfo.IME_ACTION_UNSPECIFIED) {
// The "return" key has been pressed on the IME.
Expand All @@ -846,7 +846,7 @@ public boolean performEditorAction(int actionCode) {

public boolean sendKeyEvent(KeyEvent event) {
if (LOG_IME) {
Log.w(TAG, "sendKeyEvent(" + event + ")");
TLog.w(TAG, "sendKeyEvent(" + event + ")");
}
// Some keys are sent here rather than to commitText.
// In particular, del and the digit keys are sent here.
Expand All @@ -858,7 +858,7 @@ public boolean sendKeyEvent(KeyEvent event) {

public boolean setComposingText(CharSequence text, int newCursorPosition) {
if (LOG_IME) {
Log.w(TAG, "setComposingText(\"" + text + "\", " + newCursorPosition + ")");
TLog.w(TAG, "setComposingText(\"" + text + "\", " + newCursorPosition + ")");
}
int len = mImeBuffer.length();
if (mComposingTextStart > len || mComposingTextEnd > len) {
Expand All @@ -874,7 +874,7 @@ public boolean setComposingText(CharSequence text, int newCursorPosition) {

public boolean setSelection(int start, int end) {
if (LOG_IME) {
Log.w(TAG, "setSelection" + start + "," + end);
TLog.w(TAG, "setSelection" + start + "," + end);
}
int length = mImeBuffer.length();
if (start == end && start > 0 && start < length) {
Expand All @@ -890,7 +890,7 @@ public boolean setSelection(int start, int end) {

public boolean setComposingRegion(int start, int end) {
if (LOG_IME) {
Log.w(TAG, "setComposingRegion " + start + "," + end);
TLog.w(TAG, "setComposingRegion " + start + "," + end);
}
if (start < end && start > 0 && end < mImeBuffer.length()) {
clearComposingText();
Expand All @@ -902,7 +902,7 @@ public boolean setComposingRegion(int start, int end) {

public CharSequence getSelectedText(int flags) {
if (LOG_IME) {
Log.w(TAG, "getSelectedText " + flags);
TLog.w(TAG, "getSelectedText " + flags);
}
int len = mImeBuffer.length();
if (mSelectedTextEnd >= len || mSelectedTextStart > mSelectedTextEnd) {
Expand Down Expand Up @@ -1098,7 +1098,7 @@ private void sendMouseEventCode(MotionEvent e, int button_code) {
x > 255-32 || y > 255-32;
//Log.d(TAG, "mouse button "+x+","+y+","+button_code+",oob="+out_of_bounds);
if(button_code < 0 || button_code > 255-32) {
Log.e(TAG, "mouse button_code out of range: "+button_code);
TLog.e(TAG, "mouse button_code out of range: "+button_code);
return;
}
if(!out_of_bounds) {
Expand Down Expand Up @@ -1275,7 +1275,7 @@ private boolean onTouchEventWhileSelectingText(MotionEvent ev) {
@Override
public boolean onKeyDown(int keyCode, KeyEvent event) {
if (LOG_KEY_EVENTS) {
Log.w(TAG, "onKeyDown " + keyCode);
TLog.w(TAG, "onKeyDown " + keyCode);
}
if (handleControlKey(keyCode, true)) {
return true;
Expand Down Expand Up @@ -1320,7 +1320,7 @@ private boolean isInterceptedSystemKey(int keyCode) {
@Override
public boolean onKeyUp(int keyCode, KeyEvent event) {
if (LOG_KEY_EVENTS) {
Log.w(TAG, "onKeyUp " + keyCode);
TLog.w(TAG, "onKeyUp " + keyCode);
}
if (handleControlKey(keyCode, false)) {
return true;
Expand Down Expand Up @@ -1374,7 +1374,7 @@ public boolean onKeyPreIme(int keyCode, KeyEvent event) {
private boolean handleControlKey(int keyCode, boolean down) {
if (keyCode == mControlKeyCode) {
if (LOG_KEY_EVENTS) {
Log.w(TAG, "handleControlKey " + keyCode);
TLog.w(TAG, "handleControlKey " + keyCode);
}
mKeyListener.handleControlKey(down);
invalidate();
Expand All @@ -1387,7 +1387,7 @@ private boolean handleHardwareControlKey(int keyCode, KeyEvent event) {
if (keyCode == KeycodeConstants.KEYCODE_CTRL_LEFT ||
keyCode == KeycodeConstants.KEYCODE_CTRL_RIGHT) {
if (LOG_KEY_EVENTS) {
Log.w(TAG, "handleHardwareControlKey " + keyCode);
TLog.w(TAG, "handleHardwareControlKey " + keyCode);
}
boolean down = event.getAction() == KeyEvent.ACTION_DOWN;
mKeyListener.handleHardwareControlKey(down);
Expand All @@ -1400,7 +1400,7 @@ private boolean handleHardwareControlKey(int keyCode, KeyEvent event) {
private boolean handleFnKey(int keyCode, boolean down) {
if (keyCode == mFnKeyCode) {
if (LOG_KEY_EVENTS) {
Log.w(TAG, "handleFnKey " + keyCode);
TLog.w(TAG, "handleFnKey " + keyCode);
}
mKeyListener.handleFnKey(down);
invalidate();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
import java.io.IOException;
import java.text.SimpleDateFormat;
import java.util.Date;
public class Log {
public class TLog {

static File logFile = new File("/sdcard/TerminalLog.txt");

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@ private void initKeyCodes() {

public void setCursorKeysApplicationMode(boolean val) {
if (LOG_MISC) {
Log.d(EmulatorDebug.LOG_TAG, "CursorKeysApplicationMode=" + val);
TLog.d(EmulatorDebug.LOG_TAG, "CursorKeysApplicationMode=" + val);
}
if (val) {
mKeyCodes[KEYCODE_NUMPAD_8] = mKeyCodes[KEYCODE_DPAD_UP] = "\033OA";
Expand Down Expand Up @@ -519,7 +519,7 @@ public int mapControlChar(boolean control, boolean fn, int ch) {
public void keyDown(int keyCode, KeyEvent event, boolean appMode,
boolean allowToggle) throws IOException {
if (LOG_KEYS) {
Log.i(TAG, "keyDown(" + keyCode + "," + event + "," + appMode + "," + allowToggle + ")");
TLog.i(TAG, "keyDown(" + keyCode + "," + event + "," + appMode + "," + allowToggle + ")");
}
if (handleKeyCode(keyCode, event, appMode)) {
return;
Expand Down Expand Up @@ -605,7 +605,7 @@ public void keyDown(int keyCode, KeyEvent event, boolean appMode,

if ((result & KeyCharacterMap.COMBINING_ACCENT) != 0) {
if (LOG_COMBINING_ACCENT) {
Log.i(TAG, "Got combining accent " + result);
TLog.i(TAG, "Got combining accent " + result);
}
mCombiningAccent = result & KeyCharacterMap.COMBINING_ACCENT_MASK;
return;
Expand All @@ -614,7 +614,7 @@ public void keyDown(int keyCode, KeyEvent event, boolean appMode,
int unaccentedChar = result;
result = KeyCharacterMap.getDeadChar(mCombiningAccent, unaccentedChar);
if (LOG_COMBINING_ACCENT) {
Log.i(TAG, "getDeadChar(" + mCombiningAccent + ", " + unaccentedChar + ") -> " + result);
TLog.i(TAG, "getDeadChar(" + mCombiningAccent + ", " + unaccentedChar + ") -> " + result);
}
mCombiningAccent = 0;
}
Expand Down Expand Up @@ -701,7 +701,7 @@ public boolean handleKeyCode(int keyCode, KeyEvent event, boolean appMode) throw
if (code != null) {
if (EmulatorDebug.LOG_CHARACTERS_FLAG) {
byte[] bytes = code.getBytes();
Log.d(EmulatorDebug.LOG_TAG, "Out: '" + EmulatorDebug.bytesToString(bytes, 0, bytes.length) + "'");
TLog.d(EmulatorDebug.LOG_TAG, "Out: '" + EmulatorDebug.bytesToString(bytes, 0, bytes.length) + "'");
}
mTermSession.write(code);
return true;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -663,15 +663,15 @@ private void setDefaultTabStops() {
*/
public void append(byte[] buffer, int base, int length) {
if (EmulatorDebug.LOG_CHARACTERS_FLAG) {
Log.d(EmulatorDebug.LOG_TAG, "In: '" + EmulatorDebug.bytesToString(buffer, base, length) + "'");
TLog.d(EmulatorDebug.LOG_TAG, "In: '" + EmulatorDebug.bytesToString(buffer, base, length) + "'");
}
for (int i = 0; i < length; i++) {
byte b = buffer[base + i];
try {
process(b);
mProcessedCharCount++;
} catch (Exception e) {
Log.e(EmulatorDebug.LOG_TAG, "Exception while processing character "
TLog.e(EmulatorDebug.LOG_TAG, "Exception while processing character "
+ Integer.toString(mProcessedCharCount) + " code "
+ Integer.toString(b), e);
}
Expand Down Expand Up @@ -1467,7 +1467,7 @@ private void selectGraphicRendition() {
mBackColor = code - 100 + 8;
} else {
if (EmulatorDebug.LOG_UNKNOWN_ESCAPE_SEQUENCES) {
Log.w(EmulatorDebug.LOG_TAG, String.format("SGR unknown code %d", code));
TLog.w(EmulatorDebug.LOG_TAG, String.format("SGR unknown code %d", code));
}
}
}
Expand All @@ -1477,7 +1477,7 @@ private boolean checkColor(int color) {
boolean result = isValidColor(color);
if (!result) {
if (EmulatorDebug.LOG_UNKNOWN_ESCAPE_SEQUENCES) {
Log.w(EmulatorDebug.LOG_TAG,
TLog.w(EmulatorDebug.LOG_TAG,
String.format("Invalid color %d", color));
}
}
Expand Down Expand Up @@ -1783,7 +1783,7 @@ private void logError(String errorType, byte b) {

private void logError(String error) {
if (EmulatorDebug.LOG_UNKNOWN_ESCAPE_SEQUENCES) {
Log.e(EmulatorDebug.LOG_TAG, error);
TLog.e(EmulatorDebug.LOG_TAG, error);
}
finishSequence();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ private int externalToInternalRow(int extRow) {
if (extRow < -mActiveTranscriptRows || extRow > mScreenRows) {
String errorMessage = "externalToInternalRow "+ extRow +
" " + mScreenRows + " " + mActiveTranscriptRows;
Log.e(TAG, errorMessage);
TLog.e(TAG, errorMessage);
throw new IllegalArgumentException(errorMessage);
}

Expand Down Expand Up @@ -468,7 +468,7 @@ public void blockCopy(int sx, int sy, int w, int h, int dx, int dy) {
*/
public void blockSet(int sx, int sy, int w, int h, int val, int style) {
if (sx < 0 || sx + w > mColumns || sy < 0 || sy + h > mScreenRows) {
Log.e(TAG, "illegal arguments! " + sx + " " + sy + " " + w + " " + h + " " + val + " " + mColumns + " " + mScreenRows);
TLog.e(TAG, "illegal arguments! " + sx + " " + sy + " " + w + " " + h + " " + val + " " + mColumns + " " + mScreenRows);
throw new IllegalArgumentException();
}

Expand Down Expand Up @@ -811,7 +811,7 @@ public boolean setChar(int column, int row, int codePoint, int style) {

public boolean setChar(int column, int row, int codePoint) {
if (row >= mScreenRows || column >= mColumns) {
Log.e(TAG, "illegal arguments! " + row + " " + column + " " + mScreenRows + " " + mColumns);
TLog.e(TAG, "illegal arguments! " + row + " " + column + " " + mScreenRows + " " + mColumns);
throw new IllegalArgumentException();
}
row = externalToInternalRow(row);
Expand Down
Loading

0 comments on commit e826d5b

Please sign in to comment.