Merge branch 'bug-2366-ssh-debug-logging_master' into custom-sftp-private-key_patches

This commit is contained in:
Rick Brown
2023-07-19 17:12:53 -04:00
80 changed files with 6431 additions and 1508 deletions

View File

@@ -0,0 +1,93 @@
package keepass2android.javafilestorage;
import android.util.Log;
import com.jcraft.jsch.Logger;
import java.io.FileWriter;
import java.io.PrintWriter;
import java.util.Map;
public class Kp2aJSchLogger implements Logger {
private static final String PREFIX = "KP2AJFS[JSch]";
private interface ILogger {
void log(String message);
}
private static final class LogEntry {
private final String levelTag;
private final ILogger logger;
LogEntry(String levelTag, ILogger logger) {
this.levelTag = levelTag;
this.logger = logger;
}
}
private static final ILogger DEBUG = msg -> Log.d(PREFIX, msg);
private static final LogEntry DEBUG_ENTRY = new LogEntry("D", DEBUG);
private static final ILogger ERROR = msg -> Log.e(PREFIX, msg);
private static final LogEntry DEFAULT_ENTRY = DEBUG_ENTRY;
private static final Map<Integer, LogEntry> loggers = Map.of(
Logger.DEBUG, DEBUG_ENTRY,
Logger.INFO, new LogEntry("I", msg -> Log.i(PREFIX, msg)),
Logger.WARN, new LogEntry("W", msg -> Log.w(PREFIX, msg)),
Logger.ERROR, new LogEntry("E", ERROR),
Logger.FATAL, new LogEntry("F", msg -> Log.wtf(PREFIX, msg))
);
private final String logFilename;
public Kp2aJSchLogger(String logFilename) {
this.logFilename = logFilename;
}
@Override
public boolean isEnabled(int level) {
return true;
}
@Override
public void log(int level, String message) {
if (isEnabled(level))
getLogger(level).log(message);
}
private ILogger getLogger(int level) {
LogEntry entry = loggers.get(level);
if (entry == null)
entry = DEFAULT_ENTRY;
ILogger logger;
if (logFilename != null) {
logger = createFileLogger(entry);
} else {
logger = entry.logger;
}
return logger;
}
private ILogger createFileLogger(LogEntry entry) {
try {
final PrintWriter p = new PrintWriter(new FileWriter(logFilename, true));
return msg -> {
try {
String fullMsg = String.join(" ", entry.levelTag, PREFIX, msg);
p.println(fullMsg);
} catch (Exception e) {
ERROR.log(e.getMessage());
} finally {
p.close();
}
};
} catch (Exception e) {
ERROR.log(e.getMessage());
return entry.logger;
}
}
}

View File

