diff --git a/app/build.gradle b/app/build.gradle
index 8e08895..6bb000c 100644
--- a/app/build.gradle
+++ b/app/build.gradle
@@ -41,6 +41,7 @@ dependencies {
implementation 'com.android.support.constraint:constraint-layout:1.1.2'
implementation 'com.android.support:design:28.0.0-rc01'
+ implementation 'com.android.support:appcompat-v7:28.0.0-rc02'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'androidx.test:runner:1.1.0-alpha4'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.1.0-alpha4'
diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml
index 70a77f6..0d7ee91 100644
--- a/app/src/main/AndroidManifest.xml
+++ b/app/src/main/AndroidManifest.xml
@@ -16,20 +16,20 @@
android:supportsRtl="true"
android:theme="@style/AppTheme"
tools:ignore="GoogleAppIndexingWarning">
-
-
+
-
+
+
+
+
+
\ No newline at end of file
diff --git a/app/src/main/java/eu/depau/etchdroid/activities/ErrorActivity.kt b/app/src/main/java/eu/depau/etchdroid/activities/ErrorActivity.kt
new file mode 100644
index 0000000..8462d5d
--- /dev/null
+++ b/app/src/main/java/eu/depau/etchdroid/activities/ErrorActivity.kt
@@ -0,0 +1,21 @@
+package eu.depau.etchdroid.activities
+
+import android.os.Bundle
+import androidx.appcompat.app.AppCompatActivity
+import eu.depau.etchdroid.R
+import kotlinx.android.synthetic.main.activity_error.*
+
+class ErrorActivity : AppCompatActivity() {
+
+ override fun onCreate(savedInstanceState: Bundle?) {
+ super.onCreate(savedInstanceState)
+ setContentView(R.layout.activity_error)
+ val msg = intent.getStringExtra("error")
+ error_message.text = msg
+
+ if ("errno 88" in msg)
+ troubleshooting_info.text = getString(R.string.troubleshoot_sock_op_on_non_sock)
+ else
+ troubleshooting_info.text = getString(R.string.unknown_error)
+ }
+}
diff --git a/app/src/main/java/eu/depau/etchdroid/services/UsbApiWriteService.kt b/app/src/main/java/eu/depau/etchdroid/services/UsbApiWriteService.kt
index 3edb8cd..cb3b091 100644
--- a/app/src/main/java/eu/depau/etchdroid/services/UsbApiWriteService.kt
+++ b/app/src/main/java/eu/depau/etchdroid/services/UsbApiWriteService.kt
@@ -101,9 +101,9 @@ abstract class UsbApiWriteService(name: String) : UsbWriteService(name) {
try {
writtenBytes = writeInputStream(inputStream, msDev, sendProgress)
- resultNotification(usbDevice.name, uri.getFileName(this)!!, true, writtenBytes, startTime)
+ resultNotification(usbDevice.name, uri.getFileName(this)!!, null, writtenBytes, startTime)
} catch (e: Exception) {
- resultNotification(usbDevice.name, uri.getFileName(this)!!, false, writtenBytes, startTime)
+ resultNotification(usbDevice.name, uri.getFileName(this)!!, e, writtenBytes, startTime)
Log.e(TAG, "Could't write image to ${usbDevice.name}")
throw e
} finally {
diff --git a/app/src/main/java/eu/depau/etchdroid/services/UsbWriteService.kt b/app/src/main/java/eu/depau/etchdroid/services/UsbWriteService.kt
index e92ab22..9f2e0e8 100644
--- a/app/src/main/java/eu/depau/etchdroid/services/UsbWriteService.kt
+++ b/app/src/main/java/eu/depau/etchdroid/services/UsbWriteService.kt
@@ -1,15 +1,13 @@
package eu.depau.etchdroid.services
-import android.app.IntentService
-import android.app.Notification
-import android.app.NotificationChannel
-import android.app.NotificationManager
+import android.app.*
import android.content.Context
import android.content.Intent
import android.os.Build
import android.os.PowerManager
import androidx.core.app.NotificationCompat
import eu.depau.etchdroid.R
+import eu.depau.etchdroid.activities.ErrorActivity
import eu.depau.etchdroid.kotlin_exts.toHRSize
import eu.depau.etchdroid.kotlin_exts.toHRTime
import java.util.*
@@ -89,7 +87,7 @@ abstract class UsbWriteService(name: String) : IntentService(name) {
notificationManager.notify(FOREGROUND_ID, buildForegroundNotification(usbDevice, filename, progr, "$progr% • $speed/s"))
}
- fun resultNotification(usbDevice: String, filename: String, success: Boolean, bytes: Long = 0, startTime: Long = 0) {
+ fun resultNotification(usbDevice: String, filename: String, exception: Throwable?, bytes: Long = 0, startTime: Long = 0) {
val notificationManager = getSystemService(NOTIFICATION_SERVICE) as NotificationManager
val b = getNotificationBuilder(WRITE_RESULT_CHANNEL_ID)
@@ -97,11 +95,18 @@ abstract class UsbWriteService(name: String) : IntentService(name) {
val dt = System.currentTimeMillis() - startTime
- if (!success)
- b.setContentTitle(getString(R.string.write_failed))
+ if (exception != null) {
+ val intent = Intent(this, ErrorActivity::class.java)
+ intent.flags = Intent.FLAG_ACTIVITY_NEW_TASK or Intent.FLAG_ACTIVITY_CLEAR_TASK
+ intent.putExtra("error", exception.message)
+ val pendingIntent = PendingIntent.getActivity(this, 0, intent, PendingIntent.FLAG_UPDATE_CURRENT)
+
+ b.setContentTitle(getString(R.string.write_failed_tap_for_info))
.setContentText(getString(R.string.error_notif_content_text, usbDevice))
+ .setContentIntent(pendingIntent)
+ .setAutoCancel(true)
.setSubText(dt.toHRTime())
- else {
+ } else {
val speed = max(bytes.toDouble() / dt.toDouble() * 1000, 0.0).toHRSize() + "/s"
b.setContentTitle(getString(R.string.write_finished))
.setContentText(getString(R.string.success_notif_content_text, filename, usbDevice))
diff --git a/app/src/main/res/layout/activity_error.xml b/app/src/main/res/layout/activity_error.xml
new file mode 100644
index 0000000..64f6b8d
--- /dev/null
+++ b/app/src/main/res/layout/activity_error.xml
@@ -0,0 +1,74 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/app/src/main/res/values-it/strings.xml b/app/src/main/res/values-it/strings.xml
index 0fd3533..7232e62 100644
--- a/app/src/main/res/values-it/strings.xml
+++ b/app/src/main/res/values-it/strings.xml
@@ -91,8 +91,15 @@
Selettore file DMG
Utilizzato per mostrare il risultato di un\'operazione di scrittura terminata
Risultati scrittura USB
- Scrittura fallita
+ Scrittura fallita • Tocca per i dettagli
Scrittura terminata
%1$s potrebbe essere stato rimosso durante la scrittura.
%1$s scritto con successo su %2$s
+ Risoluzione dei problemi
+ L\'operazione non è stata completata a causa del seguente errore:
+ Questo è un errore comune. In genere succede quando il dispositivo USB viene scollegato mentre è in corso una scrittura o quando è connesso attraverso un hub USB. Su qualche dispositivo, invece, è presente un problema nel sottosistema USB di Android: solitamente un riavvio lo risolve per un po\' di tempo.\n\nProva questi suggerimenti:\n• Stacca e riattacca il dispositivo USB, quindi riavvia l\'app\n• Riavvia il dispositivo (davvero, fallo)\n• Prova un\'altro dispositivo USB\n• Evita di usare adattatori o hub se non necessari\n• Evita di usare il telefono mentre sta scrivendo immagini\n• Sostituisci un adattatore USB On-The-Go difettoso
+ Segnalazione dei problemi
+ I problemi possono essere segnalati su GitHub:\nhttps://github.com/Depau/EtchDroid/issues
+ Scrittura fallita
+ Errore sconosciuto. Prova a ricollegare il dispositivo USB o a riavviare il dispositivo. Per favore, segnala il problema su GitHub.
\ No newline at end of file
diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml
index adb917e..3d68c14 100644
--- a/app/src/main/res/values/strings.xml
+++ b/app/src/main/res/values/strings.xml
@@ -90,8 +90,15 @@
DMG file selector
Used to display the result of a finished write operation
USB write result notifications
- Write failed
+ Write failed • Tap for info
Write finished
%1$s may have been unplugged while writing.
%1$s successfully written to %2$s
+ Troubleshooting information
+ The operation could not be completed because the following error occurred:
+ This is a common error. Usually this happens when the USB drive is unplugged while it\'s being written to, or when it\'s connected through a USB hub. On some devices there might be a bug in Android\'s USB subsystem: usually a reboot will fix it for some time. \n\nTry these:\n• Unplug and re-plug the USB device, then restart the app\n• Reboot your device (really, try it)\n• Try another USB drive\n• Avoid using unnecessary adapters, dongles or hubs\n• Avoid using your phone while it\'s writing\n• Replace defective USB On-The-Go adapters\n\nIf the problem persists, please file an issue on GitHub.
+ Reporting issues
+ Issues can be reported on GitHub:\nhttps://github.com/Depau/EtchDroid/issues
+ Write failed
+ Unknown error. Try to reattach the USB drive or reboot the device. Please file an issue on GitHub.