Merge changes Iaa09cb74,I59376805 into main
* changes:
Revise error activity's guide
Increase timeout for ttyd, and make it interrupt-aware
diff --git a/android/TerminalApp/java/com/android/virtualization/terminal/MainActivity.java b/android/TerminalApp/java/com/android/virtualization/terminal/MainActivity.java
index 624d6ca..316c8c4 100644
--- a/android/TerminalApp/java/com/android/virtualization/terminal/MainActivity.java
+++ b/android/TerminalApp/java/com/android/virtualization/terminal/MainActivity.java
@@ -77,7 +77,7 @@
static final String KEY_DISK_SIZE = "disk_size";
private static final String VM_ADDR = "192.168.0.2";
private static final int TTYD_PORT = 7681;
- private static final int TERMINAL_CONNECTION_TIMEOUT_MS = 10_000;
+ private static final int TERMINAL_CONNECTION_TIMEOUT_MS = 20_000;
private static final int REQUEST_CODE_INSTALLER = 0x33;
private static final int FONT_SIZE_DEFAULT = 13;
@@ -348,14 +348,18 @@
} catch (UnknownHostException e) {
// this can never happen.
}
-
long startTime = SystemClock.elapsedRealtime();
while (true) {
int remainingTime =
TERMINAL_CONNECTION_TIMEOUT_MS
- (int) (SystemClock.elapsedRealtime() - startTime);
+
+ if (Thread.interrupted()) {
+ Log.d(TAG, "the waiting thread is interrupted");
+ return;
+ }
if (remainingTime <= 0) {
- throw new RuntimeException("Connection to terminal timedout");
+ throw new RuntimeException("Connection to terminal timeout");
}
try {
// Note: this quits immediately if VM is unreachable.
diff --git a/android/TerminalApp/res/values/strings.xml b/android/TerminalApp/res/values/strings.xml
index 9cb6e4d..6e06b88 100644
--- a/android/TerminalApp/res/values/strings.xml
+++ b/android/TerminalApp/res/values/strings.xml
@@ -142,7 +142,7 @@
<!-- Error page that shows error page [CHAR LIMIT=none] -->
<string name="error_title">Unrecoverable error</string>
<!-- Error page that shows error page [CHAR LIMIT=none] -->
- <string name="error_desc">Failed to recover from an error.\nYou can try restarting terminal or try one of the recovery options.</string>
+ <string name="error_desc">Failed to recover from an error.\nYou can try restarting terminal or try one of the recovery options.\nIf all attempts fail, wipe all data by turning on/off Linux terminal from developer options."</string>
<!-- Error page that shows detailed error code (error reason) for bugreport. [CHAR LIMIT=none] -->
<string name="error_code">Error code: <xliff:g id="error_code" example="ACCESS_DENIED">%s</xliff:g></string>