@@ -27,6 +27,7 @@ import com.jcraft.jsch.UserInfo;
import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.util.Log;
@SuppressWarnings("unused") // Exposed by JavaFileStorageBindings
public class SftpStorage extends JavaFileStorageBase {
@@ -423,6 +424,8 @@ public class SftpStorage extends JavaFileStorageBase {
ChannelSftp init(ConnectionInfo cInfo) throws JSchException, UnsupportedEncodingException {
jsch = new JSch();
Log.d("KP2AJFS", "init SFTP");
String base_dir = getBaseDir();
jsch.setKnownHosts(base_dir + "/known_hosts");
@@ -434,7 +437,9 @@ public class SftpStorage extends JavaFileStorageBase {
}
Log.e("KP2AJFS[thread]", "getting session...");
Session session = jsch.getSession(cInfo.username, cInfo.host, cInfo.port);
Log.e("KP2AJFS", "creating SftpUserInfo");
UserInfo ui = new SftpUserInfo(cInfo.password, cInfo.keyPassphrase, _appContext);
session.setUserInfo(ui);
@@ -475,12 +480,20 @@ public class SftpStorage extends JavaFileStorageBase {
return _keyUtils.createKeyPair(jsch);
}
@SuppressWarnings("unused") // Exposed by JavaFileStorageBindings
public void savePrivateKeyContent(String keyName, String keyContent) throws IOException, Exception {
_keyUtils.savePrivateKeyContent(keyName, keyContent);
}
@SuppressWarnings("unused") // Exposed by JavaFileStorageBindings
public void setJschLogging(boolean enabled, String logFilename) {
if (enabled) {
JSch.setLogger(new Kp2aJSchLogger(logFilename));
} else {
JSch.setLogger(null);
}
}
/**
* Exposed for testing purposes only.
* @param keyName

View File

@@ -34,7 +34,6 @@ public class SftpUserInfo implements UserInfo {
builder.setContentText("SFTP prompt");
builder.setSmallIcon(R.drawable.ic_logo_green_foreground);
Handler h = new Handler() {
public void handleMessage(Message M) {
msg.copyFrom(M);
@@ -51,8 +50,12 @@ public class SftpUserInfo implements UserInfo {
intent.putExtra("keepass2android.sftp.prompt", text);
intent.setData((Uri.parse("suckit://"+SystemClock.elapsedRealtime())));
Log.e("KP2AJFS[thread]", "built after 2023-03-14");
int flags = 0;
if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.S) {
Log.e("KP2AJFS[thread]", "Setting mutable flag...");
flags |= PendingIntent.FLAG_MUTABLE;
}
PendingIntent contentIntent = PendingIntent.getActivity(_appContext, 0, intent, flags);

View File

@@ -0,0 +1 @@
org.gradle.jvmargs=-Xmx1536m

View File

@@ -19,4 +19,4 @@
android.enableJetifier=true
android.useAndroidX=true
org.gradle.jvmargs=-Xmx2048m
org.gradle.jvmargs=-Xmx1536m

View File

@@ -0,0 +1 @@
org.gradle.jvmargs=-Xmx1536m

View File

@@ -25,7 +25,7 @@
<!-- Title for Latin keyboard input options dialog -->
<string name="english_ime_input_options">Eingabeoptionen</string>
<!-- Option to provide vibrate/haptic feedback on keypress -->
<string name="vibrate_on_keypress">Vibrieren b. Tastendruck</string>
<string name="vibrate_on_keypress">Bei Tastendruck vibrieren</string>
<!-- Option to play back sound on keypress in soft keyboard -->
<string name="sound_on_keypress">Ton bei Tastendruck</string>
<!-- Option to pop up the character with a larger font above soft keyboard -->
@@ -120,13 +120,13 @@
<!-- Tutorial tip 2 - Touch and hold a key to view accents (examples) -->
<string name="tip_to_view_accents"><b>\"Halten Sie eine Taste gedrückt, um Akzente anzuzeigen\"\n\"(ø, ö, ô, ó usw.).\"</b></string>
<!-- Tutorial tip 3 - How to switch to number/symbol keyboard -->
<string name="tip_to_open_symbols"><b>\"Wechseln Sie zu Ziffern und Symbolen, indem Sie diese Taste berühren.\"</b></string>
<string name="tip_to_open_symbols"><b>Wechseln Sie zu Ziffern und Symbolen, indem Sie diese Taste berühren.</b></string>
<!-- Tutorial tip 4 - How to switch back to alphabet keyboard -->
<string name="tip_to_close_symbols"><b>\"Durch erneutes Drücken dieser Taste gelangen Sie zurück zu den Buchstaben.\"</b></string>
<string name="tip_to_close_symbols"><b>Durch erneutes Drücken dieser Taste gelangen Sie zurück zu den Buchstaben.</b></string>
<!-- Tutorial tip 5 - How to launch keyboard settings -->
<string name="tip_to_launch_settings"><b>\"Halten Sie diese Taste gedrückt, um die Tastatureinstellungen, wie beispielsweise die automatische Vervollständigung, zu ändern.\"</b></string>
<string name="tip_to_launch_settings"><b>Halten Sie diese Taste gedrückt, um die Tastatureinstellungen, wie beispielsweise die automatische Vervollständigung, zu ändern.</b></string>
<!-- Tutorial tip 6 - Done with the tutorial -->
<string name="tip_to_start_typing"><b>\"Probieren Sie es aus!\"</b></string>
<string name="tip_to_start_typing"><b>Probieren Sie es aus!</b></string>
<!-- Label for soft enter key when it performs GO action. Must be short to fit on key! -->
<string name="label_go_key">Los</string>
<!-- Label for soft enter key when it performs NEXT action. Must be short to fit on key! -->
@@ -166,7 +166,7 @@
<string name="voice_working">Vorgang läuft</string>
<!-- Short message shown before the user should speak. -->
<!-- Short message shown when a generic error occurs. -->
<string name="voice_error">Fehler. Versuchen Sie es erneut..</string>
<string name="voice_error">Fehler. Versuchen Sie es erneut.</string>
<!-- Short message shown for a network error. -->
<string name="voice_network_error">Keine Verbindung</string>
<!-- Short message shown for a network error where the utterance was really long,
@@ -184,9 +184,9 @@
search is not installed. -->
<string name="voice_not_installed">Sprachsuche nicht installiert</string>
<!-- Short hint shown in candidate view to explain voice input. -->
<string name="voice_swipe_hint"><b>\"Hinweis:\"</b>\" Ziehen Sie zum Sprechen den Finger über die Tastatur.\"</string>
<string name="voice_swipe_hint"><b>Hinweis:</b> Ziehen Sie zum Sprechen den Finger über die Tastatur.</string>
<!-- Short hint shown in candidate view to explain that user can speak punctuation. -->
<string name="voice_punctuation_hint"><b>\"Hinweis:\"</b>\" Versuchen Sie beim nächsten Mal, Satzzeichen wie \"Punkt\", \"Komma\" oder \"Fragezeichen\" per Sprachbefehl einzugeben.\"</string>
<string name="voice_punctuation_hint"><b>Hinweis:</b> Versuchen Sie beim nächsten Mal, Satzzeichen wie Punkt“, „Komma oder Fragezeichen per Sprachbefehl einzugeben.</string>
<!-- Label on button to stop recognition. Must be short to fit on button. -->
<string name="cancel">Abbrechen</string>
<!-- Label on button when an error occurs -->
@@ -214,13 +214,13 @@
<string name="auto_submit_summary">Drücken Sie auf die Eingabetaste, wenn Sie einen Suchvorgang durchführen oder zum nächsten Feld wechseln.</string>
<!-- IME Tutorial screen (ROMAN) -->
<!-- appears above image showing the user to click on a TextView to show the IME -->
<string name="open_the_keyboard"><font size="17"><b>\"Tastatur öffnen\"\n</b></font><font size="3">\n</font>\"Berühren Sie ein beliebiges Textfeld.\"</string>
<string name="open_the_keyboard"><font size="17"><b>Tastatur öffnen\n</b></font><font size="3">\n</font>Berühren Sie ein beliebiges Textfeld.</string>
<!-- appears above the image showing the back button used to close the keyboard -->
<string name="close_the_keyboard"><font size="17"><b>\"Tastatur schließen\"\n</b></font><font size="3">\n</font>\"Drücken Sie die Zurücktaste.\"</string>
<string name="close_the_keyboard"><font size="17"><b>Tastatur schließen\n</b></font><font size="3">\n</font>Drücken Sie die Zurücktaste.</string>
<!-- appears above image showing how to use touch and hold -->
<string name="touch_and_hold"><font size="17"><b>\"Für Optionen eine Taste berühren und gedrückt halten\"\n</b></font><font size="3">\n</font>\"Greifen Sie auf Satzzeichen und Akzente zu.\"</string>
<string name="touch_and_hold"><font size="17"><b>Für Optionen eine Taste berühren und gedrückt halten\n</b></font><font size="3">\n</font>Greifen Sie auf Satzzeichen und Akzente zu.</string>
<!-- appears above image showing how to access keyboard settings -->
<string name="keyboard_settings"><font size="17"><b>\"Tastatureinstellungen\"\n</b></font><font size="3">\n</font>\"Berühren und halten Sie die Taste \"<b>\"?123\"</b>\" gedrückt.\"</string>
<string name="keyboard_settings"><font size="17"><b>Tastatureinstellungen\n</b></font><font size="3">\n</font>Berühren und halten Sie die Taste <b>\"?123\"</b> gedrückt.</string>
<!-- popular web domains for the locale - most popular, displayed on the keyboard -->
<string name="popular_domain_0">".com"</string>
<!-- popular web domains for the locale - item 1, displayed in the popup -->

View File

@@ -21,7 +21,7 @@
<!-- Title for Latin keyboard -->
<string name="english_ime_name">Πληκτρολόγιο Keepass2Android</string>
<!-- Title for Latin keyboard settings activity / dialog -->
<string name="english_ime_settings">Ρυθμίσεις πληκτρολογίου Keepass2Android</string>
<string name="english_ime_settings">Ρυθμίσεις πληκτρολογίου Android</string>
<!-- Title for Latin keyboard input options dialog -->
<string name="english_ime_input_options">Επιλογές εισόδου</string>
<!-- Option to provide vibrate/haptic feedback on keypress -->
@@ -51,7 +51,7 @@
<!-- Dialog title for auto complete choices -->
<string name="auto_complete_dialog_title">Αυτόματη συμπλήρωση</string>
<!-- Option to enable text prediction in landscape -->
<string name="prediction_landscape">Αυξήστε το μέγεθος του πεδίου κειμένου</string>
<string name="prediction_landscape">Αύξηση μεγέθους του πεδίου κειμένου</string>
<!-- Description for text prediction -->
<string name="prediction_landscape_summary">Απόκρυψη υποδείξεων λέξεων στην οριζόντια προβολή</string>
<!-- Option to enable auto capitalization of sentences -->
@@ -77,7 +77,7 @@
<string name="prefs_settings_key">Εμφάνιση πλήκτρου ρυθμίσεων</string>
<!-- Array of the settings key mode values -->
<!-- Option to automatically decide to show/hide the settings key -->
<string name="settings_key_mode_auto_name">Αυτόματο</string>
<string name="settings_key_mode_auto_name">Αυτόματα</string>
<!-- Option to always show the settings key -->
<string name="settings_key_mode_always_show_name">Να εμφανίζεται πάντα</string>
<!-- Option to always hide the settings key -->
@@ -110,25 +110,25 @@
<!-- Tip to press ?123 to access numbers and symbols -->
<string name="tip_access_symbols">Πρόσβαση σε αριθμούς και σύμβολα</string>
<!-- Tip to long press on typed word to add to dictionary -->
<string name="tip_add_to_dictionary">Κρατήστε πατημένη τη λέξη στην άκρη αριστερά, για να την προσθέσετε στο λεξικό</string>
<string name="tip_add_to_dictionary">Παρατεταμένη επιλογή της λέξης στα αριστερά, την προσθέτει στο λεξικό</string>
<!-- Instruction to touch the bubble to continue -->
<string name="touch_to_continue">Αγγίξτε αυτή τη συμβουλή για να συνεχίσετε »</string>
<string name="touch_to_continue">Αγγίξτε αυτή την υπόδειξη για να συνεχίσετε »</string>
<!-- Instruction to touch the bubble to start typing -->
<string name="touch_to_finish">Αγγίξτε εδώ για να κλείσετε τη συμβουλή και να ξεκινήσετε την πληκτρολόγηση!</string>
<string name="touch_to_finish">Αγγίξτε εδώ για να κλείσετε την υπόδειξη και να ξεκινήσετε την πληκτρολόγηση!</string>
<!-- Tutorial tip 1 - The keyboard opens any time you touch a text field -->
<string name="tip_to_open_keyboard"><b>\"Το πληκτρολόγιο ανοίγει κάθε φορά που αγγίζετε ένα πεδίο κειμένου\"</b></string>
<string name="tip_to_open_keyboard"><b>Το πληκτρολόγιο ανοίγει κάθε φορά που αγγίζετε ένα πεδίο κειμένου</b></string>
<!-- Tutorial tip 2 - Touch and hold a key to view accents (examples) -->
<string name="tip_to_view_accents"><b>\"Αγγίξτε και κρατήστε κάποιο πλήκτρο για να προβάλετε τους τονισμένους χαρακτήρες\"\n\"(ø, ö, ô, ó κ.τ.λ.)\"</b></string>
<!-- Tutorial tip 3 - How to switch to number/symbol keyboard -->
<string name="tip_to_open_symbols"><b>\"Αλλαγή σε αριθμούς και σύμβολα με το πάτημα αυτού του πλήκτρου\"</b></string>
<string name="tip_to_open_symbols"><b>Αλλαγή σε αριθμούς και σύμβολα με το πάτημα αυτού του πλήκτρου</b></string>
<!-- Tutorial tip 4 - How to switch back to alphabet keyboard -->
<string name="tip_to_close_symbols"><b>\"Επιστρέψτε στα γράμματα αγγίζοντας ξανά αυτό το πλήκτρο\"</b></string>
<string name="tip_to_close_symbols"><b>Επιστρέψτε στα γράμματα αγγίζοντας ξανά αυτό το πλήκτρο</b></string>
<!-- Tutorial tip 5 - How to launch keyboard settings -->
<string name="tip_to_launch_settings"><b>\"Αγγίξτε και κρατήστε πατημένο αυτό το πληκτρολόγιο για να αλλάξετε τις ρυθμίσεις πληκτρολογίου, όπως η αυτόματη συμπλήρωση\"</b></string>
<string name="tip_to_launch_settings"><b>Αγγίξτε και κρατήστε πατημένο αυτό το πλήκτρο για να αλλάξετε τις ρυθμίσεις πληκτρολογίου, όπως η αυτόματη συμπλήρωση</b></string>
<!-- Tutorial tip 6 - Done with the tutorial -->
<string name="tip_to_start_typing"><b>\"Δοκιμάστε το!\"</b></string>
<string name="tip_to_start_typing"><b>Δοκιμάστε το!</b></string>
<!-- Label for soft enter key when it performs GO action. Must be short to fit on key! -->
<string name="label_go_key">Μετ.</string>
<string name="label_go_key">Μετάβαση</string>
<!-- Label for soft enter key when it performs NEXT action. Must be short to fit on key! -->
<string name="label_next_key">Επόμενο</string>
<!-- Label for soft enter key when it performs DONE action. Must be short to fit on key! -->

View File

@@ -21,7 +21,7 @@
<!-- Title for Latin keyboard -->
<string name="english_ime_name">== Keepass2Android 键盘 ==</string>
<!-- Title for Latin keyboard settings activity / dialog -->
<string name="english_ime_settings">USB 键盘设置</string>
<string name="english_ime_settings">键盘设置</string>
<!-- Title for Latin keyboard input options dialog -->
<string name="english_ime_input_options">输入选项</string>
<!-- Option to provide vibrate/haptic feedback on keypress -->
@@ -29,23 +29,23 @@
<!-- Option to play back sound on keypress in soft keyboard -->
<string name="sound_on_keypress">按键声音</string>
<!-- Option to pop up the character with a larger font above soft keyboard -->
<string name="popup_on_keypress">按键弹出放大</string>
<string name="popup_on_keypress">按键弹出显示</string>
<!-- Option to enable using nearby keys when correcting/predicting -->
<string name="hit_correction">智能纠错</string>
<!-- Description for hit_correction -->
<string name="hit_correction_summary">启用输入错误校正</string>
<!-- Option to enable using nearby keys when correcting/predicting in landscape-->
<string name="hit_correction_land">横屏输入错</string>
<string name="hit_correction_land">横屏输入</string>
<!-- Description for hit_correction in landscape -->
<string name="hit_correction_land_summary">启用输入错误校正</string>
<!-- Option to automatically correct word on hitting space -->
<string name="auto_correction">单词联想</string>
<string name="auto_correction">输入建议</string>
<!-- Description for auto_correction -->
<string name="auto_correction_summary">自动更正前一个单词</string>
<!-- Option to enable text prediction -->
<string name="prediction">单词联想</string>
<string name="prediction">输入建议</string>
<!-- Category title for text prediction -->
<string name="prediction_category"> 词语建议设置</string>
<string name="prediction_category">输入建议设置</string>
<!-- Description for text prediction -->
<string name="prediction_summary">在输入时启用自动补全</string>
<!-- Dialog title for auto complete choices -->
@@ -91,7 +91,7 @@
<!-- Option to enable bigram completion -->
<string name="bigram_suggestion">二元语法分词建议</string>
<!-- Description for auto completion -->
<string name="bigram_suggestion_summary">使用曾经使用过的词语改进建议</string>
<string name="bigram_suggestion_summary">使用前一个单词来改进建议</string>
<!-- Array of prediction modes -->
<string-array name="prediction_modes">
<item></item>

View File

@@ -1 +1 @@
org.gradle.jvmargs=-Xmx1024m
org.gradle.jvmargs=-Xmx1536m

View File

@@ -0,0 +1 @@
org.gradle.jvmargs=-Xmx1536m

View File

@@ -1 +1 @@
org.gradle.jvmargs=-Xmx1024m
org.gradle.jvmargs=-Xmx1536m

View File

@@ -529,7 +529,7 @@ public abstract class Kp2aFileProvider extends BaseFileProvider {
* parameters.
*/
private MatrixCursor doRetrieveFileInfo(Uri uri) {
Log.d(CLASSNAME, "retrieve file info "+uri.toString());
MatrixCursor matrixCursor = BaseFileProviderUtils.newBaseFileCursor();
String filename = extractFile(uri);

View File

@@ -56,15 +56,15 @@
<string name="afc_title_sort_by">Sortieren nach…</string>
<string name="afc_yesterday">Gestern</string>
<plurals name="afc_title_choose_directories">
<item quantity="one">Verzeichnis wählen&#8230;</item>
<item quantity="one">Ordner wählen …</item>
<item quantity="other">Verzeichnisse wählen&#8230;</item>
</plurals>
<plurals name="afc_title_choose_files">
<item quantity="one">Datei wählen&#8230;</item>
<item quantity="other">Dateien wählen&#8230;</item>
<item quantity="other">Dateien wählen</item>
</plurals>
<plurals name="afc_title_choose_files_directories">
<item quantity="one">Datei/Ordner wählen&#8230;</item>
<item quantity="other">Dateien/Ordner wählen&#8230;</item>
<item quantity="one">Datei/Ordner wählen</item>
<item quantity="other">Dateien/Ordner wählen</item>
</plurals>
</resources>

View File

@@ -1,2 +1,2 @@
org.gradle.jvmargs=-Xmx1024m
org.gradle.jvmargs=-Xmx1536m
android.useAndroidX=true