Gradle runs a build script's plugins {} block before the rest of the
script, so the flavor property set in app/build.gradle.kts was only seen
by the next build in the same daemon. A fresh daemon skipped the Sentry
plugin and then failed configuring the missing 'sentry' extension; a
FOSS build after a GPlay one got the Google plugins. Set it in
settings.gradle.kts, which is evaluated before any project script.
R8 merges classes and rewrites line numbers even with -dontobfuscate,
and no mapping ever reached Sentry, so release stack traces showed
merged class names (IntentKt.safeParcelableExtra as
coil.size.Dimension.safeParcelableExtra) and R8 line positions.
Apply the Sentry Android Gradle plugin for mapping upload only (no
bytecode instrumentation, no auto-installed dependencies). The mapping
UUID is always embedded; the upload runs when SENTRY_AUTH_TOKEN is set,
which the release lanes now require.
Dual SD/microSD readers expose one LUN per slot. With the card in the
second slot LUN 0 has no medium, so the job failed with NoMediumException
although there was exactly one usable medium. Fall back to it when it's
the only one.
b263ffa dropped FLAG_GRANT_READ_URI_PERMISSION from every intent. For
images opened via ACTION_VIEW, whose grants can't be persisted, the
grant then dies with the receiving activity, and the worker's later
reads (e.g. the verify pass after the task is swiped away) fail.
Grant it again on the job start intent only, and only while we still
hold it: granting a permission we lost throws SecurityException.
The image URI was only readable through temporary grants tied to the
activity that received it, so screens created later (progress screen
reopened from the notification, activities restored after process death)
could lose access. getDisplayName only caught SecurityException, so a
removed volume ("No root for ...") crashed MainActivity and
ProgressActivity, and the progress screen re-queried the provider and
sent an error event on every recomposition.
Take a persistable read grant for picked documents, treat any query
failure in getDisplayName as non-fatal (fall back to the URI path, log a
breadcrumb instead of an error event), query the name once per URI on
the progress screen, and refuse to open or confirm an image the provider
no longer lets us read, with a "Could not open the source file" toast.
ETCHDROID-AE (startActivity granting a URI we no longer held) was fixed
by b263ffa, which dropped FLAG_GRANT_READ_URI_PERMISSION; the confirm
screen now also handles the stale URI it can receive.
Fixes ETCHDROID-B0
Fixes ETCHDROID-BA
Fixes ETCHDROID-DD
Fixes ETCHDROID-D5
Fixes ETCHDROID-D6
Fixes ETCHDROID-D7
Fixes ETCHDROID-BN
Fixes ETCHDROID-AE
Fixes ETCHDROID-7S
Fixes ETCHDROID-DF
Fixes ETCHDROID-D8
WorkerService already captures every error it broadcasts. The progress
screen captured the parcelled copy again, doubling every job error and
splitting it into a second issue with a mangled stack (culprit
ProgressActivity), also on each intent re-delivery.
Card readers without a card (or dead drives) fail TEST UNIT READY with
"medium not present"; init() skips such LUNs, leaving blockDevices
without LUN 0, so `blockDevices[0]!!` threw a bare NullPointerException
that surfaced as "InitException: Initialization failed".
Throw a recoverable NoMediumException that tells the user to insert a
card instead.
Fixes ETCHDROID-A4
Fixes ETCHDROID-AJ
A cancelled job (service destroyed) surfaced as JobCancellationException,
which the job handler wrapped into UnknownException (and verifyImage's
close into UsbCommunicationException), so it was broadcast as an error
and sent to Sentry, defeating the CancellationException filter. Rethrow
cancellation instead, and release the USB device in NonCancellable.
libaums transfer failures (MAX_RECOVERY_ATTEMPTS IOException caused by
PipeException/libusb errors) reaching the job handler unwrapped (e.g.
via the stream close in a finally) were reported as UnknownException.
Map them to UsbCommunicationException by cause type.
Drop the "Verification failed" captureMessage: it carries nothing the
VerificationFailedException event doesn't and doubled every report.
Fixes ETCHDROID-A6
Fixes ETCHDROID-CH
Fixes ETCHDROID-B2
Fixes ETCHDROID-9W
Fixes ETCHDROID-17
Fixes ETCHDROID-A1
ConfirmOperationActivity requests permission with an immutable PendingIntent,
so its USB_PERMISSION broadcast carries no device; a ProgressActivity still
alive in the background received it too and crashed on `intent.usbDevice!!`.
Ignore broadcasts without a device.
The auto-restarter stays registered while the progress screen is
backgrounded, so a granted permission could start WorkerService from the
background, which Android 12+ forbids. Defer the start until the activity is
started again.
UsbManager.requestPermission can throw "package not found" from the system
(e.g. secondary users/profiles); catch it and tell the user instead.
Fixes ETCHDROID-AF
Fixes ETCHDROID-7M
Fixes ETCHDROID-BF
Devices without DocumentsUI (TV boxes, some OEM ROMs) have no handler
for ACTION_OPEN_DOCUMENT, so launching the picker threw
ActivityNotFoundException. Fall back to ACTION_GET_CONTENT and show a
toast if no picker exists at all.
getDisplayName() only caught SecurityException, but the remote document
provider can throw anything across the binder; a ZTE provider threw
IllegalArgumentException ("You must pass a valid uri and observer")
from query() while handling the picker result. Catch all exceptions and
fall back to the URI path.
Fixes ETCHDROID-D4
Fixes ETCHDROID-BJ
isEnvironmentalFault() returned true for any RecoverableException in the
chain, but the worker wraps every failure into InitException /
UsbCommunicationException, so NPEs, IllegalArgumentExceptions and
coroutine cancellations were tagged recoverable and hidden as warnings.
Return false when the chain contains a programming error.
Fixes ETCHDROID-A4
Fixes ETCHDROID-AJ
Fixes ETCHDROID-9Y
Fixes ETCHDROID-Z
Fixes ETCHDROID-9Z
Fixes ETCHDROID-AX
Fixes ETCHDROID-CH
The API 33 typed getParcelableExtra NPEs in readParcelableCreatorInternal;
every read was caught and reported as a handled event. Use IntentCompat,
which only calls the typed overload on API 34+.
Fixes ETCHDROID-A9
Fixes ETCHDROID-9X
Google Play's Payments policy forbids linking to pages that eventually
lead to donations. On Play builds, hide the donate buttons, unlink
depau.eu and open the website with ?gplay=1, which hides its donation
links.
GitHub release builds keep them: build with -Petchdroid.githubRelease.
Job updates are not replayed, so a progress screen that only listens
while resumed misses everything that happens while the user is in a
system dialog or another app -- including FINISHED. Nothing re-syncs
state on the way back, so the screen went on claiming the write was
still running long after it had completed, with no way forward.
Writes take minutes, so leaving the app during one is ordinary. Register
the receiver for the life of the activity instead.
onPause unregisters the progress receiver, but the silence watchdog kept
running, so any time away from the progress screen longer than
LAST_NOTIFICATION_TIMEOUT was read as the service having died and raised
a fatal error on a job that was writing perfectly well.
A system permission dialog, the notification settings screen, or simply
leaving the app during a long write all trip it -- writes take minutes,
so backgrounding is normal. In CI it is reliably fatal: the notification
tests spend more than 11s in the system permission dialog.
Only run the watchdog while the screen is actually receiving updates,
and restart its countdown on the way back in.
release the USB device before broadcasting errors; never leak connections;
reject concurrent jobs
a job started while another holds the drive steals the USB interface claim
(USBDEVFS_DISCONNECT_CLAIM), killing the other's transfers; failed inits
leaked claimed connections, making recovery permanently impossible (#449).